Kirdy::set_tec_current

This commit is contained in:
Sébastien Bourdeauducq 2025-01-19 19:25:55 +08:00
parent 22492da21b
commit f24c710af2
3 changed files with 14 additions and 3 deletions

View File

@ -29,8 +29,17 @@ Json::Value Kirdy::command(Json::Value &request)
float Kirdy::get_laser_temp()
{
Json::Value json;
json["device_cmd"] = "GetStatusReport";
auto reply = command(json);
Json::Value request;
request["device_cmd"] = "GetStatusReport";
Json::Value reply = command(request);
return reply["thermostat"]["temperature"].asFloat();
}
void Kirdy::set_tec_current(float amps)
{
Json::Value request;
request["tec_set_i"] = amps;
Json::Value reply = command(request);
if(reply["msg_type"].asString() != "Acknowledge")
std::cerr << "TEC set current failed" << std::endl;
}

View File

@ -10,4 +10,5 @@ class Kirdy {
public:
Kirdy(asio::string_view host, asio::string_view service);
float get_laser_temp();
void set_tec_current(float amps);
};

View File

@ -260,6 +260,7 @@ static void servo_thread(int channel)
while(!shutdown_threads) {
clocker.tick();
laser_temp[channel] = kirdy.get_laser_temp();
kirdy.set_tec_current(0.01);
}
}