From c47759dd1fe17c840fa92ab3fec803a58d2d1785 Mon Sep 17 00:00:00 2001 From: "xin.zhang" Date: Tue, 18 Mar 2025 14:09:15 +0800 Subject: [PATCH] FIX: use time to hold the control jira: [STUDIO-10923] Change-Id: I7069ed1ea0112837080c59895081e798d6a83e6e --- src/slic3r/GUI/DeviceManager.cpp | 15 +++++++-------- src/slic3r/GUI/DeviceManager.hpp | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 9dc4151fe..920d48850 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -2820,7 +2820,7 @@ int MachineObject::command_xcam_control_ai_monitoring(bool on_off, std::string l bool print_halt = (lvl == "never_halt") ? false:true; xcam_ai_monitoring = on_off; - xcam_ai_monitoring_hold_count = HOLD_COUNT_MAX; + xcam_ai_monitoring_hold_start = time(nullptr); xcam_ai_monitoring_sensitivity = lvl; return command_xcam_control("printing_monitor", on_off, lvl); } @@ -4297,9 +4297,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) try { if (jj.contains("xcam")) { - if (xcam_ai_monitoring_hold_count > 0) - xcam_ai_monitoring_hold_count--; - else { + if (time(nullptr) - xcam_ai_monitoring_hold_start > HOLD_TIME_MAX) { if (jj["xcam"].contains("printing_monitor")) { // new protocol xcam_ai_monitoring = jj["xcam"]["printing_monitor"].get(); @@ -4957,7 +4955,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } else if (jj["module_name"].get() == "printing_monitor") { xcam_ai_monitoring = enable; - xcam_ai_monitoring_hold_count = HOLD_COUNT_MAX; if (jj.contains("halt_print_sensitivity")) { xcam_ai_monitoring_sensitivity = jj["halt_print_sensitivity"].get(); } @@ -4965,7 +4962,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) else if (jj["module_name"].get() == "spaghetti_detector") { // old protocol xcam_ai_monitoring = enable; - xcam_ai_monitoring_hold_count = HOLD_COUNT_MAX; if (jj.contains("print_halt")) { if (jj["print_halt"].get()) xcam_ai_monitoring_sensitivity = "medium"; @@ -5972,7 +5968,6 @@ void MachineObject::parse_new_info(json print) 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_ai_monitoring_hold_count > 0) xcam_ai_monitoring_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--; @@ -6037,7 +6032,11 @@ void MachineObject::parse_new_info(json print) break; } - xcam_ai_monitoring = get_flag_bits(cfg, 15); + if (time(nullptr) - xcam_ai_monitoring_hold_start > HOLD_COUNT_MAX) + { + xcam_ai_monitoring = get_flag_bits(cfg, 15); + } + xcam_auto_recovery_step_loss = get_flag_bits(cfg, 16); if (time(nullptr) - ams_user_setting_start > HOLD_COUNT_MAX) diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 5927ea508..c509d7268 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -1011,7 +1011,7 @@ public: int nozzle_setting_hold_count = 0; bool xcam_ai_monitoring{ false }; - int xcam_ai_monitoring_hold_count = 0; + 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;