ENH:accept full package once after switching printers

Change-Id: I561a0f3c0ae86c4215c7e1bd57328245a672a046
This commit is contained in:
tao wang 2023-06-30 12:06:47 +08:00 committed by Lane.Wei
parent 8cf98f10a4
commit e9bee2eb62
3 changed files with 11 additions and 5 deletions

View file

@ -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<std::chrono::milliseconds>(curr_time - last_request_push);
if (diff.count() < REQUEST_PUSH_MIN_TIME) {
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();

View file

@ -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);

View file

@ -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()) {