From 0ed457207e2ec31cca276667af9c4ffa392f9843 Mon Sep 17 00:00:00 2001 From: "xin.zhang" Date: Wed, 12 Mar 2025 18:11:50 +0800 Subject: [PATCH] FIX: add hms action buttons jira: [STUDIO-10823] Change-Id: I751f0951df439a5265cc53f5679fa69b8d1c728a --- src/slic3r/GUI/DeviceManager.cpp | 44 +++++++++++++++++++++++++ src/slic3r/GUI/DeviceManager.hpp | 7 ++++ src/slic3r/GUI/ReleaseNote.cpp | 56 +++++++++++++++++++++++++++++++- src/slic3r/GUI/ReleaseNote.hpp | 15 +++++++-- src/slic3r/GUI/StatusPanel.cpp | 33 ++++++++++++++++++- src/slic3r/GUI/StatusPanel.hpp | 1 + 6 files changed, 152 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index bb06a9140..ea98a96f2 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -2031,6 +2031,50 @@ int MachineObject::command_task_resume() return this->publish_json(j.dump(), 1); } +int MachineObject::command_hms_idle_ignore(const std::string &error_str, int type) +{ + json j; + j["print"]["command"] = "idle_ignore"; + j["print"]["err"] = error_str; + j["print"]["type"] = type; + j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); + return this->publish_json(j.dump(), 1); +} + +int MachineObject::command_hms_resume(const std::string& error_str, const std::string& job_id) +{ + json j; + j["print"]["command"] = "resume"; + 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_hms_ignore(const std::string& error_str, const std::string& job_id) +{ + json j; + j["print"]["command"] = "ignore"; + 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; + j["print"]["command"] = "buzzer_ctrl"; + j["print"]["mode"] = 0; + j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); + + return this->publish_json(j.dump(), 1); +} + int MachineObject::command_set_bed(int temp) { std::string gcode_str = (boost::format("M140 S%1%\n") % temp).str(); diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 11fde3a71..d1aa7e0d1 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -1146,6 +1146,13 @@ public: int command_task_cancel(std::string job_id); int command_task_pause(); int command_task_resume(); + 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); + /* buzzer*/ + int command_stop_buzzer(); + + /* temp*/ int command_set_bed(int temp); int command_set_nozzle(int temp); int command_set_nozzle_new(int nozzle_id, int temp); diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index a14ab8167..da7fc3989 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -40,6 +40,7 @@ wxDEFINE_EVENT(EVT_UPDATE_NOZZLE, wxCommandEvent); wxDEFINE_EVENT(EVT_JUMP_TO_HMS, wxCommandEvent); wxDEFINE_EVENT(EVT_JUMP_TO_LIVEVIEW, wxCommandEvent); wxDEFINE_EVENT(EVT_UPDATE_TEXT_MSG, wxCommandEvent); +wxDEFINE_EVENT(EVT_ERROR_DIALOG_BTN_CLICKED, wxCommandEvent); ReleaseNoteDialog::ReleaseNoteDialog(Plater *plater /*= nullptr*/) : DPIDialog(static_cast(wxGetApp().mainframe), wxID_ANY, _L("Release Note"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX) @@ -900,7 +901,17 @@ PrintErrorDialog::PrintErrorDialog(wxWindow* parent, wxWindowID id, const wxStri wxGetApp().UpdateFrameDarkUI(this); } -void PrintErrorDialog::post_event(wxCommandEvent&& event) +void PrintErrorDialog::post_event(wxCommandEvent& event) +{ + if (event_parent) { + event.SetString(""); + event.SetEventObject(event_parent); + wxPostEvent(event_parent, event); + event.Skip(); + } +} + +void PrintErrorDialog::post_event(wxCommandEvent &&event) { if (event_parent) { event.SetString(""); @@ -1154,6 +1165,49 @@ void PrintErrorDialog::init_button_list() post_event(wxCommandEvent(EVT_JUMP_TO_LIVEVIEW)); e.Skip(); }); + + init_button(NO_REMINDER_NEXT_TIME, _L("No Reminder Next Time")); + m_button_list[NO_REMINDER_NEXT_TIME]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) { + wxCommandEvent evt(EVT_ERROR_DIALOG_BTN_CLICKED); + evt.SetInt(NO_REMINDER_NEXT_TIME); + post_event(evt); + e.Skip(); + }); + + init_button(IGNORE_NO_REMINDER_NEXT_TIME, _L("Ignore. Don't Remind Next Time")); + m_button_list[IGNORE_NO_REMINDER_NEXT_TIME]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) { + wxCommandEvent evt(EVT_ERROR_DIALOG_BTN_CLICKED); + evt.SetInt(IGNORE_NO_REMINDER_NEXT_TIME); + post_event(evt); + e.Skip(); + }); + + init_button(IGNORE_RESUME, _L("Ignore this and Resume")); + m_button_list[IGNORE_RESUME]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) + { + wxCommandEvent evt(EVT_ERROR_DIALOG_BTN_CLICKED); + evt.SetInt(IGNORE_RESUME); + post_event(evt); + e.Skip(); + }); + + init_button(PROBLEM_SOLVED_RESUME, _L("Problem Solved and Resume")); + m_button_list[PROBLEM_SOLVED_RESUME]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) + { + wxCommandEvent evt(EVT_ERROR_DIALOG_BTN_CLICKED); + evt.SetInt(PROBLEM_SOLVED_RESUME); + post_event(evt); + e.Skip(); + }); + + init_button(STOP_BUZZER, _L("Stop Buzzer")); + m_button_list[STOP_BUZZER]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) + { + wxCommandEvent evt(EVT_ERROR_DIALOG_BTN_CLICKED); + evt.SetInt(STOP_BUZZER); + post_event(evt); + e.Skip(); + }); } PrintErrorDialog::~PrintErrorDialog() diff --git a/src/slic3r/GUI/ReleaseNote.hpp b/src/slic3r/GUI/ReleaseNote.hpp index 7320e6f4a..174cd1f12 100644 --- a/src/slic3r/GUI/ReleaseNote.hpp +++ b/src/slic3r/GUI/ReleaseNote.hpp @@ -38,6 +38,7 @@ #include #include + namespace Slic3r { namespace GUI { wxDECLARE_EVENT(EVT_SECONDARY_CHECK_CONFIRM, wxCommandEvent); @@ -51,6 +52,7 @@ wxDECLARE_EVENT(EVT_LOAD_VAMS_TRAY, wxCommandEvent); wxDECLARE_EVENT(EVT_JUMP_TO_HMS, wxCommandEvent); wxDECLARE_EVENT(EVT_JUMP_TO_LIVEVIEW, wxCommandEvent); wxDECLARE_EVENT(EVT_UPDATE_TEXT_MSG, wxCommandEvent); +wxDECLARE_EVENT(EVT_ERROR_DIALOG_BTN_CLICKED, wxCommandEvent); class ReleaseNoteDialog : public DPIDialog { @@ -167,7 +169,7 @@ class PrintErrorDialog : public DPIFrame private: wxWindow* event_parent{ nullptr }; public: - enum PrintErrorButton { + enum PrintErrorButton : int { RESUME_PRINTING = 2, RESUME_PRINTING_DEFECTS = 3, RESUME_PRINTING_PROBELM_SOLVED = 4, @@ -178,8 +180,16 @@ public: CONTINUE = 9, LOAD_VIRTUAL_TRAY = 10, OK_BUTTON = 11, - FILAMENT_LOAD_RESUME, + FILAMENT_LOAD_RESUME = 12, JUMP_TO_LIVEVIEW, + + NO_REMINDER_NEXT_TIME = 23, + IGNORE_NO_REMINDER_NEXT_TIME = 25, + //LOAD_FILAMENT = 26, /*TODO*/ + IGNORE_RESUME = 27, + PROBLEM_SOLVED_RESUME = 28, + STOP_BUZZER = 29, + ERROR_BUTTON_COUNT }; PrintErrorDialog( @@ -194,6 +204,7 @@ public: void on_show(); void on_hide(); void update_title_style(wxString title, std::vector style, wxWindow* parent = nullptr); + void post_event(wxCommandEvent& event); void post_event(wxCommandEvent&& event); void rescale(); ~PrintErrorDialog(); diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index 6933f9c90..b5376251b 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -2298,7 +2298,7 @@ StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, co if (m_print_error_dlg) m_print_error_dlg->on_hide(); }); - + Bind(EVT_ERROR_DIALOG_BTN_CLICKED, &StatusPanel::on_print_error_dlg_btn_clicked, this); m_switch_speed->Connect(wxEVT_LEFT_DOWN, wxCommandEventHandler(StatusPanel::on_switch_speed), NULL, this); m_calibration_btn->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_start_calibration), NULL, this); @@ -4640,6 +4640,37 @@ void StatusPanel::on_print_error_done(wxCommandEvent& event) } } +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(); + } + + if (m_print_error_dlg) { m_print_error_dlg->on_hide(); } + if (m_print_error_dlg_no_action) { m_print_error_dlg_no_action->on_hide();} + } +} + void StatusPanel::on_fan_changed(wxCommandEvent& event) { auto type = event.GetInt(); diff --git a/src/slic3r/GUI/StatusPanel.hpp b/src/slic3r/GUI/StatusPanel.hpp index db6cda5c6..5e61f33f9 100644 --- a/src/slic3r/GUI/StatusPanel.hpp +++ b/src/slic3r/GUI/StatusPanel.hpp @@ -700,6 +700,7 @@ protected: void on_ams_guide(wxCommandEvent &event); void on_ams_retry(wxCommandEvent &event); void on_print_error_done(wxCommandEvent& event); + void on_print_error_dlg_btn_clicked(wxCommandEvent& event); void on_fan_changed(wxCommandEvent& event); void on_cham_temp_kill_focus(wxFocusEvent& event);