FIX: support open door check

jira: [STUDIO-9095]
Change-Id: I2e033641724beb15f649b04950c5de51be8722df
This commit is contained in:
xin.zhang 2025-02-24 17:41:44 +08:00 committed by lane.wei
parent f61beec992
commit d504010ee0
8 changed files with 140 additions and 8 deletions

View File

@ -1785,7 +1785,7 @@ void AmsReplaceMaterialDialog::create()
m_nozzle_btn_panel = new SwitchBoard(this, _L("Left"), _L("Right"), wxSize(FromDIP(126), FromDIP(26))); m_nozzle_btn_panel = new SwitchBoard(this, _L("Left"), _L("Right"), wxSize(FromDIP(126), FromDIP(26)));
m_nozzle_btn_panel->Hide(); m_nozzle_btn_panel->Hide();
m_nozzle_btn_panel->Connect(wxCUSTOMEVT_SELECT_NOZZLE_POS, wxCommandEventHandler(AmsReplaceMaterialDialog::on_nozzle_selected), NULL, this); m_nozzle_btn_panel->Connect(wxCUSTOMEVT_SWITCH_POS, wxCommandEventHandler(AmsReplaceMaterialDialog::on_nozzle_selected), NULL, this);
label_txt = new Label(this, _L("When the current material run out, the printer will continue to print in the following order.")); label_txt = new Label(this, _L("When the current material run out, the printer will continue to print in the following order."));
label_txt->SetFont(Label::Body_13); label_txt->SetFont(Label::Body_13);

View File

@ -5944,6 +5944,11 @@ void MachineObject::parse_new_info(json print)
ams_auto_switch_filament_flag = get_flag_bits(cfg, 18); ams_auto_switch_filament_flag = get_flag_bits(cfg, 18);
} }
if (time(nullptr) - xcam_door_open_check_start_time > HOLD_TIME_MAX)
{
xcam_door_open_check = (DoorOpenCheckState) get_flag_bits(cfg, 20, 2);
}
xcam_allow_prompt_sound = get_flag_bits(cfg, 22); xcam_allow_prompt_sound = get_flag_bits(cfg, 22);
xcam_filament_tangle_detect = get_flag_bits(cfg, 23); xcam_filament_tangle_detect = get_flag_bits(cfg, 23);
nozzle_blob_detection_enabled = get_flag_bits(cfg, 24); nozzle_blob_detection_enabled = get_flag_bits(cfg, 24);
@ -5966,6 +5971,7 @@ void MachineObject::parse_new_info(json print)
is_support_filament_tangle_detect = get_flag_bits(fun, 9); is_support_filament_tangle_detect = get_flag_bits(fun, 9);
is_support_motor_noise_cali = get_flag_bits(fun, 10); is_support_motor_noise_cali = get_flag_bits(fun, 10);
is_support_user_preset = get_flag_bits(fun, 11); is_support_user_preset = get_flag_bits(fun, 11);
is_support_door_open_check = get_flag_bits(fun, 12);
is_support_nozzle_blob_detection = get_flag_bits(fun, 13); is_support_nozzle_blob_detection = get_flag_bits(fun, 13);
is_support_upgrade_kit = get_flag_bits(fun, 14); is_support_upgrade_kit = get_flag_bits(fun, 14);
is_support_internal_timelapse = get_flag_bits(fun, 28); is_support_internal_timelapse = get_flag_bits(fun, 28);
@ -6516,6 +6522,26 @@ int MachineObject::command_handle_response(const json &response)
return 0; return 0;
} }
void MachineObject::command_set_door_open_check(DoorOpenCheckState state)
{
json j;
j["system"]["command"] = "set_door_stat";
j["system"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
switch (state)
{
case Slic3r::MachineObject::DOOR_OPEN_CHECK_DISABLE: j["system"]["config"] = 0; break;
case Slic3r::MachineObject::DOOR_OPEN_CHECK_ENABLE_WARNING: j["system"]["config"] = 1; break;
case Slic3r::MachineObject::DOOR_OPEN_CHECK_ENABLE_PAUSE_PRINT: j["system"]["config"] = 2; break;
default: assert(0); return;
}
if (publish_json(j.dump()) == 0)
{
xcam_door_open_check = state;
xcam_door_open_check_start_time = time(nullptr);
}
}
bool DeviceManager::EnableMultiMachine = false; bool DeviceManager::EnableMultiMachine = false;
bool DeviceManager::key_field_only = false; bool DeviceManager::key_field_only = false;

View File

@ -941,6 +941,14 @@ public:
FR_Agora, FR_Agora,
FR_TutkAgora FR_TutkAgora
} file_remote{ FR_None }; } file_remote{ FR_None };
enum DoorOpenCheckState : int
{
DOOR_OPEN_CHECK_DISABLE = 0,/*do nothing*/
DOOR_OPEN_CHECK_ENABLE_WARNING = 1,/*warning*/
DOOR_OPEN_CHECK_ENABLE_PAUSE_PRINT = 2,/*pause print*/
};
bool file_model_download{false}; bool file_model_download{false};
bool virtual_camera{false}; bool virtual_camera{false};
@ -1258,6 +1266,18 @@ public:
void check_ams_filament_valid(); void check_ams_filament_valid();
int command_handle_response(const json &response); int command_handle_response(const json &response);
/* xcam door open check*/
bool support_door_open_check() const { return is_support_door_open_check;};
DoorOpenCheckState get_door_open_check_state() const { return xcam_door_open_check;};
void command_set_door_open_check(DoorOpenCheckState state);
private:
/* xcam door open check*/
bool is_support_door_open_check = false;
DoorOpenCheckState xcam_door_open_check = DoorOpenCheckState::DOOR_OPEN_CHECK_DISABLE;
time_t xcam_door_open_check_start_time = 0;
}; };
class DeviceManager class DeviceManager

View File

@ -2,6 +2,8 @@
#include "I18N.hpp" #include "I18N.hpp"
#include "GUI_App.hpp" #include "GUI_App.hpp"
#include "libslic3r/Utils.hpp" #include "libslic3r/Utils.hpp"
#include "Widgets/SwitchButton.hpp"
#include "MsgDialog.hpp"
static const wxColour STATIC_BOX_LINE_COL = wxColour(238, 238, 238); static const wxColour STATIC_BOX_LINE_COL = wxColour(238, 238, 238);
static const wxColour STATIC_TEXT_CAPTION_COL = wxColour(100, 100, 100); static const wxColour STATIC_TEXT_CAPTION_COL = wxColour(100, 100, 100);
@ -49,6 +51,33 @@ PrintOptionsDialog::PrintOptionsDialog(wxWindow* parent)
evt.Skip(); evt.Skip();
}); });
m_cb_open_door->Bind(wxEVT_TOGGLEBUTTON, [this](wxCommandEvent &evt) {
if (m_cb_open_door->GetValue())
{
if (obj) { obj->command_set_door_open_check(MachineObject::DOOR_OPEN_CHECK_DISABLE); }
}
else
{
if (obj) { obj->command_set_door_open_check(MachineObject::DOOR_OPEN_CHECK_ENABLE_WARNING); }
}
evt.Skip();
});
open_door_switch_board->Bind(wxCUSTOMEVT_SWITCH_POS, [this](wxCommandEvent &evt)
{
if (evt.GetInt() == 0)
{
if (obj) { obj->command_set_door_open_check(MachineObject::DOOR_OPEN_CHECK_ENABLE_PAUSE_PRINT); }
}
else if (evt.GetInt() == 1)
{
if (obj) { obj->command_set_door_open_check(MachineObject::DOOR_OPEN_CHECK_ENABLE_WARNING); }
}
evt.Skip();
});
m_cb_plate_mark->Bind(wxEVT_TOGGLEBUTTON, [this](wxCommandEvent& evt) { m_cb_plate_mark->Bind(wxEVT_TOGGLEBUTTON, [this](wxCommandEvent& evt) {
if (obj) { if (obj) {
obj->command_xcam_control_buildplate_marker_detector(m_cb_plate_mark->GetValue()); obj->command_xcam_control_buildplate_marker_detector(m_cb_plate_mark->GetValue());
@ -100,6 +129,7 @@ void PrintOptionsDialog::update_ai_monitor_status()
void PrintOptionsDialog::update_options(MachineObject* obj_) void PrintOptionsDialog::update_options(MachineObject* obj_)
{ {
if (!obj_) return; if (!obj_) return;
if (obj_->is_support_ai_monitoring) { if (obj_->is_support_ai_monitoring) {
text_ai_monitoring->Show(); text_ai_monitoring->Show();
m_cb_ai_monitoring->Show(); m_cb_ai_monitoring->Show();
@ -182,6 +212,8 @@ void PrintOptionsDialog::update_options(MachineObject* obj_)
line7->Hide(); line7->Hide();
} }
UpdateOptionOpenDoorCheck(obj_);
this->Freeze(); this->Freeze();
m_cb_first_layer->SetValue(obj_->xcam_first_layer_inspector); m_cb_first_layer->SetValue(obj_->xcam_first_layer_inspector);
@ -204,6 +236,33 @@ void PrintOptionsDialog::update_options(MachineObject* obj_)
Layout(); Layout();
} }
void PrintOptionsDialog::UpdateOptionOpenDoorCheck(MachineObject *obj) {
if (!obj || !obj->support_door_open_check()) {
m_cb_open_door->Hide();
text_open_door->Hide();
open_door_line->Hide();
open_door_switch_board->Hide();
return;
}
if (obj->get_door_open_check_state() != MachineObject::DOOR_OPEN_CHECK_DISABLE) {
m_cb_open_door->SetValue(true);
open_door_switch_board->Enable();
if (obj->get_door_open_check_state() == MachineObject::DOOR_OPEN_CHECK_ENABLE_WARNING) {
open_door_switch_board->updateState("left");
open_door_switch_board->Refresh();
} else if (obj->get_door_open_check_state() == MachineObject::DOOR_OPEN_CHECK_ENABLE_PAUSE_PRINT) {
open_door_switch_board->updateState("right");
open_door_switch_board->Refresh();
}
} else {
m_cb_open_door->SetValue(false);
open_door_switch_board->Disable();
}
}
wxBoxSizer* PrintOptionsDialog::create_settings_group(wxWindow* parent) wxBoxSizer* PrintOptionsDialog::create_settings_group(wxWindow* parent)
{ {
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
@ -303,14 +362,31 @@ wxBoxSizer* PrintOptionsDialog::create_settings_group(wxWindow* parent)
line_sizer->Add(FromDIP(5), 0, 0, 0); line_sizer->Add(FromDIP(5), 0, 0, 0);
line_sizer->Add(m_cb_auto_recovery, 0, wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5)); line_sizer->Add(m_cb_auto_recovery, 0, wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5));
line_sizer->Add(text_auto_recovery, 1, wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5)); line_sizer->Add(text_auto_recovery, 1, wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5));
sizer->Add(0,0,0,wxTOP, FromDIP(15));
sizer->Add(line_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(18)); sizer->Add(line_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(18));
line_sizer->Add(FromDIP(5), 0, 0, 0); line_sizer->Add(FromDIP(5), 0, 0, 0);
line4 = new StaticLine(parent, false); line4 = new StaticLine(parent, false);
line4->SetLineColour(wxColour(255,255,255)); line4->SetLineColour(wxColour(255,255,255));
sizer->Add(line4, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(20)); sizer->Add(line4, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(20));
sizer->Add(0,0,0,wxTOP, FromDIP(20));
//Open Door Detection
line_sizer = new wxBoxSizer(wxHORIZONTAL);
m_cb_open_door = new CheckBox(parent);
text_open_door = new Label(parent, _L("Open Door Dectection"));
text_open_door->SetFont(Label::Body_14);
open_door_switch_board = new SwitchBoard(parent, _L("Notification"), _L("Pause printing"), wxSize(FromDIP(200), FromDIP(26)));
open_door_switch_board->Disable();
line_sizer->Add(FromDIP(5), 0, 0, 0);
line_sizer->Add(m_cb_open_door, 0, wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5));
line_sizer->Add(text_open_door, 1, wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5));
sizer->Add(0, 0, 0, wxTOP, FromDIP(15));
sizer->Add(line_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(18));
sizer->Add(open_door_switch_board, 0, wxLEFT, FromDIP(58));
line_sizer->Add(FromDIP(5), 0, 0, 0);
open_door_line = new StaticLine(parent, false);
open_door_line->SetLineColour(wxColour(255, 255, 255));
sizer->Add(open_door_line, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(20));
//Allow prompt sound //Allow prompt sound
line_sizer = new wxBoxSizer(wxHORIZONTAL); line_sizer = new wxBoxSizer(wxHORIZONTAL);

View File

@ -16,6 +16,9 @@
#include "Widgets/StaticLine.hpp" #include "Widgets/StaticLine.hpp"
#include "Widgets/ComboBox.hpp" #include "Widgets/ComboBox.hpp"
// Previous definitions
class SwitchBoard;
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
class PrinterPartsDialog : public DPIDialog class PrinterPartsDialog : public DPIDialog
@ -75,6 +78,7 @@ protected:
CheckBox* m_cb_ai_monitoring; CheckBox* m_cb_ai_monitoring;
CheckBox* m_cb_plate_mark; CheckBox* m_cb_plate_mark;
CheckBox* m_cb_auto_recovery; CheckBox* m_cb_auto_recovery;
CheckBox* m_cb_open_door;
CheckBox* m_cb_sup_sound; CheckBox* m_cb_sup_sound;
CheckBox* m_cb_filament_tangle; CheckBox* m_cb_filament_tangle;
CheckBox* m_cb_nozzle_blob; CheckBox* m_cb_nozzle_blob;
@ -85,6 +89,7 @@ protected:
Label* text_plate_mark; Label* text_plate_mark;
Label* text_plate_mark_caption; Label* text_plate_mark_caption;
Label* text_auto_recovery; Label* text_auto_recovery;
Label* text_open_door;
Label* text_sup_sound; Label* text_sup_sound;
Label* text_filament_tangle; Label* text_filament_tangle;
Label* text_nozzle_blob; Label* text_nozzle_blob;
@ -96,6 +101,8 @@ protected:
StaticLine* line5; StaticLine* line5;
StaticLine* line6; StaticLine* line6;
StaticLine* line7; StaticLine* line7;
StaticLine* open_door_line;
SwitchBoard* open_door_switch_board;
wxBoxSizer* create_settings_group(wxWindow* parent); wxBoxSizer* create_settings_group(wxWindow* parent);
bool print_halt = false; bool print_halt = false;
@ -123,6 +130,9 @@ public:
wxString sensitivity_level_to_label_string(enum AiMonitorSensitivityLevel level); wxString sensitivity_level_to_label_string(enum AiMonitorSensitivityLevel level);
std::string sensitivity_level_to_msg_string(enum AiMonitorSensitivityLevel level); std::string sensitivity_level_to_msg_string(enum AiMonitorSensitivityLevel level);
void set_ai_monitor_sensitivity(wxCommandEvent& evt); void set_ai_monitor_sensitivity(wxCommandEvent& evt);
private:
void UpdateOptionOpenDoorCheck(MachineObject *obj);
}; };
}} // namespace Slic3r::GUI }} // namespace Slic3r::GUI

View File

@ -2266,7 +2266,7 @@ StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, co
m_bpButton_z_down_10->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_z_down_10), NULL, this); m_bpButton_z_down_10->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_z_down_10), NULL, this);
m_bpButton_e_10->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_e_up_10), NULL, this); m_bpButton_e_10->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_e_up_10), NULL, this);
m_bpButton_e_down_10->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_e_down_10), NULL, this); m_bpButton_e_down_10->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_e_down_10), NULL, this);
m_nozzle_btn_panel->Connect(wxCUSTOMEVT_SELECT_NOZZLE_POS, wxCommandEventHandler(StatusPanel::on_nozzle_selected), NULL, this); m_nozzle_btn_panel->Connect(wxCUSTOMEVT_SWITCH_POS, wxCommandEventHandler(StatusPanel::on_nozzle_selected), NULL, this);
Bind(EVT_AMS_EXTRUSION_CALI, &StatusPanel::on_filament_extrusion_cali, this); Bind(EVT_AMS_EXTRUSION_CALI, &StatusPanel::on_filament_extrusion_cali, this);
Bind(EVT_AMS_LOAD, &StatusPanel::on_ams_load, this); Bind(EVT_AMS_LOAD, &StatusPanel::on_ams_load, this);
@ -2335,7 +2335,7 @@ StatusPanel::~StatusPanel()
m_bpButton_z_down_10->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_z_down_10), NULL, this); m_bpButton_z_down_10->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_z_down_10), NULL, this);
m_bpButton_e_10->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_e_up_10), NULL, this); m_bpButton_e_10->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_e_up_10), NULL, this);
m_bpButton_e_down_10->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_e_down_10), NULL, this); m_bpButton_e_down_10->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_e_down_10), NULL, this);
m_nozzle_btn_panel->Disconnect(wxCUSTOMEVT_SELECT_NOZZLE_POS, wxCommandEventHandler(StatusPanel::on_nozzle_selected), NULL, this); m_nozzle_btn_panel->Disconnect(wxCUSTOMEVT_SWITCH_POS, wxCommandEventHandler(StatusPanel::on_nozzle_selected), NULL, this);
m_switch_speed->Disconnect(wxEVT_LEFT_DOWN, wxCommandEventHandler(StatusPanel::on_switch_speed), NULL, this); m_switch_speed->Disconnect(wxEVT_LEFT_DOWN, wxCommandEventHandler(StatusPanel::on_switch_speed), NULL, this);
m_calibration_btn->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_start_calibration), NULL, this); m_calibration_btn->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_start_calibration), NULL, this);
m_options_btn->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_show_print_options), NULL, this); m_options_btn->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_show_print_options), NULL, this);

View File

@ -10,7 +10,7 @@
#include <wx/dcgraph.h> #include <wx/dcgraph.h>
#include <wx/dcmemory.h> #include <wx/dcmemory.h>
wxDEFINE_EVENT(wxCUSTOMEVT_SELECT_NOZZLE_POS, wxCommandEvent); wxDEFINE_EVENT(wxCUSTOMEVT_SWITCH_POS, wxCommandEvent);
SwitchButton::SwitchButton(wxWindow* parent, wxWindowID id) SwitchButton::SwitchButton(wxWindow* parent, wxWindowID id)
: wxBitmapToggleButton(parent, id, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE | wxBU_EXACTFIT) : wxBitmapToggleButton(parent, id, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE | wxBU_EXACTFIT)
@ -294,7 +294,7 @@ void SwitchBoard::on_left_down(wxMouseEvent &evt)
} }
Refresh(); Refresh();
wxCommandEvent event(wxCUSTOMEVT_SELECT_NOZZLE_POS); wxCommandEvent event(wxCUSTOMEVT_SWITCH_POS);
event.SetInt(index); event.SetInt(index);
wxPostEvent(this, event); wxPostEvent(this, event);
} }

View File

@ -8,7 +8,7 @@
#include "Label.hpp" #include "Label.hpp"
#include "Button.hpp" #include "Button.hpp"
wxDECLARE_EVENT(wxCUSTOMEVT_SELECT_NOZZLE_POS, wxCommandEvent); wxDECLARE_EVENT(wxCUSTOMEVT_SWITCH_POS, wxCommandEvent);
class SwitchButton : public wxBitmapToggleButton class SwitchButton : public wxBitmapToggleButton
{ {