From e9bee2eb621a4a5435772657d7c36886eec6e441 Mon Sep 17 00:00:00 2001 From: tao wang Date: Fri, 30 Jun 2023 12:06:47 +0800 Subject: [PATCH] ENH:accept full package once after switching printers Change-Id: I561a0f3c0ae86c4215c7e1bd57328245a672a046 --- src/slic3r/GUI/DeviceManager.cpp | 12 +++++++++--- src/slic3r/GUI/DeviceManager.hpp | 2 +- src/slic3r/GUI/SelectMachine.cpp | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index e85294f7b4..1af4577731 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -1473,13 +1473,19 @@ int MachineObject::command_get_version(bool with_retry) return this->publish_json(j.dump(), 1); } -int MachineObject::command_request_push_all() +int MachineObject::command_request_push_all(bool request_now) { auto curr_time = std::chrono::system_clock::now(); auto diff = std::chrono::duration_cast(curr_time - last_request_push); if (diff.count() < REQUEST_PUSH_MIN_TIME) { - BOOST_LOG_TRIVIAL(trace) << "static: command_request_push_all: send request too fast, dev_id=" << dev_id; - return -1; + if (request_now) { + BOOST_LOG_TRIVIAL(trace) << "static: command_request_push_all, dev_id=" << dev_id; + last_request_push = std::chrono::system_clock::now(); + } + else { + BOOST_LOG_TRIVIAL(trace) << "static: command_request_push_all: send request too fast, dev_id=" << dev_id; + return -1; + } } else { BOOST_LOG_TRIVIAL(trace) << "static: command_request_push_all, dev_id=" << dev_id; last_request_push = std::chrono::system_clock::now(); diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index e4cd182d5f..03e8ee7276 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -775,7 +775,7 @@ public: bool is_studio_cmd(int seq); /* command commands */ int command_get_version(bool with_retry = true); - int command_request_push_all(); + int command_request_push_all(bool request_now = false); int command_pushing(std::string cmd); int command_clean_print_error(std::string task_id, int print_error); diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index 299df9be79..e8bce56163 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -2958,7 +2958,7 @@ void SelectMachineDialog::on_selection_changed(wxCommandEvent &event) } } - if (obj && !obj->get_lan_mode_connection_state()) { + if (obj) { obj->command_get_version(); obj->command_request_push_all(); if (!dev->get_selected_machine()) {