Skip to content

Commit

Permalink
Update INDI CCD Properties (#972)
Browse files Browse the repository at this point in the history
* Update INDI CCD Properties

* Update qsi_ccd.cpp
  • Loading branch information
naheedsa committed Sep 14, 2024
1 parent dafbbdf commit fa35d75
Show file tree
Hide file tree
Showing 20 changed files with 255 additions and 249 deletions.
34 changes: 17 additions & 17 deletions indi-apogee/apogee_ccd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1299,30 +1299,30 @@ void ApogeeCCD::TimerHit()
}
}

switch (TemperatureNP.s)
switch (TemperatureNP.getState())
{
case IPS_IDLE:
case IPS_OK:

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;

Expand All @@ -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:
Expand Down
26 changes: 13 additions & 13 deletions indi-asi/asi_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -497,7 +497,7 @@ bool ASIBase::updateProperties()
deleteProperty(CoolerSP.getName());
}
else
deleteProperty(TemperatureNP.name);
deleteProperty(TemperatureNP);

if (!ControlNP.isEmpty())
deleteProperty(ControlNP.getName());
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand All @@ -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())
Expand Down
34 changes: 17 additions & 17 deletions indi-atik/atik_ccd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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)
Expand Down Expand Up @@ -243,7 +243,7 @@ bool ATIKCCD::updateProperties()
deleteProperty(CoolerSP.name);
}
else
deleteProperty(TemperatureNP.name);
deleteProperty(TemperatureNP);

if (m_isHorizon)
{
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand All @@ -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.");
Expand Down Expand Up @@ -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;

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

Expand All @@ -1173,7 +1173,7 @@ void ATIKCCD::TimerHit()
// {
// TemperatureNP.s = IPS_OK;
// }
IDSetNumber(&TemperatureNP, nullptr);
TemperatureNP.apply();
break;
}

Expand Down
4 changes: 2 additions & 2 deletions indi-dsi/dsi_ccd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions indi-fishcamp/indi_fishcamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -475,7 +475,7 @@ void FishCampCCD::TimerHit()
}
}

switch (TemperatureNP.s)
switch (TemperatureNP.getState())
{
case IPS_IDLE:
case IPS_OK:
Expand All @@ -487,33 +487,33 @@ 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;

case IPS_BUSY:
if (sim)
{
TemperatureN[0].value = TemperatureRequest;
TemperatureNP[0].setValue(TemperatureRequest);
}
else
{
rc = fcUsb_cmd_getTemperature(cameraNum);

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:
Expand Down
Loading

0 comments on commit fa35d75

Please sign in to comment.