mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2026-02-24 21:35:03 -07: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:
parent
e774104f87
commit
e6d8339406
1 changed files with 20 additions and 14 deletions
|
|
@ -445,18 +445,22 @@ namespace Slic3r
|
|||
|
||||
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 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);
|
||||
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")
|
||||
{
|
||||
m_agent->disconnect_printer();
|
||||
}
|
||||
else if (last_selected->second->connection_type() == "cloud") {
|
||||
m_agent->set_user_selected_machine("");
|
||||
}
|
||||
}
|
||||
|
||||
// connect curr
|
||||
|
|
@ -464,8 +468,12 @@ namespace Slic3r
|
|||
{
|
||||
if (selected_machine == dev_id)
|
||||
{
|
||||
// same dev_id, cloud => reset update time
|
||||
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
|
||||
it->second->reset_update_time();
|
||||
|
||||
|
|
@ -474,8 +482,12 @@ namespace Slic3r
|
|||
|
||||
return true;
|
||||
}
|
||||
// same dev_id, lan => disconnect and reconnect
|
||||
else
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << "set_selected_machine: same lan machine, dev_id =" << dev_id
|
||||
<< ", disconnect and reconnect";
|
||||
|
||||
// lan mode printer reconnect printer
|
||||
if (m_agent)
|
||||
{
|
||||
|
|
@ -497,20 +509,14 @@ namespace Slic3r
|
|||
{
|
||||
if (it->second->connection_type() != "lan" || it->second->connection_type().empty())
|
||||
{
|
||||
if (m_agent->get_user_selected_machine() == dev_id)
|
||||
{
|
||||
it->second->reset_update_time();
|
||||
}
|
||||
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();
|
||||
}
|
||||
// diff dev_id, cloud => set_user_selected_machine(new)
|
||||
BOOST_LOG_TRIVIAL(info) << "set_selected_machine: select new cloud machine, dev_id =" << dev_id;
|
||||
m_agent->set_user_selected_machine(dev_id);
|
||||
it->second->reset();
|
||||
}
|
||||
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();
|
||||
#if !BBL_RELEASE_TO_PUBLIC
|
||||
it->second->connect(Slic3r::GUI::wxGetApp().app_config->get("enable_ssl_for_mqtt") == "true" ? true : false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue