BOOL DevLXV7::LXV7DirectLink(PDeviceDescriptor_t d, BOOL bLinkEnable) { TCHAR szTmp[254]; #define CHANGE_DELAY 10 if(LXV7_iGPSBaudrate ==0) { _stprintf(szTmp, TEXT("$PLXV0,BRGPS,R")); LXV7NMEAddCheckSumStrg(szTmp); d->Com->WriteString(szTmp); Sleep(CHANGE_DELAY); d->Com->WriteString(szTmp); Sleep(CHANGE_DELAY); } if(bLinkEnable) { LockComm(); StartupStore(TEXT("enable LX V7 direct Link %s"), NEWLINE); LXV7_iPDABaudrate = d->Com->GetBaudrate(); _stprintf(szTmp, TEXT("$PLXV0,CONNECTION,W,DIRECT")); LXV7NMEAddCheckSumStrg(szTmp); d->Com->WriteString(szTmp); Sleep(CHANGE_DELAY); if(LXV7_iPDABaudrate != LXV7_iGPSBaudrate) { d->Com->SetBaudrate(LXV7_iGPSBaudrate); StartupStore(TEXT("Set Baudrate %i %s"),LXV7_iGPSBaudrate, NEWLINE); Sleep(CHANGE_DELAY); } Sleep(CHANGE_DELAY); } else { Sleep(CHANGE_DELAY); if(LXV7_iPDABaudrate != LXV7_iGPSBaudrate) { StartupStore(TEXT("Set Baudrate %i %s"),LXV7_iPDABaudrate, NEWLINE); d->Com->SetBaudrate(LXV7_iPDABaudrate); Sleep(CHANGE_DELAY); } StartupStore(TEXT("Return from V7 link %s"), NEWLINE); _stprintf(szTmp, TEXT("$PLXV0,CONNECTION,W,VSEVEN")); LXV7NMEAddCheckSumStrg(szTmp); d->Com->WriteString(szTmp); Sleep(CHANGE_DELAY); UnlockComm(); Sleep(CHANGE_DELAY); } return true; }
BOOL devIsCondor(PDeviceDescriptor_t d) { BOOL result = FALSE; LockComm(); if ((d != NULL) && (d->IsCondor != NULL)) result = d->IsCondor(d); UnlockComm(); return result; }
BOOL devIsBaroSource(PDeviceDescriptor_t d) { BOOL result = FALSE; LockComm(); if ((d != NULL) && (d->IsBaroSource != NULL)) result = d->IsBaroSource(d); UnlockComm(); return result; }
BOOL PVCOMRequestAllData(PDeviceDescriptor_t d) { TCHAR szTmp[255]; _stprintf(szTmp, TEXT("$PVCOM,R,ALL")); PVCOMNMEAddCheckSumStrg(szTmp); LockComm(); if(d != NULL) if(!d->Disabled) if (d->Com) d->Com->WriteString(szTmp); UnlockComm(); return(TRUE); }
BOOL devPutBallast(PDeviceDescriptor_t d, double Ballast) { BOOL result = TRUE; if (SIMMODE) return TRUE; LockComm(); if (d != NULL && d->PutBallast != NULL) result = d->PutBallast(d, Ballast); UnlockComm(); return result; }
BOOL devPutMacCready(PDeviceDescriptor_t d, double MacCready) { BOOL result = TRUE; if (SIMMODE) return TRUE; LockComm(); if (d != NULL && d->PutMacCready != NULL) result = d->PutMacCready(d, MacCready); UnlockComm(); return result; }
BOOL devPutVolume(PDeviceDescriptor_t d, int Volume) { BOOL result = TRUE; if (SIMMODE) return TRUE; LockComm(); if (d != NULL && d->PutVolume != NULL) result = d->PutVolume(d, Volume); UnlockComm(); return result; }
BOOL devPutFreqStandby(PDeviceDescriptor_t d, double Freq) { BOOL result = TRUE; if (SIMMODE) return TRUE; LockComm(); if (d != NULL && d->PutFreqStandby != NULL) result = d->PutFreqStandby(d, Freq); UnlockComm(); return result; }
void devWriteNMEAString(PDeviceDescriptor_t d, const TCHAR *text) { TCHAR tmp[512]; devFormatNMEAString(tmp, 512, text); devDirectLink(d,true); LockComm(); if (d->Com) d->Com->WriteString(tmp); UnlockComm(); devDirectLink(d,false); }
BOOL devPutBugs(PDeviceDescriptor_t d, double Bugs) { BOOL result = TRUE; if (SIMMODE) return TRUE; LockComm(); if (d != NULL && d->PutBugs != NULL) result = d->PutBugs(d, Bugs); UnlockComm(); return result; }
BOOL devIsLogger(PDeviceDescriptor_t d) { bool result = false; LockComm(); if ((d != NULL) && (d->IsLogger != NULL)) { if (d->IsLogger(d)) { result = true; } } if ((d != NULL) && !result) { result |= NMEAParser::PortIsFlarm(d->Port); } UnlockComm(); return result; }
BOOL devPutQNH(DeviceDescriptor_t *d, double NewQNH) { BOOL result = FALSE; LockComm(); if (d == NULL){ for (int i=0; i<NUMDEV; i++){ d = &DeviceList[i]; if (d->PutQNH != NULL) d->PutQNH(d, NewQNH); } result = TRUE; } else { if (d->PutQNH != NULL) result = d->PutQNH(d, NewQNH); } UnlockComm(); return result; }
BOOL devOnSysTicker(DeviceDescriptor_t *d) { BOOL result = FALSE; LockComm(); if (d == NULL){ for (int i=0; i<NUMDEV; i++){ d = &DeviceList[i]; if (d->OnSysTicker != NULL) d->OnSysTicker(d); } result = TRUE; } else { if (d->OnSysTicker != NULL) result = d->OnSysTicker(d); } UnlockComm(); return result; }
BOOL DevLX16xx::LX16xxDirectLink(PDeviceDescriptor_t d, BOOL bLinkEnable) { TCHAR szTmp[254]; if(bLinkEnable) { LockComm(); StartupStore(TEXT("enable LX 16xx direct Link %s"), NEWLINE); _stprintf(szTmp, TEXT("$PFLX0,COLIBRI")); LX16xxNMEAddCheckSumStrg(szTmp); d->Com->WriteString(szTmp); Sleep(100); } else { // exit transfer mode // and return to normal LX16xx communication StartupStore(TEXT("return from LX 16xx link %s"), NEWLINE); _stprintf(szTmp, TEXT("$PFLX0,LX1600")); LX16xxNMEAddCheckSumStrg(szTmp); d->Com->WriteString(szTmp); unsigned long lOldBR = d->Com->GetBaudrate(); /* switch to 4k8 for new Firmware versions of LX1600 */ d->Com->SetBaudrate(4800); Sleep(100); d->Com->WriteString(szTmp); Sleep(100); d->Com->WriteString(szTmp); Sleep(100); /* return to previous original */ d->Com->SetBaudrate(lOldBR); Sleep(100); d->Com->WriteString(szTmp); Sleep(100); d->Com->WriteString(szTmp); Sleep(100); UnlockComm(); } return true; }
BOOL devDeclare(PDeviceDescriptor_t d, Declaration_t *decl, unsigned errBufferLen, TCHAR errBuffer[]) { BOOL result = FALSE; if (SIMMODE) return TRUE; const unsigned BUFF_LEN = 128; TCHAR buffer[BUFF_LEN]; // We must be sure we are not going to attempt task declaration // while a port reset is already in progress. If this happens, a Flarm device will not be Flarm anymore // until a Flarm nmea sentence is parsed again once. // LKTOKEN _@M1400_ = "Task declaration" // LKTOKEN _@M571_ = "START" _sntprintf(buffer, BUFF_LEN, _T("%s: %s..."), gettext(_T("_@M1400_")), gettext(_T("_@M571_"))); CreateProgressDialog(buffer); /***********************************************************/ devDirectLink(d,true); /***********************************************************/ LockComm(); if ((d != NULL) && (d->Declare != NULL)) result = d->Declare(d, decl, errBufferLen, errBuffer); else { if ((d != NULL) && NMEAParser::PortIsFlarm(d->Port)) { result |= FlarmDeclare(d, decl, errBufferLen, errBuffer); } } UnlockComm(); /***********************************************************/ devDirectLink(d,false); /***********************************************************/ CloseProgressDialog(); return result; }
BOOL devLinkTimeout(PDeviceDescriptor_t d) { BOOL result = FALSE; if (SIMMODE) return TRUE; LockComm(); if (d == NULL){ for (int i=0; i<NUMDEV; i++){ d = &DeviceList[i]; if (d->LinkTimeout != NULL) (d->LinkTimeout)(d); } result = TRUE; } else { if (d->LinkTimeout != NULL) result = d->LinkTimeout(d); } UnlockComm(); return result; }
BOOL DevLXV7_EXP::LXV7_EXP_DirectLink(PDeviceDescriptor_t d, BOOL bLinkEnable) { TCHAR szTmp[254]; #define CHANGE_DELAY 10 if(LXV7_EXP_iGPSBaudrate ==0) { _stprintf(szTmp, TEXT("$PLXV0,BRGPS,R")); LXV7_EXPNMEAddCheckSumStrg(szTmp); d->Com->WriteString(szTmp); Poco::Thread::sleep(CHANGE_DELAY); d->Com->WriteString(szTmp); Poco::Thread::sleep(CHANGE_DELAY); } if(bLinkEnable) { LockComm(); #if TESTBENCH StartupStore(TEXT("V7: enable LX V7 direct Link %s"), NEWLINE); #endif LXV7_EXP_iPDABaudrate = d->Com->GetBaudrate(); _stprintf(szTmp, TEXT("$PLXV0,CONNECTION,W,DIRECT")); LXV7_EXPNMEAddCheckSumStrg(szTmp); d->Com->WriteString(szTmp); Poco::Thread::sleep(CHANGE_DELAY); if(LXV7_EXP_iPDABaudrate != LXV7_EXP_iGPSBaudrate) { d->Com->SetBaudrate(LXV7_EXP_iGPSBaudrate); #if TESTBENCH StartupStore(TEXT("V7: Set Baudrate %i %s"),LXV7_EXP_iGPSBaudrate, NEWLINE); #endif Poco::Thread::sleep(CHANGE_DELAY); } Poco::Thread::sleep(CHANGE_DELAY); } else { Poco::Thread::sleep(CHANGE_DELAY); if(LXV7_EXP_iPDABaudrate != LXV7_EXP_iGPSBaudrate) { #if TESTBENCH StartupStore(TEXT("V7: Set Baudrate %i %s"),LXV7_EXP_iPDABaudrate, NEWLINE); #endif d->Com->SetBaudrate(LXV7_EXP_iPDABaudrate); Poco::Thread::sleep(CHANGE_DELAY); } #if TESTBENCH StartupStore(TEXT("v7: Return from V7 link %s"), NEWLINE); #endif _stprintf(szTmp, TEXT("$PLXV0,CONNECTION,W,VSEVEN")); LXV7_EXPNMEAddCheckSumStrg(szTmp); d->Com->WriteString(szTmp); Poco::Thread::sleep(CHANGE_DELAY); UnlockComm(); Poco::Thread::sleep(CHANGE_DELAY); } return true; }