mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-07 23:17:35 -06:00
ENH: request start when it stopped by app
Change-Id: I48b8692f87b834e0f96c7c19c4e8651ae7a8fc1e Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
parent
5454a65c8d
commit
dcbe442184
4 changed files with 52 additions and 1 deletions
|
@ -1260,6 +1260,28 @@ int MachineObject::command_request_push_all()
|
||||||
return this->publish_json(j.dump());
|
return this->publish_json(j.dump());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MachineObject::command_pushing(std::string cmd)
|
||||||
|
{
|
||||||
|
auto curr_time = std::chrono::system_clock::now();
|
||||||
|
auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(curr_time - last_request_start);
|
||||||
|
if (diff.count() < REQUEST_START_MIN_TIME) {
|
||||||
|
BOOST_LOG_TRIVIAL(trace) << "static: command_request_start: send request too fast, dev_id=" << dev_id;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
BOOST_LOG_TRIVIAL(trace) << "static: command_request_start, dev_id=" << dev_id;
|
||||||
|
last_request_start = std::chrono::system_clock::now();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd == "start" || cmd == "stop") {
|
||||||
|
json j;
|
||||||
|
j["pushing"]["command"] = cmd;
|
||||||
|
j["pushing"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||||
|
return this->publish_json(j.dump());
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int MachineObject::command_upgrade_confirm()
|
int MachineObject::command_upgrade_confirm()
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(info) << "command_upgrade_confirm";
|
BOOST_LOG_TRIVIAL(info) << "command_upgrade_confirm";
|
||||||
|
@ -2012,6 +2034,11 @@ int MachineObject::parse_json(std::string payload)
|
||||||
std::chrono::system_clock::time_point clock_start = std::chrono::system_clock::now();
|
std::chrono::system_clock::time_point clock_start = std::chrono::system_clock::now();
|
||||||
this->set_online_state(true);
|
this->set_online_state(true);
|
||||||
|
|
||||||
|
std::chrono::system_clock::time_point curr_time = std::chrono::system_clock::now();
|
||||||
|
auto diff1 = std::chrono::duration_cast<std::chrono::microseconds>(curr_time - last_update_time);
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "interval = " << diff1.count();
|
||||||
|
|
||||||
/* update last received time */
|
/* update last received time */
|
||||||
last_update_time = std::chrono::system_clock::now();
|
last_update_time = std::chrono::system_clock::now();
|
||||||
|
|
||||||
|
@ -2019,8 +2046,9 @@ int MachineObject::parse_json(std::string payload)
|
||||||
bool restored_json = false;
|
bool restored_json = false;
|
||||||
json j;
|
json j;
|
||||||
json j_pre = json::parse(payload);
|
json j_pre = json::parse(payload);
|
||||||
if (j_pre.empty())
|
if (j_pre.empty()) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (j_pre.contains("print")) {
|
if (j_pre.contains("print")) {
|
||||||
if (j_pre["print"].contains("command")) {
|
if (j_pre["print"].contains("command")) {
|
||||||
|
@ -3186,6 +3214,19 @@ void DeviceManager::set_agent(NetworkAgent* agent)
|
||||||
m_agent = agent;
|
m_agent = agent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceManager::check_pushing()
|
||||||
|
{
|
||||||
|
MachineObject* obj = this->get_selected_machine();
|
||||||
|
if (obj) {
|
||||||
|
std::chrono::system_clock::time_point start = std::chrono::system_clock::now();
|
||||||
|
auto internal = std::chrono::duration_cast<std::chrono::milliseconds>(start - obj->last_update_time);
|
||||||
|
if (internal.count() > TIMEOUT_FOR_STRAT && internal.count() < 1000 * 60 * 60 * 300) {
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "command_pushing: diff = " << internal.count();
|
||||||
|
obj->command_pushing("start");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DeviceManager::on_machine_alive(std::string json_str)
|
void DeviceManager::on_machine_alive(std::string json_str)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -17,7 +17,9 @@
|
||||||
|
|
||||||
#define DISCONNECT_TIMEOUT 30000.f // milliseconds
|
#define DISCONNECT_TIMEOUT 30000.f // milliseconds
|
||||||
#define PUSHINFO_TIMEOUT 15000.f // milliseconds
|
#define PUSHINFO_TIMEOUT 15000.f // milliseconds
|
||||||
|
#define TIMEOUT_FOR_STRAT 20000.f // milliseconds
|
||||||
#define REQUEST_PUSH_MIN_TIME 15000.f // milliseconds
|
#define REQUEST_PUSH_MIN_TIME 15000.f // milliseconds
|
||||||
|
#define REQUEST_START_MIN_TIME 15000.f // milliseconds
|
||||||
|
|
||||||
#define FILAMENT_MAX_TEMP 300
|
#define FILAMENT_MAX_TEMP 300
|
||||||
#define FILAMENT_DEF_TEMP 220
|
#define FILAMENT_DEF_TEMP 220
|
||||||
|
@ -401,6 +403,7 @@ public:
|
||||||
std::chrono::system_clock::time_point last_update_time; /* last received print data from machine */
|
std::chrono::system_clock::time_point last_update_time; /* last received print data from machine */
|
||||||
std::chrono::system_clock::time_point last_push_time; /* last received print push from machine */
|
std::chrono::system_clock::time_point last_push_time; /* last received print push from machine */
|
||||||
std::chrono::system_clock::time_point last_request_push; /* last received print push from machine */
|
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 */
|
||||||
|
|
||||||
/* ams properties */
|
/* ams properties */
|
||||||
std::map<std::string, Ams*> amsList; // key: ams[id], start with 0
|
std::map<std::string, Ams*> amsList; // key: ams[id], start with 0
|
||||||
|
@ -592,6 +595,7 @@ public:
|
||||||
BBLSliceInfo* slice_info {nullptr};
|
BBLSliceInfo* slice_info {nullptr};
|
||||||
boost::thread* get_slice_info_thread { nullptr };
|
boost::thread* get_slice_info_thread { nullptr };
|
||||||
|
|
||||||
|
|
||||||
int plate_index { -1 };
|
int plate_index { -1 };
|
||||||
std::string m_gcode_file;
|
std::string m_gcode_file;
|
||||||
int gcode_file_prepare_percent = 0;
|
int gcode_file_prepare_percent = 0;
|
||||||
|
@ -610,6 +614,7 @@ public:
|
||||||
/* command commands */
|
/* command commands */
|
||||||
int command_get_version(bool with_retry = true);
|
int command_get_version(bool with_retry = true);
|
||||||
int command_request_push_all();
|
int command_request_push_all();
|
||||||
|
int command_pushing(std::string cmd);
|
||||||
|
|
||||||
/* command upgrade */
|
/* command upgrade */
|
||||||
int command_upgrade_confirm();
|
int command_upgrade_confirm();
|
||||||
|
@ -725,6 +730,8 @@ public:
|
||||||
std::map<std::string, MachineObject*> localMachineList; /* dev_id -> MachineObject*, localMachine SSDP */
|
std::map<std::string, MachineObject*> localMachineList; /* dev_id -> MachineObject*, localMachine SSDP */
|
||||||
std::map<std::string, MachineObject*> userMachineList; /* dev_id -> MachineObject* cloudMachine of User */
|
std::map<std::string, MachineObject*> userMachineList; /* dev_id -> MachineObject* cloudMachine of User */
|
||||||
|
|
||||||
|
void check_pushing();
|
||||||
|
|
||||||
MachineObject* get_default_machine();
|
MachineObject* get_default_machine();
|
||||||
MachineObject* get_local_selected_machine();
|
MachineObject* get_local_selected_machine();
|
||||||
MachineObject* get_local_machine(std::string dev_id);
|
MachineObject* get_local_machine(std::string dev_id);
|
||||||
|
|
|
@ -395,6 +395,7 @@ void MonitorPanel::update_all()
|
||||||
|
|
||||||
//BBS check mqtt connections if user is login
|
//BBS check mqtt connections if user is login
|
||||||
if (wxGetApp().is_user_login()) {
|
if (wxGetApp().is_user_login()) {
|
||||||
|
dev->check_pushing();
|
||||||
// check mqtt connection and reconnect if disconnected
|
// check mqtt connection and reconnect if disconnected
|
||||||
try {
|
try {
|
||||||
m_agent->refresh_connection();
|
m_agent->refresh_connection();
|
||||||
|
|
|
@ -2551,6 +2551,8 @@ void SelectMachineDialog::update_show_status()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!dev) return;
|
if (!dev) return;
|
||||||
|
dev->check_pushing();
|
||||||
|
|
||||||
MachineObject* obj_ = dev->get_my_machine(m_printer_last_select);
|
MachineObject* obj_ = dev->get_my_machine(m_printer_last_select);
|
||||||
if (!obj_) {
|
if (!obj_) {
|
||||||
update_ams_check(nullptr);
|
update_ams_check(nullptr);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue