Skip to content
Snippets Groups Projects
Commit bc543f19 authored by Carl Philipp Klemm's avatar Carl Philipp Klemm
Browse files

add the ability to read the enabled state per device

parent 18196e81
No related branches found
No related tags found
No related merge requests found
......@@ -72,6 +72,11 @@ bool CoinCell::getSetpoint(float& temperature)
return ret;
}
bool CoinCell::getEnabled()
{
return heaters->getHeaterEnabled(heaterId);
}
bool CoinCell::setConnected(bool connected)
{
bool ret = true;
......
......@@ -36,6 +36,7 @@ public:
bool isShorted(bool& detected);
bool measureEis(std::filesystem::path path, std::string userStr = "");
bool setEnabled(bool enable);
bool getEnabled();
double getLastKnownCapacity();
void setLastKnownCapacity(double cap);
double getFullVoltage();
......
......@@ -299,6 +299,44 @@ bool Heaters::getSetpoint(int heater, float& temperature)
return true;
}
bool Heaters::getHeaterState(int heater, struct heater_state& state)
{
int device = getAddress(heater).first;
int heaterId = getAddress(heater).second;
if(devices.size() <= device)
return false;
if(deviceBad(device))
return false;
devices[device].mutex->lock();
int ret = coincellhell_get_state(&devices[device].device, heaterId, &state);
devices[device].mutex->unlock();
if(ret != 0)
{
deviceError(device, ERR_CONNECTION);
if(deviceBad(device))
{
return false;
}
else
{
return getHeaterState(heater, state);
}
}
return true;
}
bool Heaters::getHeaterEnabled(int heater)
{
struct heater_state state;
bool ret = getHeaterState(heater, state);
if(!ret)
return false;
else
return state.enabled;
}
bool Heaters::getTemperature(int heater, float& temperature)
{
......
......@@ -45,6 +45,8 @@ private:
bool heaterBad(int heater);
void recoverDevice(int device);
bool getHeaterState(int heater, struct heater_state& state);
public:
Heaters(const std::vector<uint16_t> serials,
......@@ -56,6 +58,7 @@ public:
void reconnectDevices();
bool setHeaterEnabled(int heater, bool enabled);
bool getHeaterEnabled(int heater);
bool setSetpoint(int heater, float temperature);
bool getSetpoint(int heater, float& temperature);
bool setRamp(int heater, time_t endTime, float temperature);
......
......@@ -168,6 +168,10 @@ int main(int argc, char** argv)
else
Log(Log::INFO, true, false)<<"Cell "<<i<<" temperature: "<<temperature;
}
auto connected = multiplexers.getConnected();
for(size_t i = 0; i < connected.size(); ++i)
Log(Log::INFO, true, false)<<"multiplexer channel "<<i<<' '<<(connected[i] ? "connected" : "disconnected");
}
else
{
......@@ -188,12 +192,12 @@ int main(int argc, char** argv)
continue;
}
Log(Log::ERROR, true, false)<<"Cell "<<coincellId<<" temperature: "<<temperature<<" setpoint: "<<setpoint;
}
bool enabled = coinCells[coincellId]->getEnabled();
auto connected = multiplexers.getConnected();
for(size_t i = 0; i < connected.size(); ++i)
Log(Log::INFO, true, false)<<"multiplexer channel "<<i<<' '<<(connected[i] ? "connected" : "disconnected");
Log(Log::ERROR, true, false)<<"Cell "<<coincellId<<':';
Log(Log::ERROR, true, false)<<"\ttemperature: "<<temperature<<"\n\tsetpoint: "<<setpoint<<"\t\nenabled: "<<enabled;
}
}
else if(tokens[0] == "clear")
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment