mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-19 11:23:42 +00:00
FIX: Improve device switching logic for disconnect and reconnect
jira: none Change-Id: If9b4081581da7bb7c9cdcc44adcb1b9f490afb3f (cherry picked from commit 725799eec1aad721e74ec956d14b30369d75446a)
This commit is contained in:
@@ -445,18 +445,22 @@ namespace Slic3r
|
|||||||
|
|
||||||
bool DeviceManager::set_selected_machine(std::string dev_id)
|
bool DeviceManager::set_selected_machine(std::string dev_id)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(info) << "set_selected_machine=" << dev_id;
|
BOOST_LOG_TRIVIAL(info) << "set_selected_machine=" << dev_id
|
||||||
|
<< " cur_selected=" << selected_machine;
|
||||||
auto my_machine_list = get_my_machine_list();
|
auto my_machine_list = get_my_machine_list();
|
||||||
auto it = my_machine_list.find(dev_id);
|
auto it = my_machine_list.find(dev_id);
|
||||||
|
|
||||||
// disconnect last
|
// disconnect last if dev_id difference from previous one
|
||||||
auto last_selected = my_machine_list.find(selected_machine);
|
auto last_selected = my_machine_list.find(selected_machine);
|
||||||
if (last_selected != my_machine_list.end())
|
if (last_selected != my_machine_list.end() && selected_machine != dev_id)
|
||||||
{
|
{
|
||||||
if (last_selected->second->connection_type() == "lan")
|
if (last_selected->second->connection_type() == "lan")
|
||||||
{
|
{
|
||||||
m_agent->disconnect_printer();
|
m_agent->disconnect_printer();
|
||||||
}
|
}
|
||||||
|
else if (last_selected->second->connection_type() == "cloud") {
|
||||||
|
m_agent->set_user_selected_machine("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// connect curr
|
// connect curr
|
||||||
@@ -464,8 +468,12 @@ namespace Slic3r
|
|||||||
{
|
{
|
||||||
if (selected_machine == dev_id)
|
if (selected_machine == dev_id)
|
||||||
{
|
{
|
||||||
|
// same dev_id, cloud => reset update time
|
||||||
if (it->second->connection_type() != "lan")
|
if (it->second->connection_type() != "lan")
|
||||||
{
|
{
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "set_selected_machine: same cloud machine, dev_id =" << dev_id
|
||||||
|
<< ", just reset update time";
|
||||||
|
|
||||||
// only reset update time
|
// only reset update time
|
||||||
it->second->reset_update_time();
|
it->second->reset_update_time();
|
||||||
|
|
||||||
@@ -474,8 +482,12 @@ namespace Slic3r
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// same dev_id, lan => disconnect and reconnect
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "set_selected_machine: same lan machine, dev_id =" << dev_id
|
||||||
|
<< ", disconnect and reconnect";
|
||||||
|
|
||||||
// lan mode printer reconnect printer
|
// lan mode printer reconnect printer
|
||||||
if (m_agent)
|
if (m_agent)
|
||||||
{
|
{
|
||||||
@@ -497,20 +509,14 @@ namespace Slic3r
|
|||||||
{
|
{
|
||||||
if (it->second->connection_type() != "lan" || it->second->connection_type().empty())
|
if (it->second->connection_type() != "lan" || it->second->connection_type().empty())
|
||||||
{
|
{
|
||||||
if (m_agent->get_user_selected_machine() == dev_id)
|
// diff dev_id, cloud => set_user_selected_machine(new)
|
||||||
{
|
BOOST_LOG_TRIVIAL(info) << "set_selected_machine: select new cloud machine, dev_id =" << dev_id;
|
||||||
it->second->reset_update_time();
|
m_agent->set_user_selected_machine(dev_id);
|
||||||
}
|
it->second->reset();
|
||||||
else
|
|
||||||
{
|
|
||||||
BOOST_LOG_TRIVIAL(info) << "static: set_selected_machine: same dev_id = " << dev_id;
|
|
||||||
m_agent->set_user_selected_machine(dev_id);
|
|
||||||
it->second->reset();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(info) << "static: set_selected_machine: same dev_id = empty";
|
BOOST_LOG_TRIVIAL(info) << "set_selected_machine: select new lan machine, dev_id =" << dev_id;
|
||||||
it->second->reset();
|
it->second->reset();
|
||||||
#if !BBL_RELEASE_TO_PUBLIC
|
#if !BBL_RELEASE_TO_PUBLIC
|
||||||
it->second->connect(Slic3r::GUI::wxGetApp().app_config->get("enable_ssl_for_mqtt") == "true" ? true : false);
|
it->second->connect(Slic3r::GUI::wxGetApp().app_config->get("enable_ssl_for_mqtt") == "true" ? true : false);
|
||||||
|
|||||||
Reference in New Issue
Block a user