mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 18:39:18 +02:00
Merge branch 'master' of https://github.com/firleju/maszyna
This commit is contained in:
43
Console.cpp
43
Console.cpp
@@ -288,35 +288,24 @@ void Console::ValueSet(int x, double y)
|
|||||||
if (iMode == 4)
|
if (iMode == 4)
|
||||||
if (PoKeys55[0])
|
if (PoKeys55[0])
|
||||||
{
|
{
|
||||||
//if (x == 7)
|
if (Global::iCalibrateOutDebugInfo == x)
|
||||||
//{
|
WriteLog("CalibrateOutDebugInfo: oryginal=" + AnsiString(y), false);
|
||||||
// PoKeys55[0]->PoExtUpdate(8, y);
|
if (Global::fCalibrateOutMax[x] > 0)
|
||||||
//} // nbmx: wal kulakowy
|
{
|
||||||
//else
|
y = Global::CutValueToRange(0, y, Global::fCalibrateOutMax[x]);
|
||||||
//{
|
|
||||||
if (Global::iCalibrateOutDebugInfo == x)
|
if (Global::iCalibrateOutDebugInfo == x)
|
||||||
WriteLog("CalibrateOutDebugInfo: oryginal=" + AnsiString(y), false);
|
WriteLog(" cutted=" + AnsiString(y),false);
|
||||||
if (Global::fCalibrateOutMax[x] > 0)
|
y = y / Global::fCalibrateOutMax[x]; // sprowadzenie do <0,1> jeśli podana maksymalna wartość
|
||||||
{
|
|
||||||
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)
|
if (Global::iCalibrateOutDebugInfo == x)
|
||||||
WriteLog(" calibrated=" + AnsiString(temp));
|
WriteLog(" fraction=" + AnsiString(y),false);
|
||||||
PoKeys55[0]->PWM(x, temp);
|
}
|
||||||
//if (x == 6)
|
double temp = (((((Global::fCalibrateOut[x][5] * y) + Global::fCalibrateOut[x][4]) * y +
|
||||||
//{
|
Global::fCalibrateOut[x][3]) * y + Global::fCalibrateOut[x][2]) * y +
|
||||||
// PoKeys55[0]->PoExtUpdate(9, temp); //dodatkowo hasler na PoExt
|
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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ TPoKeys55::TPoKeys55()
|
|||||||
fAnalog[0] = fAnalog[1] = fAnalog[2] = fAnalog[3] = fAnalog[4] = fAnalog[5] = fAnalog[6] = -1.0;
|
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[0] = iPWM[1] = iPWM[2] = iPWM[3] = iPWM[4] = iPWM[5] = iPWM[6] = 0;
|
||||||
iPWM[7] = 4096;
|
iPWM[7] = 4096;
|
||||||
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?
|
iInputs[0] = 0; // czy normalnie s¹ w stanie wysokim?
|
||||||
iRepeats = 0;
|
iRepeats = 0;
|
||||||
bNoError = true;
|
bNoError = true;
|
||||||
@@ -231,29 +230,6 @@ bool TPoKeys55::Write(unsigned char c, unsigned char b3, unsigned char b4, unsig
|
|||||||
// Read(); //odczyt trzeba zrobiæ inaczej - w tym miejscu bêdzie za szybko i nic siê nie odczyta
|
// 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()
|
bool TPoKeys55::Read()
|
||||||
@@ -322,13 +298,6 @@ bool TPoKeys55::PWM(int x, float y)
|
|||||||
return true;
|
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)
|
bool TPoKeys55::Update(bool pause)
|
||||||
{ // funkcja powinna byæ wywo³ywana regularnie, np. raz w ka¿dej ramce ekranowej
|
{ // funkcja powinna byæ wywo³ywana regularnie, np. raz w ka¿dej ramce ekranowej
|
||||||
if (pause)
|
if (pause)
|
||||||
@@ -385,14 +354,9 @@ bool TPoKeys55::Update(bool pause)
|
|||||||
case 3: // ustawienie wyjœæ analogowych, 0..4095 mapowaæ na 0..65520 (<<4)
|
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ñ
|
if (Write(0x41, 43 - 1, (iPWM[6] >> 4), (iPWM[6] << 4))) // wys³anie ustawieñ
|
||||||
iRepeats = 0; // informacja, ¿e posz³o dobrze
|
iRepeats = 0; // informacja, ¿e posz³o dobrze
|
||||||
iFaza = 4; //++iFaza; //ta faza zosta³a zakoñczona
|
iFaza = 0; //++iFaza; //ta faza zosta³a zakoñczona
|
||||||
// powinno jeszcze przyjϾ potwierdzenie o kodzie 0x41
|
// powinno jeszcze przyjϾ potwierdzenie o kodzie 0x41
|
||||||
break;
|
break;
|
||||||
case 4: //ustawienie
|
|
||||||
//if (PoExtWrite(PoExt))
|
|
||||||
// iRepeats = 0; //informacja, ¿e posz³o dobrze
|
|
||||||
iFaza = 0; //++iFaza; //ta faza zosta³a zakoñczona
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
iFaza = 0; // na wypadek, gdyby zb³¹dzi³o po jakichœ zmianach w kodzie
|
iFaza = 0; // na wypadek, gdyby zb³¹dzi³o po jakichœ zmianach w kodzie
|
||||||
// iRepeats=0;
|
// iRepeats=0;
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ class TPoKeys55
|
|||||||
unsigned char OutputBuffer[65]; // Allocate a memory buffer equal to our endpoint size + 1
|
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
|
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 iPWM[8]; // 0-5:wyjœcia PWM,6:analogowe,7:czêstotliwoœc PWM
|
||||||
char PoExt[10];// Wyjscia PoExt
|
|
||||||
int iPWMbits;
|
int iPWMbits;
|
||||||
int iLastCommand;
|
int iLastCommand;
|
||||||
int iFaza;
|
int iFaza;
|
||||||
@@ -30,12 +29,10 @@ class TPoKeys55
|
|||||||
bool Connect();
|
bool Connect();
|
||||||
bool Close();
|
bool Close();
|
||||||
bool Write(unsigned char c, unsigned char b3, unsigned char b4 = 0, unsigned char b5 = 0);
|
bool Write(unsigned char c, unsigned char b3, unsigned char b4 = 0, unsigned char b5 = 0);
|
||||||
bool PoExtWrite(unsigned char *c);
|
|
||||||
bool Read();
|
bool Read();
|
||||||
bool ReadLoop(int i);
|
bool ReadLoop(int i);
|
||||||
AnsiString Version();
|
AnsiString Version();
|
||||||
bool PWM(int x, float y);
|
bool PWM(int x, float y);
|
||||||
bool PoExtUpdate(int x, char y);
|
|
||||||
bool Update(bool pause);
|
bool Update(bool pause);
|
||||||
};
|
};
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -2800,7 +2800,6 @@ bool TTrain::Update()
|
|||||||
fHCurrent[(mvControlled->TrainType & dt_EZT) ? 0 : 1]); // pierwszy amperomierz; dla
|
fHCurrent[(mvControlled->TrainType & dt_EZT) ? 0 : 1]); // pierwszy amperomierz; dla
|
||||||
// EZT pr¹d ca³kowity
|
// EZT pr¹d ca³kowity
|
||||||
Console::ValueSet(6, fTachoVelocity); ////Ra: prêdkoœæ na pin 43 - wyjœcie
|
Console::ValueSet(6, fTachoVelocity); ////Ra: prêdkoœæ na pin 43 - wyjœcie
|
||||||
Console::ValueSet(7, mvControlled->MainCtrlActualPos + mvControlled->ScndCtrlActualPos); //nbmx: Wal kulakowy
|
|
||||||
/// analogowe (to nie jest PWM);
|
/// analogowe (to nie jest PWM);
|
||||||
/// skakanie zapewnia mechanika
|
/// skakanie zapewnia mechanika
|
||||||
/// napêdu
|
/// napêdu
|
||||||
|
|||||||
Reference in New Issue
Block a user