mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-16 18:12:10 +00:00
FIX: remove legacy MQTT optimizations; disconnect previous printer on switch
jira: STUDIO-13455 Change-Id: I88f48801f443b3830fbd2bccbc53577f615e6d96 (cherry picked from commit 562ac1a3e7e75e1cab5e42ab09cec719bf698184) (cherry picked from commit 5143086c5efb4d974e27ba4f55bd82752ded0a93)
This commit is contained in:
@@ -3137,8 +3137,6 @@ void MachineObject::reset()
|
||||
jobState_ = 0;
|
||||
m_plate_index = -1;
|
||||
|
||||
nt_reset_data();
|
||||
|
||||
// reset print_json
|
||||
json empty_j;
|
||||
print_json.diff2all_base_reset(empty_j);
|
||||
@@ -3153,14 +3151,6 @@ void MachineObject::reset()
|
||||
subtask_ = nullptr;
|
||||
}
|
||||
|
||||
void MachineObject::nt_reset_data()
|
||||
{
|
||||
nt_try_local_tunnel = false;
|
||||
nt_use_local_tunnel = false;
|
||||
nt_cloud_full_msg_count = 0;
|
||||
nt_local_full_msg_count = 0;
|
||||
}
|
||||
|
||||
void MachineObject::set_print_state(std::string status)
|
||||
{
|
||||
print_status = status;
|
||||
@@ -3366,10 +3356,6 @@ int MachineObject::parse_json(std::string tunnel, std::string payload, bool key_
|
||||
m_push_count++;
|
||||
m_full_msg_count++;
|
||||
|
||||
if (tunnel == "cloud") {nt_cloud_full_msg_count++;}
|
||||
if (tunnel == "lan") {nt_local_full_msg_count++;}
|
||||
nt_condition_local_tunnel();
|
||||
|
||||
if (!printer_type.empty())
|
||||
print_json.load_compatible_settings(printer_type, "");
|
||||
print_json.diff2all_base_reset(j_pre);
|
||||
@@ -3394,9 +3380,7 @@ int MachineObject::parse_json(std::string tunnel, std::string payload, bool key_
|
||||
}
|
||||
else {
|
||||
if (!printer_type.empty()) {
|
||||
nt_local_full_msg_count++;
|
||||
m_full_msg_count++;/* all message package is full at LAN mode*/
|
||||
nt_condition_local_tunnel();
|
||||
print_json.load_compatible_settings(printer_type, "");
|
||||
}
|
||||
|
||||
@@ -6064,32 +6048,6 @@ std::string MachineObject::get_string_from_fantype(int type)
|
||||
return "";
|
||||
}
|
||||
|
||||
void MachineObject::nt_condition_local_tunnel()
|
||||
{
|
||||
return;
|
||||
int full_msg_count_limit = 2;
|
||||
if (!nt_try_local_tunnel && nt_cloud_full_msg_count == full_msg_count_limit) {
|
||||
connect(Slic3r::GUI::wxGetApp().app_config->get("enable_ssl_for_mqtt") == "true" ? true : false);
|
||||
nt_try_local_tunnel = true;
|
||||
}
|
||||
|
||||
if (!nt_use_local_tunnel && nt_try_local_tunnel && nt_local_full_msg_count == full_msg_count_limit) {
|
||||
std::vector<std::string> dev_list{dev_id};
|
||||
Slic3r::GUI::wxGetApp().getAgent()->del_subscribe(dev_list);
|
||||
nt_use_local_tunnel = true;
|
||||
}
|
||||
}
|
||||
|
||||
void MachineObject::nt_restore_cloud_tunnel()
|
||||
{
|
||||
if (is_connected()) {
|
||||
disconnect();
|
||||
std::vector<std::string> dev_list{dev_id};
|
||||
Slic3r::GUI::wxGetApp().getAgent()->add_subscribe(dev_list);
|
||||
nt_use_local_tunnel = false;
|
||||
}
|
||||
}
|
||||
|
||||
NozzleFlowType MachineObject::get_nozzle_flow_type(int extruder_id) const
|
||||
{
|
||||
if (is_nozzle_flow_type_supported() && m_extder_data.extders.size() > extruder_id)
|
||||
@@ -7276,12 +7234,6 @@ void DeviceManager::check_pushing()
|
||||
obj->command_pushing("start");
|
||||
}
|
||||
}
|
||||
|
||||
/*check local tunnel state*/
|
||||
if (obj && obj->nt_use_local_tunnel && internal.count() > PUSHINFO_TIMEOUT) {
|
||||
obj->nt_restore_cloud_tunnel();
|
||||
BOOST_LOG_TRIVIAL(info) << "Unable to receive more data in LAN tunnel";
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceManager::on_machine_alive(std::string json_str)
|
||||
@@ -7577,7 +7529,7 @@ void DeviceManager::clean_user_info()
|
||||
userMachineList.clear();
|
||||
}
|
||||
|
||||
bool DeviceManager::set_selected_machine(std::string dev_id, bool need_disconnect)
|
||||
bool DeviceManager::set_selected_machine(std::string dev_id)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << "set_selected_machine=" << dev_id;
|
||||
auto my_machine_list = get_my_machine_list();
|
||||
@@ -7588,8 +7540,7 @@ bool DeviceManager::set_selected_machine(std::string dev_id, bool need_disconnec
|
||||
if (last_selected != my_machine_list.end()) {
|
||||
last_selected->second->m_active_state = MachineObject::NotActive;
|
||||
if (last_selected->second->connection_type() == "lan") {
|
||||
if (last_selected->second->is_connecting() && !need_disconnect)
|
||||
return false;
|
||||
m_agent->disconnect_printer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7607,6 +7558,7 @@ bool DeviceManager::set_selected_machine(std::string dev_id, bool need_disconnec
|
||||
} else {
|
||||
// lan mode printer reconnect printer
|
||||
if (m_agent) {
|
||||
m_agent->disconnect_printer();
|
||||
it->second->reset();
|
||||
#if !BBL_RELEASE_TO_PUBLIC
|
||||
it->second->connect(Slic3r::GUI::wxGetApp().app_config->get("enable_ssl_for_mqtt") == "true" ? true : false);
|
||||
@@ -7621,7 +7573,6 @@ bool DeviceManager::set_selected_machine(std::string dev_id, bool need_disconnec
|
||||
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();
|
||||
it->second->nt_reset_data();
|
||||
}
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(info) << "static: set_selected_machine: same dev_id = " << dev_id;
|
||||
|
||||
@@ -1402,15 +1402,6 @@ public:
|
||||
bool is_firmware_info_valid();
|
||||
std::string get_string_from_fantype(int type);
|
||||
|
||||
/*for local mqtt tunnel try*/
|
||||
bool nt_try_local_tunnel { false };
|
||||
bool nt_use_local_tunnel { false };
|
||||
int nt_cloud_full_msg_count { 0 };
|
||||
int nt_local_full_msg_count { 0 };
|
||||
void nt_condition_local_tunnel();
|
||||
void nt_restore_cloud_tunnel();
|
||||
void nt_reset_data();
|
||||
|
||||
/*for more extruder*/
|
||||
bool is_enable_np{ false };
|
||||
bool is_enable_ams_np{ false };
|
||||
@@ -1511,7 +1502,7 @@ public:
|
||||
void clean_user_info();
|
||||
void reload_printer_settings();
|
||||
|
||||
bool set_selected_machine(std::string dev_id, bool need_disconnect = false);
|
||||
bool set_selected_machine(std::string dev_id);
|
||||
MachineObject* get_selected_machine();
|
||||
|
||||
void subscribe_device_list(std::vector<std::string> dev_list);
|
||||
|
||||
@@ -1697,13 +1697,6 @@ void GUI_App::init_networking_callbacks()
|
||||
MachineObject *obj = dev->get_selected_machine();
|
||||
if (!obj) return;
|
||||
|
||||
if (obj->nt_try_local_tunnel && obj->connection_type() == "cloud") {
|
||||
if (obj->is_connected()) {
|
||||
obj->disconnect();
|
||||
}
|
||||
obj->nt_reset_data();
|
||||
}
|
||||
|
||||
/* resubscribe the cache dev list */
|
||||
if (this->is_enable_multi_machine()) {
|
||||
|
||||
@@ -1776,7 +1769,7 @@ void GUI_App::init_networking_callbacks()
|
||||
} else if (state == ConnectStatus::ConnectStatusFailed) {
|
||||
// Orca: avoid showing same error message multiple times until next connection attempt.
|
||||
const auto already_disconnected = m_device_manager->selected_machine.empty();
|
||||
m_device_manager->set_selected_machine("", true);
|
||||
m_device_manager->set_selected_machine("");
|
||||
if (!already_disconnected) {
|
||||
wxString text;
|
||||
if (msg == "5") {
|
||||
@@ -1791,7 +1784,7 @@ void GUI_App::init_networking_callbacks()
|
||||
}
|
||||
event.SetInt(-1);
|
||||
} else if (state == ConnectStatus::ConnectStatusLost) {
|
||||
m_device_manager->set_selected_machine("", true);
|
||||
m_device_manager->set_selected_machine("");
|
||||
event.SetInt(-1);
|
||||
BOOST_LOG_TRIVIAL(info) << "set_on_local_connect_fn: state = lost";
|
||||
} else {
|
||||
|
||||
@@ -2095,7 +2095,7 @@ void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_
|
||||
|
||||
if (m_obj) {
|
||||
m_obj->set_user_access_code(str_access_code);
|
||||
wxGetApp().getDeviceManager()->set_selected_machine(m_obj->dev_id, true);
|
||||
wxGetApp().getDeviceManager()->set_selected_machine(m_obj->dev_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3010,9 +3010,9 @@ void SelectMachineDialog::on_selection_changed(wxCommandEvent &event)
|
||||
obj->command_get_version();
|
||||
obj->command_request_push_all();
|
||||
if (!dev->get_selected_machine()) {
|
||||
dev->set_selected_machine(m_printer_last_select, true);
|
||||
dev->set_selected_machine(m_printer_last_select);
|
||||
}else if (dev->get_selected_machine()->dev_id != m_printer_last_select) {
|
||||
dev->set_selected_machine(m_printer_last_select, true);
|
||||
dev->set_selected_machine(m_printer_last_select);
|
||||
}
|
||||
|
||||
// Has changed machine unrecoverably
|
||||
@@ -4499,15 +4499,6 @@ bool SelectMachineDialog::Show(bool show)
|
||||
m_refresh_timer->Start(LIST_REFRESH_INTERVAL);
|
||||
} else {
|
||||
m_refresh_timer->Stop();
|
||||
|
||||
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (dev) {
|
||||
MachineObject *obj_ = dev->get_selected_machine();
|
||||
if (obj_ && obj_->connection_type() == "cloud" /*&& m_print_type == FROM_SDCARD_VIEW*/) {
|
||||
if (obj_->is_connected()) { obj_->disconnect(); }
|
||||
}
|
||||
}
|
||||
|
||||
return DPIDialog::Show(false);
|
||||
}
|
||||
show_init();
|
||||
|
||||
@@ -1214,12 +1214,12 @@ void SendToPrinterDialog::on_selection_changed(wxCommandEvent &event)
|
||||
obj->command_get_version();
|
||||
obj->command_request_push_all();
|
||||
if (!dev->get_selected_machine()) {
|
||||
dev->set_selected_machine(m_printer_last_select, true);
|
||||
dev->set_selected_machine(m_printer_last_select);
|
||||
if (m_file_sys) m_file_sys.reset();
|
||||
}else if (dev->get_selected_machine()->dev_id != m_printer_last_select) {
|
||||
m_ability_list.clear();
|
||||
//update_storage_list(std::vector<std::string>());
|
||||
dev->set_selected_machine(m_printer_last_select, true);
|
||||
dev->set_selected_machine(m_printer_last_select);
|
||||
if (m_file_sys) m_file_sys.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,15 +52,6 @@ bool SyncAmsInfoDialog::Show(bool show)
|
||||
if (m_refresh_timer) { m_refresh_timer->Start(LIST_REFRESH_INTERVAL); }
|
||||
} else {
|
||||
m_refresh_timer->Stop();
|
||||
|
||||
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (dev) {
|
||||
MachineObject *obj_ = dev->get_selected_machine();
|
||||
if (obj_ && obj_->connection_type() == "cloud" /*&& m_print_type == FROM_SDCARD_VIEW*/) {
|
||||
if (obj_->is_connected()) { obj_->disconnect(); }
|
||||
}
|
||||
}
|
||||
|
||||
return DPIDialog::Show(false);
|
||||
}
|
||||
// set default value when show this dialog
|
||||
@@ -456,7 +447,6 @@ void SyncAmsInfoDialog::init_bitmaps()
|
||||
void SyncAmsInfoDialog::add_two_image_control()
|
||||
{// thumbnail
|
||||
m_two_thumbnail_panel = new StaticBox(m_scrolledWindow);
|
||||
// m_two_thumbnail_panel->SetBackgroundColour(wxColour(0xF8F8F8));
|
||||
m_two_thumbnail_panel->SetBorderWidth(0);
|
||||
//m_two_thumbnail_panel->SetMinSize(wxSize(FromDIP(637), -1));
|
||||
//m_two_thumbnail_panel->SetMaxSize(wxSize(FromDIP(637), -1));
|
||||
@@ -484,7 +474,6 @@ void SyncAmsInfoDialog::add_two_image_control()
|
||||
view_two_thumbnail_sizer->AddSpacer(FromDIP(24));
|
||||
{
|
||||
m_two_image_panel = new StaticBox(m_two_thumbnail_panel);
|
||||
// m_two_thumbnail_panel->SetBackgroundColour(wxColour(0xF8F8F8));
|
||||
m_two_image_panel->SetBorderWidth(0);
|
||||
//m_two_image_panel->SetForegroundColour(wxColour(248, 248, 248, 100));
|
||||
m_two_image_panel_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
@@ -754,7 +743,6 @@ SyncAmsInfoDialog::SyncAmsInfoDialog(wxWindow *parent, SyncInfo &info) :
|
||||
m_fix_filament_panel->Fit();
|
||||
/*1 extruder*/
|
||||
m_filament_panel = new StaticBox(m_scrolledWindow);
|
||||
//m_filament_panel->SetBackgroundColour(wxColour(0xF8F8F8));
|
||||
m_filament_panel->SetBorderWidth(0);
|
||||
m_filament_panel->SetMinSize(wxSize(FromDIP(637), -1));
|
||||
m_filament_panel->SetMaxSize(wxSize(FromDIP(637), -1));
|
||||
@@ -770,7 +758,7 @@ SyncAmsInfoDialog::SyncAmsInfoDialog(wxWindow *parent, SyncInfo &info) :
|
||||
m_sizer_filament_2extruder = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
m_filament_left_panel = new StaticBox(m_scrolledWindow);
|
||||
m_filament_left_panel->SetBackgroundColour(wxColour(0xF8F8F8));
|
||||
m_filament_left_panel->SetBackgroundColour(wxColour("#F8F8F8"));
|
||||
m_filament_left_panel->SetBorderWidth(0);
|
||||
m_filament_left_panel->SetMinSize(wxSize(FromDIP(315), -1));
|
||||
m_filament_left_panel->SetMaxSize(wxSize(FromDIP(315), -1));
|
||||
@@ -779,11 +767,11 @@ SyncAmsInfoDialog::SyncAmsInfoDialog(wxWindow *parent, SyncInfo &info) :
|
||||
auto left_recommend_title_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto left_recommend_title1 = new Label(m_filament_left_panel, _L("Left Extruder"));
|
||||
left_recommend_title1->SetFont(::Label::Head_13);
|
||||
left_recommend_title1->SetBackgroundColour(wxColour(0xF8F8F8));
|
||||
left_recommend_title1->SetBackgroundColour(wxColour("#F8F8F8"));
|
||||
auto left_recommend_title2 = new Label(m_filament_left_panel, _L("(Recommended filament)"));
|
||||
left_recommend_title2->SetFont(::Label::Body_13);
|
||||
left_recommend_title2->SetForegroundColour(wxColour(0x6B6B6B));
|
||||
left_recommend_title2->SetBackgroundColour(wxColour(0xF8F8F8));
|
||||
left_recommend_title2->SetForegroundColour(wxColour("#6B6B6B"));
|
||||
left_recommend_title2->SetBackgroundColour(wxColour("#F8F8F8"));
|
||||
left_recommend_title_sizer->Add(left_recommend_title1, 0, wxALIGN_CENTER, 0);
|
||||
left_recommend_title_sizer->Add(0, 0, 0, wxLEFT, FromDIP(4));
|
||||
left_recommend_title_sizer->Add(left_recommend_title2, 0, wxALIGN_CENTER, 0);
|
||||
@@ -796,7 +784,7 @@ SyncAmsInfoDialog::SyncAmsInfoDialog(wxWindow *parent, SyncInfo &info) :
|
||||
|
||||
m_filament_right_panel = new StaticBox(m_scrolledWindow);
|
||||
m_filament_right_panel->SetBorderWidth(0);
|
||||
m_filament_right_panel->SetBackgroundColour(wxColour(0xf8f8f8));
|
||||
m_filament_right_panel->SetBackgroundColour(wxColour("#F8F8F8"));
|
||||
m_filament_right_panel->SetMinSize(wxSize(FromDIP(315), -1));
|
||||
m_filament_right_panel->SetMaxSize(wxSize(FromDIP(315), -1));
|
||||
|
||||
@@ -804,12 +792,12 @@ SyncAmsInfoDialog::SyncAmsInfoDialog(wxWindow *parent, SyncInfo &info) :
|
||||
auto right_recommend_title_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto right_recommend_title1 = new Label(m_filament_right_panel, _L("Right Extruder"));
|
||||
right_recommend_title1->SetFont(::Label::Head_13);
|
||||
right_recommend_title1->SetBackgroundColour(wxColour(0xF8F8F8));
|
||||
right_recommend_title1->SetBackgroundColour(wxColour("#F8F8F8"));
|
||||
|
||||
auto right_recommend_title2 = new Label(m_filament_right_panel, _L("(Recommended filament)"));
|
||||
right_recommend_title2->SetFont(::Label::Body_13);
|
||||
right_recommend_title2->SetForegroundColour(wxColour(0x6B6B6B));
|
||||
right_recommend_title2->SetBackgroundColour(wxColour(0xF8F8F8));
|
||||
right_recommend_title2->SetForegroundColour(wxColour("#6B6B6B"));
|
||||
right_recommend_title2->SetBackgroundColour(wxColour("#F8F8F8"));
|
||||
right_recommend_title_sizer->Add(right_recommend_title1, 0, wxALIGN_CENTER, 0);
|
||||
right_recommend_title_sizer->Add(0, 0, 0, wxLEFT, FromDIP(4));
|
||||
right_recommend_title_sizer->Add(right_recommend_title2, 0, wxALIGN_CENTER, 0);
|
||||
@@ -1004,7 +992,7 @@ SyncAmsInfoDialog::SyncAmsInfoDialog(wxWindow *parent, SyncInfo &info) :
|
||||
m_button_ok = new Button(m_show_page, _L("Synchronize now"));
|
||||
m_button_ok->SetBackgroundColor(btn_bg_green);
|
||||
m_button_ok->SetBorderColor(*wxWHITE);
|
||||
m_button_ok->SetTextColor(wxColour(0xFFFFFE));
|
||||
m_button_ok->SetTextColor(wxColour("#FFFFFE"));
|
||||
m_button_ok->SetFont(Label::Body_12);
|
||||
m_button_ok->SetSize(OK_BUTTON_SIZE);
|
||||
m_button_ok->SetMinSize(OK_BUTTON_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user