From 060d7c2d26b1db769a91de995c64634b673731f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Soja?= Date: Thu, 22 Dec 2022 05:22:59 +0100 Subject: [PATCH] Refactor - use PropertyView/WidgetView (#1774) --- drivers/auxiliary/skysafari.cpp | 94 +++--- drivers/auxiliary/skysafariclient.cpp | 22 +- drivers/auxiliary/skysafariclient.h | 30 +- drivers/auxiliary/watchdogclient.cpp | 20 +- drivers/auxiliary/watchdogclient.h | 2 +- drivers/ccd/guide_simulator.cpp | 2 +- drivers/dome/nexdome_beaver.cpp | 24 +- drivers/dome/scopedome_dome.cpp | 8 +- drivers/focuser/esattoarco.cpp | 12 +- drivers/focuser/focus_simulator.cpp | 2 +- drivers/focuser/tcfs.cpp | 12 +- drivers/telescope/astrotrac.cpp | 14 +- drivers/telescope/skywatcherAPIMount.cpp | 8 +- drivers/telescope/synscandriver.cpp | 10 +- drivers/video/lx/Lx.cpp | 25 +- drivers/video/lx/Lx.h | 4 +- drivers/video/v4l2driver.cpp | 11 +- drivers/weather/openweathermap.cpp | 4 +- drivers/weather/uranusmeteo.cpp | 2 +- .../ClientAPIForAlignmentDatabase.cpp | 310 +++++++++--------- .../ClientAPIForMathPluginManagement.cpp | 32 +- .../indiabstractclient/abstractbaseclient.cpp | 18 +- libs/indiabstractclient/abstractbaseclient.h | 2 +- libs/indibase/defaultdevice.cpp | 10 +- libs/indibase/dsp/dspinterface.cpp | 36 +- libs/indibase/indiccd.cpp | 20 +- libs/indibase/inditelescope.cpp | 16 +- libs/indibase/indiweatherinterface.cpp | 2 +- .../stream/encoder/encoderinterface.h | 3 +- libs/indibase/stream/encoder/mjpegencoder.cpp | 10 +- libs/indibase/stream/encoder/mjpegencoder.h | 2 +- libs/indibase/stream/encoder/rawencoder.cpp | 18 +- libs/indibase/stream/encoder/rawencoder.h | 2 +- libs/indibase/stream/streammanager.cpp | 36 +- libs/indibase/stream/streammanager_p.h | 2 +- libs/indidevice/basedevice.cpp | 12 +- libs/indidevice/basedevice_p.h | 10 +- libs/indidevice/property/indiproperty.cpp | 50 +-- libs/indidevice/property/indiproperty.h | 36 +- libs/indidevice/property/indiproperty_p.h | 10 +- .../indidevice/property/indipropertybasic.cpp | 4 +- libs/indidevice/property/indipropertybasic.h | 10 +- .../property/indipropertyswitch.cpp | 2 +- libs/indidevice/property/indipropertyswitch.h | 2 +- libs/indidevice/property/indipropertyview.h | 51 ++- test/core/test_property_class.cpp | 24 +- test/drivers/test_ccd_simulator.cpp | 46 +-- 47 files changed, 559 insertions(+), 523 deletions(-) diff --git a/drivers/auxiliary/skysafari.cpp b/drivers/auxiliary/skysafari.cpp index 9b1cc68ea2..4a53dacd66 100644 --- a/drivers/auxiliary/skysafari.cpp +++ b/drivers/auxiliary/skysafari.cpp @@ -449,7 +449,7 @@ void SkySafari::processCommand(std::string cmd) // Get RA else if (cmd == "GR") { - INumberVectorProperty *eqCoordsNP = skySafariClient->getEquatorialCoords(); + auto eqCoordsNP = skySafariClient->getEquatorialCoords(); if (eqCoordsNP == nullptr) { LOG_WARN("Unable to communicate with mount, is mount turned on and connected?"); @@ -458,14 +458,14 @@ void SkySafari::processCommand(std::string cmd) int hh, mm, ss; char output[32] = { 0 }; - getSexComponents(eqCoordsNP->np[AXIS_RA].value, &hh, &mm, &ss); + getSexComponents(eqCoordsNP->at(AXIS_RA)->getValue(), &hh, &mm, &ss); snprintf(output, 32, "%02d:%02d:%02d#", hh, mm, ss); sendSkySafari(output); } // Get DE else if (cmd == "GD") { - INumberVectorProperty *eqCoordsNP = skySafariClient->getEquatorialCoords(); + auto eqCoordsNP = skySafariClient->getEquatorialCoords(); if (eqCoordsNP == nullptr) { LOG_WARN("Unable to communicate with mount, is mount turned on and connected?"); @@ -473,8 +473,8 @@ void SkySafari::processCommand(std::string cmd) } int dd, mm, ss; char output[32] = { 0 }; - getSexComponents(eqCoordsNP->np[AXIS_DE].value, &dd, &mm, &ss); - snprintf(output, 32, "%c%02d:%02d:%02d#", (eqCoordsNP->np[AXIS_DE].value >= 0) ? '+' : '-', + getSexComponents(eqCoordsNP->at(AXIS_DE)->getValue(), &dd, &mm, &ss); + snprintf(output, 32, "%c%02d:%02d:%02d#", (eqCoordsNP->at(AXIS_DE)->getValue() >= 0) ? '+' : '-', std::abs(dd), mm, ss); sendSkySafari(output); } @@ -495,7 +495,7 @@ void SkySafari::processCommand(std::string cmd) // GOTO else if (cmd == "MS") { - ISwitchVectorProperty *gotoModeSP = skySafariClient->getGotoMode(); + auto gotoModeSP = skySafariClient->getGotoMode(); if (gotoModeSP == nullptr) { sendSkySafari("2#"); @@ -503,20 +503,20 @@ void SkySafari::processCommand(std::string cmd) } // Set mode first - ISwitch *trackSW = IUFindSwitch(gotoModeSP, "TRACK"); + auto trackSW = gotoModeSP->findWidgetByName("TRACK"); if (trackSW == nullptr) { sendSkySafari("2#"); return; } - IUResetSwitch(gotoModeSP); - trackSW->s = ISS_ON; + gotoModeSP->reset(); + trackSW->setState(ISS_ON); skySafariClient->sendGotoMode(); - INumberVectorProperty *eqCoordsNP = skySafariClient->getEquatorialCoords(); - eqCoordsNP->np[AXIS_RA].value = RA; - eqCoordsNP->np[AXIS_DE].value = DE; + auto eqCoordsNP = skySafariClient->getEquatorialCoords(); + eqCoordsNP->at(AXIS_RA)->setValue(RA); + eqCoordsNP->at(AXIS_DE)->setValue(DE); skySafariClient->sendEquatorialCoords(); sendSkySafari("0"); @@ -524,7 +524,7 @@ void SkySafari::processCommand(std::string cmd) // Sync else if (cmd == "CM") { - ISwitchVectorProperty *gotoModeSP = skySafariClient->getGotoMode(); + auto gotoModeSP = skySafariClient->getGotoMode(); if (gotoModeSP == nullptr) { sendSkySafari("Not Supported#"); @@ -532,20 +532,20 @@ void SkySafari::processCommand(std::string cmd) } // Set mode first - ISwitch *syncSW = IUFindSwitch(gotoModeSP, "SYNC"); + auto syncSW = gotoModeSP->findWidgetByName("SYNC"); if (syncSW == nullptr) { sendSkySafari("Not Supported#"); return; } - IUResetSwitch(gotoModeSP); - syncSW->s = ISS_ON; + gotoModeSP->reset(); + syncSW->setState(ISS_ON); skySafariClient->sendGotoMode(); - INumberVectorProperty *eqCoordsNP = skySafariClient->getEquatorialCoords(); - eqCoordsNP->np[AXIS_RA].value = RA; - eqCoordsNP->np[AXIS_DE].value = DE; + auto eqCoordsNP = skySafariClient->getEquatorialCoords(); + eqCoordsNP->at(AXIS_RA)->setValue(RA); + eqCoordsNP->at(AXIS_DE)->setValue(DE); skySafariClient->sendEquatorialCoords(); sendSkySafari(" M31 EX GAL MAG 3.5 SZ178.0'#"); @@ -578,84 +578,84 @@ void SkySafari::processCommand(std::string cmd) // Mn else if (cmd == "Mn") { - ISwitchVectorProperty *motionNSNP = skySafariClient->getMotionNS(); + auto motionNSNP = skySafariClient->getMotionNS(); if (motionNSNP) { - IUResetSwitch(motionNSNP); - motionNSNP->sp[0].s = ISS_ON; + motionNSNP->reset(); + motionNSNP->at(0)->setState(ISS_ON); skySafariClient->setMotionNS(); } } // Qn else if (cmd == "Qn") { - ISwitchVectorProperty *motionNSNP = skySafariClient->getMotionNS(); + auto motionNSNP = skySafariClient->getMotionNS(); if (motionNSNP) { - IUResetSwitch(motionNSNP); + motionNSNP->reset(); skySafariClient->setMotionNS(); } } // Ms else if (cmd == "Ms") { - ISwitchVectorProperty *motionNSNP = skySafariClient->getMotionNS(); + auto motionNSNP = skySafariClient->getMotionNS(); if (motionNSNP) { - IUResetSwitch(motionNSNP); - motionNSNP->sp[1].s = ISS_ON; + motionNSNP->reset(); + motionNSNP->at(1)->setState(ISS_ON); skySafariClient->setMotionNS(); } } // Qs else if (cmd == "Qs") { - ISwitchVectorProperty *motionNSNP = skySafariClient->getMotionNS(); + auto motionNSNP = skySafariClient->getMotionNS(); if (motionNSNP) { - IUResetSwitch(motionNSNP); + motionNSNP->reset(); skySafariClient->setMotionNS(); } } // Mw else if (cmd == "Mw") { - ISwitchVectorProperty *motionWENP = skySafariClient->getMotionWE(); + auto motionWENP = skySafariClient->getMotionWE(); if (motionWENP) { - IUResetSwitch(motionWENP); - motionWENP->sp[0].s = ISS_ON; + motionWENP->reset(); + motionWENP->at(0)->setState(ISS_ON); skySafariClient->setMotionWE(); } } // Qw else if (cmd == "Qw") { - ISwitchVectorProperty *motionWENP = skySafariClient->getMotionWE(); + auto motionWENP = skySafariClient->getMotionWE(); if (motionWENP) { - IUResetSwitch(motionWENP); + motionWENP->reset(); skySafariClient->setMotionWE(); } } // Me else if (cmd == "Me") { - ISwitchVectorProperty *motionWENP = skySafariClient->getMotionWE(); + auto motionWENP = skySafariClient->getMotionWE(); if (motionWENP) { - IUResetSwitch(motionWENP); - motionWENP->sp[1].s = ISS_ON; + motionWENP->reset(); + motionWENP->at(1)->setState(ISS_ON); skySafariClient->setMotionWE(); } } // Qe else if (cmd == "Qe") { - ISwitchVectorProperty *motionWENP = skySafariClient->getMotionWE(); + auto motionWENP = skySafariClient->getMotionWE(); if (motionWENP) { - IUResetSwitch(motionWENP); + motionWENP->reset(); skySafariClient->setMotionWE(); } } @@ -663,15 +663,15 @@ void SkySafari::processCommand(std::string cmd) void SkySafari::sendGeographicCoords() { - INumberVectorProperty *geographicCoords = skySafariClient->getGeographiCoords(); + auto geographicCoords = skySafariClient->getGeographiCoords(); if (geographicCoords && haveLatitude && haveLongitude) { - INumber *latitude = IUFindNumber(geographicCoords, "LAT"); - INumber *longitude = IUFindNumber(geographicCoords, "LONG"); + auto latitude = geographicCoords->findWidgetByName("LAT"); + auto longitude = geographicCoords->findWidgetByName("LONG"); if (latitude && longitude) { - latitude->value = siteLatitude; - longitude->value = siteLongitude; + latitude->setValue(siteLatitude); + longitude->setValue(siteLongitude); skySafariClient->sendGeographicCoords(); // Reset @@ -703,7 +703,7 @@ bool SkySafari::sendSkySafari(const char *message) void SkySafari::sendUTCtimedate() { - ITextVectorProperty *timeUTC = skySafariClient->getTimeUTC(); + auto timeUTC = skySafariClient->getTimeUTC(); if (timeUTC && haveUTCoffset && haveUTCtime && haveUTCdate) { int yyyy = timeYear; @@ -730,8 +730,8 @@ void SkySafari::sendUTCtimedate() utcdate.minutes, (int)(utcdate.seconds)); snprintf(bufOff, 8, "%4.2f", timeUTCOffset); - IUSaveText(IUFindText(timeUTC, "UTC"), bufDT); - IUSaveText(IUFindText(timeUTC, "OFFSET"), bufOff); + timeUTC->findWidgetByName("UTC")->setText(bufDT); + timeUTC->findWidgetByName("OFFSET")->setText(bufOff); LOGF_DEBUG("send to timedate. %s, %s", bufDT, bufOff); diff --git a/drivers/auxiliary/skysafariclient.cpp b/drivers/auxiliary/skysafariclient.cpp index c05e2cdd40..ee4b245251 100644 --- a/drivers/auxiliary/skysafariclient.cpp +++ b/drivers/auxiliary/skysafariclient.cpp @@ -100,15 +100,15 @@ bool SkySafariClient::parkMount() if (mountParkSP == nullptr) return false; - ISwitch *sw = IUFindSwitch(mountParkSP, "PARK"); + auto sw = mountParkSP->findWidgetByName("PARK"); if (sw == nullptr) return false; - IUResetSwitch(mountParkSP); - sw->s = ISS_ON; + mountParkSP->reset(); + sw->setState(ISS_ON); - mountParkSP->s = IPS_BUSY; + mountParkSP->setState(IPS_BUSY); sendNewSwitch(mountParkSP); @@ -120,7 +120,7 @@ bool SkySafariClient::parkMount() ***************************************************************************************/ IPState SkySafariClient::getMountParkState() { - return mountParkSP->s; + return mountParkSP->getState(); } /************************************************************************************** @@ -131,7 +131,7 @@ bool SkySafariClient::sendEquatorialCoords() if (eqCoordsNP == nullptr) return false; - eqCoordsNP->s = IPS_BUSY; + eqCoordsNP->setState(IPS_BUSY); sendNewNumber(eqCoordsNP); return true; } @@ -144,7 +144,7 @@ bool SkySafariClient::sendGeographicCoords() if (geoCoordsNP == nullptr) return false; - geoCoordsNP->s = IPS_BUSY; + geoCoordsNP->setState(IPS_BUSY); sendNewNumber(geoCoordsNP); return true; } @@ -169,7 +169,7 @@ bool SkySafariClient::abort() if (abortSP == nullptr) return false; - abortSP->sp[0].s = ISS_ON; + abortSP->at(0)->setState(ISS_ON); sendNewSwitch(abortSP); return true; @@ -183,7 +183,7 @@ bool SkySafariClient::setSlewRate(int slewRate) if (slewRateSP == nullptr) return false; - int maxSlewRate = slewRateSP->nsp - 1; + int maxSlewRate = slewRateSP->count() - 1; int finalSlewRate = slewRate; @@ -191,8 +191,8 @@ bool SkySafariClient::setSlewRate(int slewRate) if (slewRate > 0 && slewRate < maxSlewRate) finalSlewRate = static_cast(ceil(slewRate * maxSlewRate / 3.0)); - IUResetSwitch(slewRateSP); - slewRateSP->sp[finalSlewRate].s = ISS_ON; + slewRateSP->reset(); + slewRateSP->at(finalSlewRate)->setState(ISS_ON); sendNewSwitch(slewRateSP); diff --git a/drivers/auxiliary/skysafariclient.h b/drivers/auxiliary/skysafariclient.h index 2f92382911..7792313781 100644 --- a/drivers/auxiliary/skysafariclient.h +++ b/drivers/auxiliary/skysafariclient.h @@ -44,31 +44,31 @@ class SkySafariClient : public INDI::BaseClient void setMount(const std::string &value); - INumberVectorProperty *getEquatorialCoords() + INDI::PropertyViewNumber *getEquatorialCoords() { return eqCoordsNP; } bool sendEquatorialCoords(); - INumberVectorProperty *getGeographiCoords() + INDI::PropertyViewNumber *getGeographiCoords() { return geoCoordsNP; } bool sendGeographicCoords(); - ISwitchVectorProperty *getGotoMode() + INDI::PropertyViewSwitch *getGotoMode() { return gotoModeSP; } bool sendGotoMode(); - ISwitchVectorProperty *getMotionNS() + INDI::PropertyViewSwitch *getMotionNS() { return motionNSSP; } bool setMotionNS(); - ISwitchVectorProperty *getMotionWE() + INDI::PropertyViewSwitch *getMotionWE() { return motionWESP; } @@ -81,7 +81,7 @@ class SkySafariClient : public INDI::BaseClient bool abort(); - ITextVectorProperty *getTimeUTC() + INDI::PropertyViewText *getTimeUTC() { return timeUTC; } @@ -105,13 +105,13 @@ class SkySafariClient : public INDI::BaseClient std::string mount; bool isReady, mountOnline; - ISwitchVectorProperty *mountParkSP = nullptr; - ISwitchVectorProperty *gotoModeSP = nullptr; - INumberVectorProperty *eqCoordsNP = nullptr; - INumberVectorProperty *geoCoordsNP = nullptr; - ISwitchVectorProperty *abortSP = nullptr; - ISwitchVectorProperty *slewRateSP = nullptr; - ISwitchVectorProperty *motionNSSP = nullptr; - ISwitchVectorProperty *motionWESP = nullptr; - ITextVectorProperty *timeUTC = nullptr; + INDI::PropertyViewSwitch *mountParkSP = nullptr; + INDI::PropertyViewSwitch *gotoModeSP = nullptr; + INDI::PropertyViewNumber *eqCoordsNP = nullptr; + INDI::PropertyViewNumber *geoCoordsNP = nullptr; + INDI::PropertyViewSwitch *abortSP = nullptr; + INDI::PropertyViewSwitch *slewRateSP = nullptr; + INDI::PropertyViewSwitch *motionNSSP = nullptr; + INDI::PropertyViewSwitch *motionWESP = nullptr; + INDI::PropertyViewText *timeUTC = nullptr; }; diff --git a/drivers/auxiliary/watchdogclient.cpp b/drivers/auxiliary/watchdogclient.cpp index 70879963bc..24087e44d5 100644 --- a/drivers/auxiliary/watchdogclient.cpp +++ b/drivers/auxiliary/watchdogclient.cpp @@ -98,15 +98,15 @@ bool WatchDogClient::parkDome() if (domeParkSP == nullptr) return false; - ISwitch *sw = IUFindSwitch(domeParkSP, "PARK"); + auto sw = domeParkSP->findWidgetByName("PARK"); if (sw == nullptr) return false; - IUResetSwitch(domeParkSP); - sw->s = ISS_ON; + domeParkSP->reset(); + sw->setState(ISS_ON); - domeParkSP->s = IPS_BUSY; + domeParkSP->setState(IPS_BUSY); sendNewSwitch(domeParkSP); @@ -121,15 +121,15 @@ bool WatchDogClient::parkMount() if (mountParkSP == nullptr) return false; - ISwitch *sw = IUFindSwitch(mountParkSP, "PARK"); + auto sw = mountParkSP->findWidgetByName("PARK"); if (sw == nullptr) return false; - IUResetSwitch(mountParkSP); - sw->s = ISS_ON; + mountParkSP->reset(); + sw->setState(ISS_ON); - mountParkSP->s = IPS_BUSY; + mountParkSP->setState(IPS_BUSY); sendNewSwitch(mountParkSP); @@ -141,7 +141,7 @@ bool WatchDogClient::parkMount() ***************************************************************************************/ IPState WatchDogClient::getDomeParkState() { - return domeParkSP->s; + return domeParkSP->getState(); } /************************************************************************************** @@ -149,5 +149,5 @@ IPState WatchDogClient::getDomeParkState() ***************************************************************************************/ IPState WatchDogClient::getMountParkState() { - return mountParkSP->s; + return mountParkSP->getState(); } diff --git a/drivers/auxiliary/watchdogclient.h b/drivers/auxiliary/watchdogclient.h index 38e9bcd010..283517b4f3 100644 --- a/drivers/auxiliary/watchdogclient.h +++ b/drivers/auxiliary/watchdogclient.h @@ -72,5 +72,5 @@ class WatchDogClient : public INDI::BaseClient std::string dome, mount; bool isReady, isRunning, domeOnline, mountOnline; - ISwitchVectorProperty *mountParkSP, *domeParkSP; + INDI::PropertyViewSwitch *mountParkSP, *domeParkSP; }; diff --git a/drivers/ccd/guide_simulator.cpp b/drivers/ccd/guide_simulator.cpp index fb8c1919c9..ab2e034976 100644 --- a/drivers/ccd/guide_simulator.cpp +++ b/drivers/ccd/guide_simulator.cpp @@ -218,7 +218,7 @@ void GuideSim::ISGetProperties(const char * dev) defineProperty(&SimulatorSettingsNP); defineProperty(&EqPENP); defineProperty(&SimulateRgbSP); - defineProperty(&ToggleTimeoutSP); + defineProperty(ToggleTimeoutSP); } bool GuideSim::updateProperties() diff --git a/drivers/dome/nexdome_beaver.cpp b/drivers/dome/nexdome_beaver.cpp index 1ad7804929..8d84b3c0b2 100644 --- a/drivers/dome/nexdome_beaver.cpp +++ b/drivers/dome/nexdome_beaver.cpp @@ -154,20 +154,20 @@ bool Beaver::updateProperties() } TimerHit(); - defineProperty(&VersionTP); - defineProperty(&HomePositionNP); - defineProperty(&HomeOptionsSP); - defineProperty(&RotatorCalibrationSP); - defineProperty(&GotoHomeSP); - defineProperty(&RotatorSettingsNP); - defineProperty(&RotatorStatusTP); + defineProperty(VersionTP); + defineProperty(HomePositionNP); + defineProperty(HomeOptionsSP); + defineProperty(RotatorCalibrationSP); + defineProperty(GotoHomeSP); + defineProperty(RotatorSettingsNP); + defineProperty(RotatorStatusTP); if (shutterOnLine()) { - defineProperty(&ShutterCalibrationSP); - defineProperty(&ShutterSettingsNP); - defineProperty(&ShutterSettingsTimeoutNP); - defineProperty(&ShutterStatusTP); - defineProperty(&ShutterVoltsNP); + defineProperty(ShutterCalibrationSP); + defineProperty(ShutterSettingsNP); + defineProperty(ShutterSettingsTimeoutNP); + defineProperty(ShutterStatusTP); + defineProperty(ShutterVoltsNP); } } else diff --git a/drivers/dome/scopedome_dome.cpp b/drivers/dome/scopedome_dome.cpp index 004bd278aa..a546c7dc2e 100644 --- a/drivers/dome/scopedome_dome.cpp +++ b/drivers/dome/scopedome_dome.cpp @@ -174,7 +174,7 @@ bool ScopeDome::initProperties() SetParkDataType(PARK_AZ); addAuxControls(); - defineProperty(&CardTypeSP); + defineProperty(CardTypeSP); defineProperty(CredentialsTP); setPollingPeriodRange(1000, 3000); // Device doesn't like too long interval @@ -375,7 +375,7 @@ bool ScopeDome::ISNewSwitch(const char *dev, const char *name, ISState *states, { LOG_INFO("Finding home sensor"); status = DOME_HOMING; - IUResetSwitch(&FindHomeSP); + FindHomeSP.reset(); DomeAbsPosNP.s = IPS_BUSY; FindHomeSP.setState(IPS_BUSY); FindHomeSP.apply(); @@ -390,7 +390,7 @@ bool ScopeDome::ISNewSwitch(const char *dev, const char *name, ISState *states, { LOG_INFO("De-rotating started"); status = DOME_DEROTATING; - IUResetSwitch(&DerotateSP); + DerotateSP.reset(); DomeAbsPosNP.s = IPS_BUSY; DerotateSP.setState(IPS_BUSY); DerotateSP.apply(); @@ -404,7 +404,7 @@ bool ScopeDome::ISNewSwitch(const char *dev, const char *name, ISState *states, { LOG_INFO("Calibration started"); status = DOME_CALIBRATING; - IUResetSwitch(&StartCalibrationSP); + StartCalibrationSP.reset(); DomeAbsPosNP.s = IPS_BUSY; StartCalibrationSP.setState(IPS_BUSY); StartCalibrationSP.apply(); diff --git a/drivers/focuser/esattoarco.cpp b/drivers/focuser/esattoarco.cpp index 6e3d0a08b4..30ab73e4c9 100644 --- a/drivers/focuser/esattoarco.cpp +++ b/drivers/focuser/esattoarco.cpp @@ -190,13 +190,13 @@ bool EsattoArco::updateProperties() defineProperty(&SpeedNP); defineProperty(&BacklashMessageTP); defineProperty(&BacklashMeasurementSP); - defineProperty(&FirmwareTP); + defineProperty(FirmwareTP); if (updateTemperature()) defineProperty(&TemperatureNP); if (updateVoltageIn()) - defineProperty(&VoltageNP); + defineProperty(VoltageNP); // Rotator INDI::RotatorInterface::updateProperties(); @@ -727,8 +727,8 @@ bool EsattoArco::Ack() if (rc1 && rc2) { - IUSaveText(&FirmwareTP[ESATTO_FIRMWARE_SN], serial.c_str()); - IUSaveText(&FirmwareTP[ESATTO_FIRMWARE_VERSION], firmware.c_str()); + FirmwareTP[ESATTO_FIRMWARE_SN].setText(serial); + FirmwareTP[ESATTO_FIRMWARE_VERSION].setText(firmware); LOGF_INFO("Esatto SN: %s Firmware version: %s", FirmwareTP[ESATTO_FIRMWARE_SN].getText(), FirmwareTP[ESATTO_FIRMWARE_VERSION].getText()); } @@ -740,8 +740,8 @@ bool EsattoArco::Ack() if (rc1 && rc2) { - IUSaveText(&FirmwareTP[ARCO_FIRMWARE_SN], serial.c_str()); - IUSaveText(&FirmwareTP[ARCO_FIRMWARE_VERSION], firmware.c_str()); + FirmwareTP[ARCO_FIRMWARE_SN].setText(serial); + FirmwareTP[ARCO_FIRMWARE_VERSION].setText(firmware); LOGF_INFO("Arco SN: %s Firmware version: %s", FirmwareTP[ARCO_FIRMWARE_SN].getText(), FirmwareTP[ARCO_FIRMWARE_VERSION].getText()); } diff --git a/drivers/focuser/focus_simulator.cpp b/drivers/focuser/focus_simulator.cpp index 4dfd06a844..d20f12f359 100644 --- a/drivers/focuser/focus_simulator.cpp +++ b/drivers/focuser/focus_simulator.cpp @@ -348,7 +348,7 @@ bool FocusSim::saveConfigItems(FILE *fp) { INDI::Focuser::saveConfigItems(fp); - IUSaveConfigNumber(fp, &DelayNP); + DelayNP.save(fp); return true; } diff --git a/drivers/focuser/tcfs.cpp b/drivers/focuser/tcfs.cpp index 5fe0d1de66..c6cafa2233 100644 --- a/drivers/focuser/tcfs.cpp +++ b/drivers/focuser/tcfs.cpp @@ -507,12 +507,12 @@ bool TCFS::ISNewSwitch(const char *dev, const char *name, ISState *states, char // Do not process any command if focuser is asleep if (isConnected() && FocusPowerSP.sp[0].s == ISS_ON) { - ISwitchVectorProperty *svp = getSwitch(name); + auto svp = getSwitch(name); if (svp) { - svp->s = IPS_IDLE; + svp.setState(IPS_IDLE); LOG_WARN("Focuser is still in sleep mode. Wake up in order to issue commands."); - IDSetSwitch(svp, nullptr); + svp->apply(); } return true; } @@ -599,12 +599,12 @@ bool TCFS::ISNewSwitch(const char *dev, const char *name, ISState *states, char // Do not process any other command if focuser is in auto mode if (isConnected() && FocusModeSP.sp[0].s != ISS_ON) { - ISwitchVectorProperty *svp = getSwitch(name); + auto svp = getSwitch(name); if (svp) { - svp->s = IPS_IDLE; + svp.setState(IPS_IDLE); LOG_WARN("Focuser is in auto mode. Change to manual in order to issue commands."); - IDSetSwitch(svp, nullptr); + svp.apply(); } return true; } diff --git a/drivers/telescope/astrotrac.cpp b/drivers/telescope/astrotrac.cpp index 057fd40705..2445656936 100644 --- a/drivers/telescope/astrotrac.cpp +++ b/drivers/telescope/astrotrac.cpp @@ -116,7 +116,7 @@ bool AstroTrac::initProperties() Initialise(this); // Force the alignment system to always be on - getSwitch("ALIGNMENT_SUBSYSTEM_ACTIVE")->sp[0].s = ISS_ON; + getSwitch("ALIGNMENT_SUBSYSTEM_ACTIVE")[0].setState(ISS_ON); return true; } @@ -128,7 +128,7 @@ void AstroTrac::ISGetProperties(const char *dev) { INDI::Telescope::ISGetProperties(dev); - defineProperty(&MountTypeSP); + defineProperty(MountTypeSP); } ///////////////////////////////////////////////////////////////////////////// @@ -145,12 +145,12 @@ bool AstroTrac::updateProperties() getVelocity(AXIS_RA); getVelocity(AXIS_DE); - defineProperty(&FirmwareTP); - defineProperty(&AccelerationNP); - defineProperty(&EncoderNP); + defineProperty(FirmwareTP); + defineProperty(AccelerationNP); + defineProperty(EncoderNP); defineProperty(&GuideNSNP); defineProperty(&GuideWENP); - defineProperty(&GuideRateNP); + defineProperty(GuideRateNP); // Initial AZ/AL parking position. if (InitPark()) @@ -1068,7 +1068,7 @@ bool AstroTrac::SetTrackEnabled(bool enabled) bool AstroTrac::saveConfigItems(FILE *fp) { INDI::Telescope::saveConfigItems(fp); - IUSaveConfigSwitch(fp, &MountTypeSP); + MountTypeSP.save(fp); SaveAlignmentConfigProperties(fp); return true; } diff --git a/drivers/telescope/skywatcherAPIMount.cpp b/drivers/telescope/skywatcherAPIMount.cpp index d0c270f68d..c7796f4883 100644 --- a/drivers/telescope/skywatcherAPIMount.cpp +++ b/drivers/telescope/skywatcherAPIMount.cpp @@ -114,7 +114,7 @@ bool SkywatcherAPIMount::initProperties() InitAlignmentProperties(this); // Force the alignment system to always be on - getSwitch("ALIGNMENT_SUBSYSTEM_ACTIVE")->sp[0].s = ISS_ON; + getSwitch("ALIGNMENT_SUBSYSTEM_ACTIVE")[0].setState(ISS_ON); // Set up property variables IUFillText(&BasicMountInfoT[MOTOR_CONTROL_FIRMWARE_VERSION], "MOTOR_CONTROL_FIRMWARE_VERSION", @@ -810,7 +810,7 @@ bool SkywatcherAPIMount::saveConfigItems(FILE *fp) { SaveAlignmentConfigProperties(fp); - IUSaveConfigNumber(fp, &TrackFactorNP); + TrackFactorNP.save(fp); return INDI::Telescope::saveConfigItems(fp); } @@ -1192,14 +1192,14 @@ bool SkywatcherAPIMount::updateProperties() defineProperty(&GuidingRatesNP); defineProperty(&GuideNSNP); defineProperty(&GuideWENP); - defineProperty(&TrackFactorNP); + defineProperty(TrackFactorNP); if (HasAuxEncoders()) { LOG_WARN("AUX encoders detected. Turning off..."); TurnRAEncoder(false); TurnDEEncoder(false); - defineProperty(&AUXEncoderSP); + defineProperty(AUXEncoderSP); } if (InitPark()) diff --git a/drivers/telescope/synscandriver.cpp b/drivers/telescope/synscandriver.cpp index 0d15a4f18a..3ecb6e6782 100644 --- a/drivers/telescope/synscandriver.cpp +++ b/drivers/telescope/synscandriver.cpp @@ -317,16 +317,16 @@ bool SynscanDriver::ISNewSwitch(const char *dev, const char *name, ISState *stat { if (dev && !strcmp(dev, getDeviceName())) { - ISwitchVectorProperty *svp = getSwitch(name); + auto svp = getSwitch(name); - if (!strcmp(svp->name, GotoModeSP.name)) + if (svp.isNameMatch(GotoModeSP.name)) { - IUUpdateSwitch(svp, states, names, n); - ISwitch *sp = IUFindOnSwitch(svp); + svp.update(states, names, n); + auto sp = svp.findOnSwitch(); assert(sp != nullptr); - if (!strcmp(sp->name, GotoModeS[0].name)) + if (sp->isNameMatch(GotoModeS[0].name)) SetAltAzMode(true); else SetAltAzMode(false); diff --git a/drivers/video/lx/Lx.cpp b/drivers/video/lx/Lx.cpp index dbcba10b4d..9f64a27991 100644 --- a/drivers/video/lx/Lx.cpp +++ b/drivers/video/lx/Lx.cpp @@ -605,25 +605,26 @@ void Lx::pwcsetLed(int on, int off) void Lx::pwcsetflashon() { ISState states[2] = { ISS_ON, ISS_OFF }; - const char *names[2] = { FlashStrobeSP->sp[0].name, FlashStrobeStopSP->sp[0].name }; - dev->ISNewSwitch(device_name, FlashStrobeSP->name, &(states[0]), (char **)names, 1); + const char *names[2] = { FlashStrobeSP->at(0)->getName(), FlashStrobeStopSP->at(0)->getName() }; + dev->ISNewSwitch(device_name, FlashStrobeSP->getName(), &(states[0]), (char **)names, 1); //dev->ISNewSwitch(device_name, FlashStrobeStopSP->name, &(states[1]), (char **)(names + 1), 1); - FlashStrobeSP->s = IPS_OK; - IDSetSwitch(FlashStrobeSP, nullptr); - FlashStrobeStopSP->s = IPS_IDLE; - IDSetSwitch(FlashStrobeStopSP, nullptr); + FlashStrobeSP->setState(IPS_OK); + FlashStrobeSP->apply(); + FlashStrobeStopSP->setState(IPS_IDLE); + FlashStrobeStopSP->apply(); } void Lx::pwcsetflashoff() { ISState states[2] = { ISS_OFF, ISS_ON }; - const char *names[2] = { FlashStrobeSP->sp[0].name, FlashStrobeStopSP->sp[0].name }; + const char *names[2] = { FlashStrobeSP->at(0)->getName(), FlashStrobeStopSP->at(0)->getName()}; //dev->ISNewSwitch(device_name, FlashStrobeSP->name, &(states[0]), (char **)names, 1); - dev->ISNewSwitch(device_name, FlashStrobeStopSP->name, &(states[1]), (char **)(names + 1), 1); - FlashStrobeStopSP->s = IPS_OK; - IDSetSwitch(FlashStrobeStopSP, nullptr); - FlashStrobeSP->s = IPS_IDLE; - IDSetSwitch(FlashStrobeSP, nullptr); + dev->ISNewSwitch(device_name, FlashStrobeStopSP->getName(), &(states[1]), (char **)(names + 1), 1); + FlashStrobeStopSP->setState(IPS_OK); + FlashStrobeStopSP->apply(); + + FlashStrobeSP->setState(IPS_IDLE); + FlashStrobeSP->apply(); } bool Lx::startLxPWC() diff --git a/drivers/video/lx/Lx.h b/drivers/video/lx/Lx.h index b3141c3adc..1765ccdc54 100644 --- a/drivers/video/lx/Lx.h +++ b/drivers/video/lx/Lx.h @@ -74,8 +74,8 @@ class Lx const char *getSerialEOL(); INDI::Property *findbyLabel(INDI::DefaultDevice *dev, char *label); // PWC Cameras - ISwitchVectorProperty *FlashStrobeSP; - ISwitchVectorProperty *FlashStrobeStopSP; + INDI::PropertyViewSwitch *FlashStrobeSP; + INDI::PropertyViewSwitch *FlashStrobeStopSP; enum pwcledmethod { PWCIOCTL, diff --git a/drivers/video/v4l2driver.cpp b/drivers/video/v4l2driver.cpp index dea7f850ec..52323d715d 100644 --- a/drivers/video/v4l2driver.cpp +++ b/drivers/video/v4l2driver.cpp @@ -282,7 +282,7 @@ void V4L2_Driver::ISGetProperties(const char * dev) defineProperty(&StackModeSP); - v4l_base->setNative(EncodeFormatSP[FORMAT_NATIVE].s == ISS_ON); + v4l_base->setNative(EncodeFormatSP[FORMAT_NATIVE].getState() == ISS_ON); #ifdef WITH_V4L2_EXPERIMENTS defineProperty(&ImageDepthSP); @@ -1939,7 +1939,7 @@ bool V4L2_Driver::StopStreaming() return false; } - v4l_base->setNative(EncodeFormatSP[FORMAT_NATIVE].s == ISS_ON); + v4l_base->setNative(EncodeFormatSP[FORMAT_NATIVE].getState() == ISS_ON); return stop_capturing(); } @@ -1958,17 +1958,16 @@ bool V4L2_Driver::saveConfigItems(FILE * fp) // Format auto format = getProperty("V4L2_FORMAT"); if (format.isValid()) - IUSaveConfigSwitch(fp, format.getSwitch()); + format.save(fp); // Size auto size = getProperty("V4L2_SIZE_DISCRETE"); if (size.isValid()) - IUSaveConfigSwitch(fp, size.getSwitch()); + size.save(fp); auto fps = getProperty("V4L2_FRAMEINT_DISCRETE"); if (fps.isValid()) - IUSaveConfigSwitch(fp, fps.getSwitch()); - + fps.save(fp); return Streamer->saveConfigItems(fp); } diff --git a/drivers/weather/openweathermap.cpp b/drivers/weather/openweathermap.cpp index 24e1c92a31..1a7455a2a6 100644 --- a/drivers/weather/openweathermap.cpp +++ b/drivers/weather/openweathermap.cpp @@ -69,7 +69,7 @@ const char *OpenWeatherMap::getDefaultName() void OpenWeatherMap::ISGetProperties(const char *dev) { INDI::Weather::ISGetProperties(dev); - defineProperty(&owmAPIKeyTP); + defineProperty(owmAPIKeyTP); } bool OpenWeatherMap::Connect() @@ -282,7 +282,7 @@ bool OpenWeatherMap::saveConfigItems(FILE *fp) { INDI::Weather::saveConfigItems(fp); - IUSaveConfigText(fp, &owmAPIKeyTP); + owmAPIKeyTP.save(fp); return true; } diff --git a/drivers/weather/uranusmeteo.cpp b/drivers/weather/uranusmeteo.cpp index 834047236b..4b405093e3 100644 --- a/drivers/weather/uranusmeteo.cpp +++ b/drivers/weather/uranusmeteo.cpp @@ -362,7 +362,7 @@ bool UranusMeteo::saveConfigItems(FILE * fp) { INDI::GPS::saveConfigItems(fp); WI::saveConfigItems(fp); - IUSaveConfigNumber(fp, &SkyQualityUpdateNP); + SkyQualityUpdateNP.save(fp); return true; } diff --git a/libs/alignment/ClientAPIForAlignmentDatabase.cpp b/libs/alignment/ClientAPIForAlignmentDatabase.cpp index 5efb2b9183..753029bfd9 100644 --- a/libs/alignment/ClientAPIForAlignmentDatabase.cpp +++ b/libs/alignment/ClientAPIForAlignmentDatabase.cpp @@ -31,20 +31,20 @@ bool ClientAPIForAlignmentDatabase::AppendSyncPoint(const AlignmentDatabaseEntry // Wait for driver to initialise if neccessary WaitForDriverCompletion(); - ISwitchVectorProperty *pAction = Action->getSwitch(); - ISwitchVectorProperty *pCommit = Commit->getSwitch(); + auto pAction = Action->getSwitch(); + auto pCommit = Commit->getSwitch(); - if (APPEND != IUFindOnSwitchIndex(pAction)) + if (APPEND != pAction->findOnSwitchIndex()) { // Request Append mode - IUResetSwitch(pAction); - pAction->sp[APPEND].s = ISS_ON; + pAction->reset(); + pAction->at(APPEND)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pAction); WaitForDriverCompletion(); - if (IPS_OK != pAction->s) + if (IPS_OK != pAction->getState()) { - IDLog("AppendSyncPoint - Bad Action switch state %s\n", pstateStr(pAction->s)); + IDLog("AppendSyncPoint - Bad Action switch state %s\n", pAction->getStateAsString()); return false; } } @@ -53,14 +53,14 @@ bool ClientAPIForAlignmentDatabase::AppendSyncPoint(const AlignmentDatabaseEntry return false; // Commit the entry to the database - IUResetSwitch(pCommit); - pCommit->sp[0].s = ISS_ON; + pCommit->reset(); + pCommit->at(0)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pCommit); WaitForDriverCompletion(); - if (IPS_OK != pCommit->s) + if (IPS_OK != pCommit->getState()) { - IDLog("AppendSyncPoint - Bad Commit switch state %s\n", pstateStr(pCommit->s)); + IDLog("AppendSyncPoint - Bad Commit switch state %s\n", pCommit->getStateAsString()); return false; } @@ -72,33 +72,33 @@ bool ClientAPIForAlignmentDatabase::ClearSyncPoints() // Wait for driver to initialise if neccessary WaitForDriverCompletion(); - ISwitchVectorProperty *pAction = Action->getSwitch(); - ISwitchVectorProperty *pCommit = Commit->getSwitch(); + auto pAction = Action->getSwitch(); + auto pCommit = Commit->getSwitch(); // Select the required action - if (CLEAR != IUFindOnSwitchIndex(pAction)) + if (CLEAR != pAction->findOnSwitchIndex()) { // Request Clear mode - IUResetSwitch(pAction); - pAction->sp[CLEAR].s = ISS_ON; + pAction->reset(); + pAction->at(CLEAR)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pAction); WaitForDriverCompletion(); - if (IPS_OK != pAction->s) + if (IPS_OK != pAction->getState()) { - IDLog("ClearSyncPoints - Bad Action switch state %s\n", pstateStr(pAction->s)); + IDLog("ClearSyncPoints - Bad Action switch state %s\n", pAction->getStateAsString()); return false; } } - IUResetSwitch(pCommit); - pCommit->sp[0].s = ISS_ON; + pCommit->reset(); + pCommit->at(0)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pCommit); WaitForDriverCompletion(); - if (IPS_OK != pCommit->s) + if (IPS_OK != pCommit->getState()) { - IDLog("ClearSyncPoints - Bad Commit switch state %s\n", pstateStr(pCommit->s)); + IDLog("ClearSyncPoints - Bad Commit switch state %s\n", pCommit->getStateAsString()); return false; } @@ -110,46 +110,46 @@ bool ClientAPIForAlignmentDatabase::DeleteSyncPoint(unsigned int Offset) // Wait for driver to initialise if neccessary WaitForDriverCompletion(); - ISwitchVectorProperty *pAction = Action->getSwitch(); - INumberVectorProperty *pCurrentEntry = CurrentEntry->getNumber(); - ISwitchVectorProperty *pCommit = Commit->getSwitch(); + auto pAction = Action->getSwitch(); + auto pCurrentEntry = CurrentEntry->getNumber(); + auto pCommit = Commit->getSwitch(); // Select the required action - if (DELETE != IUFindOnSwitchIndex(pAction)) + if (DELETE != pAction->findOnSwitchIndex()) { // Request Delete mode - IUResetSwitch(pAction); - pAction->sp[DELETE].s = ISS_ON; + pAction->reset(); + pAction->at(DELETE)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pAction); WaitForDriverCompletion(); - if (IPS_OK != pAction->s) + if (IPS_OK != pAction->getState()) { - IDLog("DeleteSyncPoint - Bad Action switch state %s\n", pstateStr(pAction->s)); + IDLog("DeleteSyncPoint - Bad Action switch state %s\n", pAction->getStateAsString()); return false; } } // Send the offset - pCurrentEntry->np[0].value = Offset; + pCurrentEntry->at(0)->setValue(Offset); SetDriverBusy(); BaseClient->sendNewNumber(pCurrentEntry); WaitForDriverCompletion(); - if (IPS_OK != pCurrentEntry->s) + if (IPS_OK != pCurrentEntry->getState()) { - IDLog("DeleteSyncPoint - Bad Current Entry state %s\n", pstateStr(pCurrentEntry->s)); + IDLog("DeleteSyncPoint - Bad Current Entry state %s\n", pCurrentEntry->getStateAsString()); return false; } // Commit the entry to the database - IUResetSwitch(pCommit); - pCommit->sp[0].s = ISS_ON; + pCommit->reset(); + pCommit->at(0)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pCommit); WaitForDriverCompletion(); - if (IPS_OK != pCommit->s) + if (IPS_OK != pCommit->getState()) { - IDLog("DeleteSyncPoint - Bad Commit switch state %s\n", pstateStr(pCommit->s)); + IDLog("DeleteSyncPoint - Bad Commit switch state %s\n", pCommit->getStateAsString()); return false; } @@ -161,34 +161,34 @@ bool ClientAPIForAlignmentDatabase::EditSyncPoint(unsigned int Offset, const Ali // Wait for driver to initialise if neccessary WaitForDriverCompletion(); - ISwitchVectorProperty *pAction = Action->getSwitch(); - INumberVectorProperty *pCurrentEntry = CurrentEntry->getNumber(); - ISwitchVectorProperty *pCommit = Commit->getSwitch(); + auto pAction = Action->getSwitch(); + auto pCurrentEntry = CurrentEntry->getNumber(); + auto pCommit = Commit->getSwitch(); // Select the required action - if (EDIT != IUFindOnSwitchIndex(pAction)) + if (EDIT != pAction->findOnSwitchIndex()) { // Request Edit mode - IUResetSwitch(pAction); - pAction->sp[EDIT].s = ISS_ON; + pAction->reset(); + pAction->at(EDIT)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pAction); WaitForDriverCompletion(); - if (IPS_OK != pAction->s) + if (IPS_OK != pAction->getState()) { - IDLog("EditSyncPoint - Bad Action switch state %s\n", pstateStr(pAction->s)); + IDLog("EditSyncPoint - Bad Action switch state %s\n", pAction->getStateAsString()); return false; } } // Send the offset - pCurrentEntry->np[0].value = Offset; + pCurrentEntry->at(0)->setValue(Offset); SetDriverBusy(); BaseClient->sendNewNumber(pCurrentEntry); WaitForDriverCompletion(); - if (IPS_OK != pCurrentEntry->s) + if (IPS_OK != pCurrentEntry->getState()) { - IDLog("EditSyncPoint - Bad Current Entry state %s\n", pstateStr(pCurrentEntry->s)); + IDLog("EditSyncPoint - Bad Current Entry state %s\n", pCurrentEntry->getStateAsString()); return false; } @@ -196,14 +196,14 @@ bool ClientAPIForAlignmentDatabase::EditSyncPoint(unsigned int Offset, const Ali return false; // Commit the entry to the database - IUResetSwitch(pCommit); - pCommit->sp[0].s = ISS_ON; + pCommit->reset(); + pCommit->at(0)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pCommit); WaitForDriverCompletion(); - if (IPS_OK != pCommit->s) + if (IPS_OK != pCommit->getState()) { - IDLog("EditSyncPoint - Bad Commit switch state %s\n", pstateStr(pCommit->s)); + IDLog("EditSyncPoint - Bad Commit switch state %s\n", pCommit->getStateAsString()); return false; } @@ -225,34 +225,34 @@ bool ClientAPIForAlignmentDatabase::InsertSyncPoint(unsigned int Offset, const A // Wait for driver to initialise if neccessary WaitForDriverCompletion(); - ISwitchVectorProperty *pAction = Action->getSwitch(); - INumberVectorProperty *pCurrentEntry = CurrentEntry->getNumber(); - ISwitchVectorProperty *pCommit = Commit->getSwitch(); + auto pAction = Action->getSwitch(); + auto pCurrentEntry = CurrentEntry->getNumber(); + auto pCommit = Commit->getSwitch(); // Select the required action - if (INSERT != IUFindOnSwitchIndex(pAction)) + if (INSERT != pAction->findOnSwitchIndex()) { // Request Insert mode - IUResetSwitch(pAction); - pAction->sp[INSERT].s = ISS_ON; + pAction->reset(); + pAction->at(INSERT)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pAction); WaitForDriverCompletion(); - if (IPS_OK != pAction->s) + if (IPS_OK != pAction->getState()) { - IDLog("InsertSyncPoint - Bad Action switch state %s\n", pstateStr(pAction->s)); + IDLog("InsertSyncPoint - Bad Action switch state %s\n", pAction->getStateAsString()); return false; } } // Send the offset - pCurrentEntry->np[0].value = Offset; + pCurrentEntry->at(0)->setValue(Offset); SetDriverBusy(); BaseClient->sendNewNumber(pCurrentEntry); WaitForDriverCompletion(); - if (IPS_OK != pCurrentEntry->s) + if (IPS_OK != pCurrentEntry->getState()) { - IDLog("InsertSyncPoint - Bad Current Entry state %s\n", pstateStr(pCurrentEntry->s)); + IDLog("InsertSyncPoint - Bad Current Entry state %s\n", pCurrentEntry->getStateAsString()); return false; } @@ -260,14 +260,14 @@ bool ClientAPIForAlignmentDatabase::InsertSyncPoint(unsigned int Offset, const A return false; // Commit the entry to the database - IUResetSwitch(pCommit); - pCommit->sp[0].s = ISS_ON; + pCommit->reset(); + pCommit->at(0)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pCommit); WaitForDriverCompletion(); - if (IPS_OK != pCommit->s) + if (IPS_OK != pCommit->getState()) { - IDLog("InsertSyncPoint - Bad Commit switch state %s\n", pstateStr(pCommit->s)); + IDLog("InsertSyncPoint - Bad Commit switch state %s\n", pCommit->getStateAsString()); return false; } @@ -279,34 +279,34 @@ bool ClientAPIForAlignmentDatabase::LoadDatabase() // Wait for driver to initialise if neccessary WaitForDriverCompletion(); - ISwitchVectorProperty *pAction = Action->getSwitch(); - ISwitchVectorProperty *pCommit = Commit->getSwitch(); + auto pAction = Action->getSwitch(); + auto pCommit = Commit->getSwitch(); // Select the required action - if (LOAD_DATABASE != IUFindOnSwitchIndex(pAction)) + if (LOAD_DATABASE != pAction->findOnSwitchIndex()) { // Request Load Database mode - IUResetSwitch(pAction); - pAction->sp[LOAD_DATABASE].s = ISS_ON; + pAction->reset(); + pAction->at(LOAD_DATABASE)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pAction); WaitForDriverCompletion(); - if (IPS_OK != pAction->s) + if (IPS_OK != pAction->getState()) { - IDLog("LoadDatabase - Bad Action switch state %s\n", pstateStr(pAction->s)); + IDLog("LoadDatabase - Bad Action switch state %s\n", pAction->getStateAsString()); return false; } } // Commit the Load Database - IUResetSwitch(pCommit); - pCommit->sp[0].s = ISS_ON; + pCommit->reset(); + pCommit->at(0)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pCommit); WaitForDriverCompletion(); - if (IPS_OK != pCommit->s) + if (IPS_OK != pCommit->getState()) { - IDLog("LoadDatabase - Bad Commit state %s\n", pstateStr(pCommit->s)); + IDLog("LoadDatabase - Bad Commit state %s\n", pCommit->getStateAsString()); return false; } @@ -319,8 +319,8 @@ void ClientAPIForAlignmentDatabase::ProcessNewBLOB(IBLOB *BLOBPointer) { if (IPS_BUSY != BLOBPointer->bvp->s) { - ISwitchVectorProperty *pAction = Action->getSwitch(); - int Index = IUFindOnSwitchIndex(pAction); + auto pAction = Action->getSwitch(); + int Index = pAction->findOnSwitchIndex(); if ((READ != Index) && (READ_INCREMENT != Index)) SignalDriverCompletion(); } @@ -338,8 +338,8 @@ void ClientAPIForAlignmentDatabase::ProcessNewNumber(INumberVectorProperty *Numb { if (IPS_BUSY != NumberVectorProperty->s) { - ISwitchVectorProperty *pAction = Action->getSwitch(); - int Index = IUFindOnSwitchIndex(pAction); + auto pAction = Action->getSwitch(); + int Index = pAction->findOnSwitchIndex(); if ((READ != Index) && (READ_INCREMENT != Index)) SignalDriverCompletion(); } @@ -348,8 +348,8 @@ void ClientAPIForAlignmentDatabase::ProcessNewNumber(INumberVectorProperty *Numb { if (IPS_BUSY != NumberVectorProperty->s) { - ISwitchVectorProperty *pAction = Action->getSwitch(); - int Index = IUFindOnSwitchIndex(pAction); + auto pAction = Action->getSwitch(); + int Index = pAction->findOnSwitchIndex(); if (READ_INCREMENT != Index) SignalDriverCompletion(); } @@ -366,7 +366,7 @@ void ClientAPIForAlignmentDatabase::ProcessNewProperty(INDI::Property *PropertyP { OptionalBinaryBlob = PropertyPointer; // Make sure the format string is set up - strncpy(OptionalBinaryBlob->getBLOB()->bp->format, "alignmentPrivateData", MAXINDIBLOBFMT); + OptionalBinaryBlob->getBLOB()->at(0)->setFormat("alignmentPrivateData"); } else if (strcmp(PropertyPointer->getName(), "ALIGNMENT_POINTSET_SIZE") == 0) PointsetSize = PropertyPointer; @@ -409,49 +409,49 @@ bool ClientAPIForAlignmentDatabase::ReadIncrementSyncPoint(AlignmentDatabaseEntr // 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(); + auto pAction = Action->getSwitch(); + auto pMandatoryNumbers = MandatoryNumbers->getNumber(); + auto pBLOB = OptionalBinaryBlob->getBLOB(); + auto pCurrentEntry = CurrentEntry->getNumber(); + auto pCommit = Commit->getSwitch(); // Select the required action - if (READ_INCREMENT != IUFindOnSwitchIndex(pAction)) + if (READ_INCREMENT != pAction->findOnSwitchIndex()) { // Request Read Increment mode - IUResetSwitch(pAction); - pAction->sp[READ_INCREMENT].s = ISS_ON; + pAction->reset(); + pAction->at(READ_INCREMENT)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pAction); WaitForDriverCompletion(); - if (IPS_OK != pAction->s) + if (IPS_OK != pAction->getState()) { - IDLog("ReadIncrementSyncPoint - Bad Action switch state %s\n", pstateStr(pAction->s)); + IDLog("ReadIncrementSyncPoint - Bad Action switch state %s\n", pAction->getStateAsString()); return false; } } // Commit the read increment - IUResetSwitch(pCommit); - pCommit->sp[0].s = ISS_ON; + pCommit->reset(); + pCommit->at(0)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pCommit); WaitForDriverCompletion(); - if ((IPS_OK != pCommit->s) || (IPS_OK != pMandatoryNumbers->s) || (IPS_OK != pBLOB->s) || - (IPS_OK != pCurrentEntry->s)) + if ((IPS_OK != pCommit->getState()) || (IPS_OK != pMandatoryNumbers->getState()) || (IPS_OK != pBLOB->getState()) || + (IPS_OK != pCurrentEntry->getState())) { 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)); + pCommit->getStateAsString(), pMandatoryNumbers->getStateAsString(), pBLOB->getStateAsString(), pCurrentEntry->getStateAsString()); 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; + CurrentValues.ObservationJulianDate = pMandatoryNumbers->at(ENTRY_OBSERVATION_JULIAN_DATE)->getValue(); + CurrentValues.RightAscension = pMandatoryNumbers->at(ENTRY_RA)->getValue(); + CurrentValues.Declination = pMandatoryNumbers->at(ENTRY_DEC)->getValue(); + CurrentValues.TelescopeDirection.x = pMandatoryNumbers->at(ENTRY_VECTOR_X)->getValue(); + CurrentValues.TelescopeDirection.y = pMandatoryNumbers->at(ENTRY_VECTOR_Y)->getValue(); + CurrentValues.TelescopeDirection.z = pMandatoryNumbers->at(ENTRY_VECTOR_Z)->getValue(); return true; } @@ -461,59 +461,59 @@ bool ClientAPIForAlignmentDatabase::ReadSyncPoint(unsigned int Offset, Alignment // 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(); + auto pAction = Action->getSwitch(); + auto pMandatoryNumbers = MandatoryNumbers->getNumber(); + auto pBLOB = OptionalBinaryBlob->getBLOB(); + auto pCurrentEntry = CurrentEntry->getNumber(); + auto pCommit = Commit->getSwitch(); // Select the required action - if (READ != IUFindOnSwitchIndex(pAction)) + if (READ != pAction->findOnSwitchIndex()) { // Request Read mode - IUResetSwitch(pAction); - pAction->sp[READ].s = ISS_ON; + pAction->reset(); + pAction->at(READ)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pAction); WaitForDriverCompletion(); - if (IPS_OK != pAction->s) + if (IPS_OK != pAction->getState()) { - IDLog("ReadSyncPoint - Bad Action switch state %s\n", pstateStr(pAction->s)); + IDLog("ReadSyncPoint - Bad Action switch state %s\n", pAction->getStateAsString()); return false; } } // Send the offset - pCurrentEntry->np[0].value = Offset; + pCurrentEntry->at(0)->setValue(Offset); SetDriverBusy(); BaseClient->sendNewNumber(pCurrentEntry); WaitForDriverCompletion(); - if (IPS_OK != pCurrentEntry->s) + if (IPS_OK != pCurrentEntry->getState()) { - IDLog("ReadSyncPoint - Bad Current Entry state %s\n", pstateStr(pCurrentEntry->s)); + IDLog("ReadSyncPoint - Bad Current Entry state %s\n", pCurrentEntry->getStateAsString()); return false; } // Commit the read - IUResetSwitch(pCommit); - pCommit->sp[0].s = ISS_ON; + pCommit->reset(); + pCommit->at(0)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pCommit); WaitForDriverCompletion(); - if ((IPS_OK != pCommit->s) || (IPS_OK != pMandatoryNumbers->s) || (IPS_OK != pBLOB->s)) + if ((IPS_OK != pCommit->getState()) || (IPS_OK != pMandatoryNumbers->getState()) || (IPS_OK != pBLOB->getState())) { - IDLog("ReadSyncPoint - Bad Commit/Mandatory numbers/Blob state %s %s %s\n", pstateStr(pCommit->s), - pstateStr(pMandatoryNumbers->s), pstateStr(pBLOB->s)); + IDLog("ReadSyncPoint - Bad Commit/Mandatory numbers/Blob state %s %s %s\n", pCommit->getStateAsString(), + pMandatoryNumbers->getStateAsString(), pBLOB->getStateAsString()); 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; + CurrentValues.ObservationJulianDate = pMandatoryNumbers->at(ENTRY_OBSERVATION_JULIAN_DATE)->getValue(); + CurrentValues.RightAscension = pMandatoryNumbers->at(ENTRY_RA)->getValue(); + CurrentValues.Declination = pMandatoryNumbers->at(ENTRY_DEC)->getValue(); + CurrentValues.TelescopeDirection.x = pMandatoryNumbers->at(ENTRY_VECTOR_X)->getValue(); + CurrentValues.TelescopeDirection.y = pMandatoryNumbers->at(ENTRY_VECTOR_Y)->getValue(); + CurrentValues.TelescopeDirection.z = pMandatoryNumbers->at(ENTRY_VECTOR_Z)->getValue(); return true; } @@ -523,34 +523,34 @@ bool ClientAPIForAlignmentDatabase::SaveDatabase() // Wait for driver to initialise if neccessary WaitForDriverCompletion(); - ISwitchVectorProperty *pAction = Action->getSwitch(); - ISwitchVectorProperty *pCommit = Commit->getSwitch(); + auto pAction = Action->getSwitch(); + auto pCommit = Commit->getSwitch(); // Select the required action - if (SAVE_DATABASE != IUFindOnSwitchIndex(pAction)) + if (SAVE_DATABASE != pAction->findOnSwitchIndex()) { // Request Load Database mode - IUResetSwitch(pAction); - pAction->sp[SAVE_DATABASE].s = ISS_ON; + pAction->reset(); + pAction->at(SAVE_DATABASE)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pAction); WaitForDriverCompletion(); - if (IPS_OK != pAction->s) + if (IPS_OK != pAction->getState()) { - IDLog("SaveDatabase - Bad Action switch state %s\n", pstateStr(pAction->s)); + IDLog("SaveDatabase - Bad Action switch state %s\n", pAction->getStateAsString()); return false; } } // Commit the Save Database - IUResetSwitch(pCommit); - pCommit->sp[0].s = ISS_ON; + pCommit->reset(); + pCommit->at(0)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pCommit); WaitForDriverCompletion(); - if (IPS_OK != pCommit->s) + if (IPS_OK != pCommit->getState()) { - IDLog("Save Database - Bad Commit state %s\n", pstateStr(pCommit->s)); + IDLog("Save Database - Bad Commit state %s\n", pCommit->getStateAsString()); return false; } @@ -561,21 +561,21 @@ bool ClientAPIForAlignmentDatabase::SaveDatabase() bool ClientAPIForAlignmentDatabase::SendEntryData(const AlignmentDatabaseEntry &CurrentValues) { - INumberVectorProperty *pMandatoryNumbers = MandatoryNumbers->getNumber(); - IBLOBVectorProperty *pBLOB = OptionalBinaryBlob->getBLOB(); + auto pMandatoryNumbers = MandatoryNumbers->getNumber(); + auto pBLOB = OptionalBinaryBlob->getBLOB(); // Send the entry data - pMandatoryNumbers->np[ENTRY_OBSERVATION_JULIAN_DATE].value = CurrentValues.ObservationJulianDate; - pMandatoryNumbers->np[ENTRY_RA].value = CurrentValues.RightAscension; - pMandatoryNumbers->np[ENTRY_DEC].value = CurrentValues.Declination; - pMandatoryNumbers->np[ENTRY_VECTOR_X].value = CurrentValues.TelescopeDirection.x; - pMandatoryNumbers->np[ENTRY_VECTOR_Y].value = CurrentValues.TelescopeDirection.y; - pMandatoryNumbers->np[ENTRY_VECTOR_Z].value = CurrentValues.TelescopeDirection.z; + pMandatoryNumbers->at(ENTRY_OBSERVATION_JULIAN_DATE)->setValue(CurrentValues.ObservationJulianDate); + pMandatoryNumbers->at(ENTRY_RA)->setValue(CurrentValues.RightAscension); + pMandatoryNumbers->at(ENTRY_DEC)->setValue(CurrentValues.Declination); + pMandatoryNumbers->at(ENTRY_VECTOR_X)->setValue(CurrentValues.TelescopeDirection.x); + pMandatoryNumbers->at(ENTRY_VECTOR_Y)->setValue(CurrentValues.TelescopeDirection.y); + pMandatoryNumbers->at(ENTRY_VECTOR_Z)->setValue(CurrentValues.TelescopeDirection.z); SetDriverBusy(); BaseClient->sendNewNumber(pMandatoryNumbers); WaitForDriverCompletion(); - if (IPS_OK != pMandatoryNumbers->s) + if (IPS_OK != pMandatoryNumbers->getState()) { - IDLog("SendEntryData - Bad mandatory numbers state %s\n", pstateStr(pMandatoryNumbers->s)); + IDLog("SendEntryData - Bad mandatory numbers state %s\n", pMandatoryNumbers->getStateAsString()); return false; } @@ -583,14 +583,14 @@ bool ClientAPIForAlignmentDatabase::SendEntryData(const AlignmentDatabaseEntry & { // I have a BLOB to send SetDriverBusy(); - BaseClient->startBlob(Device->getDeviceName(), pBLOB->name, timestamp()); - BaseClient->sendOneBlob(pBLOB->bp->name, CurrentValues.PrivateDataSize, pBLOB->bp->format, + BaseClient->startBlob(Device->getDeviceName(), pBLOB->getName(), timestamp()); + BaseClient->sendOneBlob(pBLOB->at(0)->getName(), CurrentValues.PrivateDataSize, pBLOB->at(0)->getFormat(), CurrentValues.PrivateData.get()); BaseClient->finishBlob(); WaitForDriverCompletion(); - if (IPS_OK != pBLOB->s) + if (IPS_OK != pBLOB->getState()) { - IDLog("SendEntryData - Bad BLOB state %s\n", pstateStr(pBLOB->s)); + IDLog("SendEntryData - Bad BLOB state %s\n", pBLOB->getStateAsString()); return false; } } diff --git a/libs/alignment/ClientAPIForMathPluginManagement.cpp b/libs/alignment/ClientAPIForMathPluginManagement.cpp index fbeabe22e0..84d0365512 100644 --- a/libs/alignment/ClientAPIForMathPluginManagement.cpp +++ b/libs/alignment/ClientAPIForMathPluginManagement.cpp @@ -23,10 +23,10 @@ bool ClientAPIForMathPluginManagement::EnumerateMathPlugins(MathPluginsList &Ava AvailableMathPlugins.clear(); - ISwitchVectorProperty *pPlugins = MathPlugins->getSwitch(); + auto pPlugins = MathPlugins->getSwitch(); - for (int i = 0; i < pPlugins->nsp; i++) - AvailableMathPlugins.emplace_back(std::string(pPlugins->sp[i].label)); + for (int i = 0; i < pPlugins->count(); i++) + AvailableMathPlugins.emplace_back(std::string(pPlugins->at(i)->getLabel())); return true; } @@ -81,25 +81,25 @@ bool ClientAPIForMathPluginManagement::SelectMathPlugin(const std::string &MathP // Wait for driver to initialise if neccessary WaitForDriverCompletion(); - ISwitchVectorProperty *pPlugins = MathPlugins->getSwitch(); + auto pPlugins = MathPlugins->getSwitch(); int i; - for (i = 0; i < pPlugins->nsp; i++) + for (i = 0; i < pPlugins->count(); i++) { - if (0 == strcmp(MathPluginName.c_str(), pPlugins->sp[i].label)) + if (0 == strcmp(MathPluginName.c_str(), pPlugins->at(i)->getLabel())) break; } - if (i >= pPlugins->nsp) + if (i >= pPlugins->count()) return false; - IUResetSwitch(pPlugins); - pPlugins->sp[i].s = ISS_ON; + pPlugins->reset(); + pPlugins->at(i)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pPlugins); WaitForDriverCompletion(); - if (IPS_OK != pPlugins->s) + if (IPS_OK != pPlugins->getState()) { - IDLog("SelectMathPlugin - Bad MathPlugins switch state %s\n", pstateStr(pPlugins->s)); + IDLog("SelectMathPlugin - Bad MathPlugins switch state %s\n", pPlugins->getStateAsString()); return false; } return true; @@ -110,16 +110,16 @@ bool ClientAPIForMathPluginManagement::ReInitialiseMathPlugin() // Wait for driver to initialise if neccessary WaitForDriverCompletion(); - ISwitchVectorProperty *pPluginInitialise = PluginInitialise->getSwitch(); + auto pPluginInitialise = PluginInitialise->getSwitch(); - IUResetSwitch(pPluginInitialise); - pPluginInitialise->sp[0].s = ISS_ON; + pPluginInitialise->reset(); + pPluginInitialise->at(0)->setState(ISS_ON); SetDriverBusy(); BaseClient->sendNewSwitch(pPluginInitialise); WaitForDriverCompletion(); - if (IPS_OK != pPluginInitialise->s) + if (IPS_OK != pPluginInitialise->getState()) { - IDLog("ReInitialiseMathPlugin - Bad PluginInitialise switch state %s\n", pstateStr(pPluginInitialise->s)); + IDLog("ReInitialiseMathPlugin - Bad PluginInitialise switch state %s\n", pPluginInitialise->getStateAsString()); return false; } return true; diff --git a/libs/indiabstractclient/abstractbaseclient.cpp b/libs/indiabstractclient/abstractbaseclient.cpp index 25471a55e0..ef2ec4d205 100644 --- a/libs/indiabstractclient/abstractbaseclient.cpp +++ b/libs/indiabstractclient/abstractbaseclient.cpp @@ -465,19 +465,19 @@ void AbstractBaseClient::sendNewProperty(INDI::Property pp) switch (pp.getType()) { case INDI_NUMBER: - IUUserIONewNumber(&d->io, d, pp.getNumber()); + IUUserIONewNumber(&d->io, d, pp.getNumber()->cast()); break; case INDI_SWITCH: - IUUserIONewSwitch(&d->io, d, pp.getSwitch()); + IUUserIONewSwitch(&d->io, d, pp.getSwitch()->cast()); break; case INDI_TEXT: - IUUserIONewText(&d->io, d, pp.getText()); + IUUserIONewText(&d->io, d, pp.getText()->cast()); break; case INDI_LIGHT: IDLog("Light type is not supported to send\n"); break; case INDI_BLOB: - IUUserIONewBLOB(&d->io, d, pp.getBLOB()); + IUUserIONewBLOB(&d->io, d, pp.getBLOB()->cast()); break; case INDI_UNKNOWN: IDLog("Unknown type of property to send\n"); @@ -491,7 +491,7 @@ void AbstractBaseClient::sendNewText(INDI::Property pp) AutoCNumeric locale; pp.setState(IPS_BUSY); - IUUserIONewText(&d->io, d, pp.getText()); + IUUserIONewText(&d->io, d, pp.getText()->cast()); } void AbstractBaseClient::sendNewText(const char *deviceName, const char *propertyName, const char *elementName, @@ -517,7 +517,7 @@ void AbstractBaseClient::sendNewNumber(INDI::Property pp) D_PTR(AbstractBaseClient); AutoCNumeric locale; pp.setState(IPS_BUSY); - IUUserIONewNumber(&d->io, d, pp.getNumber()); + IUUserIONewNumber(&d->io, d, pp.getNumber()->cast()); } void AbstractBaseClient::sendNewNumber(const char *deviceName, const char *propertyName, const char *elementName, @@ -542,7 +542,7 @@ void AbstractBaseClient::sendNewSwitch(INDI::Property pp) { D_PTR(AbstractBaseClient); pp.setState(IPS_BUSY); - IUUserIONewSwitch(&d->io, d, pp.getSwitch()); + IUUserIONewSwitch(&d->io, d, pp.getSwitch()->cast()); } void AbstractBaseClient::sendNewSwitch(const char *deviceName, const char *propertyName, const char *elementName) @@ -568,7 +568,7 @@ void AbstractBaseClient::startBlob(const char *devName, const char *propName, co IUUserIONewBLOBStart(&d->io, d, devName, propName, timestamp); } -void AbstractBaseClient::sendOneBlob(INDI::WidgetView *blob) +void AbstractBaseClient::sendOneBlob(INDI::WidgetViewBlob *blob) { D_PTR(AbstractBaseClient); IUUserIOBLOBContextOne( @@ -579,7 +579,7 @@ void AbstractBaseClient::sendOneBlob(INDI::WidgetView *blob) void AbstractBaseClient::sendOneBlob(IBLOB *bp) { - sendOneBlob(static_cast*>(bp)); + sendOneBlob(INDI::WidgetViewBlob::cast(bp)); } void AbstractBaseClient::sendOneBlob(const char *blobName, unsigned int blobSize, const char *blobFormat, diff --git a/libs/indiabstractclient/abstractbaseclient.h b/libs/indiabstractclient/abstractbaseclient.h index 49d43a73fe..3f03ed1fe7 100644 --- a/libs/indiabstractclient/abstractbaseclient.h +++ b/libs/indiabstractclient/abstractbaseclient.h @@ -191,7 +191,7 @@ class AbstractBaseClient : public INDI::BaseMediator void startBlob(const char *devName, const char *propName, const char *timestamp); /** @brief Send ONE blob content to server. The BLOB data in raw binary format and will be converted to base64 and sent to server */ void sendOneBlob(IBLOB *bp); - void sendOneBlob(INDI::WidgetView *blob); + void sendOneBlob(INDI::WidgetViewBlob *blob); /** @brief Send ONE blob content to server. The BLOB data in raw binary format and will be converted to base64 and sent to server */ void sendOneBlob(const char *blobName, unsigned int blobSize, const char *blobFormat, void *blobBuffer); /** @brief Send closing tag for BLOB command to server */ diff --git a/libs/indibase/defaultdevice.cpp b/libs/indibase/defaultdevice.cpp index 9af70f972c..b3e68f8128 100644 --- a/libs/indibase/defaultdevice.cpp +++ b/libs/indibase/defaultdevice.cpp @@ -1059,31 +1059,31 @@ bool DefaultDevice::deleteProperty(const char *propertyName) void DefaultDevice::defineProperty(INumberVectorProperty *property) { registerProperty(INDI::Property(property)); - static_cast*>(property)->define(); + static_cast(property)->define(); } void DefaultDevice::defineProperty(ITextVectorProperty *property) { registerProperty(INDI::Property(property)); - static_cast*>(property)->define(); + static_cast(property)->define(); } void DefaultDevice::defineProperty(ISwitchVectorProperty *property) { registerProperty(INDI::Property(property)); - static_cast*>(property)->define(); + static_cast(property)->define(); } void DefaultDevice::defineProperty(ILightVectorProperty *property) { registerProperty(INDI::Property(property)); - static_cast*>(property)->define(); + static_cast(property)->define(); } void DefaultDevice::defineProperty(IBLOBVectorProperty *property) { registerProperty(INDI::Property(property)); - static_cast*>(property)->define(); + static_cast(property)->define(); } void DefaultDevice::defineProperty(INDI::Property &property) diff --git a/libs/indibase/dsp/dspinterface.cpp b/libs/indibase/dsp/dspinterface.cpp index 8817d5110a..da4505a2a7 100644 --- a/libs/indibase/dsp/dspinterface.cpp +++ b/libs/indibase/dsp/dspinterface.cpp @@ -196,10 +196,10 @@ bool Interface::processBLOB(uint8_t* buffer, uint32_t ndims, int* dims, int bits bool success = false; if(PluginActive) { - bool sendCapture = (m_Device->getSwitch("UPLOAD_MODE")->sp[0].s == ISS_ON - || m_Device->getSwitch("UPLOAD_MODE")->sp[2].s == ISS_ON); - bool saveCapture = (m_Device->getSwitch("UPLOAD_MODE")->sp[1].s == ISS_ON - || m_Device->getSwitch("UPLOAD_MODE")->sp[2].s == ISS_ON); + bool sendCapture = (m_Device->getSwitch("UPLOAD_MODE")[0].getState() == ISS_ON + || m_Device->getSwitch("UPLOAD_MODE")[2].getState() == ISS_ON); + bool saveCapture = (m_Device->getSwitch("UPLOAD_MODE")[1].getState() == ISS_ON + || m_Device->getSwitch("UPLOAD_MODE")[2].getState() == ISS_ON); if (sendCapture || saveCapture) { @@ -254,23 +254,23 @@ void Interface::addFITSKeywords(fitsfile *fptr) char fitsString[MAXINDIDEVICE]; // Telescope - strncpy(fitsString, m_Device->getText("ACTIVE_DEVICES")->tp[0].text, MAXINDIDEVICE); + strncpy(fitsString, m_Device->getText("ACTIVE_DEVICES")[0].getText(), MAXINDIDEVICE); fits_update_key_s(fptr, TSTRING, "TELESCOP", fitsString, "Telescope name", &status); // Observer - strncpy(fitsString, m_Device->getText("FITS_HEADER")->tp[0].text, MAXINDIDEVICE); + strncpy(fitsString, m_Device->getText("FITS_HEADER")[0].getText(), MAXINDIDEVICE); fits_update_key_s(fptr, TSTRING, "OBSERVER", fitsString, "Observer name", &status); // Object - strncpy(fitsString, m_Device->getText("FITS_HEADER")->tp[1].text, MAXINDIDEVICE); + strncpy(fitsString, m_Device->getText("FITS_HEADER")[1].getText(), MAXINDIDEVICE); fits_update_key_s(fptr, TSTRING, "OBJECT", fitsString, "Object name", &status); - INumberVectorProperty *nv = m_Device->getNumber("GEOGRAPHIC_COORDS"); - if(nv != nullptr) + auto nv = m_Device->getNumber("GEOGRAPHIC_COORDS"); + if(!nv) { - double Lat = nv->np[0].value; - double Lon = nv->np[1].value; - double El = nv->np[2].value; + double Lat = nv[0].getValue(); + double Lon = nv[1].getValue(); + double El = nv[2].getValue(); char lat_str[MAXINDIFORMAT]; char lon_str[MAXINDIFORMAT]; @@ -286,8 +286,8 @@ void Interface::addFITSKeywords(fitsfile *fptr) nv = m_Device->getNumber("EQUATORIAL_EOD_COORDS"); if(nv != nullptr) { - double RA = nv->np[0].value; - double Dec = nv->np[1].value; + double RA = nv[0].getValue(); + double Dec = nv[1].getValue(); INDI::IEquatorialCoordinates epochPos { 0, 0 }, J2000Pos { 0, 0 }; epochPos.rightascension = RA; @@ -501,14 +501,14 @@ bool Interface::uploadFile(const void *fitsData, size_t totalBytes, bool sendCap FILE *fp = nullptr; - std::string prefix = m_Device->getText("UPLOAD_SETTINGS")->tp[1].text; + std::string prefix = m_Device->getText("UPLOAD_SETTINGS")[1].getText(); - int maxIndex = getFileIndex(m_Device->getText("UPLOAD_SETTINGS")->tp[0].text, prefix.c_str(), + int maxIndex = getFileIndex(m_Device->getText("UPLOAD_SETTINGS")[0].getText(), prefix.c_str(), format); if (maxIndex < 0) { - DEBUGF(INDI::Logger::DBG_ERROR, "Error iterating directory %s. %s", m_Device->getText("UPLOAD_SETTINGS")->tp[0].text, + DEBUGF(INDI::Logger::DBG_ERROR, "Error iterating directory %s. %s", m_Device->getText("UPLOAD_SETTINGS")[0].getText(), strerror(errno)); return false; } @@ -533,7 +533,7 @@ bool Interface::uploadFile(const void *fitsData, size_t totalBytes, bool sendCap char processedFileName[MAXINDINAME]; - snprintf(processedFileName, MAXINDINAME, "%s/%s_%s.%s", m_Device->getText("UPLOAD_SETTINGS")->tp[0].text, prefix.c_str(), + snprintf(processedFileName, MAXINDINAME, "%s/%s_%s.%s", m_Device->getText("UPLOAD_SETTINGS")[0].getText(), prefix.c_str(), m_Name, format); fp = fopen(processedFileName, "w"); diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index 949e773c3e..250acedab5 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -550,11 +550,11 @@ bool CCD::updateProperties() if (HasCooler()) { defineProperty(&TemperatureNP); - defineProperty(&TemperatureRampNP); + defineProperty(TemperatureRampNP); } - defineProperty(&CaptureFormatSP); - defineProperty(&EncodeFormatSP); + defineProperty(CaptureFormatSP); + defineProperty(EncodeFormatSP); defineProperty(&PrimaryCCD.ImagePixelSizeNP); if (HasGuideHead()) @@ -2585,11 +2585,11 @@ bool CCD::saveConfigItems(FILE * fp) if (PrimaryCCD.getCCDInfo()->p != IP_RO) IUSaveConfigNumber(fp, PrimaryCCD.getCCDInfo()); - IUSaveConfigSwitch(fp, &CaptureFormatSP); - IUSaveConfigSwitch(fp, &EncodeFormatSP); + CaptureFormatSP.save(fp); + EncodeFormatSP.save(fp); if (HasCooler()) - IUSaveConfigNumber(fp, &TemperatureRampNP); + TemperatureRampNP.save(fp); if (HasGuideHead()) { @@ -2815,25 +2815,25 @@ void CCD::checkTemperatureTarget() { if (TemperatureNP.s == IPS_BUSY) { - if (std::abs(m_TargetTemperature - TemperatureN[0].value) <= TemperatureRampNP[RAMP_THRESHOLD].value) + if (std::abs(m_TargetTemperature - TemperatureN[0].value) <= TemperatureRampNP[RAMP_THRESHOLD].getValue()) { TemperatureNP.s = IPS_OK; m_TemperatureCheckTimer.stop(); IDSetNumber(&TemperatureNP, nullptr); } // If we are beyond a minute, check for next step - else if (TemperatureRampNP[RAMP_SLOPE].value > 0 && m_TemperatureElapsedTimer.elapsed() >= 60000) + else if (TemperatureRampNP[RAMP_SLOPE].getValue() > 0 && m_TemperatureElapsedTimer.elapsed() >= 60000) { double nextTemperature = 0; // Going down if (m_TargetTemperature < TemperatureN[0].value) { - nextTemperature = std::max(m_TargetTemperature, TemperatureN[0].value - TemperatureRampNP[RAMP_SLOPE].value); + nextTemperature = std::max(m_TargetTemperature, TemperatureN[0].value - TemperatureRampNP[RAMP_SLOPE].getValue()); } // Going up else { - nextTemperature = std::min(m_TargetTemperature, TemperatureN[0].value + TemperatureRampNP[RAMP_SLOPE].value); + nextTemperature = std::min(m_TargetTemperature, TemperatureN[0].value + TemperatureRampNP[RAMP_SLOPE].getValue()); } m_TemperatureElapsedTimer.restart(); diff --git a/libs/indibase/inditelescope.cpp b/libs/indibase/inditelescope.cpp index 61907716b0..03cb16aaaa 100644 --- a/libs/indibase/inditelescope.cpp +++ b/libs/indibase/inditelescope.cpp @@ -385,7 +385,7 @@ bool Telescope::updateProperties() { defineProperty(&MovementNSSP); defineProperty(&MovementWESP); - defineProperty(&ReverseMovementSP); + defineProperty(ReverseMovementSP); if (nSlewRate >= 4) defineProperty(&SlewRateSP); defineProperty(&TargetNP); @@ -496,12 +496,12 @@ bool Telescope::updateProperties() { controller->updateProperties(); - ISwitchVectorProperty *useJoystick = getSwitch("USEJOYSTICK"); + auto useJoystick = getSwitch("USEJOYSTICK"); if (useJoystick) { if (isConnected()) { - if (useJoystick->sp[0].s == ISS_ON) + if (useJoystick[0].getState() == ISS_ON) { defineProperty(&MotionControlModeTP); loadConfig(true, "MOTION_CONTROL_MODE"); @@ -667,7 +667,7 @@ bool Telescope::saveConfigItems(FILE *fp) } if (CanGOTO()) - IUSaveConfigSwitch(fp, &ReverseMovementSP); + ReverseMovementSP.save(fp); if (SlewRateS != nullptr) IUSaveConfigSwitch(fp, &SlewRateSP); @@ -1593,8 +1593,8 @@ bool Telescope::ISNewSwitch(const char *dev, const char *name, ISState *states, bool rc = controller->ISNewSwitch(dev, name, states, names, n); if (rc) { - ISwitchVectorProperty *useJoystick = getSwitch("USEJOYSTICK"); - if (useJoystick && useJoystick->sp[0].s == ISS_ON) + auto useJoystick = getSwitch("USEJOYSTICK"); + if (useJoystick && useJoystick[0].getState() == ISS_ON) { defineProperty(&MotionControlModeTP); defineProperty(&LockAxisSP); @@ -2339,10 +2339,10 @@ void Telescope::processButton(const char *button_n, ISState state) if (!strcmp(button_n, "ABORTBUTTON")) { - ISwitchVectorProperty *trackSW = getSwitch("TELESCOPE_TRACK_MODE"); + auto trackSW = getSwitch("TELESCOPE_TRACK_MODE"); // Only abort if we have some sort of motion going on if (ParkSP.s == IPS_BUSY || MovementNSSP.s == IPS_BUSY || MovementWESP.s == IPS_BUSY || EqNP.s == IPS_BUSY || - (trackSW && trackSW->s == IPS_BUSY)) + (trackSW && trackSW.getState() == IPS_BUSY)) { // Invoke parent processing so that Telescope takes care of abort cross-check ISState states[1] = { ISS_ON }; diff --git a/libs/indibase/indiweatherinterface.cpp b/libs/indibase/indiweatherinterface.cpp index 294d837268..0a00a8d856 100644 --- a/libs/indibase/indiweatherinterface.cpp +++ b/libs/indibase/indiweatherinterface.cpp @@ -446,7 +446,7 @@ void WeatherInterface::createParameterRange(std::string name, std::string label) bool WeatherInterface::saveConfigItems(FILE *fp) { - IUSaveConfigNumber(fp, &UpdatePeriodNP); + UpdatePeriodNP.save(fp); for (int i = 0; i < nRanges; i++) IUSaveConfigNumber(fp, &ParametersRangeNP[i]); return true; diff --git a/libs/indibase/stream/encoder/encoderinterface.h b/libs/indibase/stream/encoder/encoderinterface.h index 2037fd0c37..141368311b 100644 --- a/libs/indibase/stream/encoder/encoderinterface.h +++ b/libs/indibase/stream/encoder/encoderinterface.h @@ -23,6 +23,7 @@ #include "indidevapi.h" #include "indibasetypes.h" +#include "indiwidgetview.h" #include #include @@ -52,7 +53,7 @@ class EncoderInterface virtual bool setSize(uint16_t width, uint16_t height); - virtual bool upload(IBLOB *bp, const uint8_t *buffer, uint32_t nbytes, bool isCompressed = false) = 0; + virtual bool upload(INDI::WidgetViewBlob *bp, const uint8_t *buffer, uint32_t nbytes, bool isCompressed = false) = 0; const char *getName(); diff --git a/libs/indibase/stream/encoder/mjpegencoder.cpp b/libs/indibase/stream/encoder/mjpegencoder.cpp index 0ec31cfa65..36428dc67f 100644 --- a/libs/indibase/stream/encoder/mjpegencoder.cpp +++ b/libs/indibase/stream/encoder/mjpegencoder.cpp @@ -64,7 +64,7 @@ const char *MJPEGEncoder::getDeviceName() return currentDevice->getDeviceName(); } -bool MJPEGEncoder::upload(IBLOB *bp, const uint8_t *buffer, uint32_t nbytes, bool isCompressed) +bool MJPEGEncoder::upload(INDI::WidgetViewBlob *bp, const uint8_t *buffer, uint32_t nbytes, bool isCompressed) { // We do not support compression if (isCompressed) @@ -90,10 +90,10 @@ bool MJPEGEncoder::upload(IBLOB *bp, const uint8_t *buffer, uint32_t nbytes, boo else jpeg_compress_8u_gray(buffer, rawWidth, rawHeight, rawWidth, scale, jpegBuffer, &bufsize, 85); - bp->blob = jpegBuffer; - bp->bloblen = bufsize; - bp->size = bufsize; - strcpy(bp->format, ".stream_jpg"); + bp->setBlob(jpegBuffer); + bp->setBlobLen(bufsize); + bp->setSize(bufsize); + bp->setFormat(".stream_jpg"); return true; } diff --git a/libs/indibase/stream/encoder/mjpegencoder.h b/libs/indibase/stream/encoder/mjpegencoder.h index 3fc4ed19b5..927f7a06b5 100644 --- a/libs/indibase/stream/encoder/mjpegencoder.h +++ b/libs/indibase/stream/encoder/mjpegencoder.h @@ -37,7 +37,7 @@ class MJPEGEncoder : public EncoderInterface MJPEGEncoder(); ~MJPEGEncoder(); - virtual bool upload(IBLOB *bp, const uint8_t *buffer, uint32_t nbytes, bool isCompressed = false) override; + virtual bool upload(INDI::WidgetViewBlob *bp, const uint8_t *buffer, uint32_t nbytes, bool isCompressed = false) override; private: const char *getDeviceName(); diff --git a/libs/indibase/stream/encoder/rawencoder.cpp b/libs/indibase/stream/encoder/rawencoder.cpp index 9eb77f3a36..3a574269f7 100644 --- a/libs/indibase/stream/encoder/rawencoder.cpp +++ b/libs/indibase/stream/encoder/rawencoder.cpp @@ -42,7 +42,7 @@ const char *RawEncoder::getDeviceName() return currentDevice->getDeviceName(); } -bool RawEncoder::upload(IBLOB *bp, const uint8_t *buffer, uint32_t nbytes, bool isCompressed) +bool RawEncoder::upload(INDI::WidgetViewBlob *bp, const uint8_t *buffer, uint32_t nbytes, bool isCompressed) { // Do we want to compress ? if (isCompressed) @@ -60,18 +60,18 @@ bool RawEncoder::upload(IBLOB *bp, const uint8_t *buffer, uint32_t nbytes, bool } // Send it compressed - bp->blob = compressedFrame.data(); - bp->bloblen = compressedBytes; - bp->size = nbytes; - strcpy(bp->format, ".stream.z"); + bp->setBlob(compressedFrame.data()); + bp->setBlobLen(compressedBytes); + bp->setSize(nbytes); + bp->setFormat(".stream.z"); } else { // Send it uncompressed - bp->blob = (const_cast(buffer)); - bp->bloblen = nbytes; - bp->size = nbytes; - strcpy(bp->format, ".stream"); + bp->setBlob((const_cast(buffer))); + bp->setBlobLen(nbytes); + bp->setSize(nbytes); + bp->setFormat(".stream"); } return true; diff --git a/libs/indibase/stream/encoder/rawencoder.h b/libs/indibase/stream/encoder/rawencoder.h index c343ee22f4..2cc64df876 100644 --- a/libs/indibase/stream/encoder/rawencoder.h +++ b/libs/indibase/stream/encoder/rawencoder.h @@ -37,7 +37,7 @@ class RawEncoder : public EncoderInterface RawEncoder(); ~RawEncoder(); - virtual bool upload(IBLOB *bp, const uint8_t *buffer, uint32_t nbytes, bool isCompressed = false) override; + virtual bool upload(INDI::WidgetViewBlob *bp, const uint8_t *buffer, uint32_t nbytes, bool isCompressed = false) override; private: const char *getDeviceName(); diff --git a/libs/indibase/stream/streammanager.cpp b/libs/indibase/stream/streammanager.cpp index b70a9a0751..2003ae7e25 100644 --- a/libs/indibase/stream/streammanager.cpp +++ b/libs/indibase/stream/streammanager.cpp @@ -280,8 +280,8 @@ void StreamManagerPrivate::newFrame(const uint8_t * buffer, uint32_t nbytes) // N is StreamExposureNP[STREAM_DIVISOR].getValue() ++frameCountDivider; if ( - (StreamExposureNP[STREAM_DIVISOR].value > 1) && - (frameCountDivider % static_cast(StreamExposureNP[STREAM_DIVISOR].value)) == 0 + (StreamExposureNP[STREAM_DIVISOR].getValue() > 1) && + (frameCountDivider % static_cast(StreamExposureNP[STREAM_DIVISOR].getValue())) == 0 ) { return; @@ -323,8 +323,8 @@ void StreamManagerPrivate::newFrame(const uint8_t * buffer, uint32_t nbytes) // captured all frames, stream should be close if ( - (RecordStreamSP[RECORD_FRAME].getState() == ISS_ON && FPSRecorder.totalFrames() >= (RecordOptionsNP[1].value)) || - (RecordStreamSP[RECORD_TIME ].getState() == ISS_ON && FPSRecorder.totalTime() >= (RecordOptionsNP[0].value * 1000.0)) + (RecordStreamSP[RECORD_FRAME].getState() == ISS_ON && FPSRecorder.totalFrames() >= (RecordOptionsNP[1].getValue())) || + (RecordStreamSP[RECORD_TIME ].getState() == ISS_ON && FPSRecorder.totalTime() >= (RecordOptionsNP[0].getValue() * 1000.0)) ) { LOG_INFO("Waiting for all buffered frames to be recorded"); @@ -503,7 +503,7 @@ void StreamManagerPrivate::asyncStreamThread() void StreamManagerPrivate::setSize(uint16_t width, uint16_t height) { - if (width != StreamFrameNP[CCDChip::FRAME_W].value || height != StreamFrameNP[CCDChip::FRAME_H].getValue()) + if (width != StreamFrameNP[CCDChip::FRAME_W].getValue() || height != StreamFrameNP[CCDChip::FRAME_H].getValue()) { if (PixelFormat == INDI_JPG) LOG_WARN("Cannot subframe JPEG streams."); @@ -643,14 +643,14 @@ bool StreamManagerPrivate::startRecording() } } - recorder->setFPS(FpsNP[FPS_AVERAGE].value); + recorder->setFPS(FpsNP[FPS_AVERAGE].getValue()); /* pattern substitution */ - recordfiledir.assign(RecordFileTP[0].text); + recordfiledir.assign(RecordFileTP[0].getText()); expfiledir = expand(recordfiledir, patterns); if (expfiledir.at(expfiledir.size() - 1) != '/') expfiledir += '/'; - recordfilename.assign(RecordFileTP[1].text); + recordfilename.assign(RecordFileTP[1].getText()); expfilename = expand(recordfilename, patterns); if (expfilename.size() < 4 || expfilename.substr(expfilename.size() - 4, 4) != recorder->getExtension()) expfilename += recorder->getExtension(); @@ -813,10 +813,10 @@ bool StreamManagerPrivate::ISNewSwitch(const char * dev, const char * name, ISSt if (!isRecording) { RecordStreamSP.setState(IPS_BUSY); - if (RecordStreamSP[RECORD_TIME].s == ISS_ON) + if (RecordStreamSP[RECORD_TIME].getState() == ISS_ON) LOGF_INFO("Starting video record (Duration): %g secs.", RecordOptionsNP[0].getValue()); - else if (RecordStreamSP[RECORD_FRAME].s == ISS_ON) - LOGF_INFO("Starting video record (Frame count): %d.", static_cast(RecordOptionsNP[1].value)); + else if (RecordStreamSP[RECORD_FRAME].getState() == ISS_ON) + LOGF_INFO("Starting video record (Frame count): %d.", static_cast(RecordOptionsNP[1].getValue())); else LOG_INFO("Starting video record."); @@ -851,7 +851,7 @@ bool StreamManagerPrivate::ISNewSwitch(const char * dev, const char * name, ISSt EncoderSP.update(states, names, n); EncoderSP.setState(IPS_ALERT); - const char * selectedEncoder = EncoderSP.findOnSwitch()->name; + const char * selectedEncoder = EncoderSP.findOnSwitch()->getName(); for (EncoderInterface * oneEncoder : encoderManager.getEncoderList()) { @@ -876,7 +876,7 @@ bool StreamManagerPrivate::ISNewSwitch(const char * dev, const char * name, ISSt RecorderSP.update(states, names, n); RecorderSP.setState(IPS_ALERT); - const char * selectedRecorder = RecorderSP.findOnSwitch()->name; + const char * selectedRecorder = RecorderSP.findOnSwitch()->getName(); for (RecorderInterface * oneRecorder : recorderManager.getRecorderList()) { @@ -913,8 +913,8 @@ bool StreamManagerPrivate::ISNewText(const char * dev, const char * name, char * if (RecordFileTP.isNameMatch(name)) { - IText * tp = RecordFileTP.findWidgetByName("RECORD_FILE_NAME"); - if (strchr(tp->text, '/')) + auto tp = RecordFileTP.findWidgetByName("RECORD_FILE_NAME"); + if (strchr(tp->getText(), '/')) { LOG_WARN("Dir. separator (/) not allowed in filename."); return true; @@ -1003,10 +1003,10 @@ bool StreamManagerPrivate::ISNewNumber(const char * dev, const char * name, doub double subW = srcFrameInfo.w - StreamFrameNP[CCDChip::FRAME_X].getValue(); double subH = srcFrameInfo.h - StreamFrameNP[CCDChip::FRAME_Y].getValue(); - StreamFrameNP[CCDChip::FRAME_W].setValue(std::min(StreamFrameNP[CCDChip::FRAME_W].value, subW)); - StreamFrameNP[CCDChip::FRAME_H].setValue(std::min(StreamFrameNP[CCDChip::FRAME_H].value, subH)); + StreamFrameNP[CCDChip::FRAME_W].setValue(std::min(StreamFrameNP[CCDChip::FRAME_W].getValue(), subW)); + StreamFrameNP[CCDChip::FRAME_H].setValue(std::min(StreamFrameNP[CCDChip::FRAME_H].getValue(), subH)); - setSize(StreamFrameNP[CCDChip::FRAME_W].value, StreamFrameNP[CCDChip::FRAME_H].getValue()); + setSize(StreamFrameNP[CCDChip::FRAME_W].getValue(), StreamFrameNP[CCDChip::FRAME_H].getValue()); StreamFrameNP.apply(); return true; diff --git a/libs/indibase/stream/streammanager_p.h b/libs/indibase/stream/streammanager_p.h index bccb023b34..5bcaee2bd7 100644 --- a/libs/indibase/stream/streammanager_p.h +++ b/libs/indibase/stream/streammanager_p.h @@ -201,7 +201,7 @@ class StreamManagerPrivate INDI::PropertyNumber StreamFrameNP {4}; /* BLOBs */ - INDI::PropertyView *imageBP {nullptr}; + INDI::PropertyViewBlob *imageBP {nullptr}; // Encoder Selector. It's static now but should this implemented as plugin interface? INDI::PropertySwitch EncoderSP {2}; diff --git a/libs/indidevice/basedevice.cpp b/libs/indidevice/basedevice.cpp index e1a3f29122..0f844cdbd3 100644 --- a/libs/indidevice/basedevice.cpp +++ b/libs/indidevice/basedevice.cpp @@ -373,7 +373,7 @@ int BaseDevice::buildProp(const INDI::LilXmlElement &root, char *errmsg, bool is INDI::PropertyNumber typedProperty {0}; for (const auto &element : root.getElementsByTagName("defNumber")) { - INDI::WidgetView widget; + INDI::WidgetViewNumber widget; widget.setParent(typedProperty.getNumber()); @@ -399,7 +399,7 @@ int BaseDevice::buildProp(const INDI::LilXmlElement &root, char *errmsg, bool is typedProperty.setRule(root.getAttribute("rule")); for (const auto &element : root.getElementsByTagName("defSwitch")) { - INDI::WidgetView widget; + INDI::WidgetViewSwitch widget; widget.setParent(typedProperty.getSwitch()); @@ -420,7 +420,7 @@ int BaseDevice::buildProp(const INDI::LilXmlElement &root, char *errmsg, bool is INDI::PropertyText typedProperty {0}; for (const auto &element : root.getElementsByTagName("defText")) { - INDI::WidgetView widget; + INDI::WidgetViewText widget; widget.setParent(typedProperty.getText()); @@ -441,7 +441,7 @@ int BaseDevice::buildProp(const INDI::LilXmlElement &root, char *errmsg, bool is INDI::PropertyLight typedProperty {0}; for (const auto &element : root.getElementsByTagName("defLight")) { - INDI::WidgetView widget; + INDI::WidgetViewLight widget; widget.setParent(typedProperty.getLight()); @@ -462,7 +462,7 @@ int BaseDevice::buildProp(const INDI::LilXmlElement &root, char *errmsg, bool is INDI::PropertyBlob typedProperty {0}; for (const auto &element : root.getElementsByTagName("defBLOB")) { - INDI::WidgetView widget; + INDI::WidgetViewBlob widget; widget.setParent(typedProperty.getBLOB()); @@ -695,7 +695,7 @@ int BaseDevice::setValue(const INDI::LilXmlElement &root, char *errmsg) } #ifdef ENABLE_INDI_SHARED_MEMORY -static bool sSharedToBlob(const INDI::LilXmlElement &element, INDI::WidgetView &widget) +static bool sSharedToBlob(const INDI::LilXmlElement &element, INDI::WidgetViewBlob &widget) { auto attachementId = element.getAttribute("attached-data-id"); diff --git a/libs/indidevice/basedevice_p.h b/libs/indidevice/basedevice_p.h index 35a9acede3..d79753f0dc 100644 --- a/libs/indidevice/basedevice_p.h +++ b/libs/indidevice/basedevice_p.h @@ -102,21 +102,21 @@ class BaseDevicePrivate switch (property.getType()) { case INDI_NUMBER: - mediator->newNumber(property.getNumber()); + mediator->newNumber(property.getNumber()->cast()); break; case INDI_SWITCH: - mediator->newSwitch(property.getSwitch()); + mediator->newSwitch(property.getSwitch()->cast()); break; case INDI_TEXT: - mediator->newText(property.getText()); + mediator->newText(property.getText()->cast()); break; case INDI_LIGHT: - mediator->newLight(property.getLight()); + mediator->newLight(property.getLight()->cast()); break; case INDI_BLOB: for (auto &it : PropertyBlob(property)) { - mediator->newBLOB(&it); + mediator->newBLOB(it.cast()); } break; case INDI_UNKNOWN: diff --git a/libs/indidevice/property/indiproperty.cpp b/libs/indidevice/property/indiproperty.cpp index 30168fe841..1b26fe0222 100644 --- a/libs/indidevice/property/indiproperty.cpp +++ b/libs/indidevice/property/indiproperty.cpp @@ -46,31 +46,31 @@ PropertyPrivate::PropertyPrivate(void *property, INDI_PROPERTY_TYPE type) , registered(property != nullptr) { } -PropertyPrivate::PropertyPrivate(ITextVectorProperty *property) +PropertyPrivate::PropertyPrivate(PropertyViewText *property) : property(property) , type(property ? INDI_TEXT : INDI_UNKNOWN) , registered(property != nullptr) { } -PropertyPrivate::PropertyPrivate(INumberVectorProperty *property) +PropertyPrivate::PropertyPrivate(PropertyViewNumber *property) : property(property) , type(property ? INDI_NUMBER : INDI_UNKNOWN) , registered(property != nullptr) { } -PropertyPrivate::PropertyPrivate(ISwitchVectorProperty *property) +PropertyPrivate::PropertyPrivate(PropertyViewSwitch *property) : property(property) , type(property ? INDI_SWITCH : INDI_UNKNOWN) , registered(property != nullptr) { } -PropertyPrivate::PropertyPrivate(ILightVectorProperty *property) +PropertyPrivate::PropertyPrivate(PropertyViewLight *property) : property(property) , type(property ? INDI_LIGHT : INDI_UNKNOWN) , registered(property != nullptr) { } -PropertyPrivate::PropertyPrivate(IBLOBVectorProperty *property) +PropertyPrivate::PropertyPrivate(PropertyViewBlob *property) : property(property) , type(property ? INDI_BLOB : INDI_UNKNOWN) , registered(property != nullptr) @@ -103,11 +103,11 @@ Property::operator const INDI::Property *() const #define PROPERTY_CASE(CODE) \ switch (d->property != nullptr ? d->type : INDI_UNKNOWN) \ { \ - case INDI_NUMBER: { auto property = static_cast *>(d->property); CODE } break; \ - case INDI_TEXT: { auto property = static_cast *>(d->property); CODE } break; \ - case INDI_SWITCH: { auto property = static_cast *>(d->property); CODE } break; \ - case INDI_LIGHT: { auto property = static_cast *>(d->property); CODE } break; \ - case INDI_BLOB: { auto property = static_cast *>(d->property); CODE } break; \ + case INDI_NUMBER: { auto property = static_cast(d->property); CODE } break; \ + case INDI_TEXT: { auto property = static_cast(d->property); CODE } break; \ + case INDI_SWITCH: { auto property = static_cast(d->property); CODE } break; \ + case INDI_LIGHT: { auto property = static_cast(d->property); CODE } break; \ + case INDI_BLOB: { auto property = static_cast(d->property); CODE } break; \ default:; \ } @@ -148,23 +148,23 @@ Property::Property(INDI::PropertyBlob property) #ifdef INDI_PROPERTY_BACKWARD_COMPATIBILE -Property::Property(INDI::PropertyView *property) +Property::Property(INDI::PropertyViewNumber *property) : d_ptr(new PropertyNumberPrivate(property)) { } -Property::Property(INDI::PropertyView *property) +Property::Property(INDI::PropertyViewText *property) : d_ptr(new PropertyTextPrivate(property)) { } -Property::Property(INDI::PropertyView *property) +Property::Property(INDI::PropertyViewSwitch *property) : d_ptr(new PropertySwitchPrivate(property)) { } -Property::Property(INDI::PropertyView *property) +Property::Property(INDI::PropertyViewLight *property) : d_ptr(new PropertyLightPrivate(property)) { } -Property::Property(INDI::PropertyView *property) +Property::Property(INDI::PropertyViewBlob *property) : d_ptr(new PropertyBlobPrivate(property)) { } @@ -431,47 +431,47 @@ bool Property::isLabelMatch(const std::string &otherLabel) const return false; } -PropertyView *Property::getNumber() const +PropertyViewNumber *Property::getNumber() const { D_PTR(const Property); if (d->type == INDI_NUMBER) - return static_cast*>(d->property); + return static_cast(d->property); return nullptr; } -PropertyView *Property::getText() const +PropertyViewText *Property::getText() const { D_PTR(const Property); if (d->type == INDI_TEXT) - return static_cast*>(d->property); + return static_cast(d->property); return nullptr; } -PropertyView *Property::getLight() const +PropertyViewLight *Property::getLight() const { D_PTR(const Property); if (d->type == INDI_LIGHT) - return static_cast*>(d->property); + return static_cast(d->property); return nullptr; } -PropertyView *Property::getSwitch() const +PropertyViewSwitch *Property::getSwitch() const { D_PTR(const Property); if (d->type == INDI_SWITCH) - return static_cast*>(d->property); + return static_cast(d->property); return nullptr; } -PropertyView *Property::getBLOB() const +PropertyViewBlob *Property::getBLOB() const { D_PTR(const Property); if (d->type == INDI_BLOB) - return static_cast*>(d->property); + return static_cast(d->property); return nullptr; } diff --git a/libs/indidevice/property/indiproperty.h b/libs/indidevice/property/indiproperty.h index 8612d3d790..5c75750f7e 100644 --- a/libs/indidevice/property/indiproperty.h +++ b/libs/indidevice/property/indiproperty.h @@ -67,11 +67,11 @@ class Property Property(IBLOBVectorProperty *property); public: - Property(INDI::PropertyView *property); - Property(INDI::PropertyView *property); - Property(INDI::PropertyView *property); - Property(INDI::PropertyView *property); - Property(INDI::PropertyView *property); + Property(INDI::PropertyViewNumber *property); + Property(INDI::PropertyViewText *property); + Property(INDI::PropertyViewSwitch *property); + Property(INDI::PropertyViewLight *property); + Property(INDI::PropertyViewBlob *property); #endif public: @@ -148,11 +148,11 @@ class Property public: #ifdef INDI_PROPERTY_BACKWARD_COMPATIBILE - INDI::PropertyView *getNumber() const; - INDI::PropertyView *getText() const; - INDI::PropertyView *getSwitch() const; - INDI::PropertyView *getLight() const; - INDI::PropertyView *getBLOB() const; + INDI::PropertyViewNumber *getNumber() const; + INDI::PropertyViewText *getText() const; + INDI::PropertyViewSwitch *getSwitch() const; + INDI::PropertyViewLight *getLight() const; + INDI::PropertyViewBlob *getBLOB() const; #endif public: @@ -163,14 +163,14 @@ class Property operator INDI::Property *(); operator const INDI::Property *() const; - operator INDI::PropertyView *() const { return getNumber(); } - operator INDI::PropertyView *() const { return getText(); } - operator INDI::PropertyView *() const { return getSwitch(); } - operator INDI::PropertyView *() const { return getLight(); } - operator INDI::PropertyView *() const { return getBLOB(); } - bool operator != (std::nullptr_t) const { return isValid(); } - bool operator == (std::nullptr_t) const { return !isValid(); } - operator bool() const { return isValid(); } + operator INDI::PropertyViewNumber *() const { return getNumber(); } + operator INDI::PropertyViewText *() const { return getText(); } + operator INDI::PropertyViewSwitch *() const { return getSwitch(); } + operator INDI::PropertyViewLight *() const { return getLight(); } + operator INDI::PropertyViewBlob *() const { return getBLOB(); } + bool operator != (std::nullptr_t) const { return isValid(); } + bool operator == (std::nullptr_t) const { return !isValid(); } + operator bool() const { return isValid(); } #endif protected: diff --git a/libs/indidevice/property/indiproperty_p.h b/libs/indidevice/property/indiproperty_p.h index 65024c897f..e4324d849e 100644 --- a/libs/indidevice/property/indiproperty_p.h +++ b/libs/indidevice/property/indiproperty_p.h @@ -53,11 +53,11 @@ class PropertyPrivate std::function onUpdateCallback; PropertyPrivate(void *property, INDI_PROPERTY_TYPE type); - PropertyPrivate(ITextVectorProperty *property); - PropertyPrivate(INumberVectorProperty *property); - PropertyPrivate(ISwitchVectorProperty *property); - PropertyPrivate(ILightVectorProperty *property); - PropertyPrivate(IBLOBVectorProperty *property); + PropertyPrivate(PropertyViewText *property); + PropertyPrivate(PropertyViewNumber *property); + PropertyPrivate(PropertyViewSwitch *property); + PropertyPrivate(PropertyViewLight *property); + PropertyPrivate(PropertyViewBlob *property); virtual ~PropertyPrivate(); diff --git a/libs/indidevice/property/indipropertybasic.cpp b/libs/indidevice/property/indipropertybasic.cpp index d86ccb9064..b7488d2066 100644 --- a/libs/indidevice/property/indipropertybasic.cpp +++ b/libs/indidevice/property/indipropertybasic.cpp @@ -40,8 +40,8 @@ PropertyBasicPrivateTemplate::PropertyBasicPrivateTemplate(size_t count) #ifdef INDI_PROPERTY_RAW_CAST template PropertyBasicPrivateTemplate::PropertyBasicPrivateTemplate(RawPropertyType *rawProperty) - : PropertyContainer{*static_cast*>(rawProperty)} - , PropertyPrivate(rawProperty) + : PropertyContainer{*PropertyView::cast(rawProperty)} + , PropertyPrivate(PropertyView::cast(rawProperty)) , raw{true} { } #endif diff --git a/libs/indidevice/property/indipropertybasic.h b/libs/indidevice/property/indipropertybasic.h index 9ede3dce97..2829d2cb8d 100644 --- a/libs/indidevice/property/indipropertybasic.h +++ b/libs/indidevice/property/indipropertybasic.h @@ -25,11 +25,11 @@ namespace INDI { -using WidgetText = INDI::WidgetView; -using WidgetNumber = INDI::WidgetView; -using WidgetSwitch = INDI::WidgetView; -using WidgetLight = INDI::WidgetView; -using WidgetBlob = INDI::WidgetView; +using WidgetText = INDI::WidgetViewText; +using WidgetNumber = INDI::WidgetViewNumber; +using WidgetSwitch = INDI::WidgetViewSwitch; +using WidgetLight = INDI::WidgetViewLight; +using WidgetBlob = INDI::WidgetViewBlob; template class PropertyBasicPrivateTemplate; diff --git a/libs/indidevice/property/indipropertyswitch.cpp b/libs/indidevice/property/indipropertyswitch.cpp index df55b8c96e..f4e2a9c863 100644 --- a/libs/indidevice/property/indipropertyswitch.cpp +++ b/libs/indidevice/property/indipropertyswitch.cpp @@ -52,7 +52,7 @@ int PropertySwitch::findOnSwitchIndex() const return d->typedProperty.findOnSwitchIndex(); } -INDI::WidgetView *PropertySwitch::findOnSwitch() const +INDI::WidgetViewSwitch *PropertySwitch::findOnSwitch() const { D_PTR(const PropertySwitch); return d->typedProperty.findOnSwitch(); diff --git a/libs/indidevice/property/indipropertyswitch.h b/libs/indidevice/property/indipropertyswitch.h index 7c79a0479a..96e03900b8 100644 --- a/libs/indidevice/property/indipropertyswitch.h +++ b/libs/indidevice/property/indipropertyswitch.h @@ -58,7 +58,7 @@ class PropertySwitch: public INDI::PropertyBasic public: void reset(); int findOnSwitchIndex() const; - INDI::WidgetView *findOnSwitch() const; + INDI::WidgetViewSwitch *findOnSwitch() const; public: void setRule(ISRule rule); diff --git a/libs/indidevice/property/indipropertyview.h b/libs/indidevice/property/indipropertyview.h index 6fb1b82163..517767a7d6 100644 --- a/libs/indidevice/property/indipropertyview.h +++ b/libs/indidevice/property/indipropertyview.h @@ -35,6 +35,18 @@ namespace INDI template struct WidgetView; template struct PropertyView; +typedef PropertyView PropertyViewText; +typedef PropertyView PropertyViewNumber; +typedef PropertyView PropertyViewSwitch; +typedef PropertyView PropertyViewLight; +typedef PropertyView PropertyViewBlob; + +typedef WidgetView WidgetViewText; +typedef WidgetView WidgetViewNumber; +typedef WidgetView WidgetViewSwitch; +typedef WidgetView WidgetViewLight; +typedef WidgetView WidgetViewBlob; + #define PROPERTYVIEW_BASE_ACCESS public // don't use direct access to low-level property //#define PROPERTYVIEW_BASE_ACCESS protected // future @@ -46,22 +58,22 @@ template struct PropertyView; * INDI::PropertyView * * A class that will allow a easy transition to the new widget handling interface (future). - * - Use PropertyView instead of ITextVectorProperty - * - Use PropertyView instead of INumberVectorProperty - * - Use PropertyView instead of ISwitchVectorProperty - * - Use PropertyView instead of ILightVectorProperty - * - Use PropertyView instead of IBLOBVectorProperty + * - Use PropertyViewText instead of ITextVectorProperty + * - Use PropertyViewNumber instead of INumberVectorProperty + * - Use PropertyViewSwitch instead of ISwitchVectorProperty + * - Use PropertyViewLight instead of ILightVectorProperty + * - Use PropertyViewBlob instead of IBLOBVectorProperty * * The PropertyView class is compatible with low-level IXXXVectorProperty structures. * * INDI::WidgetView * * A class that will allow a easy transition to the new widget handling interface (future). - * - Use WidgetView instead of IText - * - Use WidgetView instead of INumber - * - Use WidgetView instead of ISwitch - * - Use WidgetView instead of ILight - * - Use WidgetView instead of IBLOB + * - Use WidgetViewText instead of IText + * - Use WidgetViewNumber instead of INumber + * - Use WidgetViewSwitch instead of ISwitch + * - Use WidgetViewLight instead of ILight + * - Use WidgetViewBlob instead of IBLOB * * The WidgetView class is compatible with low-level IXXX structures. */ @@ -320,6 +332,15 @@ struct PropertyView: PROPERTYVIEW_BASE_ACCESS WidgetTraits::PropertyType //free(widget()); // #PS: do not delete items, they may be on the stack. memset(this, 0, sizeof(*this)); } + public: // internal use only + static PropertyView *cast(PropertyType *raw) + { + return static_cast*>(raw); + } + PropertyType *cast() + { + return this; + } }; template @@ -1037,6 +1058,16 @@ struct WidgetView: PROPERTYVIEW_BASE_ACCESS IBLOB { fill(name.c_str(), label.c_str(), format.c_str()); } + + public: // internal use only + static WidgetView *cast(Type *blob) + { + return static_cast*>(blob); + } + Type *cast() + { + return this; + } }; diff --git a/test/core/test_property_class.cpp b/test/core/test_property_class.cpp index e29a57e228..54d342514f 100644 --- a/test/core/test_property_class.cpp +++ b/test/core/test_property_class.cpp @@ -33,6 +33,8 @@ #include "indipropertylight.h" #include "indipropertyblob.h" +#include + TEST(CORE_PROPERTY_CLASS, Test_EmptyProperty) { INDI::Property p; @@ -63,16 +65,18 @@ TEST(CORE_PROPERTY_CLASS, Test_PropertySetters) { INDI::Property p; - INumberVectorProperty nvp - { - "device field", - "name field", - "label field", - "group field", - IP_RW, 42, IPS_BUSY, - nullptr, 0, - "timestamp field", - nullptr }; + INDI::PropertyViewNumber nvp; + nvp.setDeviceName("device field"); + nvp.setName("name field"); + nvp.setLabel("label field"); + nvp.setGroupName("group field"); + nvp.setPermission(IP_RW); + nvp.setState(IPS_BUSY); + nvp.setTimestamp("timestamp field"); + nvp.setAux(nullptr); + nvp.setWidgets(nullptr, 0); + nvp.setTimeout(42); + // Setting a property makes it registered but NOT meaningful p.setProperty(&nvp); diff --git a/test/drivers/test_ccd_simulator.cpp b/test/drivers/test_ccd_simulator.cpp index 7dca88a010..04bd66a1b6 100644 --- a/test/drivers/test_ccd_simulator.cpp +++ b/test/drivers/test_ccd_simulator.cpp @@ -22,20 +22,20 @@ class MockCCDSimDriver: public CCDSim void testProperties() { - INumberVectorProperty * const p = getNumber("SIMULATOR_SETTINGS"); + auto p = getNumber("SIMULATOR_SETTINGS"); ASSERT_NE(p, nullptr); - ASSERT_NE(IUFindNumber(p, "SIM_XRES"), nullptr); - ASSERT_NE(IUFindNumber(p, "SIM_YRES"), nullptr); - ASSERT_NE(IUFindNumber(p, "SIM_XSIZE"), nullptr); - ASSERT_NE(IUFindNumber(p, "SIM_YSIZE"), nullptr); - ASSERT_NE(IUFindNumber(p, "SIM_MAXVAL"), nullptr); - ASSERT_NE(IUFindNumber(p, "SIM_SATURATION"), nullptr); - ASSERT_NE(IUFindNumber(p, "SIM_LIMITINGMAG"), nullptr); - ASSERT_NE(IUFindNumber(p, "SIM_NOISE"), nullptr); - ASSERT_NE(IUFindNumber(p, "SIM_SKYGLOW"), nullptr); - ASSERT_NE(IUFindNumber(p, "SIM_OAGOFFSET"), nullptr); - ASSERT_NE(IUFindNumber(p, "SIM_POLAR"), nullptr); - ASSERT_NE(IUFindNumber(p, "SIM_POLARDRIFT"), nullptr); + ASSERT_NE(p.findWidgetByName("SIM_XRES"), nullptr); + ASSERT_NE(p.findWidgetByName("SIM_YRES"), nullptr); + ASSERT_NE(p.findWidgetByName("SIM_XSIZE"), nullptr); + ASSERT_NE(p.findWidgetByName("SIM_YSIZE"), nullptr); + ASSERT_NE(p.findWidgetByName("SIM_MAXVAL"), nullptr); + ASSERT_NE(p.findWidgetByName("SIM_SATURATION"), nullptr); + ASSERT_NE(p.findWidgetByName("SIM_LIMITINGMAG"), nullptr); + ASSERT_NE(p.findWidgetByName("SIM_NOISE"), nullptr); + ASSERT_NE(p.findWidgetByName("SIM_SKYGLOW"), nullptr); + ASSERT_NE(p.findWidgetByName("SIM_OAGOFFSET"), nullptr); + ASSERT_NE(p.findWidgetByName("SIM_POLAR"), nullptr); + ASSERT_NE(p.findWidgetByName("SIM_POLARDRIFT"), nullptr); } void testGuideAPI() @@ -88,22 +88,22 @@ class MockCCDSimDriver: public CCDSim int const maxval = pow(2, 8) - 1; // Setup a 65x65, 16-bit depth, 4.6u square pixel sensor - INumberVectorProperty * const p = getNumber("SIMULATOR_SETTINGS"); + auto p = getNumber("SIMULATOR_SETTINGS"); ASSERT_NE(p, nullptr); - IUFindNumber(p, "SIM_XRES")->value = (double) xres; - IUFindNumber(p, "SIM_YRES")->value = (double) yres; + p.findWidgetByName("SIM_XRES")->setValue((double) xres); + p.findWidgetByName("SIM_YRES")->setValue((double) yres); // There is no way to set depth, it is hardcoded at 16-bit - so set maximum value instead - IUFindNumber(p, "SIM_MAXVAL")->value = (double) maxval; - IUFindNumber(p, "SIM_XSIZE")->value = 4.6; - IUFindNumber(p, "SIM_YSIZE")->value = 4.6; + p.findWidgetByName("SIM_MAXVAL")->setValue((double) maxval); + p.findWidgetByName("SIM_XSIZE")->setValue(4.6); + p.findWidgetByName("SIM_YSIZE")->setValue(4.6); // Setup a saturation magnitude (max ADUs in one second) and limit magnitude (zero ADU whatever the exposure) - IUFindNumber(p, "SIM_SATURATION")->value = 0.0; - IUFindNumber(p, "SIM_LIMITINGMAG")->value = 30.0; + p.findWidgetByName("SIM_SATURATION")->setValue(0.0); + p.findWidgetByName("SIM_LIMITINGMAG")->setValue(30.0); // Setup some parameters to simplify verifications - IUFindNumber(p, "SIM_SKYGLOW")->value = 0.0; - IUFindNumber(p, "SIM_NOISE")->value = 0.0; + p.findWidgetByName("SIM_SKYGLOW")->setValue(0.0); + p.findWidgetByName("SIM_NOISE")->setValue(0.0); this->seeing = 1.0f; // No way to control seeing from properties // Setup