diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 89635d82e..186ff3946 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -1725,8 +1725,13 @@ int MachineObject::command_select_extruder(int id) j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); j["print"]["command"] = "select_extruder"; j["print"]["extruder_index"] = id; + int rtn = this->publish_json(j.dump(), 1); + if (rtn == 0) + { + targ_nozzle_id_from_pc = id; + } - return this->publish_json(j.dump(), 1); + return rtn; } int MachineObject::command_get_version(bool with_retry) @@ -5991,10 +5996,12 @@ void MachineObject::parse_new_info(json print) if (m_extder_data.current_extder_id != extder_data.current_extder_id) { flag_update_nozzle = true; + targ_nozzle_id_from_pc = INVALID_NOZZLE_ID; } else if (extder_data.switch_extder_state == ES_SWITCHING_FAILED) { flag_update_nozzle = true; + targ_nozzle_id_from_pc = INVALID_NOZZLE_ID; } extder_data.current_loading_extder_id = get_flag_bits(extruder["state"].get(), 15, 4); diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index ec8da3467..489ddb2a5 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -948,6 +948,9 @@ public: int nozzle_selected_count = 0; bool flag_update_nozzle = {true}; + /*target from Studio-SwitchBoard, default to INVALID_NOZZLE_ID if no switching control from PC*/ + int targ_nozzle_id_from_pc = INVALID_NOZZLE_ID; + //supported features bool is_support_chamber_edit{false}; bool is_support_extrusion_cali{false}; diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index cad267594..52cb00ce9 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -2832,7 +2832,6 @@ void StatusPanel::update_misc_ctrl(MachineObject *obj) m_nozzle_btn_panel->updateState("left"); } - targ_nozzle_id_from_pc = INVALID_NOZZLE_ID;// the switching is finished obj->flag_update_nozzle = false; } @@ -2840,7 +2839,7 @@ void StatusPanel::update_misc_ctrl(MachineObject *obj) /* Can do switch while printing pause STUDIO-9789*/ if ((obj->is_in_printing() && !obj->is_in_printing_pause()) || obj->ams_status_main == AMS_STATUS_MAIN_FILAMENT_CHANGE || - targ_nozzle_id_from_pc != INVALID_NOZZLE_ID) + obj->targ_nozzle_id_from_pc != INVALID_NOZZLE_ID) { m_nozzle_btn_panel->Disable(); } @@ -4691,9 +4690,8 @@ void StatusPanel::on_nozzle_selected(wxCommandEvent &event) } auto nozzle_id = event.GetInt(); - if(obj->command_select_extruder(nozzle_id) == 0) + if (obj->command_select_extruder(nozzle_id) == 0) { - targ_nozzle_id_from_pc = nozzle_id; return; } } diff --git a/src/slic3r/GUI/StatusPanel.hpp b/src/slic3r/GUI/StatusPanel.hpp index ac8fc7930..d49d28474 100644 --- a/src/slic3r/GUI/StatusPanel.hpp +++ b/src/slic3r/GUI/StatusPanel.hpp @@ -411,8 +411,6 @@ protected: wxSimplebook* m_extruder_book; std::vector m_extruderImage; - /*the target nozzle id from PC-SwitchBoard, default to INVALID_NOZZLE_ID if not switching*/ - int targ_nozzle_id_from_pc = INVALID_NOZZLE_ID; SwitchBoard * m_nozzle_btn_panel; wxStaticText * m_text_tasklist_caption;