From 90830ab2ea1ddf44062e73eb151ffed14671831c Mon Sep 17 00:00:00 2001 From: "haolin.tian" Date: Mon, 25 Aug 2025 10:10:51 +0800 Subject: [PATCH] FIX: Sync AMS settings after device certificate installation jira: STUDIO-14191 Change-Id: If4a02ed6f2c5ef111f0c7086b138e3dabc8ed1dd (cherry picked from commit 172824c4b93f6b3eb197481efc38a262774ef313) --- src/slic3r/GUI/DeviceManager.cpp | 11 +++++++++++ src/slic3r/GUI/DeviceManager.hpp | 4 ++++ src/slic3r/GUI/GUI_App.cpp | 9 +++++++++ src/slic3r/GUI/StatusPanel.cpp | 3 ++- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 3a3b4dd32a..b4680d3229 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -2299,6 +2299,7 @@ void MachineObject::reset() job_id_ = ""; jobState_ = 0; m_plate_index = -1; + device_cert_installed = false; // reset print_json json empty_j; @@ -2395,6 +2396,11 @@ bool MachineObject::is_info_ready(bool check_version) const } +bool MachineObject::is_security_control_ready() const +{ + return device_cert_installed; +} + std::vector MachineObject::get_resolution_supported() { return camera_resolution_supported; @@ -4230,6 +4236,11 @@ int MachineObject::publish_gcode(std::string gcode_str) return publish_json(j); } +void MachineObject::update_device_cert_state(bool ready) +{ + device_cert_installed = ready; +} + BBLSubTask* MachineObject::get_subtask() { if (!subtask_) diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index c3fcb19923..ffc90c71ff 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -239,6 +239,8 @@ public: std::chrono::system_clock::time_point last_request_push; /* last received print push from machine */ std::chrono::system_clock::time_point last_request_start; /* last received print push from machine */ + bool device_cert_installed = false; + int m_active_state = 0; // 0 - not active, 1 - active, 2 - update-to-date bool is_tunnel_mqtt = false; @@ -801,6 +803,7 @@ public: void set_online_state(bool on_off); bool is_online() { return m_is_online; } bool is_info_ready(bool check_version = true) const; + bool is_security_control_ready() const; bool is_camera_busy_off(); std::vector get_resolution_supported(); @@ -814,6 +817,7 @@ public: int local_publish_json(std::string json_str, int qos = 0, int flag = 0); int parse_json(std::string tunnel, std::string payload, bool key_filed_only = false); int publish_gcode(std::string gcode_str); + void update_device_cert_state(bool ready); static std::string setting_id_to_type(std::string setting_id, std::string tray_type); BBLSubTask* get_subtask(); diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 6aa8dcd3d5..6491f76b53 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -4904,6 +4904,15 @@ void GUI_App::process_network_msg(std::string dev_id, std::string msg) if (dev_id.empty()) { BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << msg; } + else if (msg == "device_cert_installed") { + BOOST_LOG_TRIVIAL(info) << "process_network_msg, device_cert_installed"; + Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); + if (!dev) return; + MachineObject* obj = dev->get_my_machine(dev_id); + if (obj) { + obj->update_device_cert_state(true); + } + } } //BBS pop up a dialog and download files diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index 82a90ee044..0ad4df5a28 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -3120,7 +3120,8 @@ void StatusPanel::update_ams(MachineObject *obj) if (obj) { if (obj->get_printer_ams_type() == "f1") { ams_mode = AMSModel::AMS_LITE; } - obj->check_ams_filament_valid(); + if (obj->is_security_control_ready()) + obj->check_ams_filament_valid(); } if (obj->is_enable_np && obj->GetFilaSystem()->GetAmsList().size() > 0) { ams_mode = AMSModel(obj->GetFilaSystem()->GetAmsList().begin()->second->GetAmsType());