bool LX200GPS::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) { int index = 0; char msg[64]; if (dev != nullptr && strcmp(dev, getDeviceName()) == 0) { /* GPS Power */ if (!strcmp(name, GPSPowerSP.name)) { int ret = 0; if (IUUpdateSwitch(&GPSPowerSP, states, names, n) < 0) return false; index = IUFindOnSwitchIndex(&GPSPowerSP); if (index == 0) ret = turnGPSOn(PortFD); else ret = turnGPSOff(PortFD); GPSPowerSP.s = IPS_OK; IDSetSwitch(&GPSPowerSP, index == 0 ? "GPS System is ON" : "GPS System is OFF"); return true; } /* GPS Status Update */ if (!strcmp(name, GPSStatusSP.name)) { int ret = 0; if (IUUpdateSwitch(&GPSStatusSP, states, names, n) < 0) return false; index = IUFindOnSwitchIndex(&GPSStatusSP); if (index == 0) { ret = gpsSleep(PortFD); strncpy(msg, "GPS system is in sleep mode.", 64); } else if (index == 1) { ret = gpsWakeUp(PortFD); strncpy(msg, "GPS system is reactivated.", 64); } else { ret = gpsRestart(PortFD); strncpy(msg, "GPS system is restarting...", 64); sendScopeTime(); sendScopeLocation(); } GPSStatusSP.s = IPS_OK; IDSetSwitch(&GPSStatusSP, "%s", msg); return true; } /* GPS Update */ if (!strcmp(name, GPSUpdateSP.name)) { if (IUUpdateSwitch(&GPSUpdateSP, states, names, n) < 0) return false; index = IUFindOnSwitchIndex(&GPSUpdateSP); GPSUpdateSP.s = IPS_OK; if (index == 0) { IDSetSwitch(&GPSUpdateSP, "Updating GPS system. This operation might take few minutes to complete..."); if (updateGPS_System(PortFD)) { IDSetSwitch(&GPSUpdateSP, "GPS system update successful."); sendScopeTime(); sendScopeLocation(); } else { GPSUpdateSP.s = IPS_IDLE; IDSetSwitch(&GPSUpdateSP, "GPS system update failed."); } } else { sendScopeTime(); sendScopeLocation(); IDSetSwitch(&GPSUpdateSP, "Client time and location is synced to LX200 GPS Data."); } return true; } /* Alt Dec Periodic Error correction */ if (!strcmp(name, AltDecPecSP.name)) { int ret = 0; if (IUUpdateSwitch(&AltDecPecSP, states, names, n) < 0) return false; index = IUFindOnSwitchIndex(&AltDecPecSP); if (index == 0) { ret = enableDecAltPec(PortFD); strncpy(msg, "Alt/Dec Compensation Enabled.", 64); } else { ret = disableDecAltPec(PortFD); strncpy(msg, "Alt/Dec Compensation Disabled.", 64); } AltDecPecSP.s = IPS_OK; IDSetSwitch(&AltDecPecSP, "%s", msg); return true; } /* Az RA periodic error correction */ if (!strcmp(name, AzRaPecSP.name)) { int ret = 0; if (IUUpdateSwitch(&AzRaPecSP, states, names, n) < 0) return false; index = IUFindOnSwitchIndex(&AzRaPecSP); if (index == 0) { ret = enableRaAzPec(PortFD); strncpy(msg, "Ra/Az Compensation Enabled.", 64); } else { ret = disableRaAzPec(PortFD); strncpy(msg, "Ra/Az Compensation Disabled.", 64); } AzRaPecSP.s = IPS_OK; IDSetSwitch(&AzRaPecSP, "%s", msg); return true; } if (!strcmp(name, AltDecBacklashSP.name)) { int ret = 0; ret = activateAltDecAntiBackSlash(PortFD); AltDecBacklashSP.s = IPS_OK; IDSetSwitch(&AltDecBacklashSP, "Alt/Dec Anti-backlash enabled"); return true; } if (!strcmp(name, AzRaBacklashSP.name)) { int ret = 0; ret = activateAzRaAntiBackSlash(PortFD); AzRaBacklashSP.s = IPS_OK; IDSetSwitch(&AzRaBacklashSP, "Az/Ra Anti-backlash enabled"); return true; } if (!strcmp(name, OTAUpdateSP.name)) { IUResetSwitch(&OTAUpdateSP); if (getOTATemp(PortFD, &OTATempNP.np[0].value) < 0) { OTAUpdateSP.s = IPS_ALERT; OTATempNP.s = IPS_ALERT; IDSetNumber(&OTATempNP, "Error: OTA temperature read timed out."); return false; } else { OTAUpdateSP.s = IPS_OK; OTATempNP.s = IPS_OK; IDSetNumber(&OTATempNP, nullptr); IDSetSwitch(&OTAUpdateSP, nullptr); return true; } } } return LX200Autostar::ISNewSwitch(dev, name, states, names, n); }
void ioptronHC8406::getBasicData() { checkLX200Format(PortFD); sendScopeLocation(); sendScopeTime(); }
void LX200SS2000PC::getBasicData(void) { if (!isSimulation()) checkLX200Format(PortFD); sendScopeLocation(); sendScopeTime(); }