Skip to content

Commit

Permalink
Cooler power must be a number property to comply with INDI standard p…
Browse files Browse the repository at this point in the history
…roperties
  • Loading branch information
knro committed Jan 5, 2024
1 parent 39c2b7b commit aee8bcf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
28 changes: 12 additions & 16 deletions indi-toupbase/indi_toupbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,8 @@ bool ToupBase::initProperties()
IUFillSwitchVector(&m_CoolerSP, m_CoolerS, 2, getDeviceName(), "CCD_COOLER", "Cooler", MAIN_CONTROL_TAB, IP_WO, ISR_1OFMANY,
0, IPS_BUSY);

IUFillText(&m_CoolerT, "COOLER_POWER", "Percent", nullptr);
IUFillTextVector(&m_CoolerTP, &m_CoolerT, 1, getDeviceName(), "CCD_COOLER_POWER", "Cooler Power", MAIN_CONTROL_TAB, IP_RO,
0,
IPS_IDLE);
m_CoolerNP[0].fill("COOLER_POWER", "Percent", "%.f", 0, 100, 10, 0);
m_CoolerNP.fill(getDeviceName(), "CCD_COOLER_POWER", "Cooler Power", MAIN_CONTROL_TAB, IP_RO, 0, IPS_IDLE);
}

///////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -330,7 +328,7 @@ bool ToupBase::updateProperties()
if (HasCooler())
{
defineProperty(&m_CoolerSP);
defineProperty(&m_CoolerTP);
defineProperty(m_CoolerNP);
}

// Even if there is no cooler, we define temperature property as READ ONLY
Expand Down Expand Up @@ -382,7 +380,7 @@ bool ToupBase::updateProperties()
if (HasCooler())
{
deleteProperty(m_CoolerSP.name);
deleteProperty(m_CoolerTP.name);
deleteProperty(m_CoolerNP);
}
else
{
Expand Down Expand Up @@ -1524,25 +1522,23 @@ void ToupBase::TimerHit()
int val = 0;
HRESULT rc = FP(get_Option(m_Handle, CP(OPTION_TEC), &val));
if (FAILED(rc))
m_CoolerTP.s = IPS_ALERT;
m_CoolerNP.setState(IPS_ALERT);
else if (0 == val)
{
m_CoolerTP.s = IPS_IDLE;
IUSaveText(&m_CoolerT, "0.0% (OFF)");
IDSetText(&m_CoolerTP, nullptr);
m_CoolerNP.setState(IPS_IDLE);
m_CoolerNP[0].setValue(0);
m_CoolerNP.apply();
}
else
{
rc = FP(get_Option(m_Handle, CP(OPTION_TEC_VOLTAGE), &val));
if (FAILED(rc))
m_CoolerTP.s = IPS_ALERT;
m_CoolerNP.setState(IPS_ALERT);
else if (val <= m_maxTecVoltage)
{
char str[32];
sprintf(str, "%.1f%%", val * 100.0 / m_maxTecVoltage);
IUSaveText(&m_CoolerT, str);
m_CoolerTP.s = IPS_BUSY;
IDSetText(&m_CoolerTP, nullptr);
m_CoolerNP[0].setValue(val * 100.0 / m_maxTecVoltage);
m_CoolerNP.setState(IPS_BUSY);
m_CoolerNP.apply();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions indi-toupbase/indi_toupbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ class ToupBase : public INDI::CCD
ISwitchVectorProperty m_CoolerSP;
ISwitch m_CoolerS[2];

IText m_CoolerT;
ITextVectorProperty m_CoolerTP;
INDI::PropertyNumber m_CoolerNP {1};

int32_t m_maxTecVoltage { -1 };

INumberVectorProperty m_ControlNP;
Expand Down

0 comments on commit aee8bcf

Please sign in to comment.