From 936073366117ed7e9cf134cf02adf6508705e15d Mon Sep 17 00:00:00 2001 From: hemai Date: Tue, 2 Sep 2025 15:22:24 +0800 Subject: [PATCH] ENH: support proceed action Jira: [STUDIO-13620] Change-Id: I4ec96fc3adab517196b9725a54241575288c3bbf (cherry picked from commit 240e26147917c32749427f31ebe7623500334ed6) --- src/slic3r/GUI/DeviceErrorDialog.cpp | 16 +++++++++++++++ src/slic3r/GUI/DeviceErrorDialog.hpp | 15 ++++++++++++++ src/slic3r/GUI/DeviceManager.cpp | 29 ++++++++++++++++++++++++++-- src/slic3r/GUI/DeviceManager.hpp | 5 +++-- 4 files changed, 61 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/DeviceErrorDialog.cpp b/src/slic3r/GUI/DeviceErrorDialog.cpp index be7b0fa704..a365588f9c 100644 --- a/src/slic3r/GUI/DeviceErrorDialog.cpp +++ b/src/slic3r/GUI/DeviceErrorDialog.cpp @@ -172,7 +172,9 @@ void DeviceErrorDialog::init_button_list() init_button(PROBLEM_SOLVED_RESUME, _L("Problem Solved and Resume")); init_button(TURN_OFF_FIRE_ALARM, _L("Got it, Turn off the Fire Alarm.")); init_button(RETRY_PROBLEM_SOLVED, _L("Retry (problem solved)")); + init_button(CANCLE, _L("Cancle")); init_button(STOP_DRYING, _L("Stop Drying")); + init_button(PROCEED, _L("Proceed")); init_button(DBL_CHECK_CANCEL, _L("Cancle")); init_button(DBL_CHECK_DONE, _L("Done")); init_button(DBL_CHECK_RETRY, _L("Retry")); @@ -433,10 +435,24 @@ void DeviceErrorDialog::on_button_click(ActionButton btn_id) m_obj->command_ams_control("resume"); break; } + case DeviceErrorDialog::CANCLE: { + break; + } case DeviceErrorDialog::STOP_DRYING: { m_obj->command_ams_drying_stop(); break; } + case DeviceErrorDialog::PROCEED: { + if(!m_action_json.is_null()){ + try{ + ActionProceed proceed = m_action_json.get(); + m_obj->command_ack_proceed(proceed); + } catch(...){ + BOOST_LOG_TRIVIAL(error) << "DeviceErrorDialog: Action Proceed missing params."; + } + } + break; + } case DeviceErrorDialog::ERROR_BUTTON_COUNT: break; case DeviceErrorDialog::DBL_CHECK_CANCEL: { diff --git a/src/slic3r/GUI/DeviceErrorDialog.hpp b/src/slic3r/GUI/DeviceErrorDialog.hpp index fb970c3209..4fed2d402d 100644 --- a/src/slic3r/GUI/DeviceErrorDialog.hpp +++ b/src/slic3r/GUI/DeviceErrorDialog.hpp @@ -6,6 +6,7 @@ #include "GUI_Utils.hpp" #include "Widgets/StateColor.hpp" +#include class Label; class Button; @@ -16,6 +17,15 @@ class MachineObject;//Previous definitions namespace GUI { +struct ActionProceed{ + std::string command; + uint16_t err_index; + uint32_t err_code; + std::vector err_ignored; +}; +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Slic3r::GUI::ActionProceed, command, err_index, err_code, err_ignored); + + class DeviceErrorDialog : public DPIDialog { public: @@ -42,7 +52,9 @@ public: RETRY_PROBLEM_SOLVED = 34, STOP_DRYING = 35, + CANCLE = 37, REMOVE_CLOSE_BTN = 39, // special case, do not show close button + PROCEED = 41, ERROR_BUTTON_COUNT, @@ -53,6 +65,8 @@ public: DBL_CHECK_RESUME = 10003, DBL_CHECK_OK = 10004, }; + /* action params json */ + nlohmann::json m_action_json; public: DeviceErrorDialog(MachineObject* obj, @@ -66,6 +80,7 @@ public: public: wxString show_error_code(int error_code); + void set_action_json(const nlohmann::json &action_json) { m_action_json = action_json; } protected: void init_button_list(); diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 416321f195..be83651974 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -2111,6 +2111,20 @@ int MachineObject::command_xcam_control(std::string module_name, bool on_off, st return this->publish_json(j); } +int MachineObject::command_ack_proceed(GUI::ActionProceed& proceed) { + if(proceed.command.empty()) return -1; + + proceed.err_ignored.push_back(proceed.err_index); + + json j; + j["print"]["command"] = proceed.command; + j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); + j["print"]["err_code"] = 0; + j["print"]["err_index"] = proceed.err_index; + j["print"]["err_ignored"] = proceed.err_ignored; + return this->publish_json(j); +} + int MachineObject::command_xcam_control_ai_monitoring(bool on_off, std::string lvl) { bool print_halt = (lvl == "never_halt") ? false:true; @@ -2984,6 +2998,16 @@ int MachineObject::parse_json(std::string tunnel, std::string payload, bool key_ { if (jj["err_code"].is_number()) { add_command_error_code_dlg(jj["err_code"].get());} } + /* proceed action*/ + else if (is_studio_cmd(sequence_id) && jj.contains("command") && jj.contains("err_code") && jj.contains("err_index")) { + json action_json; + action_json["command"] = jj["command"]; + action_json["err_code"] = jj["err_code"]; + action_json["err_index"] = jj["err_index"]; + action_json["err_ignored"] = jj.contains("err_ignored") ? jj["err_ignored"] : json::array(); + + add_command_error_code_dlg(jj["err_code"].get(), action_json); + } } if (jj["command"].get() == "push_status") { @@ -5326,11 +5350,11 @@ std::string MachineObject::get_error_code_str(int error_code) return print_error_str; } -void MachineObject::add_command_error_code_dlg(int command_err) +void MachineObject::add_command_error_code_dlg(int command_err, json action_json) { if (command_err > 0 && !Slic3r::GUI::wxGetApp().get_hms_query()->is_internal_error(this, command_err)) { - GUI::wxGetApp().CallAfter([this, command_err, token = std::weak_ptr(m_token)] + GUI::wxGetApp().CallAfter([this, command_err, action_json, token = std::weak_ptr(m_token)] { if (token.expired()) { return;} GUI::DeviceErrorDialog* device_error_dialog = new GUI::DeviceErrorDialog(this, (wxWindow*)GUI::wxGetApp().mainframe); @@ -5340,6 +5364,7 @@ void MachineObject::add_command_error_code_dlg(int command_err) event.Skip(); }); + if(!action_json.is_null()) device_error_dialog->set_action_json(action_json); device_error_dialog->show_error_code(command_err); m_command_error_code_dlgs.insert(device_error_dialog); }); diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index b09954bbb8..d6771f125f 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -20,7 +20,7 @@ #include "DeviceCore/DevDefs.h" #include "DeviceCore/DevConfigUtil.h" #include "DeviceCore/DevFirmware.h" - +#include "DeviceErrorDialog.hpp" #include #include @@ -401,7 +401,7 @@ public: std::string get_print_error_str() const { return MachineObject::get_error_code_str(this->print_error); } std::unordered_set m_command_error_code_dlgs; - void add_command_error_code_dlg(int command_err); + void add_command_error_code_dlg(int command_err, json action_json=json{}); int curr_layer = 0; int total_layers = 0; @@ -685,6 +685,7 @@ public: int command_set_printer_nozzle(std::string nozzle_type, float diameter); int command_set_printer_nozzle2(int id, std::string nozzle_type, float diameter); int command_get_access_code(); + int command_ack_proceed(GUI::ActionProceed& proceed); /* command upgrade */ int command_upgrade_confirm();