ENH:support setting chamber temperature

Change-Id: Icacd3f248a8f4dbff6c928e666f986c62801eebd
This commit is contained in:
tao wang 2023-07-06 10:53:28 +08:00 committed by Lane.Wei
parent 403c5e825d
commit 771bc38a02
5 changed files with 122 additions and 27 deletions

View file

@ -462,6 +462,7 @@ MachineObject::MachineObject(NetworkAgent* agent, std::string name, std::string
bed_temp = 0.0f;
bed_temp_target = 0.0f;
chamber_temp = 0.0f;
chamber_temp_target = 0;
frame_temp = 0.0f;
/* ams fileds */
@ -1720,6 +1721,12 @@ int MachineObject::command_set_nozzle(int temp)
return this->publish_gcode(gcode_str);
}
int MachineObject::command_set_chamber(int temp)
{
std::string gcode_str = (boost::format("M141 S%1%\n") % temp).str();
return this->publish_gcode(gcode_str);
}
int MachineObject::command_ams_switch(int tray_index, int old_temp, int new_temp)
{
BOOST_LOG_TRIVIAL(trace) << "ams_switch to " << tray_index << " with temp: " << old_temp << ", " << new_temp;
@ -2980,6 +2987,11 @@ int MachineObject::parse_json(std::string payload)
chamber_temp = jj["chamber_temper"].get<float>();
}
}
if (jj.contains("ctt")) {
if (jj["ctt"].is_number()) {
chamber_temp_target = jj["ctt"].get<int>();
}
}
/* signals */
if (jj.contains("link_th_state"))
link_th = jj["link_th_state"].get<std::string>();
@ -5121,6 +5133,22 @@ bool DeviceManager::get_bed_temperature_limit(std::string type_str, int &limit)
return result;
}
bool DeviceManager::get_nozzle_max_temperature(std::string type_str, int& limit)
{
bool result = false;
if (DeviceManager::function_table.contains("printers")) {
for (auto printer : DeviceManager::function_table["printers"]) {
if (printer.contains("model_id") && printer["model_id"].get<std::string>() == type_str) {
if (printer.contains("nozzle_max_temperature")) {
limit = printer["nozzle_max_temperature"].get<int>();
return true;
}
}
}
}
return result;
}
bool DeviceManager::load_functional_config(std::string config_file)
{
std::ifstream json_file(config_file.c_str());