NEW:Add filament tangle detect function

JIRA: STUDIO-4455
Change-Id: I01a7e66a24bf10a8f26aacc0c0a2924a07f91388
This commit is contained in:
hu.wang 2023-09-25 15:40:24 +08:00 committed by Lane.Wei
parent be6106a43b
commit a61352e613
4 changed files with 76 additions and 1 deletions

View File

@ -1350,6 +1350,14 @@ void MachineObject::parse_status(int flag)
xcam_allow_prompt_sound = ((flag >> 17) & 0x1) != 0;
}
is_support_filament_tangle_detect = ((flag >> 19) & 0x1) != 0;
if (xcam_filament_tangle_detect_count > 0)
xcam_filament_tangle_detect_count--;
else {
xcam_filament_tangle_detect = ((flag >> 20) & 0x1) != 0;
}
sdcard_state = MachineObject::SdcardState((flag >> 8) & 0x11);
network_wired = ((flag >> 18) & 0x1) != 0;
@ -1973,6 +1981,15 @@ int MachineObject::command_set_prompt_sound(bool prompt_sound){
return this->publish_json(j.dump());
}
int MachineObject::command_set_filament_tangle_detect(bool filament_tangle_detect) {
json j;
j["print"]["command"] = "print_option";
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["print"]["filament_tangle_detect"] = filament_tangle_detect;
return this->publish_json(j.dump());
}
int MachineObject::command_ams_switch_filament(bool switch_filament)
{
json j;
@ -2349,6 +2366,13 @@ int MachineObject::command_xcam_control_allow_prompt_sound(bool on_off)
return command_set_prompt_sound(on_off);
}
int MachineObject::command_xcam_control_filament_tangle_detect(bool on_off)
{
xcam_filament_tangle_detect = on_off;
xcam_filament_tangle_detect_count = HOLD_COUNT_MAX;
return command_set_filament_tangle_detect(on_off);
}
void MachineObject::set_bind_status(std::string status)
{
bind_user_name = status;
@ -2882,6 +2906,12 @@ int MachineObject::parse_json(std::string payload)
}
}
//if (jj.contains("support_filament_tangle_detect")) {
// if (jj["support_filament_tangle_detect"].is_boolean()) {
// is_support_filament_tangle_detect = jj["support_filament_tangle_detect"].get<bool>();
// }
//}
if (jj.contains("support_1080dpi")) {
if (jj["support_1080dpi"].is_boolean()) {
is_support_1080dpi = jj["support_1080dpi"].get<bool>();

View File

@ -699,8 +699,10 @@ public:
int xcam_buildplate_marker_hold_count = 0;
bool xcam_auto_recovery_step_loss{ false };
bool xcam_allow_prompt_sound{ false };
bool xcam_filament_tangle_detect{ false };
int xcam_auto_recovery_hold_count = 0;
int xcam_prompt_sound_hold_count = 0;
int xcam_filament_tangle_detect_count = 0;
int ams_print_option_count = 0;
//supported features
@ -724,6 +726,7 @@ public:
bool is_support_auto_recovery_step_loss{false};
bool is_support_ams_humidity {false};
bool is_support_prompt_sound{false};
bool is_support_filament_tangle_detect{false};
bool is_support_1080dpi {false};
bool is_support_cloud_print_only {false};
bool is_support_command_ams_switch{false};
@ -835,9 +838,13 @@ public:
// set printing speed
int command_set_printing_speed(PrintingSpeedLevel lvl);
//set pormpt sound
//set prompt sound
int command_set_prompt_sound(bool prompt_sound);
//set fliament tangle detect
int command_set_filament_tangle_detect(bool fliament_tangle_detect);
// set print option
int command_set_printing_option(bool auto_recovery);
@ -872,6 +879,7 @@ public:
int command_xcam_control_buildplate_marker_detector(bool on_off);
int command_xcam_control_auto_recovery_step_loss(bool on_off);
int command_xcam_control_allow_prompt_sound(bool on_off);
int command_xcam_control_filament_tangle_detect(bool on_off);
/* common apis */
inline bool is_local() { return !dev_ip.empty(); }

View File

@ -61,6 +61,12 @@ PrintOptionsDialog::PrintOptionsDialog(wxWindow* parent)
}
evt.Skip();
});
m_cb_filament_tangle->Bind(wxEVT_TOGGLEBUTTON, [this](wxCommandEvent& evt) {
if (obj) {
obj->command_xcam_control_filament_tangle_detect(m_cb_filament_tangle->GetValue());
}
evt.Skip();
});
wxGetApp().UpdateDlgDarkUI(this);
}
@ -147,6 +153,16 @@ void PrintOptionsDialog::update_options(MachineObject* obj_)
m_cb_sup_sound->Hide();
line5->Hide();
}
if (obj_->is_support_filament_tangle_detect) {
text_filament_tangle->Show();
m_cb_filament_tangle->Show();
line6->Show();
}
else {
text_filament_tangle->Hide();
m_cb_filament_tangle->Hide();
line6->Hide();
}
this->Freeze();
@ -154,6 +170,7 @@ void PrintOptionsDialog::update_options(MachineObject* obj_)
m_cb_plate_mark->SetValue(obj_->xcam_buildplate_marker_detector);
m_cb_auto_recovery->SetValue(obj_->xcam_auto_recovery_step_loss);
m_cb_sup_sound->SetValue(obj_->xcam_allow_prompt_sound);
m_cb_filament_tangle->SetValue(obj_->xcam_filament_tangle_detect);
m_cb_ai_monitoring->SetValue(obj_->xcam_ai_monitoring);
for (auto i = AiMonitorSensitivityLevel::LOW; i < LEVELS_NUM; i = (AiMonitorSensitivityLevel) (i + 1)) {
@ -286,6 +303,23 @@ wxBoxSizer* PrintOptionsDialog::create_settings_group(wxWindow* parent)
line5 = new StaticLine(parent, false);
line5->SetLineColour(STATIC_BOX_LINE_COL);
sizer->Add(line5, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(20));
sizer->Add(0, 0, 0, wxTOP, FromDIP(20));
//filament tangle detect
line_sizer = new wxBoxSizer(wxHORIZONTAL);
m_cb_filament_tangle = new CheckBox(parent);
text_filament_tangle = new wxStaticText(parent, wxID_ANY, _L("Fliament Tangle Detect"));
text_filament_tangle->SetFont(Label::Body_14);
line_sizer->Add(FromDIP(5), 0, 0, 0);
line_sizer->Add(m_cb_filament_tangle, 0, wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5));
line_sizer->Add(text_filament_tangle, 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));
line_sizer->Add(FromDIP(5), 0, 0, 0);
line6 = new StaticLine(parent, false);
line6->SetLineColour(STATIC_BOX_LINE_COL);
sizer->Add(line6, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(20));
ai_monitoring_level_list->Connect( wxEVT_COMBOBOX, wxCommandEventHandler(PrintOptionsDialog::set_ai_monitor_sensitivity), NULL, this );

View File

@ -27,6 +27,7 @@ protected:
CheckBox* m_cb_plate_mark;
CheckBox* m_cb_auto_recovery;
CheckBox* m_cb_sup_sound;
CheckBox* m_cb_filament_tangle;
wxStaticText* text_first_layer;
wxStaticText* text_ai_monitoring;
wxStaticText* text_ai_monitoring_caption;
@ -35,11 +36,13 @@ protected:
wxStaticText* text_plate_mark_caption;
wxStaticText* text_auto_recovery;
wxStaticText* text_sup_sound;
wxStaticText* text_filament_tangle;
StaticLine* line1;
StaticLine* line2;
StaticLine* line3;
StaticLine* line4;
StaticLine* line5;
StaticLine* line6;
wxBoxSizer* create_settings_group(wxWindow* parent);
bool print_halt = false;