From 15d140d582a68842691bc4912cfd069655cf6607 Mon Sep 17 00:00:00 2001 From: "xin.zhang" Date: Thu, 24 Apr 2025 17:31:05 +0800 Subject: [PATCH] FIX: update the hold impl of PrintOptionDialog jira: [STUDIO-10972] Change-Id: Ie62d0f4ec7e08087c422ddb38768df99c1f0d5f9 (cherry picked from commit 4f144417030fdd54b05e22c3c6eaad7e66cdeeff) --- src/slic3r/GUI/DeviceManager.cpp | 110 ++++++++++++++++--------------- src/slic3r/GUI/DeviceManager.hpp | 15 +++-- src/slic3r/GUI/StatusPanel.cpp | 4 +- 3 files changed, 69 insertions(+), 60 deletions(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index ea9de06609..16671257e6 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -757,7 +757,9 @@ bool MachineObject::check_valid_ip() void MachineObject::_parse_print_option_ack(int option) { - xcam_auto_recovery_step_loss = ((option >> (int)PRINT_OP_AUTO_RECOVERY) & 0x01) != 0; + if (time(nullptr) - xcam_auto_recovery_hold_start > HOLD_TIME_3SEC) { + xcam_auto_recovery_step_loss = ((option >> (int)PRINT_OP_AUTO_RECOVERY) & 0x01) != 0; + } } bool MachineObject::is_in_extrusion_cali() @@ -1557,9 +1559,7 @@ void MachineObject::parse_state_changed_event() void MachineObject::parse_status(int flag) { is_220V_voltage = ((flag >> 3) & 0x1) != 0; - if (xcam_auto_recovery_hold_count > 0) - xcam_auto_recovery_hold_count--; - else { + if (time(nullptr) - xcam_auto_recovery_hold_start > HOLD_TIME_3SEC) { xcam_auto_recovery_step_loss = ((flag >> 4) & 0x1) != 0; } @@ -1572,7 +1572,7 @@ void MachineObject::parse_status(int flag) sdcard_state = MachineObject::SdcardState(get_flag_bits(flag, 8, 2)); - if (time(nullptr) - ams_switch_filament_start > HOLD_TIME_MAX) + if (time(nullptr) - ams_switch_filament_start > HOLD_TIME_3SEC) { ams_auto_switch_filament_flag = ((flag >> 10) & 0x1) != 0; } @@ -1582,18 +1582,14 @@ void MachineObject::parse_status(int flag) is_support_pa_calibration = ((flag >> 16) & 0x1) != 0; - if (xcam_prompt_sound_hold_count > 0) - xcam_prompt_sound_hold_count--; - else { + if (time(nullptr) - xcam_prompt_sound_hold_start > HOLD_TIME_3SEC) { xcam_allow_prompt_sound = ((flag >> 17) & 0x1) != 0; } is_support_prompt_sound = ((flag >> 18) & 0x1) != 0; is_support_filament_tangle_detect = ((flag >> 19) & 0x1) != 0; - if (xcam_filament_tangle_detect_count > 0) - xcam_filament_tangle_detect_count--; - else { + if (time(nullptr) - xcam_filament_tangle_detect_hold_start > HOLD_TIME_3SEC) { xcam_filament_tangle_detect = ((flag >> 20) & 0x1) != 0; } @@ -1605,7 +1601,10 @@ void MachineObject::parse_status(int flag) is_support_user_preset = ((flag >> 22) & 0x1) != 0; is_support_nozzle_blob_detection = ((flag >> 25) & 0x1) != 0; - nozzle_blob_detection_enabled = ((flag >> 24) & 0x1) != 0; + + if (time(nullptr) - nozzle_blob_detection_hold_start > HOLD_TIME_3SEC) { + nozzle_blob_detection_enabled = ((flag >> 24) & 0x1) != 0; + } is_support_air_print_detection = ((flag >> 29) & 0x1) != 0; ams_air_print_status = ((flag >> 28) & 0x1) != 0; @@ -2408,6 +2407,7 @@ int MachineObject::command_nozzle_blob_detect(bool nozzle_blob_detect) j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); j["print"]["nozzle_blob_detect"] = nozzle_blob_detect; nozzle_blob_detection_enabled = nozzle_blob_detect; + nozzle_blob_detection_hold_start = time(nullptr); return this->publish_json(j.dump()); } @@ -2782,35 +2782,35 @@ int MachineObject::command_xcam_control_ai_monitoring(bool on_off, std::string l int MachineObject::command_xcam_control_buildplate_marker_detector(bool on_off) { xcam_buildplate_marker_detector = on_off; - xcam_buildplate_marker_hold_count = HOLD_COUNT_MAX; + xcam_buildplate_marker_hold_start = time(nullptr); return command_xcam_control("buildplate_marker_detector", on_off); } int MachineObject::command_xcam_control_first_layer_inspector(bool on_off, bool print_halt) { xcam_first_layer_inspector = on_off; - xcam_first_layer_hold_count = HOLD_COUNT_MAX; + xcam_first_layer_hold_start = time(nullptr); return command_xcam_control("first_layer_inspector", on_off); } int MachineObject::command_xcam_control_auto_recovery_step_loss(bool on_off) { xcam_auto_recovery_step_loss = on_off; - xcam_auto_recovery_hold_count = HOLD_COUNT_MAX; + xcam_auto_recovery_hold_start = time(nullptr); return command_set_printing_option(on_off); } int MachineObject::command_xcam_control_allow_prompt_sound(bool on_off) { xcam_allow_prompt_sound = on_off; - xcam_prompt_sound_hold_count = HOLD_COUNT_MAX; + xcam_prompt_sound_hold_start = time(nullptr); 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; + xcam_filament_tangle_detect_hold_start = time(nullptr); return command_set_filament_tangle_detect(on_off); } @@ -4198,7 +4198,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) if (jj.contains("ipcam")) { json const & ipcam = jj["ipcam"]; if (ipcam.contains("ipcam_record")) { - if (time(nullptr) - camera_recording_ctl_start > HOLD_TIME_MAX) { + if (time(nullptr) - camera_recording_ctl_start > HOLD_TIME_3SEC) { if (ipcam["ipcam_record"].get() == "enable") { camera_recording_when_printing = true; } @@ -4269,7 +4269,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) try { if (jj.contains("xcam")) { - if (time(nullptr) - xcam_ai_monitoring_hold_start > HOLD_TIME_MAX) { + if (time(nullptr) - xcam_ai_monitoring_hold_start > HOLD_TIME_3SEC) { if (jj["xcam"].contains("printing_monitor")) { // new protocol xcam_ai_monitoring = jj["xcam"]["printing_monitor"].get(); @@ -4288,17 +4288,13 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } } - if (xcam_first_layer_hold_count > 0) - xcam_first_layer_hold_count--; - else { + if (time(nullptr) - xcam_first_layer_hold_start > HOLD_TIME_3SEC) { if (jj["xcam"].contains("first_layer_inspector")) { xcam_first_layer_inspector = jj["xcam"]["first_layer_inspector"].get(); } } - if (xcam_buildplate_marker_hold_count > 0) - xcam_buildplate_marker_hold_count--; - else { + if (time(nullptr) - xcam_buildplate_marker_hold_start > HOLD_TIME_3SEC) { if (jj["xcam"].contains("buildplate_marker_detector")) { xcam_buildplate_marker_detector = jj["xcam"]["buildplate_marker_detector"].get(); is_support_build_plate_marker_detect = true; @@ -4411,7 +4407,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) if (jj["ams"].contains("insert_flag") || jj["ams"].contains("power_on_flag") || jj["ams"].contains("calibrate_remain_flag")) { - if (time(nullptr) - ams_user_setting_start > HOLD_TIME_MAX) + if (time(nullptr) - ams_user_setting_start > HOLD_TIME_3SEC) { if (jj["ams"].contains("insert_flag")) { ams_insert_flag = jj["ams"]["insert_flag"].get(); @@ -4909,15 +4905,17 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } if (jj["module_name"].get() == "first_layer_inspector") { - xcam_first_layer_inspector = enable; - xcam_first_layer_hold_count = HOLD_COUNT_MAX; + if (time(nullptr) - xcam_first_layer_hold_start > HOLD_TIME_3SEC) { + xcam_first_layer_inspector = enable; + } } else if (jj["module_name"].get() == "buildplate_marker_detector") { - xcam_buildplate_marker_detector = enable; - xcam_buildplate_marker_hold_count = HOLD_COUNT_MAX; + if (time(nullptr) - xcam_buildplate_marker_hold_start > HOLD_TIME_3SEC) { + xcam_buildplate_marker_detector = enable; + } } else if (jj["module_name"].get() == "printing_monitor") { - if (time(nullptr) - xcam_ai_monitoring_hold_start > HOLD_TIME_MAX) { + if (time(nullptr) - xcam_ai_monitoring_hold_start > HOLD_TIME_3SEC) { xcam_ai_monitoring = enable; if (jj.contains("halt_print_sensitivity")) { xcam_ai_monitoring_sensitivity = jj["halt_print_sensitivity"].get(); @@ -4925,7 +4923,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } } else if (jj["module_name"].get() == "spaghetti_detector") { - if (time(nullptr) - xcam_ai_monitoring_hold_start > HOLD_TIME_MAX) { + if (time(nullptr) - xcam_ai_monitoring_hold_start > HOLD_TIME_3SEC) { // old protocol xcam_ai_monitoring = enable; if (jj.contains("print_halt")) { @@ -4945,8 +4943,11 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) _parse_print_option_ack(option); } } - if (jj.contains("auto_recovery")) { - xcam_auto_recovery_step_loss = jj["auto_recovery"].get(); + + if (time(nullptr) - xcam_auto_recovery_hold_start > HOLD_TIME_3SEC) { + if (jj.contains("auto_recovery")) { + xcam_auto_recovery_step_loss = jj["auto_recovery"].get(); + } } } catch(...) { @@ -5313,7 +5314,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) BOOST_LOG_TRIVIAL(info) << "ack of timelapse = " << camera_timelapse; } } else if (j["camera"]["command"].get() == "ipcam_record_set") { - if (time(nullptr) - camera_recording_ctl_start > HOLD_TIME_MAX) { + if (time(nullptr) - camera_recording_ctl_start > HOLD_TIME_3SEC) { if (j["camera"]["control"].get() == "enable") this->camera_recording_when_printing = true; if (j["camera"]["control"].get() == "disable") this->camera_recording_when_printing = false; BOOST_LOG_TRIVIAL(info) << "ack of ipcam_record_set " << camera_recording_when_printing; @@ -5993,10 +5994,6 @@ void MachineObject::parse_new_info(json print) if (camera_resolution_hold_count > 0) camera_resolution_hold_count--; if (camera_timelapse_hold_count > 0) camera_timelapse_hold_count--; //if (xcam_buildplate_marker_hold_count > 0) xcam_buildplate_marker_hold_count--;first_layer_inspector - if (xcam_first_layer_hold_count > 0) xcam_first_layer_hold_count--; - if (xcam_auto_recovery_hold_count > 0) xcam_auto_recovery_hold_count--; - if (xcam_prompt_sound_hold_count > 0) xcam_prompt_sound_hold_count--; - if (xcam_filament_tangle_detect_count > 0)xcam_filament_tangle_detect_count--; if (nozzle_setting_hold_count > 0)nozzle_setting_hold_count--; @@ -6036,7 +6033,9 @@ void MachineObject::parse_new_info(json print) printing_speed_lvl = (PrintingSpeedLevel)get_flag_bits(cfg, 8, 3); //is_support_build_plate_marker_detect = get_flag_bits(cfg, 12); todo yangcong - xcam_first_layer_inspector = get_flag_bits(cfg, 12); + if (time(nullptr) - xcam_first_layer_hold_start > HOLD_TIME_3SEC) { + xcam_first_layer_inspector = get_flag_bits(cfg, 12); + } if (time(nullptr) - xcam_ai_monitoring_hold_start > HOLD_COUNT_MAX) { @@ -6052,31 +6051,38 @@ void MachineObject::parse_new_info(json print) } } - xcam_auto_recovery_step_loss = get_flag_bits(cfg, 16); + if (time(nullptr) - xcam_auto_recovery_hold_start > HOLD_COUNT_MAX) { + xcam_auto_recovery_step_loss = get_flag_bits(cfg, 16); + } - if (time(nullptr) - ams_user_setting_start > HOLD_COUNT_MAX) - { + if (time(nullptr) - ams_user_setting_start > HOLD_COUNT_MAX){ ams_calibrate_remain_flag = get_flag_bits(cfg, 17); } - if (time(nullptr) - ams_switch_filament_start > HOLD_TIME_MAX) - { + if (time(nullptr) - ams_switch_filament_start > HOLD_TIME_3SEC){ ams_auto_switch_filament_flag = get_flag_bits(cfg, 18); } - if (time(nullptr) - xcam__save_remote_print_file_to_storage_start_time > HOLD_TIME_MAX) - { + if (time(nullptr) - xcam__save_remote_print_file_to_storage_start_time > HOLD_TIME_3SEC){ xcam__save_remote_print_file_to_storage = get_flag_bits(cfg, 19); } - if (time(nullptr) - xcam_door_open_check_start_time > HOLD_TIME_MAX) - { + if (time(nullptr) - xcam_door_open_check_start_time > HOLD_TIME_3SEC){ xcam_door_open_check = (DoorOpenCheckState) get_flag_bits(cfg, 20, 2); } - xcam_allow_prompt_sound = get_flag_bits(cfg, 22); - xcam_filament_tangle_detect = get_flag_bits(cfg, 23); - nozzle_blob_detection_enabled = get_flag_bits(cfg, 24); + if (time(nullptr) - xcam_prompt_sound_hold_start > HOLD_TIME_3SEC) { + xcam_allow_prompt_sound = get_flag_bits(cfg, 22); + } + + if (time(nullptr) - xcam_filament_tangle_detect_hold_start > HOLD_TIME_3SEC){ + xcam_filament_tangle_detect = get_flag_bits(cfg, 23); + } + + if (time(nullptr) - nozzle_blob_detection_hold_start > HOLD_TIME_3SEC) { + nozzle_blob_detection_enabled = get_flag_bits(cfg, 24); + } + installed_upgrade_kit = get_flag_bits(cfg, 25); } diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 9876ea4644..5b23c923d6 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -39,8 +39,8 @@ #define HOLD_COUNT_MAX 3 #define HOLD_COUNT_CAMERA 6 -#define HOLD_TIME_MAX 3 // 3 seconds -#define HOLD_TIME_SWITCHING 6 // 6 seconds +#define HOLD_TIME_3SEC 3 // 3 seconds +#define HOLD_TIME_6SEC 6 // 6 seconds #define GET_VERSION_RETRYS 10 #define RETRY_INTERNAL 2000 @@ -888,6 +888,7 @@ public: int total_layers = 0; bool is_support_layer_num { false }; bool nozzle_blob_detection_enabled{ false }; + time_t nozzle_blob_detection_hold_start = 0; int last_cali_version = -1; int cali_version = -1; @@ -966,7 +967,7 @@ public: std::string camera_resolution = ""; std::vector camera_resolution_supported; bool xcam_first_layer_inspector { false }; - int xcam_first_layer_hold_count = 0; + time_t xcam_first_layer_hold_start = 0; std::string local_rtsp_url; std::string tutk_state; enum LiveviewLocal { @@ -1022,13 +1023,13 @@ public: time_t xcam_ai_monitoring_hold_start = 0; std::string xcam_ai_monitoring_sensitivity; bool xcam_buildplate_marker_detector{ false }; - int xcam_buildplate_marker_hold_count = 0; + time_t xcam_buildplate_marker_hold_start = 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; + time_t xcam_auto_recovery_hold_start = 0; + time_t xcam_prompt_sound_hold_start = 0; + time_t xcam_filament_tangle_detect_hold_start = 0; int nozzle_selected_count = 0; bool flag_update_nozzle = {true}; diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index d45c79dc47..2c04349a88 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -415,7 +415,7 @@ void ExtruderSwithingStatus::updateBy(MachineObject *obj) else { /*do not display while command sended in a mean while*/ - if ((time(nullptr) - m_last_ctrl_time) > HOLD_TIME_SWITCHING) + if ((time(nullptr) - m_last_ctrl_time) > HOLD_TIME_6SEC) { updateBy(obj->m_extder_data); } @@ -5109,10 +5109,12 @@ void StatusPanel::on_show_print_options(wxCommandEvent& event) if (print_options_dlg == nullptr) { print_options_dlg = new PrintOptionsDialog(this); print_options_dlg->update_machine_obj(obj); + print_options_dlg->update_options(obj); print_options_dlg->ShowModal(); } else { print_options_dlg->update_machine_obj(obj); + print_options_dlg->update_options(obj); print_options_dlg->ShowModal(); } }