FIX: update the load or unload
jira: [STUDIO-10088] Change-Id: I234c1c092f403a42789c1eff67819420322fcdb7
This commit is contained in:
parent
405d0231b2
commit
9c7214428d
|
@ -2037,6 +2037,8 @@ int MachineObject::command_set_chamber(int temp)
|
|||
|
||||
int MachineObject::command_ams_switch(int tray_index, int old_temp, int new_temp)
|
||||
{
|
||||
assert(!is_enable_np);
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "ams_switch to " << tray_index << " with temp: " << old_temp << ", " << new_temp;
|
||||
if (old_temp < 0) old_temp = FILAMENT_DEF_TEMP;
|
||||
if (new_temp < 0) new_temp = FILAMENT_DEF_TEMP;
|
||||
|
@ -2077,16 +2079,28 @@ int MachineObject::command_ams_change_filament(int tray_id, int old_temp, int ne
|
|||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
int MachineObject::command_ams_change_filament2(int ams_id, int slot_id, int old_temp, int new_temp)
|
||||
int MachineObject::command_ams_change_filament2(bool load_or_unload, int ams_id, int slot_id, int old_temp, int new_temp)
|
||||
{
|
||||
assert(is_enable_np);
|
||||
|
||||
json j;
|
||||
j["print"]["command"] = "ams_change_filament";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["target"] = ams_id == VIRTUAL_TRAY_MAIN_ID?VIRTUAL_TRAY_DEPUTY_ID:slot_id;
|
||||
//j["print"]["target"] = ams_id == VIRTUAL_TRAY_MAIN_ID?VIRTUAL_TRAY_DEPUTY_ID:slot_id; /*this is not used in new protocol*/
|
||||
j["print"]["curr_temp"] = old_temp;
|
||||
j["print"]["tar_temp"] = new_temp;
|
||||
j["print"]["ams_id"] = ams_id;
|
||||
j["print"]["slot_id"] = slot_id;
|
||||
|
||||
// the new protocol
|
||||
if (load_or_unload)
|
||||
{
|
||||
j["print"]["slot_id"] = slot_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
j["print"]["slot_id"] = 255;// the new protocol to mark unload
|
||||
}
|
||||
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
|
|
|
@ -1102,7 +1102,7 @@ public:
|
|||
// ams controls
|
||||
int command_ams_switch(int tray_index, int old_temp = 210, int new_temp = 210);
|
||||
int command_ams_change_filament(int tray_id, int old_temp = 210, int new_temp = 210);
|
||||
int command_ams_change_filament2(int ams_id, int slot_id, int old_temp = 210, int new_temp = 210);
|
||||
int command_ams_change_filament2(bool load_or_unload, int ams_id, int slot_id, int old_temp = 210, int new_temp = 210);
|
||||
int command_ams_user_settings(int ams_id, bool start_read_opt, bool tray_read_opt, bool remain_flag = false);
|
||||
int command_ams_switch_filament(bool switch_filament);
|
||||
int command_ams_air_print_detect(bool air_print_detect);
|
||||
|
|
|
@ -3932,18 +3932,26 @@ void StatusPanel::on_ams_load_curr()
|
|||
|
||||
update_load_with_temp();
|
||||
//virtual tray
|
||||
if (curr_ams_id.compare(std::to_string(VIRTUAL_TRAY_MAIN_ID)) == 0) {
|
||||
if (curr_ams_id.compare(std::to_string(VIRTUAL_TRAY_MAIN_ID)) == 0 ||
|
||||
curr_ams_id.compare(std::to_string(VIRTUAL_TRAY_DEPUTY_ID)) == 0)
|
||||
{
|
||||
int vt_slot_idx = 0;
|
||||
if (curr_ams_id.compare(std::to_string(VIRTUAL_TRAY_DEPUTY_ID)) == 0)
|
||||
{
|
||||
vt_slot_idx = 1;
|
||||
}
|
||||
|
||||
int old_temp = -1;
|
||||
int new_temp = -1;
|
||||
AmsTray* curr_tray = &obj->vt_slot[0];
|
||||
AmsTray* curr_tray = &obj->vt_slot[vt_slot_idx];
|
||||
|
||||
if (!curr_tray) return;
|
||||
|
||||
try {
|
||||
if (!curr_tray->nozzle_temp_max.empty() && !curr_tray->nozzle_temp_min.empty())
|
||||
old_temp = (atoi(curr_tray->nozzle_temp_min.c_str()) + atoi(curr_tray->nozzle_temp_max.c_str())) / 2;
|
||||
if (!obj->vt_slot[0].nozzle_temp_max.empty() && !obj->vt_slot[0].nozzle_temp_min.empty())
|
||||
new_temp = (atoi(obj->vt_slot[0].nozzle_temp_min.c_str()) + atoi(obj->vt_slot[0].nozzle_temp_max.c_str())) / 2;
|
||||
if (!curr_tray->nozzle_temp_max.empty() && !curr_tray->nozzle_temp_min.empty())
|
||||
new_temp = (atoi(curr_tray->nozzle_temp_min.c_str()) + atoi(curr_tray->nozzle_temp_max.c_str())) / 2;
|
||||
}
|
||||
catch (...) {
|
||||
;
|
||||
|
@ -3952,7 +3960,7 @@ void StatusPanel::on_ams_load_curr()
|
|||
if (obj->is_enable_np) {
|
||||
try {
|
||||
if (!curr_ams_id.empty() && !curr_can_id.empty()) {
|
||||
obj->command_ams_change_filament2(stoi(curr_ams_id), 0, old_temp, new_temp);
|
||||
obj->command_ams_change_filament2(true, stoi(curr_ams_id), 0, old_temp, new_temp);
|
||||
}
|
||||
} catch (...) {}
|
||||
} else {
|
||||
|
@ -3992,7 +4000,7 @@ void StatusPanel::on_ams_load_curr()
|
|||
if (obj->is_enable_np) {
|
||||
try {
|
||||
if (!curr_ams_id.empty() && !curr_can_id.empty()) {
|
||||
obj->command_ams_change_filament2(stoi(curr_ams_id), stoi(curr_can_id), old_temp, new_temp);
|
||||
obj->command_ams_change_filament2(true, stoi(curr_ams_id), stoi(curr_can_id), old_temp, new_temp);
|
||||
}
|
||||
}
|
||||
catch (...){}
|
||||
|
@ -4055,7 +4063,7 @@ void StatusPanel::on_ams_unload(SimpleEvent &event)
|
|||
std::string curr_can_id = m_ams_control->GetCurrentCan(curr_ams_id);
|
||||
|
||||
for (auto ext : obj->m_extder_data.extders) {
|
||||
if (ext.snow.ams_id == curr_ams_id && ext.snow.slot_id == curr_can_id) { obj->command_ams_change_filament2(stoi(curr_ams_id), 255); }
|
||||
if (ext.snow.ams_id == curr_ams_id && ext.snow.slot_id == curr_can_id) { obj->command_ams_change_filament2(false, stoi(curr_ams_id), 0); }
|
||||
}
|
||||
} catch (...) {}
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue