Skip to content

Commit

Permalink
Merge pull request #12 from firleju/master
Browse files Browse the repository at this point in the history
EU07_475
  • Loading branch information
firleju committed May 24, 2016
2 parents 024eea0 + 4bd94da commit 6509cc1
Show file tree
Hide file tree
Showing 174 changed files with 21,805 additions and 5,469 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,15 @@ install_manifest.txt
*.~h
*.~bpr
*.~pas
*.opensdf
*.sdf
*.sln
*.vcxproj
*.filters
format_all_files.py
MaSzyna.opensdf
MaSzyna.sdf
MaSzyna.sln
MaSzyna.vcxproj
MaSzyna.vcxproj.filters
*.suo
7 changes: 4 additions & 3 deletions AnimModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ obtain one at
//---------------------------------------------------------------------------

TAnimAdvanced::TAnimAdvanced(){};

TAnimAdvanced::~TAnimAdvanced(){
// delete[] pVocaloidMotionData; //plik został zmodyfikowany
};
Expand Down Expand Up @@ -530,7 +531,7 @@ bool TAnimModel::Load(cParser *parser, bool ter)
return true;
}

TAnimContainer *__fastcall TAnimModel::AddContainer(char *pName)
TAnimContainer * TAnimModel::AddContainer(char *pName)
{ // dodanie sterowania submodelem dla egzemplarza
if (!pModel)
return NULL;
Expand All @@ -546,7 +547,7 @@ TAnimContainer *__fastcall TAnimModel::AddContainer(char *pName)
return NULL;
}

TAnimContainer *__fastcall TAnimModel::GetContainer(char *pName)
TAnimContainer * TAnimModel::GetContainer(char *pName)
{ // szukanie/dodanie sterowania submodelem dla egzemplarza
if (!pName)
return pRoot; // pobranie pierwszego (dla obrotnicy)
Expand Down Expand Up @@ -690,7 +691,7 @@ int TAnimModel::TerrainCount()
{ // zliczanie kwadratów kilometrowych (główna linia po Next) do tworznia tablicy
return pModel ? pModel->TerrainCount() : 0;
};
TSubModel *__fastcall TAnimModel::TerrainSquare(int n)
TSubModel * TAnimModel::TerrainSquare(int n)
{ // pobieranie wskaźników do pierwszego submodelu
return pModel ? pModel->TerrainSquare(n) : 0;
};
Expand Down
10 changes: 5 additions & 5 deletions AnimModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class TAnimContainer
// std::string(pSubModel?pSubModel->asName.c_str():""); };
// std::string inline GetName() { return std::string(pSubModel?pSubModel->pName:"");
// };
char *__fastcall NameGet()
char * NameGet()
{
return (pSubModel ? pSubModel->pName : NULL);
};
Expand All @@ -107,7 +107,7 @@ class TAnimContainer
pSubModel->WillBeAnimated();
};
void EventAssign(TEvent *ev);
TEvent *__fastcall Event()
TEvent * Event()
{
return evDone;
};
Expand Down Expand Up @@ -156,8 +156,8 @@ class TAnimModel
bool Init(TModel3d *pNewModel);
bool Init(AnsiString asName, AnsiString asReplacableTexture);
bool Load(cParser *parser, bool ter = false);
TAnimContainer *__fastcall AddContainer(char *pName);
TAnimContainer *__fastcall GetContainer(char *pName);
TAnimContainer * AddContainer(char *pName);
TAnimContainer * GetContainer(char *pName);
void RenderDL(vector3 pPosition = vector3(0, 0, 0), double fAngle = 0);
void RenderAlphaDL(vector3 pPosition = vector3(0, 0, 0), double fAngle = 0);
void RenderVBO(vector3 pPosition = vector3(0, 0, 0), double fAngle = 0);
Expand All @@ -175,7 +175,7 @@ class TAnimModel
};
bool TerrainLoaded();
int TerrainCount();
TSubModel *__fastcall TerrainSquare(int n);
TSubModel * TerrainSquare(int n);
void TerrainRenderVBO(int n);
void AnimationVND(void *pData, double a, double b, double c, double d);
void LightSet(int n, float v);
Expand Down
12 changes: 10 additions & 2 deletions Button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ obtain one at
TButton::TButton()
{
iFeedbackBit = 0;
bData = NULL;
Clear();
};

Expand Down Expand Up @@ -54,8 +55,8 @@ void TButton::Load(TQueryParserComp *Parser, TModel3d *pModel1, TModel3d *pModel
Init(str, pModel1, false);
if (pModel2)
if (!pModelOn && !pModelOff)
Init(str, pModel2,
false); // mo¿e w drugim bêdzie (jak nie w kabinie, to w zewnêtrznym)
Init(str, pModel2, false); // mo¿e w drugim bêdzie (jak nie w kabinie,
// to w zewnêtrznym)
}
else
{
Expand All @@ -66,6 +67,8 @@ void TButton::Load(TQueryParserComp *Parser, TModel3d *pModel1, TModel3d *pModel

void TButton::Update()
{
if (bData != NULL)
bOn = (*bData);
if (pModelOn)
pModelOn->iVisible = bOn;
if (pModelOff)
Expand All @@ -78,3 +81,8 @@ void TButton::Update()
Console::BitsClear(iFeedbackBit);
}
};

void TButton::AssignBool(bool *bValue)
{
bData = bValue;
}
7 changes: 5 additions & 2 deletions Button.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ obtain one at
#include "QueryParserComp.hpp"

class TButton
{ // animacja dwustanowa, w³¹cza jeden z dwóch submodeli (jednego z nich mo¿e nie byæ)
{ // animacja dwustanowa, w³¹cza jeden z dwóch submodeli (jednego
// z nich mo¿e nie byæ)
private:
TSubModel *pModelOn, *pModelOff; // submodel dla stanu za³¹czonego i wy³¹czonego
bool bOn;
bool *bData;
int iFeedbackBit; // Ra: bit informacji zwrotnej, do wyprowadzenia na pulpit
void Update();

public:
TButton();
Expand Down Expand Up @@ -53,8 +54,10 @@ class TButton
{
return (pModelOn) || (pModelOff);
};
void Update();
void Init(AnsiString asName, TModel3d *pModel, bool bNewOn = false);
void Load(TQueryParserComp *Parser, TModel3d *pModel1, TModel3d *pModel2 = NULL);
void AssignBool(bool *bValue);
};

//---------------------------------------------------------------------------
Expand Down
8 changes: 5 additions & 3 deletions Classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ typedef enum
{ // binarne odpowiedniki komend w komórce pamiêci
cm_Unknown, // ci¹g nierozpoznany (nie jest komend¹)
cm_Ready, // W4 zezwala na odjazd, ale semafor mo¿e zatrzymaæ
cm_SetVelocity,
cm_ShuntVelocity,
cm_SetProximityVelocity,
cm_SetVelocity, // prêdkoœæ poci¹gowa zadawana na semaforze
cm_RoadVelocity, // prêdkoœæ drogowa
cm_SectionVelocity, //ograniczenie prêdkoœci na odcinku
cm_ShuntVelocity, // prêdkoœæ manewrowa na semaforze
cm_SetProximityVelocity, // informacja wstêpna o ograniczeniu
cm_ChangeDirection,
cm_PassengerStopPoint,
cm_OutsideStation,
Expand Down
56 changes: 48 additions & 8 deletions Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ void Console::BitsSet(int mask, int entry)
int old = iBits; // poprzednie stany
iBits |= mask;
BitsUpdate(old ^ iBits); // 1 dla bitów zmienionych
if (iMode == 4)
WriteLog("PoKeys::BitsSet: mask: " + AnsiString(mask) + " iBits: " + AnsiString(iBits));
}
};

Expand Down Expand Up @@ -269,26 +271,52 @@ void Console::BitsUpdate(int mask)
PoKeys55[0]->Write(0x40, 52 - 1, iBits & 0x1000 ? 1 : 0);
if (mask & 0x2000) // b13 Prąd na silnikach do odbijania w haslerze
PoKeys55[0]->Write(0x40, 53 - 1, iBits & 0x2000 ? 1 : 0);
}
if (mask & 0x4000) // b14 Brzęczyk SHP lub CA
PoKeys55[0]->Write(0x40, 16 - 1, iBits & 0x4000 ? 1 : 0);
}
break;
}
};

bool Console::Pressed(int x)
{
{ // na razie tak - czyta się tylko klawiatura
return Global::bActive && (GetKeyState(x) < 0);
}; // na razie tak - czyta się tylko klawiatura
};

void Console::ValueSet(int x, double y)
{ // ustawienie wartości (y) na kanale analogowym (x)
if (iMode == 4)
if (PoKeys55[0])
{
PoKeys55[0]->PWM(
x, (((Global::fCalibrateOut[x][3] * y) + Global::fCalibrateOut[x][2]) * y +
Global::fCalibrateOut[x][1]) *
y +
Global::fCalibrateOut[x][0]); // zakres <0;1>
//if (x == 7)
//{
// PoKeys55[0]->PoExtUpdate(8, y);
//} // nbmx: wal kulakowy
//else
//{
if (Global::iCalibrateOutDebugInfo == x)
WriteLog("CalibrateOutDebugInfo: oryginal=" + AnsiString(y), false);
if (Global::fCalibrateOutMax[x] > 0)
{
y = Global::CutValueToRange(0, y, Global::fCalibrateOutMax[x]);
if (Global::iCalibrateOutDebugInfo == x)
WriteLog(" cutted=" + AnsiString(y),false);
y = y / Global::fCalibrateOutMax[x]; // sprowadzenie do <0,1> jeśli podana maksymalna wartość
if (Global::iCalibrateOutDebugInfo == x)
WriteLog(" fraction=" + AnsiString(y),false);
}
double temp = (((((Global::fCalibrateOut[x][5] * y) + Global::fCalibrateOut[x][4]) * y +
Global::fCalibrateOut[x][3]) * y + Global::fCalibrateOut[x][2]) * y +
Global::fCalibrateOut[x][1]) * y +
Global::fCalibrateOut[x][0]; // zakres <0;1>
if (Global::iCalibrateOutDebugInfo == x)
WriteLog(" calibrated=" + AnsiString(temp));
PoKeys55[0]->PWM(x, temp);
//if (x == 6)
//{
// PoKeys55[0]->PoExtUpdate(9, temp); //dodatkowo hasler na PoExt
//}
//}
}
};

Expand Down Expand Up @@ -317,6 +345,18 @@ float Console::AnalogGet(int x)
return -1.0;
};

float Console::AnalogCalibrateGet(int x)
{ // pobranie i kalibracja wartości analogowej, jeśli nie ma PoKeys zwraca NULL
if (iMode == 4 && PoKeys55[0])
{
float b = PoKeys55[0]->fAnalog[x];
return (((((Global::fCalibrateIn[x][5] * b) + Global::fCalibrateIn[x][4]) * b +
Global::fCalibrateIn[x][3]) * b + Global::fCalibrateIn[x][2]) * b +
Global::fCalibrateIn[x][1]) *b + Global::fCalibrateIn[x][0];
}
return -1.0; //odcięcie
};

unsigned char Console::DigitalGet(int x)
{ // pobranie wartości cyfrowej
if (iMode == 4)
Expand Down
1 change: 1 addition & 0 deletions Console.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Console
static void ValueSet(int x, double y);
static void Update();
static float AnalogGet(int x);
static float AnalogCalibrateGet(int x);
static unsigned char DigitalGet(int x);
static void OnKeyDown(int k);
static void OnKeyUp(int k);
Expand Down
4 changes: 2 additions & 2 deletions Console/LPT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ bool TLPT::Connect(int port)
};

void TLPT::Out(int x)
{
{ // wys³anie bajtu do portu
OutPort(address, x);
}; // wys³anie bajtu do portu
};
43 changes: 40 additions & 3 deletions Console/PoKeys55.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ TPoKeys55::TPoKeys55()
fAnalog[0] = fAnalog[1] = fAnalog[2] = fAnalog[3] = fAnalog[4] = fAnalog[5] = fAnalog[6] = -1.0;
iPWM[0] = iPWM[1] = iPWM[2] = iPWM[3] = iPWM[4] = iPWM[5] = iPWM[6] = 0;
iPWM[7] = 4096;
iInputs[0] = 0; // czy normalnie s¹ w stanie wysokim?
PoExt[0] = PoExt[1] = PoExt[2] = PoExt[3] = PoExt[4] = PoExt[5] = PoExt[6] = PoExt[7] = PoExt[8] = PoExt[9] = PoExt[10] = 0;
iInputs[0] = 0; // czy normalnie s¹ w stanie wysokim?
iRepeats = 0;
bNoError = true;
};
Expand Down Expand Up @@ -229,6 +230,30 @@ bool TPoKeys55::Write(unsigned char c, unsigned char b3, unsigned char b4, unsig
return (BytesWritten == 65);
// Read(); //odczyt trzeba zrobiæ inaczej - w tym miejscu bêdzie za szybko i nic siê nie odczyta
}

bool TPoKeys55::PoExtWrite(unsigned char *c)
{
DWORD BytesWritten = 0;
OutputBuffer[0] = 0; //The first byte is the "Report ID" and does not get transmitted over the USB bus. Always set=0.
OutputBuffer[1] = 0xBB; //0xBB - bajt rozpoznawczy dla PoKeys55
OutputBuffer[2] = iLastCommand = 0xDA; //operacja: 0xDA PoExt
OutputBuffer[3] = 1; //1 = enable PoExt
OutputBuffer[4] = 0; // Connector selection 0: dedicated , 1: normal pins
OutputBuffer[5] = 0;
OutputBuffer[6] = 0;
OutputBuffer[7] = ++cRequest; //numer ¿¹dania
OutputBuffer[8] = 0;
for (int i = 0; i<10; ++i)
OutputBuffer[9 + i] = c[i];
for (int i = 0; i<8; ++i)
OutputBuffer[8] += OutputBuffer[i]; //czy sumowaæ te¿ od 9 do 64?
//The basic Windows I/O functions WriteFile() and ReadFile() can be used to read and write to HID class USB devices
//(once we have the read and write handles to the device, which are obtained with CreateFile()).
//The following call to WriteFile() sends 64 bytes of data to the USB device.
WriteFile(WriteHandle, &OutputBuffer, 65, &BytesWritten, 0); //Blocking function, unless an "overlapped" structure is used
return (BytesWritten == 65);
//Read(); //odczyt trzeba zrobiæ inaczej - w tym miejscu bêdzie za szybko i nic siê nie odczyta
}
//---------------------------------------------------------------------------

bool TPoKeys55::Read()
Expand Down Expand Up @@ -297,6 +322,13 @@ bool TPoKeys55::PWM(int x, float y)
return true;
}

bool TPoKeys55::PoExtUpdate(int x, char y)
{//ustawienie wskazanego PWM (@12Mhz: 12000=1ms=1000Hz)
//iPWM[7]=1024; //1024==85333.3333333333ns=11718.75Hz
PoExt[x] = y & 0x0FF; //0x0FF=256
return true;
}

bool TPoKeys55::Update(bool pause)
{ // funkcja powinna byæ wywo³ywana regularnie, np. raz w ka¿dej ramce ekranowej
if (pause)
Expand Down Expand Up @@ -353,10 +385,15 @@ bool TPoKeys55::Update(bool pause)
case 3: // ustawienie wyjœæ analogowych, 0..4095 mapowaæ na 0..65520 (<<4)
if (Write(0x41, 43 - 1, (iPWM[6] >> 4), (iPWM[6] << 4))) // wys³anie ustawieñ
iRepeats = 0; // informacja, ¿e posz³o dobrze
iFaza = 0; //++iFaza; //ta faza zosta³a zakoñczona
iFaza = 4; //++iFaza; //ta faza zosta³a zakoñczona
// powinno jeszcze przyjϾ potwierdzenie o kodzie 0x41
break;
default:
case 4: //ustawienie
//if (PoExtWrite(PoExt))
// iRepeats = 0; //informacja, ¿e posz³o dobrze
iFaza = 0; //++iFaza; //ta faza zosta³a zakoñczona
break;
default:
iFaza = 0; // na wypadek, gdyby zb³¹dzi³o po jakichœ zmianach w kodzie
// iRepeats=0;
}
Expand Down
9 changes: 6 additions & 3 deletions Console/PoKeys55.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class TPoKeys55
unsigned char OutputBuffer[65]; // Allocate a memory buffer equal to our endpoint size + 1
unsigned char InputBuffer[65]; // Allocate a memory buffer equal to our endpoint size + 1
int iPWM[8]; // 0-5:wyjœcia PWM,6:analogowe,7:czêstotliwoœc PWM
int iPWMbits;
char PoExt[10];// Wyjscia PoExt
int iPWMbits;
int iLastCommand;
int iFaza;
int iRepeats; // liczba powtórzeñ
Expand All @@ -29,11 +30,13 @@ class TPoKeys55
bool Connect();
bool Close();
bool Write(unsigned char c, unsigned char b3, unsigned char b4 = 0, unsigned char b5 = 0);
bool Read();
bool PoExtWrite(unsigned char *c);
bool Read();
bool ReadLoop(int i);
AnsiString Version();
bool PWM(int x, float y);
bool Update(bool pause);
bool PoExtUpdate(int x, char y);
bool Update(bool pause);
};
//---------------------------------------------------------------------------
#endif
4 changes: 2 additions & 2 deletions Curve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ obtain one at

#include "Curve.h"

__fastcall TCurve::TCurve()
TCurve::TCurve()
{
Values = NULL;
iNumValues = 0;
iNumCols = 0;
}

__fastcall TCurve::~TCurve()
TCurve::~TCurve()
{
for (int i = 0; i < iNumValues; i++)
SafeDelete(Values[i]);
Expand Down
Binary file added Dokumentacja zmiennych Python.docx
Binary file not shown.
Loading

0 comments on commit 6509cc1

Please sign in to comment.