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
Branches
No related tags found
No related merge requests found
...@@ -72,6 +72,11 @@ bool CoinCell::getSetpoint(float& temperature) ...@@ -72,6 +72,11 @@ bool CoinCell::getSetpoint(float& temperature)
return ret; return ret;
} }
bool CoinCell::getEnabled()
{
return heaters->getHeaterEnabled(heaterId);
}
bool CoinCell::setConnected(bool connected) bool CoinCell::setConnected(bool connected)
{ {
bool ret = true; bool ret = true;
......
...@@ -36,6 +36,7 @@ public: ...@@ -36,6 +36,7 @@ public:
bool isShorted(bool& detected); bool isShorted(bool& detected);
bool measureEis(std::filesystem::path path, std::string userStr = ""); bool measureEis(std::filesystem::path path, std::string userStr = "");
bool setEnabled(bool enable); bool setEnabled(bool enable);
bool getEnabled();
double getLastKnownCapacity(); double getLastKnownCapacity();
void setLastKnownCapacity(double cap); void setLastKnownCapacity(double cap);
double getFullVoltage(); double getFullVoltage();
......
...@@ -299,6 +299,44 @@ bool Heaters::getSetpoint(int heater, float& temperature) ...@@ -299,6 +299,44 @@ bool Heaters::getSetpoint(int heater, float& temperature)
return true; 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) bool Heaters::getTemperature(int heater, float& temperature)
{ {
......
...@@ -45,6 +45,8 @@ private: ...@@ -45,6 +45,8 @@ private:
bool heaterBad(int heater); bool heaterBad(int heater);
void recoverDevice(int device); void recoverDevice(int device);
bool getHeaterState(int heater, struct heater_state& state);
public: public:
Heaters(const std::vector<uint16_t> serials, Heaters(const std::vector<uint16_t> serials,
...@@ -56,6 +58,7 @@ public: ...@@ -56,6 +58,7 @@ public:
void reconnectDevices(); void reconnectDevices();
bool setHeaterEnabled(int heater, bool enabled); bool setHeaterEnabled(int heater, bool enabled);
bool getHeaterEnabled(int heater);
bool setSetpoint(int heater, float temperature); bool setSetpoint(int heater, float temperature);
bool getSetpoint(int heater, float& temperature); bool getSetpoint(int heater, float& temperature);
bool setRamp(int heater, time_t endTime, float temperature); bool setRamp(int heater, time_t endTime, float temperature);
......
...@@ -168,6 +168,10 @@ int main(int argc, char** argv) ...@@ -168,6 +168,10 @@ int main(int argc, char** argv)
else else
Log(Log::INFO, true, false)<<"Cell "<<i<<" temperature: "<<temperature; 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 else
{ {
...@@ -188,12 +192,12 @@ int main(int argc, char** argv) ...@@ -188,12 +192,12 @@ int main(int argc, char** argv)
continue; continue;
} }
Log(Log::ERROR, true, false)<<"Cell "<<coincellId<<" temperature: "<<temperature<<" setpoint: "<<setpoint; bool enabled = coinCells[coincellId]->getEnabled();
}
auto connected = multiplexers.getConnected(); Log(Log::ERROR, true, false)<<"Cell "<<coincellId<<':';
for(size_t i = 0; i < connected.size(); ++i) Log(Log::ERROR, true, false)<<"\ttemperature: "<<temperature<<"\n\tsetpoint: "<<setpoint<<"\t\nenabled: "<<enabled;
Log(Log::INFO, true, false)<<"multiplexer channel "<<i<<' '<<(connected[i] ? "connected" : "disconnected");
}
} }
else if(tokens[0] == "clear") 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