diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 1c4ce7bde..4d88464f1 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() @@ -1566,9 +1568,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; } @@ -1581,7 +1581,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; } @@ -1591,18 +1591,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; } @@ -1614,7 +1610,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; @@ -2481,6 +2480,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()); } @@ -2873,35 +2873,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); } @@ -4284,7 +4284,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; } @@ -4355,7 +4355,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(); @@ -4374,17 +4374,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; @@ -4497,7 +4493,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(); @@ -5010,15 +5006,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(); @@ -5026,7 +5024,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")) { @@ -5046,8 +5044,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(...) { @@ -5413,7 +5414,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; @@ -6093,10 +6094,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--; @@ -6136,7 +6133,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) { @@ -6152,31 +6151,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 fe76b4350..64b407f37 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 8ea1bf26f..c7f4e3cfa 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -414,7 +414,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); } @@ -5029,10 +5029,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(); } }