diff --git a/Console.cpp b/Console.cpp index 33b31275..16b0723d 100644 --- a/Console.cpp +++ b/Console.cpp @@ -288,35 +288,24 @@ void Console::ValueSet(int x, double y) if (iMode == 4) if (PoKeys55[0]) { - //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("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> + WriteLog(" cutted=" + AnsiString(y),false); + y = y / Global::fCalibrateOutMax[x]; // sprowadzenie do <0,1> jeśli podana maksymalna wartość 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 - //} - //} + 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); } }; diff --git a/Console/PoKeys55.cpp b/Console/PoKeys55.cpp index 10aa9cef..bd2c3454 100644 --- a/Console/PoKeys55.cpp +++ b/Console/PoKeys55.cpp @@ -34,7 +34,6 @@ 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; - 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; @@ -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 } -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() @@ -322,13 +298,6 @@ 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) @@ -385,14 +354,9 @@ 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 = 4; //++iFaza; //ta faza została zakończona + iFaza = 0; //++iFaza; //ta faza została zakończona // powinno jeszcze przyjść potwierdzenie o kodzie 0x41 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: iFaza = 0; // na wypadek, gdyby zbłądziło po jakichś zmianach w kodzie // iRepeats=0; diff --git a/Console/PoKeys55.h b/Console/PoKeys55.h index 7b08ac05..44274617 100644 --- a/Console/PoKeys55.h +++ b/Console/PoKeys55.h @@ -16,7 +16,6 @@ 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 - char PoExt[10];// Wyjscia PoExt int iPWMbits; int iLastCommand; int iFaza; @@ -30,12 +29,10 @@ class TPoKeys55 bool Connect(); bool Close(); bool Write(unsigned char c, unsigned char b3, unsigned char b4 = 0, unsigned char b5 = 0); - bool PoExtWrite(unsigned char *c); bool Read(); bool ReadLoop(int i); AnsiString Version(); bool PWM(int x, float y); - bool PoExtUpdate(int x, char y); bool Update(bool pause); }; //--------------------------------------------------------------------------- diff --git a/Train.cpp b/Train.cpp index 538c572c..1e969b67 100644 --- a/Train.cpp +++ b/Train.cpp @@ -2797,7 +2797,6 @@ bool TTrain::Update() fHCurrent[(mvControlled->TrainType & dt_EZT) ? 0 : 1]); // pierwszy amperomierz; dla // EZT prąd całkowity 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); /// skakanie zapewnia mechanika /// napędu