/************************************************************************************** ** Client is asking us to set a new number ***************************************************************************************/ bool RadioSim::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) { if (strcmp (dev, getDeviceName())) return false; if (!strcmp(name, DetectorPropertiesNP.name)) { IUUpdateNumber(&DetectorPropertiesNP, values, names, n); DishSize = (DetectorPropertiesN[0].value); DetectorPropertiesNP.s = IPS_OK; IDSetNumber(&DetectorPropertiesNP, nullptr); return true; } if (!strcmp(name, DetectorCoordsNP.name)) { IUUpdateNumber(&DetectorCoordsNP, values, names, n); DetectorCoordsNP.s = IPS_OK; IDSetNumber(&DetectorCoordsNP, nullptr); return true; } return INDI::Detector::ISNewNumber(dev, name, values, names, n); }
bool Weather::processLocationInfo(double latitude, double longitude, double elevation) { // Do not update if not necessary if (latitude == LocationN[LOCATION_LATITUDE].value && longitude == LocationN[LOCATION_LONGITUDE].value && elevation == LocationN[LOCATION_ELEVATION].value) { LocationNP.s = IPS_OK; IDSetNumber(&LocationNP, nullptr); } if (updateLocation(latitude, longitude, elevation)) { LocationNP.s = IPS_OK; LocationN[LOCATION_LATITUDE].value = latitude; LocationN[LOCATION_LONGITUDE].value = longitude; LocationN[LOCATION_ELEVATION].value = elevation; // Update client display IDSetNumber(&LocationNP, nullptr); return true; } else { LocationNP.s = IPS_ALERT; // Update client display IDSetNumber(&LocationNP, nullptr); return false; } }
void LX200_16::handleAltAzSlew() { int i=0; char altStr[64], azStr[64]; if (horNum.s == IPS_BUSY) { abortSlew(); // sleep for 100 mseconds usleep(100000); } if ((i = slewToAltAz())) { horNum.s = IPS_IDLE; IDSetNumber(&horNum, "Slew not possible"); return; } horNum.s = IPS_BUSY; fs_sexa(azStr, targetAz, 2, 3600); fs_sexa(altStr, targetAlt, 2, 3600); IDSetNumber(&horNum, "Slewing to Alt %s - Az %s", altStr, azStr); return; }
void MICCD::updateTemperature() { float ccdtemp = 0; float ccdpower = 0; int err = 0; if (isSimulation()) { ccdtemp = TemperatureN[0].value; if (TemperatureN[0].value < TemperatureRequest) ccdtemp += TEMP_THRESHOLD; else if (TemperatureN[0].value > TemperatureRequest) ccdtemp -= TEMP_THRESHOLD; ccdpower = 30; } else { if (gxccd_get_value(cameraHandle, GV_CHIP_TEMPERATURE, &ccdtemp) < 0) { char errorStr[MAX_ERROR_LEN]; gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr)); LOGF_ERROR("Getting temperature failed: %s.", errorStr); err |= 1; } if (gxccd_get_value(cameraHandle, GV_POWER_UTILIZATION, &ccdpower) < 0) { char errorStr[MAX_ERROR_LEN]; gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr)); LOGF_ERROR("Getting voltage failed: %s.", errorStr); err |= 2; } } TemperatureN[0].value = ccdtemp; CoolerN[0].value = ccdpower * 100.0; if (TemperatureNP.s == IPS_BUSY && fabs(TemperatureN[0].value - TemperatureRequest) <= TEMP_THRESHOLD) { // end of temperature ramp TemperatureN[0].value = TemperatureRequest; TemperatureNP.s = IPS_OK; } if (err) { if (err & 1) TemperatureNP.s = IPS_ALERT; if (err & 2) CoolerNP.s = IPS_ALERT; } else { CoolerNP.s = IPS_OK; } IDSetNumber(&TemperatureNP, nullptr); IDSetNumber(&CoolerNP, nullptr); temperatureID = IEAddTimer(POLLMS, MICCD::updateTemperatureHelper, this); }
bool ASICCD::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n) { ASI_ERROR_CODE errCode = ASI_SUCCESS; if(!strcmp(dev,getDeviceName())) { if (!strcmp(name, ControlNP.name)) { double oldValues[ControlNP.nnp]; for (int i=0; i < ControlNP.nnp; i++) oldValues[i] = ControlN[i].value; IUUpdateNumber(&ControlNP, values, names, n); for (int i=0; i < ControlNP.nnp; i++) { ASI_BOOL nAuto = *((ASI_BOOL *) ControlN[i].aux1); ASI_CONTROL_TYPE nType = *((ASI_CONTROL_TYPE *) ControlN[i].aux0); // If value didn't change or if USB bandwidth control is to change, then only continue if ExposureRequest < 250 ms if (ControlN[i].value == oldValues[i] || (nType == ASI_BANDWIDTHOVERLOAD && ExposureRequest > 0.25)) continue; if ( (errCode = ASISetControlValue(m_camInfo->CameraID, nType, ControlN[i].value, ASI_FALSE)) != ASI_SUCCESS) { DEBUGF(INDI::Logger::DBG_ERROR, "ASISetControlValue (%s=%g) error (%d)", ControlN[i].name, ControlN[i].value, errCode); ControlNP.s = IPS_ALERT; for (int i=0; i < ControlNP.nnp; i++) ControlN[i].value = oldValues[i]; IDSetNumber(&ControlNP, NULL); return false; } // If it was set to nAuto value to turn it off if (nAuto) { for (int j=0; j < ControlSP.nsp; j++) { ASI_CONTROL_TYPE swType = *((ASI_CONTROL_TYPE *) ControlS[j].aux); if (swType == nType) { ControlS[j].s = ISS_OFF; break; } } IDSetSwitch(&ControlSP, NULL); } } ControlNP.s = IPS_OK; IDSetNumber(&ControlNP, NULL); return true; } } return INDI::CCD::ISNewNumber(dev,name,values,names,n); }
bool ArmPlat::AbortFocuser() { if ( port == -1 ) return false; int rc = -1; char cmd[SLP_SEND_BUF_SIZE]={0}; LOG_DEBUG("Aborting motion" ); sprintf(cmd, "!step stop %d#", port ); if ( slpSendRxInt( cmd, &rc ) ) { if ( rc == 0 ) { FocusAbsPosNP.s = IPS_IDLE; FocusRelPosNP.s = IPS_IDLE; IDSetNumber(&FocusAbsPosNP, nullptr); IDSetNumber(&FocusRelPosNP, nullptr); return true; } } return true; }
void QHYCCD::setCooler(bool enable) { if (enable && coolerEnabled == false) { CoolerS[0].s = ISS_ON; CoolerS[1].s = ISS_OFF; CoolerSP.s = IPS_OK; IDSetSwitch(&CoolerSP, NULL); CoolerNP.s = IPS_BUSY; IDSetNumber(&CoolerNP, NULL); DEBUG(INDI::Logger::DBG_SESSION, "Cooler on."); coolerEnabled = true; } else if (!enable && coolerEnabled == true) { coolerEnabled = false; if (sim == false) SetQHYCCDParam(camhandle, CONTROL_MANULPWM, 0); CoolerSP.s = IPS_IDLE; CoolerS[0].s = ISS_OFF; CoolerS[1].s = ISS_ON; IDSetSwitch(&CoolerSP, NULL); CoolerNP.s = IPS_IDLE; IDSetNumber(&CoolerNP, NULL); TemperatureNP.s = IPS_IDLE; IDSetNumber(&TemperatureNP, NULL); DEBUG(INDI::Logger::DBG_SESSION, "Cooler off."); } }
bool LX200_16::handleAltAzSlew() { char altStr[64], azStr[64]; if (HorizontalCoordsNP.s == IPS_BUSY) { abortSlew(PortFD); // sleep for 100 mseconds usleep(100000); } if (isSimulation() == false && slewToAltAz(PortFD)) { HorizontalCoordsNP.s = IPS_ALERT; IDSetNumber(&HorizontalCoordsNP, "Slew is not possible."); return false; } HorizontalCoordsNP.s = IPS_BUSY; fs_sexa(azStr, targetAZ, 2, 3600); fs_sexa(altStr, targetALT, 2, 3600); TrackState = SCOPE_SLEWING; IDSetNumber(&HorizontalCoordsNP, "Slewing to Alt %s - Az %s", altStr, azStr); return true; }
/******************************************************************************* ** Client is asking us to set a new number *******************************************************************************/ bool DSICCD::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) { if (!strcmp(dev, getDeviceName())) { if (!strcmp(name, GainNP.name)) { IUUpdateNumber(&GainNP, values, names, n); GainNP.s = IPS_OK; IDSetNumber(&GainNP, NULL); return true; } if (!strcmp(name, OffsetNP.name)) { IUUpdateNumber(&OffsetNP, values, names, n); OffsetNP.s = IPS_OK; IDSetNumber(&OffsetNP, NULL); return true; } } // If we didn't process anything above, let the parent handle it. return INDI::CCD::ISNewNumber(dev,name,values,names,n); }
bool QSICCD::SelectFilter(int targetFilter) { short filter = targetFilter - 1; try { QSICam.put_Position(filter); } catch (std::runtime_error err) { FilterSlotNP.s = IPS_ALERT; DEBUGF(INDI::Logger::DBG_ERROR, "put_Position() failed. %s.", err.what()); return false; } // Check current filter position short newFilter = QueryFilter(); if (newFilter == targetFilter) { FilterSlotN[0].value = targetFilter; FilterSlotNP.s = IPS_OK; DEBUGF(INDI::Logger::DBG_DEBUG, "Filter set to slot #%d", targetFilter); IDSetNumber(&FilterSlotNP, nullptr); return true; } IDSetNumber(&FilterSlotNP, nullptr); FilterSlotNP.s = IPS_ALERT; return false; }
IPState TCFS::MoveRelFocuser(FocusDirection dir, uint32_t ticks) { if (FocusModeSP.sp[0].s != ISS_ON) { LOG_WARN("The focuser can only be moved in Manual mode."); return IPS_ALERT; } targetTicks = ticks; targetPosition = currentPosition; // Inward if (dir == FOCUS_INWARD) { targetPosition -= targetTicks; dispatch_command(FIN); } // Outward else { targetPosition += targetTicks; dispatch_command(FOUT); } FocusAbsPosNP.s = IPS_BUSY; FocusRelPosNP.s = IPS_BUSY; IDSetNumber(&FocusAbsPosNP, nullptr); IDSetNumber(&FocusRelPosNP, nullptr); simulated_position = targetPosition; return IPS_BUSY; }
bool DomeSim::SetupParms() { targetAz = 0; shutterTimer = SHUTTER_TIMER; DomeAbsPosN[0].value = 0; DomeParamN[0].value = 5; IDSetNumber(&DomeAbsPosNP, NULL); IDSetNumber(&DomeParamNP, NULL); if (InitPark()) { // If loading parking data is successful, we just set the default parking values. SetAxis1ParkDefault(90); } else { // Otherwise, we set all parking data to default in case no parking data is found. SetAxis1Park(90); SetAxis1ParkDefault(90); } return true; }
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; }
void SestoSenso::GetFocusParams() { if (updatePosition()) IDSetNumber(&FocusAbsPosNP, nullptr); if (updateTemperature()) IDSetNumber(&TemperatureNP, nullptr); }
bool MaxDomeII::SetupParms() { DomeAbsPosN[0].value = 0; IDSetNumber(&DomeAbsPosNP, NULL); IDSetNumber(&DomeParamNP, NULL); return true; }
bool ioptronHC8406::Sync(double ra, double dec) { char syncString[256]; int syncType = IUFindOnSwitchIndex(&SyncCMRSP); if (!isSimulation()) { if (setObjectRA(PortFD, ra) < 0 || setObjectDEC(PortFD, dec) < 0) { EqNP.s = IPS_ALERT; IDSetNumber(&EqNP, "Error setting RA/DEC. Unable to Sync."); return false; } bool syncOK = true; switch (syncType) { case USE_REGULAR_SYNC: if (::Sync(PortFD, syncString) < 0) syncOK = false; break; case USE_CMR_SYNC: if (ioptronHC8406SyncCMR(syncString) < 0) syncOK = false; break; default: break; } if (syncOK == false) { EqNP.s = IPS_ALERT; IDSetNumber(&EqNP, "Synchronization failed."); return false; } } currentRA = ra; currentDEC = dec; DEBUGF(INDI::Logger::DBG_DEBUG, "%s Synchronization successful %s", (syncType == USE_REGULAR_SYNC ? "CM" : "CMR"), syncString); DEBUG(INDI::Logger::DBG_SESSION, "Synchronization successful."); EqNP.s = IPS_OK; NewRaDec(currentRA, currentDEC); return true; }
/************************************************************************************ * * ***********************************************************************************/ bool ScopeDome::SetupParms() { targetAz = 0; readU32(GetImpPerTurn, stepsPerTurn); LOGF_INFO("Steps per turn read as %d", stepsPerTurn); StepsPerRevolutionN[0].value = stepsPerTurn; StepsPerRevolutionNP.s = IPS_OK; IDSetNumber(&StepsPerRevolutionNP, nullptr); readS32(GetHomeSensorPosition, homePosition); LOGF_INFO("Home position read as %d", homePosition); if (UpdatePosition()) IDSetNumber(&DomeAbsPosNP, nullptr); if (UpdateShutterStatus()) IDSetSwitch(&DomeShutterSP, nullptr); UpdateSensorStatus(); UpdateRelayStatus(); if (InitPark()) { // If loading parking data is successful, we just set the default parking // values. SetAxis1ParkDefault(0); } else { // Otherwise, we set all parking data to default in case no parking data is // found. SetAxis1Park(0); SetAxis1ParkDefault(0); } uint8_t calibrationNeeded = false; readU8(IsFullSystemCalReq, calibrationNeeded); CalibrationNeededS[0].s = calibrationNeeded ? ISS_ON : ISS_OFF; CalibrationNeededSP.s = IPS_OK; IDSetSwitch(&CalibrationNeededSP, nullptr); uint16_t fwVersion; readU16(GetVersionFirmware, fwVersion); FirmwareVersionsN[0].value = fwVersion / 100.0; uint8_t fwVersionRotary; readU8(GetVersionFirmwareRotary, fwVersionRotary); FirmwareVersionsN[1].value = (fwVersionRotary + 9) / 10.0; FirmwareVersionsNP.s = IPS_OK; IDSetNumber(&FirmwareVersionsNP, nullptr); return true; }
bool MICCD::setupParams() { bool sim = isSimulation(); if (sim) { SetCCDParams(4032, 2688, 16, 9, 9); } else { int chipW, chipD, pixelW, pixelD; gxccd_get_integer_parameter(cameraHandle, GIP_CHIP_W, &chipW); gxccd_get_integer_parameter(cameraHandle, GIP_CHIP_D, &chipD); gxccd_get_integer_parameter(cameraHandle, GIP_PIXEL_W, &pixelW); gxccd_get_integer_parameter(cameraHandle, GIP_PIXEL_D, &pixelD); SetCCDParams(chipW, chipD, 16, pixelW / 1000.0, pixelD / 1000.0); } int nbuf = PrimaryCCD.getXRes() * PrimaryCCD.getYRes() * PrimaryCCD.getBPP() / 8; nbuf += 512; PrimaryCCD.setFrameBufferSize(nbuf); int expTime = 0; gxccd_get_integer_parameter(cameraHandle, GIP_MINIMAL_EXPOSURE, &expTime); minExpTime = expTime / 1000000.0; // convert to seconds PrimaryCCD.setMinMaxStep("CCD_EXPOSURE", "CCD_EXPOSURE_VALUE", minExpTime, 3600, 1, false); gxccd_get_integer_parameter(cameraHandle, GIP_MAX_BINNING_X, &maxBinX); gxccd_get_integer_parameter(cameraHandle, GIP_MAX_BINNING_Y, &maxBinY); if (!sim && hasGain) { float gain = 0; if (gxccd_get_value(cameraHandle, GV_ADC_GAIN, &gain) < 0) { char errorStr[MAX_ERROR_LEN]; gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr)); DEBUGF(INDI::Logger::DBG_ERROR, "Getting gain failed: %s.", errorStr); GainN[0].value = 0; GainNP.s = IPS_ALERT; IDSetNumber(&GainNP, NULL); return false; } else { GainN[0].value = gain; GainNP.s = IPS_OK; IDSetNumber(&GainNP, NULL); } } return true; }
bool IEQPro::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n) { if (!strcmp (dev, getDeviceName())) { // Custom Tracking Rate if (!strcmp(name, CustomTrackRateNP.name)) { if (TrackModeS[TRACK_CUSTOM].s != ISS_ON) { CustomTrackRateNP.s = IPS_IDLE; DEBUG(INDI::Logger::DBG_ERROR, "Can only set tracking rate if tracking mode is set to custom."); IDSetNumber(&CustomTrackRateNP, NULL); return true; } IUUpdateNumber(&CustomTrackRateNP, values, names, n); if (set_ieqpro_custom_track_rate(PortFD, CustomTrackRateN[0].value)) CustomTrackRateNP.s = IPS_OK; else CustomTrackRateNP.s = IPS_ALERT; IDSetNumber(&CustomTrackRateNP, NULL); return true; } // Guiding Rate if (!strcmp(name, GuideRateNP.name)) { IUUpdateNumber(&GuideRateNP, values, names, n); if (set_ieqpro_guide_rate(PortFD, GuideRateN[0].value)) GuideRateNP.s = IPS_OK; else GuideRateNP.s = IPS_ALERT; IDSetNumber(&GuideRateNP, NULL); return true; } if (!strcmp(name,GuideNSNP.name) || !strcmp(name,GuideWENP.name)) { processGuiderProperties(name, values, names, n); return true; } } return INDI::Telescope::ISNewNumber (dev, name, values, names, n); }
bool Weather::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) { // first check if it's for our device if (dev != nullptr && strcmp(dev, getDeviceName()) == 0) { if (strcmp(name, "GEOGRAPHIC_COORD") == 0) { int latindex = IUFindIndex("LAT", names, n); int longindex = IUFindIndex("LONG", names, n); int elevationindex = IUFindIndex("ELEV", names, n); if (latindex == -1 || longindex == -1 || elevationindex == -1) { LocationNP.s = IPS_ALERT; IDSetNumber(&LocationNP, "Location data missing or corrupted."); } double targetLat = values[latindex]; double targetLong = values[longindex]; double targetElev = values[elevationindex]; return processLocationInfo(targetLat, targetLong, targetElev); } // Update period if (strcmp(name, "WEATHER_UPDATE") == 0) { IUUpdateNumber(&UpdatePeriodNP, values, names, n); UpdatePeriodNP.s = IPS_OK; IDSetNumber(&UpdatePeriodNP, nullptr); if (UpdatePeriodN[0].value == 0) DEBUG(Logger::DBG_SESSION, "Periodic updates are disabled."); else { if (updateTimerID > 0) RemoveTimer(updateTimerID); updateTimerID = SetTimer(UpdatePeriodN[0].value * 1000); } return true; } // Pass to weather interface if (processNumber(dev, name, values, names, n)) return true; } return DefaultDevice::ISNewNumber(dev, name, values, names, n); }
bool LX200_16::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) { double newAlt = 0, newAz = 0; if (dev != nullptr && strcmp(dev, getDeviceName()) == 0) { if (!strcmp(name, HorizontalCoordsNP.name)) { int i = 0, nset = 0; for (nset = i = 0; i < n; i++) { INumber *horp = IUFindNumber(&HorizontalCoordsNP, names[i]); if (horp == &HorizontalCoordsN[0]) { newAlt = values[i]; nset += newAlt >= -90. && newAlt <= 90.0; } else if (horp == &HorizontalCoordsN[1]) { newAz = values[i]; nset += newAz >= 0. && newAz <= 360.0; } } if (nset == 2) { if (!isSimulation() && (setObjAz(PortFD, newAz) < 0 || setObjAlt(PortFD, newAlt) < 0)) { HorizontalCoordsNP.s = IPS_ALERT; IDSetNumber(&HorizontalCoordsNP, "Error setting Alt/Az."); return false; } targetAZ = newAz; targetALT = newAlt; return handleAltAzSlew(); } else { HorizontalCoordsNP.s = IPS_ALERT; IDSetNumber(&HorizontalCoordsNP, "Altitude or Azimuth missing or invalid"); return false; } } } LX200GPS::ISNewNumber(dev, name, values, names, n); return true; }
bool RotatorInterface::processNumber(const char *dev, const char *name, double values[], char *names[], int n) { INDI_UNUSED(names); INDI_UNUSED(n); if (dev != nullptr && strcmp(dev, m_defaultDevice->getDeviceName()) == 0) { //////////////////////////////////////////// // Move Absolute Angle //////////////////////////////////////////// if (strcmp(name, GotoRotatorNP.name) == 0) { if (values[0] == GotoRotatorN[0].value) { GotoRotatorNP.s = IPS_OK; IDSetNumber(&GotoRotatorNP, nullptr); return true; } GotoRotatorNP.s = MoveRotator(values[0]); IDSetNumber(&GotoRotatorNP, nullptr); if (GotoRotatorNP.s == IPS_BUSY) DEBUGFDEVICE(m_defaultDevice->getDeviceName(), Logger::DBG_SESSION, "Rotator moving to %.2f degrees...", values[0]); return true; } //////////////////////////////////////////// // Sync //////////////////////////////////////////// else if (strcmp(name, SyncRotatorNP.name) == 0) { if (values[0] == GotoRotatorN[0].value) { SyncRotatorNP.s = IPS_OK; IDSetNumber(&SyncRotatorNP, nullptr); return true; } bool rc = SyncRotator(values[0]); SyncRotatorNP.s = rc ? IPS_OK : IPS_ALERT; if (rc) SyncRotatorN[0].value = values[0]; IDSetNumber(&SyncRotatorNP, nullptr); return true; } } return false; }
void FocusMaster::TimerHit() { if (!isConnected()) return; //uint32_t currentTicks = 0; if (FocusTimerNP.s == IPS_BUSY) { float remaining = CalcTimeLeft(focusMoveStart, focusMoveRequest); if (remaining <= 0) { FocusTimerNP.s = IPS_OK; FocusTimerN[0].value = 0; AbortFocuser(); } else FocusTimerN[0].value = remaining * 1000.0; IDSetNumber(&FocusTimerNP, nullptr); } #if 0 bool rc = getPosition(¤tTicks); if (rc) FocusAbsPosN[0].value = currentTicks; if (FocusAbsPosNP.s == IPS_BUSY || FocusRelPosNP.s == IPS_BUSY) { if (targetPosition == FocusAbsPosN[0].value) { if (FocusRelPosNP.s == IPS_BUSY) { FocusRelPosNP.s = IPS_OK; IDSetNumber(&FocusRelPosNP, nullptr); } FocusAbsPosNP.s = IPS_OK; LOG_DEBUG("Focuser reached target position."); } } IDSetNumber(&FocusAbsPosNP, nullptr); #endif SetTimer(POLLMS); }
void INDI::GuiderInterface::GuideComplete(INDI_EQ_AXIS axis) { switch (axis) { case AXIS_DE: GuideNSNP.s = IPS_IDLE; IDSetNumber(&GuideNSNP, nullptr); break; case AXIS_RA: GuideWENP.s = IPS_IDLE; IDSetNumber(&GuideWENP, nullptr); break; } }
bool WatchDog::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) { if (dev != nullptr && strcmp(dev, getDeviceName()) == 0) { if (!strcmp(HeartBeatNP.name, name)) { double prevHeartBeat = HeartBeatN[0].value; if (watchdogClient->isBusy()) { HeartBeatNP.s = IPS_ALERT; IDSetNumber(&HeartBeatNP, nullptr); LOG_ERROR("Cannot change heart beat while shutdown is in progress..."); return true; } IUUpdateNumber(&HeartBeatNP, values, names, n); HeartBeatNP.s = IPS_OK; if (HeartBeatN[0].value == 0) LOG_INFO("Watchdog is disabled."); else { if (isConnected()) { if (prevHeartBeat != HeartBeatN[0].value) DEBUGF(INDI::Logger::DBG_SESSION, "Watchdog is enabled. Shutdown is triggered after %g minutes of communication loss with " "the client.", HeartBeatN[0].value); LOG_DEBUG("Received heart beat from client."); RemoveTimer(watchDogTimer); watchDogTimer = SetTimer(HeartBeatN[0].value * 60 * 1000); } else LOG_INFO("Watchdog is armed. Please connect to enable it."); } IDSetNumber(&HeartBeatNP, nullptr); return true; } } return DefaultDevice::ISNewNumber(dev, name, values, names, n); }
void SestoSenso::TimerHit() { if (!isConnected()) { SetTimer(POLLMS); return; } if (FocusAbsPosNP.s == IPS_BUSY || FocusRelPosNP.s == IPS_BUSY) { if (isMotionComplete()) { FocusAbsPosNP.s = IPS_OK; FocusRelPosNP.s = IPS_OK; IDSetNumber(&FocusRelPosNP, nullptr); IDSetNumber(&FocusAbsPosNP, nullptr); DEBUG(INDI::Logger::DBG_SESSION, "Focuser reached requested position."); } else IDSetNumber(&FocusAbsPosNP, nullptr); lastPos = FocusAbsPosN[0].value; SetTimer(POLLMS); return; } bool rc = updatePosition(); if (rc) { if (lastPos != FocusAbsPosN[0].value) { IDSetNumber(&FocusAbsPosNP, nullptr); lastPos = FocusAbsPosN[0].value; } } rc = updateTemperature(); if (rc) { if (fabs(lastTemperature - TemperatureN[0].value) >= 0.1) { IDSetNumber(&TemperatureNP, nullptr); lastTemperature = TemperatureN[0].value; } } SetTimer(POLLMS); }
bool MaxDomeII::Abort() { int error=0; int nRetry = 3; while (nRetry) { error = Abort_Azimuth_MaxDomeII(PortFD); handle_driver_error(&error, &nRetry); } while (nRetry) { error = Abort_Shutter_MaxDomeII(PortFD); handle_driver_error(&error, &nRetry); } DomeAbsPosNP.s = IPS_IDLE; IDSetNumber(&DomeAbsPosNP, NULL); // If we abort while in the middle of opening/closing shutter, alert. if (DomeShutterSP.s == IPS_BUSY) { DomeShutterSP.s = IPS_ALERT; IDSetSwitch(&DomeShutterSP, "Shutter operation aborted."); return false; } return true; }
IPState FocusSim::MoveAbsFocuser(uint32_t targetTicks) { if (targetTicks < FocusAbsPosN[0].min || targetTicks > FocusAbsPosN[0].max) { IDMessage(getDeviceName(), "Error, requested absolute position is out of range."); return IPS_ALERT; } double mid = (FocusAbsPosN[0].max - FocusAbsPosN[0].min)/2; IDMessage(getDeviceName() , "Focuser is moving to requested position..."); // Limit to +/- 10 from initTicks ticks = initTicks + (targetTicks - mid) / 5000.0; if (isDebug()) IDLog("Current ticks: %g\n", ticks); // simulate delay in motion as the focuser moves to the new position usleep( abs(targetTicks - FocusAbsPosN[0].value) * FOCUS_MOTION_DELAY); FocusAbsPosN[0].value = targetTicks; FWHMN[0].value = 0.5625*ticks*ticks + SeeingN[0].value; if (FWHMN[0].value < SeeingN[0].value) FWHMN[0].value = SeeingN[0].value; IDSetNumber(&FWHMNP, NULL); return IPS_OK; }
bool lacerta_mfoc::SetTempComp(double values[], char *names[], int n) { LOGF_INFO("-> TEMPCOMP_SETTINGS", 0); char MFOC_cmd[32] = ": D "; char MFOC_res[32] = {0}; int nbytes_read = 0; int nbytes_written = 0; int MFOC_tc_measd = 0; int tc_int = 0; char tc_char[32] = {0}; char MFOC_res_type[32] = "0"; TempCompNP.s = IPS_OK; IUUpdateNumber(&TempCompNP, values, names, n); tc_int = TempCompN[0].value; sprintf(tc_char, "%d", tc_int); strcat(tc_char, " #"); strcat(MFOC_cmd, tc_char); tty_write_string(PortFD, MFOC_cmd, &nbytes_written); LOGF_DEBUG("CMD <%s>", MFOC_cmd); tty_write_string(PortFD, ": U #", &nbytes_written); tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read); sscanf (MFOC_res, "%s %d", MFOC_res_type, &MFOC_tc_measd); LOGF_DEBUG("RES <%s>", MFOC_res); IDSetNumber(&TempCompNP, nullptr); return true; }
bool lacerta_mfoc::SetBacklash(double values[], char *names[], int n) { LOGF_DEBUG("-> BACKLASH_SETTINGS", 0); char MFOC_cmd[32] = ": B "; char MFOC_res[32] = {0}; int nbytes_read = 0; int nbytes_written = 0; int MFOC_tdir_measd = 0; int bl_int = 0; char bl_char[32] = {0}; char MFOC_res_type[32] = "0"; BacklashNP.s = IPS_OK; IUUpdateNumber(&BacklashNP, values, names, n); bl_int = BacklashN[0].value; sprintf(bl_char, "%d", bl_int); strcat(bl_char, " #"); strcat(MFOC_cmd, bl_char); tty_write_string(PortFD, MFOC_cmd, &nbytes_written); LOGF_DEBUG("CMD <%s>", MFOC_cmd); tty_write_string(PortFD, ": J #", &nbytes_written); tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read); sscanf (MFOC_res, "%s %d", MFOC_res_type, &MFOC_tdir_measd); LOGF_DEBUG("RES <%s>", MFOC_res); IDSetNumber(&BacklashNP, nullptr); return true; }