From b39b427ebcbe14958b74423472fafa3ba161af63 Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Mon, 2 Sep 2024 16:25:32 +0300 Subject: [PATCH 01/23] Migrate Temperature Property --- drivers/ccd/ccd_simulator.cpp | 22 ++++++------ drivers/ccd/guide_simulator.cpp | 22 ++++++------ examples/tutorial_three/simpleccd.cpp | 12 +++---- libs/indibase/indiccd.cpp | 50 +++++++++++++-------------- libs/indibase/indiccd.h | 3 +- 5 files changed, 54 insertions(+), 55 deletions(-) diff --git a/drivers/ccd/ccd_simulator.cpp b/drivers/ccd/ccd_simulator.cpp index fc90411258..aa4548046d 100644 --- a/drivers/ccd/ccd_simulator.cpp +++ b/drivers/ccd/ccd_simulator.cpp @@ -321,9 +321,9 @@ bool CCDSim::updateProperties() int CCDSim::SetTemperature(double temperature) { TemperatureRequest = temperature; - if (fabs(temperature - TemperatureN[0].value) < 0.1) + if (fabs(temperature - TemperatureNP[0].getValue()) < 0.1) { - TemperatureN[0].value = temperature; + TemperatureNP[0].setValue(temperature); return 1; } @@ -492,21 +492,21 @@ void CCDSim::TimerHit() } } - if (TemperatureNP.s == IPS_BUSY) + if (TemperatureNP.getState() == IPS_BUSY) { - if (TemperatureRequest < TemperatureN[0].value) - TemperatureN[0].value = std::max(TemperatureRequest, TemperatureN[0].value - 0.5); + if (TemperatureRequest < TemperatureNP[0].getValue()) + TemperatureNP[0].setValue(std::max(TemperatureRequest, TemperatureNP[0].getValue() - 0.5)); else - TemperatureN[0].value = std::min(TemperatureRequest, TemperatureN[0].value + 0.5); + TemperatureNP[0].setValue(std::min(TemperatureRequest, TemperatureNP[0].getValue() + 0.5)); - if (std::abs(TemperatureN[0].value - m_LastTemperature) > 0.1) + if (std::abs(TemperatureNP[0].getValue() - m_LastTemperature) > 0.1) { - m_LastTemperature = TemperatureN[0].value; - IDSetNumber(&TemperatureNP, nullptr); + m_LastTemperature = TemperatureNP[0].getValue(); + TemperatureNP.apply(); } // Above 20, cooler is off - if (TemperatureN[0].value >= 20) + if (TemperatureNP[0].getValue() >= 20) { CoolerSP[INDI_ENABLED].setState(ISS_OFF); CoolerSP[INDI_DISABLED].setState(ISS_ON); @@ -1183,7 +1183,7 @@ bool CCDSim::ISNewSwitch(const char * dev, const char * name, ISState * states, { CoolerSP.setState(IPS_IDLE); m_TargetTemperature = 20; - TemperatureNP.s = IPS_BUSY; + TemperatureNP.setState(IPS_BUSY); m_TemperatureCheckTimer.start(); m_TemperatureElapsedTimer.start(); } diff --git a/drivers/ccd/guide_simulator.cpp b/drivers/ccd/guide_simulator.cpp index 0b8ca22877..642e19e75f 100644 --- a/drivers/ccd/guide_simulator.cpp +++ b/drivers/ccd/guide_simulator.cpp @@ -54,8 +54,8 @@ bool GuideSim::SetupParms() if (HasCooler()) { - TemperatureN[0].value = 20; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP[0].setValue(20); + TemperatureNP.apply(); } // Kwiq @@ -256,9 +256,9 @@ bool GuideSim::updateProperties() int GuideSim::SetTemperature(double temperature) { TemperatureRequest = temperature; - if (fabs(temperature - TemperatureN[0].value) < 0.1) + if (fabs(temperature - TemperatureNP[0].getValue()) < 0.1) { - TemperatureN[0].value = temperature; + TemperatureNP[0].setValue(temperature); return 1; } @@ -358,18 +358,18 @@ void GuideSim::TimerHit() } } - if (TemperatureNP.s == IPS_BUSY) + if (TemperatureNP.getState() == IPS_BUSY) { - if (TemperatureRequest < TemperatureN[0].value) - TemperatureN[0].value = std::max(TemperatureRequest, TemperatureN[0].value - 0.5); + if (TemperatureRequest < TemperatureNP[0].getValue()) + TemperatureNP[0].setValue(std::max(TemperatureRequest, TemperatureNP[0].getValue() - 0.5)); else - TemperatureN[0].value = std::min(TemperatureRequest, TemperatureN[0].value + 0.5); + TemperatureNP[0].setValue(std::min(TemperatureRequest, TemperatureNP[0].getValue() + 0.5)); - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.apply(); // Above 20, cooler is off - if (TemperatureN[0].value >= 20) + if (TemperatureNP[0].getValue() >= 20) { CoolerSP[COOLER_ON].setState(ISS_OFF); CoolerSP[COOLER_OFF].setState(ISS_ON); @@ -1085,7 +1085,7 @@ bool GuideSim::ISNewSwitch(const char * dev, const char * name, ISState * states { CoolerSP.setState(IPS_IDLE); TemperatureRequest = 20; - TemperatureNP.s = IPS_BUSY; + TemperatureNP.setState(IPS_BUSY); } CoolerSP.apply(); diff --git a/examples/tutorial_three/simpleccd.cpp b/examples/tutorial_three/simpleccd.cpp index fcbf0eb3cf..f4b8ae28a6 100644 --- a/examples/tutorial_three/simpleccd.cpp +++ b/examples/tutorial_three/simpleccd.cpp @@ -25,7 +25,7 @@ #include /* Macro shortcut to CCD temperature value */ -#define currentCCDTemperature TemperatureN[0].value +#define currentCCDTemperature TemperatureNP[0].value std::unique_ptr simpleCCD(new SimpleCCD()); @@ -191,7 +191,7 @@ void SimpleCCD::TimerHit() } // TemperatureNP is defined in INDI::CCD - switch (TemperatureNP.s) + switch (TemperatureNP.getState()) { case IPS_IDLE: case IPS_OK: @@ -207,13 +207,13 @@ void SimpleCCD::TimerHit() /* If they're equal, stop updating */ else { - TemperatureNP.s = IPS_OK; - IDSetNumber(&TemperatureNP, "Target temperature reached."); - + TemperatureNP.setState(IPS_OK); + LOG_WARN("Target temperature reached."); + TemperatureNP.apply(); break; } - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.apply(); break; diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index 1fda59b755..61c6becd74 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -155,8 +155,8 @@ bool CCD::initProperties() DefaultDevice::initProperties(); // CCD Temperature - IUFillNumber(&TemperatureN[0], "CCD_TEMPERATURE_VALUE", "Temperature (C)", "%5.2f", -50.0, 50.0, 0., 0.); - IUFillNumberVector(&TemperatureNP, TemperatureN, 1, getDeviceName(), "CCD_TEMPERATURE", "Temperature", + TemperatureNP[0].fill("CCD_TEMPERATURE_VALUE", "Temperature (C)", "%5.2f", -50.0, 50.0, 0., 0.); + TemperatureNP.fill(getDeviceName(), "CCD_TEMPERATURE", "Temperature", MAIN_CONTROL_TAB, IP_RW, 60, IPS_IDLE); // Camera temperature ramp @@ -558,7 +558,7 @@ bool CCD::updateProperties() if (HasCooler()) { - defineProperty(&TemperatureNP); + defineProperty(TemperatureNP); defineProperty(TemperatureRampNP); } @@ -681,7 +681,7 @@ bool CCD::updateProperties() } if (HasCooler()) { - deleteProperty(TemperatureNP.name); + deleteProperty(TemperatureNP); deleteProperty(TemperatureRampNP.getName()); } if (HasST4Port()) @@ -1333,14 +1333,14 @@ bool CCD::ISNewNumber(const char * dev, const char * name, double values[], char } // CCD TEMPERATURE - if (!strcmp(name, TemperatureNP.name)) + if (TemperatureNP.isNameMatch(name)) { - if (values[0] < TemperatureN[0].min || values[0] > TemperatureN[0].max) + if (values[0] < TemperatureNP[0].getMin() || values[0] > TemperatureNP[0].getMax()) { - TemperatureNP.s = IPS_ALERT; + TemperatureNP.setState(IPS_ALERT); LOGF_ERROR("Error: Bad temperature value! Range is [%.1f, %.1f] [C].", - TemperatureN[0].min, TemperatureN[0].max); - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP[0].getMin(), TemperatureNP[0].getMax()); + TemperatureNP.apply(); return false; } @@ -1348,14 +1348,14 @@ bool CCD::ISNewNumber(const char * dev, const char * name, double values[], char // If temperature ramp is enabled, find if (TemperatureRampNP[RAMP_SLOPE].getValue() != 0) { - if (values[0] < TemperatureN[0].value) + if (values[0] < TemperatureNP[0].getValue()) { - nextTemperature = std::max(values[0], TemperatureN[0].value - TemperatureRampNP[RAMP_SLOPE].getValue()); + nextTemperature = std::max(values[0], TemperatureNP[0].getValue() - TemperatureRampNP[RAMP_SLOPE].getValue()); } // Going up else { - nextTemperature = std::min(values[0], TemperatureN[0].value + TemperatureRampNP[RAMP_SLOPE].getValue()); + nextTemperature = std::min(values[0], TemperatureNP[0].getValue() + TemperatureRampNP[RAMP_SLOPE].getValue()); } } @@ -1368,14 +1368,14 @@ bool CCD::ISNewNumber(const char * dev, const char * name, double values[], char m_TargetTemperature = values[0]; m_TemperatureCheckTimer.start(); - TemperatureNP.s = IPS_BUSY; + TemperatureNP.setState(IPS_BUSY); } else if (rc == 1) - TemperatureNP.s = IPS_OK; + TemperatureNP.setState(IPS_OK); else - TemperatureNP.s = IPS_ALERT; + TemperatureNP.setState(IPS_ALERT); - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.apply(); return true; } @@ -1992,8 +1992,8 @@ void CCD::addFITSKeywords(CCDChip * targetChip, std::vector &fitsKey fitsKeywords.push_back({"DARKTIME", exposureDuration, 6, "Total Dark Exposure Time (s)"}); // If the camera has a cooler OR if the temperature permission was explicitly set to Read-Only, then record the temperature - if (HasCooler() || TemperatureNP.p == IP_RO) - fitsKeywords.push_back({"CCD-TEMP", TemperatureN[0].value, 3, "CCD Temperature (Celsius)"}); + if (HasCooler() || TemperatureNP.getPermission() == IP_RO) + fitsKeywords.push_back({"CCD-TEMP", TemperatureNP[0].getValue(), 3, "CCD Temperature (Celsius)"}); fitsKeywords.push_back({"PIXSIZE1", subPixSize1, 6, "Pixel Size 1 (microns)"}); fitsKeywords.push_back({"PIXSIZE2", subPixSize2, 6, "Pixel Size 2 (microns)"}); @@ -3024,27 +3024,27 @@ void CCD::wsThreadEntry() ///////////////////////////////////////////////////////////////////////////////////////// void CCD::checkTemperatureTarget() { - if (TemperatureNP.s == IPS_BUSY) + if (TemperatureNP.getState() == IPS_BUSY) { - if (std::abs(m_TargetTemperature - TemperatureN[0].value) <= TemperatureRampNP[RAMP_THRESHOLD].getValue()) + if (std::abs(m_TargetTemperature - TemperatureNP[0].getValue()) <= TemperatureRampNP[RAMP_THRESHOLD].getValue()) { - TemperatureNP.s = IPS_OK; + TemperatureNP.setState(IPS_OK); m_TemperatureCheckTimer.stop(); - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.apply(); } // If we are beyond a minute, check for next step else if (TemperatureRampNP[RAMP_SLOPE].getValue() > 0 && m_TemperatureElapsedTimer.elapsed() >= 60000) { double nextTemperature = 0; // Going down - if (m_TargetTemperature < TemperatureN[0].value) + if (m_TargetTemperature < TemperatureNP[0].getValue()) { - nextTemperature = std::max(m_TargetTemperature, TemperatureN[0].value - TemperatureRampNP[RAMP_SLOPE].getValue()); + nextTemperature = std::max(m_TargetTemperature, TemperatureNP[0].getValue() - TemperatureRampNP[RAMP_SLOPE].getValue()); } // Going up else { - nextTemperature = std::min(m_TargetTemperature, TemperatureN[0].value + TemperatureRampNP[RAMP_SLOPE].getValue()); + nextTemperature = std::min(m_TargetTemperature, TemperatureNP[0].getValue() + TemperatureRampNP[RAMP_SLOPE].getValue()); } m_TemperatureElapsedTimer.restart(); diff --git a/libs/indibase/indiccd.h b/libs/indibase/indiccd.h index ee5373469d..31baa3a0a7 100644 --- a/libs/indibase/indiccd.h +++ b/libs/indibase/indiccd.h @@ -671,8 +671,7 @@ class CCD : public DefaultDevice, GuiderInterface /** * @brief TemperatureNP Camera Temperature in Celcius. */ - INumberVectorProperty TemperatureNP; - INumber TemperatureN[1]; + INDI::PropertyNumber TemperatureNP {1}; /** * @brief Temperature Ramp in C/Min with configurable threshold From 6da8294b7d0900644198c4a1112f16ef156e536a Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Mon, 2 Sep 2024 16:51:23 +0300 Subject: [PATCH 02/23] Migrate Bayer Property --- drivers/ccd/ccd_simulator.cpp | 12 ++++++------ drivers/ccd/guide_simulator.cpp | 6 +++--- libs/indibase/indiccd.cpp | 30 +++++++++++++++--------------- libs/indibase/indiccd.h | 10 +++++++--- 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/drivers/ccd/ccd_simulator.cpp b/drivers/ccd/ccd_simulator.cpp index aa4548046d..598d1b13c9 100644 --- a/drivers/ccd/ccd_simulator.cpp +++ b/drivers/ccd/ccd_simulator.cpp @@ -253,9 +253,9 @@ void CCDSim::setBayerEnabled(bool onOff) if (onOff) { SetCCDCapability(GetCCDCapability() | CCD_HAS_BAYER); - IUSaveText(&BayerT[0], "0"); - IUSaveText(&BayerT[1], "0"); - IUSaveText(&BayerT[2], "RGGB"); + BayerTP[CFA_OFFSET_X].setText("0"); + BayerTP[CFA_OFFSET_Y].setText("0"); + BayerTP[CFA_TYPE].setText("RGGB"); } else { @@ -1601,9 +1601,9 @@ bool CCDSim::loadNextImage() if (channels == 1 && strlen(bayer_pattern) == 4) { SetCCDCapability(GetCCDCapability() | CCD_HAS_BAYER); - IUSaveText(&BayerT[0], "0"); - IUSaveText(&BayerT[1], "0"); - IUSaveText(&BayerT[2], bayer_pattern); + BayerTP[CFA_OFFSET_X].setText("0"); + BayerTP[CFA_OFFSET_Y].setText("0"); + BayerTP[CFA_TYPE].setText(bayer_pattern); } else { diff --git a/drivers/ccd/guide_simulator.cpp b/drivers/ccd/guide_simulator.cpp index 642e19e75f..78476f5575 100644 --- a/drivers/ccd/guide_simulator.cpp +++ b/drivers/ccd/guide_simulator.cpp @@ -203,9 +203,9 @@ void GuideSim::setRGB(bool onOff) if (onOff) { SetCCDCapability(GetCCDCapability() | CCD_HAS_BAYER); - IUSaveText(&BayerT[0], "0"); - IUSaveText(&BayerT[1], "0"); - IUSaveText(&BayerT[2], "RGGB"); + BayerTP[CFA_OFFSET_X].setText("0"); + BayerTP[CFA_OFFSET_Y].setText("0"); + BayerTP[CFA_TYPE].setText("RGGB"); } else { diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index 61c6becd74..f6f4d35de7 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -227,10 +227,10 @@ bool CCD::initProperties() IP_RO, 60, IPS_IDLE); // Bayer - IUFillText(&BayerT[0], "CFA_OFFSET_X", "X Offset", "0"); - IUFillText(&BayerT[1], "CFA_OFFSET_Y", "Y Offset", "0"); - IUFillText(&BayerT[2], "CFA_TYPE", "Filter", nullptr); - IUFillTextVector(&BayerTP, BayerT, 3, getDeviceName(), "CCD_CFA", "Bayer Info", IMAGE_INFO_TAB, IP_RW, 60, + BayerTP[CFA_OFFSET_X].fill("CFA_OFFSET_X", "X Offset", "0"); + BayerTP[CFA_OFFSET_Y].fill("CFA_OFFSET_Y", "Y Offset", "0"); + BayerTP[CFA_TYPE].fill("CFA_TYPE", "Filter", nullptr); + BayerTP.fill(getDeviceName(), "CCD_CFA", "Bayer Info", IMAGE_INFO_TAB, IP_RW, 60, IPS_IDLE); // Reset Frame Settings @@ -589,7 +589,7 @@ bool CCD::updateProperties() defineProperty(&GuideCCD.FrameTypeSP); if (HasBayer()) - defineProperty(&BayerTP); + defineProperty(BayerTP); #if 0 defineProperty(&PrimaryCCD.RapidGuideSP); @@ -690,7 +690,7 @@ bool CCD::updateProperties() } deleteProperty(PrimaryCCD.FrameTypeSP.name); if (HasBayer()) - deleteProperty(BayerTP.name); + deleteProperty(BayerTP); deleteProperty(ScopeInfoNP); if (WorldCoordS[0].s == ISS_ON) @@ -968,11 +968,11 @@ bool CCD::ISNewText(const char * dev, const char * name, char * texts[], char * return true; } - if (!strcmp(name, BayerTP.name)) + if (BayerTP.isNameMatch(name)) { - IUUpdateText(&BayerTP, texts, names, n); - BayerTP.s = IPS_OK; - IDSetText(&BayerTP, nullptr); + BayerTP.update(texts, names, n); + BayerTP.setState(IPS_OK); + BayerTP.apply(); return true; } @@ -2043,9 +2043,9 @@ void CCD::addFITSKeywords(CCDChip * targetChip, std::vector &fitsKey if (HasBayer() && targetChip->getNAxis() == 2) { - fitsKeywords.push_back({"XBAYROFF", atoi(BayerT[0].text), "X offset of Bayer array"}); - fitsKeywords.push_back({"YBAYROFF", atoi(BayerT[1].text), "Y offset of Bayer array"}); - fitsKeywords.push_back({"BAYERPAT", BayerT[2].text, "Bayer color pattern"}); + fitsKeywords.push_back({"XBAYROFF", atoi(BayerTP[CFA_OFFSET_X].getText()), "X offset of Bayer array"}); + fitsKeywords.push_back({"YBAYROFF", atoi(BayerTP[CFA_OFFSET_Y].getText()), "Y offset of Bayer array"}); + fitsKeywords.push_back({"BAYERPAT", BayerTP[CFA_TYPE].getText(), "Bayer color pattern"}); } if (!std::isnan(effectiveFocalLength)) @@ -2476,7 +2476,7 @@ bool CCD::ExposureCompletePrivate(CCDChip * targetChip) } if (HasBayer()) - image.setColorFilterArray({2, 2, BayerT[2].text}); + image.setColorFilterArray({2, 2, BayerTP[2].getText()}); if (targetChip->getNAxis() == 3) { @@ -2813,7 +2813,7 @@ bool CCD::saveConfigItems(FILE * fp) IUSaveConfigNumber(fp, &PrimaryCCD.ImageBinNP); if (HasBayer()) - IUSaveConfigText(fp, &BayerTP); + BayerTP.save(fp); if (HasStreaming()) Streamer->saveConfigItems(fp); diff --git a/libs/indibase/indiccd.h b/libs/indibase/indiccd.h index 31baa3a0a7..37595e96c4 100644 --- a/libs/indibase/indiccd.h +++ b/libs/indibase/indiccd.h @@ -686,9 +686,13 @@ class CCD : public DefaultDevice, GuiderInterface /** *@brief BayerTP Bayer pattern offset and type */ - ITextVectorProperty BayerTP; - IText BayerT[3] {}; - + INDI::PropertyText BayerTP {3}; + enum + { + CFA_OFFSET_X, + CFA_OFFSET_Y, + CFA_TYPE + }; /** *@brief FileNameTP File name of locally-saved images. By default, images are uploaded to the client * but when upload option is set to either @a Both or @a Local, then they are saved on the local disk with From 9df5ff886efca0cb838ab485585fb6990bbb6423 Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Mon, 2 Sep 2024 17:15:13 +0300 Subject: [PATCH 03/23] Migrate WorldCoordSP Property --- libs/indibase/indiccd.cpp | 24 ++++++++++++------------ libs/indibase/indiccd.h | 9 ++++++--- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index f6f4d35de7..f9a2241692 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -344,9 +344,9 @@ bool CCD::initProperties() /**********************************************/ // WCS Enable/Disable - IUFillSwitch(&WorldCoordS[0], "WCS_ENABLE", "Enable", ISS_OFF); - IUFillSwitch(&WorldCoordS[1], "WCS_DISABLE", "Disable", ISS_ON); - IUFillSwitchVector(&WorldCoordSP, WorldCoordS, 2, getDeviceName(), "WCS_CONTROL", "WCS", WCS_TAB, IP_RW, + WorldCoordSP[WCS_ENABLE].fill("WCS_ENABLE", "Enable", ISS_OFF); + WorldCoordSP[WCS_DISABLE].fill("WCS_DISABLE", "Disable", ISS_ON); + WorldCoordSP.fill(getDeviceName(), "WCS_CONTROL", "WCS", WCS_TAB, IP_RW, ISR_1OFMANY, 0, IPS_IDLE); IUFillNumber(&CCDRotationN[0], "CCD_ROTATION_VALUE", "Rotation", "%g", -360, 360, 1, 0); @@ -610,7 +610,7 @@ bool CCD::updateProperties() #endif defineProperty(ScopeInfoNP); - defineProperty(&WorldCoordSP); + defineProperty(WorldCoordSP); defineProperty(&UploadSP); if (UploadSettingsT[UPLOAD_DIR].text == nullptr) @@ -693,11 +693,11 @@ bool CCD::updateProperties() deleteProperty(BayerTP); deleteProperty(ScopeInfoNP); - if (WorldCoordS[0].s == ISS_ON) + if (WorldCoordSP[WCS_ENABLE].getState() == ISS_ON) { deleteProperty(CCDRotationNP.name); } - deleteProperty(WorldCoordSP.name); + deleteProperty(WorldCoordSP); deleteProperty(UploadSP.name); deleteProperty(UploadSettingsTP.name); @@ -1553,12 +1553,12 @@ bool CCD::ISNewSwitch(const char * dev, const char * name, ISState * states, cha #endif // WCS Enable/Disable - if (!strcmp(name, WorldCoordSP.name)) + if (WorldCoordSP.isNameMatch(name)) { - IUUpdateSwitch(&WorldCoordSP, states, names, n); - WorldCoordSP.s = IPS_OK; + WorldCoordSP.update(states, names, n); + WorldCoordSP.setState(IPS_OK); - if (WorldCoordS[0].s == ISS_ON) + if (WorldCoordSP[0].getState() == ISS_ON) { LOG_INFO("World Coordinate System is enabled."); defineProperty(&CCDRotationNP); @@ -1570,7 +1570,7 @@ bool CCD::ISNewSwitch(const char * dev, const char * name, ISState * states, cha } m_ValidCCDRotation = false; - IDSetSwitch(&WorldCoordSP, nullptr); + WorldCoordSP.apply(); } // Primary Chip Frame Reset @@ -2174,7 +2174,7 @@ void CCD::addFITSKeywords(CCDChip * targetChip, std::vector &fitsKey fitsKeywords.push_back({"EQUINOX", 2000, "Equinox"}); // Add WCS Info - if (WorldCoordS[0].s == ISS_ON && m_ValidCCDRotation && !std::isnan(effectiveFocalLength)) + if (WorldCoordSP[WCS_ENABLE].getState() == ISS_ON && m_ValidCCDRotation && !std::isnan(effectiveFocalLength)) { double J2000RAHours = J2000RA * 15; fitsKeywords.push_back({"CRVAL1", J2000RAHours, 10, "CRVAL1"}); diff --git a/libs/indibase/indiccd.h b/libs/indibase/indiccd.h index 37595e96c4..c2c11df887 100644 --- a/libs/indibase/indiccd.h +++ b/libs/indibase/indiccd.h @@ -751,9 +751,12 @@ class CCD : public DefaultDevice, GuiderInterface }; // WCS - ISwitch WorldCoordS[2]; - ISwitchVectorProperty WorldCoordSP; - + INDI::PropertySwitch WorldCoordSP{2}; + enum + { + WCS_ENABLE, + WCS_DISABLE + }; // WCS CCD Rotation INumber CCDRotationN[1]; INumberVectorProperty CCDRotationNP; From cabe74526f86b911aba8953e8042c1ca9ed0b0db Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Tue, 3 Sep 2024 11:09:45 +0300 Subject: [PATCH 04/23] Migrate CCDRotationNP, ImageFrameNP and ImageBinNP Properties --- libs/indibase/indiccd.cpp | 144 +++++++++++++++++----------------- libs/indibase/indiccd.h | 3 +- libs/indibase/indiccdchip.cpp | 56 +++++++------ libs/indibase/indiccdchip.h | 13 +-- 4 files changed, 116 insertions(+), 100 deletions(-) diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index f9a2241692..3cda3ca749 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -169,11 +169,11 @@ bool CCD::initProperties() /**********************************************/ // Primary CCD Region-Of-Interest (ROI) - IUFillNumber(&PrimaryCCD.ImageFrameN[CCDChip::FRAME_X], "X", "Left ", "%4.0f", 0, 0.0, 0, 0); - IUFillNumber(&PrimaryCCD.ImageFrameN[CCDChip::FRAME_Y], "Y", "Top", "%4.0f", 0, 0, 0, 0); - IUFillNumber(&PrimaryCCD.ImageFrameN[CCDChip::FRAME_W], "WIDTH", "Width", "%4.0f", 0, 0.0, 0, 0.0); - IUFillNumber(&PrimaryCCD.ImageFrameN[CCDChip::FRAME_H], "HEIGHT", "Height", "%4.0f", 0, 0, 0, 0.0); - IUFillNumberVector(&PrimaryCCD.ImageFrameNP, PrimaryCCD.ImageFrameN, 4, getDeviceName(), "CCD_FRAME", "Frame", + PrimaryCCD.ImageFrameNP[CCDChip::FRAME_X].fill("X", "Left ", "%4.0f", 0, 0.0, 0, 0); + PrimaryCCD.ImageFrameNP[CCDChip::FRAME_Y].fill("Y", "Top", "%4.0f", 0, 0, 0, 0); + PrimaryCCD.ImageFrameNP[CCDChip::FRAME_W].fill("WIDTH", "Width", "%4.0f", 0, 0.0, 0, 0.0); + PrimaryCCD.ImageFrameNP[CCDChip::FRAME_H].fill("HEIGHT", "Height", "%4.0f", 0, 0, 0, 0.0); + PrimaryCCD.ImageFrameNP.fill(getDeviceName(), "CCD_FRAME", "Frame", IMAGE_SETTINGS_TAB, IP_RW, 60, IPS_IDLE); // Primary CCD Frame Type @@ -195,9 +195,9 @@ bool CCD::initProperties() "Abort", MAIN_CONTROL_TAB, IP_RW, ISR_ATMOST1, 60, IPS_IDLE); // Primary CCD Binning - IUFillNumber(&PrimaryCCD.ImageBinN[0], "HOR_BIN", "X", "%2.0f", 1, 4, 1, 1); - IUFillNumber(&PrimaryCCD.ImageBinN[1], "VER_BIN", "Y", "%2.0f", 1, 4, 1, 1); - IUFillNumberVector(&PrimaryCCD.ImageBinNP, PrimaryCCD.ImageBinN, 2, getDeviceName(), "CCD_BINNING", "Binning", + PrimaryCCD.ImageBinNP[0].fill("HOR_BIN", "X", "%2.0f", 1, 4, 1, 1); + PrimaryCCD.ImageBinNP[1].fill("VER_BIN", "Y", "%2.0f", 1, 4, 1, 1); + PrimaryCCD.ImageBinNP.fill(getDeviceName(), "CCD_BINNING", "Binning", IMAGE_SETTINGS_TAB, IP_RW, 60, IPS_IDLE); // Primary CCD Info @@ -264,16 +264,16 @@ bool CCD::initProperties() /***************** Guide Chip *****************/ /**********************************************/ - IUFillNumber(&GuideCCD.ImageFrameN[CCDChip::FRAME_X], "X", "Left ", "%4.0f", 0, 0, 0, 0); - IUFillNumber(&GuideCCD.ImageFrameN[CCDChip::FRAME_Y], "Y", "Top", "%4.0f", 0, 0, 0, 0); - IUFillNumber(&GuideCCD.ImageFrameN[CCDChip::FRAME_W], "WIDTH", "Width", "%4.0f", 0, 0, 0, 0); - IUFillNumber(&GuideCCD.ImageFrameN[CCDChip::FRAME_H], "HEIGHT", "Height", "%4.0f", 0, 0, 0, 0); - IUFillNumberVector(&GuideCCD.ImageFrameNP, GuideCCD.ImageFrameN, 4, getDeviceName(), "GUIDER_FRAME", "Frame", + GuideCCD.ImageFrameNP[CCDChip::FRAME_X].fill("X", "Left ", "%4.0f", 0, 0, 0, 0); + GuideCCD.ImageFrameNP[CCDChip::FRAME_Y].fill("Y", "Top", "%4.0f", 0, 0, 0, 0); + GuideCCD.ImageFrameNP[CCDChip::FRAME_W].fill("WIDTH", "Width", "%4.0f", 0, 0, 0, 0); + GuideCCD.ImageFrameNP[CCDChip::FRAME_H].fill("HEIGHT", "Height", "%4.0f", 0, 0, 0, 0); + GuideCCD.ImageFrameNP.fill(getDeviceName(), "GUIDER_FRAME", "Frame", GUIDE_HEAD_TAB, IP_RW, 60, IPS_IDLE); - IUFillNumber(&GuideCCD.ImageBinN[0], "HOR_BIN", "X", "%2.0f", 1, 4, 1, 1); - IUFillNumber(&GuideCCD.ImageBinN[1], "VER_BIN", "Y", "%2.0f", 1, 4, 1, 1); - IUFillNumberVector(&GuideCCD.ImageBinNP, GuideCCD.ImageBinN, 2, getDeviceName(), "GUIDER_BINNING", "Binning", + GuideCCD.ImageBinNP[CCDChip::HOR_BIN].fill("HOR_BIN", "X", "%2.0f", 1, 4, 1, 1); + GuideCCD.ImageBinNP[CCDChip::VER_BIN].fill("VER_BIN", "Y", "%2.0f", 1, 4, 1, 1); + GuideCCD.ImageBinNP.fill(getDeviceName(), "GUIDER_BINNING", "Binning", GUIDE_HEAD_TAB, IP_RW, 60, IPS_IDLE); IUFillNumber(&GuideCCD.ImagePixelSizeN[CCDChip::CCD_MAX_X], "CCD_MAX_X", "Max. Width", "%4.0f", 1, 16000, 0, 0); @@ -349,8 +349,8 @@ bool CCD::initProperties() WorldCoordSP.fill(getDeviceName(), "WCS_CONTROL", "WCS", WCS_TAB, IP_RW, ISR_1OFMANY, 0, IPS_IDLE); - IUFillNumber(&CCDRotationN[0], "CCD_ROTATION_VALUE", "Rotation", "%g", -360, 360, 1, 0); - IUFillNumberVector(&CCDRotationNP, CCDRotationN, 1, getDeviceName(), "CCD_ROTATION", "CCD FOV", WCS_TAB, IP_RW, 60, + CCDRotationNP[0].fill("CCD_ROTATION_VALUE", "Rotation", "%g", -360, 360, 1, 0); + CCDRotationNP.fill(getDeviceName(), "CCD_ROTATION", "CCD FOV", WCS_TAB, IP_RW, 60, IPS_IDLE); ScopeInfoNP[FOCAL_LENGTH].fill("FOCAL_LENGTH", "Focal Length (mm)", "%g", 0, 10000, 1, 0); @@ -535,14 +535,14 @@ bool CCD::updateProperties() if (CanAbort()) defineProperty(&PrimaryCCD.AbortExposureSP); if (CanSubFrame() == false) - PrimaryCCD.ImageFrameNP.p = IP_RO; + PrimaryCCD.ImageFrameNP.setPermission(IP_RO); - defineProperty(&PrimaryCCD.ImageFrameNP); + defineProperty(PrimaryCCD.ImageFrameNP); if (CanBin() || CanSubFrame()) defineProperty(&PrimaryCCD.ResetSP); if (CanBin()) - defineProperty(&PrimaryCCD.ImageBinNP); + defineProperty(PrimaryCCD.ImageBinNP); defineProperty(FITSHeaderTP); @@ -552,8 +552,8 @@ bool CCD::updateProperties() if (CanAbort()) defineProperty(&GuideCCD.AbortExposureSP); if (CanSubFrame() == false) - GuideCCD.ImageFrameNP.p = IP_RO; - defineProperty(&GuideCCD.ImageFrameNP); + GuideCCD.ImageFrameNP.setPermission(IP_RO); + defineProperty(GuideCCD.ImageFrameNP); } if (HasCooler()) @@ -570,7 +570,7 @@ bool CCD::updateProperties() { defineProperty(&GuideCCD.ImagePixelSizeNP); if (CanBin()) - defineProperty(&GuideCCD.ImageBinNP); + defineProperty(GuideCCD.ImageBinNP); } defineProperty(&PrimaryCCD.CompressSP); defineProperty(&PrimaryCCD.FitsBP); @@ -627,7 +627,7 @@ bool CCD::updateProperties() } else { - deleteProperty(PrimaryCCD.ImageFrameNP.name); + deleteProperty(PrimaryCCD.ImageFrameNP); if (CanBin() || CanSubFrame()) deleteProperty(PrimaryCCD.ResetSP.name); @@ -637,7 +637,7 @@ bool CCD::updateProperties() deleteProperty(EncodeFormatSP.getName()); if (CanBin()) - deleteProperty(PrimaryCCD.ImageBinNP.name); + deleteProperty(PrimaryCCD.ImageBinNP); deleteProperty(PrimaryCCD.ImageExposureNP.name); if (CanAbort()) @@ -661,12 +661,12 @@ bool CCD::updateProperties() deleteProperty(GuideCCD.ImageExposureNP.name); if (CanAbort()) deleteProperty(GuideCCD.AbortExposureSP.name); - deleteProperty(GuideCCD.ImageFrameNP.name); + deleteProperty(GuideCCD.ImageFrameNP); deleteProperty(GuideCCD.ImagePixelSizeNP.name); deleteProperty(GuideCCD.FitsBP.name); if (CanBin()) - deleteProperty(GuideCCD.ImageBinNP.name); + deleteProperty(GuideCCD.ImageBinNP); deleteProperty(GuideCCD.CompressSP.name); deleteProperty(GuideCCD.FrameTypeSP.name); @@ -695,7 +695,7 @@ bool CCD::updateProperties() if (WorldCoordSP[WCS_ENABLE].getState() == ISS_ON) { - deleteProperty(CCDRotationNP.name); + deleteProperty(CCDRotationNP); } deleteProperty(WorldCoordSP); deleteProperty(UploadSP.name); @@ -1148,17 +1148,18 @@ bool CCD::ISNewNumber(const char * dev, const char * name, double values[], char if (!strcmp(name, "CCD_BINNING")) { // We are being asked to set camera binning - INumber * np = IUFindNumber(&PrimaryCCD.ImageBinNP, names[0]); + auto np = PrimaryCCD.ImageBinNP.findWidgetByName(names[0]); + // auto np = if (np == nullptr) { - PrimaryCCD.ImageBinNP.s = IPS_ALERT; - IDSetNumber(&PrimaryCCD.ImageBinNP, nullptr); + PrimaryCCD.ImageBinNP.setState(IPS_ALERT); + PrimaryCCD.ImageBinNP.apply(); return false; } else if (values[0] == 0 || values[1] == 0) { - PrimaryCCD.ImageBinNP.s = IPS_ALERT; - IDSetNumber(&PrimaryCCD.ImageBinNP, nullptr); + PrimaryCCD.ImageBinNP.setState(IPS_ALERT); + PrimaryCCD.ImageBinNP.apply(); LOGF_ERROR("%.fx%.f binning is invalid.", values[0], values[1]); return false; } @@ -1177,13 +1178,13 @@ bool CCD::ISNewNumber(const char * dev, const char * name, double values[], char if (UpdateCCDBin(binx, biny)) { - IUUpdateNumber(&PrimaryCCD.ImageBinNP, values, names, n); - PrimaryCCD.ImageBinNP.s = IPS_OK; + PrimaryCCD.ImageBinNP.update(values, names, n); + PrimaryCCD.ImageBinNP.setState(IPS_OK); } else - PrimaryCCD.ImageBinNP.s = IPS_ALERT; + PrimaryCCD.ImageBinNP.setState(IPS_ALERT); - IDSetNumber(&PrimaryCCD.ImageBinNP, nullptr); + PrimaryCCD.ImageBinNP.apply(); return true; } @@ -1191,17 +1192,18 @@ bool CCD::ISNewNumber(const char * dev, const char * name, double values[], char if (!strcmp(name, "GUIDER_BINNING")) { // We are being asked to set camera binning - INumber * np = IUFindNumber(&GuideCCD.ImageBinNP, names[0]); + // INumber * np = IUFindNumber(&GuideCCD.ImageBinNP, names[0]); + auto np = GuideCCD.ImageBinNP.findWidgetByName(names[0]); if (np == nullptr) { - GuideCCD.ImageBinNP.s = IPS_ALERT; - IDSetNumber(&GuideCCD.ImageBinNP, nullptr); + GuideCCD.ImageBinNP.setState(IPS_ALERT); + GuideCCD.ImageBinNP.apply(); return false; } else if (values[0] == 0 || values[1] == 0) { - PrimaryCCD.ImageBinNP.s = IPS_ALERT; - IDSetNumber(&PrimaryCCD.ImageBinNP, nullptr); + PrimaryCCD.ImageBinNP.setState(IPS_ALERT); + PrimaryCCD.ImageBinNP.apply(); LOGF_ERROR("%.fx%.f binning is invalid.", values[0], values[1]); return false; } @@ -1220,13 +1222,13 @@ bool CCD::ISNewNumber(const char * dev, const char * name, double values[], char if (UpdateGuiderBin(binx, biny)) { - IUUpdateNumber(&GuideCCD.ImageBinNP, values, names, n); - GuideCCD.ImageBinNP.s = IPS_OK; + GuideCCD.ImageBinNP.update(values, names, n); + GuideCCD.ImageBinNP.setState(IPS_OK); } else - GuideCCD.ImageBinNP.s = IPS_ALERT; + GuideCCD.ImageBinNP.setState(IPS_ALERT); - IDSetNumber(&GuideCCD.ImageBinNP, nullptr); + GuideCCD.ImageBinNP.apply(); return true; } @@ -1269,39 +1271,39 @@ bool CCD::ISNewNumber(const char * dev, const char * name, double values[], char if (x < 0 || y < 0 || w <= 0 || h <= 0) { LOGF_ERROR("Invalid frame requested (%d,%d) (%d x %d)", x, y, w, h); - PrimaryCCD.ImageFrameNP.s = IPS_ALERT; - IDSetNumber(&PrimaryCCD.ImageFrameNP, nullptr); + PrimaryCCD.ImageFrameNP.setState(IPS_ALERT); + PrimaryCCD.ImageFrameNP.apply(); return true; } if (UpdateCCDFrame(x, y, w, h)) { - PrimaryCCD.ImageFrameNP.s = IPS_OK; - IUUpdateNumber(&PrimaryCCD.ImageFrameNP, values, names, n); + PrimaryCCD.ImageFrameNP.setState(IPS_OK); + PrimaryCCD.ImageFrameNP.update(values, names, n); } else - PrimaryCCD.ImageFrameNP.s = IPS_ALERT; + PrimaryCCD.ImageFrameNP.setState(IPS_ALERT); - IDSetNumber(&PrimaryCCD.ImageFrameNP, nullptr); + PrimaryCCD.ImageFrameNP.apply(); return true; } if (!strcmp(name, "GUIDER_FRAME")) { // We are being asked to set guide frame - if (IUUpdateNumber(&GuideCCD.ImageFrameNP, values, names, n) < 0) + if (GuideCCD.ImageFrameNP.update(values, names, n) == false) return false; - GuideCCD.ImageFrameNP.s = IPS_OK; + GuideCCD.ImageFrameNP.setState(IPS_OK); DEBUGF(Logger::DBG_DEBUG, "Requested Guide Frame is %4.0f,%4.0f %4.0f x %4.0f", values[0], values[1], values[2], values[4]); - if (UpdateGuiderFrame(GuideCCD.ImageFrameN[0].value, GuideCCD.ImageFrameN[1].value, - GuideCCD.ImageFrameN[2].value, GuideCCD.ImageFrameN[3].value) == false) - GuideCCD.ImageFrameNP.s = IPS_ALERT; + if (UpdateGuiderFrame(GuideCCD.ImageFrameNP[CCDChip::FRAME_X].getValue(), GuideCCD.ImageFrameNP[CCDChip::FRAME_Y].getValue(), + GuideCCD.ImageFrameNP[CCDChip::FRAME_W].getValue(), GuideCCD.ImageFrameNP[CCDChip::FRAME_H].getValue()) == false) + GuideCCD.ImageFrameNP.setState(IPS_ALERT); - IDSetNumber(&GuideCCD.ImageFrameNP, nullptr); + GuideCCD.ImageFrameNP.apply(); return true; } @@ -1435,14 +1437,14 @@ bool CCD::ISNewNumber(const char * dev, const char * name, double values[], char } // CCD Rotation - if (!strcmp(name, CCDRotationNP.name)) + if (CCDRotationNP.isNameMatch(name)) { - IUUpdateNumber(&CCDRotationNP, values, names, n); - CCDRotationNP.s = IPS_OK; - IDSetNumber(&CCDRotationNP, nullptr); + CCDRotationNP.update(values, names, n); + CCDRotationNP.setState(IPS_OK); + CCDRotationNP.apply(); m_ValidCCDRotation = true; - DEBUGF(Logger::DBG_SESSION, "CCD FOV rotation updated to %g degrees.", CCDRotationN[0].value); + DEBUGF(Logger::DBG_SESSION, "CCD FOV rotation updated to %g degrees.", CCDRotationNP[0].getValue()); return true; } @@ -1561,12 +1563,12 @@ bool CCD::ISNewSwitch(const char * dev, const char * name, ISState * states, cha if (WorldCoordSP[0].getState() == ISS_ON) { LOG_INFO("World Coordinate System is enabled."); - defineProperty(&CCDRotationNP); + defineProperty(CCDRotationNP); } else { LOG_INFO("World Coordinate System is disabled."); - deleteProperty(CCDRotationNP.name); + deleteProperty(CCDRotationNP); } m_ValidCCDRotation = false; @@ -2207,7 +2209,7 @@ void CCD::addFITSKeywords(CCDChip * targetChip, std::vector &fitsKey fitsKeywords.push_back({"CDELT2", degpix2, 10, "CDELT2"}); // Rotation is CW, we need to convert it to CCW per CROTA1 definition - double rotation = 360 - CCDRotationN[0].value; + double rotation = 360 - CCDRotationNP[0].getValue(); if (rotation > 360) rotation -= 360; @@ -2803,14 +2805,14 @@ bool CCD::saveConfigItems(FILE * fp) if (HasGuideHead()) { IUSaveConfigSwitch(fp, &GuideCCD.CompressSP); - IUSaveConfigNumber(fp, &GuideCCD.ImageBinNP); + GuideCCD.ImageBinNP.save(fp); } - if (CanSubFrame() && PrimaryCCD.ImageFrameN[2].value > 0) - IUSaveConfigNumber(fp, &PrimaryCCD.ImageFrameNP); + if (CanSubFrame() && PrimaryCCD.ImageFrameNP[CCDChip::FRAME_W].getValue() > 0) + PrimaryCCD.ImageFrameNP.save(fp); if (CanBin()) - IUSaveConfigNumber(fp, &PrimaryCCD.ImageBinNP); + PrimaryCCD.ImageBinNP.save(fp); if (HasBayer()) BayerTP.save(fp); diff --git a/libs/indibase/indiccd.h b/libs/indibase/indiccd.h index c2c11df887..5aefe9fc81 100644 --- a/libs/indibase/indiccd.h +++ b/libs/indibase/indiccd.h @@ -758,8 +758,7 @@ class CCD : public DefaultDevice, GuiderInterface WCS_DISABLE }; // WCS CCD Rotation - INumber CCDRotationN[1]; - INumberVectorProperty CCDRotationNP; + INDI::PropertyNumber CCDRotationNP{1}; // Fast Exposure Toggle ISwitch FastExposureToggleS[2]; diff --git a/libs/indibase/indiccdchip.cpp b/libs/indibase/indiccdchip.cpp index 033e672c36..60c2ab82b7 100644 --- a/libs/indibase/indiccdchip.cpp +++ b/libs/indibase/indiccdchip.cpp @@ -98,16 +98,16 @@ void CCDChip::setResolution(uint32_t x, uint32_t y) IDSetNumber(&ImagePixelSizeNP, nullptr); - ImageFrameN[FRAME_X].min = 0; - ImageFrameN[FRAME_X].max = x - 1; - ImageFrameN[FRAME_Y].min = 0; - ImageFrameN[FRAME_Y].max = y - 1; - - ImageFrameN[FRAME_W].min = 1; - ImageFrameN[FRAME_W].max = x; - ImageFrameN[FRAME_H].min = 1; - ImageFrameN[FRAME_H].max = y; - IUUpdateMinMax(&ImageFrameNP); + ImageFrameNP[FRAME_X].setMin(0); + ImageFrameNP[FRAME_X].setMax(x - 1); + ImageFrameNP[FRAME_Y].setMin(0); + ImageFrameNP[FRAME_Y].setMax(y - 1); + + ImageFrameNP[FRAME_W].setMin(1); + ImageFrameNP[FRAME_W].setMax(x); + ImageFrameNP[FRAME_H].setMin(1); + ImageFrameNP[FRAME_H].setMax(y); + ImageFrameNP.updateMinMax(); } void CCDChip::setFrame(uint32_t subx, uint32_t suby, uint32_t subw, uint32_t subh) @@ -117,12 +117,12 @@ void CCDChip::setFrame(uint32_t subx, uint32_t suby, uint32_t subw, uint32_t sub SubW = subw; SubH = subh; - ImageFrameN[FRAME_X].value = SubX; - ImageFrameN[FRAME_Y].value = SubY; - ImageFrameN[FRAME_W].value = SubW; - ImageFrameN[FRAME_H].value = SubH; + ImageFrameNP[FRAME_X].setValue(SubX); + ImageFrameNP[FRAME_Y].setValue(SubY); + ImageFrameNP[FRAME_W].setValue(SubW); + ImageFrameNP[FRAME_H].setValue(SubH); - IDSetNumber(&ImageFrameNP, nullptr); + ImageFrameNP.apply(); } void CCDChip::setBin(uint8_t hor, uint8_t ver) @@ -130,10 +130,10 @@ void CCDChip::setBin(uint8_t hor, uint8_t ver) BinX = hor; BinY = ver; - ImageBinN[BIN_W].value = BinX; - ImageBinN[BIN_H].value = BinY; + ImageBinNP[BIN_W].setValue(BinX); + ImageBinNP[BIN_H].setValue(BinY); - IDSetNumber(&ImageBinNP, nullptr); + ImageBinNP.apply(); } void CCDChip::setMinMaxStep(const char *property, const char *element, double min, double max, double step, @@ -141,12 +141,24 @@ void CCDChip::setMinMaxStep(const char *property, const char *element, double mi { INumberVectorProperty *nvp = nullptr; + auto updateMinMaxStep = [element, min, max, sendToClient](INDI::PropertyNumber &oneProperty) + { + auto oneElement = oneProperty.findWidgetByName(element); + if(oneElement) + { + oneElement->setMinMax(min, max); + if(sendToClient) + IUUpdateMinMax(oneProperty); + } + }; + if (!strcmp(property, ImageExposureNP.name)) nvp = &ImageExposureNP; - else if (!strcmp(property, ImageFrameNP.name)) - nvp = &ImageFrameNP; - else if (!strcmp(property, ImageBinNP.name)) - nvp = &ImageBinNP; + else if (ImageFrameNP.isNameMatch(property)) + updateMinMaxStep(ImageFrameNP); + else if (ImageBinNP.isNameMatch(property)) + updateMinMaxStep(ImageBinNP); + else if (!strcmp(property, ImagePixelSizeNP.name)) nvp = &ImagePixelSizeNP; // else if (!strcmp(property, RapidGuideDataNP.name)) diff --git a/libs/indibase/indiccdchip.h b/libs/indibase/indiccdchip.h index 6f8e199fc7..469a7cc652 100644 --- a/libs/indibase/indiccdchip.h +++ b/libs/indibase/indiccdchip.h @@ -20,6 +20,7 @@ #include "indiapi.h" #include "indidriver.h" +#include "indipropertynumber.h" #include #include @@ -497,15 +498,17 @@ class CCDChip ///////////////////////////////////////////////////////////////////////////////////////// /// Image Frame ROI ///////////////////////////////////////////////////////////////////////////////////////// - INumberVectorProperty ImageFrameNP; - INumber ImageFrameN[4]; + INDI::PropertyNumber ImageFrameNP {4}; ///////////////////////////////////////////////////////////////////////////////////////// /// Image Binning ///////////////////////////////////////////////////////////////////////////////////////// - INumberVectorProperty ImageBinNP; - INumber ImageBinN[2]; - + INDI::PropertyNumber ImageBinNP{2}; + enum + { + HOR_BIN, + VER_BIN + }; ///////////////////////////////////////////////////////////////////////////////////////// /// Image Resolution & Pixel Size data ///////////////////////////////////////////////////////////////////////////////////////// From a4789868fc468c377fe92e3b2ccbc24c8bc580cf Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Tue, 3 Sep 2024 11:45:46 +0300 Subject: [PATCH 05/23] use updateMinMax() --- libs/indibase/indiccdchip.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/indibase/indiccdchip.cpp b/libs/indibase/indiccdchip.cpp index 60c2ab82b7..e1a4892326 100644 --- a/libs/indibase/indiccdchip.cpp +++ b/libs/indibase/indiccdchip.cpp @@ -148,7 +148,7 @@ void CCDChip::setMinMaxStep(const char *property, const char *element, double mi { oneElement->setMinMax(min, max); if(sendToClient) - IUUpdateMinMax(oneProperty); + oneProperty.updateMinMax(); } }; From ac1c69f2273b6c3512f1143a6c432ff6738e5f43 Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Tue, 3 Sep 2024 11:59:38 +0300 Subject: [PATCH 06/23] Migrate FastExposureToggleSP Property --- libs/indibase/indiccd.cpp | 34 +++++++++++++++++----------------- libs/indibase/indiccd.h | 3 +-- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index 3cda3ca749..3d9902c4b4 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -132,8 +132,8 @@ CCD::CCD() : GI(this) CCD::~CCD() { // Only update if index is different. - if (m_ConfigFastExposureIndex != IUFindOnSwitchIndex(&FastExposureToggleSP)) - saveConfig(true, FastExposureToggleSP.name); + if (m_ConfigFastExposureIndex != FastExposureToggleSP.findOnSwitchIndex()) + saveConfig(true, FastExposureToggleSP.getName()); } void CCD::SetCCDCapability(uint32_t cap) @@ -413,12 +413,12 @@ bool CCD::initProperties() /**********************************************/ /****************** Exposure Looping **********/ /***************** Primary CCD Only ***********/ - IUGetConfigOnSwitchIndex(getDeviceName(), FastExposureToggleSP.name, &m_ConfigFastExposureIndex); - IUFillSwitch(&FastExposureToggleS[INDI_ENABLED], "INDI_ENABLED", "Enabled", + IUGetConfigOnSwitchIndex(getDeviceName(), FastExposureToggleSP.getName(), &m_ConfigFastExposureIndex); + FastExposureToggleSP[INDI_ENABLED].fill("INDI_ENABLED", "Enabled", m_ConfigFastExposureIndex == INDI_ENABLED ? ISS_ON : ISS_OFF); - IUFillSwitch(&FastExposureToggleS[INDI_DISABLED], "INDI_DISABLED", "Disabled", + FastExposureToggleSP[INDI_DISABLED].fill("INDI_DISABLED", "Disabled", m_ConfigFastExposureIndex == INDI_DISABLED ? ISS_ON : ISS_OFF); - IUFillSwitchVector(&FastExposureToggleSP, FastExposureToggleS, 2, getDeviceName(), "CCD_FAST_TOGGLE", "Fast Exposure", + FastExposureToggleSP.fill(getDeviceName(), "CCD_FAST_TOGGLE", "Fast Exposure", OPTIONS_TAB, IP_RW, ISR_1OFMANY, 0, IPS_IDLE); // CCD Should loop until the number of frames specified in this property is completed @@ -622,7 +622,7 @@ bool CCD::updateProperties() defineProperty(&WebSocketSP); #endif - defineProperty(&FastExposureToggleSP); + defineProperty(FastExposureToggleSP); defineProperty(&FastExposureCountNP); } else @@ -708,7 +708,7 @@ bool CCD::updateProperties() deleteProperty(WebSocketSettingsNP.name); } #endif - deleteProperty(FastExposureToggleSP.name); + deleteProperty(FastExposureToggleSP); deleteProperty(FastExposureCountNP.name); } @@ -1505,15 +1505,15 @@ bool CCD::ISNewSwitch(const char * dev, const char * name, ISState * states, cha } // Fast Exposure Toggle - if (!strcmp(name, FastExposureToggleSP.name)) + if (FastExposureToggleSP.isNameMatch(name)) { - IUUpdateSwitch(&FastExposureToggleSP, states, names, n); + FastExposureToggleSP.update(states, names, n); // Only display warning for the first time this is enabled. - if (FastExposureToggleSP.s == IPS_IDLE && FastExposureToggleS[INDI_ENABLED].s == ISS_ON) + if (FastExposureToggleSP.getState() == IPS_IDLE && FastExposureToggleSP[INDI_ENABLED].getState() == ISS_ON) LOG_WARN("Experimental Feature: After a frame is downloaded, the next frame capture immediately starts to avoid any delays."); - if (FastExposureToggleS[INDI_DISABLED].s == ISS_ON) + if (FastExposureToggleSP[INDI_DISABLED].getState() == ISS_ON) { FastExposureCountNP.s = IPS_IDLE; IDSetNumber(&FastExposureCountNP, nullptr); @@ -1522,8 +1522,8 @@ bool CCD::ISNewSwitch(const char * dev, const char * name, ISState * states, cha AbortExposure(); } - FastExposureToggleSP.s = IPS_OK; - IDSetSwitch(&FastExposureToggleSP, nullptr); + FastExposureToggleSP.setState(IPS_OK); + FastExposureToggleSP.apply(); return true; } @@ -2523,7 +2523,7 @@ bool CCD::ExposureCompletePrivate(CCDChip * targetChip) } } - if (FastExposureToggleS[INDI_ENABLED].s != ISS_ON) + if (FastExposureToggleSP[INDI_ENABLED].getState() != ISS_ON) targetChip->setExposureComplete(); UploadComplete(targetChip); @@ -2698,7 +2698,7 @@ bool CCD::uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBy bool CCD::processFastExposure(CCDChip * targetChip) { // If fast exposure is on, let's immediately take another capture - if (FastExposureToggleS[INDI_ENABLED].s == ISS_ON) + if (FastExposureToggleSP[INDI_ENABLED].getState() == ISS_ON) { targetChip->setExposureComplete(); double duration = targetChip->getExposureDuration(); @@ -2789,7 +2789,7 @@ bool CCD::saveConfigItems(FILE * fp) ActiveDeviceTP.save(fp); IUSaveConfigSwitch(fp, &UploadSP); IUSaveConfigText(fp, &UploadSettingsTP); - IUSaveConfigSwitch(fp, &FastExposureToggleSP); + FastExposureToggleSP.save(fp); IUSaveConfigSwitch(fp, &PrimaryCCD.CompressSP); diff --git a/libs/indibase/indiccd.h b/libs/indibase/indiccd.h index 5aefe9fc81..d3816d80ce 100644 --- a/libs/indibase/indiccd.h +++ b/libs/indibase/indiccd.h @@ -761,8 +761,7 @@ class CCD : public DefaultDevice, GuiderInterface INDI::PropertyNumber CCDRotationNP{1}; // Fast Exposure Toggle - ISwitch FastExposureToggleS[2]; - ISwitchVectorProperty FastExposureToggleSP; + INDI::PropertySwitch FastExposureToggleSP {2}; // Fast Exposure Frame Count INumber FastExposureCountN[1]; From 4a8fa824b66509bd7800217cbff3aeda7c2e6b87 Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Mon, 9 Sep 2024 11:31:47 +0300 Subject: [PATCH 07/23] Migrate ImagePixelSizeNP, ImageExposureNP, FastExposureCountNP, WebSocketSP, EqNP, J2000EqNP Properties --- libs/indibase/indiccd.cpp | 283 +++++++++++++++++----------------- libs/indibase/indiccd.h | 20 +-- libs/indibase/indiccdchip.cpp | 42 ++--- libs/indibase/indiccdchip.h | 12 +- 4 files changed, 179 insertions(+), 178 deletions(-) diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index 3d9902c4b4..a43928b240 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -185,8 +185,8 @@ bool CCD::initProperties() "Type", IMAGE_SETTINGS_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE); // Primary CCD Exposure - IUFillNumber(&PrimaryCCD.ImageExposureN[0], "CCD_EXPOSURE_VALUE", "Duration (s)", "%5.2f", 0.01, 3600, 1.0, 1.0); - IUFillNumberVector(&PrimaryCCD.ImageExposureNP, PrimaryCCD.ImageExposureN, 1, getDeviceName(), "CCD_EXPOSURE", + PrimaryCCD.ImageExposureNP[0].fill("CCD_EXPOSURE_VALUE", "Duration (s)", "%5.2f", 0.01, 3600, 1.0, 1.0); + PrimaryCCD.ImageExposureNP.fill(getDeviceName(), "CCD_EXPOSURE", "Expose", MAIN_CONTROL_TAB, IP_RW, 60, IPS_IDLE); // Primary CCD Abort @@ -201,17 +201,17 @@ bool CCD::initProperties() IMAGE_SETTINGS_TAB, IP_RW, 60, IPS_IDLE); // Primary CCD Info - IUFillNumber(&PrimaryCCD.ImagePixelSizeN[CCDChip::CCD_MAX_X], "CCD_MAX_X", "Max. Width", "%.f", 1, 16000, 0, 0); - IUFillNumber(&PrimaryCCD.ImagePixelSizeN[CCDChip::CCD_MAX_Y], "CCD_MAX_Y", "Max. Height", "%.f", 1, 16000, 0, 0); - IUFillNumber(&PrimaryCCD.ImagePixelSizeN[CCDChip::CCD_PIXEL_SIZE], "CCD_PIXEL_SIZE", "Pixel size (um)", "%.2f", 1, + PrimaryCCD.ImagePixelSizeNP[CCDChip::CCD_MAX_X].fill("CCD_MAX_X", "Max. Width", "%.f", 1, 16000, 0, 0); + PrimaryCCD.ImagePixelSizeNP[CCDChip::CCD_MAX_Y].fill("CCD_MAX_Y", "Max. Height", "%.f", 1, 16000, 0, 0); + PrimaryCCD.ImagePixelSizeNP[CCDChip::CCD_PIXEL_SIZE].fill("CCD_PIXEL_SIZE", "Pixel size (um)", "%.2f", 1, 40, 0, 0); - IUFillNumber(&PrimaryCCD.ImagePixelSizeN[CCDChip::CCD_PIXEL_SIZE_X], "CCD_PIXEL_SIZE_X", "Pixel size X", "%.2f", 1, + PrimaryCCD.ImagePixelSizeNP[CCDChip::CCD_PIXEL_SIZE_X].fill("CCD_PIXEL_SIZE_X", "Pixel size X", "%.2f", 1, 40, 0, 0); - IUFillNumber(&PrimaryCCD.ImagePixelSizeN[CCDChip::CCD_PIXEL_SIZE_Y], "CCD_PIXEL_SIZE_Y", "Pixel size Y", "%.2f", 1, + PrimaryCCD.ImagePixelSizeNP[CCDChip::CCD_PIXEL_SIZE_Y].fill("CCD_PIXEL_SIZE_Y", "Pixel size Y", "%.2f", 1, 40, 0, 0); - IUFillNumber(&PrimaryCCD.ImagePixelSizeN[CCDChip::CCD_BITSPERPIXEL], "CCD_BITSPERPIXEL", "Bits per pixel", "%.f", + PrimaryCCD.ImagePixelSizeNP[CCDChip::CCD_BITSPERPIXEL].fill("CCD_BITSPERPIXEL", "Bits per pixel", "%.f", 8, 64, 0, 0); - IUFillNumberVector(&PrimaryCCD.ImagePixelSizeNP, PrimaryCCD.ImagePixelSizeN, 6, getDeviceName(), "CCD_INFO", + PrimaryCCD.ImagePixelSizeNP.fill(getDeviceName(), "CCD_INFO", "CCD Information", IMAGE_INFO_TAB, IP_RO, 60, IPS_IDLE); // Primary CCD Compression Options @@ -276,17 +276,17 @@ bool CCD::initProperties() GuideCCD.ImageBinNP.fill(getDeviceName(), "GUIDER_BINNING", "Binning", GUIDE_HEAD_TAB, IP_RW, 60, IPS_IDLE); - IUFillNumber(&GuideCCD.ImagePixelSizeN[CCDChip::CCD_MAX_X], "CCD_MAX_X", "Max. Width", "%4.0f", 1, 16000, 0, 0); - IUFillNumber(&GuideCCD.ImagePixelSizeN[CCDChip::CCD_MAX_Y], "CCD_MAX_Y", "Max. Height", "%4.0f", 1, 16000, 0, 0); - IUFillNumber(&GuideCCD.ImagePixelSizeN[CCDChip::CCD_PIXEL_SIZE], "CCD_PIXEL_SIZE", "Pixel size (um)", "%5.2f", 1, + GuideCCD.ImagePixelSizeNP[CCDChip::CCD_MAX_X].fill("CCD_MAX_X", "Max. Width", "%4.0f", 1, 16000, 0, 0); + GuideCCD.ImagePixelSizeNP[CCDChip::CCD_MAX_Y].fill("CCD_MAX_Y", "Max. Height", "%4.0f", 1, 16000, 0, 0); + GuideCCD.ImagePixelSizeNP[CCDChip::CCD_PIXEL_SIZE].fill("CCD_PIXEL_SIZE", "Pixel size (um)", "%5.2f", 1, 40, 0, 0); - IUFillNumber(&GuideCCD.ImagePixelSizeN[CCDChip::CCD_PIXEL_SIZE_X], "CCD_PIXEL_SIZE_X", "Pixel size X", "%5.2f", 1, + GuideCCD.ImagePixelSizeNP[CCDChip::CCD_PIXEL_SIZE_X].fill("CCD_PIXEL_SIZE_X", "Pixel size X", "%5.2f", 1, 40, 0, 0); - IUFillNumber(&GuideCCD.ImagePixelSizeN[CCDChip::CCD_PIXEL_SIZE_Y], "CCD_PIXEL_SIZE_Y", "Pixel size Y", "%5.2f", 1, + GuideCCD.ImagePixelSizeNP[CCDChip::CCD_PIXEL_SIZE_Y].fill("CCD_PIXEL_SIZE_Y", "Pixel size Y", "%5.2f", 1, 40, 0, 0); - IUFillNumber(&GuideCCD.ImagePixelSizeN[CCDChip::CCD_BITSPERPIXEL], "CCD_BITSPERPIXEL", "Bits per pixel", "%3.0f", 8, + GuideCCD.ImagePixelSizeNP[CCDChip::CCD_BITSPERPIXEL].fill("CCD_BITSPERPIXEL", "Bits per pixel", "%3.0f", 8, 64, 0, 0); - IUFillNumberVector(&GuideCCD.ImagePixelSizeNP, GuideCCD.ImagePixelSizeN, 6, getDeviceName(), "GUIDER_INFO", + GuideCCD.ImagePixelSizeNP.fill(getDeviceName(), "GUIDER_INFO", "Info", IMAGE_INFO_TAB, IP_RO, 60, IPS_IDLE); IUFillSwitch(&GuideCCD.FrameTypeS[0], "FRAME_LIGHT", "Light", ISS_ON); @@ -296,8 +296,8 @@ bool CCD::initProperties() IUFillSwitchVector(&GuideCCD.FrameTypeSP, GuideCCD.FrameTypeS, 4, getDeviceName(), "GUIDER_FRAME_TYPE", "Type", GUIDE_HEAD_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE); - IUFillNumber(&GuideCCD.ImageExposureN[0], "GUIDER_EXPOSURE_VALUE", "Duration (s)", "%5.2f", 0.01, 3600, 1.0, 1.0); - IUFillNumberVector(&GuideCCD.ImageExposureNP, GuideCCD.ImageExposureN, 1, getDeviceName(), "GUIDER_EXPOSURE", + GuideCCD.ImageExposureNP[0].fill("GUIDER_EXPOSURE_VALUE", "Duration (s)", "%5.2f", 0.01, 3600, 1.0, 1.0); + GuideCCD.ImageExposureNP.fill(getDeviceName(), "GUIDER_EXPOSURE", "Guide Head", MAIN_CONTROL_TAB, IP_RW, 60, IPS_IDLE); IUFillSwitch(&GuideCCD.AbortExposureS[0], "ABORT", "Abort", ISS_OFF); @@ -422,20 +422,20 @@ bool CCD::initProperties() OPTIONS_TAB, IP_RW, ISR_1OFMANY, 0, IPS_IDLE); // CCD Should loop until the number of frames specified in this property is completed - IUFillNumber(&FastExposureCountN[0], "FRAMES", "Frames", "%.f", 0, 100000, 1, 1); - IUFillNumberVector(&FastExposureCountNP, FastExposureCountN, 1, getDeviceName(), "CCD_FAST_COUNT", "Fast Count", + FastExposureCountNP[0].fill("FRAMES", "Frames", "%.f", 0, 100000, 1, 1); + FastExposureCountNP.fill(getDeviceName(), "CCD_FAST_COUNT", "Fast Count", OPTIONS_TAB, IP_RW, 0, IPS_IDLE); /**********************************************/ /**************** Web Socket ******************/ /**********************************************/ - IUFillSwitch(&WebSocketS[WEBSOCKET_ENABLED], "WEBSOCKET_ENABLED", "Enabled", ISS_OFF); - IUFillSwitch(&WebSocketS[WEBSOCKET_DISABLED], "WEBSOCKET_DISABLED", "Disabled", ISS_ON); - IUFillSwitchVector(&WebSocketSP, WebSocketS, 2, getDeviceName(), "CCD_WEBSOCKET", "Websocket", OPTIONS_TAB, + WebSocketSP[WEBSOCKET_ENABLED].fill("WEBSOCKET_ENABLED", "Enabled", ISS_OFF); + WebSocketSP[WEBSOCKET_DISABLED].fill("WEBSOCKET_DISABLED", "Disabled", ISS_ON); + WebSocketSP.fill(getDeviceName(), "CCD_WEBSOCKET", "Websocket", OPTIONS_TAB, IP_RW, ISR_1OFMANY, 0, IPS_IDLE); - IUFillNumber(&WebSocketSettingsN[WS_SETTINGS_PORT], "WS_SETTINGS_PORT", "Port", "%.f", 0, 50000, 0, 0); - IUFillNumberVector(&WebSocketSettingsNP, WebSocketSettingsN, 1, getDeviceName(), "CCD_WEBSOCKET_SETTINGS", "WS Settings", + WebSocketSettingsNP[WS_SETTINGS_PORT].fill("WS_SETTINGS_PORT", "Port", "%.f", 0, 50000, 0, 0); + WebSocketSettingsNP.fill(getDeviceName(), "CCD_WEBSOCKET_SETTINGS", "WS Settings", OPTIONS_TAB, IP_RW, 60, IPS_IDLE); @@ -467,14 +467,14 @@ bool CCD::initProperties() auto mount = ActiveDeviceTP[ACTIVE_TELESCOPE].getText() ? ActiveDeviceTP[ACTIVE_TELESCOPE].getText() : ""; // Snooped RA/DEC Property - IUFillNumber(&EqN[0], "RA", "Ra (hh:mm:ss)", "%010.6m", 0, 24, 0, 0); - IUFillNumber(&EqN[1], "DEC", "Dec (dd:mm:ss)", "%010.6m", -90, 90, 0, 0); - IUFillNumberVector(&EqNP, EqN, 2, mount, "EQUATORIAL_EOD_COORD", "EQ Coord", "Main Control", IP_RW, 60, IPS_IDLE); + EqNP[Ra].fill("RA", "Ra (hh:mm:ss)", "%010.6m", 0, 24, 0, 0); + EqNP[DEC].fill("DEC", "Dec (dd:mm:ss)", "%010.6m", -90, 90, 0, 0); + EqNP.fill(mount, "EQUATORIAL_EOD_COORD", "EQ Coord", "Main Control", IP_RW, 60, IPS_IDLE); // Snooped J2000 RA/DEC Property - IUFillNumber(&J2000EqN[0], "RA", "Ra (hh:mm:ss)", "%010.6m", 0, 24, 0, 0); - IUFillNumber(&J2000EqN[1], "DEC", "Dec (dd:mm:ss)", "%010.6m", -90, 90, 0, 0); - IUFillNumberVector(&J2000EqNP, J2000EqN, 2, mount, "EQUATORIAL_COORD", "J2000 EQ Coord", + J2000EqNP[Ra].fill("RA", "Ra (hh:mm:ss)", "%010.6m", 0, 24, 0, 0); + J2000EqNP[DEC].fill("DEC", "Dec (dd:mm:ss)", "%010.6m", -90, 90, 0, 0); + J2000EqNP.fill(mount, "EQUATORIAL_COORD", "J2000 EQ Coord", "Main Control", IP_RW, 60, IPS_IDLE); @@ -530,7 +530,7 @@ bool CCD::updateProperties() //IDLog("CCD UpdateProperties isConnected returns %d %d\n",isConnected(),Connected); if (isConnected()) { - defineProperty(&PrimaryCCD.ImageExposureNP); + defineProperty(PrimaryCCD.ImageExposureNP); if (CanAbort()) defineProperty(&PrimaryCCD.AbortExposureSP); @@ -548,7 +548,7 @@ bool CCD::updateProperties() if (HasGuideHead()) { - defineProperty(&GuideCCD.ImageExposureNP); + defineProperty(GuideCCD.ImageExposureNP); if (CanAbort()) defineProperty(&GuideCCD.AbortExposureSP); if (CanSubFrame() == false) @@ -565,10 +565,10 @@ bool CCD::updateProperties() defineProperty(CaptureFormatSP); defineProperty(EncodeFormatSP); - defineProperty(&PrimaryCCD.ImagePixelSizeNP); + defineProperty(PrimaryCCD.ImagePixelSizeNP); if (HasGuideHead()) { - defineProperty(&GuideCCD.ImagePixelSizeNP); + defineProperty(GuideCCD.ImagePixelSizeNP); if (CanBin()) defineProperty(GuideCCD.ImageBinNP); } @@ -623,7 +623,7 @@ bool CCD::updateProperties() #endif defineProperty(FastExposureToggleSP); - defineProperty(&FastExposureCountNP); + defineProperty(FastExposureCountNP); } else { @@ -631,7 +631,7 @@ bool CCD::updateProperties() if (CanBin() || CanSubFrame()) deleteProperty(PrimaryCCD.ResetSP.name); - deleteProperty(PrimaryCCD.ImagePixelSizeNP.name); + deleteProperty(PrimaryCCD.ImagePixelSizeNP); deleteProperty(CaptureFormatSP.getName()); deleteProperty(EncodeFormatSP.getName()); @@ -639,7 +639,7 @@ bool CCD::updateProperties() if (CanBin()) deleteProperty(PrimaryCCD.ImageBinNP); - deleteProperty(PrimaryCCD.ImageExposureNP.name); + deleteProperty(PrimaryCCD.ImageExposureNP); if (CanAbort()) deleteProperty(PrimaryCCD.AbortExposureSP.name); deleteProperty(PrimaryCCD.FitsBP.name); @@ -658,11 +658,11 @@ bool CCD::updateProperties() if (HasGuideHead()) { - deleteProperty(GuideCCD.ImageExposureNP.name); + deleteProperty(GuideCCD.ImageExposureNP); if (CanAbort()) deleteProperty(GuideCCD.AbortExposureSP.name); deleteProperty(GuideCCD.ImageFrameNP); - deleteProperty(GuideCCD.ImagePixelSizeNP.name); + deleteProperty(GuideCCD.ImagePixelSizeNP); deleteProperty(GuideCCD.FitsBP.name); if (CanBin()) @@ -709,7 +709,7 @@ bool CCD::updateProperties() } #endif deleteProperty(FastExposureToggleSP); - deleteProperty(FastExposureCountNP.name); + deleteProperty(FastExposureCountNP); } // Streamer @@ -729,32 +729,34 @@ bool CCD::ISSnoopDevice(XMLEle * root) auto propName = findXMLAttValu(root, "name"); auto deviceName = std::string(findXMLAttValu(root, "device")); - if (IUSnoopNumber(root, &EqNP) == 0) - { - double newra, newdec; - newra = EqN[0].value; - newdec = EqN[1].value; - if ((newra != RA) || (newdec != Dec)) - { - //IDLog("RA %4.2f Dec %4.2f Snooped RA %4.2f Dec %4.2f\n",RA,Dec,newra,newdec); - RA = newra; - Dec = newdec; - } - } - else if (IUSnoopNumber(root, &J2000EqNP) == 0) - { - float newra, newdec; - newra = J2000EqN[0].value; - newdec = J2000EqN[1].value; - if ((newra != J2000RA) || (newdec != J2000DE)) - { - // IDLog("J2000 RA %4.2f Dec %4.2f Snooped RA %4.2f Dec %4.2f\n",J2000RA,J2000DE,newra,newdec); - J2000RA = newra; - J2000DE = newdec; - } - J2000Valid = true; - } - else if (!strcmp("TELESCOPE_PIER_SIDE", propName) && deviceName == ActiveDeviceTP[ACTIVE_TELESCOPE].getText()) + // FixMe:// Uncomment Snoop conditions once Snoop property is added + // if (IUSnoopNumber(root, &EqNP) == 0) + // { + // double newra, newdec; + // newra = EqNP[Ra].getValue(); + // newdec = EqNP[DEC].getValue(); + // if ((newra != RA) || (newdec != Dec)) + // { + // //IDLog("RA %4.2f Dec %4.2f Snooped RA %4.2f Dec %4.2f\n",RA,Dec,newra,newdec); + // RA = newra; + // Dec = newdec; + // } + // } + // else if (IUSnoopNumber(root, &J2000EqNP) == 0) + // { + // float newra, newdec; + // newra = J2000EqNP[Ra].getValue(); + // newdec = J2000EqNP[DEC].getValue(); + // if ((newra != J2000RA) || (newdec != J2000DE)) + // { + // // IDLog("J2000 RA %4.2f Dec %4.2f Snooped RA %4.2f Dec %4.2f\n",J2000RA,J2000DE,newra,newdec); + // J2000RA = newra; + // J2000DE = newdec; + // } + // J2000Valid = true; + // } + // else + if (!strcmp("TELESCOPE_PIER_SIDE", propName) && deviceName == ActiveDeviceTP[ACTIVE_TELESCOPE].getText()) { // set default to say we have no valid information from mount pierSide = -1; @@ -895,8 +897,9 @@ bool CCD::ISNewText(const char * dev, const char * name, char * texts[], char * ActiveDeviceTP.apply(); // Update the property name! - strncpy(EqNP.device, ActiveDeviceTP[ACTIVE_TELESCOPE].getText(), MAXINDIDEVICE); - strncpy(J2000EqNP.device, ActiveDeviceTP[ACTIVE_TELESCOPE].getText(), MAXINDIDEVICE); + // strncpy(EqNP.device, ActiveDeviceTP[ACTIVE_TELESCOPE].getText(), MAXINDIDEVICE); + EqNP.setDeviceName(ActiveDeviceTP[ACTIVE_TELESCOPE].getText()); + J2000EqNP.setDeviceName(ActiveDeviceTP[ACTIVE_TELESCOPE].getText()); if (strlen(ActiveDeviceTP[ACTIVE_TELESCOPE].getText()) > 0) { LOGF_DEBUG("Snopping on Mount %s", ActiveDeviceTP[ACTIVE_TELESCOPE].getText()); @@ -1085,23 +1088,23 @@ bool CCD::ISNewNumber(const char * dev, const char * name, double values[], char if (!strcmp(name, "CCD_EXPOSURE")) { if (PrimaryCCD.getFrameType() != CCDChip::BIAS_FRAME && - (values[0] < PrimaryCCD.ImageExposureN[0].min || values[0] > PrimaryCCD.ImageExposureN[0].max)) + (values[0] < PrimaryCCD.ImageExposureNP[0].getMin() || values[0] > PrimaryCCD.ImageExposureNP[0].getMax())) { LOGF_ERROR("Requested exposure value (%g) seconds out of bounds [%g,%g].", - values[0], PrimaryCCD.ImageExposureN[0].min, PrimaryCCD.ImageExposureN[0].max); - PrimaryCCD.ImageExposureNP.s = IPS_ALERT; - IDSetNumber(&PrimaryCCD.ImageExposureNP, nullptr); + values[0], PrimaryCCD.ImageExposureNP[0].getMin(), PrimaryCCD.ImageExposureNP[0].getMax()); + PrimaryCCD.ImageExposureNP.setState(IPS_ALERT); + PrimaryCCD.ImageExposureNP.apply(); return false; } if (PrimaryCCD.getFrameType() == CCDChip::BIAS_FRAME) - PrimaryCCD.ImageExposureN[0].value = ExposureTime = PrimaryCCD.ImageExposureN[0].min; + PrimaryCCD.ImageExposureNP[0].setValue(ExposureTime = PrimaryCCD.ImageExposureNP[0].getMin()); else - PrimaryCCD.ImageExposureN[0].value = ExposureTime = values[0]; + PrimaryCCD.ImageExposureNP[0].setValue(ExposureTime = values[0]); // Only abort when busy if we are not already in an exposure loops //if (PrimaryCCD.ImageExposureNP.s == IPS_BUSY && FastExposureToggleS[INDI_DISABLED].s == ISS_ON) - if (PrimaryCCD.ImageExposureNP.s == IPS_BUSY) + if (PrimaryCCD.ImageExposureNP.getState() == IPS_BUSY) { if (CanAbort() && AbortExposure() == false) DEBUG(Logger::DBG_WARNING, "Warning: Aborting exposure failed."); @@ -1109,39 +1112,39 @@ bool CCD::ISNewNumber(const char * dev, const char * name, double values[], char if (StartExposure(ExposureTime)) { - PrimaryCCD.ImageExposureNP.s = IPS_BUSY; + PrimaryCCD.ImageExposureNP.setState(IPS_BUSY); if (ExposureTime * 1000 < getCurrentPollingPeriod()) setCurrentPollingPeriod(ExposureTime * 950); } else - PrimaryCCD.ImageExposureNP.s = IPS_ALERT; - IDSetNumber(&PrimaryCCD.ImageExposureNP, nullptr); + PrimaryCCD.ImageExposureNP.setState(IPS_ALERT); + PrimaryCCD.ImageExposureNP.apply(); return true; } if (!strcmp(name, "GUIDER_EXPOSURE")) { if (GuideCCD.getFrameType() != CCDChip::BIAS_FRAME && - (values[0] < GuideCCD.ImageExposureN[0].min || values[0] > GuideCCD.ImageExposureN[0].max)) + (values[0] < GuideCCD.ImageExposureNP[0].getMin() || values[0] > GuideCCD.ImageExposureNP[0].getMax())) { LOGF_ERROR("Requested guide exposure value (%g) seconds out of bounds [%g,%g].", - values[0], GuideCCD.ImageExposureN[0].min, GuideCCD.ImageExposureN[0].max); - GuideCCD.ImageExposureNP.s = IPS_ALERT; - IDSetNumber(&GuideCCD.ImageExposureNP, nullptr); + values[0], GuideCCD.ImageExposureNP[0].getMin(), GuideCCD.ImageExposureNP[0].getMax()); + GuideCCD.ImageExposureNP.setState(IPS_ALERT); + GuideCCD.ImageExposureNP.apply(); return false; } if (GuideCCD.getFrameType() == CCDChip::BIAS_FRAME) - GuideCCD.ImageExposureN[0].value = GuiderExposureTime = GuideCCD.ImageExposureN[0].min; + GuideCCD.ImageExposureNP[0].setValue(GuiderExposureTime = GuideCCD.ImageExposureNP[0].getMin()); else - GuideCCD.ImageExposureN[0].value = GuiderExposureTime = values[0]; + GuideCCD.ImageExposureNP[0].setValue(GuiderExposureTime = values[0]); - GuideCCD.ImageExposureNP.s = IPS_BUSY; + GuideCCD.ImageExposureNP.setState(IPS_BUSY); if (StartGuideExposure(GuiderExposureTime)) - GuideCCD.ImageExposureNP.s = IPS_BUSY; + GuideCCD.ImageExposureNP.setState(IPS_BUSY); else - GuideCCD.ImageExposureNP.s = IPS_ALERT; - IDSetNumber(&GuideCCD.ImageExposureNP, nullptr); + GuideCCD.ImageExposureNP.setState(IPS_ALERT); + GuideCCD.ImageExposureNP.apply(); return true; } @@ -1326,11 +1329,11 @@ bool CCD::ISNewNumber(const char * dev, const char * name, double values[], char } #endif // Fast Exposure Count - if (!strcmp(name, FastExposureCountNP.name)) + if (FastExposureCountNP.isNameMatch(name)) { - IUUpdateNumber(&FastExposureCountNP, values, names, n); - FastExposureCountNP.s = IPS_OK; - IDSetNumber(&FastExposureCountNP, nullptr); + FastExposureCountNP.update(values, names, n); + FastExposureCountNP.setState(IPS_OK); + FastExposureCountNP.apply(); return true; } @@ -1403,35 +1406,35 @@ bool CCD::ISNewNumber(const char * dev, const char * name, double values[], char } // Primary CCD Info - if (!strcmp(name, PrimaryCCD.ImagePixelSizeNP.name)) + if (PrimaryCCD.ImagePixelSizeNP.isNameMatch(name)) { - if (IUUpdateNumber(&PrimaryCCD.ImagePixelSizeNP, values, names, n) == 0) + if (PrimaryCCD.ImagePixelSizeNP.update(values, names, n) == 0) { - PrimaryCCD.ImagePixelSizeNP.s = IPS_OK; - SetCCDParams(PrimaryCCD.ImagePixelSizeNP.np[CCDChip::CCD_MAX_X].value, - PrimaryCCD.ImagePixelSizeNP.np[CCDChip::CCD_MAX_Y].value, + PrimaryCCD.ImagePixelSizeNP.setState(IPS_OK); + SetCCDParams(PrimaryCCD.ImagePixelSizeNP[CCDChip::CCD_MAX_X].getValue(), + PrimaryCCD.ImagePixelSizeNP[CCDChip::CCD_MAX_Y].getValue(), PrimaryCCD.getBPP(), - PrimaryCCD.ImagePixelSizeNP.np[CCDChip::CCD_PIXEL_SIZE_X].value, - PrimaryCCD.ImagePixelSizeNP.np[CCDChip::CCD_PIXEL_SIZE_Y].value); - saveConfig(true, PrimaryCCD.ImagePixelSizeNP.name); + PrimaryCCD.ImagePixelSizeNP[CCDChip::CCD_PIXEL_SIZE_X].getValue(), + PrimaryCCD.ImagePixelSizeNP[CCDChip::CCD_PIXEL_SIZE_Y].getValue()); + saveConfig(true, PrimaryCCD.ImagePixelSizeNP.getName()); } else - PrimaryCCD.ImagePixelSizeNP.s = IPS_ALERT; + PrimaryCCD.ImagePixelSizeNP.setState(IPS_ALERT); - IDSetNumber(&PrimaryCCD.ImagePixelSizeNP, nullptr); + PrimaryCCD.ImagePixelSizeNP.apply(); return true; } // Guide CCD Info - if (!strcmp(name, GuideCCD.ImagePixelSizeNP.name)) - { - IUUpdateNumber(&GuideCCD.ImagePixelSizeNP, values, names, n); - GuideCCD.ImagePixelSizeNP.s = IPS_OK; - SetGuiderParams(GuideCCD.ImagePixelSizeNP.np[CCDChip::CCD_MAX_X].value, - GuideCCD.ImagePixelSizeNP.np[CCDChip::CCD_MAX_Y].value, GuideCCD.getBPP(), - GuideCCD.ImagePixelSizeNP.np[CCDChip::CCD_PIXEL_SIZE_X].value, - GuideCCD.ImagePixelSizeNP.np[CCDChip::CCD_PIXEL_SIZE_Y].value); - IDSetNumber(&GuideCCD.ImagePixelSizeNP, nullptr); + if (GuideCCD.ImagePixelSizeNP.isNameMatch(name)) + { + GuideCCD.ImagePixelSizeNP.update(values, names, n); + GuideCCD.ImagePixelSizeNP.setState(IPS_OK); + SetGuiderParams(GuideCCD.ImagePixelSizeNP[CCDChip::CCD_MAX_X].getValue(), + GuideCCD.ImagePixelSizeNP[CCDChip::CCD_MAX_Y].getValue(), GuideCCD.getBPP(), + GuideCCD.ImagePixelSizeNP[CCDChip::CCD_PIXEL_SIZE_X].getValue(), + GuideCCD.ImagePixelSizeNP[CCDChip::CCD_PIXEL_SIZE_Y].getValue()); + GuideCCD.ImagePixelSizeNP.apply(); saveConfig(true); return true; } @@ -1515,8 +1518,8 @@ bool CCD::ISNewSwitch(const char * dev, const char * name, ISState * states, cha if (FastExposureToggleSP[INDI_DISABLED].getState() == ISS_ON) { - FastExposureCountNP.s = IPS_IDLE; - IDSetNumber(&FastExposureCountNP, nullptr); + FastExposureCountNP.setState(IPS_IDLE); + FastExposureCountNP.apply(); m_UploadTime = 0; if (PrimaryCCD.isExposing()) AbortExposure(); @@ -1597,28 +1600,28 @@ bool CCD::ISNewSwitch(const char * dev, const char * name, ISState * states, cha if (AbortExposure()) { PrimaryCCD.AbortExposureSP.s = IPS_OK; - PrimaryCCD.ImageExposureNP.s = IPS_IDLE; - PrimaryCCD.ImageExposureN[0].value = 0; + PrimaryCCD.ImageExposureNP.setState(IPS_IDLE); + PrimaryCCD.ImageExposureNP[0].setValue(0); } else { PrimaryCCD.AbortExposureSP.s = IPS_ALERT; - PrimaryCCD.ImageExposureNP.s = IPS_ALERT; + PrimaryCCD.ImageExposureNP.setState(IPS_ALERT); } setCurrentPollingPeriod(getPollingPeriod()); // Fast Exposure Count - if (FastExposureCountNP.s == IPS_BUSY) + if (FastExposureCountNP.getState() == IPS_BUSY) { m_UploadTime = 0; - FastExposureCountNP.s = IPS_IDLE; - FastExposureCountN[0].value = 1; - IDSetNumber(&FastExposureCountNP, nullptr); + FastExposureCountNP.setState(IPS_IDLE); + FastExposureCountNP[0].setValue(1); + FastExposureCountNP.apply(); } IDSetSwitch(&PrimaryCCD.AbortExposureSP, nullptr); - IDSetNumber(&PrimaryCCD.ImageExposureNP, nullptr); + PrimaryCCD.ImageExposureNP.apply(); return true; } @@ -1631,17 +1634,17 @@ bool CCD::ISNewSwitch(const char * dev, const char * name, ISState * states, cha if (AbortGuideExposure()) { GuideCCD.AbortExposureSP.s = IPS_OK; - GuideCCD.ImageExposureNP.s = IPS_IDLE; - GuideCCD.ImageExposureN[0].value = 0; + GuideCCD.ImageExposureNP.setState(IPS_IDLE); + GuideCCD.ImageExposureNP[0].setValue(0); } else { GuideCCD.AbortExposureSP.s = IPS_ALERT; - GuideCCD.ImageExposureNP.s = IPS_ALERT; + GuideCCD.ImageExposureNP.setState(IPS_ALERT); } IDSetSwitch(&GuideCCD.AbortExposureSP, nullptr); - IDSetNumber(&GuideCCD.ImageExposureNP, nullptr); + GuideCCD.ImageExposureNP.apply(); return true; } @@ -2704,11 +2707,11 @@ bool CCD::processFastExposure(CCDChip * targetChip) double duration = targetChip->getExposureDuration(); // Check fast exposure count - if (FastExposureCountN[0].value > 1) + if (FastExposureCountNP[0].getValue() > 1) { if (UploadS[UPLOAD_LOCAL].s != ISS_ON) { - if (FastExposureCountNP.s != IPS_BUSY) + if (FastExposureCountNP.getState() != IPS_BUSY) { FastExposureToggleStartup = std::chrono::system_clock::now(); } @@ -2724,16 +2727,16 @@ bool CCD::processFastExposure(CCDChip * targetChip) } } - FastExposureCountNP.s = IPS_BUSY; - FastExposureCountN[0].value--; - IDSetNumber(&FastExposureCountNP, nullptr); + FastExposureCountNP.setState(IPS_BUSY); + FastExposureCountNP[0].setValue(FastExposureCountNP[0].getValue() - 1); + FastExposureCountNP.apply(); if (UploadS[UPLOAD_LOCAL].s == ISS_ON || m_UploadTime < duration) { if (StartExposure(duration)) - PrimaryCCD.ImageExposureNP.s = IPS_BUSY; + PrimaryCCD.ImageExposureNP.setState(IPS_BUSY); else - PrimaryCCD.ImageExposureNP.s = IPS_ALERT; + PrimaryCCD.ImageExposureNP.setState(IPS_ALERT); if (duration * 1000 < getCurrentPollingPeriod()) setCurrentPollingPeriod(duration * 950); } @@ -2742,11 +2745,11 @@ bool CCD::processFastExposure(CCDChip * targetChip) LOGF_ERROR("Rapid exposure not possible since upload time is %.2f seconds while exposure time is %.2f seconds.", m_UploadTime, duration); - PrimaryCCD.ImageExposureNP.s = IPS_ALERT; - IDSetNumber(&PrimaryCCD.ImageExposureNP, nullptr); - FastExposureCountN[0].value = 1; - FastExposureCountNP.s = IPS_IDLE; - IDSetNumber(&FastExposureCountNP, nullptr); + PrimaryCCD.ImageExposureNP.setState(IPS_ALERT); + PrimaryCCD.ImageExposureNP.apply(); + FastExposureCountNP[0].setValue(1); + FastExposureCountNP.setState(IPS_IDLE); + FastExposureCountNP.apply(); m_UploadTime = 0; return false; } @@ -2754,8 +2757,8 @@ bool CCD::processFastExposure(CCDChip * targetChip) else { m_UploadTime = 0; - FastExposureCountNP.s = IPS_IDLE; - IDSetNumber(&FastExposureCountNP, nullptr); + FastExposureCountNP.setState(IPS_IDLE); + FastExposureCountNP.apply(); } } diff --git a/libs/indibase/indiccd.h b/libs/indibase/indiccd.h index d3816d80ce..579d97af5f 100644 --- a/libs/indibase/indiccd.h +++ b/libs/indibase/indiccd.h @@ -639,16 +639,19 @@ class CCD : public DefaultDevice, GuiderInterface * ActiveDeviceTP defines snoop devices and the driver listens to this property emitted * by the mount driver if specified. It is important to generate a proper FITS header. */ - INumberVectorProperty EqNP; - INumber EqN[2]; + INDI::PropertyNumber EqNP {2}; /** * @brief J200EqNP Snoop property to read the equatorial J2000 coordinates of the mount. * ActiveDeviceTP defines snoop devices and the driver listens to this property emitted * by the mount driver if specified. It is important to generate a proper FITS header. */ - INumberVectorProperty J2000EqNP; - INumber J2000EqN[2]; + INDI::PropertyNumber J2000EqNP {2}; + enum + { + Ra, + DEC, + }; /** * @brief ActiveDeviceTP defines 4 devices the camera driver can listen to (snoop) for @@ -733,8 +736,7 @@ class CCD : public DefaultDevice, GuiderInterface }; // Websocket Support - ISwitch WebSocketS[2]; - ISwitchVectorProperty WebSocketSP; + INDI::PropertySwitch WebSocketSP {2}; enum { WEBSOCKET_ENABLED, @@ -743,8 +745,7 @@ class CCD : public DefaultDevice, GuiderInterface // Websocket Settings - INumber WebSocketSettingsN[1]; - INumberVectorProperty WebSocketSettingsNP; + INDI::PropertyNumber WebSocketSettingsNP {1}; enum { WS_SETTINGS_PORT, @@ -764,8 +765,7 @@ class CCD : public DefaultDevice, GuiderInterface INDI::PropertySwitch FastExposureToggleSP {2}; // Fast Exposure Frame Count - INumber FastExposureCountN[1]; - INumberVectorProperty FastExposureCountNP; + INDI::PropertyNumber FastExposureCountNP {1}; double m_UploadTime = { 0 }; std::chrono::system_clock::time_point FastExposureToggleStartup; diff --git a/libs/indibase/indiccdchip.cpp b/libs/indibase/indiccdchip.cpp index e1a4892326..29121cb626 100644 --- a/libs/indibase/indiccdchip.cpp +++ b/libs/indibase/indiccdchip.cpp @@ -93,10 +93,10 @@ void CCDChip::setResolution(uint32_t x, uint32_t y) XRes = x; YRes = y; - ImagePixelSizeN[0].value = x; - ImagePixelSizeN[1].value = y; + ImagePixelSizeNP[0].setValue(x); + ImagePixelSizeNP[1].setValue(y); - IDSetNumber(&ImagePixelSizeNP, nullptr); + ImagePixelSizeNP.apply(); ImageFrameNP[FRAME_X].setMin(0); ImageFrameNP[FRAME_X].setMax(x - 1); @@ -152,15 +152,15 @@ void CCDChip::setMinMaxStep(const char *property, const char *element, double mi } }; - if (!strcmp(property, ImageExposureNP.name)) - nvp = &ImageExposureNP; + if (ImageExposureNP.isNameMatch(property)) + updateMinMaxStep(ImageExposureNP); else if (ImageFrameNP.isNameMatch(property)) updateMinMaxStep(ImageFrameNP); else if (ImageBinNP.isNameMatch(property)) updateMinMaxStep(ImageBinNP); - else if (!strcmp(property, ImagePixelSizeNP.name)) - nvp = &ImagePixelSizeNP; + else if (ImagePixelSizeNP.isNameMatch(property)) + updateMinMaxStep(ImagePixelSizeNP); // else if (!strcmp(property, RapidGuideDataNP.name)) // nvp = &RapidGuideDataNP; else @@ -183,20 +183,20 @@ void CCDChip::setPixelSize(double x, double y) PixelSizeX = x; PixelSizeY = y; - ImagePixelSizeN[2].value = x; - ImagePixelSizeN[3].value = x; - ImagePixelSizeN[4].value = y; + ImagePixelSizeNP[2].setValue(x); + ImagePixelSizeNP[3].setValue(x); + ImagePixelSizeNP[4].setValue(y); - IDSetNumber(&ImagePixelSizeNP, nullptr); + ImagePixelSizeNP.apply(); } void CCDChip::setBPP(uint8_t bbp) { BitsPerPixel = bbp; - ImagePixelSizeN[5].value = BitsPerPixel; + ImagePixelSizeNP[5].setValue(BitsPerPixel); - IDSetNumber(&ImagePixelSizeNP, nullptr); + ImagePixelSizeNP.apply(); } void CCDChip::setFrameBufferSize(uint32_t nbuf, bool allocMem) @@ -223,16 +223,16 @@ void CCDChip::setFrameBufferSize(uint32_t nbuf, bool allocMem) void CCDChip::setExposureLeft(double duration) { - ImageExposureNP.s = IPS_BUSY; - ImageExposureN[0].value = duration; - IDSetNumber(&ImageExposureNP, nullptr); + ImageExposureNP.setState(IPS_BUSY); + ImageExposureNP[0].setValue(duration); + ImageExposureNP.apply(); } void CCDChip::setExposureComplete() { - ImageExposureNP.s = IPS_OK; - ImageExposureN[0].value = 0; - IDSetNumber(&ImageExposureNP, nullptr); + ImageExposureNP.setState(IPS_OK); + ImageExposureNP[0].setValue(0); + ImageExposureNP.apply(); } void CCDChip::setExposureDuration(double duration) @@ -275,8 +275,8 @@ const char *CCDChip::getExposureStartTime() void CCDChip::setExposureFailed() { - ImageExposureNP.s = IPS_ALERT; - IDSetNumber(&ImageExposureNP, nullptr); + ImageExposureNP.setState(IPS_ALERT); + ImageExposureNP.apply(); } int CCDChip::getNAxis() const diff --git a/libs/indibase/indiccdchip.h b/libs/indibase/indiccdchip.h index 469a7cc652..1e7cf3d5e5 100644 --- a/libs/indibase/indiccdchip.h +++ b/libs/indibase/indiccdchip.h @@ -185,7 +185,7 @@ class CCDChip */ inline double getExposureLeft() const { - return ImageExposureN[0].value; + return ImageExposureNP[0].getValue(); } /** @@ -264,7 +264,7 @@ class CCDChip */ INumberVectorProperty *getCCDInfo() { - return &ImagePixelSizeNP; + return ImagePixelSizeNP; } /** @@ -399,7 +399,7 @@ class CCDChip */ bool isExposing() const { - return (ImageExposureNP.s == IPS_BUSY); + return (ImageExposureNP.getState() == IPS_BUSY); } /** @@ -486,8 +486,7 @@ class CCDChip ///////////////////////////////////////////////////////////////////////////////////////// /// Image Exposure Duration ///////////////////////////////////////////////////////////////////////////////////////// - INumberVectorProperty ImageExposureNP; - INumber ImageExposureN[1]; + INDI::PropertyNumber ImageExposureNP {1}; ///////////////////////////////////////////////////////////////////////////////////////// /// Abort Exposure @@ -512,8 +511,7 @@ class CCDChip ///////////////////////////////////////////////////////////////////////////////////////// /// Image Resolution & Pixel Size data ///////////////////////////////////////////////////////////////////////////////////////// - INumberVectorProperty ImagePixelSizeNP; - INumber ImagePixelSizeN[6]; + INDI::PropertyNumber ImagePixelSizeNP {6}; ///////////////////////////////////////////////////////////////////////////////////////// /// Frame Type (Light, Bias..etc) From 34cbec4612cb90e101b5c12e76004665c20dd08e Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Mon, 9 Sep 2024 12:00:16 +0300 Subject: [PATCH 08/23] Migrate AbortExposureSP Property --- libs/indibase/indiccd.cpp | 36 ++++++++++++++++++------------------ libs/indibase/indiccdchip.h | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index a43928b240..25ded2f8b2 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -190,8 +190,8 @@ bool CCD::initProperties() "Expose", MAIN_CONTROL_TAB, IP_RW, 60, IPS_IDLE); // Primary CCD Abort - IUFillSwitch(&PrimaryCCD.AbortExposureS[0], "ABORT", "Abort", ISS_OFF); - IUFillSwitchVector(&PrimaryCCD.AbortExposureSP, PrimaryCCD.AbortExposureS, 1, getDeviceName(), "CCD_ABORT_EXPOSURE", + PrimaryCCD.AbortExposureSP[0].fill("ABORT", "Abort", ISS_OFF); + PrimaryCCD.AbortExposureSP.fill(getDeviceName(), "CCD_ABORT_EXPOSURE", "Abort", MAIN_CONTROL_TAB, IP_RW, ISR_ATMOST1, 60, IPS_IDLE); // Primary CCD Binning @@ -300,8 +300,8 @@ bool CCD::initProperties() GuideCCD.ImageExposureNP.fill(getDeviceName(), "GUIDER_EXPOSURE", "Guide Head", MAIN_CONTROL_TAB, IP_RW, 60, IPS_IDLE); - IUFillSwitch(&GuideCCD.AbortExposureS[0], "ABORT", "Abort", ISS_OFF); - IUFillSwitchVector(&GuideCCD.AbortExposureSP, GuideCCD.AbortExposureS, 1, getDeviceName(), "GUIDER_ABORT_EXPOSURE", + GuideCCD.AbortExposureSP[0].fill("ABORT", "Abort", ISS_OFF); + GuideCCD.AbortExposureSP.fill(getDeviceName(), "GUIDER_ABORT_EXPOSURE", "Abort", MAIN_CONTROL_TAB, IP_RW, ISR_ATMOST1, 60, IPS_IDLE); IUFillSwitch(&GuideCCD.CompressS[INDI_ENABLED], "INDI_ENABLED", "Enabled", ISS_OFF); @@ -533,7 +533,7 @@ bool CCD::updateProperties() defineProperty(PrimaryCCD.ImageExposureNP); if (CanAbort()) - defineProperty(&PrimaryCCD.AbortExposureSP); + defineProperty(PrimaryCCD.AbortExposureSP); if (CanSubFrame() == false) PrimaryCCD.ImageFrameNP.setPermission(IP_RO); @@ -550,7 +550,7 @@ bool CCD::updateProperties() { defineProperty(GuideCCD.ImageExposureNP); if (CanAbort()) - defineProperty(&GuideCCD.AbortExposureSP); + defineProperty(GuideCCD.AbortExposureSP); if (CanSubFrame() == false) GuideCCD.ImageFrameNP.setPermission(IP_RO); defineProperty(GuideCCD.ImageFrameNP); @@ -641,7 +641,7 @@ bool CCD::updateProperties() deleteProperty(PrimaryCCD.ImageExposureNP); if (CanAbort()) - deleteProperty(PrimaryCCD.AbortExposureSP.name); + deleteProperty(PrimaryCCD.AbortExposureSP); deleteProperty(PrimaryCCD.FitsBP.name); deleteProperty(PrimaryCCD.CompressSP.name); @@ -660,7 +660,7 @@ bool CCD::updateProperties() { deleteProperty(GuideCCD.ImageExposureNP); if (CanAbort()) - deleteProperty(GuideCCD.AbortExposureSP.name); + deleteProperty(GuideCCD.AbortExposureSP); deleteProperty(GuideCCD.ImageFrameNP); deleteProperty(GuideCCD.ImagePixelSizeNP); @@ -1593,19 +1593,19 @@ bool CCD::ISNewSwitch(const char * dev, const char * name, ISState * states, cha } // Primary Chip Abort Expsoure - if (strcmp(name, PrimaryCCD.AbortExposureSP.name) == 0) + if (PrimaryCCD.AbortExposureSP.isNameMatch(name)) { - IUResetSwitch(&PrimaryCCD.AbortExposureSP); + PrimaryCCD.AbortExposureSP.reset(); if (AbortExposure()) { - PrimaryCCD.AbortExposureSP.s = IPS_OK; + PrimaryCCD.AbortExposureSP.setState(IPS_OK); PrimaryCCD.ImageExposureNP.setState(IPS_IDLE); PrimaryCCD.ImageExposureNP[0].setValue(0); } else { - PrimaryCCD.AbortExposureSP.s = IPS_ALERT; + PrimaryCCD.AbortExposureSP.setState(IPS_ALERT); PrimaryCCD.ImageExposureNP.setState(IPS_ALERT); } @@ -1620,30 +1620,30 @@ bool CCD::ISNewSwitch(const char * dev, const char * name, ISState * states, cha FastExposureCountNP.apply(); } - IDSetSwitch(&PrimaryCCD.AbortExposureSP, nullptr); + PrimaryCCD.AbortExposureSP.apply(); PrimaryCCD.ImageExposureNP.apply(); return true; } // Guide Chip Abort Exposure - if (strcmp(name, GuideCCD.AbortExposureSP.name) == 0) + if (GuideCCD.AbortExposureSP.isNameMatch(name)) { - IUResetSwitch(&GuideCCD.AbortExposureSP); + GuideCCD.AbortExposureSP.reset(); if (AbortGuideExposure()) { - GuideCCD.AbortExposureSP.s = IPS_OK; + GuideCCD.AbortExposureSP.setState(IPS_OK); GuideCCD.ImageExposureNP.setState(IPS_IDLE); GuideCCD.ImageExposureNP[0].setValue(0); } else { - GuideCCD.AbortExposureSP.s = IPS_ALERT; + GuideCCD.AbortExposureSP.setState(IPS_ALERT); GuideCCD.ImageExposureNP.setState(IPS_ALERT); } - IDSetSwitch(&GuideCCD.AbortExposureSP, nullptr); + GuideCCD.AbortExposureSP.apply(); GuideCCD.ImageExposureNP.apply(); return true; diff --git a/libs/indibase/indiccdchip.h b/libs/indibase/indiccdchip.h index 1e7cf3d5e5..233c7de976 100644 --- a/libs/indibase/indiccdchip.h +++ b/libs/indibase/indiccdchip.h @@ -20,6 +20,7 @@ #include "indiapi.h" #include "indidriver.h" +#include #include "indipropertynumber.h" #include @@ -491,8 +492,7 @@ class CCDChip ///////////////////////////////////////////////////////////////////////////////////////// /// Abort Exposure ///////////////////////////////////////////////////////////////////////////////////////// - ISwitchVectorProperty AbortExposureSP; - ISwitch AbortExposureS[1]; + INDI::PropertySwitch AbortExposureSP {1}; ///////////////////////////////////////////////////////////////////////////////////////// /// Image Frame ROI From 2f2bcd51ae90ef4b85bebcd8cea09ae1153b0bcf Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Mon, 9 Sep 2024 13:28:53 +0300 Subject: [PATCH 09/23] Migrate UploadSP Property --- libs/indibase/indiccd.cpp | 44 +++++++++++++++++++-------------------- libs/indibase/indiccd.h | 3 +-- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index 25ded2f8b2..7efdd019dc 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -384,10 +384,10 @@ bool CCD::initProperties() /**********************************************/ // Upload Mode - IUFillSwitch(&UploadS[UPLOAD_CLIENT], "UPLOAD_CLIENT", "Client", ISS_ON); - IUFillSwitch(&UploadS[UPLOAD_LOCAL], "UPLOAD_LOCAL", "Local", ISS_OFF); - IUFillSwitch(&UploadS[UPLOAD_BOTH], "UPLOAD_BOTH", "Both", ISS_OFF); - IUFillSwitchVector(&UploadSP, UploadS, 3, getDeviceName(), "UPLOAD_MODE", "Upload", OPTIONS_TAB, IP_RW, ISR_1OFMANY, + UploadSP[UPLOAD_CLIENT].fill("UPLOAD_CLIENT", "Client", ISS_ON); + UploadSP[UPLOAD_LOCAL].fill("UPLOAD_LOCAL", "Local", ISS_OFF); + UploadSP[UPLOAD_BOTH].fill("UPLOAD_BOTH", "Both", ISS_OFF); + UploadSP.fill(getDeviceName(), "UPLOAD_MODE", "Upload", OPTIONS_TAB, IP_RW, ISR_1OFMANY, 0, IPS_IDLE); // Upload Settings @@ -611,7 +611,7 @@ bool CCD::updateProperties() defineProperty(ScopeInfoNP); defineProperty(WorldCoordSP); - defineProperty(&UploadSP); + defineProperty(UploadSP); if (UploadSettingsT[UPLOAD_DIR].text == nullptr) IUSaveText(&UploadSettingsT[UPLOAD_DIR], getenv("HOME")); @@ -698,7 +698,7 @@ bool CCD::updateProperties() deleteProperty(CCDRotationNP); } deleteProperty(WorldCoordSP); - deleteProperty(UploadSP.name); + deleteProperty(UploadSP); deleteProperty(UploadSettingsTP.name); #ifdef HAVE_WEBSOCKET @@ -1469,20 +1469,20 @@ bool CCD::ISNewSwitch(const char * dev, const char * name, ISState * states, cha if (dev != nullptr && strcmp(dev, getDeviceName()) == 0) { // Upload Mode - if (!strcmp(name, UploadSP.name)) + if (UploadSP.isNameMatch(name)) { - int prevMode = IUFindOnSwitchIndex(&UploadSP); - IUUpdateSwitch(&UploadSP, states, names, n); + int prevMode = UploadSP.findOnSwitchIndex(); + UploadSP.update(states, names, n); - if (UpdateCCDUploadMode(static_cast(IUFindOnSwitchIndex(&UploadSP)))) + if (UpdateCCDUploadMode(static_cast(UploadSP.findOnSwitchIndex()))) { - if (UploadS[UPLOAD_CLIENT].s == ISS_ON) + if (UploadSP[UPLOAD_CLIENT].getState() == ISS_ON) { DEBUG(Logger::DBG_SESSION, "Upload settings set to client only."); if (prevMode != 0) deleteProperty(FileNameTP.name); } - else if (UploadS[UPLOAD_LOCAL].s == ISS_ON) + else if (UploadSP[UPLOAD_LOCAL].getState() == ISS_ON) { DEBUG(Logger::DBG_SESSION, "Upload settings set to local only."); defineProperty(&FileNameTP); @@ -1493,16 +1493,16 @@ bool CCD::ISNewSwitch(const char * dev, const char * name, ISState * states, cha defineProperty(&FileNameTP); } - UploadSP.s = IPS_OK; + UploadSP.setState(IPS_OK); } else { - IUResetSwitch(&UploadSP); - UploadS[prevMode].s = ISS_ON; - UploadSP.s = IPS_ALERT; + UploadSP.reset(); + UploadSP[prevMode].setState(ISS_ON); + UploadSP.setState(IPS_ALERT); } - IDSetSwitch(&UploadSP, nullptr); + UploadSP.apply(); return true; } @@ -2274,8 +2274,8 @@ bool CCD::ExposureCompletePrivate(CCDChip * targetChip) if (processFastExposure(targetChip) == false) return false; - bool sendImage = (UploadS[UPLOAD_CLIENT].s == ISS_ON || UploadS[UPLOAD_BOTH].s == ISS_ON); - bool saveImage = (UploadS[UPLOAD_LOCAL].s == ISS_ON || UploadS[UPLOAD_BOTH].s == ISS_ON); + bool sendImage = (UploadSP[UPLOAD_CLIENT].getState() == ISS_ON || UploadSP[UPLOAD_BOTH].getState() == ISS_ON); + bool saveImage = (UploadSP[UPLOAD_LOCAL].getState() == ISS_ON || UploadSP[UPLOAD_BOTH].getState() == ISS_ON); // Do not send or save an empty image. if (targetChip->getFrameBufferSize() == 0) @@ -2709,7 +2709,7 @@ bool CCD::processFastExposure(CCDChip * targetChip) // Check fast exposure count if (FastExposureCountNP[0].getValue() > 1) { - if (UploadS[UPLOAD_LOCAL].s != ISS_ON) + if (UploadSP[UPLOAD_LOCAL].getState() != ISS_ON) { if (FastExposureCountNP.getState() != IPS_BUSY) { @@ -2731,7 +2731,7 @@ bool CCD::processFastExposure(CCDChip * targetChip) FastExposureCountNP[0].setValue(FastExposureCountNP[0].getValue() - 1); FastExposureCountNP.apply(); - if (UploadS[UPLOAD_LOCAL].s == ISS_ON || m_UploadTime < duration) + if (UploadSP[UPLOAD_LOCAL].getState() == ISS_ON || m_UploadTime < duration) { if (StartExposure(duration)) PrimaryCCD.ImageExposureNP.setState(IPS_BUSY); @@ -2790,7 +2790,7 @@ bool CCD::saveConfigItems(FILE * fp) DefaultDevice::saveConfigItems(fp); ActiveDeviceTP.save(fp); - IUSaveConfigSwitch(fp, &UploadSP); + UploadSP.save(fp); IUSaveConfigText(fp, &UploadSettingsTP); FastExposureToggleSP.save(fp); diff --git a/libs/indibase/indiccd.h b/libs/indibase/indiccd.h index 579d97af5f..2c52501a65 100644 --- a/libs/indibase/indiccd.h +++ b/libs/indibase/indiccd.h @@ -716,8 +716,7 @@ class CCD : public DefaultDevice, GuiderInterface FORMAT_XISF /*!< Save Image as XISF format */ }; - ISwitch UploadS[3]; - ISwitchVectorProperty UploadSP; + INDI::PropertySwitch UploadSP {3}; IText UploadSettingsT[2] {}; ITextVectorProperty UploadSettingsTP; From 02a028f134c7249ab8b59b07c9da3c515603ca93 Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Mon, 9 Sep 2024 13:42:22 +0300 Subject: [PATCH 10/23] Migrate CompressSP Property --- libs/indibase/indiccd.cpp | 44 ++++++++++++++++++------------------- libs/indibase/indiccdchip.h | 3 +-- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index 7efdd019dc..dae116da3b 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -215,9 +215,9 @@ bool CCD::initProperties() "CCD Information", IMAGE_INFO_TAB, IP_RO, 60, IPS_IDLE); // Primary CCD Compression Options - IUFillSwitch(&PrimaryCCD.CompressS[INDI_ENABLED], "INDI_ENABLED", "Enabled", ISS_OFF); - IUFillSwitch(&PrimaryCCD.CompressS[INDI_DISABLED], "INDI_DISABLED", "Disabled", ISS_ON); - IUFillSwitchVector(&PrimaryCCD.CompressSP, PrimaryCCD.CompressS, 2, getDeviceName(), "CCD_COMPRESSION", "Compression", + PrimaryCCD.CompressSP[INDI_ENABLED].fill("INDI_ENABLED", "Enabled", ISS_OFF); + PrimaryCCD.CompressSP[INDI_DISABLED].fill("INDI_DISABLED", "Disabled", ISS_ON); + PrimaryCCD.CompressSP.fill(getDeviceName(), "CCD_COMPRESSION", "Compression", IMAGE_SETTINGS_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE); PrimaryCCD.SendCompressed = false; @@ -304,9 +304,9 @@ bool CCD::initProperties() GuideCCD.AbortExposureSP.fill(getDeviceName(), "GUIDER_ABORT_EXPOSURE", "Abort", MAIN_CONTROL_TAB, IP_RW, ISR_ATMOST1, 60, IPS_IDLE); - IUFillSwitch(&GuideCCD.CompressS[INDI_ENABLED], "INDI_ENABLED", "Enabled", ISS_OFF); - IUFillSwitch(&GuideCCD.CompressS[INDI_DISABLED], "INDI_DISABLED", "Disabled", ISS_ON); - IUFillSwitchVector(&GuideCCD.CompressSP, GuideCCD.CompressS, 2, getDeviceName(), "GUIDER_COMPRESSION", "Compression", + GuideCCD.CompressSP[INDI_ENABLED].fill("INDI_ENABLED", "Enabled", ISS_OFF); + GuideCCD.CompressSP[INDI_DISABLED].fill("INDI_DISABLED", "Disabled", ISS_ON); + GuideCCD.CompressSP.fill(getDeviceName(), "GUIDER_COMPRESSION", "Compression", GUIDE_HEAD_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE); GuideCCD.SendCompressed = false; @@ -572,11 +572,11 @@ bool CCD::updateProperties() if (CanBin()) defineProperty(GuideCCD.ImageBinNP); } - defineProperty(&PrimaryCCD.CompressSP); + defineProperty(PrimaryCCD.CompressSP); defineProperty(&PrimaryCCD.FitsBP); if (HasGuideHead()) { - defineProperty(&GuideCCD.CompressSP); + defineProperty(GuideCCD.CompressSP); defineProperty(&GuideCCD.FitsBP); } if (HasST4Port()) @@ -643,7 +643,7 @@ bool CCD::updateProperties() if (CanAbort()) deleteProperty(PrimaryCCD.AbortExposureSP); deleteProperty(PrimaryCCD.FitsBP.name); - deleteProperty(PrimaryCCD.CompressSP.name); + deleteProperty(PrimaryCCD.CompressSP); #if 0 deleteProperty(PrimaryCCD.RapidGuideSP.name); @@ -667,7 +667,7 @@ bool CCD::updateProperties() deleteProperty(GuideCCD.FitsBP.name); if (CanBin()) deleteProperty(GuideCCD.ImageBinNP); - deleteProperty(GuideCCD.CompressSP.name); + deleteProperty(GuideCCD.CompressSP); deleteProperty(GuideCCD.FrameTypeSP.name); #if 0 @@ -1650,22 +1650,22 @@ bool CCD::ISNewSwitch(const char * dev, const char * name, ISState * states, cha } // Primary Chip Compression - if (strcmp(name, PrimaryCCD.CompressSP.name) == 0) + if (PrimaryCCD.CompressSP.isNameMatch(name)) { - IUUpdateSwitch(&PrimaryCCD.CompressSP, states, names, n); - PrimaryCCD.CompressSP.s = IPS_OK; - IDSetSwitch(&PrimaryCCD.CompressSP, nullptr); - PrimaryCCD.SendCompressed = PrimaryCCD.CompressS[INDI_ENABLED].s == ISS_ON; + PrimaryCCD.CompressSP.update(states, names, n); + PrimaryCCD.CompressSP.setState(IPS_OK); + PrimaryCCD.CompressSP.apply(); + PrimaryCCD.SendCompressed = PrimaryCCD.CompressSP[INDI_ENABLED].getState() == ISS_ON; return true; } // Guide Chip Compression - if (strcmp(name, GuideCCD.CompressSP.name) == 0) + if (GuideCCD.CompressSP.isNameMatch(name)) { - IUUpdateSwitch(&GuideCCD.CompressSP, states, names, n); - GuideCCD.CompressSP.s = IPS_OK; - IDSetSwitch(&GuideCCD.CompressSP, nullptr); - GuideCCD.SendCompressed = GuideCCD.CompressS[INDI_ENABLED].s == ISS_ON; + GuideCCD.CompressSP.update(states, names, n); + GuideCCD.CompressSP.setState(IPS_OK); + GuideCCD.CompressSP.apply(); + GuideCCD.SendCompressed = GuideCCD.CompressSP[INDI_ENABLED].getState() == ISS_ON; return true; } @@ -2794,7 +2794,7 @@ bool CCD::saveConfigItems(FILE * fp) IUSaveConfigText(fp, &UploadSettingsTP); FastExposureToggleSP.save(fp); - IUSaveConfigSwitch(fp, &PrimaryCCD.CompressSP); + PrimaryCCD.CompressSP.save(fp); if (PrimaryCCD.getCCDInfo()->p != IP_RO) IUSaveConfigNumber(fp, PrimaryCCD.getCCDInfo()); @@ -2807,7 +2807,7 @@ bool CCD::saveConfigItems(FILE * fp) if (HasGuideHead()) { - IUSaveConfigSwitch(fp, &GuideCCD.CompressSP); + GuideCCD.CompressSP.save(fp); GuideCCD.ImageBinNP.save(fp); } diff --git a/libs/indibase/indiccdchip.h b/libs/indibase/indiccdchip.h index 233c7de976..f4a7a7e6c9 100644 --- a/libs/indibase/indiccdchip.h +++ b/libs/indibase/indiccdchip.h @@ -522,8 +522,7 @@ class CCDChip ///////////////////////////////////////////////////////////////////////////////////////// /// Compression Toggle ///////////////////////////////////////////////////////////////////////////////////////// - ISwitchVectorProperty CompressSP; - ISwitch CompressS[2]; + INDI::PropertySwitch CompressSP {2}; ///////////////////////////////////////////////////////////////////////////////////////// /// FITS Binary Data From 2fe337c85e637866cb186836302aff6665739a66 Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Mon, 9 Sep 2024 14:01:27 +0300 Subject: [PATCH 11/23] Migrate FrameTypeSP Property --- libs/indibase/indiccd.cpp | 64 +++++++++++++++++------------------ libs/indibase/indiccdchip.cpp | 2 +- libs/indibase/indiccdchip.h | 3 +- 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index dae116da3b..3e2e71a0ac 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -177,11 +177,11 @@ bool CCD::initProperties() IMAGE_SETTINGS_TAB, IP_RW, 60, IPS_IDLE); // Primary CCD Frame Type - IUFillSwitch(&PrimaryCCD.FrameTypeS[CCDChip::LIGHT_FRAME], "FRAME_LIGHT", "Light", ISS_ON); - IUFillSwitch(&PrimaryCCD.FrameTypeS[CCDChip::BIAS_FRAME], "FRAME_BIAS", "Bias", ISS_OFF); - IUFillSwitch(&PrimaryCCD.FrameTypeS[CCDChip::DARK_FRAME], "FRAME_DARK", "Dark", ISS_OFF); - IUFillSwitch(&PrimaryCCD.FrameTypeS[CCDChip::FLAT_FRAME], "FRAME_FLAT", "Flat", ISS_OFF); - IUFillSwitchVector(&PrimaryCCD.FrameTypeSP, PrimaryCCD.FrameTypeS, 4, getDeviceName(), "CCD_FRAME_TYPE", + PrimaryCCD.FrameTypeSP[CCDChip::LIGHT_FRAME].fill("FRAME_LIGHT", "Light", ISS_ON); + PrimaryCCD.FrameTypeSP[CCDChip::BIAS_FRAME].fill("FRAME_BIAS", "Bias", ISS_OFF); + PrimaryCCD.FrameTypeSP[CCDChip::DARK_FRAME].fill("FRAME_DARK", "Dark", ISS_OFF); + PrimaryCCD.FrameTypeSP[CCDChip::FLAT_FRAME].fill("FRAME_FLAT", "Flat", ISS_OFF); + PrimaryCCD.FrameTypeSP.fill(getDeviceName(), "CCD_FRAME_TYPE", "Type", IMAGE_SETTINGS_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE); // Primary CCD Exposure @@ -289,11 +289,11 @@ bool CCD::initProperties() GuideCCD.ImagePixelSizeNP.fill(getDeviceName(), "GUIDER_INFO", "Info", IMAGE_INFO_TAB, IP_RO, 60, IPS_IDLE); - IUFillSwitch(&GuideCCD.FrameTypeS[0], "FRAME_LIGHT", "Light", ISS_ON); - IUFillSwitch(&GuideCCD.FrameTypeS[1], "FRAME_BIAS", "Bias", ISS_OFF); - IUFillSwitch(&GuideCCD.FrameTypeS[2], "FRAME_DARK", "Dark", ISS_OFF); - IUFillSwitch(&GuideCCD.FrameTypeS[3], "FRAME_FLAT", "Flat", ISS_OFF); - IUFillSwitchVector(&GuideCCD.FrameTypeSP, GuideCCD.FrameTypeS, 4, getDeviceName(), "GUIDER_FRAME_TYPE", + GuideCCD.FrameTypeSP[CCDChip::LIGHT_FRAME].fill("FRAME_LIGHT", "Light", ISS_ON); + GuideCCD.FrameTypeSP[CCDChip::BIAS_FRAME].fill("FRAME_BIAS", "Bias", ISS_OFF); + GuideCCD.FrameTypeSP[CCDChip::DARK_FRAME].fill("FRAME_DARK", "Dark", ISS_OFF); + GuideCCD.FrameTypeSP[CCDChip::FLAT_FRAME].fill("FRAME_FLAT", "Flat", ISS_OFF); + GuideCCD.FrameTypeSP.fill(getDeviceName(), "GUIDER_FRAME_TYPE", "Type", GUIDE_HEAD_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE); GuideCCD.ImageExposureNP[0].fill("GUIDER_EXPOSURE_VALUE", "Duration (s)", "%5.2f", 0.01, 3600, 1.0, 1.0); @@ -583,10 +583,10 @@ bool CCD::updateProperties() { GI::updateProperties(); } - defineProperty(&PrimaryCCD.FrameTypeSP); + defineProperty(PrimaryCCD.FrameTypeSP); if (HasGuideHead()) - defineProperty(&GuideCCD.FrameTypeSP); + defineProperty(GuideCCD.FrameTypeSP); if (HasBayer()) defineProperty(BayerTP); @@ -668,7 +668,7 @@ bool CCD::updateProperties() if (CanBin()) deleteProperty(GuideCCD.ImageBinNP); deleteProperty(GuideCCD.CompressSP); - deleteProperty(GuideCCD.FrameTypeSP.name); + deleteProperty(GuideCCD.FrameTypeSP); #if 0 deleteProperty(GuideCCD.RapidGuideSP.name); @@ -688,7 +688,7 @@ bool CCD::updateProperties() { GI::updateProperties(); } - deleteProperty(PrimaryCCD.FrameTypeSP.name); + deleteProperty(PrimaryCCD.FrameTypeSP); if (HasBayer()) deleteProperty(BayerTP); deleteProperty(ScopeInfoNP); @@ -1670,66 +1670,66 @@ bool CCD::ISNewSwitch(const char * dev, const char * name, ISState * states, cha } // Primary Chip Frame Type - if (strcmp(name, PrimaryCCD.FrameTypeSP.name) == 0) + if (PrimaryCCD.FrameTypeSP.isNameMatch(name)) { - IUUpdateSwitch(&PrimaryCCD.FrameTypeSP, states, names, n); - PrimaryCCD.FrameTypeSP.s = IPS_OK; - if (PrimaryCCD.FrameTypeS[0].s == ISS_ON) + PrimaryCCD.FrameTypeSP.update(states, names, n); + PrimaryCCD.FrameTypeSP.setState(IPS_OK); + if (PrimaryCCD.FrameTypeSP[CCDChip::LIGHT_FRAME].getState() == ISS_ON) PrimaryCCD.setFrameType(CCDChip::LIGHT_FRAME); - else if (PrimaryCCD.FrameTypeS[1].s == ISS_ON) + else if (PrimaryCCD.FrameTypeSP[CCDChip::BIAS_FRAME].getState() == ISS_ON) { PrimaryCCD.setFrameType(CCDChip::BIAS_FRAME); if (HasShutter() == false) DEBUG(Logger::DBG_WARNING, "The CCD does not have a shutter. Cover the camera in order to take a bias frame."); } - else if (PrimaryCCD.FrameTypeS[2].s == ISS_ON) + else if (PrimaryCCD.FrameTypeSP[CCDChip::DARK_FRAME].getState() == ISS_ON) { PrimaryCCD.setFrameType(CCDChip::DARK_FRAME); if (HasShutter() == false) DEBUG(Logger::DBG_WARNING, "The CCD does not have a shutter. Cover the camera in order to take a dark frame."); } - else if (PrimaryCCD.FrameTypeS[3].s == ISS_ON) + else if (PrimaryCCD.FrameTypeSP[CCDChip::FLAT_FRAME].getState() == ISS_ON) PrimaryCCD.setFrameType(CCDChip::FLAT_FRAME); if (UpdateCCDFrameType(PrimaryCCD.getFrameType()) == false) - PrimaryCCD.FrameTypeSP.s = IPS_ALERT; + PrimaryCCD.FrameTypeSP.setState(IPS_ALERT); - IDSetSwitch(&PrimaryCCD.FrameTypeSP, nullptr); + PrimaryCCD.FrameTypeSP.apply(); return true; } // Guide Chip Frame Type - if (strcmp(name, GuideCCD.FrameTypeSP.name) == 0) + if (GuideCCD.FrameTypeSP.isNameMatch(name)) { // Compression Update - IUUpdateSwitch(&GuideCCD.FrameTypeSP, states, names, n); - GuideCCD.FrameTypeSP.s = IPS_OK; - if (GuideCCD.FrameTypeS[0].s == ISS_ON) + GuideCCD.FrameTypeSP.update(states, names, n); + GuideCCD.FrameTypeSP.setState(IPS_OK); + if (GuideCCD.FrameTypeSP[CCDChip::LIGHT_FRAME].getState() == ISS_ON) GuideCCD.setFrameType(CCDChip::LIGHT_FRAME); - else if (GuideCCD.FrameTypeS[1].s == ISS_ON) + else if (GuideCCD.FrameTypeSP[CCDChip::BIAS_FRAME].getState() == ISS_ON) { GuideCCD.setFrameType(CCDChip::BIAS_FRAME); if (HasShutter() == false) DEBUG(Logger::DBG_WARNING, "The CCD does not have a shutter. Cover the camera in order to take a bias frame."); } - else if (GuideCCD.FrameTypeS[2].s == ISS_ON) + else if (GuideCCD.FrameTypeSP[CCDChip::DARK_FRAME].getState() == ISS_ON) { GuideCCD.setFrameType(CCDChip::DARK_FRAME); if (HasShutter() == false) DEBUG(Logger::DBG_WARNING, "The CCD does not have a shutter. Cover the camera in order to take a dark frame."); } - else if (GuideCCD.FrameTypeS[3].s == ISS_ON) + else if (GuideCCD.FrameTypeSP[CCDChip::FLAT_FRAME].getState() == ISS_ON) GuideCCD.setFrameType(CCDChip::FLAT_FRAME); if (UpdateGuiderFrameType(GuideCCD.getFrameType()) == false) - GuideCCD.FrameTypeSP.s = IPS_ALERT; + GuideCCD.FrameTypeSP.setState(IPS_ALERT); - IDSetSwitch(&GuideCCD.FrameTypeSP, nullptr); + GuideCCD.FrameTypeSP.apply(); return true; } diff --git a/libs/indibase/indiccdchip.cpp b/libs/indibase/indiccdchip.cpp index 29121cb626..a3771f968f 100644 --- a/libs/indibase/indiccdchip.cpp +++ b/libs/indibase/indiccdchip.cpp @@ -243,7 +243,7 @@ void CCDChip::setExposureDuration(double duration) const char *CCDChip::getFrameTypeName(CCD_FRAME fType) { - return FrameTypeS[fType].name; + return FrameTypeSP[fType].getName(); } const char *CCDChip::getExposureStartTime() diff --git a/libs/indibase/indiccdchip.h b/libs/indibase/indiccdchip.h index f4a7a7e6c9..43baeb36fc 100644 --- a/libs/indibase/indiccdchip.h +++ b/libs/indibase/indiccdchip.h @@ -516,8 +516,7 @@ class CCDChip ///////////////////////////////////////////////////////////////////////////////////////// /// Frame Type (Light, Bias..etc) ///////////////////////////////////////////////////////////////////////////////////////// - ISwitchVectorProperty FrameTypeSP; - ISwitch FrameTypeS[4]; + INDI::PropertySwitch FrameTypeSP {4}; ///////////////////////////////////////////////////////////////////////////////////////// /// Compression Toggle From ef839d7345c8b5e0825527556286a8023f0d2c4e Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Mon, 9 Sep 2024 14:08:13 +0300 Subject: [PATCH 12/23] Migrate ResetSP Property --- libs/indibase/indiccd.cpp | 16 ++++++++-------- libs/indibase/indiccdchip.h | 3 +-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index 3e2e71a0ac..5e272ceb8b 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -234,8 +234,8 @@ bool CCD::initProperties() IPS_IDLE); // Reset Frame Settings - IUFillSwitch(&PrimaryCCD.ResetS[0], "RESET", "Reset", ISS_OFF); - IUFillSwitchVector(&PrimaryCCD.ResetSP, PrimaryCCD.ResetS, 1, getDeviceName(), "CCD_FRAME_RESET", "Frame Values", + PrimaryCCD.ResetSP[0].fill("RESET", "Reset", ISS_OFF); + PrimaryCCD.ResetSP.fill(getDeviceName(), "CCD_FRAME_RESET", "Frame Values", IMAGE_SETTINGS_TAB, IP_WO, ISR_1OFMANY, 0, IPS_IDLE); /**********************************************/ @@ -539,7 +539,7 @@ bool CCD::updateProperties() defineProperty(PrimaryCCD.ImageFrameNP); if (CanBin() || CanSubFrame()) - defineProperty(&PrimaryCCD.ResetSP); + defineProperty(PrimaryCCD.ResetSP); if (CanBin()) defineProperty(PrimaryCCD.ImageBinNP); @@ -629,7 +629,7 @@ bool CCD::updateProperties() { deleteProperty(PrimaryCCD.ImageFrameNP); if (CanBin() || CanSubFrame()) - deleteProperty(PrimaryCCD.ResetSP.name); + deleteProperty(PrimaryCCD.ResetSP); deleteProperty(PrimaryCCD.ImagePixelSizeNP); @@ -1579,16 +1579,16 @@ bool CCD::ISNewSwitch(const char * dev, const char * name, ISState * states, cha } // Primary Chip Frame Reset - if (strcmp(name, PrimaryCCD.ResetSP.name) == 0) + if (PrimaryCCD.ResetSP.isNameMatch(name)) { - IUResetSwitch(&PrimaryCCD.ResetSP); - PrimaryCCD.ResetSP.s = IPS_OK; + PrimaryCCD.ResetSP.reset(); + PrimaryCCD.ResetSP.setState(IPS_OK); if (CanBin()) UpdateCCDBin(1, 1); if (CanSubFrame()) UpdateCCDFrame(0, 0, PrimaryCCD.getXRes(), PrimaryCCD.getYRes()); - IDSetSwitch(&PrimaryCCD.ResetSP, nullptr); + PrimaryCCD.ResetSP.apply(); return true; } diff --git a/libs/indibase/indiccdchip.h b/libs/indibase/indiccdchip.h index 43baeb36fc..917fd0886c 100644 --- a/libs/indibase/indiccdchip.h +++ b/libs/indibase/indiccdchip.h @@ -532,8 +532,7 @@ class CCDChip ///////////////////////////////////////////////////////////////////////////////////////// /// Reset ROI Frame to Full Resolution ///////////////////////////////////////////////////////////////////////////////////////// - ISwitchVectorProperty ResetSP; - ISwitch ResetS[1]; + INDI::PropertySwitch ResetSP{1}; friend class CCD; friend class StreamRecoder; From 036febaa17502bb57c4807cd9379d622e132962b Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Mon, 9 Sep 2024 14:37:55 +0300 Subject: [PATCH 13/23] Migrate UploadSettingsTP Property --- libs/indibase/indiccd.cpp | 36 ++++++++++++++++++------------------ libs/indibase/indiccd.h | 3 +-- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index 5e272ceb8b..7911ebb6cc 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -195,8 +195,8 @@ bool CCD::initProperties() "Abort", MAIN_CONTROL_TAB, IP_RW, ISR_ATMOST1, 60, IPS_IDLE); // Primary CCD Binning - PrimaryCCD.ImageBinNP[0].fill("HOR_BIN", "X", "%2.0f", 1, 4, 1, 1); - PrimaryCCD.ImageBinNP[1].fill("VER_BIN", "Y", "%2.0f", 1, 4, 1, 1); + PrimaryCCD.ImageBinNP[CCDChip::HOR_BIN].fill("HOR_BIN", "X", "%2.0f", 1, 4, 1, 1); + PrimaryCCD.ImageBinNP[CCDChip::VER_BIN].fill("VER_BIN", "Y", "%2.0f", 1, 4, 1, 1); PrimaryCCD.ImageBinNP.fill(getDeviceName(), "CCD_BINNING", "Binning", IMAGE_SETTINGS_TAB, IP_RW, 60, IPS_IDLE); @@ -391,9 +391,9 @@ bool CCD::initProperties() 0, IPS_IDLE); // Upload Settings - IUFillText(&UploadSettingsT[UPLOAD_DIR], "UPLOAD_DIR", "Dir", ""); - IUFillText(&UploadSettingsT[UPLOAD_PREFIX], "UPLOAD_PREFIX", "Prefix", "IMAGE_XXX"); - IUFillTextVector(&UploadSettingsTP, UploadSettingsT, 2, getDeviceName(), "UPLOAD_SETTINGS", "Upload Settings", + UploadSettingsTP[UPLOAD_DIR].fill("UPLOAD_DIR", "Dir", ""); + UploadSettingsTP[UPLOAD_PREFIX].fill("UPLOAD_PREFIX", "Prefix", "IMAGE_XXX"); + UploadSettingsTP.fill(getDeviceName(), "UPLOAD_SETTINGS", "Upload Settings", OPTIONS_TAB, IP_RW, 60, IPS_IDLE); // Upload File Path @@ -613,9 +613,9 @@ bool CCD::updateProperties() defineProperty(WorldCoordSP); defineProperty(UploadSP); - if (UploadSettingsT[UPLOAD_DIR].text == nullptr) - IUSaveText(&UploadSettingsT[UPLOAD_DIR], getenv("HOME")); - defineProperty(&UploadSettingsTP); + if (UploadSettingsTP[UPLOAD_DIR].getText() == nullptr) + UploadSettingsTP[UPLOAD_DIR].setText(getenv("HOME")); + defineProperty(UploadSettingsTP); #ifdef HAVE_WEBSOCKET if (HasWebSocket()) @@ -699,7 +699,7 @@ bool CCD::updateProperties() } deleteProperty(WorldCoordSP); deleteProperty(UploadSP); - deleteProperty(UploadSettingsTP.name); + deleteProperty(UploadSettingsTP); #ifdef HAVE_WEBSOCKET if (HasWebSocket()) @@ -1055,11 +1055,11 @@ bool CCD::ISNewText(const char * dev, const char * name, char * texts[], char * return true; } - if (!strcmp(name, UploadSettingsTP.name)) + if (UploadSettingsTP.isNameMatch(name)) { - IUUpdateText(&UploadSettingsTP, texts, names, n); - UploadSettingsTP.s = IPS_OK; - IDSetText(&UploadSettingsTP, nullptr); + UploadSettingsTP.update(texts, names, n); + UploadSettingsTP.setState(IPS_OK); + UploadSettingsTP.apply(); return true; } } @@ -2550,13 +2550,13 @@ bool CCD::uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBy FILE * fp = nullptr; char imageFileName[MAXRBUF]; - std::string prefix = UploadSettingsT[UPLOAD_PREFIX].text; - int maxIndex = getFileIndex(UploadSettingsT[UPLOAD_DIR].text, UploadSettingsT[UPLOAD_PREFIX].text, + std::string prefix = UploadSettingsTP[UPLOAD_PREFIX].getText(); + int maxIndex = getFileIndex(UploadSettingsTP[UPLOAD_DIR].getText(), UploadSettingsTP[UPLOAD_PREFIX].getText(), targetChip->FitsB.format); if (maxIndex < 0) { - LOGF_ERROR("Error iterating directory %s. %s", UploadSettingsT[0].text, + LOGF_ERROR("Error iterating directory %s. %s", UploadSettingsTP[UPLOAD_DIR].getText(), strerror(errno)); return false; } @@ -2584,7 +2584,7 @@ bool CCD::uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBy prefix = std::regex_replace(prefix, std::regex("XXX"), prefixIndex); } - snprintf(imageFileName, MAXRBUF, "%s/%s%s", UploadSettingsT[0].text, prefix.c_str(), targetChip->FitsB.format); + snprintf(imageFileName, MAXRBUF, "%s/%s%s", UploadSettingsTP[UPLOAD_DIR].getText(), prefix.c_str(), targetChip->FitsB.format); fp = fopen(imageFileName, "w"); if (fp == nullptr) @@ -2791,7 +2791,7 @@ bool CCD::saveConfigItems(FILE * fp) ActiveDeviceTP.save(fp); UploadSP.save(fp); - IUSaveConfigText(fp, &UploadSettingsTP); + UploadSettingsTP.save(fp); FastExposureToggleSP.save(fp); PrimaryCCD.CompressSP.save(fp); diff --git a/libs/indibase/indiccd.h b/libs/indibase/indiccd.h index 2c52501a65..ce667d75ba 100644 --- a/libs/indibase/indiccd.h +++ b/libs/indibase/indiccd.h @@ -718,8 +718,7 @@ class CCD : public DefaultDevice, GuiderInterface INDI::PropertySwitch UploadSP {3}; - IText UploadSettingsT[2] {}; - ITextVectorProperty UploadSettingsTP; + INDI::PropertyText UploadSettingsTP {2}; enum { UPLOAD_DIR, From 71c3d556dcad5235571a9e53bc87ad7851785281 Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Mon, 9 Sep 2024 14:46:10 +0300 Subject: [PATCH 14/23] Migrate FileNameTP Property --- libs/indibase/indiccd.cpp | 16 ++++++++-------- libs/indibase/indiccd.h | 3 +-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index 7911ebb6cc..00e27f197b 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -397,8 +397,8 @@ bool CCD::initProperties() OPTIONS_TAB, IP_RW, 60, IPS_IDLE); // Upload File Path - IUFillText(&FileNameT[0], "FILE_PATH", "Path", ""); - IUFillTextVector(&FileNameTP, FileNameT, 1, getDeviceName(), "CCD_FILE_PATH", "Filename", IMAGE_INFO_TAB, IP_RO, 60, + FileNameTP[0].fill("FILE_PATH", "Path", ""); + FileNameTP.fill(getDeviceName(), "CCD_FILE_PATH", "Filename", IMAGE_INFO_TAB, IP_RO, 60, IPS_IDLE); /**********************************************/ @@ -1480,17 +1480,17 @@ bool CCD::ISNewSwitch(const char * dev, const char * name, ISState * states, cha { DEBUG(Logger::DBG_SESSION, "Upload settings set to client only."); if (prevMode != 0) - deleteProperty(FileNameTP.name); + deleteProperty(FileNameTP); } else if (UploadSP[UPLOAD_LOCAL].getState() == ISS_ON) { DEBUG(Logger::DBG_SESSION, "Upload settings set to local only."); - defineProperty(&FileNameTP); + defineProperty(FileNameTP); } else { DEBUG(Logger::DBG_SESSION, "Upload settings set to client and local."); - defineProperty(&FileNameTP); + defineProperty(FileNameTP); } UploadSP.setState(IPS_OK); @@ -2600,11 +2600,11 @@ bool CCD::uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBy fclose(fp); // Save image file path - IUSaveText(&FileNameT[0], imageFileName); + FileNameTP[0].setText(imageFileName); DEBUGF(Logger::DBG_SESSION, "Image saved to %s", imageFileName); - FileNameTP.s = IPS_OK; - IDSetText(&FileNameTP, nullptr); + FileNameTP.setState(IPS_OK); + FileNameTP.apply(); } if (targetChip->SendCompressed && EncodeFormatSP[FORMAT_XISF].getState() != ISS_ON) diff --git a/libs/indibase/indiccd.h b/libs/indibase/indiccd.h index ce667d75ba..a2a2eb1698 100644 --- a/libs/indibase/indiccd.h +++ b/libs/indibase/indiccd.h @@ -701,8 +701,7 @@ class CCD : public DefaultDevice, GuiderInterface * but when upload option is set to either @a Both or @a Local, then they are saved on the local disk with * this name. */ - ITextVectorProperty FileNameTP; - IText FileNameT[1] {}; + INDI::PropertyText FileNameTP {1}; /// Specifies Camera NATIVE capture format (e.g. Mono, RGB, RAW8..etc). INDI::PropertySwitch CaptureFormatSP {0}; From ef23262333a6ffc8a6bf497a58dcfba70ac62e03 Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Tue, 10 Sep 2024 10:51:06 +0300 Subject: [PATCH 15/23] Fix build issues --- libs/indibase/indiccd.cpp | 84 ++++++++++++++++++++++--------------- libs/indibase/indiccdchip.h | 10 ++--- 2 files changed, 55 insertions(+), 39 deletions(-) diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index 00e27f197b..2d15d56614 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -222,8 +222,8 @@ bool CCD::initProperties() PrimaryCCD.SendCompressed = false; // Primary CCD Chip Data Blob - IUFillBLOB(&PrimaryCCD.FitsB, "CCD1", "Image", ""); - IUFillBLOBVector(&PrimaryCCD.FitsBP, &PrimaryCCD.FitsB, 1, getDeviceName(), "CCD1", "Image Data", IMAGE_INFO_TAB, + PrimaryCCD.FitsBP[0].fill("CCD1", "Image", ""); + PrimaryCCD.FitsBP.fill(getDeviceName(), "CCD1", "Image Data", IMAGE_INFO_TAB, IP_RO, 60, IPS_IDLE); // Bayer @@ -310,8 +310,8 @@ bool CCD::initProperties() GUIDE_HEAD_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE); GuideCCD.SendCompressed = false; - IUFillBLOB(&GuideCCD.FitsB, "CCD2", "Guider Image", ""); - IUFillBLOBVector(&GuideCCD.FitsBP, &GuideCCD.FitsB, 1, getDeviceName(), "CCD2", "Image Data", IMAGE_INFO_TAB, IP_RO, + GuideCCD.FitsBP[0].fill("CCD2", "Guider Image", ""); + GuideCCD.FitsBP.fill(getDeviceName(), "CCD2", "Image Data", IMAGE_INFO_TAB, IP_RO, 60, IPS_IDLE); /**********************************************/ @@ -573,11 +573,11 @@ bool CCD::updateProperties() defineProperty(GuideCCD.ImageBinNP); } defineProperty(PrimaryCCD.CompressSP); - defineProperty(&PrimaryCCD.FitsBP); + defineProperty(PrimaryCCD.FitsBP); if (HasGuideHead()) { defineProperty(GuideCCD.CompressSP); - defineProperty(&GuideCCD.FitsBP); + defineProperty(GuideCCD.FitsBP); } if (HasST4Port()) { @@ -642,7 +642,7 @@ bool CCD::updateProperties() deleteProperty(PrimaryCCD.ImageExposureNP); if (CanAbort()) deleteProperty(PrimaryCCD.AbortExposureSP); - deleteProperty(PrimaryCCD.FitsBP.name); + deleteProperty(PrimaryCCD.FitsBP); deleteProperty(PrimaryCCD.CompressSP); #if 0 @@ -664,7 +664,7 @@ bool CCD::updateProperties() deleteProperty(GuideCCD.ImageFrameNP); deleteProperty(GuideCCD.ImagePixelSizeNP); - deleteProperty(GuideCCD.FitsBP.name); + deleteProperty(GuideCCD.FitsBP); if (CanBin()) deleteProperty(GuideCCD.ImageBinNP); deleteProperty(GuideCCD.CompressSP); @@ -1098,9 +1098,15 @@ bool CCD::ISNewNumber(const char * dev, const char * name, double values[], char } if (PrimaryCCD.getFrameType() == CCDChip::BIAS_FRAME) - PrimaryCCD.ImageExposureNP[0].setValue(ExposureTime = PrimaryCCD.ImageExposureNP[0].getMin()); + { + ExposureTime = PrimaryCCD.ImageExposureNP[0].getMin(); + PrimaryCCD.ImageExposureNP[0].setValue(PrimaryCCD.ImageExposureNP[0].getMin()); + } else - PrimaryCCD.ImageExposureNP[0].setValue(ExposureTime = values[0]); + { + ExposureTime = values[0]; + PrimaryCCD.ImageExposureNP[0].setValue(values[0]); + } // Only abort when busy if we are not already in an exposure loops //if (PrimaryCCD.ImageExposureNP.s == IPS_BUSY && FastExposureToggleS[INDI_DISABLED].s == ISS_ON) @@ -1135,9 +1141,15 @@ bool CCD::ISNewNumber(const char * dev, const char * name, double values[], char } if (GuideCCD.getFrameType() == CCDChip::BIAS_FRAME) - GuideCCD.ImageExposureNP[0].setValue(GuiderExposureTime = GuideCCD.ImageExposureNP[0].getMin()); + { + GuiderExposureTime = GuideCCD.ImageExposureNP[0].getMin(); + GuideCCD.ImageExposureNP[0].setValue(GuideCCD.ImageExposureNP[0].getMin()); + } else - GuideCCD.ImageExposureNP[0].setValue(GuiderExposureTime = values[0]); + { + GuiderExposureTime = values[0]; + GuideCCD.ImageExposureNP[0].setValue(values[0]); + } GuideCCD.ImageExposureNP.setState(IPS_BUSY); if (StartGuideExposure(GuiderExposureTime)) @@ -2543,16 +2555,16 @@ bool CCD::uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBy if (saveImage) { - targetChip->FitsB.blob = const_cast(fitsData); - targetChip->FitsB.bloblen = totalBytes; - snprintf(targetChip->FitsB.format, MAXINDIBLOBFMT, ".%s", targetChip->getImageExtension()); - + targetChip->FitsBP[0].setBlob(const_cast(fitsData)); + targetChip->FitsBP[0].setBlobLen(totalBytes); + std::string format = "." + std::string(targetChip->getImageExtension()); + targetChip->FitsBP[0].setFormat(format); FILE * fp = nullptr; char imageFileName[MAXRBUF]; std::string prefix = UploadSettingsTP[UPLOAD_PREFIX].getText(); int maxIndex = getFileIndex(UploadSettingsTP[UPLOAD_DIR].getText(), UploadSettingsTP[UPLOAD_PREFIX].getText(), - targetChip->FitsB.format); + targetChip->FitsBP[0].getFormat()); if (maxIndex < 0) { @@ -2584,7 +2596,8 @@ bool CCD::uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBy prefix = std::regex_replace(prefix, std::regex("XXX"), prefixIndex); } - snprintf(imageFileName, MAXRBUF, "%s/%s%s", UploadSettingsTP[UPLOAD_DIR].getText(), prefix.c_str(), targetChip->FitsB.format); + // snprintf(imageFileName, MAXRBUF, "%s/%s%s", UploadSettingsTP[UPLOAD_DIR].getText(), prefix.c_str(), targetChip->FitsBP[0].getFormat()); + strcpy(imageFileName, targetChip->FitsBP[0].getFormat()); fp = fopen(imageFileName, "w"); if (fp == nullptr) @@ -2594,8 +2607,8 @@ bool CCD::uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBy } int n = 0; - for (int nr = 0; nr < targetChip->FitsB.bloblen; nr += n) - n = fwrite((static_cast(targetChip->FitsB.blob) + nr), 1, targetChip->FitsB.bloblen - nr, fp); + for (int nr = 0; nr < targetChip->FitsBP[0].getBlobLen(); nr += n) + n = fwrite((static_cast(targetChip->FitsBP[0].getBlob()) + nr), 1, targetChip->FitsBP[0].getBlobLen() - nr, fp); fclose(fp); @@ -2623,9 +2636,10 @@ bool CCD::uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBy return false; } - targetChip->FitsB.blob = compressedData; - targetChip->FitsB.bloblen = compressedBytes; - snprintf(targetChip->FitsB.format, MAXINDIBLOBFMT, ".%s.fz", targetChip->getImageExtension()); + targetChip->FitsBP[0].setBlob(compressedData); + targetChip->FitsBP[0].setBlobLen(compressedBytes); + std::string format = "." + std::string(targetChip->getImageExtension()) + ".fz"; + targetChip->FitsBP[0].setFormat(format); } else { @@ -2649,20 +2663,23 @@ bool CCD::uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBy return false; } - targetChip->FitsB.blob = compressedData; - targetChip->FitsB.bloblen = compressedBytes; - snprintf(targetChip->FitsB.format, MAXINDIBLOBFMT, ".%s.z", targetChip->getImageExtension()); + targetChip->FitsBP[0].setBlob(compressedData); + targetChip->FitsBP[0].setBlobLen(compressedBytes); + std::string format = "." + std::string(targetChip->getImageExtension()) + ".z"; + targetChip->FitsBP[0].setFormat(format); + } } else { - targetChip->FitsB.blob = const_cast(fitsData); - targetChip->FitsB.bloblen = totalBytes; - snprintf(targetChip->FitsB.format, MAXINDIBLOBFMT, ".%s", targetChip->getImageExtension()); + targetChip->FitsBP[0].setBlob(const_cast(fitsData)); + targetChip->FitsBP[0].setBlobLen(totalBytes); + std::string format = "." + std::string(targetChip->getImageExtension()); + targetChip->FitsBP[0].setFormat(format); } - targetChip->FitsB.size = totalBytes; - targetChip->FitsBP.s = IPS_OK; + targetChip->FitsBP[0].setSize(totalBytes); + targetChip->FitsBP.setState(IPS_OK); if (sendImage) { @@ -2683,7 +2700,7 @@ bool CCD::uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBy #endif { auto start = std::chrono::high_resolution_clock::now(); - IDSetBLOB(&targetChip->FitsBP, nullptr); + targetChip->FitsBP.apply(); auto end = std::chrono::high_resolution_clock::now(); std::chrono::duration diff = end - start; LOGF_DEBUG("BLOB transfer took %g seconds", diff.count()); @@ -2796,9 +2813,8 @@ bool CCD::saveConfigItems(FILE * fp) PrimaryCCD.CompressSP.save(fp); - if (PrimaryCCD.getCCDInfo()->p != IP_RO) + if (PrimaryCCD.getCCDInfo() != IP_RO) IUSaveConfigNumber(fp, PrimaryCCD.getCCDInfo()); - CaptureFormatSP.save(fp); EncodeFormatSP.save(fp); diff --git a/libs/indibase/indiccdchip.h b/libs/indibase/indiccdchip.h index 917fd0886c..a02c2ae924 100644 --- a/libs/indibase/indiccdchip.h +++ b/libs/indibase/indiccdchip.h @@ -20,7 +20,9 @@ #include "indiapi.h" #include "indidriver.h" -#include +#include "indipropertyswitch.h" +#include "indipropertyblob.h" + #include "indipropertynumber.h" #include @@ -263,7 +265,7 @@ class CCDChip /** * @brief Return CCD Info Property */ - INumberVectorProperty *getCCDInfo() + INDI::PropertyNumber getCCDInfo() { return ImagePixelSizeNP; } @@ -522,12 +524,10 @@ class CCDChip /// Compression Toggle ///////////////////////////////////////////////////////////////////////////////////////// INDI::PropertySwitch CompressSP {2}; - ///////////////////////////////////////////////////////////////////////////////////////// /// FITS Binary Data ///////////////////////////////////////////////////////////////////////////////////////// - IBLOBVectorProperty FitsBP; - IBLOB FitsB; + INDI::PropertyBlob FitsBP; ///////////////////////////////////////////////////////////////////////////////////////// /// Reset ROI Frame to Full Resolution From 70bf1dbcd0f4714bcb122cb240d7294e9f524dc9 Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Tue, 10 Sep 2024 11:09:57 +0300 Subject: [PATCH 16/23] Add missing {1} --- libs/indibase/indiccdchip.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/indibase/indiccdchip.h b/libs/indibase/indiccdchip.h index a02c2ae924..ca82a54b8f 100644 --- a/libs/indibase/indiccdchip.h +++ b/libs/indibase/indiccdchip.h @@ -527,7 +527,7 @@ class CCDChip ///////////////////////////////////////////////////////////////////////////////////////// /// FITS Binary Data ///////////////////////////////////////////////////////////////////////////////////////// - INDI::PropertyBlob FitsBP; + INDI::PropertyBlob FitsBP {1}; ///////////////////////////////////////////////////////////////////////////////////////// /// Reset ROI Frame to Full Resolution From f75b15a3668aa378c718479c38e95928cadfe499 Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Tue, 10 Sep 2024 11:42:39 +0300 Subject: [PATCH 17/23] update getCCDInfo condition --- libs/indibase/indiccd.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index 2d15d56614..917022c167 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -2813,8 +2813,8 @@ bool CCD::saveConfigItems(FILE * fp) PrimaryCCD.CompressSP.save(fp); - if (PrimaryCCD.getCCDInfo() != IP_RO) - IUSaveConfigNumber(fp, PrimaryCCD.getCCDInfo()); + if (PrimaryCCD.getCCDInfo().getPermission() != IP_RO) + PrimaryCCD.getCCDInfo().save(fp); CaptureFormatSP.save(fp); EncodeFormatSP.save(fp); From fa3d60379c065133b0cfab523f3c71d2d2164479 Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Tue, 10 Sep 2024 12:16:19 +0300 Subject: [PATCH 18/23] use setPermission --- drivers/video/v4l2driver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/v4l2driver.cpp b/drivers/video/v4l2driver.cpp index 782f67f1dc..3423b01921 100644 --- a/drivers/video/v4l2driver.cpp +++ b/drivers/video/v4l2driver.cpp @@ -241,7 +241,7 @@ bool V4L2_Driver::initProperties() IUFillNumberVector(&ImageAdjustNP, nullptr, 0, getDeviceName(), "Image Adjustments", "", IMAGE_GROUP, IP_RW, 60, IPS_IDLE); - PrimaryCCD.getCCDInfo()->p = IP_RW; + PrimaryCCD.getCCDInfo().setPermission(IP_RW); PrimaryCCD.setMinMaxStep("CCD_EXPOSURE", "CCD_EXPOSURE_VALUE", 0.001, 3600, 1, false); From 7cced0e30aec70dfc8030a60c02ca97480367ea3 Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Tue, 10 Sep 2024 13:33:18 +0300 Subject: [PATCH 19/23] Use snoop property --- libs/indibase/indiccd.cpp | 54 +++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index 917022c167..2498a937aa 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -729,34 +729,32 @@ bool CCD::ISSnoopDevice(XMLEle * root) auto propName = findXMLAttValu(root, "name"); auto deviceName = std::string(findXMLAttValu(root, "device")); - // FixMe:// Uncomment Snoop conditions once Snoop property is added - // if (IUSnoopNumber(root, &EqNP) == 0) - // { - // double newra, newdec; - // newra = EqNP[Ra].getValue(); - // newdec = EqNP[DEC].getValue(); - // if ((newra != RA) || (newdec != Dec)) - // { - // //IDLog("RA %4.2f Dec %4.2f Snooped RA %4.2f Dec %4.2f\n",RA,Dec,newra,newdec); - // RA = newra; - // Dec = newdec; - // } - // } - // else if (IUSnoopNumber(root, &J2000EqNP) == 0) - // { - // float newra, newdec; - // newra = J2000EqNP[Ra].getValue(); - // newdec = J2000EqNP[DEC].getValue(); - // if ((newra != J2000RA) || (newdec != J2000DE)) - // { - // // IDLog("J2000 RA %4.2f Dec %4.2f Snooped RA %4.2f Dec %4.2f\n",J2000RA,J2000DE,newra,newdec); - // J2000RA = newra; - // J2000DE = newdec; - // } - // J2000Valid = true; - // } - // else - if (!strcmp("TELESCOPE_PIER_SIDE", propName) && deviceName == ActiveDeviceTP[ACTIVE_TELESCOPE].getText()) + if ((EqNP.snoop(root))) + { + double newra, newdec; + newra = EqNP[Ra].getValue(); + newdec = EqNP[DEC].getValue(); + if ((newra != RA) || (newdec != Dec)) + { + //IDLog("RA %4.2f Dec %4.2f Snooped RA %4.2f Dec %4.2f\n",RA,Dec,newra,newdec); + RA = newra; + Dec = newdec; + } + } + else if (J2000EqNP.snoop(root)) + { + float newra, newdec; + newra = J2000EqNP[Ra].getValue(); + newdec = J2000EqNP[DEC].getValue(); + if ((newra != J2000RA) || (newdec != J2000DE)) + { + // IDLog("J2000 RA %4.2f Dec %4.2f Snooped RA %4.2f Dec %4.2f\n",J2000RA,J2000DE,newra,newdec); + J2000RA = newra; + J2000DE = newdec; + } + J2000Valid = true; + } + else if (!strcmp("TELESCOPE_PIER_SIDE", propName) && deviceName == ActiveDeviceTP[ACTIVE_TELESCOPE].getText()) { // set default to say we have no valid information from mount pierSide = -1; From 5b924ddfc736577f13a59bf7974e2ab51168d126 Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Thu, 12 Sep 2024 10:43:40 +0300 Subject: [PATCH 20/23] Fix requested changes --- drivers/ccd/ccd_simulator.cpp | 2 +- libs/indibase/indiccd.cpp | 27 ++++++++++++++------------- libs/indibase/indiccdchip.cpp | 10 +++++----- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/ccd/ccd_simulator.cpp b/drivers/ccd/ccd_simulator.cpp index 598d1b13c9..3fc073cbac 100644 --- a/drivers/ccd/ccd_simulator.cpp +++ b/drivers/ccd/ccd_simulator.cpp @@ -321,7 +321,7 @@ bool CCDSim::updateProperties() int CCDSim::SetTemperature(double temperature) { TemperatureRequest = temperature; - if (fabs(temperature - TemperatureNP[0].getValue()) < 0.1) + if (std::abs(temperature - TemperatureNP[0].getValue()) < 0.1) { TemperatureNP[0].setValue(temperature); return 1; diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index 2498a937aa..e8674968e4 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -133,7 +133,7 @@ CCD::~CCD() { // Only update if index is different. if (m_ConfigFastExposureIndex != FastExposureToggleSP.findOnSwitchIndex()) - saveConfig(true, FastExposureToggleSP.getName()); + saveConfig(FastExposureToggleSP); } void CCD::SetCCDCapability(uint32_t cap) @@ -1457,7 +1457,8 @@ bool CCD::ISNewNumber(const char * dev, const char * name, double values[], char CCDRotationNP.apply(); m_ValidCCDRotation = true; - DEBUGF(Logger::DBG_SESSION, "CCD FOV rotation updated to %g degrees.", CCDRotationNP[0].getValue()); + // DEBUGF(Logger::DBG_SESSION, "CCD FOV rotation updated to %g degrees.", CCDRotationNP[0].getValue()); + LOGF_INFO("CCD FOV rotation updated to %g degrees.", CCDRotationNP[0].getValue()); return true; } @@ -1488,18 +1489,18 @@ bool CCD::ISNewSwitch(const char * dev, const char * name, ISState * states, cha { if (UploadSP[UPLOAD_CLIENT].getState() == ISS_ON) { - DEBUG(Logger::DBG_SESSION, "Upload settings set to client only."); + LOG_INFO("Upload settings set to client only."); if (prevMode != 0) deleteProperty(FileNameTP); } else if (UploadSP[UPLOAD_LOCAL].getState() == ISS_ON) { - DEBUG(Logger::DBG_SESSION, "Upload settings set to local only."); + LOG_INFO("Upload settings set to local only."); defineProperty(FileNameTP); } else { - DEBUG(Logger::DBG_SESSION, "Upload settings set to client and local."); + LOG_INFO("Upload settings set to client and local."); defineProperty(FileNameTP); } @@ -2558,7 +2559,6 @@ bool CCD::uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBy std::string format = "." + std::string(targetChip->getImageExtension()); targetChip->FitsBP[0].setFormat(format); FILE * fp = nullptr; - char imageFileName[MAXRBUF]; std::string prefix = UploadSettingsTP[UPLOAD_PREFIX].getText(); int maxIndex = getFileIndex(UploadSettingsTP[UPLOAD_DIR].getText(), UploadSettingsTP[UPLOAD_PREFIX].getText(), @@ -2594,26 +2594,27 @@ bool CCD::uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBy prefix = std::regex_replace(prefix, std::regex("XXX"), prefixIndex); } - // snprintf(imageFileName, MAXRBUF, "%s/%s%s", UploadSettingsTP[UPLOAD_DIR].getText(), prefix.c_str(), targetChip->FitsBP[0].getFormat()); - strcpy(imageFileName, targetChip->FitsBP[0].getFormat()); + std::string imageFileName = std::string(UploadSettingsTP[UPLOAD_DIR].getText()) + "/" + prefix + "/" + std::string(targetChip->FitsBP[0].getFormat()); - fp = fopen(imageFileName, "w"); + fp = fopen(imageFileName.c_str(), "w"); if (fp == nullptr) { - LOGF_ERROR("Unable to save image file (%s). %s", imageFileName, strerror(errno)); + LOGF_ERROR("Unable to save image file (%s). %s", imageFileName.c_str(), strerror(errno)); return false; } int n = 0; - for (int nr = 0; nr < targetChip->FitsBP[0].getBlobLen(); nr += n) - n = fwrite((static_cast(targetChip->FitsBP[0].getBlob()) + nr), 1, targetChip->FitsBP[0].getBlobLen() - nr, fp); + auto len = targetChip->FitsBP[0].getBlobLen(); + auto buffer = static_cast(targetChip->FitsBP[0].getBlob()); + for (int nr = 0; nr < len; nr += n) + n = fwrite(buffer + nr, 1, len - nr, fp); fclose(fp); // Save image file path FileNameTP[0].setText(imageFileName); - DEBUGF(Logger::DBG_SESSION, "Image saved to %s", imageFileName); + LOGF_INFO("Image saved to %s", imageFileName.c_str()); FileNameTP.setState(IPS_OK); FileNameTP.apply(); } diff --git a/libs/indibase/indiccdchip.cpp b/libs/indibase/indiccdchip.cpp index a3771f968f..56906933a9 100644 --- a/libs/indibase/indiccdchip.cpp +++ b/libs/indibase/indiccdchip.cpp @@ -141,14 +141,17 @@ void CCDChip::setMinMaxStep(const char *property, const char *element, double mi { INumberVectorProperty *nvp = nullptr; - auto updateMinMaxStep = [element, min, max, sendToClient](INDI::PropertyNumber &oneProperty) + auto updateMinMaxStep = [element, min, max, step, sendToClient](INDI::PropertyNumber &oneProperty) { auto oneElement = oneProperty.findWidgetByName(element); if(oneElement) { oneElement->setMinMax(min, max); + oneElement->setStep(step); if(sendToClient) + { oneProperty.updateMinMax(); + } } }; @@ -161,10 +164,7 @@ void CCDChip::setMinMaxStep(const char *property, const char *element, double mi else if (ImagePixelSizeNP.isNameMatch(property)) updateMinMaxStep(ImagePixelSizeNP); - // else if (!strcmp(property, RapidGuideDataNP.name)) - // nvp = &RapidGuideDataNP; - else - return; + return; INumber *np = IUFindNumber(nvp, element); if (np) From 12bd405e644cc4ade0e6c23b12ac463fdac46d52 Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Thu, 12 Sep 2024 11:19:30 +0300 Subject: [PATCH 21/23] Remove unnecessary code --- libs/indibase/indiccd.cpp | 1 - libs/indibase/indiccdchip.cpp | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index e8674968e4..419ecaff37 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -1457,7 +1457,6 @@ bool CCD::ISNewNumber(const char * dev, const char * name, double values[], char CCDRotationNP.apply(); m_ValidCCDRotation = true; - // DEBUGF(Logger::DBG_SESSION, "CCD FOV rotation updated to %g degrees.", CCDRotationNP[0].getValue()); LOGF_INFO("CCD FOV rotation updated to %g degrees.", CCDRotationNP[0].getValue()); return true; diff --git a/libs/indibase/indiccdchip.cpp b/libs/indibase/indiccdchip.cpp index 56906933a9..65c78a4903 100644 --- a/libs/indibase/indiccdchip.cpp +++ b/libs/indibase/indiccdchip.cpp @@ -164,18 +164,6 @@ void CCDChip::setMinMaxStep(const char *property, const char *element, double mi else if (ImagePixelSizeNP.isNameMatch(property)) updateMinMaxStep(ImagePixelSizeNP); - return; - - INumber *np = IUFindNumber(nvp, element); - if (np) - { - np->min = min; - np->max = max; - np->step = step; - - if (sendToClient) - IUUpdateMinMax(nvp); - } } void CCDChip::setPixelSize(double x, double y) From e5de53db0b705f950739202062d3c5e2f08f89b9 Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Thu, 12 Sep 2024 11:45:21 +0300 Subject: [PATCH 22/23] Update getFileIndex --- libs/indibase/indiccd.cpp | 17 ++++++++++------- libs/indibase/indiccd.h | 2 +- libs/indibase/indiccdchip.cpp | 2 -- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index 419ecaff37..a821e652ec 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -2560,7 +2560,10 @@ bool CCD::uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBy FILE * fp = nullptr; std::string prefix = UploadSettingsTP[UPLOAD_PREFIX].getText(); - int maxIndex = getFileIndex(UploadSettingsTP[UPLOAD_DIR].getText(), UploadSettingsTP[UPLOAD_PREFIX].getText(), + std::string directory = UploadSettingsTP[UPLOAD_DIR].getText(); + + + int maxIndex = getFileIndex(directory, UploadSettingsTP[UPLOAD_PREFIX].getText(), targetChip->FitsBP[0].getFormat()); if (maxIndex < 0) @@ -2944,7 +2947,7 @@ std::string regex_replace_compat(const std::string &input, const std::string &pa return s.str(); } -int CCD::getFileIndex(const char * dir, const char * prefix, const char * ext) +int CCD::getFileIndex(const std::string & dir, const char * prefix, const char * ext) { INDI_UNUSED(ext); @@ -2959,22 +2962,22 @@ int CCD::getFileIndex(const char * dir, const char * prefix, const char * ext) // Create directory if does not exist struct stat st; - if (stat(dir, &st) == -1) + if (stat(dir.c_str(), &st) == -1) { if (errno == ENOENT) { - DEBUGF(Logger::DBG_DEBUG, "Creating directory %s...", dir); + LOGF_INFO("Creating directory %s...", dir.c_str()); if (INDI::mkpath(dir, 0755) == -1) - LOGF_ERROR("Error creating directory %s (%s)", dir, strerror(errno)); + LOGF_ERROR("Error creating directory %s (%s)", dir.c_str(), strerror(errno)); } else { - LOGF_ERROR("Couldn't stat directory %s: %s", dir, strerror(errno)); + LOGF_ERROR("Couldn't stat directory %s: %s", dir.c_str(), strerror(errno)); return -1; } } - dpdf = opendir(dir); + dpdf = opendir(dir.c_str()); if (dpdf != nullptr) { while ((epdf = readdir(dpdf))) diff --git a/libs/indibase/indiccd.h b/libs/indibase/indiccd.h index a2a2eb1698..8429873fa4 100644 --- a/libs/indibase/indiccd.h +++ b/libs/indibase/indiccd.h @@ -789,7 +789,7 @@ class CCD : public DefaultDevice, GuiderInterface /////////////////////////////////////////////////////////////////////////////// bool uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBytes, bool sendImage, bool saveImage); void getMinMax(double * min, double * max, CCDChip * targetChip); - int getFileIndex(const char * dir, const char * prefix, const char * ext); + int getFileIndex(const std::string & dir, const char * prefix, const char * ext); bool ExposureCompletePrivate(CCDChip * targetChip); // Threading for Websocket diff --git a/libs/indibase/indiccdchip.cpp b/libs/indibase/indiccdchip.cpp index 65c78a4903..4af99d32dc 100644 --- a/libs/indibase/indiccdchip.cpp +++ b/libs/indibase/indiccdchip.cpp @@ -139,8 +139,6 @@ void CCDChip::setBin(uint8_t hor, uint8_t ver) void CCDChip::setMinMaxStep(const char *property, const char *element, double min, double max, double step, bool sendToClient) { - INumberVectorProperty *nvp = nullptr; - auto updateMinMaxStep = [element, min, max, step, sendToClient](INDI::PropertyNumber &oneProperty) { auto oneElement = oneProperty.findWidgetByName(element); From 43ea92c1f732a15118749a9f34587669ee5adf29 Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Thu, 12 Sep 2024 13:07:45 +0300 Subject: [PATCH 23/23] update getFileIndex param types --- libs/indibase/indiccd.cpp | 4 ++-- libs/indibase/indiccd.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index a821e652ec..3af245cf19 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -2563,7 +2563,7 @@ bool CCD::uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBy std::string directory = UploadSettingsTP[UPLOAD_DIR].getText(); - int maxIndex = getFileIndex(directory, UploadSettingsTP[UPLOAD_PREFIX].getText(), + int maxIndex = getFileIndex(directory, prefix, targetChip->FitsBP[0].getFormat()); if (maxIndex < 0) @@ -2947,7 +2947,7 @@ std::string regex_replace_compat(const std::string &input, const std::string &pa return s.str(); } -int CCD::getFileIndex(const std::string & dir, const char * prefix, const char * ext) +int CCD::getFileIndex(const std::string & dir, const std::string & prefix, const std::string & ext) { INDI_UNUSED(ext); diff --git a/libs/indibase/indiccd.h b/libs/indibase/indiccd.h index 8429873fa4..acc1b32e3e 100644 --- a/libs/indibase/indiccd.h +++ b/libs/indibase/indiccd.h @@ -789,7 +789,7 @@ class CCD : public DefaultDevice, GuiderInterface /////////////////////////////////////////////////////////////////////////////// bool uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBytes, bool sendImage, bool saveImage); void getMinMax(double * min, double * max, CCDChip * targetChip); - int getFileIndex(const std::string & dir, const char * prefix, const char * ext); + int getFileIndex(const std::string & dir, const std::string & prefix, const std::string & ext); bool ExposureCompletePrivate(CCDChip * targetChip); // Threading for Websocket