diff --git a/drivers/ccd/ccd_simulator.cpp b/drivers/ccd/ccd_simulator.cpp index fc90411258..3fc073cbac 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 { @@ -321,9 +321,9 @@ bool CCDSim::updateProperties() int CCDSim::SetTemperature(double temperature) { TemperatureRequest = temperature; - if (fabs(temperature - TemperatureN[0].value) < 0.1) + if (std::abs(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(); } @@ -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 0b8ca22877..78476f5575 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 @@ -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 { @@ -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/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); 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..3af245cf19 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(FastExposureToggleSP); } void CCD::SetCCDCapability(uint32_t cap) @@ -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 @@ -169,73 +169,73 @@ 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 - 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 - 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 - 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 - 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[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); // 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 - 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; // 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 - 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 - 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); /**********************************************/ @@ -264,54 +264,54 @@ 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); - 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); - 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); - 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); - 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); - 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; - 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); /**********************************************/ @@ -344,13 +344,13 @@ 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); - 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); @@ -384,21 +384,21 @@ 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 - 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 - 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); /**********************************************/ @@ -413,29 +413,29 @@ 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 - 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,66 +530,66 @@ 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); + 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); + defineProperty(PrimaryCCD.ResetSP); if (CanBin()) - defineProperty(&PrimaryCCD.ImageBinNP); + defineProperty(PrimaryCCD.ImageBinNP); defineProperty(FITSHeaderTP); if (HasGuideHead()) { - defineProperty(&GuideCCD.ImageExposureNP); + defineProperty(GuideCCD.ImageExposureNP); if (CanAbort()) - defineProperty(&GuideCCD.AbortExposureSP); + defineProperty(GuideCCD.AbortExposureSP); if (CanSubFrame() == false) - GuideCCD.ImageFrameNP.p = IP_RO; - defineProperty(&GuideCCD.ImageFrameNP); + GuideCCD.ImageFrameNP.setPermission(IP_RO); + defineProperty(GuideCCD.ImageFrameNP); } if (HasCooler()) { - defineProperty(&TemperatureNP); + defineProperty(TemperatureNP); defineProperty(TemperatureRampNP); } defineProperty(CaptureFormatSP); defineProperty(EncodeFormatSP); - defineProperty(&PrimaryCCD.ImagePixelSizeNP); + defineProperty(PrimaryCCD.ImagePixelSizeNP); if (HasGuideHead()) { - defineProperty(&GuideCCD.ImagePixelSizeNP); + defineProperty(GuideCCD.ImagePixelSizeNP); if (CanBin()) - defineProperty(&GuideCCD.ImageBinNP); + defineProperty(GuideCCD.ImageBinNP); } - defineProperty(&PrimaryCCD.CompressSP); - defineProperty(&PrimaryCCD.FitsBP); + defineProperty(PrimaryCCD.CompressSP); + defineProperty(PrimaryCCD.FitsBP); if (HasGuideHead()) { - defineProperty(&GuideCCD.CompressSP); - defineProperty(&GuideCCD.FitsBP); + defineProperty(GuideCCD.CompressSP); + defineProperty(GuideCCD.FitsBP); } if (HasST4Port()) { GI::updateProperties(); } - defineProperty(&PrimaryCCD.FrameTypeSP); + defineProperty(PrimaryCCD.FrameTypeSP); if (HasGuideHead()) - defineProperty(&GuideCCD.FrameTypeSP); + defineProperty(GuideCCD.FrameTypeSP); if (HasBayer()) - defineProperty(&BayerTP); + defineProperty(BayerTP); #if 0 defineProperty(&PrimaryCCD.RapidGuideSP); @@ -610,40 +610,40 @@ bool CCD::updateProperties() #endif defineProperty(ScopeInfoNP); - defineProperty(&WorldCoordSP); - defineProperty(&UploadSP); + 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()) defineProperty(&WebSocketSP); #endif - defineProperty(&FastExposureToggleSP); - defineProperty(&FastExposureCountNP); + defineProperty(FastExposureToggleSP); + defineProperty(FastExposureCountNP); } else { - deleteProperty(PrimaryCCD.ImageFrameNP.name); + deleteProperty(PrimaryCCD.ImageFrameNP); if (CanBin() || CanSubFrame()) - deleteProperty(PrimaryCCD.ResetSP.name); + deleteProperty(PrimaryCCD.ResetSP); - deleteProperty(PrimaryCCD.ImagePixelSizeNP.name); + deleteProperty(PrimaryCCD.ImagePixelSizeNP); deleteProperty(CaptureFormatSP.getName()); deleteProperty(EncodeFormatSP.getName()); if (CanBin()) - deleteProperty(PrimaryCCD.ImageBinNP.name); + deleteProperty(PrimaryCCD.ImageBinNP); - deleteProperty(PrimaryCCD.ImageExposureNP.name); + deleteProperty(PrimaryCCD.ImageExposureNP); if (CanAbort()) - deleteProperty(PrimaryCCD.AbortExposureSP.name); - deleteProperty(PrimaryCCD.FitsBP.name); - deleteProperty(PrimaryCCD.CompressSP.name); + deleteProperty(PrimaryCCD.AbortExposureSP); + deleteProperty(PrimaryCCD.FitsBP); + deleteProperty(PrimaryCCD.CompressSP); #if 0 deleteProperty(PrimaryCCD.RapidGuideSP.name); @@ -658,17 +658,17 @@ bool CCD::updateProperties() if (HasGuideHead()) { - deleteProperty(GuideCCD.ImageExposureNP.name); + deleteProperty(GuideCCD.ImageExposureNP); if (CanAbort()) - deleteProperty(GuideCCD.AbortExposureSP.name); - deleteProperty(GuideCCD.ImageFrameNP.name); - deleteProperty(GuideCCD.ImagePixelSizeNP.name); + deleteProperty(GuideCCD.AbortExposureSP); + deleteProperty(GuideCCD.ImageFrameNP); + deleteProperty(GuideCCD.ImagePixelSizeNP); - deleteProperty(GuideCCD.FitsBP.name); + deleteProperty(GuideCCD.FitsBP); if (CanBin()) - deleteProperty(GuideCCD.ImageBinNP.name); - deleteProperty(GuideCCD.CompressSP.name); - deleteProperty(GuideCCD.FrameTypeSP.name); + deleteProperty(GuideCCD.ImageBinNP); + deleteProperty(GuideCCD.CompressSP); + deleteProperty(GuideCCD.FrameTypeSP); #if 0 deleteProperty(GuideCCD.RapidGuideSP.name); @@ -681,25 +681,25 @@ bool CCD::updateProperties() } if (HasCooler()) { - deleteProperty(TemperatureNP.name); + deleteProperty(TemperatureNP); deleteProperty(TemperatureRampNP.getName()); } if (HasST4Port()) { GI::updateProperties(); } - deleteProperty(PrimaryCCD.FrameTypeSP.name); + deleteProperty(PrimaryCCD.FrameTypeSP); if (HasBayer()) - deleteProperty(BayerTP.name); + deleteProperty(BayerTP); deleteProperty(ScopeInfoNP); - if (WorldCoordS[0].s == ISS_ON) + if (WorldCoordSP[WCS_ENABLE].getState() == ISS_ON) { - deleteProperty(CCDRotationNP.name); + deleteProperty(CCDRotationNP); } - deleteProperty(WorldCoordSP.name); - deleteProperty(UploadSP.name); - deleteProperty(UploadSettingsTP.name); + deleteProperty(WorldCoordSP); + deleteProperty(UploadSP); + deleteProperty(UploadSettingsTP); #ifdef HAVE_WEBSOCKET if (HasWebSocket()) @@ -708,8 +708,8 @@ bool CCD::updateProperties() deleteProperty(WebSocketSettingsNP.name); } #endif - deleteProperty(FastExposureToggleSP.name); - deleteProperty(FastExposureCountNP.name); + deleteProperty(FastExposureToggleSP); + deleteProperty(FastExposureCountNP); } // Streamer @@ -729,11 +729,11 @@ bool CCD::ISSnoopDevice(XMLEle * root) auto propName = findXMLAttValu(root, "name"); auto deviceName = std::string(findXMLAttValu(root, "device")); - if (IUSnoopNumber(root, &EqNP) == 0) + if ((EqNP.snoop(root))) { double newra, newdec; - newra = EqN[0].value; - newdec = EqN[1].value; + 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); @@ -741,11 +741,11 @@ bool CCD::ISSnoopDevice(XMLEle * root) Dec = newdec; } } - else if (IUSnoopNumber(root, &J2000EqNP) == 0) + else if (J2000EqNP.snoop(root)) { float newra, newdec; - newra = J2000EqN[0].value; - newdec = J2000EqN[1].value; + 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); @@ -895,8 +895,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()); @@ -968,11 +969,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; } @@ -1052,11 +1053,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; } } @@ -1085,23 +1086,29 @@ 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; + { + ExposureTime = PrimaryCCD.ImageExposureNP[0].getMin(); + PrimaryCCD.ImageExposureNP[0].setValue(PrimaryCCD.ImageExposureNP[0].getMin()); + } else - PrimaryCCD.ImageExposureN[0].value = 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) - 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,56 +1116,63 @@ 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; + { + GuiderExposureTime = GuideCCD.ImageExposureNP[0].getMin(); + GuideCCD.ImageExposureNP[0].setValue(GuideCCD.ImageExposureNP[0].getMin()); + } else - GuideCCD.ImageExposureN[0].value = GuiderExposureTime = values[0]; + { + GuiderExposureTime = values[0]; + GuideCCD.ImageExposureNP[0].setValue(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; } 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 +1191,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 +1205,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 +1235,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 +1284,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; } @@ -1324,23 +1339,23 @@ 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; } // 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 +1363,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 +1383,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; } @@ -1401,48 +1416,48 @@ 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; } // 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); + LOGF_INFO("CCD FOV rotation updated to %g degrees.", CCDRotationNP[0].getValue()); return true; } @@ -1464,64 +1479,64 @@ 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."); + LOG_INFO("Upload settings set to client only."); if (prevMode != 0) - deleteProperty(FileNameTP.name); + deleteProperty(FileNameTP); } - 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); + LOG_INFO("Upload settings set to local only."); + defineProperty(FileNameTP); } else { - DEBUG(Logger::DBG_SESSION, "Upload settings set to client and local."); - defineProperty(&FileNameTP); + LOG_INFO("Upload settings set to client and local."); + 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; } // 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); + FastExposureCountNP.setState(IPS_IDLE); + FastExposureCountNP.apply(); m_UploadTime = 0; if (PrimaryCCD.isExposing()) AbortExposure(); } - FastExposureToggleSP.s = IPS_OK; - IDSetSwitch(&FastExposureToggleSP, nullptr); + FastExposureToggleSP.setState(IPS_OK); + FastExposureToggleSP.apply(); return true; } @@ -1553,178 +1568,178 @@ 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); + defineProperty(CCDRotationNP); } else { LOG_INFO("World Coordinate System is disabled."); - deleteProperty(CCDRotationNP.name); + deleteProperty(CCDRotationNP); } m_ValidCCDRotation = false; - IDSetSwitch(&WorldCoordSP, nullptr); + WorldCoordSP.apply(); } // 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; } // 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.ImageExposureNP.s = IPS_IDLE; - PrimaryCCD.ImageExposureN[0].value = 0; + PrimaryCCD.AbortExposureSP.setState(IPS_OK); + PrimaryCCD.ImageExposureNP.setState(IPS_IDLE); + PrimaryCCD.ImageExposureNP[0].setValue(0); } else { - PrimaryCCD.AbortExposureSP.s = IPS_ALERT; - PrimaryCCD.ImageExposureNP.s = IPS_ALERT; + PrimaryCCD.AbortExposureSP.setState(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.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.ImageExposureNP.s = IPS_IDLE; - GuideCCD.ImageExposureN[0].value = 0; + GuideCCD.AbortExposureSP.setState(IPS_OK); + GuideCCD.ImageExposureNP.setState(IPS_IDLE); + GuideCCD.ImageExposureNP[0].setValue(0); } else { - GuideCCD.AbortExposureSP.s = IPS_ALERT; - GuideCCD.ImageExposureNP.s = IPS_ALERT; + GuideCCD.AbortExposureSP.setState(IPS_ALERT); + GuideCCD.ImageExposureNP.setState(IPS_ALERT); } - IDSetSwitch(&GuideCCD.AbortExposureSP, nullptr); - IDSetNumber(&GuideCCD.ImageExposureNP, nullptr); + GuideCCD.AbortExposureSP.apply(); + GuideCCD.ImageExposureNP.apply(); return true; } // 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; } // 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; } @@ -1992,8 +2007,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)"}); @@ -2043,9 +2058,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)) @@ -2174,7 +2189,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"}); @@ -2207,7 +2222,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; @@ -2269,8 +2284,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) @@ -2476,7 +2491,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) { @@ -2521,7 +2536,7 @@ bool CCD::ExposureCompletePrivate(CCDChip * targetChip) } } - if (FastExposureToggleS[INDI_ENABLED].s != ISS_ON) + if (FastExposureToggleSP[INDI_ENABLED].getState() != ISS_ON) targetChip->setExposureComplete(); UploadComplete(targetChip); @@ -2538,20 +2553,22 @@ 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 = UploadSettingsT[UPLOAD_PREFIX].text; - int maxIndex = getFileIndex(UploadSettingsT[UPLOAD_DIR].text, UploadSettingsT[UPLOAD_PREFIX].text, - targetChip->FitsB.format); + std::string prefix = UploadSettingsTP[UPLOAD_PREFIX].getText(); + std::string directory = UploadSettingsTP[UPLOAD_DIR].getText(); + + + int maxIndex = getFileIndex(directory, prefix, + targetChip->FitsBP[0].getFormat()); 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; } @@ -2579,27 +2596,29 @@ 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); + 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->FitsB.bloblen; nr += n) - n = fwrite((static_cast(targetChip->FitsB.blob) + nr), 1, targetChip->FitsB.bloblen - 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 - IUSaveText(&FileNameT[0], imageFileName); + FileNameTP[0].setText(imageFileName); - DEBUGF(Logger::DBG_SESSION, "Image saved to %s", imageFileName); - FileNameTP.s = IPS_OK; - IDSetText(&FileNameTP, nullptr); + LOGF_INFO("Image saved to %s", imageFileName.c_str()); + FileNameTP.setState(IPS_OK); + FileNameTP.apply(); } if (targetChip->SendCompressed && EncodeFormatSP[FORMAT_XISF].getState() != ISS_ON) @@ -2618,9 +2637,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 { @@ -2644,20 +2664,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) { @@ -2678,7 +2701,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()); @@ -2696,17 +2719,17 @@ 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(); // Check fast exposure count - if (FastExposureCountN[0].value > 1) + if (FastExposureCountNP[0].getValue() > 1) { - if (UploadS[UPLOAD_LOCAL].s != ISS_ON) + if (UploadSP[UPLOAD_LOCAL].getState() != ISS_ON) { - if (FastExposureCountNP.s != IPS_BUSY) + if (FastExposureCountNP.getState() != IPS_BUSY) { FastExposureToggleStartup = std::chrono::system_clock::now(); } @@ -2722,16 +2745,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 (UploadSP[UPLOAD_LOCAL].getState() == 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); } @@ -2740,11 +2763,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; } @@ -2752,8 +2775,8 @@ bool CCD::processFastExposure(CCDChip * targetChip) else { m_UploadTime = 0; - FastExposureCountNP.s = IPS_IDLE; - IDSetNumber(&FastExposureCountNP, nullptr); + FastExposureCountNP.setState(IPS_IDLE); + FastExposureCountNP.apply(); } } @@ -2785,15 +2808,14 @@ bool CCD::saveConfigItems(FILE * fp) DefaultDevice::saveConfigItems(fp); ActiveDeviceTP.save(fp); - IUSaveConfigSwitch(fp, &UploadSP); - IUSaveConfigText(fp, &UploadSettingsTP); - IUSaveConfigSwitch(fp, &FastExposureToggleSP); - - IUSaveConfigSwitch(fp, &PrimaryCCD.CompressSP); + UploadSP.save(fp); + UploadSettingsTP.save(fp); + FastExposureToggleSP.save(fp); - if (PrimaryCCD.getCCDInfo()->p != IP_RO) - IUSaveConfigNumber(fp, PrimaryCCD.getCCDInfo()); + PrimaryCCD.CompressSP.save(fp); + if (PrimaryCCD.getCCDInfo().getPermission() != IP_RO) + PrimaryCCD.getCCDInfo().save(fp); CaptureFormatSP.save(fp); EncodeFormatSP.save(fp); @@ -2802,18 +2824,18 @@ bool CCD::saveConfigItems(FILE * fp) if (HasGuideHead()) { - IUSaveConfigSwitch(fp, &GuideCCD.CompressSP); - IUSaveConfigNumber(fp, &GuideCCD.ImageBinNP); + GuideCCD.CompressSP.save(fp); + 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()) - IUSaveConfigText(fp, &BayerTP); + BayerTP.save(fp); if (HasStreaming()) Streamer->saveConfigItems(fp); @@ -2925,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 std::string & prefix, const std::string & ext) { INDI_UNUSED(ext); @@ -2940,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))) @@ -3024,27 +3046,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..acc1b32e3e 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 @@ -671,8 +674,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 @@ -687,16 +689,19 @@ 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 * 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}; @@ -710,11 +715,9 @@ 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; + INDI::PropertyText UploadSettingsTP {2}; enum { UPLOAD_DIR, @@ -730,8 +733,7 @@ class CCD : public DefaultDevice, GuiderInterface }; // Websocket Support - ISwitch WebSocketS[2]; - ISwitchVectorProperty WebSocketSP; + INDI::PropertySwitch WebSocketSP {2}; enum { WEBSOCKET_ENABLED, @@ -740,28 +742,27 @@ class CCD : public DefaultDevice, GuiderInterface // Websocket Settings - INumber WebSocketSettingsN[1]; - INumberVectorProperty WebSocketSettingsNP; + INDI::PropertyNumber WebSocketSettingsNP {1}; enum { WS_SETTINGS_PORT, }; // WCS - ISwitch WorldCoordS[2]; - ISwitchVectorProperty WorldCoordSP; - + INDI::PropertySwitch WorldCoordSP{2}; + enum + { + WCS_ENABLE, + WCS_DISABLE + }; // WCS CCD Rotation - INumber CCDRotationN[1]; - INumberVectorProperty CCDRotationNP; + INDI::PropertyNumber CCDRotationNP{1}; // Fast Exposure Toggle - ISwitch FastExposureToggleS[2]; - ISwitchVectorProperty FastExposureToggleSP; + 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; @@ -788,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 std::string & prefix, const std::string & ext); bool ExposureCompletePrivate(CCDChip * targetChip); // Threading for Websocket diff --git a/libs/indibase/indiccdchip.cpp b/libs/indibase/indiccdchip.cpp index 033e672c36..4af99d32dc 100644 --- a/libs/indibase/indiccdchip.cpp +++ b/libs/indibase/indiccdchip.cpp @@ -93,21 +93,21 @@ 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(); - ImageFrameN[FRAME_X].min = 0; - ImageFrameN[FRAME_X].max = x - 1; - ImageFrameN[FRAME_Y].min = 0; - ImageFrameN[FRAME_Y].max = y - 1; + ImageFrameNP[FRAME_X].setMin(0); + ImageFrameNP[FRAME_X].setMax(x - 1); + ImageFrameNP[FRAME_Y].setMin(0); + ImageFrameNP[FRAME_Y].setMax(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_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,40 +130,38 @@ 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, bool sendToClient) { - INumberVectorProperty *nvp = nullptr; - - 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 (!strcmp(property, ImagePixelSizeNP.name)) - nvp = &ImagePixelSizeNP; - // else if (!strcmp(property, RapidGuideDataNP.name)) - // nvp = &RapidGuideDataNP; - else - return; - - INumber *np = IUFindNumber(nvp, element); - if (np) + auto updateMinMaxStep = [element, min, max, step, sendToClient](INDI::PropertyNumber &oneProperty) { - np->min = min; - np->max = max; - np->step = step; + auto oneElement = oneProperty.findWidgetByName(element); + if(oneElement) + { + oneElement->setMinMax(min, max); + oneElement->setStep(step); + if(sendToClient) + { + oneProperty.updateMinMax(); + } + } + }; - if (sendToClient) - IUUpdateMinMax(nvp); - } + if (ImageExposureNP.isNameMatch(property)) + updateMinMaxStep(ImageExposureNP); + else if (ImageFrameNP.isNameMatch(property)) + updateMinMaxStep(ImageFrameNP); + else if (ImageBinNP.isNameMatch(property)) + updateMinMaxStep(ImageBinNP); + + else if (ImagePixelSizeNP.isNameMatch(property)) + updateMinMaxStep(ImagePixelSizeNP); } void CCDChip::setPixelSize(double x, double y) @@ -171,20 +169,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) @@ -211,16 +209,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) @@ -231,7 +229,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() @@ -263,8 +261,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 6f8e199fc7..ca82a54b8f 100644 --- a/libs/indibase/indiccdchip.h +++ b/libs/indibase/indiccdchip.h @@ -20,6 +20,10 @@ #include "indiapi.h" #include "indidriver.h" +#include "indipropertyswitch.h" +#include "indipropertyblob.h" + +#include "indipropertynumber.h" #include #include @@ -184,7 +188,7 @@ class CCDChip */ inline double getExposureLeft() const { - return ImageExposureN[0].value; + return ImageExposureNP[0].getValue(); } /** @@ -261,9 +265,9 @@ class CCDChip /** * @brief Return CCD Info Property */ - INumberVectorProperty *getCCDInfo() + INDI::PropertyNumber getCCDInfo() { - return &ImagePixelSizeNP; + return ImagePixelSizeNP; } /** @@ -398,7 +402,7 @@ class CCDChip */ bool isExposing() const { - return (ImageExposureNP.s == IPS_BUSY); + return (ImageExposureNP.getState() == IPS_BUSY); } /** @@ -485,56 +489,50 @@ class CCDChip ///////////////////////////////////////////////////////////////////////////////////////// /// Image Exposure Duration ///////////////////////////////////////////////////////////////////////////////////////// - INumberVectorProperty ImageExposureNP; - INumber ImageExposureN[1]; + INDI::PropertyNumber ImageExposureNP {1}; ///////////////////////////////////////////////////////////////////////////////////////// /// Abort Exposure ///////////////////////////////////////////////////////////////////////////////////////// - ISwitchVectorProperty AbortExposureSP; - ISwitch AbortExposureS[1]; + INDI::PropertySwitch AbortExposureSP {1}; ///////////////////////////////////////////////////////////////////////////////////////// /// 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 ///////////////////////////////////////////////////////////////////////////////////////// - INumberVectorProperty ImagePixelSizeNP; - INumber ImagePixelSizeN[6]; + INDI::PropertyNumber ImagePixelSizeNP {6}; ///////////////////////////////////////////////////////////////////////////////////////// /// Frame Type (Light, Bias..etc) ///////////////////////////////////////////////////////////////////////////////////////// - ISwitchVectorProperty FrameTypeSP; - ISwitch FrameTypeS[4]; + INDI::PropertySwitch FrameTypeSP {4}; ///////////////////////////////////////////////////////////////////////////////////////// /// Compression Toggle ///////////////////////////////////////////////////////////////////////////////////////// - ISwitchVectorProperty CompressSP; - ISwitch CompressS[2]; - + INDI::PropertySwitch CompressSP {2}; ///////////////////////////////////////////////////////////////////////////////////////// /// FITS Binary Data ///////////////////////////////////////////////////////////////////////////////////////// - IBLOBVectorProperty FitsBP; - IBLOB FitsB; + INDI::PropertyBlob FitsBP {1}; ///////////////////////////////////////////////////////////////////////////////////////// /// Reset ROI Frame to Full Resolution ///////////////////////////////////////////////////////////////////////////////////////// - ISwitchVectorProperty ResetSP; - ISwitch ResetS[1]; + INDI::PropertySwitch ResetSP{1}; friend class CCD; friend class StreamRecoder;