From 69f0bafd8a3f0d639fa85a83deec10baac1bac22 Mon Sep 17 00:00:00 2001 From: "xin.zhang" Date: Fri, 18 Apr 2025 11:05:17 +0800 Subject: [PATCH] ENH: support the react of actions for HMS actions jira: [STUDIO-11664] Change-Id: I5444748946e5baa219d6d413efd4e954dc578064 --- src/slic3r/GUI/DeviceManager.cpp | 11 ++++ src/slic3r/GUI/DeviceManager.hpp | 1 + src/slic3r/GUI/ReleaseNote.hpp | 2 +- src/slic3r/GUI/StatusPanel.cpp | 90 +++++++++++++++++++++++--------- 4 files changed, 79 insertions(+), 25 deletions(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index f62013d38..9b7f6ca1a 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -2090,6 +2090,17 @@ int MachineObject::command_hms_ignore(const std::string& error_str, const std::s return this->publish_json(j.dump(), 1); } +int MachineObject::command_hms_stop(const std::string &error_str, const std::string &job_id) { + json j; + j["print"]["command"] = "stop"; + j["print"]["err"] = error_str; + j["print"]["param"] = "reserve"; + j["print"]["job_id"] = job_id; + j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); + + return this->publish_json(j.dump(), 1); +} + int MachineObject::command_stop_buzzer() { json j; diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 252c30e27..32412ba32 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -1185,6 +1185,7 @@ public: int command_hms_idle_ignore(const std::string &error_str, int type); int command_hms_resume(const std::string& error_str, const std::string& job_id); int command_hms_ignore(const std::string& error_str, const std::string& job_id); + int command_hms_stop(const std::string &error_str, const std::string &job_id); /* buzzer*/ int command_stop_buzzer(); diff --git a/src/slic3r/GUI/ReleaseNote.hpp b/src/slic3r/GUI/ReleaseNote.hpp index b029607fa..10f7cb94d 100644 --- a/src/slic3r/GUI/ReleaseNote.hpp +++ b/src/slic3r/GUI/ReleaseNote.hpp @@ -185,7 +185,7 @@ public: NO_REMINDER_NEXT_TIME = 23, IGNORE_NO_REMINDER_NEXT_TIME = 25, - //LOAD_FILAMENT = 26, /*TODO*/ + //LOAD_FILAMENT = 26*/ IGNORE_RESUME = 27, PROBLEM_SOLVED_RESUME = 28, STOP_BUZZER = 29, diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index 9002dd406..9d05b8dbe 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -4664,30 +4664,72 @@ void StatusPanel::on_print_error_dlg_btn_clicked(wxCommandEvent& event) { if (obj) { - int id = event.GetInt(); - if (id == PrintErrorDialog::NO_REMINDER_NEXT_TIME) - { - obj->command_hms_idle_ignore(std::to_string(before_error_code), 0);/*the type is 0, supported by AP*/ - } - else if (id == PrintErrorDialog::IGNORE_NO_REMINDER_NEXT_TIME) - { - obj->command_hms_ignore(std::to_string(before_error_code), obj->job_id_); - } - else if (id == PrintErrorDialog::IGNORE_RESUME) - { - obj->command_hms_ignore(std::to_string(before_error_code), obj->job_id_); - } - else if (id == PrintErrorDialog::PROBLEM_SOLVED_RESUME) - { - obj->command_hms_resume(std::to_string(before_error_code), obj->job_id_); - } - else if (id == PrintErrorDialog::STOP_BUZZER) - { - obj->command_stop_buzzer(); - } - else if (id == PrintErrorDialog::CONTINUE || id == PrintErrorDialog::RETRY_PROBLEM_SOLVED) - { - obj->command_ams_control("resume"); + PrintErrorDialog::PrintErrorButton btn_id = static_cast(event.GetInt()); + switch (btn_id) { + case Slic3r::GUI::PrintErrorDialog::RESUME_PRINTING: { + obj->command_hms_resume(std::to_string(before_error_code), obj->job_id_); + break; + } + case Slic3r::GUI::PrintErrorDialog::RESUME_PRINTING_DEFECTS: { + obj->command_hms_resume(std::to_string(before_error_code), obj->job_id_); + break; + } + case Slic3r::GUI::PrintErrorDialog::RESUME_PRINTING_PROBELM_SOLVED: { + obj->command_hms_resume(std::to_string(before_error_code), obj->job_id_); + break; + } + case Slic3r::GUI::PrintErrorDialog::STOP_PRINTING: { + obj->command_hms_stop(std::to_string(before_error_code), obj->job_id_); + break; + } + case Slic3r::GUI::PrintErrorDialog::CHECK_ASSISTANT: { + wxGetApp().mainframe->m_monitor->jump_to_HMS(event); // go to assistant page + break; + } + case Slic3r::GUI::PrintErrorDialog::FILAMENT_EXTRUDED: { + obj->command_ams_control("done"); + break; + } + case Slic3r::GUI::PrintErrorDialog::RETRY_FILAMENT_EXTRUDED: { + obj->command_ams_control("resume"); + break; + } + case Slic3r::GUI::PrintErrorDialog::CONTINUE: { + obj->command_ams_control("resume"); + break; + } + case Slic3r::GUI::PrintErrorDialog::LOAD_VIRTUAL_TRAY: break;/*Unknown what it is*/ + case Slic3r::GUI::PrintErrorDialog::OK_BUTTON: break;/*do nothing*/ + case Slic3r::GUI::PrintErrorDialog::FILAMENT_LOAD_RESUME: { + obj->command_hms_resume(std::to_string(before_error_code), obj->job_id_); + break; + } + case Slic3r::GUI::PrintErrorDialog::NO_REMINDER_NEXT_TIME: { + obj->command_hms_idle_ignore(std::to_string(before_error_code), 0); /*the type is 0, supported by AP*/ + break; + } + case Slic3r::GUI::PrintErrorDialog::IGNORE_NO_REMINDER_NEXT_TIME: { + obj->command_hms_ignore(std::to_string(before_error_code), obj->job_id_); + break; + } + case Slic3r::GUI::PrintErrorDialog::IGNORE_RESUME: { + obj->command_hms_ignore(std::to_string(before_error_code), obj->job_id_); + break; + } + case Slic3r::GUI::PrintErrorDialog::PROBLEM_SOLVED_RESUME: { + obj->command_hms_resume(std::to_string(before_error_code), obj->job_id_); + break; + } + case Slic3r::GUI::PrintErrorDialog::STOP_BUZZER: { + obj->command_stop_buzzer(); + break; + } + case Slic3r::GUI::PrintErrorDialog::RETRY_PROBLEM_SOLVED: { + obj->command_ams_control("resume"); + break; + } + case Slic3r::GUI::PrintErrorDialog::ERROR_BUTTON_COUNT: break; + default: break; } if (m_print_error_dlg) { m_print_error_dlg->on_hide(); }