bool FocusMaster::AbortFocuser() { uint8_t command[MAX_FM_BUF] = {0}; command[0] = 0x30; command[1] = 0x30; LOG_DEBUG("Aborting Focuser..."); bool rc = sendCommand(command); if (rc) { if (FullMotionSP.s == IPS_BUSY) { IUResetSwitch(&FullMotionSP); FullMotionSP.s = IPS_IDLE; IDSetSwitch(&FullMotionSP, nullptr); } if (FocusMotionSP.s == IPS_BUSY) { IUResetSwitch(&FocusMotionSP); FocusMotionSP.s = IPS_IDLE; IDSetSwitch(&FocusMotionSP, nullptr); } } return rc; }
bool Paramount::updateProperties() { INDI::Telescope::updateProperties(); if (isConnected()) { if (isTheSkyTracking()) { IUResetSwitch(&TrackModeSP); TrackModeS[TRACK_SIDEREAL].s = ISS_ON; TrackState = SCOPE_TRACKING; } else { IUResetSwitch(&TrackModeSP); TrackState = SCOPE_IDLE; } //defineSwitch(&TrackModeSP); //defineNumber(&TrackRateNP); defineNumber(&JogRateNP); defineNumber(&GuideNSNP); defineNumber(&GuideWENP); defineNumber(&GuideRateNP); // Initial currentRA and currentDEC to LST and +90 or -90 if (InitPark()) { // If loading parking data is successful, we just set the default parking values. SetAxis1ParkDefault(currentRA); SetAxis2ParkDefault(currentDEC); } else { // Otherwise, we set all parking data to default in case no parking data is found. SetAxis1Park(currentRA); SetAxis2Park(currentDEC); SetAxis1ParkDefault(currentRA); SetAxis2ParkDefault(currentDEC); } SetParked(isTheSkyParked()); } else { //deleteProperty(TrackModeSP.name); //deleteProperty(TrackRateNP.name); deleteProperty(JogRateNP.name); deleteProperty(GuideNSNP.name); deleteProperty(GuideWENP.name); deleteProperty(GuideRateNP.name); } return true; }
bool ClientAPIForAlignmentDatabase::InsertSyncPoint(unsigned int Offset, const AlignmentDatabaseEntry &CurrentValues) { // Wait for driver to initialise if neccessary WaitForDriverCompletion(); ISwitchVectorProperty * pAction = Action->getSwitch(); INumberVectorProperty * pMandatoryNumbers = MandatoryNumbers->getNumber(); INumberVectorProperty * pCurrentEntry = CurrentEntry->getNumber(); ISwitchVectorProperty * pCommit = Commit->getSwitch(); // Select the required action if (INSERT != IUFindOnSwitchIndex(pAction)) { // Request Insert mode IUResetSwitch(pAction); pAction->sp[INSERT].s = ISS_ON; SetDriverBusy(); BaseClient->sendNewSwitch(pAction); WaitForDriverCompletion(); if (IPS_OK != pAction->s) { IDLog("InsertSyncPoint - Bad Action switch state %s\n", pstateStr(pAction->s)); return false; } } // Send the offset pCurrentEntry->np[0].value = Offset; SetDriverBusy(); BaseClient->sendNewNumber(pCurrentEntry); WaitForDriverCompletion(); if (IPS_OK != pCurrentEntry->s) { IDLog("InsertSyncPoint - Bad Current Entry state %s\n", pstateStr(pCurrentEntry->s)); return false; } if (!SendEntryData(CurrentValues)) return false; // Commit the entry to the database IUResetSwitch(pCommit); pCommit->sp[0].s = ISS_ON; SetDriverBusy(); BaseClient->sendNewSwitch(pCommit); WaitForDriverCompletion(); if (IPS_OK != pCommit->s) { IDLog("InsertSyncPoint - Bad Commit switch state %s\n", pstateStr(pCommit->s)); return false; } return true; }
bool ClientAPIForAlignmentDatabase::ReadIncrementSyncPoint(AlignmentDatabaseEntry &CurrentValues) { // Wait for driver to initialise if neccessary WaitForDriverCompletion(); ISwitchVectorProperty * pAction = Action->getSwitch(); INumberVectorProperty * pMandatoryNumbers = MandatoryNumbers->getNumber(); IBLOBVectorProperty * pBLOB = OptionalBinaryBlob->getBLOB(); INumberVectorProperty * pCurrentEntry = CurrentEntry->getNumber(); ISwitchVectorProperty * pCommit = Commit->getSwitch(); // Select the required action if (READ_INCREMENT != IUFindOnSwitchIndex(pAction)) { // Request Read Increment mode IUResetSwitch(pAction); pAction->sp[READ_INCREMENT].s = ISS_ON; SetDriverBusy(); BaseClient->sendNewSwitch(pAction); WaitForDriverCompletion(); if (IPS_OK != pAction->s) { IDLog("ReadIncrementSyncPoint - Bad Action switch state %s\n", pstateStr(pAction->s)); return false; } } // Commit the read increment IUResetSwitch(pCommit); pCommit->sp[0].s = ISS_ON; SetDriverBusy(); BaseClient->sendNewSwitch(pCommit); WaitForDriverCompletion(); if ((IPS_OK != pCommit->s) || (IPS_OK != pMandatoryNumbers->s) || (IPS_OK != pBLOB->s) || (IPS_OK != pCurrentEntry->s)) { IDLog("ReadIncrementSyncPoint - Bad Commit/Mandatory numbers/Blob/Current entry state %s %s %s %s\n", pstateStr(pCommit->s), pstateStr(pMandatoryNumbers->s), pstateStr(pBLOB->s), pstateStr(pCurrentEntry->s)); return false; } // Read the entry data CurrentValues.ObservationJulianDate = pMandatoryNumbers->np[ENTRY_OBSERVATION_JULIAN_DATE].value; CurrentValues.RightAscension = pMandatoryNumbers->np[ENTRY_RA].value; CurrentValues.Declination = pMandatoryNumbers->np[ENTRY_DEC].value; CurrentValues.TelescopeDirection.x = pMandatoryNumbers->np[ENTRY_VECTOR_X].value; CurrentValues.TelescopeDirection.y = pMandatoryNumbers->np[ENTRY_VECTOR_Y].value; CurrentValues.TelescopeDirection.z = pMandatoryNumbers->np[ENTRY_VECTOR_Z].value; return true; }
bool LX200Autostar::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) { int index = 0; if (dev != nullptr && strcmp(dev, getDeviceName()) == 0) { // Focus Motion if (!strcmp(name, FocusMotionSP.name)) { // If speed is "halt" if (FocusSpeedN[0].value == 0) { FocusMotionSP.s = IPS_IDLE; IDSetSwitch(&FocusMotionSP, nullptr); return false; } int last_motion = IUFindOnSwitchIndex(&FocusMotionSP); if (IUUpdateSwitch(&FocusMotionSP, states, names, n) < 0) return false; index = IUFindOnSwitchIndex(&FocusMotionSP); // If same direction and we're busy, stop if (last_motion == index && FocusMotionSP.s == IPS_BUSY) { IUResetSwitch(&FocusMotionSP); FocusMotionSP.s = IPS_IDLE; setFocuserSpeedMode(PortFD, 0); IDSetSwitch(&FocusMotionSP, nullptr); return true; } if (!isSimulation() && setFocuserMotion(PortFD, index) < 0) { FocusMotionSP.s = IPS_ALERT; IDSetSwitch(&FocusMotionSP, "Error setting focuser speed."); return false; } FocusMotionSP.s = IPS_BUSY; // with a timer if (FocusTimerNP.np[0].value > 0) { FocusTimerNP.s = IPS_BUSY; if (isDebug()) IDLog("Starting Focus Timer BUSY\n"); IEAddTimer(50, LX200Generic::updateFocusHelper, this); } IDSetSwitch(&FocusMotionSP, nullptr); return true; } } return LX200Generic::ISNewSwitch(dev, name, states, names, n); }
bool ASICCD::StartStreaming() { ASI_IMG_TYPE type = getImageType(); if (type != ASI_IMG_Y8 && type != ASI_IMG_RGB24) { IUResetSwitch(&VideoFormatSP); ISwitch *vf = IUFindSwitch(&VideoFormatSP,"ASI_IMG_Y8"); if (vf == NULL) vf = IUFindSwitch(&VideoFormatSP,"ASI_IMG_RAW8"); if (vf) { vf->s = ISS_ON; DEBUGF(INDI::Logger::DBG_DEBUG, "Switching to %s video format.", vf->label); PrimaryCCD.setBPP(8); UpdateCCDFrame(PrimaryCCD.getSubX(), PrimaryCCD.getSubY(), PrimaryCCD.getSubW(), PrimaryCCD.getSubH()); IDSetSwitch(&VideoFormatSP, NULL); } else { DEBUG(INDI::Logger::DBG_ERROR, "No 8 bit video format found, cannot start stream."); return false; } } ASIStartVideoCapture(m_camInfo->CameraID); pthread_mutex_lock(&condMutex); streamPredicate = 1; pthread_mutex_unlock(&condMutex); pthread_cond_signal(&cv); return true; }
bool Telescope::Slew(SkyPoint *ScopeTarget) { ISwitchVectorProperty *motionSP = baseDevice->getSwitch("ON_COORD_SET"); if (motionSP == NULL) return false; ISwitch *slewSW = IUFindSwitch(motionSP, "TRACK"); if (slewSW == NULL) slewSW = IUFindSwitch(motionSP, "SLEW"); if (slewSW == NULL) return false; if (slewSW->s != ISS_ON) { IUResetSwitch(motionSP); slewSW->s = ISS_ON; clientManager->sendNewSwitch(motionSP); if (Options::iNDILogging()) qDebug() << "ISD:Telescope: " << slewSW->name; } return sendCoords(ScopeTarget); }
bool INDI::LightBoxInterface::processLightBoxSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) { if (strcmp(dev, device->getDeviceName()) == 0) { // Light if (!strcmp(LightSP.name, name)) { int prevIndex = IUFindOnSwitchIndex(&LightSP); IUUpdateSwitch(&LightSP, states, names, n); bool rc = EnableLightBox(LightS[FLAT_LIGHT_ON].s == ISS_ON ? true : false); LightSP.s = rc ? IPS_OK : IPS_ALERT; if (!rc) { IUResetSwitch(&LightSP); LightS[prevIndex].s = ISS_ON; } IDSetSwitch(&LightSP, nullptr); return true; } } return false; }
bool FocuserInterface::processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) { INDI_UNUSED(dev); // This one is for us if (strcmp(name, "FOCUS_MOTION") == 0) { // Record last direction and state. FocusDirection prevDirection = FocusMotionS[FOCUS_INWARD].s == ISS_ON ? FOCUS_INWARD : FOCUS_OUTWARD; IPState prevState = FocusMotionSP.s; IUUpdateSwitch(&FocusMotionSP, states, names, n); FocusDirection targetDirection = FocusMotionS[FOCUS_INWARD].s == ISS_ON ? FOCUS_INWARD : FOCUS_OUTWARD; if (CanRelMove() || CanAbsMove() || HasVariableSpeed()) { FocusMotionSP.s = IPS_OK; } // If we are dealing with a simple dumb DC focuser, we move in a specific direction in an open-loop fashion until stopped. else { // If we are reversing direction let's issue abort first. if (prevDirection != targetDirection && prevState == IPS_BUSY) AbortFocuser(); FocusMotionSP.s = MoveFocuser(targetDirection, 0, 0); } IDSetSwitch(&FocusMotionSP, nullptr); return true; } if (strcmp(name, "FOCUS_ABORT_MOTION") == 0) { IUResetSwitch(&AbortSP); if (AbortFocuser()) { AbortSP.s = IPS_OK; if (CanAbsMove() && FocusAbsPosNP.s != IPS_IDLE) { FocusAbsPosNP.s = IPS_IDLE; IDSetNumber(&FocusAbsPosNP, nullptr); } if (CanRelMove() && FocusRelPosNP.s != IPS_IDLE) { FocusRelPosNP.s = IPS_IDLE; IDSetNumber(&FocusRelPosNP, nullptr); } } else AbortSP.s = IPS_ALERT; IDSetSwitch(&AbortSP, nullptr); return true; } return false; }
bool Telescope::MoveWE(TelescopeMotionWE dir, TelescopeMotionCommand cmd) { ISwitchVectorProperty *motionSP = baseDevice->getSwitch("TELESCOPE_MOTION_WE"); if (motionSP == NULL) return false; ISwitch *motionWest = IUFindSwitch(motionSP, "MOTION_WEST"); ISwitch *motionEast = IUFindSwitch(motionSP, "MOTION_EAST"); if (motionWest == NULL || motionEast == NULL) return false; // If same direction, return if (dir == MOTION_WEST && motionWest->s == ((cmd == MOTION_START) ? ISS_ON : ISS_OFF)) return true; if (dir == MOTION_EAST && motionEast->s == ((cmd == MOTION_START) ? ISS_ON : ISS_OFF)) return true; IUResetSwitch(motionSP); if (cmd == MOTION_START) { if (dir == MOTION_WEST) motionWest->s = ISS_ON; else motionEast->s = ISS_ON; } clientManager->sendNewSwitch(motionSP); return true; }
bool Telescope::MoveNS(TelescopeMotionNS dir, TelescopeMotionCommand cmd) { ISwitchVectorProperty *motionSP = baseDevice->getSwitch("TELESCOPE_MOTION_NS"); if (motionSP == NULL) return false; ISwitch *motionNorth = IUFindSwitch(motionSP, "MOTION_NORTH"); ISwitch *motionSouth = IUFindSwitch(motionSP, "MOTION_SOUTH"); if (motionNorth == NULL || motionSouth == NULL) return false; // If same direction, return if (dir == MOTION_NORTH && motionNorth->s == ((cmd == MOTION_START) ? ISS_ON : ISS_OFF)) return true; if (dir == MOTION_SOUTH && motionSouth->s == ((cmd == MOTION_START) ? ISS_ON : ISS_OFF)) return true; IUResetSwitch(motionSP); if (cmd == MOTION_START) { if (dir == MOTION_NORTH) motionNorth->s = ISS_ON; else motionSouth->s = ISS_ON; } clientManager->sendNewSwitch(motionSP); return true; }
void INDI::BaseClientQt::setDriverConnection(bool status, const char * deviceName) { INDI::BaseDevice * drv = getDevice(deviceName); ISwitchVectorProperty * drv_connection = NULL; if (drv == NULL) { IDLog("INDI::BaseClientQt: Error. Unable to find driver %s\n", deviceName); return; } drv_connection = drv->getSwitch("CONNECTION"); if (drv_connection == NULL) return; // If we need to connect if (status) { // If there is no need to do anything, i.e. already connected. if (drv_connection->sp[0].s == ISS_ON) return; IUResetSwitch(drv_connection); drv_connection->s = IPS_BUSY; drv_connection->sp[0].s = ISS_ON; drv_connection->sp[1].s = ISS_OFF; sendNewSwitch(drv_connection); } else { // If there is no need to do anything, i.e. already disconnected. if (drv_connection->sp[1].s == ISS_ON) return; IUResetSwitch(drv_connection); drv_connection->s = IPS_BUSY; drv_connection->sp[0].s = ISS_OFF; drv_connection->sp[1].s = ISS_ON; sendNewSwitch(drv_connection); } }
bool ClientAPIForAlignmentDatabase::AppendSyncPoint(const AlignmentDatabaseEntry &CurrentValues) { // Wait for driver to initialise if neccessary WaitForDriverCompletion(); ISwitchVectorProperty * pAction = Action->getSwitch(); ISwitchVectorProperty * pCommit = Commit->getSwitch(); if (APPEND != IUFindOnSwitchIndex(pAction)) { // Request Append mode IUResetSwitch(pAction); pAction->sp[APPEND].s = ISS_ON; SetDriverBusy(); BaseClient->sendNewSwitch(pAction); WaitForDriverCompletion(); if (IPS_OK != pAction->s) { IDLog("AppendSyncPoint - Bad Action switch state %s\n", pstateStr(pAction->s)); return false; } } if (!SendEntryData(CurrentValues)) return false; // Commit the entry to the database IUResetSwitch(pCommit); pCommit->sp[0].s = ISS_ON; SetDriverBusy(); BaseClient->sendNewSwitch(pCommit); WaitForDriverCompletion(); if (IPS_OK != pCommit->s) { IDLog("AppendSyncPoint - Bad Commit switch state %s\n", pstateStr(pCommit->s)); return false; } return true; }
bool StarbookDriver::performStart() { IUResetSwitch(&StartSP); if (last_known_state == starbook::INIT) { if (cmd_interface->Start()) { StartSP.s = IPS_OK; } } else { LOGF_WARN("Can't initialize in %s state, must be INIT", starbook::STATE_TO_STR.at(last_known_state).c_str()); StartSP.s = IPS_ALERT; } IDSetSwitch(&StartSP, nullptr); return true; }
bool ClientAPIForAlignmentDatabase::SaveDatabase() { // Wait for driver to initialise if neccessary WaitForDriverCompletion(); ISwitchVectorProperty * pAction = Action->getSwitch(); ISwitchVectorProperty * pCommit = Commit->getSwitch(); // Select the required action if (SAVE_DATABASE != IUFindOnSwitchIndex(pAction)) { // Request Load Database mode IUResetSwitch(pAction); pAction->sp[SAVE_DATABASE].s = ISS_ON; SetDriverBusy(); BaseClient->sendNewSwitch(pAction); WaitForDriverCompletion(); if (IPS_OK != pAction->s) { IDLog("SaveDatabase - Bad Action switch state %s\n", pstateStr(pAction->s)); return false; } } // Commit the Save Database IUResetSwitch(pCommit); pCommit->sp[0].s = ISS_ON; SetDriverBusy(); BaseClient->sendNewSwitch(pCommit); WaitForDriverCompletion(); if (IPS_OK != pCommit->s) { IDLog("Save Database - Bad Commit state %s\n", pstateStr(pCommit->s)); return false; } return true; }
bool RollOff::Abort() { MotionRequest=-1; // If both limit switches are off, then we're neither parked nor unparked. if (fullOpenLimitSwitch == false && fullClosedLimitSwitch == false) { IUResetSwitch(&ParkSP); ParkSP.s = IPS_IDLE; IDSetSwitch(&ParkSP, NULL); } return true; }
bool ClientAPIForAlignmentDatabase::ClearSyncPoints() { // Wait for driver to initialise if neccessary WaitForDriverCompletion(); ISwitchVectorProperty * pAction = Action->getSwitch(); ISwitchVectorProperty * pCommit = Commit->getSwitch(); // Select the required action if (CLEAR != IUFindOnSwitchIndex(pAction)) { // Request Clear mode IUResetSwitch(pAction); pAction->sp[CLEAR].s = ISS_ON; SetDriverBusy(); BaseClient->sendNewSwitch(pAction); WaitForDriverCompletion(); if (IPS_OK != pAction->s) { IDLog("ClearSyncPoints - Bad Action switch state %s\n", pstateStr(pAction->s)); return false; } } IUResetSwitch(pCommit); pCommit->sp[0].s = ISS_ON; SetDriverBusy(); BaseClient->sendNewSwitch(pCommit); WaitForDriverCompletion(); if (IPS_OK != pCommit->s) { IDLog("ClearSyncPoints - Bad Commit switch state %s\n", pstateStr(pCommit->s)); return false; } return true; }
bool NStep::readCoilStatus() { char res[NSTEP_LEN] = {0}; if (sendCommand(":RC", res, 3, 1) == false) return false; IUResetSwitch(&CoilStatusSP); CoilStatusS[COIL_ENERGIZED_OFF].s = (res[0] == '0') ? ISS_ON : ISS_OFF; CoilStatusS[COIL_ENERGIZED_ON].s = (res[0] == '0') ? ISS_OFF : ISS_ON; CoilStatusSP.s = IPS_OK; return true; }
bool XAGYLWheel::ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n) { if(strcmp(dev,getDeviceName())==0) { if (!strcmp(ResetSP.name, name)) { IUUpdateSwitch(&ResetSP, states, names, n); int value = IUFindOnSwitchIndex(&ResetSP); IUResetSwitch(&ResetSP); if (value == 3) value = 6; bool rc = reset(value); if (rc) { switch (value) { case 0: DEBUG(INDI::Logger::DBG_SESSION, "Executing hard reboot..."); break; case 1: DEBUG(INDI::Logger::DBG_SESSION, "Restarting and moving to filter position #1..."); break; case 2: DEBUG(INDI::Logger::DBG_SESSION, "Calibration removed."); break; case 6: DEBUG(INDI::Logger::DBG_SESSION, "Calibrating..."); break; } } ResetSP.s = rc ? IPS_OK : IPS_ALERT; IDSetSwitch(&ResetSP, NULL); return true; } } return INDI::FilterWheel::ISNewSwitch(dev, name, states, names, n); }
bool Telescope::setSlewRate(int index) { ISwitchVectorProperty *slewRateSP = baseDevice->getSwitch("TELESCOPE_SLEW_RATE"); if (slewRateSP == NULL) return false; if (index < 0 || index > slewRateSP->nsp) return false; IUResetSwitch(slewRateSP); slewRateSP->sp[index].s = ISS_ON; clientManager->sendNewSwitch(slewRateSP); return true; }
bool ATIKCCD::activateCooler(bool enable) { IUResetSwitch(&CoolerSP); if (enable) { if (TemperatureRequest < TemperatureN[0].value) { if (CoolerSP.s != IPS_BUSY) LOG_INFO("Camera cooler is on."); CoolerS[COOLER_ON].s = ISS_ON; CoolerS[COOLER_OFF].s = ISS_OFF; CoolerSP.s = IPS_BUSY; } else { CoolerS[COOLER_ON].s = ISS_OFF; CoolerS[COOLER_OFF].s = ISS_ON; CoolerSP.s = IPS_IDLE; LOG_WARN("Cooler cannot be activated manually. Set a lower temperature to activate it."); IDSetSwitch(&CoolerSP, nullptr); return false; } } else if (enable == false) { int rc = ArtemisCoolerWarmUp(hCam); if (rc != ARTEMIS_OK) { CoolerS[COOLER_ON].s = ISS_ON; CoolerS[COOLER_OFF].s = ISS_OFF; CoolerSP.s = IPS_ALERT; LOGF_ERROR("Failed to warm camera (%d).", rc); IDSetSwitch(&CoolerSP, nullptr); return false; } CoolerS[COOLER_ON].s = ISS_OFF; CoolerS[COOLER_OFF].s = ISS_ON; CoolerSP.s = IPS_IDLE; LOG_INFO("Camera is warming up..."); } IDSetSwitch(&CoolerSP, nullptr); return true; }
void INDI_P::newSwitch(int index) { ISwitchVectorProperty *svp = dataProp->getSwitch(); if (svp == NULL) return; if (index >= svp->nsp) return; ISwitch *sp = &(svp->sp[index]); IUResetSwitch(svp); sp->s = ISS_ON; sendSwitch(); }
bool Telescope::UnPark() { ISwitchVectorProperty *parkSP = baseDevice->getSwitch("TELESCOPE_PARK"); if (parkSP == NULL) return false; ISwitch *parkSW = IUFindSwitch(parkSP, "UNPARK"); if (parkSW == NULL) return false; if (Options::iNDILogging()) qDebug() << "ISD:Telescope: UnParking..." << endl; IUResetSwitch(parkSP); parkSW->s = ISS_ON; clientManager->sendNewSwitch(parkSP); return true; }
bool Focuser::focusOut() { ISwitchVectorProperty *focusProp = baseDevice->getSwitch("FOCUS_MOTION"); if (focusProp == NULL) return false; ISwitch *outFocus = IUFindSwitch(focusProp, "FOCUS_OUTWARD"); if (outFocus == NULL) return false; if (outFocus->s == ISS_ON) return true; IUResetSwitch(focusProp); outFocus->s = ISS_ON; clientManager->sendNewSwitch(focusProp); return true; }
bool Telescope::Sync(SkyPoint *ScopeTarget) { ISwitchVectorProperty *motionSP = baseDevice->getSwitch("ON_COORD_SET"); if (motionSP == NULL) return false; ISwitch *syncSW = IUFindSwitch(motionSP, "SYNC"); if (syncSW == NULL) return false; if (syncSW->s != ISS_ON) { IUResetSwitch(motionSP); syncSW->s = ISS_ON; clientManager->sendNewSwitch(motionSP); if (Options::iNDILogging()) qDebug() << "ISD:Telescope: Syncing..."; } return sendCoords(ScopeTarget); }
bool MoonLite::updateStepMode() { int nbytes_written = 0, nbytes_read = 0, rc = -1; char errstr[MAXRBUF]; char resp[4]={0}; tcflush(PortFD, TCIOFLUSH); if ((rc = tty_write(PortFD, ":GH#", 4, &nbytes_written)) != TTY_OK) { tty_error_msg(rc, errstr, MAXRBUF); LOGF_ERROR("updateStepMode error: %s.", errstr); return false; } if ((rc = tty_read(PortFD, resp, 3, MOONLITE_TIMEOUT, &nbytes_read)) != TTY_OK) { tty_error_msg(rc, errstr, MAXRBUF); LOGF_ERROR("updateStepMode error: %s.", errstr); return false; } tcflush(PortFD, TCIOFLUSH); resp[3] = '\0'; IUResetSwitch(&StepModeSP); if (strcmp(resp, "FF#") == 0) StepModeS[0].s = ISS_ON; else if (strcmp(resp, "00#") == 0) StepModeS[1].s = ISS_ON; else { LOGF_ERROR("Unknown error: focuser step value (%s)", resp); return false; } return true; }
bool SynscanDriver::readTracking() { // Read the handset version char res[SYN_RES] = {0}; if (sendCommand("t", res)) { // Are we tracking or not? m_TrackingFlag = res[0]; // Track mode? if ((m_TrackingFlag - 1) != IUFindOnSwitchIndex(&TrackModeSP)) { IUResetSwitch(&TrackModeSP); TrackModeS[m_TrackingFlag - 1].s = ISS_ON; IDSetSwitch(&TrackModeSP, nullptr); } switch(res[0]) { case 0: m_MountInfo[MI_TRACK_MODE] = "Tracking off"; break; case 1: m_MountInfo[MI_TRACK_MODE] = "Alt/Az tracking"; break; case 2: m_MountInfo[MI_TRACK_MODE] = "EQ tracking"; break; case 3: m_MountInfo[MI_TRACK_MODE] = "PEC mode"; break; } return true; } return false; }
void INDI_P::newSwitch(const QString & name) { ISwitchVectorProperty *svp = dataProp->getSwitch(); if (svp == NULL) return; ISwitch *sp = IUFindSwitch(svp, name.toLatin1().constData()); if (sp == NULL) return; if (svp->r == ISR_1OFMANY) { IUResetSwitch(svp); sp->s = ISS_ON; } else sp->s = (sp->s == ISS_ON) ? ISS_OFF : ISS_ON; sendSwitch(); }
bool ScopeSim::Goto(double r, double d) { targetRA = r; targetDEC = d; char RAStr[64], DecStr[64]; fs_sexa(RAStr, targetRA, 2, 3600); fs_sexa(DecStr, targetDEC, 2, 3600); double current_az = getAzimuth(currentRA, currentDEC); if (current_az > MIN_AZ_FLIP && current_az < MAX_AZ_FLIP) { double target_az = getAzimuth(r, d); //if (targetAz > currentAz && target_az > MIN_AZ_FLIP && target_az < MAX_AZ_FLIP) if (target_az >= current_az && target_az > MIN_AZ_FLIP) { forceMeridianFlip = true; } } if (IUFindOnSwitchIndex(&TrackModeSP) != SLEW_MAX) { IUResetSwitch(&TrackModeSP); TrackModeS[SLEW_MAX].s = ISS_ON; IDSetSwitch(&TrackModeSP, nullptr); } TrackState = SCOPE_SLEWING; EqNP.s = IPS_BUSY; LOGF_INFO("Slewing to RA: %s - DEC: %s", RAStr, DecStr); return true; }
bool RotatorInterface::processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) { INDI_UNUSED(states); INDI_UNUSED(names); INDI_UNUSED(n); if (dev != nullptr && strcmp(dev, m_defaultDevice->getDeviceName()) == 0) { //////////////////////////////////////////// // Abort //////////////////////////////////////////// if (strcmp(name, AbortRotatorSP.name) == 0) { AbortRotatorSP.s = AbortRotator() ? IPS_OK : IPS_ALERT; IDSetSwitch(&AbortRotatorSP, nullptr); if (AbortRotatorSP.s == IPS_OK) { if (GotoRotatorNP.s != IPS_OK) { GotoRotatorNP.s = IPS_OK; IDSetNumber(&GotoRotatorNP, nullptr); } } return true; } //////////////////////////////////////////// // Home //////////////////////////////////////////// else if (strcmp(name, HomeRotatorSP.name) == 0) { HomeRotatorSP.s = HomeRotator(); IUResetSwitch(&HomeRotatorSP); if (HomeRotatorSP.s == IPS_BUSY) HomeRotatorS[0].s = ISS_ON; IDSetSwitch(&HomeRotatorSP, nullptr); return true; } //////////////////////////////////////////// // Reverse Rotator //////////////////////////////////////////// else if (strcmp(name, ReverseRotatorSP.name) == 0) { bool rc = false; bool enabled = (!strcmp(IUFindOnSwitchName(states, names, n), "ENABLED")); rc = ReverseRotator(enabled); if (rc) { IUUpdateSwitch(&ReverseRotatorSP, states, names, n); ReverseRotatorSP.s = IPS_OK; DEBUGFDEVICE(m_defaultDevice->getDeviceName(), Logger::DBG_SESSION, "Rotator direction is %s.", (enabled ? "reversed" : "normal")); } else { ReverseRotatorSP.s = IPS_ALERT; DEBUGDEVICE(m_defaultDevice->getDeviceName(), Logger::DBG_SESSION, "Rotator reverse direction failed."); } IDSetSwitch(&ReverseRotatorSP, nullptr); return true; } } return false; }