diff --git a/indi-apogee/apogee_ccd.cpp b/indi-apogee/apogee_ccd.cpp index dfdfed8ac..8dfc05253 100644 --- a/indi-apogee/apogee_ccd.cpp +++ b/indi-apogee/apogee_ccd.cpp @@ -215,8 +215,8 @@ bool ApogeeCCD::getCameraParams() if (isSimulation()) { - TemperatureN[0].value = 10; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP[0].setValue(10); + TemperatureNP.apply(); IUResetSwitch(&FanStatusSP); FanStatusS[2].s = ISS_ON; @@ -273,8 +273,8 @@ bool ApogeeCCD::getCameraParams() } LOGF_INFO("The CCD Temperature is %f.", temperature); - TemperatureN[0].value = temperature; /* CCD chip temperatre (degrees C) */ - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP[0].setValue(temperature); /* CCD chip temperatre (degrees C) */ + TemperatureNP.apply(); Apg::FanMode fStatus = Apg::FanMode_Unknown; @@ -325,7 +325,7 @@ bool ApogeeCCD::getCameraParams() int ApogeeCCD::SetTemperature(double temperature) { // If less than 0.1 of a degree, let's just return OK - if (fabs(temperature - TemperatureN[0].value) < 0.1) + if (fabs(temperature - TemperatureNP[0].getValue()) < 0.1) return 1; activateCooler(true); @@ -1299,7 +1299,7 @@ void ApogeeCCD::TimerHit() } } - switch (TemperatureNP.s) + switch (TemperatureNP.getState()) { case IPS_IDLE: case IPS_OK: @@ -1307,22 +1307,22 @@ void ApogeeCCD::TimerHit() try { if (isSimulation()) - ccdTemp = TemperatureN[0].value; + ccdTemp = TemperatureNP[0].getValue(); else ccdTemp = ApgCam->GetTempCcd(); } catch (std::runtime_error &err) { - TemperatureNP.s = IPS_IDLE; + TemperatureNP.setState(IPS_IDLE); LOGF_ERROR("GetTempCcd failed. %s.", err.what()); - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.apply(); return; } - if (fabs(TemperatureN[0].value - ccdTemp) >= TEMP_UPDATE_THRESHOLD) + if (fabs(TemperatureNP[0].getValue() - ccdTemp) >= TEMP_UPDATE_THRESHOLD) { - TemperatureN[0].value = ccdTemp; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP[0].setValue(ccdTemp); + TemperatureNP.apply(); } break; @@ -1331,23 +1331,23 @@ void ApogeeCCD::TimerHit() try { if (isSimulation()) - ccdTemp = TemperatureN[0].value; + ccdTemp = TemperatureNP[0].getValue(); else ccdTemp = ApgCam->GetTempCcd(); } catch (std::runtime_error &err) { - TemperatureNP.s = IPS_ALERT; + TemperatureNP.setState(IPS_ALERT); LOGF_ERROR("GetTempCcd failed. %s.", err.what()); - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.apply(); return; } // if (fabs(TemperatureN[0].value - ccdTemp) <= TEMP_THRESHOLD) // TemperatureNP.s = IPS_OK; - TemperatureN[0].value = ccdTemp; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP[0].setValue(ccdTemp); + TemperatureNP.apply(); break; case IPS_ALERT: diff --git a/indi-asi/asi_base.cpp b/indi-asi/asi_base.cpp index 52a676817..fa4fa0802 100644 --- a/indi-asi/asi_base.cpp +++ b/indi-asi/asi_base.cpp @@ -345,7 +345,7 @@ bool ASIBase::initProperties() BlinkNP.fill(getDeviceName(), "BLINK", "Blink", CONTROL_TAB, IP_RW, 60, IPS_IDLE); BlinkNP.load(); - IUSaveText(&BayerT[2], getBayerString()); + BayerTP[2].setText(getBayerString()); ADCDepthNP[0].fill("BITS", "Bits", "%2.0f", 0, 32, 1, mCameraInfo.BitDepth); ADCDepthNP.fill(getDeviceName(), "ADC_DEPTH", "ADC Depth", IMAGE_INFO_TAB, IP_RO, 60, IPS_IDLE); @@ -438,8 +438,8 @@ bool ASIBase::updateProperties() // Even if there is no cooler, we define temperature property as READ ONLY else { - TemperatureNP.p = IP_RO; - defineProperty(&TemperatureNP); + TemperatureNP.setPermission(IP_RO); + defineProperty(TemperatureNP); } if (!ControlNP.isEmpty()) @@ -497,7 +497,7 @@ bool ASIBase::updateProperties() deleteProperty(CoolerSP.getName()); } else - deleteProperty(TemperatureNP.name); + deleteProperty(TemperatureNP); if (!ControlNP.isEmpty()) deleteProperty(ControlNP.getName()); @@ -712,9 +712,9 @@ void ASIBase::setupParams() if (ret != ASI_SUCCESS) LOGF_DEBUG("Failed to get temperature (%s).", Helpers::toString(ret)); - TemperatureN[0].value = value / 10.0; - IDSetNumber(&TemperatureNP, nullptr); - LOGF_INFO("The CCD Temperature is %.3f.", TemperatureN[0].value); + TemperatureNP[0].setValue(value / 10.0); + TemperatureNP.apply(); + LOGF_INFO("The CCD Temperature is %.3f.", TemperatureNP[0].getValue()); ret = ASIStopVideoCapture(mCameraInfo.CameraID); if (ret != ASI_SUCCESS) @@ -1280,7 +1280,7 @@ void ASIBase::temperatureTimerTimeout() ASI_ERROR_CODE ret; ASI_BOOL isAuto = ASI_FALSE; long value = 0; - IPState newState = TemperatureNP.s; + IPState newState = TemperatureNP.getState(); ret = ASIGetControlValue(mCameraInfo.CameraID, ASI_TEMPERATURE, &value, &isAuto); @@ -1303,13 +1303,13 @@ void ASIBase::temperatureTimerTimeout() // Update if there is a change if ( - std::abs(mCurrentTemperature - TemperatureN[0].value) > 0.05 || - TemperatureNP.s != newState + std::abs(mCurrentTemperature - TemperatureNP[0].getValue()) > 0.05 || + TemperatureNP.getState() != newState ) { - TemperatureNP.s = newState; - TemperatureN[0].value = mCurrentTemperature; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.setState(newState); + TemperatureNP[0].setValue(mCurrentTemperature); + TemperatureNP.apply(); } if (HasCooler()) diff --git a/indi-atik/atik_ccd.cpp b/indi-atik/atik_ccd.cpp index 93320dff5..6b5f7e90a 100644 --- a/indi-atik/atik_ccd.cpp +++ b/indi-atik/atik_ccd.cpp @@ -183,7 +183,7 @@ bool ATIKCCD::initProperties() ISR_1OFMANY, 60, IPS_IDLE); #endif - IUSaveText(&BayerT[2], "RGGB"); + BayerTP[2].setText("RGGB"); INDI::FilterInterface::initProperties(FILTER_TAB); @@ -208,8 +208,8 @@ bool ATIKCCD::updateProperties() // Even if there is no cooler, we define temperature property as READ ONLY else { - TemperatureNP.p = IP_RO; - defineProperty(&TemperatureNP); + TemperatureNP.setPermission(IP_RO); + defineProperty(TemperatureNP); } if (m_isHorizon) @@ -243,7 +243,7 @@ bool ATIKCCD::updateProperties() deleteProperty(CoolerSP.name); } else - deleteProperty(TemperatureNP.name); + deleteProperty(TemperatureNP); if (m_isHorizon) { @@ -340,8 +340,8 @@ bool ATIKCCD::setupParams() if (colorType == ARTEMIS_COLOUR_RGGB) { cap |= CCD_HAS_BAYER; - IUSaveText(&BayerT[0], std::to_string(normalOffsetX).c_str()); - IUSaveText(&BayerT[1], std::to_string(normalOffsetY).c_str()); + BayerTP[0].setText(std::to_string(normalOffsetX).c_str()); + BayerTP[1].setText(std::to_string(normalOffsetY).c_str()); } LOGF_DEBUG("Camera is %s.", colorType == ARTEMIS_COLOUR_RGGB ? "Color" : "Mono"); @@ -784,16 +784,16 @@ bool ATIKCCD::ISNewSwitch(const char *dev, const char *name, ISState *states, ch // If user turns on cooler, but the requested temperature is higher than current temperature by more // than five degrees, then we consider this endangers the device and we alter the temperature target. // The five degrees tolerance is there to adapt to cooling overshoot. - if (enabled && TemperatureN[0].value + 5.0f < TemperatureRequest) + if (enabled && TemperatureNP[0].getValue() + 5.0f < TemperatureRequest) { LOGF_WARN("Current temperature is %.2f, refusing to set %.2f (5 degrees warming tolerance). " "To control cooler, request a lower temperature or let the device warm above %.2f.", - TemperatureN[0].value, TemperatureRequest, TemperatureRequest - 5.0f); + TemperatureNP[0].getValue(), TemperatureRequest, TemperatureRequest - 5.0f); // If current temperature is lower than zero, then we shouldn't risk // setting temperature to any arbitrary value. Instead, we turn the cooler off and ask // user to explicitly set a new temperature. - if (TemperatureN[0].value < 0) + if (TemperatureNP[0].getValue() < 0) { CoolerS[COOLER_ON].s = ISS_OFF; CoolerS[COOLER_OFF].s = ISS_ON; @@ -912,7 +912,7 @@ bool ATIKCCD::ISNewSwitch(const char *dev, const char *name, ISState *states, ch int ATIKCCD::SetTemperature(double temperature) { // If there difference, for example, is less than 0.1 degrees, let's immediately return OK. - if (fabs(temperature - TemperatureN[0].value) < TEMP_THRESHOLD) + if (fabs(temperature - TemperatureNP[0].getValue()) < TEMP_THRESHOLD) return 1; // setpoint is int 1/100 of a degree C. @@ -939,7 +939,7 @@ bool ATIKCCD::activateCooler(bool enable) IUResetSwitch(&CoolerSP); if (enable) { - if (TemperatureRequest < TemperatureN[0].value) + if (TemperatureRequest < TemperatureNP[0].getValue()) { if (CoolerSP.s != IPS_BUSY) LOG_INFO("Camera cooler is on."); @@ -1130,7 +1130,7 @@ bool ATIKCCD::grabImage() ///////////////////////////////////////////////////////// void ATIKCCD::TimerHit() { - double currentTemperature = TemperatureN[0].value; + double currentTemperature = TemperatureNP[0].getValue(); int flags, level, minlvl, maxlvl, setpoint; @@ -1152,15 +1152,15 @@ void ATIKCCD::TimerHit() pthread_mutex_lock(&accessMutex); rc = ArtemisTemperatureSensorInfo(hCam, 1, &temperature); pthread_mutex_unlock(&accessMutex); - TemperatureN[0].value = temperature / 100.0; + TemperatureNP[0].setValue(temperature / 100.0); - switch (TemperatureNP.s) + switch (TemperatureNP.getState()) { case IPS_IDLE: case IPS_OK: - if (fabs(currentTemperature - TemperatureN[0].value) > TEMP_THRESHOLD / 10.0) + if (fabs(currentTemperature - TemperatureNP[0].getValue()) > TEMP_THRESHOLD / 10.0) { - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.apply(); } break; @@ -1173,7 +1173,7 @@ void ATIKCCD::TimerHit() // { // TemperatureNP.s = IPS_OK; // } - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.apply(); break; } diff --git a/indi-dsi/dsi_ccd.cpp b/indi-dsi/dsi_ccd.cpp index e6d613630..709d89458 100644 --- a/indi-dsi/dsi_ccd.cpp +++ b/indi-dsi/dsi_ccd.cpp @@ -251,7 +251,7 @@ bool DSICCD::UpdateCCDBin(int hor, int ver) dsi->set1x1Binning(); // DSI III 1x1 binning results in a GBRG frame if (dsi->getCcdChipName() == "ICX285AQ") - IUSaveText(&BayerT[2], "GBRG"); + BayerTP[2].setText("GBRG"); return true; } else if ((hor == 2) && (ver == 2)) // ... and 2x2 binning is supported @@ -260,7 +260,7 @@ bool DSICCD::UpdateCCDBin(int hor, int ver) dsi->set2x2Binning(); // DSI III 1x1 binning results in a consolidated mono frame if (dsi->getCcdChipName() == "ICX285AQ") - IUSaveText(&BayerT[2], ""); + BayerTP[2].setText(""); return true; } else diff --git a/indi-fishcamp/indi_fishcamp.cpp b/indi-fishcamp/indi_fishcamp.cpp index 8c9fc5910..219a4dd8e 100644 --- a/indi-fishcamp/indi_fishcamp.cpp +++ b/indi-fishcamp/indi_fishcamp.cpp @@ -219,8 +219,8 @@ int FishCampCCD::SetTemperature(double temperature) else CoolerNP.s = IPS_IDLE; - TemperatureNP.s = IPS_BUSY; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.setState(IPS_BUSY); + TemperatureNP.apply(); LOGF_INFO("Setting CCD temperature to %+06.2f C", temperature); @@ -475,7 +475,7 @@ void FishCampCCD::TimerHit() } } - switch (TemperatureNP.s) + switch (TemperatureNP.getState()) { case IPS_IDLE: case IPS_OK: @@ -487,10 +487,10 @@ void FishCampCCD::TimerHit() LOGF_DEBUG("Temperature %g", ccdTemp); - if (fabs(TemperatureN[0].value - ccdTemp) >= TEMP_THRESHOLD) + if (fabs(TemperatureNP[0].getValue() - ccdTemp) >= TEMP_THRESHOLD) { - TemperatureN[0].value = ccdTemp; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP[0].setValue(ccdTemp); + TemperatureNP.apply(); } break; @@ -498,7 +498,7 @@ void FishCampCCD::TimerHit() case IPS_BUSY: if (sim) { - TemperatureN[0].value = TemperatureRequest; + TemperatureNP[0].setValue(TemperatureRequest); } else { @@ -506,14 +506,14 @@ void FishCampCCD::TimerHit() LOGF_DEBUG("fcUsb_cmd_getTemperature returns %d", rc); - TemperatureN[0].value = rc / 100.0; + TemperatureNP[0].setValue(rc / 100.0); } // If we're within threshold, let's make it BUSY ---> OK // if (fabs(TemperatureRequest - TemperatureN[0].value) <= TEMP_THRESHOLD) // TemperatureNP.s = IPS_OK; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.apply(); break; case IPS_ALERT: diff --git a/indi-fli/fli_ccd.cpp b/indi-fli/fli_ccd.cpp index d78eae182..cbc2cfe84 100644 --- a/indi-fli/fli_ccd.cpp +++ b/indi-fli/fli_ccd.cpp @@ -422,11 +422,11 @@ bool FLICCD::setupParams() } else { - TemperatureN[0].value = FLICam.temperature; /* CCD chip temperatre (degrees C) */ - TemperatureN[0].min = MIN_CCD_TEMP; - TemperatureN[0].max = MAX_CCD_TEMP; - IUUpdateMinMax(&TemperatureNP); - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP[0].setValue(FLICam.temperature); /* CCD chip temperatre (degrees C) */ + TemperatureNP[0].setMin(MIN_CCD_TEMP); + TemperatureNP[0].setMax(MAX_CCD_TEMP); + TemperatureNP.updateMinMax(); + TemperatureNP.apply(); LOGF_DEBUG("FLIGetTemperature() succeed -> %f", FLICam.temperature); } @@ -745,7 +745,7 @@ void FLICCD::TimerHit() } } - switch (TemperatureNP.s) + switch (TemperatureNP.getState()) { case IPS_IDLE: case IPS_OK: @@ -753,30 +753,30 @@ void FLICCD::TimerHit() { if ((err = FLIGetTemperature(fli_dev, &ccdTemp))) { - TemperatureNP.s = IPS_IDLE; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.setState(IPS_IDLE); + TemperatureNP.apply(); LOGF_ERROR("FLIGetTemperature() failed. %s.", strerror(-err)); break; } if ((err = FLIGetCoolerPower(fli_dev, &ccdPower))) { CoolerNP.s = IPS_IDLE; - IDSetNumber(&TemperatureNP, nullptr); - IDSetNumber(&TemperatureNP, "FLIGetCoolerPower() failed. %s.", strerror(-err)); + LOGF_ERROR("FLIGetCoolerPower() failed. %s.", strerror(-err)); + TemperatureNP.apply(); break; } } - if (fabs(TemperatureN[0].value - ccdTemp) >= TEMP_THRESHOLD) + if (fabs(TemperatureNP[0].getValue() - ccdTemp) >= TEMP_THRESHOLD) { - TemperatureN[0].value = ccdTemp; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP[0].setValue(ccdTemp); + TemperatureNP.apply(); } if (fabs(CoolerN[0].value - ccdPower) >= TEMP_THRESHOLD) { CoolerN[0].value = ccdPower; - CoolerNP.s = TemperatureNP.s; + CoolerNP.s = TemperatureNP.getState(); IDSetNumber(&CoolerNP, nullptr); } break; @@ -785,14 +785,14 @@ void FLICCD::TimerHit() if (sim) { ccdTemp = FLICam.temperature; - TemperatureN[0].value = ccdTemp; + TemperatureNP[0].setValue(ccdTemp); } else { if ((err = FLIGetTemperature(fli_dev, &ccdTemp))) { - TemperatureNP.s = IPS_IDLE; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.setState(IPS_IDLE); + TemperatureNP.apply(); LOGF_ERROR("FLIGetTemperature() failed. %s.", strerror(-err)); break; } @@ -800,7 +800,8 @@ void FLICCD::TimerHit() if ((err = FLIGetCoolerPower(fli_dev, &ccdPower))) { CoolerNP.s = IPS_IDLE; - IDSetNumber(&TemperatureNP, "FLIGetCoolerPower() failed. %s.", strerror(-err)); + LOGF_ERROR("FLIGetCoolerPower() failed. %s.", strerror(-err)); + TemperatureNP.apply(); break; } } @@ -814,12 +815,12 @@ void FLICCD::TimerHit() if (fabs(CoolerN[0].value - ccdPower) >= TEMP_THRESHOLD) { CoolerN[0].value = ccdPower; - CoolerNP.s = TemperatureNP.s; + CoolerNP.s = TemperatureNP.getState(); IDSetNumber(&CoolerNP, nullptr); } - TemperatureN[0].value = ccdTemp; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP[0].setValue(ccdTemp); + TemperatureNP.apply(); break; case IPS_ALERT: diff --git a/indi-gphoto/gphoto_ccd.cpp b/indi-gphoto/gphoto_ccd.cpp index f409e7f7a..c6a3bf666 100644 --- a/indi-gphoto/gphoto_ccd.cpp +++ b/indi-gphoto/gphoto_ccd.cpp @@ -303,7 +303,7 @@ bool GPhotoCCD::initProperties() PrimaryCCD.setMinMaxStep("CCD_EXPOSURE", "CCD_EXPOSURE_VALUE", 0.001, 3600, 1, false); // Most cameras have this by default, so let's set it as default. - IUSaveText(&BayerT[2], "RGGB"); + BayerTP[2].setText("RGGB"); #ifdef HAVE_WEBSOCKET SetCCDCapability(CCD_CAN_SUBFRAME | CCD_CAN_BIN | CCD_CAN_ABORT | CCD_HAS_BAYER | CCD_HAS_STREAMING | CCD_HAS_WEB_SOCKET); @@ -418,8 +418,8 @@ bool GPhotoCCD::updateProperties() if (isTemperatureSupported) { - TemperatureNP.p = IP_RO; - defineProperty(&TemperatureNP); + TemperatureNP.setPermission(IP_RO); + defineProperty(TemperatureNP); } defineProperty(ForceBULBSP); @@ -443,7 +443,7 @@ bool GPhotoCCD::updateProperties() } if (isTemperatureSupported) - deleteProperty(TemperatureNP.name); + deleteProperty(TemperatureNP); deleteProperty(SDCardImageSP); @@ -682,12 +682,12 @@ bool GPhotoCCD::ISNewSwitch(const char * dev, const char * name, ISState * state LOG_INFO("Images should only remain in the camera internal storage and will not be downloaded at all."); // Upload mode should always be local, no images uploaded. - if (UploadS[UPLOAD_LOCAL].s != ISS_ON) + if (UploadSP[UPLOAD_LOCAL].getState() != ISS_ON) { - IUResetSwitch(&UploadSP); - UploadS[UPLOAD_LOCAL].s = ISS_ON; - UploadSP.s = IPS_OK; - IDSetSwitch(&UploadSP, nullptr); + UploadSP.reset(); + UploadSP[UPLOAD_LOCAL].setState(ISS_ON); + UploadSP.setState(IPS_OK); + UploadSP.apply(); } // Capture target should always be SD card. @@ -1126,23 +1126,23 @@ void GPhotoCCD::TimerHit() if (isTemperatureSupported) { double cameraTemperature = static_cast(gphoto_get_last_sensor_temperature(gphotodrv)); - if (fabs(cameraTemperature - TemperatureN[0].value) > 0.01) + if (fabs(cameraTemperature - TemperatureNP[0].getValue()) > 0.01) { // Check if we are getting bogus temperature values and set property to alert // unless it is already set if (cameraTemperature < MINUMUM_CAMERA_TEMPERATURE) { - if (TemperatureNP.s != IPS_ALERT) + if (TemperatureNP.getState() != IPS_ALERT) { - TemperatureNP.s = IPS_ALERT; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.setState(IPS_ALERT); + TemperatureNP.apply(); } } else { - TemperatureNP.s = IPS_OK; - TemperatureN[0].value = cameraTemperature; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.setState(IPS_OK); + TemperatureNP[0].setValue(cameraTemperature); + TemperatureNP.apply(); } } } @@ -1300,8 +1300,8 @@ bool GPhotoCCD::grabImage() if (!isSimulation()) unlink(filename); - IUSaveText(&BayerT[2], bayer_pattern); - IDSetText(&BayerTP, nullptr); + BayerTP[2].setText(bayer_pattern); + BayerTP.apply(); SetCCDCapability(GetCCDCapability() | CCD_HAS_BAYER); } @@ -2070,7 +2070,7 @@ void GPhotoCCD::addFITSKeywords(INDI::CCDChip * targetChip, std::vector TemperatureRequest) + else if (TemperatureNP[0].getValue() > TemperatureRequest) ccdtemp -= TEMP_THRESHOLD; ccdpower = 30; @@ -954,7 +954,7 @@ void MICCD::updateTemperature() } } - TemperatureN[0].value = ccdtemp; + TemperatureNP[0].setValue(ccdtemp); CoolerN[0].value = ccdpower * 100.0; // if (TemperatureNP.s == IPS_BUSY && fabs(TemperatureN[0].value - TemperatureRequest) <= TEMP_THRESHOLD) @@ -967,7 +967,7 @@ void MICCD::updateTemperature() if (err) { if (err & 1) - TemperatureNP.s = IPS_ALERT; + TemperatureNP.setState(IPS_ALERT); if (err & 2) CoolerNP.s = IPS_ALERT; } @@ -976,7 +976,7 @@ void MICCD::updateTemperature() CoolerNP.s = IPS_OK; } - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.apply(); IDSetNumber(&CoolerNP, nullptr); temperatureID = IEAddTimer(getCurrentPollingPeriod(), MICCD::updateTemperatureHelper, this); } diff --git a/indi-nightscape/nightscape.cpp b/indi-nightscape/nightscape.cpp index 8a403985b..e185aca97 100644 --- a/indi-nightscape/nightscape.cpp +++ b/indi-nightscape/nightscape.cpp @@ -34,7 +34,7 @@ #include /* Macro shortcut to CCD temperature value */ -#define currentCCDTemperature TemperatureN[0].value +#define currentCCDTemperature TemperatureNP[0] static std::unique_ptr nightscapeCCD(new NightscapeCCD()); @@ -286,9 +286,9 @@ bool NightscapeCCD::initProperties() if (bayer) { cap |= CCD_HAS_BAYER; - IUSaveText(&BayerT[0], "0"); - IUSaveText(&BayerT[1], "0"); - IUSaveText(&BayerT[2], "BGGR"); + BayerTP[0].setText("0"); + BayerTP[1].setText("0"); + BayerTP[2].setText("BGGR"); } SetCCDCapability(cap); @@ -505,7 +505,7 @@ void NightscapeCCD::TimerHit() // TemperatureNP is defined in INDI::CCD - switch (TemperatureNP.s) + switch (TemperatureNP.getState()) { case IPS_IDLE: case IPS_OK: @@ -515,12 +515,12 @@ void NightscapeCCD::TimerHit() if (InDownload || InReadout || InExposure) break; if(ntemps % backoffs == 0) { - currentCCDTemperature = m->rcvtemp(); + currentCCDTemperature.setValue(m->rcvtemp()); backoffs *= 2; if(backoffs > 32) backoffs = 32; } ntemps++; - dn->setActTemp(currentCCDTemperature); + dn->setActTemp(currentCCDTemperature.getValue()); /* If target temperature is higher, then increase current CCD temperature */ // if (fabs(currentCCDTemperature - TemperatureRequest) < 0.1) @@ -532,7 +532,7 @@ void NightscapeCCD::TimerHit() // break; // } - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.apply(); break; @@ -629,7 +629,7 @@ bool NightscapeCCD::ISNewSwitch (const char *dev, const char *name, ISState *sta CoolerSP.s = IPS_OK; IDSetSwitch(&CoolerSP, nullptr); m->sendtemp(setTemp, cooler); - dn->setActTemp(currentCCDTemperature); + dn->setActTemp(currentCCDTemperature.getValue()); return true; } @@ -694,16 +694,16 @@ bool NightscapeCCD::ISNewNumber(const char *dev, const char *name, double values bool NightscapeCCD::saveConfigItems(FILE *fp) { - currentCCDTemperature = setTemp; + currentCCDTemperature.setValue(setTemp); IUSaveConfigSwitch(fp, &FanSP); IUSaveConfigSwitch(fp, &CoolerSP); IUSaveConfigNumber(fp, &CamNumNP); IUSaveConfigSwitch(fp, &D2xxSP); - float tTemp = currentCCDTemperature; + float tTemp = currentCCDTemperature.getValue(); - IUSaveConfigNumber(fp, &TemperatureNP); + TemperatureNP.save(fp); - currentCCDTemperature = tTemp; + currentCCDTemperature.setValue(tTemp); return INDI::CCD::saveConfigItems(fp); }; diff --git a/indi-orion-ssg3/orion_ssg3_ccd.cpp b/indi-orion-ssg3/orion_ssg3_ccd.cpp index 5b9794b12..b0af74d22 100644 --- a/indi-orion-ssg3/orion_ssg3_ccd.cpp +++ b/indi-orion-ssg3/orion_ssg3_ccd.cpp @@ -437,7 +437,7 @@ int SSG3CCD::SetTemperature(double temperature) TemperatureRequest = temperature; - if (std::abs(temperature - TemperatureN[0].value) < TEMP_THRESHOLD) + if (std::abs(temperature - TemperatureNP[0].getValue()) < TEMP_THRESHOLD) return 1; if (!activateCooler(true)) @@ -496,15 +496,15 @@ void SSG3CCD::updateTemperature(void) rc = orion_ssg3_get_temperature(&ssg3, &temp); if (rc < 0) { - TemperatureNP.s = IPS_ALERT; + TemperatureNP.setState(IPS_ALERT); } else { LOGF_DEBUG("Read temperature: %f", temp); - TemperatureN[0].value = temp; - TemperatureNP.s = IPS_OK; + TemperatureNP[0].setValue(temp); + TemperatureNP.setState(IPS_OK); } - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.apply(); if (CoolerSP[COOLER_ON].getState() == ISS_ON) { diff --git a/indi-pentax/pentax_ccd.cpp b/indi-pentax/pentax_ccd.cpp index f08917cd0..cb7760ac2 100644 --- a/indi-pentax/pentax_ccd.cpp +++ b/indi-pentax/pentax_ccd.cpp @@ -70,7 +70,7 @@ bool PentaxCCD::initProperties() PrimaryCCD.setMinMaxStep("CCD_EXPOSURE", "CCD_EXPOSURE_VALUE", 0, 30, 1, false); - IUSaveText(&BayerT[2], "RGGB"); + BayerTP[2].setText("RGGB"); PrimaryCCD.getCCDInfo()->p = IP_RW; @@ -726,7 +726,7 @@ void PentaxCCD::getCaptureSettingsState() string PentaxCCD::getUploadFilePrefix() { - return UploadSettingsT[UPLOAD_DIR].text + string("/") + UploadSettingsT[UPLOAD_PREFIX].text; + return UploadSettingsTP[UPLOAD_DIR].getText() + string("/") + UploadSettingsTP[UPLOAD_PREFIX].getText(); } bool PentaxCCD::SetCaptureFormat(uint8_t index) diff --git a/indi-pentax/pktriggercord_ccd.cpp b/indi-pentax/pktriggercord_ccd.cpp index 6b207957b..085e0c936 100644 --- a/indi-pentax/pktriggercord_ccd.cpp +++ b/indi-pentax/pktriggercord_ccd.cpp @@ -84,7 +84,7 @@ bool PkTriggerCordCCD::initProperties() PrimaryCCD.setMinMaxStep("CCD_EXPOSURE", "CCD_EXPOSURE_VALUE", 0.0001, 7200, 1, false); - IUSaveText(&BayerT[2], "RGGB"); + BayerTP[2].setText("RGGB"); PrimaryCCD.getCCDInfo()->p = IP_RW; @@ -630,8 +630,8 @@ bool PkTriggerCordCCD::grabImage() LOGF_DEBUG("read_libraw: memsize (%d) naxis (%d) w (%d) h (%d) bpp (%d) bayer pattern (%s)", memsize, naxis, w, h, bpp, bayer_pattern); - IUSaveText(&BayerT[2], bayer_pattern); - IDSetText(&BayerTP, nullptr); + BayerTP[2].setText(bayer_pattern); + BayerTP.apply(nullptr); SetCCDCapability(GetCCDCapability() | CCD_HAS_BAYER); } @@ -856,7 +856,7 @@ bool PkTriggerCordCCD::getCaptureSettingsState() string PkTriggerCordCCD::getUploadFilePrefix() { - return UploadSettingsT[UPLOAD_DIR].text + string("/") + UploadSettingsT[UPLOAD_PREFIX].text; + return UploadSettingsTP[UPLOAD_DIR].getText() + string("/") + UploadSettingsTP[UPLOAD_PREFIX].getText(); } const char * PkTriggerCordCCD::getFormatFileExtension(user_file_format format) diff --git a/indi-playerone/playerone_base.cpp b/indi-playerone/playerone_base.cpp index ffc8281a8..375b00895 100644 --- a/indi-playerone/playerone_base.cpp +++ b/indi-playerone/playerone_base.cpp @@ -351,7 +351,7 @@ bool POABase::initProperties() BlinkNP[BLINK_DURATION].fill("BLINK_DURATION", "Blink duration", "%2.3f", 0, 60, 0.001, 0); BlinkNP.fill(getDeviceName(), "BLINK", "Blink", CONTROL_TAB, IP_RW, 60, IPS_IDLE); - IUSaveText(&BayerT[2], getBayerString()); + BayerTP[2].setText(getBayerString()); ADCDepthNP[0].fill("BITS", "Bits", "%2.0f", 0, 32, 1, mCameraInfo.bitDepth); ADCDepthNP.fill(getDeviceName(), "ADC_DEPTH", "ADC Depth", IMAGE_INFO_TAB, IP_RO, 60, IPS_IDLE); @@ -430,8 +430,8 @@ bool POABase::updateProperties() // Even if there is no cooler, we define temperature property as READ ONLY else { - TemperatureNP.p = IP_RO; - defineProperty(&TemperatureNP); + TemperatureNP.setPermission(IP_RO); + defineProperty(TemperatureNP); } if (!ControlNP.isEmpty()) @@ -496,7 +496,7 @@ bool POABase::updateProperties() deleteProperty(CoolerSP); } else - deleteProperty(TemperatureNP.name); + deleteProperty(TemperatureNP); if (!ControlNP.isEmpty()) deleteProperty(ControlNP); @@ -747,9 +747,9 @@ void POABase::setupParams() if (ret != POA_OK) LOGF_DEBUG("Failed to get temperature (%s).", Helpers::toString(ret)); - TemperatureN[0].value = confVal.floatValue; - IDSetNumber(&TemperatureNP, nullptr); - LOGF_INFO("The CCD Temperature is %.3f.", TemperatureN[0].value); + TemperatureNP[0].setValue(confVal.floatValue); + TemperatureNP.apply(); + LOGF_INFO("The CCD Temperature is %.3f.", TemperatureNP[0].getValue()); // stop video capture ret = POAStopExposure(mCameraInfo.cameraID); @@ -929,7 +929,7 @@ bool POABase::ISNewSwitch(const char *dev, const char *name, ISState *states, ch // Compensate bayer pattern (effective for RAW data format) char bayer[5]; POABayerCompensationByFlip(flip, bayer); - IUSaveText(&BayerT[2], bayer); + BayerTP[2].setText(bayer); FlipSP.setState(IPS_OK); FlipSP.apply(); @@ -1347,7 +1347,7 @@ void POABase::temperatureTimerTimeout() POAConfigValue confVal; double value = 0.0; - IPState newState = TemperatureNP.s; + IPState newState = TemperatureNP.getState(); ret = POAGetConfig(mCameraInfo.cameraID, POA_TEMPERATURE, &confVal, &isAuto); value = confVal.floatValue; @@ -1371,13 +1371,13 @@ void POABase::temperatureTimerTimeout() // Update if there is a change if ( - std::abs(mCurrentTemperature - TemperatureN[0].value) > 0.05 || - TemperatureNP.s != newState + std::abs(mCurrentTemperature - TemperatureNP[0].getValue()) > 0.05 || + TemperatureNP.getState() != newState ) { - TemperatureNP.s = newState; - TemperatureN[0].value = mCurrentTemperature; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.setState(newState); + TemperatureNP[0].setValue(mCurrentTemperature); + TemperatureNP.apply(); } if (HasCooler()) diff --git a/indi-qhy/qhy_ccd.cpp b/indi-qhy/qhy_ccd.cpp index 772bb1459..04b6da012 100644 --- a/indi-qhy/qhy_ccd.cpp +++ b/indi-qhy/qhy_ccd.cpp @@ -1031,26 +1031,26 @@ bool QHYCCD::Connect() { if (ret == BAYER_GB) { - IUSaveText(&BayerT[2], "GBRG"); + BayerTP[2].setText("GBRG"); cap |= CCD_HAS_BAYER; } else if (ret == BAYER_GR) { - IUSaveText(&BayerT[2], "GRBG"); + BayerTP[2].setText("GRBG"); cap |= CCD_HAS_BAYER; } else if (ret == BAYER_BG) { - IUSaveText(&BayerT[2], "BGGR"); + BayerTP[2].setText("BGGR"); cap |= CCD_HAS_BAYER; } else if (ret == BAYER_RG) { - IUSaveText(&BayerT[2], "RGGB"); + BayerTP[2].setText("RGGB"); cap |= CCD_HAS_BAYER; } - LOGF_DEBUG("Color camera: %s", BayerT[2].text); + LOGF_DEBUG("Color camera: %s", BayerTP[2].getText()); } //////////////////////////////////////////////////////////////////// @@ -1264,17 +1264,17 @@ bool QHYCCD::setupParams() int QHYCCD::SetTemperature(double temperature) { // If there difference, for example, is less than 0.1 degrees, let's immediately return OK. - if (fabs(temperature - TemperatureN[0].value) < UPDATE_THRESHOLD) + if (fabs(temperature - TemperatureNP[0].getValue()) < UPDATE_THRESHOLD) return 1; - LOGF_DEBUG("Requested temperature is %.f, current temperature is %.f", temperature, TemperatureN[0].value); + LOGF_DEBUG("Requested temperature is %.f, current temperature is %.f", temperature, TemperatureNP[0].getValue()); m_TemperatureRequest = temperature; m_PWMRequest = -1; SetQHYCCDParam(m_CameraHandle, CONTROL_COOLER, m_TemperatureRequest); - setCoolerEnabled(m_TemperatureRequest <= TemperatureN[0].value); + setCoolerEnabled(m_TemperatureRequest <= TemperatureNP[0].getValue()); setCoolerMode(COOLER_AUTOMATIC); return 0; } @@ -1679,13 +1679,13 @@ bool QHYCCD::ISNewSwitch(const char *dev, const char *name, ISState *states, cha { if (HasCoolerAutoMode) { - double targetTemperature = TemperatureN[0].value; + double targetTemperature = TemperatureNP[0].getValue(); if (targetTemperature > 0) targetTemperature = 0; if (SetTemperature(targetTemperature) == 0) { - TemperatureNP.s = IPS_BUSY; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.setState(IPS_BUSY); + TemperatureNP.apply(); } return true; } @@ -1710,8 +1710,8 @@ bool QHYCCD::ISNewSwitch(const char *dev, const char *name, ISState *states, cha CoolerSP.s = IPS_IDLE; IDSetSwitch(&CoolerSP, nullptr); - TemperatureNP.s = IPS_IDLE; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.setState(IPS_IDLE); + TemperatureNP.apply(); setCoolerMode(COOLER_MANUAL); LOG_INFO("Camera is warming up."); @@ -1721,8 +1721,8 @@ bool QHYCCD::ISNewSwitch(const char *dev, const char *name, ISState *states, cha // Warm up the camera in auto mode if (SetTemperature(30) == 0) { - TemperatureNP.s = IPS_IDLE; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.setState(IPS_IDLE); + TemperatureNP.apply(); } LOG_INFO("Camera is warming up."); return true; @@ -2236,10 +2236,10 @@ void QHYCCD::updateTemperature() if (isSimulation()) { - currentTemperature = TemperatureN[0].value; - if (TemperatureN[0].value < m_TemperatureRequest) + currentTemperature = TemperatureNP[0].getValue(); + if (TemperatureNP[0].getValue() < m_TemperatureRequest) currentTemperature += UPDATE_THRESHOLD * 10; - else if (TemperatureN[0].value > m_TemperatureRequest) + else if (TemperatureNP[0].getValue() > m_TemperatureRequest) currentTemperature -= UPDATE_THRESHOLD * 10; currentCoolingPower = 128; @@ -2250,7 +2250,7 @@ void QHYCCD::updateTemperature() //usleep(1000000); // Call this function as long as we are busy - if (TemperatureNP.s == IPS_BUSY) + if (TemperatureNP.getState() == IPS_BUSY) { SetQHYCCDParam(m_CameraHandle, CONTROL_COOLER, m_TemperatureRequest); } @@ -2260,7 +2260,7 @@ void QHYCCD::updateTemperature() } // JM 2020-05-18: QHY reported the code below break automatic coolers, so it is only avaiable for manual coolers. // Temperature Readout does not work, if we do not set "something", so lets set the current value... - else if (CoolerModeS[COOLER_MANUAL].s == ISS_ON && TemperatureNP.s == IPS_OK) + else if (CoolerModeS[COOLER_MANUAL].s == ISS_ON && TemperatureNP.getState() == IPS_OK) { SetQHYCCDParam(m_CameraHandle, CONTROL_MANULPWM, CoolerN[0].value * 255.0 / 100 ); } @@ -2270,27 +2270,27 @@ void QHYCCD::updateTemperature() } // Only update if above update threshold - if (std::abs(currentTemperature - TemperatureN[0].value) > UPDATE_THRESHOLD) + if (std::abs(currentTemperature - TemperatureNP[0].getValue()) > UPDATE_THRESHOLD) { if (currentTemperature > 100) - TemperatureNP.s = IPS_ALERT; + TemperatureNP.setState(IPS_ALERT); else - TemperatureN[0].value = currentTemperature; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP[0].setValue(currentTemperature); + TemperatureNP.apply(); LOGF_DEBUG("CCD T.: %.f (C)", currentTemperature); } // Restart temperature regulation if needed. - else if (TemperatureNP.s == IPS_OK && fabs(TemperatureN[0].value - m_TemperatureRequest) > UPDATE_THRESHOLD) + else if (TemperatureNP.getState() == IPS_OK && fabs(TemperatureNP[0].getValue() - m_TemperatureRequest) > UPDATE_THRESHOLD) { if (currentTemperature > 100) - TemperatureNP.s = IPS_ALERT; + TemperatureNP.setState(IPS_ALERT); else { - TemperatureN[0].value = currentTemperature; - TemperatureNP.s = IPS_BUSY; + TemperatureNP[0].setValue(currentTemperature); + TemperatureNP.setState(IPS_BUSY); } - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.apply(); } // Update cooling power if needed. @@ -2448,8 +2448,8 @@ bool QHYCCD::StartStreaming() LOGF_DEBUG("SetQHYCCDResolution x: %d y: %d w: %d h: %d", subX, subY, subW, subH, ret); INDI_PIXEL_FORMAT qhyFormat = INDI_MONO; - if (BayerT[2].text && formats.count(BayerT[2].text) != 0) - qhyFormat = formats.at(BayerT[2].text); + if (BayerTP[2].getText() && formats.count(BayerTP[2].getText()) != 0) + qhyFormat = formats.at(BayerTP[2].getText()); double uSecs = static_cast(m_ExposureRequest * 950000.0); diff --git a/indi-qsi/qsi_ccd.cpp b/indi-qsi/qsi_ccd.cpp index dee4c58ce..cafa3a026 100644 --- a/indi-qsi/qsi_ccd.cpp +++ b/indi-qsi/qsi_ccd.cpp @@ -246,8 +246,8 @@ bool QSICCD::setupParams() LOGF_INFO("The CCD Temperature is %f.", temperature); - TemperatureN[0].value = temperature; /* CCD chip temperatre (degrees C) */ - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP[0].setValue(temperature); /* CCD chip temperatre (degrees C) */ + TemperatureNP.apply(); SetCCDParams(sub_frame_x, sub_frame_y, 16, pixel_size_x, pixel_size_y); @@ -467,7 +467,7 @@ int QSICCD::SetTemperature(double temperature) targetTemperature = temperature; // If less than 0.1 of a degree, let's just return OK - if (fabs(temperature - TemperatureN[0].value) < 0.1) + if (fabs(temperature - TemperatureNP[0].getValue()) < 0.1) return 1; activateCooler(true); @@ -1243,7 +1243,7 @@ void QSICCD::TimerHit() } } - switch (TemperatureNP.s) + switch (TemperatureNP.getState()) { case IPS_IDLE: case IPS_OK: @@ -1253,36 +1253,38 @@ void QSICCD::TimerHit() } catch (std::runtime_error &err) { - TemperatureNP.s = IPS_IDLE; + TemperatureNP.setState(IPS_IDLE); LOGF_ERROR("get_CCDTemperature() failed. %s.", err.what()); - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.apply(); return; } - if (fabs(TemperatureN[0].value - ccdTemp) >= TEMP_THRESHOLD) + if (fabs(TemperatureNP[0].getValue() - ccdTemp) >= TEMP_THRESHOLD) { - TemperatureN[0].value = ccdTemp; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP[0].setValue(ccdTemp); + TemperatureNP.apply(); } break; case IPS_BUSY: try { - QSICam.get_CCDTemperature(&TemperatureN[0].value); + double value = 0; + QSICam.get_CCDTemperature(&value); + TemperatureNP[0].setValue(value); } catch (std::runtime_error &err) { - TemperatureNP.s = IPS_ALERT; + TemperatureNP.setState(IPS_ALERT); LOGF_ERROR("get_CCDTemperature() failed. %s.", err.what()); - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.apply(); return; } // if (fabs(TemperatureN[0].value - targetTemperature) <= TEMP_THRESHOLD) // TemperatureNP.s = IPS_OK; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.apply(); break; case IPS_ALERT: diff --git a/indi-sbig/sbig_ccd.cpp b/indi-sbig/sbig_ccd.cpp index 53f4e06af..010df4dec 100644 --- a/indi-sbig/sbig_ccd.cpp +++ b/indi-sbig/sbig_ccd.cpp @@ -470,7 +470,7 @@ bool SBIGCCD::initProperties() ISR_1OFMANY, 60, IPS_IDLE); - IUSaveText(&BayerT[2], "BGGR"); + BayerTP[2].setText("BGGR"); INDI::FilterInterface::initProperties(FILTER_TAB); @@ -678,7 +678,7 @@ bool SBIGCCD::ISNewSwitch(const char *dev, const char *name, ISState *states, ch { IUUpdateSwitch(&CoolerSP, states, names, n); bool coolerON = CoolerS[0].s == ISS_ON; - if (SetTemperatureRegulation(TemperatureN[0].value, coolerON) == CE_NO_ERROR) + if (SetTemperatureRegulation(TemperatureNP[0].getValue(), coolerON) == CE_NO_ERROR) { CoolerSP.s = coolerON ? IPS_OK : IPS_IDLE; LOGF_INFO("Cooler turned %s.", coolerON ? "On" : "Off"); @@ -1010,9 +1010,9 @@ bool SBIGCCD::setupParams() IDSetSwitch(&CoolerSP, nullptr); CoolerN[0].value = power * 100; IDSetNumber(&CoolerNP, nullptr); - TemperatureN[0].min = MIN_CCD_TEMP; - TemperatureN[0].max = MAX_CCD_TEMP; - IUUpdateMinMax(&TemperatureNP); + TemperatureNP[0].setMin(MIN_CCD_TEMP); + TemperatureNP[0].setMax(MAX_CCD_TEMP); + TemperatureNP.updateMinMax(); } IUSaveText(&ProductInfoT[0], GetCameraName()); @@ -1024,7 +1024,7 @@ bool SBIGCCD::setupParams() int SBIGCCD::SetTemperature(double temperature) { - if (fabs(temperature - TemperatureN[0].value) < 0.1) + if (fabs(temperature - TemperatureNP[0].getValue()) < 0.1) return 1; if (SetTemperatureRegulation(temperature) == CE_NO_ERROR) { @@ -1679,7 +1679,7 @@ int SBIGCCD::SetTemperatureRegulation(double temperature, bool enable) SetTemperatureRegulationParams strp; if (isSimulation()) { - TemperatureN[0].value = temperature; + TemperatureNP[0].setValue(temperature); return CE_NO_ERROR; } if (CheckLink()) @@ -1706,7 +1706,7 @@ int SBIGCCD::QueryTemperatureStatus(bool &enabled, double &ccdTemp, double &setp if (isSimulation()) { enabled = (CoolerS[0].s == ISS_ON); - ccdTemp = TemperatureN[0].value; + ccdTemp = TemperatureNP[0].getValue(); setpointTemp = ccdTemp; power = enabled ? 0.5 : 0; return CE_NO_ERROR; @@ -2534,14 +2534,14 @@ void SBIGCCD::updateTemperature() // } if (power == 0) { - TemperatureNP.s = IPS_IDLE; + TemperatureNP.setState(IPS_IDLE); } else { - TemperatureNP.s = IPS_BUSY; + TemperatureNP.setState(IPS_BUSY); LOGF_DEBUG("CCD temperature %+.1f [C], TE cooler: %.1f [%%].", ccdTemp, power); } - TemperatureN[0].value = ccdTemp; + TemperatureNP[0].setValue(ccdTemp); // Check the TE cooler if inside the range: if (power <= CCD_COOLER_THRESHOLD) { @@ -2552,7 +2552,7 @@ void SBIGCCD::updateTemperature() CoolerNP.s = IPS_BUSY; } CoolerN[0].value = power; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.apply(); IDSetNumber(&CoolerNP, nullptr); } else @@ -2561,14 +2561,14 @@ void SBIGCCD::updateTemperature() if (res == CE_SHARE_ERROR) { LOGF_DEBUG("Erro reading temperature. %s", GetErrorString(res)); - TemperatureNP.s = IPS_IDLE; + TemperatureNP.setState(IPS_IDLE); } else { LOGF_ERROR("Erro reading temperature. %s", GetErrorString(res)); - TemperatureNP.s = IPS_ALERT; + TemperatureNP.setState(IPS_ALERT); } - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.apply(); } IEAddTimer(TEMPERATURE_POLL_MS, SBIGCCD::updateTemperatureHelper, this); } diff --git a/indi-svbony/svbony_base.cpp b/indi-svbony/svbony_base.cpp index 0aedc9148..7bb19b318 100644 --- a/indi-svbony/svbony_base.cpp +++ b/indi-svbony/svbony_base.cpp @@ -420,7 +420,7 @@ bool SVBONYBase::initProperties() NicknameTP[0].fill("nickname", "nickname", mNickname); NicknameTP.fill(getDeviceName(), "NICKNAME", "Nickname", INFO_TAB, IP_RW, 60, IPS_IDLE); - IUSaveText(&BayerT[2], "GRBG"); + BayerTP[2].setText("GRBG"); addAuxControls(); @@ -623,8 +623,8 @@ bool SVBONYBase::Connect() if (mCameraProperty.IsColorCam) { cap |= CCD_HAS_BAYER; - IUSaveText(&BayerT[2], getBayerString()); - IDSetText(&BayerTP, nullptr); + BayerTP[2].setText(getBayerString()); + BayerTP.apply(); } cap |= CCD_CAN_ABORT; @@ -776,9 +776,9 @@ void SVBONYBase::setupParams() LOGF_DEBUG("Failed to get temperature (%s).", Helpers::toString(ret)); else { - TemperatureN[0].value = value / 10.0; - IDSetNumber(&TemperatureNP, nullptr); - LOGF_INFO("The CCD Temperature is %.3f.", TemperatureN[0].value); + TemperatureNP[0].setValue(value / 10.0); + TemperatureNP.apply(); + LOGF_INFO("The CCD Temperature is %.3f.", TemperatureNP[0].getValue()); } ret = SVBStopVideoCapture(mCameraInfo.CameraID); @@ -1158,10 +1158,10 @@ void SVBONYBase::sendImage(SVB_IMG_TYPE type, float duration) SetCCDCapability(GetCCDCapability() | CCD_HAS_BAYER); auto bayerString = getBayerString(); // Send if different - if (strcmp(bayerString, BayerT[2].text)) + if (BayerTP[2].isNameMatch(bayerString)) { - IUSaveText(&BayerT[2], bayerString); - IDSetText(&BayerTP, nullptr); + BayerTP[2].setText(bayerString); + BayerTP.apply(); } } else @@ -1181,7 +1181,7 @@ void SVBONYBase::temperatureTimerTimeout() SVB_ERROR_CODE ret; SVB_BOOL isAuto = SVB_FALSE; long value = 0; - IPState newState = TemperatureNP.s; + IPState newState = TemperatureNP.getState(); ret = SVBGetControlValue(mCameraInfo.CameraID, SVB_CURRENT_TEMPERATURE, &value, &isAuto); @@ -1197,13 +1197,13 @@ void SVBONYBase::temperatureTimerTimeout() // Update if there is a change if ( - std::abs(mCurrentTemperature - TemperatureN[0].value) > 0.05 || - TemperatureNP.s != newState + std::abs(mCurrentTemperature - TemperatureNP[0].getValue()) > 0.05 || + TemperatureNP.getState() != newState ) { - TemperatureNP.s = newState; - TemperatureN[0].value = mCurrentTemperature; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.setState(newState); + TemperatureNP[0].setValue(mCurrentTemperature); + TemperatureNP.apply(); /* This log should be commented out except when investigating bugs, etc., as it outputs very frequently. LOGF_DEBUG("Current Temperature %.2f degree", mCurrentTemperature); diff --git a/indi-sx/sxccd.cpp b/indi-sx/sxccd.cpp index a0736fc2b..782a9db5e 100644 --- a/indi-sx/sxccd.cpp +++ b/indi-sx/sxccd.cpp @@ -154,7 +154,7 @@ bool SXCCD::initProperties() // IUFillSwitch(&BayerS[1], "BAYER_FALSE", "False", ISS_ON); // IUFillSwitchVector(&BayerSP, BayerS, 2, getDeviceName(), "CCD_BAYER_FILTER", "Bayer Filter", IMAGE_SETTINGS_TAB, IP_RW, ISR_1OFMANY, // 60, IPS_IDLE); - IUSaveText(&BayerT[2], "RGGB"); + BayerTP[2].setText("RGGB"); // we can expose less than 0.01 seconds at a time // and we need to for an allsky in daytime @@ -365,15 +365,15 @@ void SXCCD::TimerHit() unsigned short temperature; sxSetCooler(handle, (unsigned char)(CoolerS[0].s == ISS_ON), (unsigned short)(TemperatureRequest * 10 + 2730), &status, &temperature); - TemperatureN[0].value = (temperature - 2730) / 10.0; - if (TemperatureReported != TemperatureN[0].value) + TemperatureNP[0].setValue((temperature - 2730) / 10.0); + if (TemperatureReported != TemperatureNP[0].getValue()) { - TemperatureReported = TemperatureN[0].value; + TemperatureReported = TemperatureNP[0].getValue(); // if (std::fabs(TemperatureRequest - TemperatureReported) < 1) // TemperatureNP.s = IPS_OK; // else //TemperatureNP.s = IPS_BUSY; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.apply(); } } } @@ -393,7 +393,9 @@ int SXCCD::SetTemperature(double temperature) unsigned short sx_temperature; sxSetCooler(handle, (unsigned char)(CoolerS[0].s == ISS_ON), (unsigned short)(TemperatureRequest * 10 + 2730), &status, &sx_temperature); - TemperatureReported = TemperatureN[0].value = (sx_temperature - 2730) / 10.0; + TemperatureReported =(sx_temperature - 2730) / 10.0; + TemperatureNP[0].setValue((sx_temperature - 2730) / 10.0); + if (std::fabs(TemperatureRequest - TemperatureReported) < 1) result = 1; else @@ -771,9 +773,11 @@ bool SXCCD::ISNewSwitch(const char *dev, const char *name, ISState *states, char unsigned short temperature; sxSetCooler(handle, (unsigned char)(CoolerS[0].s == ISS_ON), (unsigned short)(TemperatureRequest * 10 + 2730), &status, &temperature); - TemperatureReported = TemperatureN[0].value = (temperature - 2730) / 10.0; - TemperatureNP.s = IPS_OK; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureReported = (temperature - 2730) / 10.0; + TemperatureNP[0].setValue((temperature - 2730) / 10.0); + + TemperatureNP.setState(IPS_OK); + TemperatureNP.apply(); result = true; } // else if (strcmp(name, BayerSP.name) == 0) diff --git a/indi-toupbase/indi_toupbase.cpp b/indi-toupbase/indi_toupbase.cpp index f939ebff9..4f6c31a54 100644 --- a/indi-toupbase/indi_toupbase.cpp +++ b/indi-toupbase/indi_toupbase.cpp @@ -368,8 +368,8 @@ bool ToupBase::updateProperties() // Even if there is no cooler, we define temperature property as READ ONLY else if (m_Instance->model->flag & CP(FLAG_GETTEMPERATURE)) { - TemperatureNP.p = IP_RO; - defineProperty(&TemperatureNP); + TemperatureNP.setPermission(IP_RO); + defineProperty(TemperatureNP); } if (m_Instance->model->flag & CP(FLAG_FAN)) @@ -421,7 +421,7 @@ bool ToupBase::updateProperties() } else { - deleteProperty(TemperatureNP.name); + deleteProperty(TemperatureNP); } if (m_Instance->model->flag & CP(FLAG_FAN)) @@ -496,10 +496,9 @@ bool ToupBase::Connect() { int tecRange = 0; FP(get_Option(m_Handle, CP(OPTION_TECTARGET_RANGE), &tecRange)); - TemperatureN[0].min = (static_cast(tecRange & 0xffff)) / 10.0; - TemperatureN[0].max - = (static_cast((tecRange >> 16) & 0xffff)) / 10.0; - TemperatureN[0].value = 0; // reasonable default + TemperatureNP[0].setMin((static_cast(tecRange & 0xffff)) / 10.0); + TemperatureNP[0].setMax((static_cast((tecRange >> 16) & 0xffff)) / 10.0); + TemperatureNP[0].setValue(0); // reasonable default } { @@ -624,7 +623,7 @@ void ToupBase::setupParams() CaptureFormat raw = {"INDI_RAW", (m_maxBitDepth > 8) ? (std::string("RAW ") + std::to_string(m_maxBitDepth)).c_str() : "RAW 8", static_cast((m_maxBitDepth > 8) ? 16 : 8), true }; m_Channels = 1; - IUSaveText(&BayerT[2], getBayerString());// Get RAW Format + BayerTP[2].setText(getBayerString());// Get RAW Format addCaptureFormat(rgb); addCaptureFormat(raw); @@ -1343,7 +1342,7 @@ bool ToupBase::StopStreaming() int ToupBase::SetTemperature(double temperature) { // JM 2023.11.21: Only activate cooler if the requested temperature is below current temperature - if (temperature < TemperatureN[0].value && activateCooler(true) == false) + if (temperature < TemperatureNP[0].getValue() && activateCooler(true) == false) { LOG_ERROR("Failed to toggle cooler."); return -1; @@ -1569,29 +1568,29 @@ void ToupBase::TimerHit() HRESULT rc = FP(get_Temperature(m_Handle, &nTemperature)); if (FAILED(rc)) { - if (TemperatureNP.s != IPS_ALERT) + if (TemperatureNP.getState() != IPS_ALERT) { - TemperatureNP.s = IPS_ALERT; - IDSetNumber(&TemperatureNP, nullptr); + TemperatureNP.setState(IPS_ALERT); + TemperatureNP.apply(); LOGF_ERROR("get Temperature error. %s", errorCodes(rc).c_str()); } } - else if (TemperatureNP.s == IPS_ALERT) - TemperatureNP.s = IPS_OK; + else if (TemperatureNP.getState() == IPS_ALERT) + TemperatureNP.setState(IPS_OK); - TemperatureN[0].value = nTemperature / 10.0; + TemperatureNP[0].setValue(nTemperature / 10.0); auto threshold = HasCooler() ? 0.1 : 0.2; - switch (TemperatureNP.s) + switch (TemperatureNP.getState()) { case IPS_IDLE: case IPS_OK: case IPS_BUSY: - if (std::abs(TemperatureN[0].value - m_LastTemperature) > threshold) + if (std::abs(TemperatureNP[0].getValue() - m_LastTemperature) > threshold) { - m_LastTemperature = TemperatureN[0].value; - IDSetNumber(&TemperatureNP, nullptr); + m_LastTemperature = TemperatureNP[0].getValue(); + TemperatureNP.apply(); } break; @@ -2058,8 +2057,8 @@ bool ToupBase::SetCaptureFormat(uint8_t index) else { SetCCDCapability(GetCCDCapability() | CCD_HAS_BAYER); - IUSaveText(&BayerT[2], getBayerString()); - IDSetText(&BayerTP, nullptr); + BayerTP[2].setText(getBayerString()); + BayerTP.apply(); m_BitsPerPixel = (m_maxBitDepth > 8) ? 16 : 8; } }