diff --git a/indi-armadillo-platypus/beaver_dome.cpp b/indi-armadillo-platypus/beaver_dome.cpp index 3d04ffc7e..c218994dc 100644 --- a/indi-armadillo-platypus/beaver_dome.cpp +++ b/indi-armadillo-platypus/beaver_dome.cpp @@ -287,12 +287,12 @@ IPState Beaver::MoveAbs(double az) ////////////////////////////////////////////////////////////////////////////// IPState Beaver::MoveRel(double azDiff) { - m_TargetRotatorAz = DomeAbsPosN[0].value + azDiff; + m_TargetRotatorAz = DomeAbsPosNP[0].getValue() + azDiff; - if (m_TargetRotatorAz < DomeAbsPosN[0].min) - m_TargetRotatorAz += DomeAbsPosN[0].max; - if (m_TargetRotatorAz > DomeAbsPosN[0].max) - m_TargetRotatorAz -= DomeAbsPosN[0].max; + if (m_TargetRotatorAz < DomeAbsPosNP[0].getMin()) + m_TargetRotatorAz += DomeAbsPosNP[0].getMax(); + if (m_TargetRotatorAz > DomeAbsPosNP[0].getMax()) + m_TargetRotatorAz -= DomeAbsPosNP[0].getMax(); // It will take a few cycles to reach final position return MoveAbs(m_TargetRotatorAz); @@ -378,7 +378,7 @@ bool Beaver::rotatorGetAz() double res = 0; if (sendCommand("!dome getaz#", res)) { - DomeAbsPosN[0].value = res; + DomeAbsPosNP[0].setValue(res); return true; } diff --git a/indi-armadillo-platypus/dragonfly_dome.cpp b/indi-armadillo-platypus/dragonfly_dome.cpp index f5c77743c..2ddf7503c 100644 --- a/indi-armadillo-platypus/dragonfly_dome.cpp +++ b/indi-armadillo-platypus/dragonfly_dome.cpp @@ -409,7 +409,7 @@ void DragonFlyDome::TimerHit() if (getDomeState() == DOME_MOVING || getDomeState() == DOME_PARKING || getDomeState() == DOME_UNPARKING) { // Roll off is opening - if (DomeMotionS[DOME_CW].s == ISS_ON) + if (DomeMotionSP[DOME_CW].getState() == ISS_ON) { if (isSensorOn(DomeControlSensorNP[SENSOR_UNPARKED].getValue())) { @@ -418,7 +418,7 @@ void DragonFlyDome::TimerHit() } } // Roll Off is closing - else if (DomeMotionS[DOME_CCW].s == ISS_ON) + else if (DomeMotionSP[DOME_CCW].getState() == ISS_ON) { if (isSensorOn(DomeControlSensorNP[SENSOR_PARKED].getValue())) { diff --git a/indi-maxdomeii/maxdomeii.cpp b/indi-maxdomeii/maxdomeii.cpp index 8f0ec2032..ebf042829 100644 --- a/indi-maxdomeii/maxdomeii.cpp +++ b/indi-maxdomeii/maxdomeii.cpp @@ -54,10 +54,10 @@ MaxDomeII::MaxDomeII() bool MaxDomeII::SetupParms() { - DomeAbsPosN[0].value = 0; + DomeAbsPosNP[0].setValue(0); - IDSetNumber(&DomeAbsPosNP, nullptr); - IDSetNumber(&DomeParamNP, nullptr); + DomeAbsPosNP.apply(); + DomeParamNP.apply(); if (InitPark()) { @@ -214,8 +214,9 @@ void MaxDomeII::TimerHit() // Close Shutter if it is not if (shutterSt != SS_CLOSED) { - DomeShutterSP.s = ControlShutter(SHUTTER_CLOSE); - IDSetSwitch(&DomeShutterSP, "Closing shutter due watch dog"); + DomeShutterSP.setState(ControlShutter(SHUTTER_CLOSE)); + LOG_INFO("Closing shutter due watch dog"); + DomeShutterSP.apply(); } } @@ -235,13 +236,14 @@ void MaxDomeII::TimerHit() switch (shutterSt) { case SS_CLOSED: - if (DomeShutterS[1].s == ISS_ON) // Close Shutter + if (DomeShutterSP[1].getState() == ISS_ON) // Close Shutter { - if (DomeShutterSP.s == IPS_BUSY || DomeShutterSP.s == IPS_ALERT) + if (DomeShutterSP.getState() == IPS_BUSY || DomeShutterSP.getState() == IPS_ALERT) { - DomeShutterSP.s = IPS_OK; // Shutter close movement ends. + DomeShutterSP.setState(IPS_OK); // Shutter close movement ends. nTimeSinceShutterStart = -1; - IDSetSwitch(&DomeShutterSP, "Shutter is closed"); + LOG_INFO("Shutter is closed"); + DomeShutterSP.apply(); } } else @@ -251,51 +253,56 @@ void MaxDomeII::TimerHit() // A movement has started. Warn but don't change if (nTimeSinceShutterStart >= 4) { - DomeShutterSP.s = IPS_ALERT; // Shutter close movement ends. - IDSetSwitch(&DomeShutterSP, "Shutter still closed"); + DomeShutterSP.setState(IPS_ALERT); // Shutter close movement ends. + LOG_INFO("Shutter still closed"); + DomeShutterSP.apply(); } } else { // For some reason (manual operation?) the shutter has closed - DomeShutterSP.s = IPS_IDLE; - DomeShutterS[1].s = ISS_ON; - DomeShutterS[0].s = ISS_OFF; - IDSetSwitch(&DomeShutterSP, "Unexpected shutter closed"); + DomeShutterSP.setState(IPS_IDLE); + DomeShutterSP[1].setState(ISS_ON); + DomeShutterSP[0].setState(ISS_OFF); + LOG_ERROR("Unexpected shutter closed"); + DomeShutterSP.apply(); } } break; case SS_OPENING: - if (DomeShutterS[0].s == ISS_OFF) // not opening Shutter + if (DomeShutterSP[0].getState() == ISS_OFF) // not opening Shutter { // For some reason the shutter is opening (manual operation?) - DomeShutterSP.s = IPS_ALERT; - DomeShutterS[1].s = ISS_OFF; - DomeShutterS[0].s = ISS_OFF; - IDSetSwitch(&DomeShutterSP, "Unexpected shutter opening"); + DomeShutterSP.setState(IPS_ALERT); + DomeShutterSP[1].setState(ISS_OFF); + DomeShutterSP[0].setState(ISS_OFF); + LOG_INFO("Unexpected shutter opening"); + DomeShutterSP.apply(); } else if (nTimeSinceShutterStart < 0) { // For some reason the shutter is opening (manual operation?) - DomeShutterSP.s = IPS_ALERT; + DomeShutterSP.setState(IPS_ALERT); nTimeSinceShutterStart = 0; - IDSetSwitch(&DomeShutterSP, "Unexpected shutter opening"); + LOG_INFO("Unexpected shutter opening"); + DomeShutterSP.apply(); } - else if (DomeShutterSP.s == IPS_ALERT) + else if (DomeShutterSP.getState() == IPS_ALERT) { // The alert has corrected - DomeShutterSP.s = IPS_BUSY; - IDSetSwitch(&DomeShutterSP, "Shutter is opening"); + DomeShutterSP.setState(IPS_BUSY); + LOG_INFO("Shutter is opening"); + DomeShutterSP.apply(); } break; case SS_OPEN: - if (DomeShutterS[0].s == ISS_ON) // Open Shutter + if (DomeShutterSP[0].getState() == ISS_ON) // Open Shutter { - if (DomeShutterSP.s == IPS_BUSY || DomeShutterSP.s == IPS_ALERT) + if (DomeShutterSP.getState() == IPS_BUSY || DomeShutterSP.getState() == IPS_ALERT) { - DomeShutterSP.s = IPS_OK; // Shutter open movement ends. + DomeShutterSP.setState(IPS_OK); // Shutter open movement ends. nTimeSinceShutterStart = -1; - IDSetSwitch(&DomeShutterSP, "Shutter is open"); + DomeShutterSP.apply(); } } else @@ -305,70 +312,78 @@ void MaxDomeII::TimerHit() // A movement has started. Warn but don't change if (nTimeSinceShutterStart >= 4) { - DomeShutterSP.s = IPS_ALERT; // Shutter open movement alert. - IDSetSwitch(&DomeShutterSP, "Shutter still open"); + DomeShutterSP.setState(IPS_ALERT); // Shutter open movement alert. + LOG_INFO("Shutter still open"); + DomeShutterSP.apply(); } } else { // For some reason (manual operation?) the shutter has open - DomeShutterSP.s = IPS_IDLE; - DomeShutterS[1].s = ISS_ON; - DomeShutterS[0].s = ISS_OFF; - IDSetSwitch(&DomeShutterSP, "Unexpected shutter open"); + DomeShutterSP.setState(IPS_IDLE); + DomeShutterSP[1].setState(ISS_ON); + DomeShutterSP[0].setState(ISS_OFF); + LOG_INFO("Unexpected shutter open"); + DomeShutterSP.apply(); } } break; case SS_CLOSING: - if (DomeShutterS[1].s == ISS_OFF) // Not closing Shutter + if (DomeShutterSP[1].getState() == ISS_OFF) // Not closing Shutter { // For some reason the shutter is closing (manual operation?) - DomeShutterSP.s = IPS_ALERT; - DomeShutterS[1].s = ISS_ON; - DomeShutterS[0].s = ISS_OFF; - IDSetSwitch(&DomeShutterSP, "Unexpected shutter closing"); + DomeShutterSP.setState(IPS_ALERT); + DomeShutterSP[1].setState(ISS_ON); + DomeShutterSP[0].setState(ISS_OFF); + LOG_INFO("Unexpected shutter closing"); + DomeShutterSP.apply(); } else if (nTimeSinceShutterStart < 0) { // For some reason the shutter is opening (manual operation?) - DomeShutterSP.s = IPS_ALERT; + DomeShutterSP.setState(IPS_ALERT); nTimeSinceShutterStart = 0; - IDSetSwitch(&DomeShutterSP, "Unexpected shutter closing"); + LOG_INFO("Unexpected shutter closing"); + DomeShutterSP.apply(); } - else if (DomeShutterSP.s == IPS_ALERT) + else if (DomeShutterSP.getState() == IPS_ALERT) { // The alert has corrected - DomeShutterSP.s = IPS_BUSY; - IDSetSwitch(&DomeShutterSP, "Shutter is closing"); + DomeShutterSP.setState(IPS_BUSY); + LOG_INFO("Shutter is closing"); + DomeShutterSP.apply(); } break; case SS_ERROR: - DomeShutterSP.s = IPS_ALERT; - DomeShutterS[1].s = ISS_OFF; - DomeShutterS[0].s = ISS_OFF; - IDSetSwitch(&DomeShutterSP, "Shutter error"); + DomeShutterSP.setState(IPS_ALERT); + DomeShutterSP[1].setState(ISS_OFF); +; + DomeShutterSP[0].setState(ISS_OFF); + LOG_ERROR("Shutter error"); + DomeShutterSP.apply(); break; case SS_ABORTED: default: if (nTimeSinceShutterStart >= 0) { - DomeShutterSP.s = IPS_ALERT; // Shutter movement aborted. - DomeShutterS[1].s = ISS_OFF; - DomeShutterS[0].s = ISS_OFF; + DomeShutterSP.setState(IPS_ALERT); // Shutter movement aborted. + DomeShutterSP[1].setState(ISS_OFF); + DomeShutterSP[0].setState(ISS_OFF); nTimeSinceShutterStart = -1; - IDSetSwitch(&DomeShutterSP, "Unknown shutter status"); + LOG_ERROR("Unknown shutter status"); + DomeShutterSP.apply(); } break; } // Azimuth nAz = TicksToAzimuth(nCurrentTicks); - if (DomeAbsPosN[0].value != nAz) + if (DomeAbsPosNP[0].getValue() != nAz) { // Only refresh position if it changed - DomeAbsPosN[0].value = nAz; + DomeAbsPosNP[0].setValue(nAz); //sprintf(buf,"%d", nCurrentTicks); - IDSetNumber(&DomeAbsPosNP, nullptr); + DomeAbsPosNP.apply(); } switch (nAzimuthStatus) @@ -380,14 +395,15 @@ void MaxDomeII::TimerHit() if (nTargetAzimuth >= 0 && AzimuthDistance(nTargetAzimuth, nCurrentTicks) > 3) // Maximum difference allowed: 3 ticks { - DomeAbsPosNP.s = IPS_ALERT; + DomeAbsPosNP.setState(IPS_ALERT); nTimeSinceAzimuthStart = -1; - IDSetNumber(&DomeAbsPosNP, "Could not position right"); + LOG_ERROR("Could not position right"); + DomeAbsPosNP.apply(); } else { // Succesfull end of movement - if (DomeAbsPosNP.s != IPS_OK) + if (DomeAbsPosNP.getState() != IPS_OK) { setDomeState(DOME_SYNCED); nTimeSinceAzimuthStart = -1; @@ -401,13 +417,13 @@ void MaxDomeII::TimerHit() LOG_INFO("Dome is homed"); HomeSP.apply(); } - if (ParkSP.s != IPS_OK) + if (ParkSP.getState() != IPS_OK) { - if (ParkS[0].s == ISS_ON) + if (ParkSP[0].getState() == ISS_ON) { SetParked(true); } - if (ParkS[1].s == ISS_ON) + if (ParkSP[1].getState() == ISS_ON) { SetParked(false); } @@ -421,17 +437,19 @@ void MaxDomeII::TimerHit() { nTimeSinceAzimuthStart = 0; nTargetAzimuth = -1; - DomeAbsPosNP.s = IPS_ALERT; - IDSetNumber(&DomeAbsPosNP, "Unexpected dome moving"); + DomeAbsPosNP.setState(IPS_ALERT); + LOG_INFO("Unexpected dome moving"); + DomeAbsPosNP.apply(); } break; case AS_ERROR: if (nTimeSinceAzimuthStart >= 0) { - DomeAbsPosNP.s = IPS_ALERT; + DomeAbsPosNP.setState(IPS_ALERT); nTimeSinceAzimuthStart = -1; nTargetAzimuth = -1; - IDSetNumber(&DomeAbsPosNP, "Dome Error"); + LOG_ERROR("Dome Error"); + DomeAbsPosNP.apply(); } default: break; @@ -454,7 +472,7 @@ IPState MaxDomeII::MoveAbs(double newAZ) int error; int nRetry = 3; - currAZ = DomeAbsPosN[0].value; + currAZ = DomeAbsPosNP[0].getValue(); // Take the shortest path if (newAZ > currAZ) @@ -498,7 +516,7 @@ IPState MaxDomeII::Move(DomeDirection dir, DomeMotionCommand operation) if (operation == MOTION_START) { LOGF_DEBUG("Move dir=%d", dir); - double currAZ = DomeAbsPosN[0].value; + double currAZ = DomeAbsPosNP[0].getValue(); double newAZ = currAZ > 180 ? currAZ - 180 : currAZ + 180; int newPos = AzimuthToTicks(newAZ); int nDir = dir ? MAXDOMEII_WE_DIR : MAXDOMEII_EW_DIR; @@ -528,8 +546,8 @@ IPState MaxDomeII::Move(DomeDirection dir, DomeMotionCommand operation) if (error != 0) return IPS_ALERT; - DomeAbsPosNP.s = IPS_IDLE; - IDSetNumber(&DomeAbsPosNP, NULL); + DomeAbsPosNP.setState(IPS_IDLE); + DomeAbsPosNP.apply(); nTimeSinceAzimuthStart = -1; } @@ -553,14 +571,15 @@ bool MaxDomeII::Abort() handle_driver_error(&error, &nRetry); } - DomeAbsPosNP.s = IPS_IDLE; - IDSetNumber(&DomeAbsPosNP, nullptr); + DomeAbsPosNP.setState(IPS_IDLE); + DomeAbsPosNP.apply(); // If we abort while in the middle of opening/closing shutter, alert. - if (DomeShutterSP.s == IPS_BUSY) + if (DomeShutterSP.getState() == IPS_BUSY) { - DomeShutterSP.s = IPS_ALERT; - IDSetSwitch(&DomeShutterSP, "Shutter operation aborted."); + DomeShutterSP.setState(IPS_ALERT); + LOG_INFO("Shutter operation aborted."); + DomeShutterSP.apply(); return false; } @@ -925,7 +944,7 @@ IPState MaxDomeII::ConfigureShutterOperation(int nMDBOS, double ShutterOperation * ***********************************************************************************/ bool MaxDomeII::SetCurrentPark() { - SetAxis1Park(DomeAbsPosN[0].value); + SetAxis1Park(DomeAbsPosNP[0].getValue()); return true; } /************************************************************************************ @@ -1011,12 +1030,12 @@ IPState MaxDomeII::Park() LOGF_INFO("Parking to %.2f azimuth...", targetAz); MoveAbs(targetAz); - if (HasShutter() && ShutterParkPolicyS[SHUTTER_CLOSE_ON_PARK].s == ISS_ON) + if (HasShutter() && ShutterParkPolicySP[SHUTTER_CLOSE_ON_PARK].getState() == ISS_ON) { LOG_INFO("Closing shutter on parking..."); ControlShutter(ShutterOperation::SHUTTER_CLOSE); - DomeShutterS[SHUTTER_OPEN].s = ISS_OFF; - DomeShutterS[SHUTTER_CLOSE].s = ISS_ON; + DomeShutterSP[SHUTTER_OPEN].setState(ISS_OFF); + DomeShutterSP[SHUTTER_CLOSE].setState(ISS_ON); setShutterState(SHUTTER_MOVING); } @@ -1039,12 +1058,12 @@ IPState MaxDomeII::UnPark() nTimeSinceAzimuthStart = 0; nTargetAzimuth = -1; - if (HasShutter() && ShutterParkPolicyS[SHUTTER_OPEN_ON_UNPARK].s == ISS_ON) + if (HasShutter() && ShutterParkPolicySP[SHUTTER_OPEN_ON_UNPARK].getState() == ISS_ON) { LOG_INFO("Opening shutter on unparking..."); ControlShutter(ShutterOperation::SHUTTER_OPEN); - DomeShutterS[SHUTTER_OPEN].s = ISS_ON; - DomeShutterS[SHUTTER_CLOSE].s = ISS_OFF; + DomeShutterSP[SHUTTER_OPEN].setState(ISS_ON); + DomeShutterSP[SHUTTER_CLOSE].setState(ISS_OFF); setShutterState(SHUTTER_MOVING); } return IPS_BUSY; diff --git a/indi-nexdome/nex_dome.cpp b/indi-nexdome/nex_dome.cpp index 5a9ab5d09..eba21c9f7 100644 --- a/indi-nexdome/nex_dome.cpp +++ b/indi-nexdome/nex_dome.cpp @@ -416,20 +416,20 @@ bool NexDome::ISNewNumber(const char *dev, const char *name, double values[], ch /// Override INDI::Dome implementaion since we need to update dead-zone /// To be compatible with this. /////////////////////////////////////////////////////////////////////////////// - else if (!strcmp(name, DomeParamNP.name)) + else if (DomeParamNP.isNameMatch(name)) { - IUUpdateNumber(&DomeParamNP, values, names, n); - DomeParamNP.s = IPS_OK; - IDSetNumber(&DomeParamNP, nullptr); + DomeParamNP.update(values, names, n); + DomeParamNP.setState(IPS_OK); + DomeParamNP.apply(); - double minDeadZone = round((DomeParamN[0].value - 0.1) * StepsPerDegree); + double minDeadZone = round((DomeParamNP[0].getValue() - 0.1) * StepsPerDegree); if (minDeadZone < RotatorSettingsNP[S_ZONE].getValue()) { if (setParameter(ND::DEAD_ZONE, ND::ROTATOR, minDeadZone)) { RotatorSettingsNP[S_ZONE].setValue(minDeadZone); LOGF_INFO("Updating dead-zone to %.f steps since autosync threshold was set to %.2f degrees.", minDeadZone, - DomeParamN[0].value); + DomeParamNP[0].getValue()); RotatorSettingsNP.apply(); } } @@ -443,10 +443,10 @@ bool NexDome::ISNewNumber(const char *dev, const char *name, double values[], ch { std::vector currentSettings(RotatorSettingsNP.count()); std::vector rc(RotatorSettingsNP.count(), true); - for (int i = 0; i < RotatorSettingsNP.count(); i++) + for (size_t i = 0; i < RotatorSettingsNP.count(); i++) currentSettings[i] = RotatorSettingsNP[i].getValue(); - for (int i = 0; i < RotatorSettingsNP.count(); i++) + for (size_t i = 0; i < RotatorSettingsNP.count(); i++) { if (std::fabs(values[i] - currentSettings[i]) > 0) { @@ -474,7 +474,7 @@ bool NexDome::ISNewNumber(const char *dev, const char *name, double values[], ch } bool result = true; - for (int i = 0; i < RotatorSettingsNP.count(); i++) + for (size_t i = 0; i < RotatorSettingsNP.count(); i++) result &= rc[i]; if (result) @@ -537,11 +537,11 @@ bool NexDome::ISNewNumber(const char *dev, const char *name, double values[], ch { std::vector currentSettings(ShutterSettingsNP.count()); std::vector rc(ShutterSettingsNP.count(), true); - for (int i = 0; i < ShutterSettingsNP.count(); i++) + for (size_t i = 0; i < ShutterSettingsNP.count(); i++) currentSettings[i] = ShutterSettingsNP[i].getValue(); - for (int i = 0; i < ShutterSettingsNP.count(); i++) + for (size_t i = 0; i < ShutterSettingsNP.count(); i++) { if (std::fabs(values[i] - currentSettings[i]) > 0) { @@ -559,7 +559,7 @@ bool NexDome::ISNewNumber(const char *dev, const char *name, double values[], ch } bool result = true; - for (int i = 0; i < ShutterSettingsNP.count(); i++) + for (size_t i = 0; i < ShutterSettingsNP.count(); i++) result &= rc[i]; if (result) @@ -634,7 +634,7 @@ IPState NexDome::Move(DomeDirection dir, DomeMotionCommand operation) { if (operation == MOTION_START) { - double nextTarget = range360(DomeAbsPosN[0].value + (dir == DOME_CW ? 10 : -10)); + double nextTarget = range360(DomeAbsPosNP[0].getValue() + (dir == DOME_CW ? 10 : -10)); LOGF_INFO("Moving %s by 10 degrees...", (dir == DOME_CW ? "CW" : "CCW")); return MoveAbs(nextTarget); } @@ -653,12 +653,12 @@ IPState NexDome::Park() LOGF_INFO("Parking to %.2f azimuth...", GetAxis1Park()); - if (HasShutter() && ShutterParkPolicyS[SHUTTER_CLOSE_ON_PARK].s == ISS_ON) + if (HasShutter() && ShutterParkPolicySP[SHUTTER_CLOSE_ON_PARK].getState() == ISS_ON) { LOG_INFO("Closing shutter on parking..."); ControlShutter(ShutterOperation::SHUTTER_CLOSE); - DomeShutterS[SHUTTER_OPEN].s = ISS_OFF; - DomeShutterS[SHUTTER_CLOSE].s = ISS_ON; + DomeShutterSP[SHUTTER_OPEN].setState(ISS_OFF); + DomeShutterSP[SHUTTER_CLOSE].setState(ISS_ON); setShutterState(SHUTTER_MOVING); } @@ -670,12 +670,12 @@ IPState NexDome::Park() ////////////////////////////////////////////////////////////////////////////// IPState NexDome::UnPark() { - if (HasShutter() && ShutterParkPolicyS[SHUTTER_OPEN_ON_UNPARK].s == ISS_ON) + if (HasShutter() && ShutterParkPolicySP[SHUTTER_OPEN_ON_UNPARK].getState() == ISS_ON) { LOG_INFO("Opening shutter on unparking..."); ControlShutter(ShutterOperation::SHUTTER_OPEN); - DomeShutterS[SHUTTER_OPEN].s = ISS_ON; - DomeShutterS[SHUTTER_CLOSE].s = ISS_OFF; + DomeShutterSP[SHUTTER_OPEN].setState(ISS_ON); + DomeShutterSP[SHUTTER_CLOSE].setState(ISS_OFF); setShutterState(SHUTTER_MOVING); return IPS_BUSY; } @@ -745,7 +745,7 @@ bool NexDome::Abort() ////////////////////////////////////////////////////////////////////////////// bool NexDome::SetCurrentPark() { - SetAxis1Park(DomeAbsPosN[0].value); + SetAxis1Park(DomeAbsPosNP[0].getValue()); return true; } @@ -1032,10 +1032,10 @@ bool NexDome::processEvent(const std::string &event) { // 153 = full_steps_circumference / 360 = 55080 / 360 double newAngle = range360(std::stoi(value) / StepsPerDegree); - if (std::fabs(DomeAbsPosN[0].value - newAngle) > 0.001) + if (std::abs(DomeAbsPosNP[0].getValue() - newAngle) > 0.001) { - DomeAbsPosN[0].value = newAngle; - IDSetNumber(&DomeAbsPosNP, nullptr); + DomeAbsPosNP[0].setValue(newAngle); + DomeAbsPosNP.apply(); } } catch (...) @@ -1169,10 +1169,10 @@ bool NexDome::processRotatorReport(const std::string &report) } double posAngle = range360(position / StepsPerDegree); - if (std::fabs(posAngle - DomeAbsPosN[0].value) > 0.01) + if (std::fabs(posAngle - DomeAbsPosNP[0].getValue()) > 0.01) { - DomeAbsPosN[0].value = posAngle; - IDSetNumber(&DomeAbsPosNP, nullptr); + DomeAbsPosNP[0].setValue(posAngle); + DomeAbsPosNP.apply(); } double homeAngle = range360(home_position / StepsPerDegree); diff --git a/indi-ocs/ocs.cpp b/indi-ocs/ocs.cpp index a5c582ed1..43194bd62 100644 --- a/indi-ocs/ocs.cpp +++ b/indi-ocs/ocs.cpp @@ -572,7 +572,7 @@ bool OCS::updateProperties() // Remove unsupported derived controls //------------------------------------ - deleteProperty(DomeMotionSP.name); + deleteProperty(DomeMotionSP); // if (weather_tab_enabled) { // WI::updateProperties(); @@ -809,46 +809,46 @@ void OCS::TimerHit() if (strcmp(dome_status_response, "H") == 0) { if (getDomeState() != DOME_IDLE) { setDomeState(DOME_IDLE); - ParkS[0].s = ISS_OFF; - ParkS[1].s = ISS_ON; - ParkSP.s = IPS_OK; - IDSetSwitch(&ParkSP, nullptr); + ParkSP[0].setState(ISS_OFF); + ParkSP[1].setState(ISS_ON); + ParkSP.setState(IPS_OK); + ParkSP.apply(); } sprintf(dome_message, "Home"); } else if (strcmp(dome_status_response, "P") == 0) { if (getDomeState() != DOME_PARKED) { setDomeState(DOME_PARKED); - ParkS[0].s = ISS_ON; - ParkS[1].s = ISS_OFF; - ParkSP.s = IPS_OK; - IDSetSwitch(&ParkSP, nullptr); + ParkSP[0].setState(ISS_ON); + ParkSP[1].setState(ISS_OFF); + ParkSP.setState(IPS_OK); + ParkSP.apply(); } sprintf(dome_message, "Parked"); } else if (strcmp(dome_status_response, "K") == 0) { if (getDomeState() != DOME_PARKING) { setDomeState(DOME_PARKING); - ParkS[0].s = ISS_OFF; - ParkS[1].s = ISS_OFF; - ParkSP.s = IPS_BUSY; - IDSetSwitch(&ParkSP, nullptr); + ParkSP[0].setState(ISS_OFF); + ParkSP[1].setState(ISS_OFF); + ParkSP.setState(IPS_BUSY); + ParkSP.apply(); } sprintf(dome_message, "Parking"); } else if (strcmp(dome_status_response, "S") == 0) { if (getDomeState() != DOME_MOVING) { setDomeState(DOME_MOVING); - ParkS[0].s = ISS_OFF; - ParkS[1].s = ISS_ON; - ParkSP.s = IPS_OK; - IDSetSwitch(&ParkSP, nullptr); + ParkSP[0].setState(ISS_OFF); + ParkSP[1].setState(ISS_ON); + ParkSP.setState(IPS_OK); + ParkSP.apply(); } sprintf(dome_message, "Slewing"); } else if (strcmp(dome_status_response, "I") == 0) { if (getDomeState() != DOME_IDLE) { setDomeState(DOME_IDLE); - ParkS[0].s = ISS_OFF; - ParkS[1].s = ISS_ON; - ParkSP.s = IPS_OK; - IDSetSwitch(&ParkSP, nullptr); + ParkSP[0].setState(ISS_OFF); + ParkSP[1].setState(ISS_ON); + ParkSP.setState(IPS_OK); + ParkSP.apply(); } sprintf(dome_message, "Idle"); } @@ -864,8 +864,9 @@ void OCS::TimerHit() int dome_position_error_or_fail = getCommandDoubleResponse(PortFD, &position, dome_position_response, OCS_get_dome_azimuth); if (dome_position_error_or_fail > 1 && position != conversion_error) { - DomeAbsPosN->value = position; - IDSetNumber(&DomeAbsPosNP, nullptr); + // DomeAbsPosN->value = position; + DomeAbsPosNP[0].setValue(position); + DomeAbsPosNP.apply(); } else { LOGF_WARN("Communication error on get Dome position %s, this update aborted, will try again...", OCS_get_dome_azimuth); } diff --git a/indi-rolloffino/rolloffino.cpp b/indi-rolloffino/rolloffino.cpp index 916cf38d8..b98227bbb 100644 --- a/indi-rolloffino/rolloffino.cpp +++ b/indi-rolloffino/rolloffino.cpp @@ -533,12 +533,12 @@ void RollOffIno::TimerHit() { if (timeleft - 5 <= 0) // Use timeout approaching to set faux switch indicator { - if (DomeMotionS[DOME_CW].s == ISS_ON) // Opening + if (DomeMotionSP[DOME_CW].getState() == ISS_ON) // Opening { simRoofOpen = true; simRoofClosed = false; } - else if (DomeMotionS[DOME_CCW].s == ISS_ON) // Closing + else if (DomeMotionSP[DOME_CCW].getState() == ISS_ON) // Closing { simRoofClosed = true; simRoofOpen = false; @@ -548,7 +548,7 @@ void RollOffIno::TimerHit() updateRoofStatus(); - if (DomeMotionSP.s == IPS_BUSY) + if (DomeMotionSP.getState() == IPS_BUSY) { // Abort called stop movement. if (MotionRequest < 0) @@ -559,7 +559,7 @@ void RollOffIno::TimerHit() else { // Roll off is opening - if (DomeMotionS[DOME_CW].s == ISS_ON) + if (DomeMotionSP[DOME_CW].getState() == ISS_ON) { if (fullyOpenedLimitSwitch == ISS_ON) { @@ -580,7 +580,7 @@ void RollOffIno::TimerHit() } } // Roll Off is closing - else if (DomeMotionS[DOME_CCW].s == ISS_ON) + else if (DomeMotionSP[DOME_CCW].getState() == ISS_ON) { if (fullyClosedLimitSwitch == ISS_ON) { @@ -789,27 +789,27 @@ bool RollOffIno::Abort() return true; } - if (closeState && DomeMotionSP.s != IPS_BUSY) + if (closeState && DomeMotionSP.getState() != IPS_BUSY) { LOG_WARN("Roof appears to be closed and stationary, no action taken on abort request"); return true; } - else if (openState && DomeMotionSP.s != IPS_BUSY) + else if (openState && DomeMotionSP.getState() != IPS_BUSY) { LOG_WARN("Roof appears to be open and stationary, no action taken on abort request"); return true; } - else if (DomeMotionSP.s != IPS_BUSY) + else if (DomeMotionSP.getState() != IPS_BUSY) { LOG_WARN("Roof appears to be partially open and stationary, no action taken on abort request"); } - else if (DomeMotionSP.s == IPS_BUSY) + else if (DomeMotionSP.getState() == IPS_BUSY) { - if (DomeMotionS[DOME_CW].s == ISS_ON) + if (DomeMotionSP[DOME_CW].getState() == ISS_ON) { LOG_WARN("Abort roof action requested while the roof was opening. Direction correction may be needed on the next move request."); } - else if (DomeMotionS[DOME_CCW].s == ISS_ON) + else if (DomeMotionSP[DOME_CCW].getState() == ISS_ON) { LOG_WARN("Abort roof action requested while the roof was closing. Direction correction may be needed on the next move request."); } @@ -822,9 +822,9 @@ bool RollOffIno::Abort() // If both limit switches are off, then we're neither parked nor unparked. if (fullyOpenedLimitSwitch == ISS_OFF && fullyClosedLimitSwitch == ISS_OFF) { - IUResetSwitch(&ParkSP); - ParkSP.s = IPS_IDLE; - IDSetSwitch(&ParkSP, nullptr); + ParkSP.reset(); + ParkSP.setState(IPS_IDLE); + ParkSP.apply(); } return true; } diff --git a/indi-talon6/talon6.cpp b/indi-talon6/talon6.cpp index 5abae8b15..861bf5589 100644 --- a/indi-talon6/talon6.cpp +++ b/indi-talon6/talon6.cpp @@ -158,7 +158,7 @@ bool Talon6::updateProperties() deleteProperty(SwitchesLP.name); } // We do not need some of the properties defined in parent class - deleteProperty(DomeMotionSP.name); + deleteProperty(DomeMotionSP); return true; } @@ -336,7 +336,7 @@ void Talon6::TimerHit() getDeviceStatus(); SetTimer(1000); - if (DomeMotionSP.s == IPS_BUSY) + if (DomeMotionSP.getState() == IPS_BUSY) { // Abort called if (MotionRequest < 0) @@ -346,7 +346,7 @@ void Talon6::TimerHit() return; } // Roll off is opening - if (DomeMotionS[DOME_CW].s == ISS_ON) + if (DomeMotionSP[DOME_CW].getState() == ISS_ON) { if (fullOpenRoofSwitch == ISS_ON) { @@ -356,7 +356,7 @@ void Talon6::TimerHit() } } // Roll Off is closing - else if (DomeMotionS[DOME_CCW].s == ISS_ON) + else if (DomeMotionSP[DOME_CCW].getState() == ISS_ON) { if (fullClosedRoofSwitch == ISS_ON ) { @@ -785,9 +785,9 @@ bool Talon6::Abort() // If both limit switches are off, then we're neither parked nor unparked. if (fullOpenRoofSwitch == ISS_OFF && fullClosedRoofSwitch == ISS_OFF) { - IUResetSwitch(&ParkSP); - ParkSP.s = IPS_IDLE; - IDSetSwitch(&ParkSP, nullptr); + ParkSP.reset(); + ParkSP.setState(IPS_IDLE); + ParkSP.apply(); WriteString("&S#"); }