From fe959f3da34f41a500b66e4d46d268817cbc54fb Mon Sep 17 00:00:00 2001 From: "xin.zhang" Date: Fri, 18 Apr 2025 14:58:15 +0800 Subject: [PATCH] FIX: update the holds of command jira: [STUDIO-11638] Change-Id: I1d2fe9fce53b819a0307e0420d0858c0e2c13ce5 --- src/slic3r/GUI/DeviceManager.cpp | 19 +++++-------------- src/slic3r/GUI/DeviceManager.hpp | 2 +- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 9b7f6ca1a..838f839b1 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -2816,7 +2816,7 @@ int MachineObject::command_ipcam_record(bool on_off) j["camera"]["command"] = "ipcam_record_set"; j["camera"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); j["camera"]["control"] = on_off ? "enable" : "disable"; - camera_recording_hold_count = HOLD_COUNT_CAMERA; + camera_recording_ctl_start = time(nullptr); this->camera_recording_when_printing = on_off; return this->publish_json(j.dump()); } @@ -2841,7 +2841,7 @@ int MachineObject::command_ipcam_resolution_set(std::string resolution) j["camera"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); j["camera"]["resolution"] = resolution; camera_resolution_hold_count = HOLD_COUNT_CAMERA; - camera_recording_hold_count = HOLD_COUNT_CAMERA; + camera_recording_ctl_start = time(nullptr); this->camera_resolution = resolution; return this->publish_json(j.dump()); } @@ -4286,9 +4286,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 (camera_recording_hold_count > 0) - camera_recording_hold_count--; - else { + if (time(nullptr) - camera_recording_ctl_start > HOLD_TIME_MAX) { if (ipcam["ipcam_record"].get() == "enable") { camera_recording_when_printing = true; } @@ -5417,9 +5415,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 (camera_recording_hold_count > 0) { - camera_recording_hold_count--; - } else { + if (time(nullptr) - camera_recording_ctl_start > HOLD_TIME_MAX) { 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; @@ -6092,7 +6088,6 @@ void MachineObject::parse_new_info(json print) BOOST_LOG_TRIVIAL(info) << "new print data cfg = " << cfg; if(!cfg.empty()){ - if (camera_recording_hold_count > 0) camera_recording_hold_count--; 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 @@ -6111,11 +6106,7 @@ void MachineObject::parse_new_info(json print) upgrade_force_upgrade = get_flag_bits(cfg, 2); - if (camera_recording_hold_count > 0) - { - camera_recording_hold_count--; - } - else + if (time(nullptr) - camera_recording_ctl_start > HOLD_COUNT_MAX) { camera_recording_when_printing = get_flag_bits(cfg, 3); } diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 32412ba32..e9bd21967 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -960,7 +960,7 @@ public: bool camera_recording { false }; bool camera_recording_when_printing { false }; bool camera_timelapse { false }; - int camera_recording_hold_count = 0; + time_t camera_recording_ctl_start = 0; int camera_timelapse_hold_count = 0; int camera_resolution_hold_count = 0; std::string camera_resolution = "";