mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-27 04:42:33 +00:00
ENH:try again after subscription failure
jira:[Try again after subscription failure] Change-Id: Ibfb1e8e26eb166d786a372632a86ef98030db034
This commit is contained in:
@@ -2468,6 +2468,7 @@ void MachineObject::reset_update_time()
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(trace) << "reset reset_update_time, dev_id =" << dev_id;
|
||||
last_update_time = std::chrono::system_clock::now();
|
||||
subscribe_counter = 3;
|
||||
}
|
||||
|
||||
void MachineObject::reset()
|
||||
@@ -2491,6 +2492,7 @@ void MachineObject::reset()
|
||||
nozzle_diameter = 0.0f;
|
||||
network_wired = false;
|
||||
dev_connection_name = "";
|
||||
subscribe_counter = 3;
|
||||
job_id_ = "";
|
||||
|
||||
// reset print_json
|
||||
@@ -5201,6 +5203,10 @@ bool DeviceManager::set_selected_machine(std::string dev_id, bool need_disconnec
|
||||
if (it->second->connection_type() != "lan") {
|
||||
// only reset update time
|
||||
it->second->reset_update_time();
|
||||
|
||||
// check subscribe state
|
||||
Slic3r::GUI::wxGetApp().on_start_subscribe_again(dev_id);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
// lan mode printer reconnect printer
|
||||
|
||||
@@ -405,6 +405,7 @@ public:
|
||||
bool local_use_ssl_for_mqtt { true };
|
||||
bool local_use_ssl_for_ftp { true };
|
||||
float nozzle_diameter { 0.0f };
|
||||
int subscribe_counter{3};
|
||||
std::string nozzle_type;
|
||||
std::string dev_connection_type; /* lan | cloud */
|
||||
std::string connection_type() { return dev_connection_type; }
|
||||
|
||||
@@ -1884,6 +1884,12 @@ void GUI_App::init_networking_callbacks()
|
||||
}
|
||||
);
|
||||
|
||||
m_agent->set_on_subscribe_failure_fn([this](std::string dev_id) {
|
||||
CallAfter([this, dev_id] {
|
||||
on_start_subscribe_again(dev_id);
|
||||
});
|
||||
});
|
||||
|
||||
m_agent->set_on_local_connect_fn(
|
||||
[this](int state, std::string dev_id, std::string msg) {
|
||||
if (m_is_closing) {
|
||||
@@ -2230,7 +2236,8 @@ void GUI_App::on_start_subscribe_again(std::string dev_id)
|
||||
MachineObject* obj = dev->get_selected_machine();
|
||||
if (!obj) return;
|
||||
|
||||
if ( (dev_id == obj->dev_id) && obj->is_connecting() ) {
|
||||
if ( (dev_id == obj->dev_id) && obj->is_connecting() && obj->subscribe_counter > 0) {
|
||||
obj->subscribe_counter--;
|
||||
if(wxGetApp().getAgent()) wxGetApp().getAgent()->set_user_selected_machine(dev_id);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": dev_id=" << obj->dev_id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user