Skip to content

Commit

Permalink
Migrate Temperature Property (#2106)
Browse files Browse the repository at this point in the history
* Migrate Temperature Property

* Migrate Bayer Property

* Migrate WorldCoordSP Property

* Migrate CCDRotationNP, ImageFrameNP and ImageBinNP Properties

* use updateMinMax()

* Migrate FastExposureToggleSP Property

* Migrate ImagePixelSizeNP, ImageExposureNP, FastExposureCountNP, WebSocketSP, EqNP, J2000EqNP Properties

* Migrate AbortExposureSP Property

* Migrate UploadSP Property

* Migrate CompressSP Property

* Migrate FrameTypeSP Property

* Migrate ResetSP Property

* Migrate UploadSettingsTP Property

* Migrate FileNameTP Property

* Fix build issues

* Add missing {1}

* update getCCDInfo condition

* use setPermission

* Use snoop property

* Fix requested changes

* Remove unnecessary code

* Update getFileIndex

* update getFileIndex param types
  • Loading branch information
naheedsa authored Sep 14, 2024
1 parent 71a7ed5 commit a2ab009
Show file tree
Hide file tree
Showing 8 changed files with 597 additions and 578 deletions.
34 changes: 17 additions & 17 deletions drivers/ccd/ccd_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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
{
Expand Down
28 changes: 14 additions & 14 deletions drivers/ccd/guide_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ bool GuideSim::SetupParms()

if (HasCooler())
{
TemperatureN[0].value = 20;
IDSetNumber(&TemperatureNP, nullptr);
TemperatureNP[0].setValue(20);
TemperatureNP.apply();
}

// Kwiq
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/v4l2driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
12 changes: 6 additions & 6 deletions examples/tutorial_three/simpleccd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <memory>

/* Macro shortcut to CCD temperature value */
#define currentCCDTemperature TemperatureN[0].value
#define currentCCDTemperature TemperatureNP[0].value

std::unique_ptr<SimpleCCD> simpleCCD(new SimpleCCD());

Expand Down Expand Up @@ -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:
Expand All @@ -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;

Expand Down
Loading

0 comments on commit a2ab009

Please sign in to comment.