From c6f3eb2d79fe8fa814f143fe758a3e2f1fe2141a Mon Sep 17 00:00:00 2001 From: Jasem Mutlaq Date: Fri, 30 Aug 2024 12:50:10 +0300 Subject: [PATCH] Migrate rest of INDI::Telescope legacy properties --- drivers/telescope/ioptronHC8406.cpp | 2 +- drivers/telescope/lx200_OnStep.cpp | 29 +--- drivers/telescope/lx200ap_v2.cpp | 8 +- drivers/telescope/pmc8.cpp | 4 +- drivers/telescope/skywatcherAPIMount.cpp | 10 +- drivers/telescope/telescope_simulator.cpp | 6 +- .../simple_telescope_simulator.cpp | 7 +- libs/indibase/inditelescope.cpp | 137 +++++++++--------- libs/indibase/inditelescope.h | 14 +- 9 files changed, 98 insertions(+), 119 deletions(-) diff --git a/drivers/telescope/ioptronHC8406.cpp b/drivers/telescope/ioptronHC8406.cpp index 7de0f059b0..23ac9117b3 100644 --- a/drivers/telescope/ioptronHC8406.cpp +++ b/drivers/telescope/ioptronHC8406.cpp @@ -879,7 +879,7 @@ bool ioptronHC8406::ReadScopeStatus() if (isSlewComplete()) { nanosleep(&timeout, nullptr); //Wait until :MS# finish - if (IUFindSwitch(&CoordSP, "SYNC")->s == ISS_ON || IUFindSwitch(&CoordSP, "SLEW")->s == ISS_ON) + if (CoordSP.isSwitchOn("SYNC") || CoordSP.isSwitchOn("SLEW")) { TrackState = SCOPE_IDLE; LOG_WARN("Slew is complete. IDLE"); diff --git a/drivers/telescope/lx200_OnStep.cpp b/drivers/telescope/lx200_OnStep.cpp index b2b1d7e102..db2ea17078 100644 --- a/drivers/telescope/lx200_OnStep.cpp +++ b/drivers/telescope/lx200_OnStep.cpp @@ -148,7 +148,7 @@ bool LX200_OnStep::initProperties() SlewRateSP[8].fill("8", "Half-Max", ISS_OFF); SlewRateSP[9].fill("9", "Max", ISS_OFF); SlewRateSP.fill(getDeviceName(), "TELESCOPE_SLEW_RATE", "Slew Rate", MOTION_TAB, - IP_RW, ISR_1OFMANY, 0, IPS_IDLE); + IP_RW, ISR_1OFMANY, 0, IPS_IDLE); IUFillNumber(&MaxSlewRateN[0], "maxSlew", "Rate", "%f", 0.0, 9.0, 1.0, 5.0); //2.0, 9.0, 1.0, 9.0 IUFillNumberVector(&MaxSlewRateNP, MaxSlewRateN, 1, getDeviceName(), "Max slew Rate", "", MOTION_TAB, @@ -809,7 +809,7 @@ bool LX200_OnStep::ISNewNumber(const char *dev, const char *name, double values[ if (strstr(name, "ROTATOR_")) return RI::processNumber(dev, name, values, names, n); - if (strcmp(name, "EQUATORIAL_EOD_COORD") == 0) + if (EqNP.isNameMatch(name)) //Replace this from inditelescope so it doesn't change state //Most of this needs to be handled by our updates, or it breaks things { @@ -843,37 +843,22 @@ bool LX200_OnStep::ISNewNumber(const char *dev, const char *name, double values[ // Check if it can sync if (Telescope::CanSync()) { - ISwitch *sw; - sw = IUFindSwitch(&CoordSP, "SYNC"); - if ((sw != nullptr) && (sw->s == ISS_ON)) + auto oneSwitch = CoordSP.findWidgetByName("SYNC"); + if (oneSwitch && oneSwitch->getState() == ISS_ON) { - rc = Sync(ra, dec); - // if (rc) - // EqNP.s = lastEqState = IPS_OK; - // else - // EqNP.s = lastEqState = IPS_ALERT; - // IDSetNumber(&EqNP, nullptr); - return rc; + return Sync(ra, dec); } } - // Remember Track State - // RememberTrackState = TrackState; // Issue GOTO rc = Goto(ra, dec); if (rc) { - // EqNP.s = lastEqState = IPS_BUSY; // Now fill in target co-ords, so domes can start turning TargetNP[AXIS_RA].setValue(ra); TargetNP[AXIS_DE].setValue(dec); TargetNP.apply(); } - else - { - // EqNP.s = lastEqState = IPS_ALERT; - } - // IDSetNumber(&EqNP, nullptr); } return rc; } @@ -2382,7 +2367,7 @@ bool LX200_OnStep::ReadScopeStatus() } break; } - if (EqNP[AXIS_RA].getValue() != currentRA || EqNP[AXIS_DE].getValue() != currentDEC) + if (EqNP[AXIS_RA].getValue() != currentRA || EqNP[AXIS_DE].getValue() != currentDEC) { #ifdef DEBUG_TRACKSTATE LOG_DEBUG("EqNP coordinates updated"); @@ -4982,7 +4967,7 @@ void LX200_OnStep::slewError(int slewCode) default: LOG_ERROR("OnStep slew/syncError: Not in range of values that should be returned! INVALID, Something went wrong!"); } - EqNP.setState(IPS_ALERT); + EqNP.setState(IPS_ALERT); EqNP.apply(); } diff --git a/drivers/telescope/lx200ap_v2.cpp b/drivers/telescope/lx200ap_v2.cpp index 6bcb0cbc00..7b3ce6b882 100644 --- a/drivers/telescope/lx200ap_v2.cpp +++ b/drivers/telescope/lx200ap_v2.cpp @@ -223,7 +223,7 @@ void LX200AstroPhysicsV2::initRateLabels() SlewRateSP[3].fill("600", "600x", ISS_OFF); SlewRateSP[4].fill("1200", "1200x", ISS_OFF); SlewRateSP.fill(getDeviceName(), "TELESCOPE_SLEW_RATE", "Slew Rate", MOTION_TAB, IP_RW, - ISR_1OFMANY, 0, IPS_IDLE); + ISR_1OFMANY, 0, IPS_IDLE); // Slew speed when performing regular GOTO IUFillSwitch(&APSlewSpeedS[0], "600", "600x", ISS_ON); @@ -584,7 +584,7 @@ bool LX200AstroPhysicsV2::ISNewNumber(const char *dev, const char *name, double double ra = lst - HourangleCoordsN[0].value; double dec = HourangleCoordsN[1].value; bool success = false; - if ((ISS_ON == IUFindSwitch(&CoordSP, "TRACK")->s) || (ISS_ON == IUFindSwitch(&CoordSP, "SLEW")->s)) + if (CoordSP.isSwitchOn("TRACK") || CoordSP.isSwitchOn("SLEW")) { success = Goto(ra, dec); } @@ -2203,7 +2203,7 @@ bool LX200AstroPhysicsV2::MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command ISState states[] = { ISS_OFF, ISS_OFF, ISS_OFF, ISS_OFF }; states[rememberSlewRate] = ISS_ON; const char *names[] = { SlewRateSP[0].getName(), SlewRateSP[1].getName(), - SlewRateSP[2].getName(), SlewRateSP[3].getName() + SlewRateSP[2].getName(), SlewRateSP[3].getName() }; ISNewSwitch(SlewRateSP.getDeviceName(), SlewRateSP.getName(), states, const_cast(names), 4); rememberSlewRate = -1; @@ -2221,7 +2221,7 @@ bool LX200AstroPhysicsV2::MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command ISState states[] = { ISS_OFF, ISS_OFF, ISS_OFF, ISS_OFF }; states[rememberSlewRate] = ISS_ON; const char *names[] = { SlewRateSP[0].getName(), SlewRateSP[1].getName(), - SlewRateSP[2].getName(), SlewRateSP[3].getName() + SlewRateSP[2].getName(), SlewRateSP[3].getName() }; ISNewSwitch(SlewRateSP.getDeviceName(), SlewRateSP.getName(), states, const_cast(names), 4); rememberSlewRate = -1; diff --git a/drivers/telescope/pmc8.cpp b/drivers/telescope/pmc8.cpp index 928e44e545..df5aad270c 100644 --- a/drivers/telescope/pmc8.cpp +++ b/drivers/telescope/pmc8.cpp @@ -193,7 +193,7 @@ bool PMC8::updateProperties() defineProperty(&FirmwareTP); // do not support park position - deleteProperty(ParkPositionNP.name); + deleteProperty(ParkPositionNP); deleteProperty(ParkOptionSP); } else @@ -1394,7 +1394,7 @@ void PMC8::mountSim() switch (TrackState) { case SCOPE_IDLE: - currentRA += (TrackRateNP[AXIS_RA].getValue() / 3600.0 * dt) / 15.0; + currentRA += (TrackRateNP[AXIS_RA].getValue() / 3600.0 * dt) / 15.0; currentRA = range24(currentRA); break; diff --git a/drivers/telescope/skywatcherAPIMount.cpp b/drivers/telescope/skywatcherAPIMount.cpp index 6bf853e675..eb08a92cfa 100644 --- a/drivers/telescope/skywatcherAPIMount.cpp +++ b/drivers/telescope/skywatcherAPIMount.cpp @@ -429,9 +429,7 @@ bool SkywatcherAPIMount::ISNewNumber(const char *dev, const char *name, double v } if ((ra >= 0) && (ra <= 24) && (dec >= -90) && (dec <= 90)) { - ISwitch *sw = IUFindSwitch(&CoordSP, "SYNC"); - - if (sw != nullptr && sw->s == ISS_ON && isParked()) + if (CoordSP.isSwitchOn("SYNC") && isParked()) { return Sync(ra, dec); } @@ -516,7 +514,8 @@ bool SkywatcherAPIMount::Goto(double ra, double dec) DEBUGF(INDI::AlignmentSubsystem::DBG_ALIGNMENT, "GOTO RA %lf DEC %lf", ra, dec); - if (IUFindSwitch(&CoordSP, "TRACK")->s == ISS_ON || IUFindSwitch(&CoordSP, "SLEW")->s == ISS_ON) + auto onSwitch = CoordSP.findOnSwitch(); + if (onSwitch && (onSwitch->isNameMatch("TRACK") || onSwitch->isNameMatch("SLEW"))) { char RAStr[32], DecStr[32]; fs_sexa(RAStr, ra, 2, 3600); @@ -840,7 +839,8 @@ bool SkywatcherAPIMount::ReadScopeStatus() return Goto(m_SkyTrackingTarget.rightascension, m_SkyTrackingTarget.declination); } - if (ISS_ON == IUFindSwitch(&CoordSP, "TRACK")->s) + auto onSwitch = CoordSP.findOnSwitch(); + if (onSwitch && (onSwitch->isNameMatch("TRACK"))) { // Goto has finished start tracking TrackState = SCOPE_TRACKING; diff --git a/drivers/telescope/telescope_simulator.cpp b/drivers/telescope/telescope_simulator.cpp index 5ad7d56b3f..bf7240d175 100644 --- a/drivers/telescope/telescope_simulator.cpp +++ b/drivers/telescope/telescope_simulator.cpp @@ -106,7 +106,7 @@ bool ScopeSim::initProperties() SlewRateSP[SLEW_FIND].fill("SLEW_FIND", "Find", ISS_OFF); SlewRateSP[SLEW_MAX].fill("SLEW_MAX", "Max", ISS_ON); SlewRateSP.fill(getDeviceName(), "TELESCOPE_SLEW_RATE", "Slew Rate", MOTION_TAB, - IP_RW, ISR_1OFMANY, 0, IPS_IDLE); + IP_RW, ISR_1OFMANY, 0, IPS_IDLE); // Add Tracking Modes, the order must match the order of the TelescopeTrackMode enum AddTrackMode("TRACK_SIDEREAL", "Sidereal", true); @@ -168,8 +168,8 @@ bool ScopeSim::updateProperties() alignment.latitude = Angle(LocationNP[LOCATION_LATITUDE].getValue()); alignment.longitude = Angle(LocationNP[LOCATION_LONGITUDE].getValue()); - currentRA = (alignment.lst() - Angle(ParkPositionN[AXIS_RA].value, Angle::ANGLE_UNITS::HOURS)).Hours(); - currentDEC = ParkPositionN[AXIS_DE].value; + currentRA = (alignment.lst() - Angle(ParkPositionNP[AXIS_RA].getValue(), Angle::ANGLE_UNITS::HOURS)).Hours(); + currentDEC = ParkPositionNP[AXIS_DE].getValue(); Sync(currentRA, currentDEC); } diff --git a/examples/tutorial_seven/simple_telescope_simulator.cpp b/examples/tutorial_seven/simple_telescope_simulator.cpp index 4d46d540b0..d581b372e0 100644 --- a/examples/tutorial_seven/simple_telescope_simulator.cpp +++ b/examples/tutorial_seven/simple_telescope_simulator.cpp @@ -87,7 +87,7 @@ bool ScopeSim::Goto(double ra, double dec) DEBUGF(DBG_SIMULATOR, "Goto - Celestial reference frame target right ascension %lf(%lf) declination %lf", ra * 360.0 / 24.0, ra, dec); - if (ISS_ON == IUFindSwitch(&CoordSP, "TRACK")->s) + if (CoordSP.isSwitchOn("TRACK")) { char RAStr[32], DecStr[32]; fs_sexa(RAStr, ra, 2, 3600); @@ -588,7 +588,7 @@ void ScopeSim::TimerHit() case SCOPE_SLEWING: if ((STOPPED == AxisStatusRA) && (STOPPED == AxisStatusDEC)) { - if (ISS_ON == IUFindSwitch(&CoordSP, "TRACK")->s) + if (CoordSP.isSwitchOn("TRACK")) { // Goto has finished start tracking DEBUG(DBG_SIMULATOR, "TimerHit - Goto finished start tracking"); @@ -601,8 +601,7 @@ void ScopeSim::TimerHit() break; } } - else - break; + break; case SCOPE_TRACKING: { diff --git a/libs/indibase/inditelescope.cpp b/libs/indibase/inditelescope.cpp index f41e36b9ad..ab29f3983d 100644 --- a/libs/indibase/inditelescope.cpp +++ b/libs/indibase/inditelescope.cpp @@ -159,6 +159,10 @@ bool Telescope::initProperties() TrackRateNP.fill(getDeviceName(), "TELESCOPE_TRACK_RATE", "Track Rates", MAIN_CONTROL_TAB, IP_RW, 60, IPS_IDLE); + // On Coord Set + // @INDI_STANDARD_PROPERTY@ + // Note: Member elements can be TRACK, SLEW, SYNC, and FLIP + CoordSP.fill(getDeviceName(), "ON_COORD_SET", "On Set", MAIN_CONTROL_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE); generateCoordSet(); // @INDI_STANDARD_PROPERTY@ @@ -337,7 +341,7 @@ bool Telescope::updateProperties() // Now we add our telescope specific stuff if (CanGOTO() || CanSync()) - defineProperty(&CoordSP); + defineProperty(CoordSP); defineProperty(EqNP); if (CanAbort()) defineProperty(AbortSP); @@ -370,7 +374,7 @@ bool Telescope::updateProperties() defineProperty(ParkSP); if (parkDataType != PARK_NONE) { - defineProperty(&ParkPositionNP); + defineProperty(ParkPositionNP); defineProperty(ParkOptionSP); } } @@ -399,7 +403,7 @@ bool Telescope::updateProperties() else { if (CanGOTO() || CanSync()) - deleteProperty(CoordSP.name); + deleteProperty(CoordSP); deleteProperty(EqNP); if (CanAbort()) deleteProperty(AbortSP); @@ -432,7 +436,7 @@ bool Telescope::updateProperties() deleteProperty(ParkSP); if (parkDataType != PARK_NONE) { - deleteProperty(ParkPositionNP.name); + deleteProperty(ParkPositionNP); deleteProperty(ParkOptionSP); } } @@ -803,9 +807,7 @@ bool Telescope::ISNewNumber(const char *dev, const char *name, double values[], // Check if it can sync if (CanSync()) { - ISwitch *sw; - sw = IUFindSwitch(&CoordSP, "SYNC"); - if ((sw != nullptr) && (sw->s == ISS_ON)) + if (CoordSP.isSwitchOn("SYNC")) { rc = Sync(ra, dec); if (rc) @@ -820,12 +822,7 @@ bool Telescope::ISNewNumber(const char *dev, const char *name, double values[], bool doFlip = false; if (CanFlip()) { - ISwitch *sw; - sw = IUFindSwitch(&CoordSP, "FLIP"); - if ((sw != nullptr) && (sw->s == ISS_ON)) - { - doFlip = true; - } + doFlip = CoordSP.isSwitchOn("FLIP"); } // Remember Track State @@ -859,7 +856,7 @@ bool Telescope::ISNewNumber(const char *dev, const char *name, double values[], /////////////////////////////////// // Geographic Coords /////////////////////////////////// - if (strcmp(name, "GEOGRAPHIC_COORD") == 0) + if (LocationNP.isNameMatch(name)) { int latindex = IUFindIndex("LAT", names, n); int longindex = IUFindIndex("LONG", names, n); @@ -882,17 +879,16 @@ bool Telescope::ISNewNumber(const char *dev, const char *name, double values[], /////////////////////////////////// // Park Position /////////////////////////////////// - if (strcmp(name, ParkPositionNP.name) == 0) + if (ParkPositionNP.isNameMatch(name)) { double axis1 = std::numeric_limits::quiet_NaN(), axis2 = std::numeric_limits::quiet_NaN(); for (int x = 0; x < n; x++) { - INumber *parkPosAxis = IUFindNumber(&ParkPositionNP, names[x]); - if (parkPosAxis == &ParkPositionN[AXIS_RA]) + if (ParkPositionNP[AXIS_RA].isNameMatch(names[x])) { axis1 = values[x]; } - else if (parkPosAxis == &ParkPositionN[AXIS_DE]) + else if (ParkPositionNP[AXIS_DE].isNameMatch(names[x])) { axis2 = values[x]; } @@ -906,17 +902,17 @@ bool Telescope::ISNewNumber(const char *dev, const char *name, double values[], if (rc) { - IUUpdateNumber(&ParkPositionNP, values, names, n); - Axis1ParkPosition = ParkPositionN[AXIS_RA].value; - Axis2ParkPosition = ParkPositionN[AXIS_DE].value; + ParkPositionNP.update(values, names, n); + Axis1ParkPosition = ParkPositionNP[AXIS_RA].getValue(); + Axis2ParkPosition = ParkPositionNP[AXIS_DE].getValue(); } - ParkPositionNP.s = rc ? IPS_OK : IPS_ALERT; + ParkPositionNP.setState(rc ? IPS_OK : IPS_ALERT); } else - ParkPositionNP.s = IPS_ALERT; + ParkPositionNP.setState(IPS_ALERT); - IDSetNumber(&ParkPositionNP, nullptr); + ParkPositionNP.apply(); return true; } @@ -926,9 +922,7 @@ bool Telescope::ISNewNumber(const char *dev, const char *name, double values[], if (TrackRateNP.isNameMatch(name)) { double preAxis1 = TrackRateNP[AXIS_RA].getValue(), preAxis2 = TrackRateNP[AXIS_DE].getValue(); - bool rc = (TrackRateNP.update(values, names, n) == 0); - - if (!rc) + if (TrackRateNP.update(values, names, n) == false) { TrackRateNP.setState(IPS_ALERT); TrackRateNP.apply(); @@ -947,13 +941,14 @@ bool Telescope::ISNewNumber(const char *dev, const char *name, double values[], } // All is fine, ask mount to change tracking rate - rc = SetTrackRate(TrackRateNP[AXIS_RA].getValue(), TrackRateNP[AXIS_DE].getValue()); - - if (!rc) + if (SetTrackRate(TrackRateNP[AXIS_RA].getValue(), TrackRateNP[AXIS_DE].getValue()) == false) { TrackRateNP[AXIS_RA].setValue(preAxis1); TrackRateNP[AXIS_DE].setValue(preAxis2); + TrackRateNP.setState(IPS_ALERT); } + else + TrackRateNP.setState(IPS_OK); } // If we are already tracking but tracking mode is NOT custom @@ -965,7 +960,6 @@ bool Telescope::ISNewNumber(const char *dev, const char *name, double values[], } // If mount is NOT tracking, we simply accept whatever valid values for use when mount tracking is engaged. - TrackRateNP.setState(rc ? IPS_OK : IPS_ALERT); TrackRateNP.apply(); return true; } @@ -982,13 +976,13 @@ bool Telescope::ISNewSwitch(const char *dev, const char *name, ISState *states, if (dev != nullptr && strcmp(dev, getDeviceName()) == 0) { // This one is for us - if (!strcmp(name, CoordSP.name)) + if (CoordSP.isNameMatch(name)) { // client is telling us what to do with co-ordinate requests - CoordSP.s = IPS_OK; - IUUpdateSwitch(&CoordSP, states, names, n); + CoordSP.setState(IPS_OK); + CoordSP.update(states, names, n); // Update client display - IDSetSwitch(&CoordSP, nullptr); + CoordSP.apply(); return true; } @@ -1833,29 +1827,33 @@ bool Telescope::SetParkPosition(double Axis1Value, double Axis2Value) void Telescope::generateCoordSet() { - std::vector > coords; + CoordSP.resize(0); - coords.push_back(std::make_tuple("TRACK", "Track")); + INDI::WidgetSwitch node; + node.fill("TRACK", "Track", ISS_ON); + CoordSP.push(std::move(node)); if(CanGOTO()) - coords.push_back(std::make_tuple("SLEW", "Slew")); + { + INDI::WidgetSwitch node; + node.fill("SLEW", "Slew", ISS_OFF); + CoordSP.push(std::move(node)); + } if(CanSync()) - coords.push_back(std::make_tuple("SYNC", "Sync")); + { + INDI::WidgetSwitch node; + node.fill("SYNC", "Sync", ISS_OFF); + CoordSP.push(std::move(node)); - if(CanFlip()) - coords.push_back(std::make_tuple("FLIP", "Flip")); + } - int j = 0; - for(auto i : coords) + if(CanFlip()) { - IUFillSwitch(&CoordS[j], std::get<0>(i).c_str(), std::get<1>(i).c_str(), j == 0 ? ISS_ON : ISS_OFF); - ++j; + INDI::WidgetSwitch node; + node.fill("FLIP", "Flip", ISS_OFF); + CoordSP.push(std::move(node)); } - - IUFillSwitchVector(&CoordSP, CoordS, static_cast(coords.size()), getDeviceName(), "ON_COORD_SET", "On Set", - MAIN_CONTROL_TAB, IP_RW, - ISR_1OFMANY, 60, IPS_IDLE); } void Telescope::SetTelescopeCapability(uint32_t cap, uint8_t slewRateCount) @@ -1935,36 +1933,35 @@ void Telescope::SetParkDataType(TelescopeParkData type) switch (parkDataType) { case PARK_RA_DEC: - IUFillNumber(&ParkPositionN[AXIS_RA], "PARK_RA", "RA (hh:mm:ss)", "%010.6m", 0, 24, 0, 0); - IUFillNumber(&ParkPositionN[AXIS_DE], "PARK_DEC", "DEC (dd:mm:ss)", "%010.6m", -90, 90, 0, 0); + ParkPositionNP[AXIS_RA].fill("PARK_RA", "RA (hh:mm:ss)", "%010.6m", 0, 24, 0, 0); + ParkPositionNP[AXIS_DE].fill("PARK_DEC", "DEC (dd:mm:ss)", "%010.6m", -90, 90, 0, 0); break; case PARK_HA_DEC: - IUFillNumber(&ParkPositionN[AXIS_RA], "PARK_HA", "HA (hh:mm:ss)", "%010.6m", -12, 12, 0, 0); - IUFillNumber(&ParkPositionN[AXIS_DE], "PARK_DEC", "DEC (dd:mm:ss)", "%010.6m", -90, 90, 0, 0); + ParkPositionNP[AXIS_RA].fill("PARK_HA", "HA (hh:mm:ss)", "%010.6m", -12, 12, 0, 0); + ParkPositionNP[AXIS_DE].fill("PARK_DEC", "DEC (dd:mm:ss)", "%010.6m", -90, 90, 0, 0); break; case PARK_AZ_ALT: - IUFillNumber(&ParkPositionN[AXIS_AZ], "PARK_AZ", "AZ D:M:S", "%10.6m", 0.0, 360.0, 0.0, 0); - IUFillNumber(&ParkPositionN[AXIS_ALT], "PARK_ALT", "Alt D:M:S", "%10.6m", -90., 90.0, 0.0, 0); + ParkPositionNP[AXIS_AZ].fill("PARK_AZ", "AZ D:M:S", "%10.6m", 0.0, 360.0, 0.0, 0); + ParkPositionNP[AXIS_ALT].fill("PARK_ALT", "Alt D:M:S", "%10.6m", -90., 90.0, 0.0, 0); break; case PARK_RA_DEC_ENCODER: - IUFillNumber(&ParkPositionN[AXIS_RA], "PARK_RA", "RA Encoder", "%.0f", 0, 16777215, 1, 0); - IUFillNumber(&ParkPositionN[AXIS_DE], "PARK_DEC", "DEC Encoder", "%.0f", 0, 16777215, 1, 0); + ParkPositionNP[AXIS_RA].fill("PARK_RA", "RA Encoder", "%.0f", 0, 16777215, 1, 0); + ParkPositionNP[AXIS_DE].fill("PARK_DEC", "DEC Encoder", "%.0f", 0, 16777215, 1, 0); break; case PARK_AZ_ALT_ENCODER: - IUFillNumber(&ParkPositionN[AXIS_RA], "PARK_AZ", "AZ Encoder", "%.0f", 0, 16777215, 1, 0); - IUFillNumber(&ParkPositionN[AXIS_DE], "PARK_ALT", "ALT Encoder", "%.0f", 0, 16777215, 1, 0); + ParkPositionNP[AXIS_RA].fill("PARK_AZ", "AZ Encoder", "%.0f", 0, 16777215, 1, 0); + ParkPositionNP[AXIS_DE].fill("PARK_ALT", "ALT Encoder", "%.0f", 0, 16777215, 1, 0); break; default: break; } - IUFillNumberVector(&ParkPositionNP, ParkPositionN, 2, getDeviceName(), "TELESCOPE_PARK_POSITION", - "Park Position", SITE_TAB, IP_RW, 60, IPS_IDLE); + ParkPositionNP.fill(getDeviceName(), "TELESCOPE_PARK_POSITION", "Park Position", SITE_TAB, IP_RW, 60, IPS_IDLE); } } @@ -2018,9 +2015,9 @@ bool Telescope::InitPark() if (parkDataType != PARK_SIMPLE) { LOGF_DEBUG("InitPark Axis1 %.2f Axis2 %.2f", Axis1ParkPosition, Axis2ParkPosition); - ParkPositionN[AXIS_RA].value = Axis1ParkPosition; - ParkPositionN[AXIS_DE].value = Axis2ParkPosition; - IDSetNumber(&ParkPositionNP, nullptr); + ParkPositionNP[AXIS_RA].setValue(Axis1ParkPosition); + ParkPositionNP[AXIS_DE].setValue(Axis2ParkPosition); + ParkPositionNP.apply(); } return true; @@ -2345,9 +2342,9 @@ double Telescope::GetAxis2ParkDefault() const void Telescope::SetAxis1Park(double value) { LOGF_DEBUG("Setting Park Axis1 to %.2f", value); - Axis1ParkPosition = value; - ParkPositionN[AXIS_RA].value = value; - IDSetNumber(&ParkPositionNP, nullptr); + Axis1ParkPosition = value; + ParkPositionNP[AXIS_RA].setValue(value); + ParkPositionNP.apply(); } void Telescope::SetAxis1ParkDefault(double value) @@ -2359,9 +2356,9 @@ void Telescope::SetAxis1ParkDefault(double value) void Telescope::SetAxis2Park(double value) { LOGF_DEBUG("Setting Park Axis2 to %.2f", value); - Axis2ParkPosition = value; - ParkPositionN[AXIS_DE].value = value; - IDSetNumber(&ParkPositionNP, nullptr); + Axis2ParkPosition = value; + ParkPositionNP[AXIS_DE].setValue(value); + ParkPositionNP.apply(); } void Telescope::SetAxis2ParkDefault(double value) diff --git a/libs/indibase/inditelescope.h b/libs/indibase/inditelescope.h index dd8f1b585a..65c080de7d 100644 --- a/libs/indibase/inditelescope.h +++ b/libs/indibase/inditelescope.h @@ -764,8 +764,7 @@ class Telescope : public DefaultDevice INDI::PropertySwitch AbortSP {1}; // On a coord_set message, sync, or slew - ISwitchVectorProperty CoordSP; - ISwitch CoordS[4]; + INDI::PropertySwitch CoordSP {4}; // A number vector that stores latitude and longitude INDI::PropertyNumber LocationNP {3}; @@ -779,8 +778,7 @@ class Telescope : public DefaultDevice }; // Custom parking position - INumber ParkPositionN[2]; - INumberVectorProperty ParkPositionNP; + INDI::PropertyNumber ParkPositionNP {2}; /** + NAME: TELESCOPE_PARK_POSITION @@ -823,8 +821,8 @@ class Telescope : public DefaultDevice INDI::PropertyText TimeTP {2}; enum { - UTC, - OFFSET + UTC, + OFFSET }; void sendTimeFromSystem(); @@ -863,8 +861,8 @@ class Telescope : public DefaultDevice INDI::PropertySwitch SimulatePierSideSP {2}; enum { - SIMULATE_YES, - SIMULATE_NO + SIMULATE_YES, + SIMULATE_NO }; bool getSimulatePierSide() const; void setSimulatePierSide(bool value);