diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index b23fffcbe9..c670bf662d 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -2018,6 +2018,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 0dfd6e9541..3081d5118b 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -1149,6 +1149,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 5abf6e1ba0..af1b52cf35 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -43,6 +43,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) @@ -909,7 +910,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(""); @@ -1163,6 +1174,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 2b8b275389..c15688808e 100644 --- a/src/slic3r/GUI/ReleaseNote.hpp +++ b/src/slic3r/GUI/ReleaseNote.hpp @@ -53,6 +53,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 { @@ -169,7 +170,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, @@ -180,8 +181,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( @@ -196,6 +205,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 fb35f2d5a2..65c9265bfe 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -2332,7 +2332,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); @@ -4651,6 +4651,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 130aed2565..fd450f286c 100644 --- a/src/slic3r/GUI/StatusPanel.hpp +++ b/src/slic3r/GUI/StatusPanel.hpp @@ -696,6 +696,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);