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