From a47a0bc6e8adc9ba85341282f04f276c968f1229 Mon Sep 17 00:00:00 2001 From: Stone Li Date: Wed, 3 Jul 2024 17:08:18 +0800 Subject: [PATCH 01/57] ENH: parse net conf for network wired status JIRA: STUDIO-5195 Change-Id: Ida3cd5c60b25d1eff4f04e324a74d63394a9ffeb Signed-off-by: Stone Li (cherry picked from commit 6b6787b30736f87491171237a36c6badc8e51878) (cherry picked from commit acfdcadac09f05f2e008340d485c4781744c95f9) --- src/slic3r/GUI/DeviceManager.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 1ce29c28a35..599999117e3 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -3167,6 +3167,13 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) mc_print_line_number = atoi(jj["mc_print_line_number"].get().c_str()); } } + if (!key_field_only) { + if (jj.contains("net")) { + if (jj["net"].contains("conf")) { + network_wired = (jj["net"]["conf"].get() & (0x1)) != 0; + } + } + } #pragma endregion #pragma region online From 02d40678983c8b34ef08fbe3d55f1677b874a667 Mon Sep 17 00:00:00 2001 From: Stone Li Date: Wed, 3 Jul 2024 10:07:05 +0800 Subject: [PATCH 02/57] FIX: fix network wired issue JIRA: STUDIO-7534 Change-Id: I0b5d3764ebf61735238207adc2053ad45ce5ec1a Signed-off-by: Stone Li (cherry picked from commit babda59caa2cb83ae993bfe87c865d7f61c6ab4b) (cherry picked from commit ff22a8651580a637e42a6839ae364552354781e1) --- src/slic3r/GUI/DeviceManager.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 599999117e3..81c51ab3993 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -1429,8 +1429,6 @@ void MachineObject::parse_status(int flag) } sdcard_state = MachineObject::SdcardState((flag >> 8) & 0x11); - - network_wired = ((flag >> 18) & 0x1) != 0; } PrintingSpeedLevel MachineObject::_parse_printing_speed_lvl(int lvl) From 4e009801abcb1cce78d3a35cda4f11af3f8ad3ea Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Tue, 13 Aug 2024 14:25:00 +0800 Subject: [PATCH 03/57] FIX: change to 'Video Stopped' Change-Id: Ie8ed7865719652998577d2801ad71bc7da1f634f Jira: none (cherry picked from commit 69ad831570601554589057983ba7c7caa7964cf2) --- src/slic3r/GUI/MediaPlayCtrl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/GUI/MediaPlayCtrl.cpp b/src/slic3r/GUI/MediaPlayCtrl.cpp index 208182b9a19..a9afffc49be 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.cpp +++ b/src/slic3r/GUI/MediaPlayCtrl.cpp @@ -375,7 +375,7 @@ void MediaPlayCtrl::Stop(wxString const &msg) #endif SetStatus(msg2); } else - SetStatus(_L("Stopped."), false); + SetStatus(_L("Video Stopped."), false); m_last_state = MEDIASTATE_IDLE; bool auto_retry = wxGetApp().app_config->get("liveview", "auto_retry") != "false"; if (!auto_retry || m_failed_code >= 100 || m_failed_code == 1) // not keep retry on local error or EOS From e54508a397e88d3b7b3671c4527b8ca60cb42ae2 Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Mon, 2 Sep 2024 19:00:34 +0800 Subject: [PATCH 04/57] FIX: sleep before retry on file session lost Change-Id: I924f0a370a2a8d6a9b5aa082cbe791fc2e1a18c5 Jira: STUDIO-7991 (cherry picked from commit 3b8ef667b106de60cba542ad5ceee5db8714fc3d) --- src/slic3r/GUI/Printer/PrinterFileSystem.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/slic3r/GUI/Printer/PrinterFileSystem.cpp b/src/slic3r/GUI/Printer/PrinterFileSystem.cpp index 8d272057f8d..f97ea156bcc 100644 --- a/src/slic3r/GUI/Printer/PrinterFileSystem.cpp +++ b/src/slic3r/GUI/Printer/PrinterFileSystem.cpp @@ -1239,6 +1239,8 @@ void PrinterFileSystem::Reconnect(boost::unique_lock &l, int resul if (c) c(result, r, nullptr); } m_messages.clear(); + if (result) + m_cond.timed_wait(l, boost::posix_time::seconds(10)); while (true) { while (m_stopped) { if (m_session.owner == nullptr) From 34652b1d48f2503dfd8b1fd4c49513120711a448 Mon Sep 17 00:00:00 2001 From: "maosheng.wei" Date: Wed, 3 Apr 2024 19:10:14 +0800 Subject: [PATCH 05/57] FIX: [6657] AMS humidity display title change Jira: 6657 Change-Id: I88ed6f438211f741ec918bc35e6c10c3f2e23975 Signed-off-by: maosheng.wei (cherry picked from commit 60149a7322425d73904cc0713eed147e09f15e78) --- src/slic3r/GUI/AmsMappingPopup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/GUI/AmsMappingPopup.cpp b/src/slic3r/GUI/AmsMappingPopup.cpp index 492926b9526..3403f1ec518 100644 --- a/src/slic3r/GUI/AmsMappingPopup.cpp +++ b/src/slic3r/GUI/AmsMappingPopup.cpp @@ -907,7 +907,7 @@ AmsHumidityTipPopup::AmsHumidityTipPopup(wxWindow* parent) close_img = ScalableBitmap(this, "hum_popup_close", 24); - m_staticText = new Label(this, _L("Current Cabin humidity")); + m_staticText = new Label(this, _L("Current AMS humidity")); m_staticText->SetFont(::Label::Head_24); humidity_level_list = new AmsHumidityLevelList(this); From 0d6d027abe820f1746958ccc2799e3ed8912c879 Mon Sep 17 00:00:00 2001 From: gerrit Date: Fri, 21 Jun 2024 10:10:16 +0800 Subject: [PATCH 06/57] ci: update network module based on commit 053c1c1 Change-Id: I88b9699d48ad1e8da53f26ff549b1700bd60247b (cherry picked from commit 76b5bc626ec1372e869649f35da84c4bbba0ea12) --- src/slic3r/Utils/bambu_networking.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index c4d992bcf14..97c57288857 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -95,7 +95,7 @@ namespace BBL { #define BAMBU_NETWORK_LIBRARY "bambu_networking" #define BAMBU_NETWORK_AGENT_NAME "bambu_network_agent" -#define BAMBU_NETWORK_AGENT_VERSION "01.09.02.05" +#define BAMBU_NETWORK_AGENT_VERSION "01.09.03.01" //iot preset type strings #define IOT_PRINTER_TYPE_STRING "printer" From 39acd7fb2b0be46927ee2da5f1b4f5e80f02d625 Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Fri, 21 Jun 2024 19:55:51 +0800 Subject: [PATCH 07/57] FIX: liveview local missing ip dialog not show Change-Id: Ie15bdf0ac20354aecb2e0dffe9471e12e0143aa9 (cherry picked from commit 4d7715cc116b37f0889729d6550c8aa1a5034b73) --- src/slic3r/GUI/MediaPlayCtrl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/GUI/MediaPlayCtrl.cpp b/src/slic3r/GUI/MediaPlayCtrl.cpp index a9afffc49be..74db88d3aa0 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.cpp +++ b/src/slic3r/GUI/MediaPlayCtrl.cpp @@ -259,7 +259,6 @@ void MediaPlayCtrl::Play() return; } - m_button_play->SetIcon("media_stop"); NetworkAgent *agent = wxGetApp().getAgent(); std::string agent_version = agent ? agent->get_version() : ""; if (m_lan_proto > MachineObject::LVL_Disable && (m_lan_mode || !m_remote_support) && !m_disable_lan && !m_lan_ip.empty()) { @@ -279,6 +278,7 @@ void MediaPlayCtrl::Play() BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: " << hide_passwd(hide_id_middle_string(url, url.find(m_lan_ip), m_lan_ip.length()), {m_lan_passwd}); m_url = url; load(); + m_button_play->SetIcon("media_stop"); return; } From 823ab50fb8318fffbc74836a325a6ac123f01059 Mon Sep 17 00:00:00 2001 From: tao wang Date: Mon, 24 Jun 2024 21:13:14 +0800 Subject: [PATCH 08/57] ENH:Support for binding farm mode printers jira:[for farm mode] Change-Id: Icb2eb3f8435bcc1cabcb343ba040ce426eb50581 (cherry picked from commit f6a230869b020bcd149b7e2878cd33a4200c6a06) --- src/slic3r/GUI/DeviceManager.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 81c51ab3993..ec83631e34c 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -5177,6 +5177,12 @@ void DeviceManager::on_machine_alive(std::string json_str) std::string printer_signal = j["dev_signal"].get(); std::string connect_type = j["connect_type"].get(); std::string bind_state = j["bind_state"].get(); + + if (connect_type == "farm") { + connect_type ="lan"; + bind_state = "free"; + } + std::string sec_link = ""; std::string ssdp_version = ""; if (j.contains("sec_link")) { From f67c84529966b2b6a51d2f962ae5f90f7c9e3cba Mon Sep 17 00:00:00 2001 From: gerrit Date: Wed, 14 Aug 2024 18:39:26 +0800 Subject: [PATCH 09/57] ci: update network module based on commit ce3b330 Change-Id: I5700edccc853075ea82118a3b9eed78e5c5f48e8 (cherry picked from commit 553028775ecb8c8338d5d32bff868ae43ac85852) --- src/slic3r/Utils/bambu_networking.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index 97c57288857..71d3c9ef77f 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -95,7 +95,7 @@ namespace BBL { #define BAMBU_NETWORK_LIBRARY "bambu_networking" #define BAMBU_NETWORK_AGENT_NAME "bambu_network_agent" -#define BAMBU_NETWORK_AGENT_VERSION "01.09.03.01" +#define BAMBU_NETWORK_AGENT_VERSION "01.09.04.01" //iot preset type strings #define IOT_PRINTER_TYPE_STRING "printer" From a727f4f04a2b41c18f7b8d01a63a21139c7ecf81 Mon Sep 17 00:00:00 2001 From: tao wang Date: Tue, 13 Aug 2024 11:41:45 +0800 Subject: [PATCH 10/57] NEW:Support setting filaments in printing jira:[set filament] Change-Id: Ib37896f9101d93ca63c7edb0b1e6328045a5ddb3 (cherry picked from commit fa2dbd7ada18bc806be845673cce9eb4559cda80) --- src/slic3r/GUI/AMSMaterialsSetting.cpp | 14 ++++++++++---- src/slic3r/GUI/DeviceManager.cpp | 14 ++++++++++++++ src/slic3r/GUI/DeviceManager.hpp | 1 + 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/AMSMaterialsSetting.cpp b/src/slic3r/GUI/AMSMaterialsSetting.cpp index 2ceab92c1b5..b8dee80661a 100644 --- a/src/slic3r/GUI/AMSMaterialsSetting.cpp +++ b/src/slic3r/GUI/AMSMaterialsSetting.cpp @@ -413,7 +413,13 @@ void AMSMaterialsSetting::update() void AMSMaterialsSetting::enable_confirm_button(bool en) { - m_button_confirm->Show(en); + if (!en) { + m_button_confirm->Show(obj->is_support_filament_setting_inprinting); + } + else { + m_button_confirm->Show(en); + } + if (!m_is_third) { m_tip_readonly->Hide(); } @@ -705,7 +711,7 @@ void AMSMaterialsSetting::on_picker_color(wxCommandEvent& event) void AMSMaterialsSetting::on_clr_picker(wxMouseEvent &event) { - if(!m_is_third || obj->is_in_printing() || obj->can_resume()) + if(!m_is_third || !obj->is_support_filament_setting_inprinting) return; @@ -922,8 +928,8 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi } m_button_reset->Show(); - m_button_confirm->Show(); - } + //m_button_confirm->Show(); + } m_comboBox_filament->Set(filament_items); m_comboBox_filament->SetSelection(selection_idx); diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index ec83631e34c..80549486ca3 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -3165,6 +3165,12 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) mc_print_line_number = atoi(jj["mc_print_line_number"].get().c_str()); } } + if (!key_field_only) { + if (jj.contains("flag3")) { + int flag3 = jj["flag3"].get(); + is_support_filament_setting_inprinting = get_flag_bits(flag3, 3); + } + } if (!key_field_only) { if (jj.contains("net")) { if (jj["net"].contains("conf")) { @@ -4308,6 +4314,14 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } } } else if (jj["command"].get() == "ams_filament_setting" && !key_field_only) { + if (jj.contains("result") && jj.contains("reason")) { + if (jj["result"].get() == "fail") { + auto err_code = jj["err_code"].get(); + print_error = err_code; + } + } + + // BBS trigger ams UI update ams_version = -1; diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index be177bba5a6..b3d2717a8b8 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -762,6 +762,7 @@ public: bool is_support_p1s_plus{false}; bool is_support_nozzle_blob_detection{false}; bool is_support_air_print_detection{false}; + bool is_support_filament_setting_inprinting{false}; int nozzle_max_temperature = -1; int bed_temperature_limit = -1; From b03ede197825523e9fddde185287233ad052a65d Mon Sep 17 00:00:00 2001 From: tao wang Date: Tue, 20 Aug 2024 17:42:49 +0800 Subject: [PATCH 11/57] FIX:disable some non existent methods Change-Id: Ic5af8864bcb709f9f76303eb4a0f13b4789400b4 (cherry picked from commit 1f4dd2b2a89e0e2109b4ba3fa80e48a01a2bebaf) --- src/slic3r/GUI/DeviceManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 80549486ca3..7170783b513 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -3168,7 +3168,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) if (!key_field_only) { if (jj.contains("flag3")) { int flag3 = jj["flag3"].get(); - is_support_filament_setting_inprinting = get_flag_bits(flag3, 3); + //is_support_filament_setting_inprinting = get_flag_bits(flag3, 3); } } if (!key_field_only) { From 5fe1b4fd7e2a84a5b5a879c3f83592dd797f6668 Mon Sep 17 00:00:00 2001 From: tao wang Date: Wed, 21 Aug 2024 12:24:17 +0800 Subject: [PATCH 12/57] FIX:fixed unable to pick color jira:[for setting] Change-Id: I877af3561fcbeb43b46202cb2b27b6522425a83f (cherry picked from commit 5648ef61afdc1463e7dc80856a6e4a65e6a892c7) --- src/slic3r/GUI/AMSMaterialsSetting.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/AMSMaterialsSetting.cpp b/src/slic3r/GUI/AMSMaterialsSetting.cpp index b8dee80661a..5c75802c7e6 100644 --- a/src/slic3r/GUI/AMSMaterialsSetting.cpp +++ b/src/slic3r/GUI/AMSMaterialsSetting.cpp @@ -711,9 +711,14 @@ void AMSMaterialsSetting::on_picker_color(wxCommandEvent& event) void AMSMaterialsSetting::on_clr_picker(wxMouseEvent &event) { - if(!m_is_third || !obj->is_support_filament_setting_inprinting) + if(!m_is_third) return; + if (obj->is_in_printing() || obj->can_resume()) { + if (!obj->is_support_filament_setting_inprinting) { + return; + } + } std::vector ams_colors; for (auto ams_it = obj->amsList.begin(); ams_it != obj->amsList.end(); ++ams_it) { From d4b1f4a574028c064bc4e586b08cf5a922a937d0 Mon Sep 17 00:00:00 2001 From: gerrit Date: Wed, 28 Aug 2024 21:16:15 +0800 Subject: [PATCH 13/57] ci: update network module based on commit ba54563 Change-Id: I587d656e20ed2ee8927ca2f5272ad715bed66740 (cherry picked from commit 20a531733ce240817610c9956af8f16dbe49d426) --- src/slic3r/Utils/bambu_networking.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index 71d3c9ef77f..6c458b20b92 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -95,7 +95,7 @@ namespace BBL { #define BAMBU_NETWORK_LIBRARY "bambu_networking" #define BAMBU_NETWORK_AGENT_NAME "bambu_network_agent" -#define BAMBU_NETWORK_AGENT_VERSION "01.09.04.01" +#define BAMBU_NETWORK_AGENT_VERSION "01.09.05.01" //iot preset type strings #define IOT_PRINTER_TYPE_STRING "printer" From d647e31bb8d2b2b4454408c9d07df53c5576ced9 Mon Sep 17 00:00:00 2001 From: tao wang Date: Wed, 14 Aug 2024 11:52:12 +0800 Subject: [PATCH 14/57] NEW:Support direct connection to LAN printers jira:[connect printer] Change-Id: Ifdc25651f4effde8e2a2d2a4e690aa20e0ef7022 (cherry picked from commit 0ec49c3588c1f81c159193de352f8a47d39ffe74) --- src/slic3r/GUI/DeviceManager.cpp | 15 +++ src/slic3r/GUI/DeviceManager.hpp | 2 +- src/slic3r/GUI/ReleaseNote.cpp | 165 ++++++++++++++++---------- src/slic3r/GUI/ReleaseNote.hpp | 9 +- src/slic3r/GUI/SelectMachine.cpp | 60 ++++------ src/slic3r/GUI/SelectMachine.hpp | 5 +- src/slic3r/Utils/NetworkAgent.cpp | 14 +++ src/slic3r/Utils/NetworkAgent.hpp | 3 + src/slic3r/Utils/bambu_networking.hpp | 11 ++ 9 files changed, 181 insertions(+), 103 deletions(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 7170783b513..91b3768776c 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -5300,6 +5300,21 @@ void DeviceManager::on_machine_alive(std::string json_str) } } +MachineObject* DeviceManager::insert_local_device(std::string dev_name, std::string dev_id, std::string dev_ip, std::string connection_type, std::string bind_state, std::string version, std::string access_code) +{ + MachineObject* obj; + obj = new MachineObject(m_agent, dev_name, dev_id, dev_ip); + obj->printer_type = MachineObject::parse_printer_type("C11"); + obj->dev_connection_type = connection_type; + obj->bind_state = bind_state; + obj->bind_sec_link = "secure"; + obj->bind_ssdp_version = version; + obj->m_is_online = true; + obj->set_access_code(access_code, false); + obj->set_user_access_code(access_code, false); + return obj; +} + void DeviceManager::disconnect_all() { diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index b3d2717a8b8..7c907257086 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -1007,7 +1007,7 @@ public: /* create machine or update machine properties */ void on_machine_alive(std::string json_str); - + MachineObject* insert_local_device(std::string dev_name, std::string dev_id, std::string dev_ip, std::string connection_type, std::string bind_state, std::string version, std::string access_code); /* disconnect all machine connections */ void disconnect_all(); int query_bind_status(std::string &msg); diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index a2a805a39f2..877992a89a6 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -1437,7 +1437,7 @@ void ConfirmBeforeSendDialog::rescale() } InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent) - :DPIDialog(static_cast(wxGetApp().mainframe), wxID_ANY, _L("LAN Connection Failed (Sending print file)"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX) + :DPIDialog(static_cast(wxGetApp().mainframe), wxID_ANY, _L("Connect the printer using IP and access code"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX) { std::string icon_path = (boost::format("%1%/images/OrcaSlicerTitle.ico") % resources_dir()).str(); SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO)); @@ -1527,7 +1527,7 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent) StateColor btn_bg_white(std::pair(wxColour(206, 206, 206), StateColor::Pressed), std::pair(wxColour(238, 238, 238), StateColor::Hovered), std::pair(*wxWHITE, StateColor::Normal)); - m_button_ok = new Button(this, _L("Test")); + m_button_ok = new Button(this, _L("Connect")); m_button_ok->SetBackgroundColor(btn_bg_green); m_button_ok->SetBorderColor(*wxWHITE); m_button_ok->SetTextColor(wxColour(0xFFFFFE)); @@ -1552,7 +1552,7 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent) }); m_sizer_button->AddStretchSpacer(); - //m_sizer_button->Add(m_button_ok, 0, wxALL, FromDIP(5)); + m_sizer_button->Add(m_button_ok, 0, wxALL, FromDIP(5)); m_sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5)); m_sizer_button->Layout(); @@ -1560,7 +1560,6 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent) m_status_bar = std::make_shared(this); m_status_bar->get_panel()->Hide(); - m_worker = std::make_unique>(this, m_status_bar, "send_worker"); auto m_step_icon_panel1 = new wxWindow(this, wxID_ANY); auto m_step_icon_panel2 = new wxWindow(this, wxID_ANY); @@ -1632,12 +1631,12 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent) m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(4)); m_sizer_main_right->Add(m_input_area, 0, wxRIGHT|wxEXPAND, FromDIP(18)); m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(4)); - m_sizer_main_right->Add(m_button_ok, 0, wxRIGHT, FromDIP(18)); + //m_sizer_main_right->Add(m_button_ok, 0, wxRIGHT, FromDIP(18)); m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(4)); m_sizer_main_right->Add(m_test_right_msg, 0, wxRIGHT|wxEXPAND, FromDIP(18)); m_sizer_main_right->Add(m_test_wrong_msg, 0, wxRIGHT|wxEXPAND, FromDIP(18)); - m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(16)); + m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(4)); m_sizer_main_right->Add(m_status_bar->get_panel(), 0,wxRIGHT|wxEXPAND, FromDIP(18)); m_sizer_main_right->Layout(); @@ -1646,8 +1645,8 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent) m_sizer_main->Layout(); m_sizer_body->Add(m_line_top, 0, wxEXPAND, 0); - m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(20)); - m_sizer_body->Add(m_sizer_main, 0, wxEXPAND, 0); + m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(4)); + m_sizer_body->Add(m_sizer_main, 0, wxRIGHT, FromDIP(10)); m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(4)); m_sizer_body->Add(m_sizer_msg, 0, wxLEFT|wxEXPAND, FromDIP(18)); m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(4)); @@ -1655,6 +1654,7 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent) m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(8)); m_sizer_body->Add(m_sizer_button, 0, wxRIGHT | wxEXPAND, FromDIP(25)); + m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(10)); m_sizer_body->Layout(); SetSizer(m_sizer_body); @@ -1665,24 +1665,33 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent) Move(wxPoint(GetScreenPosition().x, GetScreenPosition().y - FromDIP(50))); wxGetApp().UpdateDlgDarkUI(this); + closeTimer = new wxTimer(); + closeTimer->SetOwner(this); + Bind(wxEVT_TIMER, &InputIpAddressDialog::OnTimer, this); + Bind(EVT_CHECK_IP_ADDRESS_FAILED, &InputIpAddressDialog::on_check_ip_address_failed, this); Bind(EVT_CLOSE_IPADDRESS_DLG, [this](auto& e) { m_status_bar->reset(); EndModal(wxID_YES); }); - Bind(wxEVT_CLOSE_WINDOW, [this](auto& e) {on_cancel();}); + Bind(wxEVT_CLOSE_WINDOW, [this](auto& e) { + on_cancel(); + closeTimer->Stop(); + }); } void InputIpAddressDialog::on_cancel() { - m_worker->cancel_all(); - if (m_result == 0){ - this->EndModal(wxID_YES); - }else { - this->EndModal(wxID_CANCEL); + if (m_thread) { + m_thread->interrupt(); + m_thread->join(); + delete m_thread; + m_thread = nullptr; } + + EndModal(wxID_CANCEL); } @@ -1739,9 +1748,7 @@ void InputIpAddressDialog::update_test_msg(wxString msg,bool connected) m_test_wrong_msg->SetLabelText(msg); m_test_wrong_msg->SetMinSize(wxSize(FromDIP(352), -1)); m_test_wrong_msg->SetMaxSize(wxSize(FromDIP(352), -1)); - } - - + } } Layout(); @@ -1771,13 +1778,11 @@ void InputIpAddressDialog::on_ok(wxMouseEvent& evt) m_img_step3->Hide(); m_tip4->Hide(); m_trouble_shoot->Hide(); - Layout(); - Fit(); - wxString ip = m_input_ip->GetTextCtrl()->GetValue(); - wxString str_access_code = m_input_access_code->GetTextCtrl()->GetValue(); + std::string str_ip = m_input_ip->GetTextCtrl()->GetValue().ToStdString(); + std::string str_access_code = m_input_access_code->GetTextCtrl()->GetValue().ToStdString(); //check support function - if (!m_obj) return; + /*if (!m_obj) return; if (!m_obj->is_support_send_to_sdcard) { wxString input_str = wxString::Format("%s|%s", ip, str_access_code); auto event = wxCommandEvent(EVT_ENTER_IP_ADDRESS); @@ -1789,58 +1794,84 @@ void InputIpAddressDialog::on_ok(wxMouseEvent& evt) event_close.SetEventObject(this); wxPostEvent(this, event_close); return; - } + }*/ m_button_ok->Enable(false); m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90)); m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90)); - m_worker->wait_for_idle(); + Refresh(); + Layout(); + Fit(); - m_status_bar->reset(); - m_status_bar->set_prog_block(); - m_status_bar->set_cancel_callback_fina([this]() { - BOOST_LOG_TRIVIAL(info) << "print_job: enter canceled"; - m_worker->cancel_all(); - }); + m_thread = new boost::thread(boost::bind(&InputIpAddressDialog::workerThreadFunc, this, str_ip, str_access_code)); +} + +void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_access_code) +{ + update_test_msg(_L("connecting..."), true); + detectResult detectData; + auto result = wxGetApp().getAgent()->bind_detect(str_ip, "secure", detectData); + + if (result < 0) { + update_test_msg(wxEmptyString, true); + if (result == -1) { + update_test_msg(_L("Failed to connect to printer."), false); + } + else if (result == -2) { + update_test_msg(_L("Failed to publish login request."), false); + } + else if (result == -3) { + update_test_msg(_L("The device does not support using IP and Access Code for connection."), false); + } + Layout(); + Fit(); + return; + } + + if (detectData.bind_state == "occupied") { + update_test_msg(_L("The printer has already been bound."), false); + Layout(); + Fit(); + return; + } + + if (detectData.connect_type == "cloud") { + update_test_msg(_L("The printer mode is incorrect, please switch to LAN Only."), false); + Layout(); + Fit(); + return; + } + + DeviceManager* dev = wxGetApp().getDeviceManager(); + m_obj = dev->insert_local_device(detectData.dev_name, detectData.dev_id, str_ip, detectData.connect_type, detectData.bind_state, detectData.version, str_access_code); - auto m_send_job = std::make_unique(m_obj->dev_id); - m_send_job->m_dev_ip = ip.ToStdString(); - m_send_job->m_access_code = str_access_code.ToStdString(); + if (m_obj) { + m_obj->set_user_access_code(str_access_code); + wxGetApp().getDeviceManager()->set_selected_machine(m_obj->dev_id); + } -#if !BBL_RELEASE_TO_PUBLIC - m_send_job->m_local_use_ssl_for_mqtt = wxGetApp().app_config->get("enable_ssl_for_mqtt") == "true" ? true : false; - m_send_job->m_local_use_ssl_for_ftp = wxGetApp().app_config->get("enable_ssl_for_ftp") == "true" ? true : false; -#else - m_send_job->m_local_use_ssl_for_mqtt = m_obj->local_use_ssl_for_mqtt; - m_send_job->m_local_use_ssl_for_ftp = m_obj->local_use_ssl_for_ftp; -#endif + closeCount = 3; + update_test_msg(wxEmptyString, true); + update_test_msg(wxString::Format(_L("Printer binding successful. The dialog will close in %d seconds"), closeCount), true); + closeTimer->Start(1000); - m_send_job->connection_type = m_obj->connection_type(); - m_send_job->cloud_print_only = true; - m_send_job->has_sdcard = m_obj->has_sdcard(); - m_send_job->set_check_mode(); - m_send_job->set_project_name("verify_job"); + Layout(); + Fit(); +} - m_send_job->on_check_ip_address_fail([this](int result) { - this->check_ip_address_failed(result); - }); - - m_send_job->on_check_ip_address_success([this, ip, str_access_code]() { - wxString input_str = wxString::Format("%s|%s", ip, str_access_code); - auto event = wxCommandEvent(EVT_ENTER_IP_ADDRESS); - event.SetString(input_str); - event.SetEventObject(this); - wxPostEvent(this, event); - m_result = 0; - - update_test_msg(_L("IP and Access Code Verified! You may close the window"), true); - - }); - - replace_job(*m_worker, std::move(m_send_job)); +void InputIpAddressDialog::OnTimer(wxTimerEvent& event) { + if (closeCount > 0) { + closeCount--; + update_test_msg(wxString::Format(_L("Printer binding successful. The dialog will close in %d seconds"), closeCount), true); + Refresh(); + } + else { + closeTimer->Stop(); + EndModal(wxID_CLOSE); + } } void InputIpAddressDialog::check_ip_address_failed(int result) @@ -1876,8 +1907,16 @@ void InputIpAddressDialog::on_text(wxCommandEvent& evt) { auto str_ip = m_input_ip->GetTextCtrl()->GetValue(); auto str_access_code = m_input_access_code->GetTextCtrl()->GetValue(); + bool invalid_access_code = true; - if (isIp(str_ip.ToStdString()) && str_access_code.Length() == 8) { + for (char c : str_access_code) { + if (!('0' <= c && c <= '9' || 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z')) { + invalid_access_code = false; + return; + } + } + + if (isIp(str_ip.ToStdString()) && str_access_code.Length() == 8 && invalid_access_code) { m_button_ok->Enable(true); StateColor btn_bg_green(std::pair(wxColour(0, 137, 123), StateColor::Pressed), std::pair(wxColour(38, 166, 154), StateColor::Hovered), std::pair(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal)); diff --git a/src/slic3r/GUI/ReleaseNote.hpp b/src/slic3r/GUI/ReleaseNote.hpp index d8ad66644c8..75c4c24edb5 100644 --- a/src/slic3r/GUI/ReleaseNote.hpp +++ b/src/slic3r/GUI/ReleaseNote.hpp @@ -38,8 +38,6 @@ #include #include -#include "Jobs/Worker.hpp" - namespace Slic3r { namespace GUI { wxDECLARE_EVENT(EVT_SECONDARY_CHECK_CONFIRM, wxCommandEvent); @@ -277,6 +275,8 @@ public: wxString comfirm_before_enter_text; wxString comfirm_after_enter_text; + boost::thread* m_thread{nullptr}; + std::string m_ip; Label* m_tip1{ nullptr }; Label* m_tip2{ nullptr }; @@ -298,10 +298,11 @@ public: wxStaticBitmap* m_img_step2{ nullptr }; wxStaticBitmap* m_img_step3{ nullptr }; wxHyperlinkCtrl* m_trouble_shoot{ nullptr }; + wxTimer* closeTimer{ nullptr }; + int closeCount{3}; bool m_show_access_code{ false }; int m_result; std::shared_ptr m_status_bar; - std::unique_ptr m_worker; void on_cancel(); void update_title(wxString title); @@ -311,6 +312,8 @@ public: void check_ip_address_failed(int result); void on_check_ip_address_failed(wxCommandEvent& evt); void on_ok(wxMouseEvent& evt); + void workerThreadFunc(std::string str_ip, std::string str_access_code); + void OnTimer(wxTimerEvent& event); void on_text(wxCommandEvent& evt); void on_dpi_changed(const wxRect& suggested_rect) override; }; diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index e6b2ac81c57..bfd09704394 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -400,11 +400,13 @@ SelectMachinePopup::SelectMachinePopup(wxWindow *parent) m_sizer_other_devices = new wxBoxSizer(wxVERTICAL); - m_panel_ping_code = new PinCodePanel(m_scrolledWindow, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_ITEM_SIZE); + m_panel_ping_code = new PinCodePanel(m_scrolledWindow, 0, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_ITEM_SIZE); + m_panel_direct_connection = new PinCodePanel(m_scrolledWindow, 1, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_ITEM_SIZE); m_sizxer_scrolledWindow->Add(own_title, 0, wxEXPAND | wxLEFT, FromDIP(15)); m_sizxer_scrolledWindow->Add(m_sizer_my_devices, 0, wxEXPAND, 0); m_sizxer_scrolledWindow->Add(m_panel_ping_code, 0, wxEXPAND, 0); + m_sizxer_scrolledWindow->Add(m_panel_direct_connection, 0, wxEXPAND, 0); m_sizxer_scrolledWindow->Add(other_title, 0, wxEXPAND | wxLEFT, FromDIP(15)); m_sizxer_scrolledWindow->Add(m_sizer_other_devices, 0, wxEXPAND, 0); @@ -879,14 +881,16 @@ void SelectMachinePopup::OnLeftUp(wxMouseEvent &event) //pin code auto pc_rect = m_panel_ping_code->ClientToScreen(wxPoint(0, 0)); if (mouse_pos.x > pc_rect.x && mouse_pos.y > pc_rect.y && mouse_pos.x < (pc_rect.x + m_panel_ping_code->GetSize().x) && mouse_pos.y < (pc_rect.y + m_panel_ping_code->GetSize().y)) { - /*wxMouseEvent event(wxEVT_LEFT_UP); - auto tag_pos = m_panel_ping_code->ScreenToClient(mouse_pos); - event.SetPosition(tag_pos); - event.SetEventObject(m_panel_ping_code); - wxPostEvent(m_panel_ping_code, event);*/ wxGetApp().popup_ping_bind_dialog(); } + //bind with access code + auto dc_rect = m_panel_direct_connection->ClientToScreen(wxPoint(0, 0)); + if (mouse_pos.x > dc_rect.x && mouse_pos.y > dc_rect.y && mouse_pos.x < (dc_rect.x + m_panel_direct_connection->GetSize().x) && mouse_pos.y < (dc_rect.y + m_panel_direct_connection->GetSize().y)) { + InputIpAddressDialog dlgo; + dlgo.ShowModal(); + } + //hyper link auto h_rect = m_hyperlink->ClientToScreen(wxPoint(0, 0)); if (mouse_pos.x > h_rect.x && mouse_pos.y > h_rect.y && mouse_pos.x < (h_rect.x + m_hyperlink->GetSize().x) && mouse_pos.y < (h_rect.y + m_hyperlink->GetSize().y)) { @@ -1450,30 +1454,6 @@ void SelectMachineDialog::init_bind() m_comboBox_printer->SetValue(obj->dev_name + "(LAN)"); } } - /*else if (e.GetInt() == 1 && (m_print_type == PrintFromType::FROM_SDCARD_VIEW)) { - on_send_print(); - } - else if (e.GetInt() == -2 && (m_print_type == PrintFromType::FROM_SDCARD_VIEW)) { - show_status(PrintDialogStatus::PrintStatusInit); - prepare_mode(); - MessageDialog msg_wingow(nullptr, _L("Printer local connection failed, please try again."), "", wxAPPLY | wxOK); - msg_wingow.ShowModal(); - } - else if (e.GetInt() == 5 && (m_print_type == PrintFromType::FROM_SDCARD_VIEW)) { - show_status(PrintDialogStatus::PrintStatusInit); - prepare_mode(); - - DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); - if (!dev) return; - ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code")); - dlg.go_connect_printer(false); - if (dev->get_selected_machine()) { - dlg.set_machine_object(dev->get_selected_machine()); - if (dlg.ShowModal() == wxID_OK) { - this->connect_printer_mqtt(); - } - } - }*/ }); m_bitmap_last_plate->Bind(wxEVT_LEFT_DOWN, [this](auto& e) { @@ -4854,7 +4834,7 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e) ThumbnailPanel::~ThumbnailPanel() {} - PinCodePanel::PinCodePanel(wxWindow* parent, wxWindowID winid /*= wxID_ANY*/, const wxPoint& pos /*= wxDefaultPosition*/, const wxSize& size /*= wxDefaultSize*/) + PinCodePanel::PinCodePanel(wxWindow* parent, int type, wxWindowID winid /*= wxID_ANY*/, const wxPoint& pos /*= wxDefaultPosition*/, const wxSize& size /*= wxDefaultSize*/) { wxPanel::Create(parent, winid, pos, SELECT_MACHINE_ITEM_SIZE); Bind(wxEVT_PAINT, &PinCodePanel::OnPaint, this); @@ -4862,6 +4842,7 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e) SetMaxSize(SELECT_MACHINE_ITEM_SIZE); SetMinSize(SELECT_MACHINE_ITEM_SIZE); + m_type = type; m_bitmap = ScalableBitmap(this, "bind_device_ping_code",10); this->Bind(wxEVT_ENTER_WINDOW, &PinCodePanel::on_mouse_enter, this); @@ -4899,12 +4880,15 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e) void PinCodePanel::doRender(wxDC& dc) { auto size = GetSize(); - dc.DrawBitmap(m_bitmap.bmp(), wxPoint(FromDIP(20), (size.y - m_bitmap.GetBmpSize().y) / 2)); + dc.DrawBitmap(m_bitmap.bmp(), wxPoint(FromDIP(12), (size.y - m_bitmap.GetBmpSize().y) / 2)); dc.SetFont(::Label::Head_13); dc.SetTextForeground(StateColor::darkModeColorFor(wxColour("#262E30"))); // ORCA fix text not visible on dark theme - wxString txt = _L("Bind with Pin Code"); + wxString txt; + if (m_type == 0) { txt = _L("Bind with Pin Code"); } + else if (m_type == 1) { txt = _L("Bind with Access Code"); } + auto txt_size = dc.GetTextExtent(txt); - dc.DrawText(txt, wxPoint(FromDIP(40), (size.y - txt_size.y) / 2)); + dc.DrawText(txt, wxPoint(FromDIP(28), (size.y - txt_size.y) / 2)); if (m_hover) { dc.SetPen(SELECT_MACHINE_BRAND); @@ -4927,7 +4911,13 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e) void PinCodePanel::on_mouse_left_up(wxMouseEvent& evt) { - wxGetApp().popup_ping_bind_dialog(); + if (m_type == 0) { + wxGetApp().popup_ping_bind_dialog(); + } + else if (m_type == 1) { + InputIpAddressDialog dlgo; + dlgo.ShowModal(); + } } }} // namespace Slic3r::GUI diff --git a/src/slic3r/GUI/SelectMachine.hpp b/src/slic3r/GUI/SelectMachine.hpp index 16da5e05d57..6752e2a8691 100644 --- a/src/slic3r/GUI/SelectMachine.hpp +++ b/src/slic3r/GUI/SelectMachine.hpp @@ -195,7 +195,7 @@ protected: #define SELECT_MACHINE_POPUP_SIZE wxSize(FromDIP(216), FromDIP(364)) #define SELECT_MACHINE_LIST_SIZE wxSize(FromDIP(212), FromDIP(360)) -#define SELECT_MACHINE_ITEM_SIZE wxSize(FromDIP(182), FromDIP(35)) +#define SELECT_MACHINE_ITEM_SIZE wxSize(FromDIP(190), FromDIP(35)) #define SELECT_MACHINE_GREY900 wxColour(38, 46, 48) #define SELECT_MACHINE_GREY600 wxColour(144,144,144) #define SELECT_MACHINE_GREY400 wxColour(206, 206, 206) @@ -214,6 +214,7 @@ class PinCodePanel : public wxPanel { public: PinCodePanel(wxWindow* parent, + int type, wxWindowID winid = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize); @@ -221,6 +222,7 @@ public: ScalableBitmap m_bitmap; bool m_hover{false}; + int m_type{0}; void OnPaint(wxPaintEvent& event); void render(wxDC& dc); @@ -254,6 +256,7 @@ private: int m_my_devices_count{0}; int m_other_devices_count{0}; PinCodePanel* m_panel_ping_code{nullptr}; + PinCodePanel* m_panel_direct_connection{nullptr}; wxWindow* m_placeholder_panel{nullptr}; wxHyperlinkCtrl* m_hyperlink{nullptr}; Label* m_ping_code_text{nullptr}; diff --git a/src/slic3r/Utils/NetworkAgent.cpp b/src/slic3r/Utils/NetworkAgent.cpp index 1ffdf0464e4..474132983d2 100644 --- a/src/slic3r/Utils/NetworkAgent.cpp +++ b/src/slic3r/Utils/NetworkAgent.cpp @@ -75,6 +75,7 @@ func_build_logout_cmd NetworkAgent::build_logout_cmd_ptr = nullptr func_build_login_info NetworkAgent::build_login_info_ptr = nullptr; func_get_model_id_from_desgin_id NetworkAgent::get_model_id_from_desgin_id_ptr = nullptr; func_ping_bind NetworkAgent::ping_bind_ptr = nullptr; +func_bind_detect NetworkAgent::bind_detect_ptr = nullptr; func_bind NetworkAgent::bind_ptr = nullptr; func_unbind NetworkAgent::unbind_ptr = nullptr; func_get_bambulab_host NetworkAgent::get_bambulab_host_ptr = nullptr; @@ -246,6 +247,7 @@ int NetworkAgent::initialize_network_module(bool using_backup) build_logout_cmd_ptr = reinterpret_cast(get_network_function("bambu_network_build_logout_cmd")); build_login_info_ptr = reinterpret_cast(get_network_function("bambu_network_build_login_info")); ping_bind_ptr = reinterpret_cast(get_network_function("bambu_network_ping_bind")); + bind_detect_ptr = reinterpret_cast(get_network_function("bambu_network_bind_detect")); get_model_id_from_desgin_id_ptr = reinterpret_cast(get_network_function("bambu_network_get_model_id_from_desgin_id")); bind_ptr = reinterpret_cast(get_network_function("bambu_network_bind")); unbind_ptr = reinterpret_cast(get_network_function("bambu_network_unbind")); @@ -979,6 +981,18 @@ int NetworkAgent::ping_bind(std::string ping_code) return ret; } +int NetworkAgent::bind_detect(std::string dev_ip, std::string sec_link, detectResult& detect) +{ + int ret = 0; + if (network_agent && bind_detect_ptr) { + ret = bind_detect_ptr(network_agent, dev_ip, sec_link, detect); + if (ret) + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%, dev_ip=%3%") + % network_agent % ret % dev_ip; + } + return ret; +} + int NetworkAgent::bind(std::string dev_ip, std::string dev_id, std::string sec_link, std::string timezone, bool improved, OnUpdateStatusFn update_fn) { int ret = 0; diff --git a/src/slic3r/Utils/NetworkAgent.hpp b/src/slic3r/Utils/NetworkAgent.hpp index 59663fcb0b6..e0a51703ebd 100644 --- a/src/slic3r/Utils/NetworkAgent.hpp +++ b/src/slic3r/Utils/NetworkAgent.hpp @@ -55,6 +55,7 @@ typedef std::string (*func_build_logout_cmd)(void *agent); typedef std::string (*func_build_login_info)(void *agent); typedef int (*func_get_model_id_from_desgin_id)(void *agent, std::string& desgin_id, std::string& model_id); typedef int (*func_ping_bind)(void *agent, std::string ping_code); +typedef int (*func_bind_detect)(void *agent, std::string dev_ip, std::string sec_link, detectResult& detect); typedef int (*func_bind)(void *agent, std::string dev_ip, std::string dev_id, std::string sec_link, std::string timezone, bool improved, OnUpdateStatusFn update_fn); typedef int (*func_unbind)(void *agent, std::string dev_id); typedef std::string (*func_get_bambulab_host)(void *agent); @@ -171,6 +172,7 @@ public: std::string build_login_info(); int get_model_id_from_desgin_id(std::string& desgin_id, std::string& model_id); int ping_bind(std::string ping_code); + int bind_detect(std::string dev_ip, std::string sec_link, detectResult& detect); int bind(std::string dev_ip, std::string dev_id, std::string sec_link, std::string timezone, bool improved, OnUpdateStatusFn update_fn); int unbind(std::string dev_id); std::string get_bambulab_host(); @@ -277,6 +279,7 @@ private: static func_build_login_info build_login_info_ptr; static func_get_model_id_from_desgin_id get_model_id_from_desgin_id_ptr; static func_ping_bind ping_bind_ptr; + static func_bind_detect bind_detect_ptr; static func_bind bind_ptr; static func_unbind unbind_ptr; static func_get_bambulab_host get_bambulab_host_ptr; diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index 6c458b20b92..9523877c81d 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -172,6 +172,17 @@ enum ConnectStatus { ConnectStatusLost = 2, }; +struct detectResult { + std::string result_msg; + std::string command; + std::string dev_id; + std::string model_id; + std::string dev_name; + std::string version; + std::string bind_state; + std::string connect_type; +}; + /* print job*/ struct PrintParams { /* basic info */ From 84deeefba6be97aba31ae50240d4c057837c1244 Mon Sep 17 00:00:00 2001 From: Kunlong Ma Date: Wed, 4 Sep 2024 18:21:00 +0800 Subject: [PATCH 15/57] ENH: Optimize the presentation of error code dialog JIRA: STUDIO-7469 STUDIO-7477 STUDIO-7613 Change-Id: I6689dc375a51a1d690b82f9dbaa79d1555f7816f (cherry picked from commit 777c16fef0862587f3ec468652aabd70cff88dfe) --- src/slic3r/GUI/BindDialog.cpp | 2 +- src/slic3r/GUI/HMS.cpp | 18 +++++++++------- src/slic3r/GUI/HMS.hpp | 4 ++-- src/slic3r/GUI/Jobs/BindJob.cpp | 4 +++- src/slic3r/GUI/ReleaseNote.cpp | 32 +++++++++++++++++++++------- src/slic3r/GUI/ReleaseNote.hpp | 3 ++- src/slic3r/GUI/StatusPanel.cpp | 37 ++++++++++++++------------------- src/slic3r/GUI/StatusPanel.hpp | 3 ++- 8 files changed, 62 insertions(+), 41 deletions(-) diff --git a/src/slic3r/GUI/BindDialog.cpp b/src/slic3r/GUI/BindDialog.cpp index 1536da840ff..0b3e989e8b8 100644 --- a/src/slic3r/GUI/BindDialog.cpp +++ b/src/slic3r/GUI/BindDialog.cpp @@ -760,7 +760,7 @@ PingCodeBindDialog::~PingCodeBindDialog() { json j = json::parse(str.utf8_string()); if (j.contains("err_code")) { int error_code = j["err_code"].get(); - extra = wxGetApp().get_hms_query()->query_print_error_msg(error_code); + wxGetApp().get_hms_query()->query_print_error_msg(error_code, extra); } } catch (...) { diff --git a/src/slic3r/GUI/HMS.cpp b/src/slic3r/GUI/HMS.cpp index be5effc74c0..f98b9fbb8c7 100644 --- a/src/slic3r/GUI/HMS.cpp +++ b/src/slic3r/GUI/HMS.cpp @@ -243,14 +243,15 @@ wxString HMSQuery::_query_hms_msg(std::string long_error_code, std::string lang_ return wxEmptyString; } -wxString HMSQuery::_query_error_msg(std::string error_code, std::string lang_code) +bool HMSQuery::_query_error_msg(wxString &error_msg, std::string error_code, std::string lang_code) { if (m_hms_info_json.contains("device_error")) { if (m_hms_info_json["device_error"].contains(lang_code)) { for (auto item = m_hms_info_json["device_error"][lang_code].begin(); item != m_hms_info_json["device_error"][lang_code].end(); item++) { if (item->contains("ecode") && boost::to_upper_copy((*item)["ecode"].get()) == error_code) { if (item->contains("intro")) { - return wxString::FromUTF8((*item)["intro"].get()); + error_msg = wxString::FromUTF8((*item)["intro"].get()); + return true; } } } @@ -263,7 +264,8 @@ wxString HMSQuery::_query_error_msg(std::string error_code, std::string lang_cod for (auto item = lang.begin(); item != lang.end(); item++) { if (item->contains("ecode") && boost::to_upper_copy((*item)["ecode"].get()) == error_code) { if (item->contains("intro")) { - return wxString::FromUTF8((*item)["intro"].get()); + error_msg = wxString::FromUTF8((*item)["intro"].get()); + return true; } } } @@ -273,9 +275,11 @@ wxString HMSQuery::_query_error_msg(std::string error_code, std::string lang_cod } else { BOOST_LOG_TRIVIAL(info) << "device_error is not exists"; - return wxEmptyString; + error_msg = wxEmptyString; + return false; } - return wxEmptyString; + error_msg = wxEmptyString; + return false; } wxString HMSQuery::_query_error_url_action(std::string long_error_code, std::string dev_id, std::vector& button_action) @@ -305,12 +309,12 @@ wxString HMSQuery::_query_error_url_action(std::string long_error_code, std::str } -wxString HMSQuery::query_print_error_msg(int print_error) +bool HMSQuery::query_print_error_msg(int print_error, wxString &error_msg) { char buf[32]; ::sprintf(buf, "%08X", print_error); std::string lang_code = HMSQuery::hms_language_code(); - return _query_error_msg(std::string(buf), lang_code); + return _query_error_msg(error_msg, std::string(buf), lang_code); } wxString HMSQuery::query_print_error_url_action(int print_error, std::string dev_id, std::vector& button_action) diff --git a/src/slic3r/GUI/HMS.hpp b/src/slic3r/GUI/HMS.hpp index 01df19ed383..f2455f3c5f8 100644 --- a/src/slic3r/GUI/HMS.hpp +++ b/src/slic3r/GUI/HMS.hpp @@ -28,13 +28,13 @@ protected: int save_to_local(std::string lang, std::string hms_type,json save_json); std::string get_hms_file(std::string hms_type, std::string lang = std::string("en")); wxString _query_hms_msg(std::string long_error_code, std::string lang_code = std::string("en")); - wxString _query_error_msg(std::string long_error_code, std::string lang_code = std::string("en")); + bool _query_error_msg(wxString &error_msg, std::string long_error_code, std::string lang_code = std::string("en")); wxString _query_error_url_action(std::string long_error_code, std::string dev_id, std::vector& button_action); public: HMSQuery() {} int check_hms_info(); wxString query_hms_msg(std::string long_error_code); - wxString query_print_error_msg(int print_error); + bool query_print_error_msg(int print_error, wxString &error_msg); wxString query_print_error_url_action(int print_error, std::string dev_id, std::vector& button_action); static std::string hms_language_code(); static std::string build_query_params(std::string& lang); diff --git a/src/slic3r/GUI/Jobs/BindJob.cpp b/src/slic3r/GUI/Jobs/BindJob.cpp index 5809b8be7e2..fa4057214c4 100644 --- a/src/slic3r/GUI/Jobs/BindJob.cpp +++ b/src/slic3r/GUI/Jobs/BindJob.cpp @@ -105,7 +105,9 @@ void BindJob::process(Ctl &ctl) try { error_code = stoi(result_info); - result_info = wxGetApp().get_hms_query()->query_print_error_msg(error_code).ToStdString(); + wxString error_msg; + wxGetApp().get_hms_query()->query_print_error_msg(error_code, error_msg); + result_info = error_msg.ToStdString(); } catch (...) { ; diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index 877992a89a6..241c890cd30 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -896,7 +896,7 @@ PrintErrorDialog::PrintErrorDialog(wxWindow* parent, wxWindowID id, const wxStri bottom_sizer->Add(m_sizer_button, 0, wxEXPAND | wxRIGHT | wxLEFT, 0); - m_sizer_right->Add(bottom_sizer, 0, wxEXPAND | wxRIGHT | wxLEFT, FromDIP(15)); + m_sizer_right->Add(bottom_sizer, 0, wxEXPAND | wxRIGHT | wxLEFT, FromDIP(20)); m_sizer_right->Add(0, 0, 0, wxTOP, FromDIP(10)); m_sizer_main->Add(m_sizer_right, 0, wxBOTTOM | wxEXPAND, FromDIP(5)); @@ -952,20 +952,34 @@ void PrintErrorDialog::on_webrequest_state(wxWebRequestEvent& evt) } } -void PrintErrorDialog::update_text_image(wxString text, wxString image_url) +void PrintErrorDialog::update_text_image(const wxString& text, const wxString& error_code, const wxString& image_url) { //if (!m_sizer_text_release_note) { // m_sizer_text_release_note = new wxBoxSizer(wxVERTICAL); //} wxBoxSizer* sizer_text_release_note = new wxBoxSizer(wxVERTICAL); - + wxString error_code_msg = error_code; + if (!error_code.IsEmpty()) { + wxDateTime now = wxDateTime::Now(); + wxString show_time = now.Format("%H%M%d"); + error_code_msg = wxString::Format("[%S %S]", error_code, show_time); + } + if (!m_staticText_release_note) { m_staticText_release_note = new Label(m_vebview_release_note, text, LB_AUTO_WRAP); sizer_text_release_note->Add(m_error_prompt_pic_static, 0, wxALIGN_CENTER, FromDIP(5)); + sizer_text_release_note->AddSpacer(10); sizer_text_release_note->Add(m_staticText_release_note, 0, wxALIGN_CENTER , FromDIP(5)); - m_vebview_release_note->SetSizer(sizer_text_release_note); } + if (!m_staticText_error_code) { + m_staticText_error_code = new Label(m_vebview_release_note, error_code_msg, LB_AUTO_WRAP); + sizer_text_release_note->AddSpacer(5); + sizer_text_release_note->Add(m_staticText_error_code, 0, wxALIGN_CENTER, FromDIP(5)); + } + + m_vebview_release_note->SetSizer(sizer_text_release_note); + if (!image_url.empty()) { web_request = wxWebSession::GetDefault().CreateRequest(this, image_url); BOOST_LOG_TRIVIAL(trace) << "monitor: create new webrequest, state = " << web_request.GetState() << ", url = " << image_url; @@ -982,6 +996,9 @@ void PrintErrorDialog::update_text_image(wxString text, wxString image_url) m_staticText_release_note->SetMaxSize(wxSize(FromDIP(300), -1)); m_staticText_release_note->SetMinSize(wxSize(FromDIP(300), -1)); m_staticText_release_note->SetLabelText(text); + m_staticText_error_code->SetMaxSize(wxSize(FromDIP(300), -1)); + m_staticText_error_code->SetMinSize(wxSize(FromDIP(300), -1)); + m_staticText_error_code->SetLabelText(error_code_msg); m_vebview_release_note->Layout(); auto text_size = m_staticText_release_note->GetBestSize(); @@ -1048,7 +1065,8 @@ void PrintErrorDialog::update_title_style(wxString title, std::vector butto } -void PrintErrorDialog::init_button(PrintErrorButton style,wxString buton_text) { +void PrintErrorDialog::init_button(PrintErrorButton style,wxString buton_text) +{ Button* print_error_button = new Button(this, buton_text); print_error_button->SetBackgroundColor(btn_bg_white); print_error_button->SetBorderColor(wxColour(38, 46, 48)); @@ -1062,8 +1080,8 @@ void PrintErrorDialog::init_button(PrintErrorButton style,wxString buton_text) { } -void PrintErrorDialog::init_button_list() { - +void PrintErrorDialog::init_button_list() +{ init_button(RESUME_PRINTING, _L("Resume Printing")); m_button_list[RESUME_PRINTING]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) { post_event(wxCommandEvent(EVT_SECONDARY_CHECK_RESUME)); diff --git a/src/slic3r/GUI/ReleaseNote.hpp b/src/slic3r/GUI/ReleaseNote.hpp index 75c4c24edb5..7923c0fa281 100644 --- a/src/slic3r/GUI/ReleaseNote.hpp +++ b/src/slic3r/GUI/ReleaseNote.hpp @@ -189,7 +189,7 @@ public: const wxSize& size = wxDefaultSize, long style = wxCLOSE_BOX | wxCAPTION ); - void update_text_image(wxString text, wxString image_url); + void update_text_image(const wxString& text, const wxString& error_code,const wxString& image_url); void on_show(); void on_hide(); void update_title_style(wxString title, std::vector style, wxWindow* parent = nullptr); @@ -206,6 +206,7 @@ public: wxWebRequest web_request; wxStaticBitmap* m_error_prompt_pic_static; Label* m_staticText_release_note{ nullptr }; + Label* m_staticText_error_code{ nullptr }; wxBoxSizer* m_sizer_main; wxBoxSizer* m_sizer_button; wxScrolledWindow* m_vebview_release_note{ nullptr }; diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index 8a7a37c17a1..fa2b6b639f6 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -2176,9 +2176,9 @@ void StatusPanel::show_recenter_dialog() { obj->command_go_home(); } -void StatusPanel::show_error_message(MachineObject* obj, wxString msg, std::string print_error_str, wxString image_url, std::vector used_button) +void StatusPanel::show_error_message(MachineObject *obj, bool is_exist, wxString msg, std::string print_error_str, wxString image_url, std::vector used_button) { - if (msg.IsEmpty()) { + if (is_exist && msg.IsEmpty()) { error_info_reset(); } else { m_project_task_panel->show_error_msg(msg); @@ -2190,7 +2190,7 @@ void StatusPanel::show_error_message(MachineObject* obj, wxString msg, std::stri } m_print_error_dlg->update_title_style(_L("Error"), used_button, this); - m_print_error_dlg->update_text_image(msg, image_url); + m_print_error_dlg->update_text_image(msg, print_error_str, image_url); m_print_error_dlg->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this, obj](wxCommandEvent& e) { if (obj) { obj->command_clean_print_error(obj->subtask_id_, obj->print_error); @@ -2212,6 +2212,11 @@ void StatusPanel::show_error_message(MachineObject* obj, wxString msg, std::stri auto it_resume = std::find(message_containing_resume.begin(), message_containing_resume.end(), print_error_str); BOOST_LOG_TRIVIAL(info) << "show print error! error_msg = " << msg; + + wxDateTime now = wxDateTime::Now(); + wxString show_time = now.Format("%H%M%d"); + wxString error_code_msg = wxString::Format("%S\n[%S %S]", msg, print_error_str, show_time); + if (m_print_error_dlg_no_action == nullptr) { m_print_error_dlg_no_action = new SecondaryCheckDialog(this->GetParent(), wxID_ANY, _L("Warning"), SecondaryCheckDialog::ButtonStyle::ONLY_CONFIRM); } @@ -2231,7 +2236,7 @@ void StatusPanel::show_error_message(MachineObject* obj, wxString msg, std::stri else { m_print_error_dlg_no_action->update_title_style(_L("Warning"), SecondaryCheckDialog::ButtonStyle::ONLY_CONFIRM, this); } - m_print_error_dlg_no_action->update_text(msg); + m_print_error_dlg_no_action->update_text(error_code_msg); m_print_error_dlg_no_action->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this, obj](wxCommandEvent& e) { if (obj) { obj->command_clean_print_error(obj->subtask_id_, obj->print_error); @@ -2254,7 +2259,7 @@ void StatusPanel::update_error_message() { if (obj->print_error <= 0) { before_error_code = obj->print_error; - show_error_message(obj, wxEmptyString); + show_error_message(obj, true, wxEmptyString); return; } else if (before_error_code != obj->print_error && obj->print_error != skip_print_error) { before_error_code = obj->print_error; @@ -2263,27 +2268,17 @@ void StatusPanel::update_error_message() char buf[32]; ::sprintf(buf, "%08X", obj->print_error); std::string print_error_str = std::string(buf); - if (print_error_str.size() > 4) { - print_error_str.insert(4, " "); - } + if (print_error_str.size() > 4) { print_error_str.insert(4, " "); } - wxString error_msg = wxGetApp().get_hms_query()->query_print_error_msg(obj->print_error); + wxString error_msg; + bool is_errocode_exist = wxGetApp().get_hms_query()->query_print_error_msg(obj->print_error, error_msg); std::vector used_button; - wxString error_image_url = wxGetApp().get_hms_query()->query_print_error_url_action(obj->print_error,obj->dev_id, used_button); + wxString error_image_url = wxGetApp().get_hms_query()->query_print_error_url_action(obj->print_error, obj->dev_id, used_button); // special case - if (print_error_str == "0300 8003" || print_error_str == "0300 8002" || print_error_str == "0300 800A") + if (print_error_str == "0300 8003" || print_error_str == "0300 8002" || print_error_str == "0300 800A") { used_button.emplace_back(PrintErrorDialog::PrintErrorButton::JUMP_TO_LIVEVIEW); - if (!error_msg.IsEmpty()) { - wxDateTime now = wxDateTime::Now(); - wxString show_time = now.Format("%Y-%m-%d %H:%M:%S"); - - error_msg = wxString::Format("%s\n[%s %s]", - error_msg, - print_error_str, show_time); - show_error_message(obj, error_msg, print_error_str,error_image_url,used_button); - } else { - BOOST_LOG_TRIVIAL(info) << "show print error! error_msg is empty, print error = " << obj->print_error; } + show_error_message(obj, is_errocode_exist, error_msg, print_error_str, error_image_url, used_button); } } } diff --git a/src/slic3r/GUI/StatusPanel.hpp b/src/slic3r/GUI/StatusPanel.hpp index 517367d7f33..e34bf908aad 100644 --- a/src/slic3r/GUI/StatusPanel.hpp +++ b/src/slic3r/GUI/StatusPanel.hpp @@ -527,7 +527,8 @@ protected: void on_subtask_pause_resume(wxCommandEvent &event); void on_subtask_abort(wxCommandEvent &event); void on_print_error_clean(wxCommandEvent &event); - void show_error_message(MachineObject* obj, wxString msg, std::string print_error_str = "",wxString image_url="",std::vector used_button=std::vector()); + void show_error_message( + MachineObject *obj, bool is_exist, wxString msg, std::string print_error_str = "", wxString image_url = "", std::vector used_button = std::vector()); void error_info_reset(); void show_recenter_dialog(); From eb6cfbdf20f3947fb16c9cd70a516762500be075 Mon Sep 17 00:00:00 2001 From: tao wang Date: Tue, 10 Sep 2024 21:47:10 +0800 Subject: [PATCH 16/57] FIX:Fixed the issue of disconnection cause no respon jira:[STUDIO-8062] Change-Id: Ic369f6f6b293c0f616e6408651c6f40cec0de051 (cherry picked from commit c3bb86f26c399d19b00de321d490e0586a1e10f7) --- src/slic3r/GUI/ReleaseNote.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index 241c890cd30..51a67c90c0a 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -1557,7 +1557,7 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent) m_button_ok->Bind(wxEVT_LEFT_DOWN, &InputIpAddressDialog::on_ok, this); - auto m_button_cancel = new Button(this, _L("Close")); + /*auto m_button_cancel = new Button(this, _L("Close")); m_button_cancel->SetBackgroundColor(btn_bg_white); m_button_cancel->SetBorderColor(wxColour(38, 46, 48)); m_button_cancel->SetFont(Label::Body_12); @@ -1567,11 +1567,11 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent) m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) { on_cancel(); - }); + });*/ m_sizer_button->AddStretchSpacer(); m_sizer_button->Add(m_button_ok, 0, wxALL, FromDIP(5)); - m_sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5)); + //m_sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5)); m_sizer_button->Layout(); @@ -1704,7 +1704,7 @@ void InputIpAddressDialog::on_cancel() { if (m_thread) { m_thread->interrupt(); - m_thread->join(); + m_thread->detach(); delete m_thread; m_thread = nullptr; } @@ -1842,6 +1842,16 @@ void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_ else if (result == -3) { update_test_msg(_L("The device does not support using IP and Access Code for connection."), false); } + + m_button_ok->Enable(true); + + m_button_ok->Enable(true); + StateColor btn_bg_green(std::pair(wxColour(61, 203, 115), StateColor::Pressed), std::pair(wxColour(61, 203, 115), StateColor::Hovered), + std::pair(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal)); + m_button_ok->SetTextColor(StateColor::darkModeColorFor("#FFFFFE")); + m_button_ok->SetBackgroundColor(btn_bg_green); + m_button_ok->SetBorderColor(*wxWHITE); + Layout(); Fit(); return; @@ -1871,20 +1881,23 @@ void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_ } - closeCount = 3; + closeCount = 1; + update_test_msg(wxEmptyString, true); - update_test_msg(wxString::Format(_L("Printer binding successful. The dialog will close in %d seconds"), closeCount), true); + update_test_msg(wxString::Format(_L("Printer binding successful. The dialog will close later"), closeCount), true); + closeTimer->Start(1000); Layout(); Fit(); + Refresh(true); } void InputIpAddressDialog::OnTimer(wxTimerEvent& event) { if (closeCount > 0) { closeCount--; - update_test_msg(wxString::Format(_L("Printer binding successful. The dialog will close in %d seconds"), closeCount), true); - Refresh(); + //update_test_msg(wxString::Format(_L("Printer binding successful. The dialog will close in %d seconds"), closeCount), true); + //Refresh(); } else { closeTimer->Stop(); From 5f0b6b90757c90dc846e7eacf1fe307f99b1672b Mon Sep 17 00:00:00 2001 From: tao wang Date: Wed, 4 Sep 2024 19:51:46 +0800 Subject: [PATCH 17/57] ENH:fix directly connected text jira:[STUDIO-8031] Change-Id: I0e747e4a279ab97ed7cab2acc6efb14cbafc4685 (cherry picked from commit 00b65490dcf853c864cbce1abe3de22c162ba58d) --- src/slic3r/GUI/ReleaseNote.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index 51a67c90c0a..7a2d14fa50d 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -1858,6 +1858,7 @@ void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_ } if (detectData.bind_state == "occupied") { + update_test_msg(wxEmptyString, true); update_test_msg(_L("The printer has already been bound."), false); Layout(); Fit(); @@ -1865,6 +1866,7 @@ void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_ } if (detectData.connect_type == "cloud") { + update_test_msg(wxEmptyString, true); update_test_msg(_L("The printer mode is incorrect, please switch to LAN Only."), false); Layout(); Fit(); From f7bbb5efb6ded1146ed9ffe4c6f08ae51c82f9e0 Mon Sep 17 00:00:00 2001 From: gerrit Date: Wed, 18 Sep 2024 19:43:23 +0800 Subject: [PATCH 18/57] ci: update network module based on commit 4b3f1e5 Change-Id: Ifde48fc6f2d3f4d5bd6e348cc2a09deef83bd090 (cherry picked from commit 620b40c904aca8f7f40cb09f4633bbacfb62a869) --- src/slic3r/Utils/bambu_networking.hpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index 9523877c81d..b8e58a4c525 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -95,7 +95,7 @@ namespace BBL { #define BAMBU_NETWORK_LIBRARY "bambu_networking" #define BAMBU_NETWORK_AGENT_NAME "bambu_network_agent" -#define BAMBU_NETWORK_AGENT_VERSION "01.09.05.01" +#define BAMBU_NETWORK_AGENT_VERSION "01.09.07.01" //iot preset type strings #define IOT_PRINTER_TYPE_STRING "printer" @@ -172,17 +172,6 @@ enum ConnectStatus { ConnectStatusLost = 2, }; -struct detectResult { - std::string result_msg; - std::string command; - std::string dev_id; - std::string model_id; - std::string dev_name; - std::string version; - std::string bind_state; - std::string connect_type; -}; - /* print job*/ struct PrintParams { /* basic info */ From 0bcc1fe70a2f23b9e6cd195b1030d78ccf3dd569 Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Fri, 20 Sep 2024 09:26:01 +0800 Subject: [PATCH 19/57] ENH: networking: sync the header files to fix the compile issue JIRA: no-jira Change-Id: Ie1d454d4a9256e15a27b294af680a5ed49137f90 (cherry picked from commit 07e4aa213ac4a1b5bda865774a4e3d9e7f866170) --- src/slic3r/Utils/bambu_networking.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index b8e58a4c525..44005730cf4 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -172,6 +172,17 @@ enum ConnectStatus { ConnectStatusLost = 2, }; +struct detectResult { + std::string result_msg; + std::string command; + std::string dev_id; + std::string model_id; + std::string dev_name; + std::string version; + std::string bind_state; + std::string connect_type; +}; + /* print job*/ struct PrintParams { /* basic info */ From 4ba5960dd402d233419e4f093a3d71549374a855 Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Mon, 8 Apr 2024 09:48:36 +0800 Subject: [PATCH 20/57] ENH: liveview remote protocols with agora Change-Id: Id86aa4bfa5f5e09675a6fe627668c63d20c7d1bf Jira: none (cherry picked from commit 46eba0048b73f1741b4b7b57f788830c08a8d7f1) --- resources/printers/BL-P001.json | 4 ++-- resources/printers/BL-P002.json | 4 ++-- resources/printers/C11.json | 4 ++-- resources/printers/C12.json | 4 ++-- resources/printers/C13.json | 4 ++-- resources/printers/N1.json | 4 ++-- resources/printers/N2S.json | 4 ++-- src/slic3r/GUI/DeviceManager.cpp | 19 ++++++++++++++---- src/slic3r/GUI/DeviceManager.hpp | 20 ++++++++++++++++--- src/slic3r/GUI/GUI_App.cpp | 8 +++++--- src/slic3r/GUI/MediaFilePanel.cpp | 24 +++++++++++----------- src/slic3r/GUI/MediaFilePanel.h | 4 ++-- src/slic3r/GUI/MediaPlayCtrl.cpp | 33 +++++++++++++++++-------------- src/slic3r/GUI/MediaPlayCtrl.h | 4 ++-- src/slic3r/Utils/NetworkAgent.hpp | 1 + 15 files changed, 87 insertions(+), 54 deletions(-) diff --git a/resources/printers/BL-P001.json b/resources/printers/BL-P001.json index fbdea5d750f..0004806aaac 100644 --- a/resources/printers/BL-P001.json +++ b/resources/printers/BL-P001.json @@ -6,10 +6,10 @@ "resolution_supported": [ "720p", "1080p" ], "virtual_camera": "enabled", "liveview": { - "remote": "enabled" + "remote": "tutk" }, "file": { - "remote": "enabled", + "remote": "tutk", "model_download": "enabled" } }, diff --git a/resources/printers/BL-P002.json b/resources/printers/BL-P002.json index 286e552716f..3c2e7ed049b 100644 --- a/resources/printers/BL-P002.json +++ b/resources/printers/BL-P002.json @@ -6,10 +6,10 @@ "resolution_supported": [ "720p", "1080p" ], "virtual_camera": "enabled", "liveview": { - "remote": "enabled" + "remote": "tutk" }, "file": { - "remote": "enabled", + "remote": "tutk", "model_download": "enabled" } }, diff --git a/resources/printers/C11.json b/resources/printers/C11.json index 5fb53b3f0f6..a2cbbb078a5 100644 --- a/resources/printers/C11.json +++ b/resources/printers/C11.json @@ -58,7 +58,7 @@ "print": { "ipcam": { "liveview": { - "remote": "enabled" + "remote": "tutk" } } } @@ -79,7 +79,7 @@ "print": { "ipcam": { "file": { - "remote": "enabled" + "remote": "tutk" } }, "support_user_preset":true diff --git a/resources/printers/C12.json b/resources/printers/C12.json index d3a6c6d995a..5cc12a1a66f 100644 --- a/resources/printers/C12.json +++ b/resources/printers/C12.json @@ -60,7 +60,7 @@ "print": { "ipcam": { "liveview": { - "remote": "enabled" + "remote": "tutk" } }, "support_mqtt_alive":true, @@ -71,7 +71,7 @@ "print": { "ipcam": { "file": { - "remote": "enabled" + "remote": "tutk" } }, "support_user_preset":true diff --git a/resources/printers/C13.json b/resources/printers/C13.json index c8bce2ad6a5..44c4ecda299 100644 --- a/resources/printers/C13.json +++ b/resources/printers/C13.json @@ -6,10 +6,10 @@ "resolution_supported": [ "720p", "1080p" ], "virtual_camera": "enabled", "liveview": { - "remote": "enabled" + "remote": "tutk" }, "file": { - "remote": "enabled", + "remote": "tutk", "model_download": "enabled" } }, diff --git a/resources/printers/N1.json b/resources/printers/N1.json index 8bcd035a5ef..ac161ed7bed 100644 --- a/resources/printers/N1.json +++ b/resources/printers/N1.json @@ -6,7 +6,7 @@ "resolution_supported": [ "720p" ], "liveview": { "local": "local", - "remote": "enabled" + "remote": "tutk" } }, "support_motor_noise_cali":true, @@ -53,7 +53,7 @@ "print": { "ipcam": { "file": { - "remote": "enabled" + "remote": "tutk" } }, "support_user_preset":true diff --git a/resources/printers/N2S.json b/resources/printers/N2S.json index 2857bb17ebe..a87b08d08b9 100644 --- a/resources/printers/N2S.json +++ b/resources/printers/N2S.json @@ -6,7 +6,7 @@ "resolution_supported": [ "720p" ], "liveview": { "local": "local", - "remote": "enabled" + "remote": "tutk" } }, "support_motor_noise_cali":true, @@ -53,7 +53,7 @@ "print": { "ipcam": { "file": { - "remote": "enabled" + "remote": "tutk" } } } diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 91b3768776c..e67da8e1711 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -1429,6 +1429,10 @@ void MachineObject::parse_status(int flag) } sdcard_state = MachineObject::SdcardState((flag >> 8) & 0x11); + + is_support_agora = ((flag >> 30) & 0x1) != 0; + if (is_support_agora) + is_support_tunnel_mqtt = false; } PrintingSpeedLevel MachineObject::_parse_printing_speed_lvl(int lvl) @@ -2900,7 +2904,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } if (!key_field_only) { - if (!DeviceManager::EnableMultiMachine) { + if (!DeviceManager::EnableMultiMachine && !is_support_agora) { if (jj.contains("support_tunnel_mqtt")) { if (jj["support_tunnel_mqtt"].is_boolean()) { is_support_tunnel_mqtt = jj["support_tunnel_mqtt"].get(); @@ -3698,11 +3702,18 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) if (ipcam.contains("liveview")) { char const *local_protos[] = {"none", "disabled", "local", "rtsps", "rtsp"}; liveview_local = enum_index_of(ipcam["liveview"].value("local", "none").c_str(), local_protos, 5, LiveviewLocal::LVL_None); - liveview_remote = ipcam["liveview"].value("remote", "disabled") == "enabled"; + char const *remote_protos[] = {"none", "tutk", "agora", "tutk_agaro"}; + liveview_remote = enum_index_of(ipcam["liveview"].value("remote", "none").c_str(), remote_protos, 4, LiveviewRemote::LVR_None); + if (is_support_agora) + liveview_remote = liveview_remote == LVR_None ? LVR_Agora : liveview_remote == LVR_Tutk ? LVR_TutkAgora : liveview_remote; } if (ipcam.contains("file")) { - file_local = ipcam["file"].value("local", "disabled") == "enabled"; - file_remote = ipcam["file"].value("remote", "disabled") == "enabled"; + char const *local_protos[] = {"none", "local"}; + file_local = enum_index_of(ipcam["file"].value("local", "none").c_str(), local_protos, 2, FileLocal::FL_None); + char const *remote_protos[] = {"none", "tutk", "agora", "tutk_agaro"}; + file_remote = enum_index_of(ipcam["file"].value("remote", "none").c_str(), remote_protos, 4, FileRemote::FR_None); + if (is_support_agora) + file_remote = file_remote == FR_None ? FR_Agora : file_remote == FR_Tutk ? FR_TutkAgora : file_remote; file_model_download = ipcam["file"].value("model_download", "disabled") == "enabled"; } virtual_camera = ipcam.value("virtual_camera", "disabled") == "enabled"; diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 7c907257086..3a0085966da 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -708,9 +708,22 @@ public: LVL_Rtsps, LVL_Rtsp } liveview_local{ LVL_None }; - bool liveview_remote{false}; - bool file_local{false}; - bool file_remote{false}; + enum LiveviewRemote { + LVR_None, + LVR_Tutk, + LVR_Agora, + LVR_TutkAgora + } liveview_remote{ LVR_None }; + enum FileLocal { + FL_None, + FL_Local + } file_local{ FL_None }; + enum FileRemote { + FR_None, + FR_Tutk, + FR_Agora, + FR_TutkAgora + } file_remote{ FR_None }; bool file_model_download{false}; bool virtual_camera{false}; @@ -763,6 +776,7 @@ public: bool is_support_nozzle_blob_detection{false}; bool is_support_air_print_detection{false}; bool is_support_filament_setting_inprinting{false}; + bool is_support_agora{false}; int nozzle_max_temperature = -1; int bed_temperature_limit = -1; diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 2cbbd216832..26a9ccee135 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1024,9 +1024,11 @@ void GUI_App::post_init() for (auto& it : boost::filesystem::directory_iterator(log_folder)) { auto temp_path = it.path(); try { - std::time_t lw_t = boost::filesystem::last_write_time(temp_path) ; - files_vec.push_back({ lw_t, temp_path.filename().string() }); - } catch (const std::exception &) { + if (it.status().type() == boost::filesystem::regular_file) { + std::time_t lw_t = boost::filesystem::last_write_time(temp_path) ; + files_vec.push_back({ lw_t, temp_path.filename().string() }); + } + } catch (const std::exception &ex) { } } std::sort(files_vec.begin(), files_vec.end(), []( diff --git a/src/slic3r/GUI/MediaFilePanel.cpp b/src/slic3r/GUI/MediaFilePanel.cpp index 672ea696b6b..de9b3951c9e 100644 --- a/src/slic3r/GUI/MediaFilePanel.cpp +++ b/src/slic3r/GUI/MediaFilePanel.cpp @@ -219,10 +219,10 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj) m_lan_ip = obj->dev_ip; m_lan_passwd = obj->get_access_code(); m_dev_ver = obj->get_ota_version(); - m_device_busy = obj->is_camera_busy_off(); + m_device_busy = obj->is_camera_busy_off(); m_sdcard_exist = obj->has_sdcard(); - m_local_support = obj->file_local; - m_remote_support = obj->file_remote; + m_local_proto = obj->file_local; + m_remote_proto = obj->file_remote; m_model_download_support = obj->file_model_download; } else { m_lan_mode = false; @@ -231,13 +231,13 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj) m_dev_ver.clear(); m_sdcard_exist = false; m_device_busy = false; - m_local_support = false; - m_remote_support = false; + m_local_proto = 0; + m_remote_proto = 0; m_model_download_support = false; } Enable(obj && obj->is_connected() && obj->m_push_count > 0); if (machine == m_machine) { - if ((m_waiting_enable && IsEnabled()) || (m_waiting_support && (m_local_support || m_remote_support))) { + if ((m_waiting_enable && IsEnabled()) || (m_waiting_support && (m_local_proto || m_remote_proto))) { auto fs = m_image_grid->GetFileSystem(); if (fs) fs->Retry(); } @@ -433,7 +433,7 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr wfs) return; } m_waiting_enable = false; - if (!m_local_support && !m_remote_support) { + if (!m_local_proto && !m_remote_proto) { m_waiting_support = true; m_image_grid->SetStatus(m_bmp_failed, _L("Browsing file in SD card is not supported in current firmware. Please update the printer firmware.")); fs->SetUrl("0"); @@ -452,7 +452,7 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr wfs) m_waiting_support = false; NetworkAgent *agent = wxGetApp().getAgent(); std::string agent_version = agent ? agent->get_version() : ""; - if ((m_lan_mode || !m_remote_support) && m_local_support && !m_lan_ip.empty()) { + if ((m_lan_mode || !m_remote_proto) && m_local_proto && !m_lan_ip.empty()) { std::string url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd; url += "&device=" + m_machine; url += "&net_ver=" + agent_version; @@ -462,7 +462,7 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr wfs) fs->SetUrl(url); return; } - if (!m_remote_support && m_local_support) { // not support tutk + if (!m_remote_proto && m_local_proto) { // not support tutk m_image_grid->SetStatus(m_bmp_failed, _L("Please enter the IP of printer to connect.")); fs->SetUrl("0"); fs.reset(); @@ -478,12 +478,14 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr wfs) return; } if (agent) { - agent->get_camera_url(m_machine, - [this, wfs, m = m_machine, v = agent->get_version(), dv = m_dev_ver](std::string url) { + std::string protocols[] = {"", "\"tutk\"", "\"agora\"", "\"tutk\",\"agora\""}; + agent->get_camera_url(m_machine + "|" + m_dev_ver + "|" + protocols[m_remote_proto], + [this, wfs, m = m_machine, v = agent->get_version(), dv = m_dev_ver, agent](std::string url) { if (boost::algorithm::starts_with(url, "bambu:///")) { url += "&device=" + m; url += "&net_ver=" + v; url += "&dev_ver=" + dv; + url += "&network_agent=" + boost::lexical_cast(agent->get_network_agent()); url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid"); url += "&cli_ver=" + std::string(SLIC3R_VERSION); } diff --git a/src/slic3r/GUI/MediaFilePanel.h b/src/slic3r/GUI/MediaFilePanel.h index 0b64cdb5d60..c22639304be 100644 --- a/src/slic3r/GUI/MediaFilePanel.h +++ b/src/slic3r/GUI/MediaFilePanel.h @@ -83,8 +83,8 @@ private: std::string m_dev_ver; bool m_lan_mode = false; bool m_sdcard_exist = false; - bool m_local_support = false; - bool m_remote_support = false; + int m_local_proto = false; + int m_remote_proto = false; bool m_model_download_support = false; bool m_device_busy = false; bool m_waiting_enable = false; diff --git a/src/slic3r/GUI/MediaPlayCtrl.cpp b/src/slic3r/GUI/MediaPlayCtrl.cpp index 74db88d3aa0..7fa983c53b3 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.cpp +++ b/src/slic3r/GUI/MediaPlayCtrl.cpp @@ -150,7 +150,7 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj) m_dev_ver = obj->get_ota_version(); m_lan_mode = obj->is_lan_mode_printer(); m_lan_proto = obj->liveview_local; - m_remote_support = obj->liveview_remote; + m_remote_proto = obj->liveview_remote; m_lan_ip = obj->dev_ip; m_lan_passwd = obj->get_access_code(); m_device_busy = obj->is_camera_busy_off(); @@ -163,7 +163,7 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj) m_lan_passwd.clear(); m_dev_ver.clear(); m_tutk_state.clear(); - m_remote_support = true; + m_remote_proto = 0; m_device_busy = false; } Enable(obj && obj->is_connected() && obj->m_push_count > 0); @@ -261,8 +261,8 @@ void MediaPlayCtrl::Play() NetworkAgent *agent = wxGetApp().getAgent(); std::string agent_version = agent ? agent->get_version() : ""; - if (m_lan_proto > MachineObject::LVL_Disable && (m_lan_mode || !m_remote_support) && !m_disable_lan && !m_lan_ip.empty()) { - m_disable_lan = m_remote_support && !m_lan_mode; // try remote next time + if (m_lan_proto > MachineObject::LVL_Disable && (m_lan_mode || !m_remote_proto) && !m_disable_lan && !m_lan_ip.empty()) { + m_disable_lan = m_remote_proto && !m_lan_mode; // try remote next time std::string url; if (m_lan_proto == MachineObject::LVL_Local) url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd; @@ -285,12 +285,12 @@ void MediaPlayCtrl::Play() // m_lan_mode && m_lan_proto > LVL_Disable (use local tunnel) // m_lan_mode && m_lan_proto == LVL_Disable (*) // m_lan_mode && m_lan_proto == LVL_None (x) - // !m_lan_mode && m_remote_support (go on) - // !m_lan_mode && !m_remote_support && m_lan_proto > LVL_None (use local tunnel) - // !m_lan_mode && !m_remote_support && m_lan_proto == LVL_Disable (*) - // !m_lan_mode && !m_remote_support && m_lan_proto == LVL_None (x) + // !m_lan_mode && m_remote_proto (go on) + // !m_lan_mode && !m_remote_proto && m_lan_proto > LVL_None (use local tunnel) + // !m_lan_mode && !m_remote_proto && m_lan_proto == LVL_Disable (*) + // !m_lan_mode && !m_remote_proto && m_lan_proto == LVL_None (x) - if (m_lan_proto <= MachineObject::LVL_Disable && (m_lan_mode || !m_remote_support)) { + if (m_lan_proto <= MachineObject::LVL_Disable && (m_lan_mode || !m_remote_proto)) { Stop(m_lan_proto == MachineObject::LVL_None ? _L("Problem occurred. Please update the printer firmware and try again.") : _L("LAN Only Liveview is off. Please turn on the liveview on printer screen.")); @@ -312,12 +312,14 @@ void MediaPlayCtrl::Play() SetStatus(_L("Initializing...")); if (agent) { - agent->get_camera_url(m_machine, - [this, m = m_machine, v = agent_version, dv = m_dev_ver](std::string url) { + std::string protocols[] = {"", "\"tutk\"", "\"agora\"", "\"tutk\",\"agora\""}; + agent->get_camera_url(m_machine + "|" + m_dev_ver + "|" + protocols[m_remote_proto], + [this, m = m_machine, v = agent_version, dv = m_dev_ver, agent](std::string url) { if (boost::algorithm::starts_with(url, "bambu:///")) { url += "&device=" + into_u8(m); url += "&net_ver=" + v; url += "&dev_ver=" + dv; + url += "&network_agent=" + boost::lexical_cast(agent->get_network_agent()); url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid"); url += "&cli_ver=" + std::string(SLIC3R_VERSION); } @@ -331,7 +333,7 @@ void MediaPlayCtrl::Play() if (m_last_state == MEDIASTATE_INITIALIZING) { if (url.empty() || !boost::algorithm::starts_with(url, "bambu:///")) { m_failed_code = 3; - Stop(_L("Connection Failed. Please check the network and try again")); + Stop(_L("Connection Failed. Please check the network and try again"), from_u8(url)); } else { m_url = url; load(); @@ -346,7 +348,7 @@ void MediaPlayCtrl::Play() void start_ping_test(); -void MediaPlayCtrl::Stop(wxString const &msg) +void MediaPlayCtrl::Stop(wxString const &msg, wxString const &msg2) { int last_state = m_last_state; @@ -493,7 +495,7 @@ void MediaPlayCtrl::ToggleStream() wxGetApp().app_config->set("not_show_vcamera_stop_prev", "1"); if (res == wxID_CANCEL) return; } - if (m_lan_proto > MachineObject::LVL_Disable && (m_lan_mode || !m_remote_support) && !m_disable_lan && !m_lan_ip.empty()) { + if (m_lan_proto > MachineObject::LVL_Disable && (m_lan_mode || !m_remote_proto) && !m_disable_lan && !m_lan_ip.empty()) { std::string url; if (m_lan_proto == MachineObject::LVL_Local) url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd; @@ -514,11 +516,12 @@ void MediaPlayCtrl::ToggleStream() } NetworkAgent *agent = wxGetApp().getAgent(); if (!agent) return; - agent->get_camera_url(m_machine, [this, m = m_machine, v = agent->get_version(), dv = m_dev_ver](std::string url) { + agent->get_camera_url(m_machine, [this, m = m_machine, v = agent->get_version(), dv = m_dev_ver, agent](std::string url) { if (boost::algorithm::starts_with(url, "bambu:///")) { url += "&device=" + m; url += "&net_ver=" + v; url += "&dev_ver=" + dv; + url += "&network_agent=" + boost::lexical_cast(agent->get_network_agent()); url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid"); url += "&cli_ver=" + std::string(SLIC3R_VERSION); } diff --git a/src/slic3r/GUI/MediaPlayCtrl.h b/src/slic3r/GUI/MediaPlayCtrl.h index f6e8d0dbeca..d8c29b729f8 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.h +++ b/src/slic3r/GUI/MediaPlayCtrl.h @@ -49,7 +49,7 @@ protected: void Play(); - void Stop(wxString const &msg = {}); + void Stop(wxString const &msg = {}, wxString const &msg2 = {}); void TogglePlay(); @@ -83,7 +83,7 @@ private: std::string m_tutk_state; bool m_camera_exists = false; bool m_lan_mode = false; - bool m_remote_support = false; + int m_remote_proto = 0; bool m_device_busy = false; bool m_disable_lan = false; wxString m_url; diff --git a/src/slic3r/Utils/NetworkAgent.hpp b/src/slic3r/Utils/NetworkAgent.hpp index e0a51703ebd..b020a116d0f 100644 --- a/src/slic3r/Utils/NetworkAgent.hpp +++ b/src/slic3r/Utils/NetworkAgent.hpp @@ -226,6 +226,7 @@ public: int get_mw_user_preference(std::function callback); int get_mw_user_4ulist(int seed, int limit, std::function callback); + void *get_network_agent() { return network_agent; } private: bool enable_track = false; From e730b14640c3874c43240e066f99fc8990f58c15 Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Tue, 4 Jun 2024 09:13:47 +0800 Subject: [PATCH 21/57] ENH: refresh_agora_url callback Change-Id: I0d9a659d8bc9d004798409e1e76003854d4e5af6 (cherry picked from commit 76ef39c588908ad0dddef257812c333704fef84b) --- src/slic3r/GUI/MediaFilePanel.cpp | 5 +++-- src/slic3r/GUI/MediaPlayCtrl.cpp | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/MediaFilePanel.cpp b/src/slic3r/GUI/MediaFilePanel.cpp index de9b3951c9e..556a3dfb40d 100644 --- a/src/slic3r/GUI/MediaFilePanel.cpp +++ b/src/slic3r/GUI/MediaFilePanel.cpp @@ -421,6 +421,7 @@ void MediaFilePanel::modeChanged(wxCommandEvent& e1) } extern wxString hide_passwd(wxString url, std::vector const &passwords); +extern void refresh_agora_url(char const *device, char const *dev_ver, char const *channel, void *context, void (*callback)(void *context, char const *url)); void MediaFilePanel::fetchUrl(boost::weak_ptr wfs) { @@ -480,12 +481,12 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr wfs) if (agent) { std::string protocols[] = {"", "\"tutk\"", "\"agora\"", "\"tutk\",\"agora\""}; agent->get_camera_url(m_machine + "|" + m_dev_ver + "|" + protocols[m_remote_proto], - [this, wfs, m = m_machine, v = agent->get_version(), dv = m_dev_ver, agent](std::string url) { + [this, wfs, m = m_machine, v = agent->get_version(), dv = m_dev_ver](std::string url) { if (boost::algorithm::starts_with(url, "bambu:///")) { url += "&device=" + m; url += "&net_ver=" + v; url += "&dev_ver=" + dv; - url += "&network_agent=" + boost::lexical_cast(agent->get_network_agent()); + url += "&refresh_url=" + boost::lexical_cast(refresh_agora_url); url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid"); url += "&cli_ver=" + std::string(SLIC3R_VERSION); } diff --git a/src/slic3r/GUI/MediaPlayCtrl.cpp b/src/slic3r/GUI/MediaPlayCtrl.cpp index 7fa983c53b3..867d0be303c 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.cpp +++ b/src/slic3r/GUI/MediaPlayCtrl.cpp @@ -231,6 +231,18 @@ wxString hide_passwd(wxString url, std::vector const &passwords) return url; } +void refresh_agora_url(char const* device, char const* dev_ver, char const* channel, void* context, void (*callback)(void* context, char const* url)) +{ + std::string device2 =device; + device2 += "|"; + device2 += dev_ver; + device2 += "|\"agora\"|"; + device2 += channel; + wxGetApp().getAgent()->get_camera_url(device2, [context, callback](std::string url) { + callback(context, url.c_str()); + }); +} + void MediaPlayCtrl::Play() { if (!m_next_retry.IsValid() || wxDateTime::Now() < m_next_retry) @@ -314,12 +326,12 @@ void MediaPlayCtrl::Play() if (agent) { std::string protocols[] = {"", "\"tutk\"", "\"agora\"", "\"tutk\",\"agora\""}; agent->get_camera_url(m_machine + "|" + m_dev_ver + "|" + protocols[m_remote_proto], - [this, m = m_machine, v = agent_version, dv = m_dev_ver, agent](std::string url) { + [this, m = m_machine, v = agent_version, dv = m_dev_ver](std::string url) { if (boost::algorithm::starts_with(url, "bambu:///")) { url += "&device=" + into_u8(m); url += "&net_ver=" + v; url += "&dev_ver=" + dv; - url += "&network_agent=" + boost::lexical_cast(agent->get_network_agent()); + url += "&refresh_url=" + boost::lexical_cast(refresh_agora_url); url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid"); url += "&cli_ver=" + std::string(SLIC3R_VERSION); } @@ -516,12 +528,12 @@ void MediaPlayCtrl::ToggleStream() } NetworkAgent *agent = wxGetApp().getAgent(); if (!agent) return; - agent->get_camera_url(m_machine, [this, m = m_machine, v = agent->get_version(), dv = m_dev_ver, agent](std::string url) { + agent->get_camera_url(m_machine, [this, m = m_machine, v = agent->get_version(), dv = m_dev_ver](std::string url) { if (boost::algorithm::starts_with(url, "bambu:///")) { url += "&device=" + m; url += "&net_ver=" + v; url += "&dev_ver=" + dv; - url += "&network_agent=" + boost::lexical_cast(agent->get_network_agent()); + url += "&refresh_url=" + boost::lexical_cast(refresh_agora_url); url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid"); url += "&cli_ver=" + std::string(SLIC3R_VERSION); } From 2151ec4d90988abaa496d2436af24dfe67524878 Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Sat, 6 Jul 2024 20:27:18 +0800 Subject: [PATCH 22/57] ENH: network: load dlls from current directory if failed JIRA: no-jira Change-Id: I86efafe3aefac85d56879a68f864a52c0e62fca5 (cherry picked from commit cdf0859e78e8d62c2de13f2f9bf56a216a79a12a) (cherry picked from commit b4cc20ac14298bac2e928d1d598e9d75ca953ba3) --- src/slic3r/Utils/NetworkAgent.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/slic3r/Utils/NetworkAgent.cpp b/src/slic3r/Utils/NetworkAgent.cpp index 474132983d2..27e51ffccd0 100644 --- a/src/slic3r/Utils/NetworkAgent.cpp +++ b/src/slic3r/Utils/NetworkAgent.cpp @@ -171,6 +171,13 @@ int NetworkAgent::initialize_network_module(bool using_backup) ::MultiByteToWideChar(CP_UTF8, NULL, library.c_str(), strlen(library.c_str()) + 1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0])); netwoking_module = LoadLibrary(lib_wstr); }*/ + if (!netwoking_module) { + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", try load library directly from current directory"); + library = std::string(BAMBU_NETWORK_LIBRARY) + ".dll"; + memset(lib_wstr, 0, sizeof(lib_wstr)); + ::MultiByteToWideChar(CP_UTF8, NULL, library.c_str(), strlen(library.c_str())+1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0])); + netwoking_module = LoadLibrary(lib_wstr); + } #else #if defined(__WXMAC__) library = plugin_folder.string() + "/" + std::string("lib") + std::string(BAMBU_NETWORK_LIBRARY) + ".dylib"; @@ -300,7 +307,7 @@ int NetworkAgent::initialize_network_module(bool using_backup) get_model_mall_rating_result_ptr = reinterpret_cast(get_network_function("bambu_network_get_model_mall_rating")); get_mw_user_preference_ptr = reinterpret_cast(get_network_function("bambu_network_get_mw_user_preference")); - get_mw_user_4ulist_ptr = reinterpret_cast(get_network_function("bambu_network_get_mw_user_4ulist")); + get_mw_user_4ulist_ptr = reinterpret_cast(get_network_function("bambu_network_get_mw_user_4ulist")); return 0; } @@ -419,7 +426,7 @@ int NetworkAgent::unload_network_module() put_rating_picture_oss_ptr = nullptr; put_model_mall_rating_url_ptr = nullptr; get_model_mall_rating_result_ptr = nullptr; - + get_mw_user_preference_ptr = nullptr; get_mw_user_4ulist_ptr = nullptr; @@ -448,12 +455,13 @@ void* NetworkAgent::get_bambu_source_entry() memset(lib_wstr, 0, sizeof(lib_wstr)); ::MultiByteToWideChar(CP_UTF8, NULL, library.c_str(), strlen(library.c_str())+1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0])); source_module = LoadLibrary(lib_wstr); - /*if (!source_module) { + if (!source_module) { + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", try load BambuSource directly from current directory"); library = std::string(BAMBU_SOURCE_LIBRARY) + ".dll"; memset(lib_wstr, 0, sizeof(lib_wstr)); ::MultiByteToWideChar(CP_UTF8, NULL, library.c_str(), strlen(library.c_str()) + 1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0])); source_module = LoadLibrary(lib_wstr); - }*/ + } #else #if defined(__WXMAC__) library = plugin_folder.string() + "/" + std::string("lib") + std::string(BAMBU_SOURCE_LIBRARY) + ".dylib"; From 646945b58dfa3c6243773f78f9389e230c40e3c8 Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Mon, 19 Aug 2024 15:24:10 +0800 Subject: [PATCH 23/57] ENH: network: refine current path logic only use the same path as binary for current path JIRA: STUDIO-7875 Change-Id: I5523e3b7e20b0f24de50c8d295f54b984693165a (cherry picked from commit 62b98f783dcee8900da034b384167817155a3e59) --- src/slic3r/Utils/NetworkAgent.cpp | 46 +++++++++++++++++++++++++++---- src/slic3r/Utils/NetworkAgent.hpp | 1 + 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/slic3r/Utils/NetworkAgent.cpp b/src/slic3r/Utils/NetworkAgent.cpp index 27e51ffccd0..904471848db 100644 --- a/src/slic3r/Utils/NetworkAgent.cpp +++ b/src/slic3r/Utils/NetworkAgent.cpp @@ -146,6 +146,31 @@ NetworkAgent::~NetworkAgent() BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", this %1%, network_agent=%2%, destroy_agent_ptr=%3%, ret %4%")%this %network_agent %destroy_agent_ptr %ret; } +std::string NetworkAgent::get_libpath_in_current_directory(std::string library_name) +{ + std::string lib_path; +#if defined(_MSC_VER) || defined(_WIN32) + wchar_t file_name[512]; + DWORD ret = GetModuleFileNameW(NULL, file_name, 512); + if (!ret) { + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", GetModuleFileNameW return error, can not Load Library for %1%") % library_name; + return lib_path; + } + int size_needed = ::WideCharToMultiByte(0, 0, file_name, wcslen(file_name), nullptr, 0, nullptr, nullptr); + std::string file_name_string(size_needed, 0); + ::WideCharToMultiByte(0, 0, file_name, wcslen(file_name), file_name_string.data(), size_needed, nullptr, nullptr); + + std::size_t found = file_name_string.find("bambu-studio.exe"); + if (found == (file_name_string.size() - 16)) { + lib_path = library_name + ".dll"; + lib_path = file_name_string.replace(found, 16, lib_path); + } +#else +#endif + return lib_path; +} + + int NetworkAgent::initialize_network_module(bool using_backup) { //int ret = -1; @@ -160,7 +185,7 @@ int NetworkAgent::initialize_network_module(bool using_backup) //first load the library #if defined(_MSC_VER) || defined(_WIN32) - library = plugin_folder.string() + "/" + std::string(BAMBU_NETWORK_LIBRARY) + ".dll"; + library = plugin_folder.string() + "\\" + std::string(BAMBU_NETWORK_LIBRARY) + ".dll"; wchar_t lib_wstr[128]; memset(lib_wstr, 0, sizeof(lib_wstr)); ::MultiByteToWideChar(CP_UTF8, NULL, library.c_str(), strlen(library.c_str())+1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0])); @@ -173,9 +198,15 @@ int NetworkAgent::initialize_network_module(bool using_backup) }*/ if (!netwoking_module) { BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", try load library directly from current directory"); - library = std::string(BAMBU_NETWORK_LIBRARY) + ".dll"; + + std::string library_path = get_libpath_in_current_directory(std::string(BAMBU_NETWORK_LIBRARY)); + if (library_path.empty()) { + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", can not get path in current directory for %1%") % BAMBU_NETWORK_LIBRARY; + return -1; + } + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", current path %1%")%library_path; memset(lib_wstr, 0, sizeof(lib_wstr)); - ::MultiByteToWideChar(CP_UTF8, NULL, library.c_str(), strlen(library.c_str())+1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0])); + ::MultiByteToWideChar(CP_UTF8, NULL, library_path.c_str(), strlen(library_path.c_str())+1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0])); netwoking_module = LoadLibrary(lib_wstr); } #else @@ -457,9 +488,14 @@ void* NetworkAgent::get_bambu_source_entry() source_module = LoadLibrary(lib_wstr); if (!source_module) { BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", try load BambuSource directly from current directory"); - library = std::string(BAMBU_SOURCE_LIBRARY) + ".dll"; + std::string library_path = get_libpath_in_current_directory(std::string(BAMBU_SOURCE_LIBRARY)); + if (library_path.empty()) { + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", can not get path in current directory for %1%") % BAMBU_SOURCE_LIBRARY; + return source_module; + } + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", current path %1%")%library_path; memset(lib_wstr, 0, sizeof(lib_wstr)); - ::MultiByteToWideChar(CP_UTF8, NULL, library.c_str(), strlen(library.c_str()) + 1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0])); + ::MultiByteToWideChar(CP_UTF8, NULL, library_path.c_str(), strlen(library_path.c_str()) + 1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0])); source_module = LoadLibrary(lib_wstr); } #else diff --git a/src/slic3r/Utils/NetworkAgent.hpp b/src/slic3r/Utils/NetworkAgent.hpp index b020a116d0f..1f419a191af 100644 --- a/src/slic3r/Utils/NetworkAgent.hpp +++ b/src/slic3r/Utils/NetworkAgent.hpp @@ -116,6 +116,7 @@ class NetworkAgent { public: + static std::string get_libpath_in_current_directory(std::string library_name); static int initialize_network_module(bool using_backup = false); static int unload_network_module(); #if defined(_MSC_VER) || defined(_WIN32) From fd74396f5b1fcb998267bef7de83754bc6247e29 Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Fri, 20 Sep 2024 16:12:25 +0800 Subject: [PATCH 24/57] FIX: take addr of refresh_agora_url Change-Id: I02e7010634f578d76d3d4ee39edf73117d5684d1 Jira: none (cherry picked from commit ee290b439d2dd19bc00e7037b38fc48bc741b938) --- src/slic3r/GUI/MediaFilePanel.cpp | 2 +- src/slic3r/GUI/MediaPlayCtrl.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/MediaFilePanel.cpp b/src/slic3r/GUI/MediaFilePanel.cpp index 556a3dfb40d..9ff4b7fd18a 100644 --- a/src/slic3r/GUI/MediaFilePanel.cpp +++ b/src/slic3r/GUI/MediaFilePanel.cpp @@ -486,7 +486,7 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr wfs) url += "&device=" + m; url += "&net_ver=" + v; url += "&dev_ver=" + dv; - url += "&refresh_url=" + boost::lexical_cast(refresh_agora_url); + url += "&refresh_url=" + boost::lexical_cast(&refresh_agora_url); url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid"); url += "&cli_ver=" + std::string(SLIC3R_VERSION); } diff --git a/src/slic3r/GUI/MediaPlayCtrl.cpp b/src/slic3r/GUI/MediaPlayCtrl.cpp index 867d0be303c..923484b0a36 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.cpp +++ b/src/slic3r/GUI/MediaPlayCtrl.cpp @@ -331,7 +331,7 @@ void MediaPlayCtrl::Play() url += "&device=" + into_u8(m); url += "&net_ver=" + v; url += "&dev_ver=" + dv; - url += "&refresh_url=" + boost::lexical_cast(refresh_agora_url); + url += "&refresh_url=" + boost::lexical_cast(&refresh_agora_url); url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid"); url += "&cli_ver=" + std::string(SLIC3R_VERSION); } @@ -533,7 +533,7 @@ void MediaPlayCtrl::ToggleStream() url += "&device=" + m; url += "&net_ver=" + v; url += "&dev_ver=" + dv; - url += "&refresh_url=" + boost::lexical_cast(refresh_agora_url); + url += "&refresh_url=" + boost::lexical_cast(&refresh_agora_url); url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid"); url += "&cli_ver=" + std::string(SLIC3R_VERSION); } From c331958239e2f450456434f702b5bb56246b9e58 Mon Sep 17 00:00:00 2001 From: gerrit Date: Mon, 23 Sep 2024 16:34:08 +0800 Subject: [PATCH 25/57] ci: update network module based on commit 0988159 Change-Id: I28069501e6fb9468d92903a82e3e6839f007ef3d (cherry picked from commit 6aca03d69a6f5e80d9551b8f192ed8199cec1f1c) --- src/slic3r/Utils/bambu_networking.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index 44005730cf4..13acc5ba231 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -95,7 +95,7 @@ namespace BBL { #define BAMBU_NETWORK_LIBRARY "bambu_networking" #define BAMBU_NETWORK_AGENT_NAME "bambu_network_agent" -#define BAMBU_NETWORK_AGENT_VERSION "01.09.07.01" +#define BAMBU_NETWORK_AGENT_VERSION "01.10.00.01" //iot preset type strings #define IOT_PRINTER_TYPE_STRING "printer" From 84895eaf9e6aac6b90212ca37946727231807dfd Mon Sep 17 00:00:00 2001 From: "maosheng.wei" Date: Tue, 13 Aug 2024 20:13:49 +0800 Subject: [PATCH 26/57] ENH: Optimize the number of function calls during information parsing During the printer connection cycle, each Filament and slot is only judged once When deleting custom filaments or modifying the temperature of custom filaments, re evaluate Jira: XXXX Change-Id: If495a343efdb1be6f46d11dd20f6ec7934266e87 (cherry picked from commit e5dab1487188d744c732568232b32666e5f2cc5c) --- src/libslic3r/PresetBundle.cpp | 2 +- src/slic3r/GUI/DeviceManager.cpp | 190 +++++++++++++++++++++++-------- src/slic3r/GUI/DeviceManager.hpp | 8 ++ 3 files changed, 151 insertions(+), 49 deletions(-) diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index 039930c3872..5facc8e50f6 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -2001,7 +2001,7 @@ std::set PresetBundle::get_printer_names_by_printer_type_and_nozzle if (printer_it->name.find(nozzle_diameter_str) != std::string::npos) printer_names.insert(printer_it->name); } - //assert(printer_names.size() == 1); + assert(printer_names.size() == 1); for (auto& printer_name : printer_names) { BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " printer name: " << printer_name; diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index e67da8e1711..f567de42c4c 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -1847,7 +1847,8 @@ int MachineObject::command_ams_calibrate(int ams_id) int MachineObject::command_ams_filament_settings(int ams_id, int tray_id, std::string filament_id, std::string setting_id, std::string tray_color, std::string tray_type, int nozzle_temp_min, int nozzle_temp_max) { BOOST_LOG_TRIVIAL(info) << "command_ams_filament_settings, ams_id = " << ams_id << ", tray_id = " << tray_id << ", tray_color = " << tray_color - << ", tray_type = " << tray_type << ", setting_id = " << setting_id << ", temp_min: = " << nozzle_temp_min << ", temp_max: = " << nozzle_temp_max; + << ", tray_type = " << tray_type << ", filament_id = " << filament_id + << ", setting_id = " << setting_id << ", temp_min: = " << nozzle_temp_min << ", temp_max: = " << nozzle_temp_max; json j; j["print"]["command"] = "ams_filament_setting"; j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); @@ -3826,11 +3827,13 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) ; } PresetBundle *preset_bundle = Slic3r::GUI::wxGetApp().preset_bundle; - std::map> filament_list = preset_bundle->filaments.get_filament_presets(); std::ostringstream stream; stream << std::fixed << std::setprecision(1) << nozzle_diameter; std::string nozzle_diameter_str = stream.str(); - + if (m_printer_preset_name.find(nozzle_diameter_str + " nozzle") == std::string::npos) + update_printer_preset_name(nozzle_diameter_str); + update_filament_list(); + std::set need_checked_filament_id; if (jj.contains("ams")) { if (jj["ams"].contains("ams")) { long int last_ams_exist_bits = ams_exist_bits; @@ -3992,15 +3995,24 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } else { curr_tray->type = type; } - if (filament_list.find(curr_tray->setting_id) == filament_list.end()) { - wxColour color = *wxWHITE; - char col_buf[10]; - sprintf(col_buf, "%02X%02X%02XFF", (int) color.Red(), (int) color.Green(), (int) color.Blue()); - try { - this->command_ams_filament_settings(std::stoi(ams_id), std::stoi(tray_id), "", "", std::string(col_buf), "", 0, 0); - continue; - } catch (...) { - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " stoi error and ams_id: " << ams_id << " tray_id" << tray_id; + // settings_id is not exist in filament_list + if (curr_tray->setting_id.size() == 8 && curr_tray->setting_id[0] == 'P' && + m_filament_list.find(curr_tray->setting_id) == m_filament_list.end()) { + if (m_checked_filament.find(curr_tray->setting_id) == m_checked_filament.end()) { + need_checked_filament_id.insert(curr_tray->setting_id); + wxColour color = *wxWHITE; + char col_buf[10]; + sprintf(col_buf, "%02X%02X%02XFF", (int) color.Red(), (int) color.Green(), (int) color.Blue()); + try { + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ + << " ams settings_id is not exist in filament_list and reset, ams_id: " << ams_id + << " tray_id" << tray_id << "filament_id: " << curr_tray->setting_id; + this->command_ams_filament_settings(std::stoi(ams_id), std::stoi(tray_id), "", "", std::string(col_buf), "", 0, 0); + continue; + } catch (...) { + BOOST_LOG_TRIVIAL(info) + << __FUNCTION__ << " " << __LINE__ << " stoi error and ams_id: " << ams_id << " tray_id" << tray_id; + } } } } else { @@ -4050,20 +4062,27 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) curr_tray->nozzle_temp_min = (*tray_it)["nozzle_temp_min"].get(); else curr_tray->nozzle_temp_min = ""; - if (curr_tray->nozzle_temp_min != "" && curr_tray->nozzle_temp_max != "") { - try { - std::string preset_setting_id; - bool is_equation = preset_bundle->check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray( - MachineObject::get_preset_printer_model_name(this->printer_type), nozzle_diameter_str, curr_tray->setting_id, - curr_tray->tag_uid, curr_tray->nozzle_temp_min, curr_tray->nozzle_temp_max, preset_setting_id); - if (!is_equation) { - command_ams_filament_settings(std::stoi(ams_id), std::stoi(tray_id), curr_tray->setting_id, preset_setting_id, - curr_tray->color, curr_tray->type, - std::stoi(curr_tray->nozzle_temp_min), - std::stoi(curr_tray->nozzle_temp_max)); + if (curr_tray->setting_id.size() == 8 && curr_tray->setting_id[0] == 'P' && curr_tray->nozzle_temp_min != "" && curr_tray->nozzle_temp_max != "") { + if (m_checked_filament.find(vt_tray.setting_id) == m_checked_filament.end()) { + need_checked_filament_id.insert(vt_tray.setting_id); + try { + std::string preset_setting_id; + bool is_equation = preset_bundle->check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray( + MachineObject::get_preset_printer_model_name(this->printer_type), nozzle_diameter_str, curr_tray->setting_id, + curr_tray->tag_uid, curr_tray->nozzle_temp_min, curr_tray->nozzle_temp_max, preset_setting_id); + if (!is_equation) { + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ + << " ams filament is not match min max temp and reset, ams_id: " << ams_id + << " tray_id" << tray_id << "filament_id: " << curr_tray->setting_id; + command_ams_filament_settings(std::stoi(ams_id), std::stoi(tray_id), curr_tray->setting_id, preset_setting_id, + curr_tray->color, curr_tray->type, + std::stoi(curr_tray->nozzle_temp_min), + std::stoi(curr_tray->nozzle_temp_max)); + } + continue; + } catch (...) { + BOOST_LOG_TRIVIAL(info) << "check fail and curr_tray ams_id" << ams_id << " curr_tray tray_id"<contains("xcam_info")) @@ -4187,15 +4206,19 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) else { vt_tray.type = type; } - if (filament_list.find(vt_tray.setting_id) == filament_list.end()) { - wxColour color = *wxWHITE; - char col_buf[10]; - sprintf(col_buf, "%02X%02X%02XFF", (int) color.Red(), (int) color.Green(), (int) color.Blue()); - try { - BOOST_LOG_TRIVIAL(info) << "no filament_id in filament_list and reset vt_tray and the filament_id is: " << vt_tray.setting_id; - this->command_ams_filament_settings(255, std::stoi(vt_tray.id), "", "", std::string(col_buf), "", 0, 0); - } catch (...) { - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " stoi error and tray_id" << vt_tray.id; + if (vt_tray.setting_id.size() == 8 && vt_tray.setting_id[0] == 'P' && + m_filament_list.find(vt_tray.setting_id) == m_filament_list.end()) { + if (m_checked_filament.find(vt_tray.setting_id) == m_checked_filament.end()) { + need_checked_filament_id.insert(vt_tray.setting_id); + wxColour color = *wxWHITE; + char col_buf[10]; + sprintf(col_buf, "%02X%02X%02XFF", (int) color.Red(), (int) color.Green(), (int) color.Blue()); + try { + BOOST_LOG_TRIVIAL(info) << "vt_tray.setting_id is not exist in filament_list and reset vt_tray and the filament_id is: " << vt_tray.setting_id; + this->command_ams_filament_settings(255, std::stoi(vt_tray.id), "", "", std::string(col_buf), "", 0, 0); + } catch (...) { + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " stoi error and tray_id" << vt_tray.id; + } } } } @@ -4245,21 +4268,23 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) vt_tray.nozzle_temp_min = jj["vt_tray"]["nozzle_temp_min"].get(); else vt_tray.nozzle_temp_min = ""; - if (vt_tray.nozzle_temp_min != "" && vt_tray.nozzle_temp_max != "") { - try { - std::string preset_setting_id; - bool is_equation = preset_bundle->check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray( - MachineObject::get_preset_printer_model_name(this->printer_type), nozzle_diameter_str, vt_tray.setting_id, vt_tray.tag_uid, - vt_tray.nozzle_temp_min, vt_tray.nozzle_temp_max, preset_setting_id); - if (!is_equation) { - command_ams_filament_settings(255, std::stoi(vt_tray.id), vt_tray.setting_id, preset_setting_id, vt_tray.color, vt_tray.type, - std::stoi(vt_tray.nozzle_temp_min), std::stoi(vt_tray.nozzle_temp_max)); + if (vt_tray.setting_id.size() == 8 && vt_tray.setting_id[0] == 'P' && vt_tray.nozzle_temp_min != "" && vt_tray.nozzle_temp_max != "") { + if (m_checked_filament.find(vt_tray.setting_id) == m_checked_filament.end()) { + need_checked_filament_id.insert(vt_tray.setting_id); + try { + std::string preset_setting_id; + bool is_equation = preset_bundle->check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray( + MachineObject::get_preset_printer_model_name(this->printer_type), nozzle_diameter_str, vt_tray.setting_id, vt_tray.tag_uid, + vt_tray.nozzle_temp_min, vt_tray.nozzle_temp_max, preset_setting_id); + if (!is_equation) { + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " vt_tray filament is not match min max temp and reset, filament_id: " << vt_tray.setting_id; + command_ams_filament_settings(255, std::stoi(vt_tray.id), vt_tray.setting_id, preset_setting_id, vt_tray.color, vt_tray.type, + std::stoi(vt_tray.nozzle_temp_min), std::stoi(vt_tray.nozzle_temp_max)); + } + } catch (...) { + BOOST_LOG_TRIVIAL(info) << "check fail and vt_tray.id" << vt_tray.id; } } - catch(...) { - BOOST_LOG_TRIVIAL(info) << "check fail and vt_tray.id" << vt_tray.id; - } - } if (jj["vt_tray"].contains("xcam_info")) vt_tray.xcam_info = jj["vt_tray"]["xcam_info"].get(); @@ -4299,8 +4324,9 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) ; } } + for (auto &filament_id : need_checked_filament_id) + m_checked_filament.insert(filament_id); #pragma endregion - } else if (jj["command"].get() == "gcode_line") { //ack of gcode_line BOOST_LOG_TRIVIAL(debug) << "parse_json, ack of gcode_line = " << j.dump(4); @@ -5121,6 +5147,73 @@ std::string MachineObject::get_string_from_fantype(FanType type) return ""; } +void MachineObject::update_filament_list() +{ + PresetBundle *preset_bundle = Slic3r::GUI::wxGetApp().preset_bundle; + + // custom filament + std::map> filament_list; + for (auto &preset : preset_bundle->filaments()) { + if (preset.is_user() && preset.inherits() == "") { + ConfigOption * printer_opt = const_cast(preset).config.option("compatible_printers"); + ConfigOptionStrings *printer_strs = dynamic_cast(printer_opt); + for (const std::string &printer_str : printer_strs->values) { + if (printer_str == m_printer_preset_name) { + ConfigOption *opt_min = const_cast(preset).config.option("nozzle_temperature_range_low"); + int min_temp = -1; + if (opt_min) { + ConfigOptionInts *opt_min_ints = dynamic_cast(opt_min); + min_temp = opt_min_ints->get_at(0); + } + ConfigOption *opt_max = const_cast(preset).config.option("nozzle_temperature_range_high"); + int max_temp = -1; + if (opt_max) { + ConfigOptionInts *opt_max_ints = dynamic_cast(opt_max); + max_temp = opt_max_ints->get_at(0); + } + filament_list[preset.filament_id] = std::make_pair(min_temp, max_temp); + break; + } + } + } + } + + for (auto it = filament_list.begin(); it != filament_list.end(); it++) { + if (m_filament_list.find(it->first) != m_filament_list.end()) { + assert(it->first.size() == 8 && it->first[0] == 'P'); + + if (it->second.first != m_filament_list[it->first].first) { + BOOST_LOG_TRIVIAL(info) << "old min temp is not equal to new min temp and filament id: " << it->first; + continue; + } + + if (it->second.second != m_filament_list[it->first].second) { + BOOST_LOG_TRIVIAL(info) << "old max temp is not equal to new max temp and filament id: " << it->first; + continue; + } + + m_filament_list.erase(it->first); + } + } + + for (auto it = m_filament_list.begin(); it != m_filament_list.end(); it++) { + m_checked_filament.erase(it->first); + } + + m_filament_list = filament_list; +} + +void MachineObject::update_printer_preset_name(const std::string &nozzle_diameter_str) +{ + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << "start update preset_name"; + auto preset_boundle = Slic3r::GUI::wxGetApp().preset_bundle; + auto printer_set = preset_boundle->get_printer_names_by_printer_type_and_nozzle(MachineObject::get_preset_printer_model_name(this->printer_type), nozzle_diameter_str); + if (printer_set.size() > 0) + m_printer_preset_name = *printer_set.begin(); + else + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " update printer preset name failed "; +} + bool DeviceManager::EnableMultiMachine = false; bool DeviceManager::key_field_only = false; @@ -5520,6 +5613,7 @@ bool DeviceManager::set_selected_machine(std::string dev_id, bool need_disconnec } } } + it->second->m_checked_filament.clear(); } selected_machine = dev_id; return true; diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 3a0085966da..e1ce2974abe 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -313,6 +313,7 @@ struct DisValue { bool is_type_match = true; }; +class Preset; class MachineObject { private: @@ -973,6 +974,13 @@ public: void get_firmware_info(); bool is_firmware_info_valid(); std::string get_string_from_fantype(FanType type); + + /* Device Filament Check */ + std::set m_checked_filament; + std::string m_printer_preset_name; + std::map> m_filament_list; // filament_id, pair + void update_filament_list(); + void update_printer_preset_name(const std::string &nozzle_diameter_str); }; class DeviceManager From c334c0264af3325f3f1d3bfed295af9120409c19 Mon Sep 17 00:00:00 2001 From: tao wang Date: Sat, 28 Sep 2024 23:37:35 +0800 Subject: [PATCH 27/57] NEW:Support parsing of bit parameters Change-Id: I9b474a0e8b1bbfb5b1a4f2748f3f3f1e2afc6239 (cherry picked from commit 73c2ccd83b96490aee58f8cfe912e3ab66982094) --- src/slic3r/GUI/DeviceManager.cpp | 22 +++++++++++++++++++++- src/slic3r/GUI/DeviceManager.hpp | 2 ++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index f567de42c4c..e8fc6185b6a 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -3173,7 +3173,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) if (!key_field_only) { if (jj.contains("flag3")) { int flag3 = jj["flag3"].get(); - //is_support_filament_setting_inprinting = get_flag_bits(flag3, 3); + is_support_filament_setting_inprinting = get_flag_bits(flag3, 3); } } if (!key_field_only) { @@ -5203,6 +5203,26 @@ void MachineObject::update_filament_list() m_filament_list = filament_list; } +int MachineObject::get_flag_bits(std::string str, int start, int count) +{ + int decimal_value = std::stoi(str, nullptr, 16); + int mask = 0; + for (int i = 0; i < count; i++) { mask += 1 << (start + i); } + + int flag = (decimal_value & (mask)) >> start; + return flag; +} + +int MachineObject::get_flag_bits(int num, int start, int count) +{ + int decimal_value = num; + int mask = 0; + for (int i = 0; i < count; i++) { mask += 1 << (start + i); } + + int flag = (decimal_value & (mask)) >> start; + return flag; +} + void MachineObject::update_printer_preset_name(const std::string &nozzle_diameter_str) { BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << "start update preset_name"; diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index e1ce2974abe..cdf6f024dea 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -980,6 +980,8 @@ public: std::string m_printer_preset_name; std::map> m_filament_list; // filament_id, pair void update_filament_list(); + int get_flag_bits(std::string str, int start, int count); + int get_flag_bits(int num, int start, int count); void update_printer_preset_name(const std::string &nozzle_diameter_str); }; From caf992278623243dcd94660759a0b0c32a8d145b Mon Sep 17 00:00:00 2001 From: "zhimin.zeng" Date: Sun, 29 Sep 2024 09:31:41 +0800 Subject: [PATCH 28/57] FIX: fix build error jira: none Change-Id: I606c7ef67bf3b5f2810561ef2f5689947de4d4a8 (cherry picked from commit 93f95d95e718494a796a9290a1d7a5131485a205) --- src/slic3r/GUI/DeviceManager.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index cdf6f024dea..8814cad99b4 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -980,8 +980,8 @@ public: std::string m_printer_preset_name; std::map> m_filament_list; // filament_id, pair void update_filament_list(); - int get_flag_bits(std::string str, int start, int count); - int get_flag_bits(int num, int start, int count); + int get_flag_bits(std::string str, int start, int count = 1); + int get_flag_bits(int num, int start, int count = 1); void update_printer_preset_name(const std::string &nozzle_diameter_str); }; From 232983a0d1a23c872b93c0fced7240859071422d Mon Sep 17 00:00:00 2001 From: "zhimin.zeng" Date: Fri, 23 Aug 2024 15:41:16 +0800 Subject: [PATCH 29/57] FIX: add ack info for cali command jira: none Change-Id: Iec36ba2fd1248428234d74adb2089d975c54b7f2 (cherry picked from commit 0312db40c8ee5dfe7a912bf9992240f99036f6a8) (cherry picked from commit 8a279ef30238dc70ef9b4ef473e75b4335059b87) --- src/slic3r/GUI/DeviceManager.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index e8fc6185b6a..2fcd9d39cd2 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -4492,6 +4492,12 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } } } else if (jj["command"].get() == "extrusion_cali_set") { + if (jj.contains("result") && jj.contains("reason")) { + if (jj["result"].get() == "fail") { + auto err_code = jj["err_code"].get(); + print_error = err_code; + } + } #ifdef CALI_DEBUG std::string str = jj.dump(); BOOST_LOG_TRIVIAL(info) << "extrusion_cali_set: " << str; @@ -4536,6 +4542,13 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) extrusion_cali_set_hold_start = std::chrono::system_clock::now(); } else if (jj["command"].get() == "extrusion_cali_sel") { + if (jj.contains("result") && jj.contains("reason")) { + if (jj["result"].get() == "fail") { + auto err_code = jj["err_code"].get(); + print_error = err_code; + } + } + #ifdef CALI_DEBUG std::string str = jj.dump(); BOOST_LOG_TRIVIAL(info) << "extrusion_cali_sel: " << str; @@ -4577,6 +4590,13 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } } else if (jj["command"].get() == "extrusion_cali_get") { + if (jj.contains("result") && jj.contains("reason")) { + if (jj["result"].get() == "fail") { + auto err_code = jj["err_code"].get(); + print_error = err_code; + } + } + reset_pa_cali_history_result(); has_get_pa_calib_tab = true; @@ -4640,6 +4660,13 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) // notify cali history to update } else if (jj["command"].get() == "extrusion_cali_get_result") { + if (jj.contains("result") && jj.contains("reason")) { + if (jj["result"].get() == "fail") { + auto err_code = jj["err_code"].get(); + print_error = err_code; + } + } + reset_pa_cali_result(); get_pa_calib_result = true; From 598eaafaedf565e7293742c2ae2fdd8025533b8a Mon Sep 17 00:00:00 2001 From: gerrit Date: Fri, 11 Oct 2024 09:45:12 +0800 Subject: [PATCH 30/57] ci: update network module based on commit 89857a1 Change-Id: Id47ec68b439751f6d1459b4325cea56b26ff175b (cherry picked from commit 2a5c42fdd0d1228f85215ff05e5bca781ea8d663) --- src/slic3r/Utils/bambu_networking.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index 13acc5ba231..910bdfe369c 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -95,7 +95,7 @@ namespace BBL { #define BAMBU_NETWORK_LIBRARY "bambu_networking" #define BAMBU_NETWORK_AGENT_NAME "bambu_network_agent" -#define BAMBU_NETWORK_AGENT_VERSION "01.10.00.01" +#define BAMBU_NETWORK_AGENT_VERSION "01.10.00.02" //iot preset type strings #define IOT_PRINTER_TYPE_STRING "printer" From 21348783687a2398840434e122b65804bd18f2b5 Mon Sep 17 00:00:00 2001 From: tao wang Date: Sat, 12 Oct 2024 11:59:42 +0800 Subject: [PATCH 31/57] NEW:update prompt information in the connection jira:[STUDIO-8292] Change-Id: I3887bfe0537809a2fab39bbae1f65b7129ee0961 (cherry picked from commit 45f84d5321c4e7747a930636a95d8609d0764d34) --- src/slic3r/GUI/ReleaseNote.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index 7a2d14fa50d..c9b9811127a 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -1886,7 +1886,7 @@ void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_ closeCount = 1; update_test_msg(wxEmptyString, true); - update_test_msg(wxString::Format(_L("Printer binding successful. The dialog will close later"), closeCount), true); + update_test_msg(wxString::Format(_L("Connecting to printer... The dialog will close later"), closeCount), true); closeTimer->Start(1000); From 79fa11b66e210ff21e7890334159fce759c45aca Mon Sep 17 00:00:00 2001 From: tao wang Date: Mon, 14 Oct 2024 11:26:03 +0800 Subject: [PATCH 32/57] ENH:remove useless prompt information jira:[STUDIO-7884] Change-Id: Ia3fa5f8c99859d693544d3cb2be47975c3ed7493 (cherry picked from commit d9a8d68042c49258905071e902ac3963a6b3575e) --- src/slic3r/GUI/AMSMaterialsSetting.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/slic3r/GUI/AMSMaterialsSetting.cpp b/src/slic3r/GUI/AMSMaterialsSetting.cpp index 5c75802c7e6..7c7f2b15093 100644 --- a/src/slic3r/GUI/AMSMaterialsSetting.cpp +++ b/src/slic3r/GUI/AMSMaterialsSetting.cpp @@ -258,7 +258,7 @@ void AMSMaterialsSetting::create_panel_normal(wxWindow* parent) m_panel_SN->Fit(); wxBoxSizer* m_tip_sizer = new wxBoxSizer(wxHORIZONTAL); - m_tip_readonly = new Label(parent, _L("Setting AMS slot information while printing is not supported")); + m_tip_readonly = new Label(parent, _L("")); m_tip_readonly->SetForegroundColour(*wxBLACK); m_tip_readonly->SetBackgroundColour(*wxWHITE); m_tip_readonly->SetMinSize(wxSize(FromDIP(380), -1)); @@ -424,15 +424,14 @@ void AMSMaterialsSetting::enable_confirm_button(bool en) m_tip_readonly->Hide(); } else { - //m_comboBox_filament->Show(en); - //m_readonly_filament->Show(!en); + if (!obj->is_support_filament_setting_inprinting) { + if (!is_virtual_tray()) { + m_tip_readonly->SetLabelText(_L("Setting AMS slot information while printing is not supported")); + } else { + m_tip_readonly->SetLabelText(_L("Setting Virtual slot information while printing is not supported")); + } + } - if ( !is_virtual_tray() ) { - m_tip_readonly->SetLabelText(_L("Setting AMS slot information while printing is not supported")); - } - else { - m_tip_readonly->SetLabelText(_L("Setting Virtual slot information while printing is not supported")); - } m_tip_readonly->Wrap(FromDIP(380)); m_tip_readonly->Show(!en); } From 06e8c3c05fcdd5d96c38623a5f65d441563238de Mon Sep 17 00:00:00 2001 From: tao wang Date: Mon, 14 Oct 2024 20:04:40 +0800 Subject: [PATCH 33/57] FIX:display msg when cannot edit filament jira:[edit filament] Change-Id: I7e2b4fabeb3930f34fc252f1334e168e4f623b77 (cherry picked from commit 95655e067a7187afd29e53759aae8e3023a5a7f7) --- src/slic3r/GUI/AMSMaterialsSetting.cpp | 2 ++ src/slic3r/GUI/StatusPanel.cpp | 29 +++++++++++++------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/slic3r/GUI/AMSMaterialsSetting.cpp b/src/slic3r/GUI/AMSMaterialsSetting.cpp index 7c7f2b15093..6d5057d1619 100644 --- a/src/slic3r/GUI/AMSMaterialsSetting.cpp +++ b/src/slic3r/GUI/AMSMaterialsSetting.cpp @@ -413,6 +413,8 @@ void AMSMaterialsSetting::update() void AMSMaterialsSetting::enable_confirm_button(bool en) { + m_tip_readonly->SetLabelText(wxEmptyString); + if (!en) { m_button_confirm->Show(obj->is_support_filament_setting_inprinting); } diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index fa2b6b639f6..486f971b007 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -3122,6 +3122,20 @@ void StatusPanel::update_subtask(MachineObject *obj) } else { m_project_task_panel->enable_pause_resume_button(true, "pause"); } + + // update printing stage + m_project_task_panel->update_left_time(obj->mc_left_time); + if (obj->subtask_) { + m_project_task_panel->update_stage_value(obj->get_curr_stage(), obj->subtask_->task_progress); + m_project_task_panel->update_progress_percent(wxString::Format("%d", obj->subtask_->task_progress), "%"); + m_project_task_panel->update_layers_num(true, wxString::Format(_L("Layer: %d/%d"), obj->curr_layer, obj->total_layers)); + + } else { + m_project_task_panel->update_stage_value(obj->get_curr_stage(), 0); + m_project_task_panel->update_progress_percent(NA_STR, wxEmptyString); + m_project_task_panel->update_layers_num(true, wxString::Format(_L("Layer: %s"), NA_STR)); + } + if (obj->is_printing_finished()) { obj->update_model_task(); m_project_task_panel->enable_abort_button(false); @@ -3166,19 +3180,6 @@ void StatusPanel::update_subtask(MachineObject *obj) m_project_task_panel->market_scoring_hide(); m_project_task_panel->get_request_failed_panel()->Hide(); } - // update printing stage - - m_project_task_panel->update_left_time(obj->mc_left_time); - if (obj->subtask_) { - m_project_task_panel->update_stage_value(obj->get_curr_stage(), obj->subtask_->task_progress); - m_project_task_panel->update_progress_percent(wxString::Format("%d", obj->subtask_->task_progress), "%"); - m_project_task_panel->update_layers_num(true, wxString::Format(_L("Layer: %d/%d"), obj->curr_layer, obj->total_layers)); - - } else { - m_project_task_panel->update_stage_value(obj->get_curr_stage(), 0); - m_project_task_panel->update_progress_percent(NA_STR, wxEmptyString); - m_project_task_panel->update_layers_num(true, wxString::Format(_L("Layer: %s"), NA_STR)); - } } m_project_task_panel->update_subtask_name(wxString::Format("%s", GUI::from_u8(obj->subtask_name))); @@ -3202,7 +3203,7 @@ void StatusPanel::update_subtask(MachineObject *obj) reset_printing_values(); } - this->Layout(); + Layout(); } void StatusPanel::update_cloud_subtask(MachineObject *obj) From 56b3edf1099a5754a7198a2771359b4d36c61da8 Mon Sep 17 00:00:00 2001 From: gerrit Date: Tue, 15 Oct 2024 19:55:03 +0800 Subject: [PATCH 34/57] ci: update network module based on commit ed13d56 Change-Id: Ibef15b6751b99486b0a60e4fb9652955666c0d3b (cherry picked from commit ccab7b1ef30f9aa076d9837f7101e2a1b5e997cb) --- src/slic3r/Utils/bambu_networking.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index 910bdfe369c..0aef163aba9 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -95,7 +95,7 @@ namespace BBL { #define BAMBU_NETWORK_LIBRARY "bambu_networking" #define BAMBU_NETWORK_AGENT_NAME "bambu_network_agent" -#define BAMBU_NETWORK_AGENT_VERSION "01.10.00.02" +#define BAMBU_NETWORK_AGENT_VERSION "01.10.00.04" //iot preset type strings #define IOT_PRINTER_TYPE_STRING "printer" From 579c311797dfb5a787248ffa123c5e0e62559f53 Mon Sep 17 00:00:00 2001 From: tao wang Date: Thu, 17 Oct 2024 10:34:11 +0800 Subject: [PATCH 35/57] FIX:fix the issue of macOS crashing easily Change-Id: I7378a28734e46c4126ab0216dc93d45a10bcd451 (cherry picked from commit 35b0ef0cd7bbb3a3e06231863cf2d855e74b56cc) --- src/slic3r/GUI/SelectMachine.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index bfd09704394..431307d3f45 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -4559,16 +4559,21 @@ void SelectMachineDialog::sys_color_changed() bool SelectMachineDialog::Show(bool show) { - show_status(PrintDialogStatus::PrintStatusInit); - // set default value when show this dialog if (show) { + m_refresh_timer->Start(LIST_REFRESH_INTERVAL); + show_status(PrintDialogStatus::PrintStatusInit); wxGetApp().UpdateDlgDarkUI(this); wxGetApp().reset_to_active(); set_default(); update_user_machine_list(); + + Layout(); + Fit(); + CenterOnParent(); } else { + m_refresh_timer->Stop(); DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); if (dev) { MachineObject* obj_ = dev->get_selected_machine(); @@ -4580,15 +4585,6 @@ bool SelectMachineDialog::Show(bool show) } } } - - if (show) { - m_refresh_timer->Start(LIST_REFRESH_INTERVAL); - } else { - m_refresh_timer->Stop(); - } - Layout(); - Fit(); - if (show) { CenterOnParent(); } return DPIDialog::Show(show); } From fa96e551b45b562a329c720b1f48d7c16772346e Mon Sep 17 00:00:00 2001 From: gerrit Date: Thu, 24 Oct 2024 14:02:59 +0800 Subject: [PATCH 36/57] ci: update network module based on commit 76ae6aa Change-Id: I542fa0291c56755373679ad776766c4c3b29da0c (cherry picked from commit 6aa12e460b18b722b04370e3a36d670c8ffe299d) --- src/slic3r/Utils/bambu_networking.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index 0aef163aba9..5f7e48a41a3 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -95,7 +95,7 @@ namespace BBL { #define BAMBU_NETWORK_LIBRARY "bambu_networking" #define BAMBU_NETWORK_AGENT_NAME "bambu_network_agent" -#define BAMBU_NETWORK_AGENT_VERSION "01.10.00.04" +#define BAMBU_NETWORK_AGENT_VERSION "01.10.00.05" //iot preset type strings #define IOT_PRINTER_TYPE_STRING "printer" From bf09f29fdaa482271f1137e4fd9552d92451fd53 Mon Sep 17 00:00:00 2001 From: gerrit Date: Thu, 24 Oct 2024 17:52:12 +0800 Subject: [PATCH 37/57] ci: update network module based on commit 8f93dce Change-Id: I7fb2f5333b05346e4ba48c11fdf66838c5d67f78 (cherry picked from commit 2e4d33b5e19d6254e8f3d8ca9e5e0fdc038a885b) --- src/slic3r/Utils/bambu_networking.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index 5f7e48a41a3..c2d47719457 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -95,7 +95,7 @@ namespace BBL { #define BAMBU_NETWORK_LIBRARY "bambu_networking" #define BAMBU_NETWORK_AGENT_NAME "bambu_network_agent" -#define BAMBU_NETWORK_AGENT_VERSION "01.10.00.05" +#define BAMBU_NETWORK_AGENT_VERSION "01.10.00.06" //iot preset type strings #define IOT_PRINTER_TYPE_STRING "printer" From c621cd7d6eef9c5f10630e8f76351e0f39ccf5f5 Mon Sep 17 00:00:00 2001 From: tao wang Date: Mon, 28 Oct 2024 20:26:41 +0800 Subject: [PATCH 38/57] NEW:Support direct connection to X printer Change-Id: I4ea38d3a69834f607161ae35eda00d042b7c4f47 (cherry picked from commit a0f63b9a3a4efd2fd6d396aa757750cd0ff28178) --- src/slic3r/GUI/DeviceManager.cpp | 38 ++++ src/slic3r/GUI/DeviceManager.hpp | 3 +- src/slic3r/GUI/ReleaseNote.cpp | 301 ++++++++++++++++++++----------- src/slic3r/GUI/ReleaseNote.hpp | 12 +- 4 files changed, 243 insertions(+), 111 deletions(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 2fcd9d39cd2..3712139d056 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -5953,6 +5953,7 @@ std::string DeviceManager::get_printer_ams_img(std::string type_str) bool DeviceManager::get_printer_is_enclosed(std::string type_str) { return get_value_from_config(type_str, "printer_is_enclosed"); } + std::vector DeviceManager::get_resolution_supported(std::string type_str) { std::vector resolution_supported; @@ -5998,6 +5999,43 @@ std::vector DeviceManager::get_compatible_machine(std::string type_ return compatible_machine; } +std::vector DeviceManager::get_all_model_id() +{ + std::vector models; + std::vector m_files; + + wxDir dir(Slic3r::resources_dir() + "/printers/"); + if (!dir.IsOpened()) { + return models; + } + + wxString filename; + bool hasFile = dir.GetFirst(&filename, wxEmptyString, wxDIR_FILES); + while (hasFile) { + m_files.push_back(filename); + hasFile = dir.GetNext(&filename); + } + + for (wxString file : m_files) { + std::string config_file = Slic3r::resources_dir() + "/printers/" + file.ToStdString(); + boost::nowide::ifstream json_file(config_file.c_str()); + + try { + json jj; + if (json_file.is_open()) { + json_file >> jj; + if (jj.contains("00.00.00.00")) { + json const &printer = jj["00.00.00.00"]; + if (printer.contains("model_id")) { + for (auto res : printer["model_id"]) models.emplace_back(res.get()); + } + } + } + } catch (...) {} + } + + return models; +} bool DeviceManager::load_filaments_blacklist_config() { diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 8814cad99b4..466b611cb64 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -1080,7 +1080,8 @@ public: static bool get_printer_is_enclosed(std::string type_str); static std::vector get_resolution_supported(std::string type_str); static std::vector get_compatible_machine(std::string type_str); - static bool load_filaments_blacklist_config(); + static std::vector get_all_model_id(); + static bool load_filaments_blacklist_config(); static void check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, bool& in_blacklist, std::string& ac, std::string& info); static std::string load_gcode(std::string type_str, std::string gcode_file); }; diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index c9b9811127a..50681381410 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -1454,55 +1454,71 @@ void ConfirmBeforeSendDialog::rescale() m_button_cancel->Rescale(); } -InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent) - :DPIDialog(static_cast(wxGetApp().mainframe), wxID_ANY, _L("Connect the printer using IP and access code"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX) +InputIpAddressDialog::InputIpAddressDialog(wxWindow *parent) + : DPIDialog(static_cast(wxGetApp().mainframe), + wxID_ANY, + _L("Connect the printer using IP and access code"), + wxDefaultPosition, + wxDefaultSize, + wxCAPTION | wxCLOSE_BOX) { std::string icon_path = (boost::format("%1%/images/OrcaSlicerTitle.ico") % resources_dir()).str(); SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO)); SetBackgroundColour(*wxWHITE); - m_result = -1; - wxBoxSizer* m_sizer_body = new wxBoxSizer(wxVERTICAL); - wxBoxSizer* m_sizer_main = new wxBoxSizer(wxHORIZONTAL); - wxBoxSizer* m_sizer_main_left = new wxBoxSizer(wxVERTICAL); - wxBoxSizer* m_sizer_main_right = new wxBoxSizer(wxVERTICAL); - wxBoxSizer* m_sizer_msg = new wxBoxSizer(wxHORIZONTAL); - auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1)); + m_result = -1; + wxBoxSizer *m_sizer_body = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *m_sizer_main = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *m_sizer_main_left = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *m_sizer_main_right = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *m_sizer_msg = new wxBoxSizer(wxHORIZONTAL); + auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1)); m_line_top->SetBackgroundColour(wxColour(166, 169, 170)); - comfirm_before_enter_text = _L("Step 1, please confirm Orca Slicer and your printer are in the same LAN."); - comfirm_after_enter_text = _L("Step 2, if the IP and Access Code below are different from the actual values on your printer, please correct them."); - + comfirm_before_enter_text = _L("Step 1. Please confirm Orca Slicer and your printer are in the same LAN."); + comfirm_after_enter_text = _L("Step 2. If the IP and Access Code below are different from the actual values on your printer, please correct them."); + comfirm_last_enter_text = _L("Step 3. Please obtain the device SN from the printer side; it is usually found in the device information on the printer screen."); m_tip1 = new Label(this, ::Label::Body_13, comfirm_before_enter_text, LB_AUTO_WRAP); m_tip1->SetMinSize(wxSize(FromDIP(352), -1)); m_tip1->SetMaxSize(wxSize(FromDIP(352), -1)); m_tip1->Wrap(FromDIP(352)); - auto m_line_tips = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1)); - m_line_tips->SetBackgroundColour(wxColour(0xEEEEEE)); - m_tip2 = new Label(this, ::Label::Body_13, comfirm_after_enter_text, LB_AUTO_WRAP); m_tip2->SetMinSize(wxSize(FromDIP(352), -1)); m_tip2->SetMaxSize(wxSize(FromDIP(352), -1)); - auto m_input_tip_area = new wxBoxSizer(wxHORIZONTAL); - auto m_input_area = new wxBoxSizer(wxHORIZONTAL); + m_tip3 = new Label(this, ::Label::Body_13, comfirm_last_enter_text, LB_AUTO_WRAP); + m_tip3->SetMinSize(wxSize(FromDIP(352), -1)); + m_tip3->SetMaxSize(wxSize(FromDIP(352), -1)); - m_tips_ip = new Label(this, _L("IP")); + ip_input_top_panel = new wxPanel(this); + ip_input_bot_panel = new wxPanel(this); + + ip_input_top_panel->SetBackgroundColour(*wxWHITE); + ip_input_bot_panel->SetBackgroundColour(*wxWHITE); + + auto m_input_top_sizer = new wxBoxSizer(wxVERTICAL); + auto m_input_bot_sizer = new wxBoxSizer(wxVERTICAL); + + /*top input*/ + auto m_input_tip_area = new wxBoxSizer(wxHORIZONTAL); + auto m_input_area = new wxBoxSizer(wxHORIZONTAL); + + m_tips_ip = new Label(ip_input_top_panel, _L("IP")); m_tips_ip->SetMinSize(wxSize(FromDIP(168), -1)); m_tips_ip->SetMaxSize(wxSize(FromDIP(168), -1)); - m_input_ip = new TextInput(this, wxEmptyString, wxEmptyString); + m_input_ip = new TextInput(ip_input_top_panel, wxEmptyString, wxEmptyString); m_input_ip->Bind(wxEVT_TEXT, &InputIpAddressDialog::on_text, this); m_input_ip->SetMinSize(wxSize(FromDIP(168), FromDIP(28))); m_input_ip->SetMaxSize(wxSize(FromDIP(168), FromDIP(28))); - m_tips_access_code = new Label(this, _L("Access Code")); - m_tips_access_code->SetMinSize(wxSize(FromDIP(168),-1)); - m_tips_access_code->SetMaxSize(wxSize(FromDIP(168),-1)); + m_tips_access_code = new Label(ip_input_top_panel, _L("Access Code")); + m_tips_access_code->SetMinSize(wxSize(FromDIP(168), -1)); + m_tips_access_code->SetMaxSize(wxSize(FromDIP(168), -1)); - m_input_access_code = new TextInput(this, wxEmptyString, wxEmptyString); + m_input_access_code = new TextInput(ip_input_top_panel, wxEmptyString, wxEmptyString); m_input_access_code->Bind(wxEVT_TEXT, &InputIpAddressDialog::on_text, this); m_input_access_code->SetMinSize(wxSize(FromDIP(168), FromDIP(28))); m_input_access_code->SetMaxSize(wxSize(FromDIP(168), FromDIP(28))); @@ -1510,40 +1526,87 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent) m_input_tip_area->Add(m_tips_ip, 0, wxALIGN_CENTER, 0); m_input_tip_area->Add(0, 0, 0, wxLEFT, FromDIP(16)); m_input_tip_area->Add(m_tips_access_code, 0, wxALIGN_CENTER, 0); - + m_input_area->Add(m_input_ip, 0, wxALIGN_CENTER, 0); m_input_area->Add(0, 0, 0, wxLEFT, FromDIP(16)); m_input_area->Add(m_input_access_code, 0, wxALIGN_CENTER, 0); + m_input_top_sizer->Add(m_input_tip_area, 0, wxRIGHT | wxEXPAND, FromDIP(18)); + m_input_top_sizer->Add(0, 0, 0, wxTOP, FromDIP(4)); + m_input_top_sizer->Add(m_input_area, 0, wxRIGHT | wxEXPAND, FromDIP(18)); + + ip_input_top_panel->SetSizer(m_input_top_sizer); + ip_input_top_panel->Layout(); + ip_input_top_panel->Fit(); + + /*bom input*/ + auto m_input_sn_area = new wxBoxSizer(wxHORIZONTAL); + auto m_input_modelID_area = new wxBoxSizer(wxHORIZONTAL); + + m_tips_sn = new Label(ip_input_bot_panel, "SN"); + m_tips_sn->SetMinSize(wxSize(FromDIP(168), -1)); + m_tips_sn->SetMaxSize(wxSize(FromDIP(168), -1)); + + m_input_sn = new TextInput(ip_input_bot_panel, wxEmptyString, wxEmptyString); + m_input_sn->Bind(wxEVT_TEXT, &InputIpAddressDialog::on_text, this); + m_input_sn->SetMinSize(wxSize(FromDIP(168), FromDIP(28))); + m_input_sn->SetMaxSize(wxSize(FromDIP(168), FromDIP(28))); + + m_tips_modelID = new Label(ip_input_bot_panel, _L("Printer model")); + m_tips_modelID->SetMinSize(wxSize(FromDIP(168), -1)); + m_tips_modelID->SetMaxSize(wxSize(FromDIP(168), -1)); + + m_input_modelID = new ComboBox(ip_input_bot_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(168), FromDIP(28)), 0, nullptr, wxCB_READONLY); + // m_input_modelID->Bind(wxEVT_TEXT, &InputIpAddressDialog::on_text, this); + m_input_modelID->SetMinSize(wxSize(FromDIP(168), FromDIP(28))); + m_input_modelID->SetMaxSize(wxSize(FromDIP(168), FromDIP(28))); + + auto models = DeviceManager::get_all_model_id(); + for (int i = 0; i < models.size(); i++) { + m_input_modelID->Append(models[i]); + m_input_modelID->SetSelection(0); + } + + m_input_sn_area->Add(m_tips_sn, 0, wxALIGN_CENTER, 0); + m_input_sn_area->Add(0, 0, 0, wxLEFT, FromDIP(16)); + m_input_sn_area->Add(m_tips_modelID, 0, wxALIGN_CENTER, 0); + + m_input_modelID_area->Add(m_input_sn, 0, wxALIGN_CENTER, 0); + m_input_modelID_area->Add(0, 0, 0, wxLEFT, FromDIP(16)); + m_input_modelID_area->Add(m_input_modelID, 0, wxALIGN_CENTER, 0); + + m_input_bot_sizer->Add(m_input_sn_area, 0, wxRIGHT | wxEXPAND, FromDIP(18)); + m_input_bot_sizer->Add(0, 0, 0, wxTOP, FromDIP(4)); + m_input_bot_sizer->Add(m_input_modelID_area, 0, wxRIGHT | wxEXPAND, FromDIP(18)); + + ip_input_bot_panel->SetSizer(m_input_bot_sizer); + ip_input_bot_panel->Layout(); + ip_input_bot_panel->Fit(); + + /*other*/ m_test_right_msg = new Label(this, Label::Body_13, wxEmptyString, LB_AUTO_WRAP); m_test_right_msg->SetForegroundColour(wxColour(38, 166, 154)); m_test_right_msg->Hide(); - m_test_wrong_msg = new Label(this, Label::Body_13, wxEmptyString, LB_AUTO_WRAP); m_test_wrong_msg->SetForegroundColour(wxColour(208, 27, 27)); m_test_wrong_msg->Hide(); - m_tip3 = new Label(this, Label::Body_12, _L("Where to find your printer's IP and Access Code?"), LB_AUTO_WRAP); - m_tip3->SetMinSize(wxSize(FromDIP(352), -1)); - m_tip3->SetMaxSize(wxSize(FromDIP(352), -1)); - - m_tip4 = new Label(this, ::Label::Body_13, _L("Step 3: Ping the IP address to check for packet loss and latency."), LB_AUTO_WRAP); + m_tip4 = new Label(this, Label::Body_12, _L("Where to find your printer's IP and Access Code?"), LB_AUTO_WRAP); m_tip4->SetMinSize(wxSize(FromDIP(352), -1)); m_tip4->SetMaxSize(wxSize(FromDIP(352), -1)); - + m_trouble_shoot = new wxHyperlinkCtrl(this, wxID_ANY, "How to trouble shooting", ""); m_img_help = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("input_access_code_x1_en", this, 198), wxDefaultPosition, wxSize(FromDIP(352), -1), 0); - auto m_sizer_button = new wxBoxSizer(wxHORIZONTAL); StateColor btn_bg_green(std::pair(wxColour(38, 166, 154), StateColor::Pressed), std::pair(wxColour(38, 166, 154), StateColor::Hovered), - std::pair(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal)); + std::pair(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal)); StateColor btn_bg_white(std::pair(wxColour(206, 206, 206), StateColor::Pressed), std::pair(wxColour(238, 238, 238), StateColor::Hovered), - std::pair(*wxWHITE, StateColor::Normal)); + std::pair(*wxWHITE, StateColor::Normal)); m_button_ok = new Button(this, _L("Connect")); m_button_ok->SetBackgroundColor(btn_bg_green); @@ -1553,9 +1616,10 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent) m_button_ok->SetSize(wxSize(FromDIP(58), FromDIP(24))); m_button_ok->SetMinSize(wxSize(FromDIP(58), FromDIP(24))); m_button_ok->SetCornerRadius(FromDIP(12)); - - m_button_ok->Bind(wxEVT_LEFT_DOWN, &InputIpAddressDialog::on_ok, this); + m_button_ok->Enable(false); + m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90)); + m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90)); /*auto m_button_cancel = new Button(this, _L("Close")); m_button_cancel->SetBackgroundColor(btn_bg_white); @@ -1571,35 +1635,27 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent) m_sizer_button->AddStretchSpacer(); m_sizer_button->Add(m_button_ok, 0, wxALL, FromDIP(5)); - //m_sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5)); + // m_sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5)); m_sizer_button->Layout(); - - m_status_bar = std::make_shared(this); + m_status_bar = std::make_shared(this); m_status_bar->get_panel()->Hide(); - auto m_step_icon_panel1 = new wxWindow(this, wxID_ANY); auto m_step_icon_panel2 = new wxWindow(this, wxID_ANY); - + m_step_icon_panel3 = new wxWindow(this, wxID_ANY); + m_step_icon_panel1->SetBackgroundColour(*wxWHITE); m_step_icon_panel2->SetBackgroundColour(*wxWHITE); - + m_step_icon_panel3->SetBackgroundColour(*wxWHITE); auto m_sizer_step_icon_panel1 = new wxBoxSizer(wxVERTICAL); auto m_sizer_step_icon_panel2 = new wxBoxSizer(wxVERTICAL); - - + auto m_sizer_step_icon_panel3 = new wxBoxSizer(wxVERTICAL); m_img_step1 = new wxStaticBitmap(m_step_icon_panel1, wxID_ANY, create_scaled_bitmap("ip_address_step", this, 6), wxDefaultPosition, wxSize(FromDIP(6), FromDIP(6)), 0); - - auto m_line_tips_left = new wxPanel(m_step_icon_panel1, wxID_ANY, wxDefaultPosition, wxSize(-1, 1)); - m_line_tips_left->SetBackgroundColour(wxColour(0xEEEEEE)); m_img_step2 = new wxStaticBitmap(m_step_icon_panel2, wxID_ANY, create_scaled_bitmap("ip_address_step", this, 6), wxDefaultPosition, wxSize(FromDIP(6), FromDIP(6)), 0); - m_img_step3 = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("ip_address_step", this, 6), wxDefaultPosition, wxSize(FromDIP(6), FromDIP(6)), 0); - - m_sizer_step_icon_panel1->Add(m_img_step1, 0, wxALIGN_CENTER|wxALL, FromDIP(5)); - + m_img_step3 = new wxStaticBitmap(m_step_icon_panel3, wxID_ANY, create_scaled_bitmap("ip_address_step", this, 6), wxDefaultPosition, wxSize(FromDIP(6), FromDIP(6)), 0); m_step_icon_panel1->SetSizer(m_sizer_step_icon_panel1); m_step_icon_panel1->Layout(); @@ -1609,45 +1665,45 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent) m_step_icon_panel2->Layout(); m_step_icon_panel2->Fit(); + m_step_icon_panel3->SetSizer(m_sizer_step_icon_panel3); + m_step_icon_panel3->Layout(); + m_step_icon_panel3->Fit(); - - m_sizer_step_icon_panel2->Add(m_img_step2, 0, wxALIGN_CENTER|wxALL, FromDIP(5)); - //m_sizer_step_icon_panel3->Add(m_img_step3, 0, wxALIGN_CENTER|wxALL, FromDIP(5)); + m_sizer_step_icon_panel1->Add(m_img_step1, 0, wxALIGN_CENTER | wxALL, FromDIP(5)); + m_sizer_step_icon_panel2->Add(m_img_step2, 0, wxALIGN_CENTER | wxALL, FromDIP(5)); + m_sizer_step_icon_panel3->Add(m_img_step3, 0, wxALIGN_CENTER | wxALL, FromDIP(5)); m_step_icon_panel1->SetMinSize(wxSize(-1, m_tip1->GetBestSize().y)); m_step_icon_panel1->SetMaxSize(wxSize(-1, m_tip1->GetBestSize().y)); - m_sizer_msg->Add(0, 0, 0, wxALIGN_CENTER, FromDIP(20)); - m_sizer_msg->Add(m_img_step3, 0, wxALL, FromDIP(5)); - m_sizer_msg->Add(0, 0, 0, wxALIGN_CENTER, FromDIP(8)); - m_sizer_msg->Add(m_tip4, 0, wxALIGN_CENTER | wxEXPAND | wxLEFT, FromDIP(5)); - m_img_step3->Hide(); - m_tip4->Hide(); + m_step_icon_panel2->SetMinSize(wxSize(-1, m_tip2->GetBestSize().y)); + m_step_icon_panel2->SetMaxSize(wxSize(-1, m_tip2->GetBestSize().y)); + + m_sizer_msg->Layout(); m_sizer_main_left->Add(m_step_icon_panel1, 0, wxEXPAND, 0); m_sizer_main_left->Add(0, 0, 0, wxTOP, FromDIP(20)); - m_sizer_main_left->Add(m_line_tips_left, 1, wxEXPAND, 0); - m_sizer_main_left->Add(0, 0, 0, wxTOP, FromDIP(20)); m_sizer_main_left->Add(m_step_icon_panel2, 0, wxEXPAND, 0); + m_sizer_main_left->Add(0, 0, 0, wxTOP, FromDIP(20)); + m_sizer_main_left->Add(m_step_icon_panel3, 0, wxEXPAND, 0); m_sizer_main_left->Layout(); - + m_trouble_shoot->Hide(); - - m_sizer_main_right->Add(m_tip1, 0, wxRIGHT|wxEXPAND, FromDIP(18)); + + m_sizer_main_right->Add(m_tip1, 0, wxRIGHT | wxEXPAND, FromDIP(18)); m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(20)); - m_sizer_main_right->Add(m_line_tips, 0, wxRIGHT|wxEXPAND, FromDIP(18)); - m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(20)); - m_sizer_main_right->Add(m_tip2, 0, wxRIGHT|wxEXPAND, FromDIP(18)); + m_sizer_main_right->Add(m_tip2, 0, wxRIGHT | wxEXPAND, FromDIP(18)); + m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(2)); + m_sizer_main_right->Add(m_tip3, 0, wxTOP|wxRIGHT|wxEXPAND, FromDIP(18)); m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(12)); - m_sizer_main_right->Add(m_tip3, 0, wxRIGHT | wxEXPAND, FromDIP(18)); - m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(4)); + m_sizer_main_right->Add(m_tip4, 0, wxRIGHT | wxEXPAND, FromDIP(18)); + m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(3)); m_sizer_main_right->Add(m_img_help, 0, 0, 0); m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(12)); - m_sizer_main_right->Add(m_input_tip_area, 0, wxRIGHT|wxEXPAND, FromDIP(18)); - m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(4)); - m_sizer_main_right->Add(m_input_area, 0, wxRIGHT|wxEXPAND, FromDIP(18)); + m_sizer_main_right->Add(ip_input_top_panel, 0, wxRIGHT|wxEXPAND, FromDIP(18)); + m_sizer_main_right->Add(ip_input_bot_panel, 0, wxRIGHT|wxEXPAND, FromDIP(18)); m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(4)); //m_sizer_main_right->Add(m_button_ok, 0, wxRIGHT, FromDIP(18)); m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(4)); @@ -1663,18 +1719,19 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent) m_sizer_main->Layout(); m_sizer_body->Add(m_line_top, 0, wxEXPAND, 0); - m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(4)); + m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(10)); m_sizer_body->Add(m_sizer_main, 0, wxRIGHT, FromDIP(10)); m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(4)); m_sizer_body->Add(m_sizer_msg, 0, wxLEFT|wxEXPAND, FromDIP(18)); m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(4)); m_sizer_body->Add(m_trouble_shoot, 0, wxLEFT | wxRIGHT | wxEXPAND, FromDIP(40)); - m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(8)); m_sizer_body->Add(m_sizer_button, 0, wxRIGHT | wxEXPAND, FromDIP(25)); m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(10)); m_sizer_body->Layout(); + switch_input_panel(0); + SetSizer(m_sizer_body); Layout(); Fit(); @@ -1687,7 +1744,7 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent) closeTimer->SetOwner(this); Bind(wxEVT_TIMER, &InputIpAddressDialog::OnTimer, this); - Bind(EVT_CHECK_IP_ADDRESS_FAILED, &InputIpAddressDialog::on_check_ip_address_failed, this); + //Bind(EVT_CHECK_IP_ADDRESS_FAILED, &InputIpAddressDialog::on_check_ip_address_failed, this); Bind(EVT_CLOSE_IPADDRESS_DLG, [this](auto& e) { m_status_bar->reset(); @@ -1697,7 +1754,26 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent) on_cancel(); closeTimer->Stop(); }); +} +void InputIpAddressDialog::switch_input_panel(int index) +{ + if (index == 0) { + ip_input_top_panel->Show(); + ip_input_bot_panel->Hide(); + m_step_icon_panel3->Hide(); + m_tip3->Hide(); + } else { + ip_input_top_panel->Hide(); + ip_input_bot_panel->Show(); + m_step_icon_panel3->Show(); + m_tip3->Show(); + + m_button_ok->Enable(false); + m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90)); + m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90)); + } + current_input_index = index; } void InputIpAddressDialog::on_cancel() @@ -1793,26 +1869,11 @@ void InputIpAddressDialog::on_ok(wxMouseEvent& evt) { m_test_right_msg->Hide(); m_test_wrong_msg->Hide(); - m_img_step3->Hide(); - m_tip4->Hide(); m_trouble_shoot->Hide(); std::string str_ip = m_input_ip->GetTextCtrl()->GetValue().ToStdString(); std::string str_access_code = m_input_access_code->GetTextCtrl()->GetValue().ToStdString(); - - //check support function - /*if (!m_obj) return; - if (!m_obj->is_support_send_to_sdcard) { - wxString input_str = wxString::Format("%s|%s", ip, str_access_code); - auto event = wxCommandEvent(EVT_ENTER_IP_ADDRESS); - event.SetString(input_str); - event.SetEventObject(this); - wxPostEvent(this, event); - - auto event_close = wxCommandEvent(EVT_CLOSE_IPADDRESS_DLG); - event_close.SetEventObject(this); - wxPostEvent(this, event_close); - return; - }*/ + std::string str_sn = m_input_sn->GetTextCtrl()->GetValue().ToStdString(); + std::string str_model_id = m_input_modelID->GetStringSelection().ToStdString(); m_button_ok->Enable(false); m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90)); @@ -1822,14 +1883,24 @@ void InputIpAddressDialog::on_ok(wxMouseEvent& evt) Layout(); Fit(); - m_thread = new boost::thread(boost::bind(&InputIpAddressDialog::workerThreadFunc, this, str_ip, str_access_code)); + m_thread = new boost::thread(boost::bind(&InputIpAddressDialog::workerThreadFunc, this, str_ip, str_access_code, str_sn, str_model_id)); } -void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_access_code) +void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_access_code, std::string sn, std::string model_id) { update_test_msg(_L("connecting..."), true); + detectResult detectData; - auto result = wxGetApp().getAgent()->bind_detect(str_ip, "secure", detectData); + auto result = -1; + if (current_input_index == 0) { + result = wxGetApp().getAgent()->bind_detect(str_ip, "secure", detectData); + } else { + result = 0; + detectData.dev_name = sn; + detectData.dev_id = sn; + detectData.connect_type = "lan"; + detectData.connect_type = "free"; + } if (result < 0) { update_test_msg(wxEmptyString, true); @@ -1840,17 +1911,17 @@ void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_ update_test_msg(_L("Failed to publish login request."), false); } else if (result == -3) { - update_test_msg(_L("The device does not support using IP and Access Code for connection."), false); + switch_input_panel(1); + //update_test_msg(_L("The device does not support using IP and Access Code for connection."), false); } - m_button_ok->Enable(true); - m_button_ok->Enable(true); + /*m_button_ok->Enable(true); StateColor btn_bg_green(std::pair(wxColour(61, 203, 115), StateColor::Pressed), std::pair(wxColour(61, 203, 115), StateColor::Hovered), - std::pair(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal)); + std::pair(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal)); m_button_ok->SetTextColor(StateColor::darkModeColorFor("#FFFFFE")); m_button_ok->SetBackgroundColor(btn_bg_green); - m_button_ok->SetBorderColor(*wxWHITE); + m_button_ok->SetBorderColor(*wxWHITE);*/ Layout(); Fit(); @@ -1922,8 +1993,6 @@ void InputIpAddressDialog::on_check_ip_address_failed(wxCommandEvent& evt) } else { update_test_msg(_L("Connection failed! If your IP and Access Code is correct, \nplease move to step 3 for troubleshooting network issues"), false); - m_img_step3->Show(); - m_tip4->Show(); //m_trouble_shoot->Show(); Layout(); Fit(); @@ -1936,10 +2005,11 @@ void InputIpAddressDialog::on_check_ip_address_failed(wxCommandEvent& evt) m_button_ok->SetBackgroundColor(btn_bg_green); } -void InputIpAddressDialog::on_text(wxCommandEvent& evt) +void InputIpAddressDialog::on_text(wxCommandEvent &evt) { - auto str_ip = m_input_ip->GetTextCtrl()->GetValue(); - auto str_access_code = m_input_access_code->GetTextCtrl()->GetValue(); + auto str_ip = m_input_ip->GetTextCtrl()->GetValue(); + auto str_access_code = m_input_access_code->GetTextCtrl()->GetValue(); + auto str_sn = m_input_sn->GetTextCtrl()->GetValue(); bool invalid_access_code = true; for (char c : str_access_code) { @@ -1952,15 +2022,28 @@ void InputIpAddressDialog::on_text(wxCommandEvent& evt) if (isIp(str_ip.ToStdString()) && str_access_code.Length() == 8 && invalid_access_code) { m_button_ok->Enable(true); StateColor btn_bg_green(std::pair(wxColour(0, 137, 123), StateColor::Pressed), std::pair(wxColour(38, 166, 154), StateColor::Hovered), - std::pair(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal)); + std::pair(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal)); m_button_ok->SetTextColor(StateColor::darkModeColorFor("#FFFFFE")); m_button_ok->SetBackgroundColor(btn_bg_green); - } - else { + } else { m_button_ok->Enable(false); m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90)); m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90)); } + + if (current_input_index == 1){ + if (str_sn.length() == 15) { + m_button_ok->Enable(true); + StateColor btn_bg_green(std::pair(wxColour(61, 203, 115), StateColor::Pressed), std::pair(wxColour(61, 203, 115), StateColor::Hovered), + std::pair(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal)); + m_button_ok->SetTextColor(StateColor::darkModeColorFor("#FFFFFE")); + m_button_ok->SetBackgroundColor(btn_bg_green); + } else { + m_button_ok->Enable(false); + m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90)); + m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90)); + } + } } InputIpAddressDialog::~InputIpAddressDialog() diff --git a/src/slic3r/GUI/ReleaseNote.hpp b/src/slic3r/GUI/ReleaseNote.hpp index 7923c0fa281..5e8b9a52ddd 100644 --- a/src/slic3r/GUI/ReleaseNote.hpp +++ b/src/slic3r/GUI/ReleaseNote.hpp @@ -275,10 +275,12 @@ class InputIpAddressDialog : public DPIDialog public: wxString comfirm_before_enter_text; wxString comfirm_after_enter_text; + wxString comfirm_last_enter_text; boost::thread* m_thread{nullptr}; std::string m_ip; + wxWindow* m_step_icon_panel3{ nullptr }; Label* m_tip1{ nullptr }; Label* m_tip2{ nullptr }; Label* m_tip3{ nullptr }; @@ -287,13 +289,19 @@ public: ~InputIpAddressDialog(); MachineObject* m_obj{nullptr}; + wxPanel * ip_input_top_panel{ nullptr }; + wxPanel * ip_input_bot_panel{ nullptr }; Button* m_button_ok{ nullptr }; Label* m_tips_ip{ nullptr }; Label* m_tips_access_code{ nullptr }; + Label* m_tips_sn{nullptr}; + Label* m_tips_modelID{nullptr}; Label* m_test_right_msg{ nullptr }; Label* m_test_wrong_msg{ nullptr }; TextInput* m_input_ip{ nullptr }; TextInput* m_input_access_code{ nullptr }; + TextInput* m_input_sn{ nullptr }; + ComboBox* m_input_modelID{ nullptr }; wxStaticBitmap* m_img_help{ nullptr }; wxStaticBitmap* m_img_step1{ nullptr }; wxStaticBitmap* m_img_step2{ nullptr }; @@ -303,8 +311,10 @@ public: int closeCount{3}; bool m_show_access_code{ false }; int m_result; + int current_input_index {0}; std::shared_ptr m_status_bar; + void switch_input_panel(int index); void on_cancel(); void update_title(wxString title); void set_machine_obj(MachineObject* obj); @@ -313,7 +323,7 @@ public: void check_ip_address_failed(int result); void on_check_ip_address_failed(wxCommandEvent& evt); void on_ok(wxMouseEvent& evt); - void workerThreadFunc(std::string str_ip, std::string str_access_code); + void workerThreadFunc(std::string str_ip, std::string str_access_code, std::string sn, std::string model_id); void OnTimer(wxTimerEvent& event); void on_text(wxCommandEvent& evt); void on_dpi_changed(const wxRect& suggested_rect) override; From 0692e8c4dcee7c4d1545fa1af18cedf9454954d7 Mon Sep 17 00:00:00 2001 From: gerrit Date: Thu, 31 Oct 2024 14:42:49 +0800 Subject: [PATCH 39/57] ci: update network module based on commit c4c2707 Change-Id: I7ea8f149fa14d6c3fc2c10ee970b2457f0808c08 (cherry picked from commit a9940b1d5d75d02e6f34159aeeee49b84b7d9b6c) --- src/slic3r/Utils/bambu_networking.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index c2d47719457..c6d12fa6e3f 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -95,7 +95,7 @@ namespace BBL { #define BAMBU_NETWORK_LIBRARY "bambu_networking" #define BAMBU_NETWORK_AGENT_NAME "bambu_network_agent" -#define BAMBU_NETWORK_AGENT_VERSION "01.10.00.06" +#define BAMBU_NETWORK_AGENT_VERSION "01.10.00.07" //iot preset type strings #define IOT_PRINTER_TYPE_STRING "printer" From 3d44ca88a3ef3bf52b3b6d493c5f67f5b3d470f0 Mon Sep 17 00:00:00 2001 From: tao wang Date: Mon, 16 Sep 2024 22:29:39 +0800 Subject: [PATCH 40/57] ENH:optimized the retry of requests jira:[for network optimized] Change-Id: Iea43f4a97c7cd568171287278a07689e954d1093 (cherry picked from commit 35d3de8abe63a0cba30948581ed26a8bc7f94162) (cherry picked from commit 30bad38fb979f5c5a10e4b869ec2e41fa99857f8) --- src/slic3r/GUI/GUI_App.cpp | 28 +++++++++ src/slic3r/GUI/GUI_App.hpp | 7 ++- src/slic3r/GUI/MsgDialog.cpp | 87 +++++++++++++++++++++++++++ src/slic3r/GUI/MsgDialog.hpp | 16 +++++ src/slic3r/Utils/NetworkAgent.cpp | 14 +++++ src/slic3r/Utils/NetworkAgent.hpp | 3 + src/slic3r/Utils/bambu_networking.hpp | 3 + 7 files changed, 156 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 26a9ccee135..0e8691cec95 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1571,6 +1571,17 @@ void GUI_App::init_networking_callbacks() // GUI::wxGetApp().request_user_handle(online_login); // }); + m_agent->set_server_callback([this](std::string url, int status) { + if (!m_server_error_dialog) { + m_server_error_dialog = new NetworkErrorDialog(mainframe); + } + + if (!m_server_error_dialog->IsShown()) { + m_server_error_dialog->ShowModal(); + } + }); + + m_agent->set_on_server_connected_fn([this](int return_code, int reason_code) { if (m_is_closing) { return; @@ -3227,6 +3238,23 @@ void GUI_App::link_to_network_check() wxLaunchDefaultBrowser(url); } +void GUI_App::link_to_lan_only_wiki() +{ + std::string url; + std::string country_code = app_config->get_country_code(); + + if (country_code == "US") { + url = "https://wiki.bambulab.com/en/knowledge-sharing/enable-lan-mode"; + } + else if (country_code == "CN") { + url = "https://wiki.bambulab.com/zh/knowledge-sharing/enable-lan-mode"; + } + else { + url = "https://wiki.bambulab.com/en/knowledge-sharing/enable-lan-mode"; + } + wxLaunchDefaultBrowser(url); +} + bool GUI_App::tabs_as_menu() const { return false; diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index e4d735448ce..34428d1705a 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -81,6 +81,7 @@ class ParamsDialog; class HMSQuery; class ModelMallDialog; class PingCodeBindDialog; +class NetworkErrorDialog; enum FileType @@ -393,9 +394,9 @@ private: bool get_side_menu_popup_status(); void set_side_menu_popup_status(bool status); void link_to_network_check(); - + void link_to_lan_only_wiki(); - const wxColour& get_label_clr_modified(){ return m_color_label_modified; } + const wxColour& get_label_clr_modified() { return m_color_label_modified; } const wxColour& get_label_clr_sys() { return m_color_label_sys; } const wxColour& get_label_clr_default() { return m_color_label_default; } const wxColour& get_window_default_clr(){ return m_color_window_default; } @@ -574,6 +575,8 @@ private: ModelMallDialog* m_mall_publish_dialog{ nullptr }; PingCodeBindDialog* m_ping_code_binding_dialog{ nullptr }; + NetworkErrorDialog* m_server_error_dialog { nullptr }; + void set_download_model_url(std::string url) {m_mall_model_download_url = url;} void set_download_model_name(std::string name) {m_mall_model_download_name = name;} std::string get_download_model_url() {return m_mall_model_download_url;} diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index 3d67c5c2e52..7be96c48d68 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -660,6 +660,93 @@ wxBoxSizer *Newer3mfVersionDialog::get_btn_sizer() return horizontal_sizer; } +NetworkErrorDialog::NetworkErrorDialog(wxWindow* parent) + : DPIDialog(parent ? parent : nullptr, wxID_ANY, _L("Server Exception"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX) +{ + this->SetBackgroundColour(*wxWHITE); + std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str(); + SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO)); + + wxBoxSizer* sizer_main = new wxBoxSizer(wxVERTICAL); + + auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL); + m_line_top->SetBackgroundColour(wxColour(166, 169, 170)); + + wxBoxSizer* sizer_bacis_text = new wxBoxSizer(wxVERTICAL); + + m_text_basic = new Label(this, _L("The server is unable to respond. Please click the link below to check the server status.")); + m_text_basic->SetForegroundColour(0x323A3C); + m_text_basic->SetMinSize(wxSize(FromDIP(450), -1)); + m_text_basic->SetMaxSize(wxSize(FromDIP(450), -1)); + m_text_basic->Wrap(FromDIP(450)); + m_text_basic->SetFont(::Label::Body_14); + sizer_bacis_text->Add(m_text_basic, 0, wxALL, 0); + + + wxBoxSizer* sizer_link = new wxBoxSizer(wxVERTICAL); + + m_link_server_state = new wxHyperlinkCtrl(this, wxID_ANY, _L("Check the status of current system services"), ""); + m_link_server_state->SetFont(::Label::Body_13); + m_link_server_state->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {wxGetApp().link_to_network_check(); }); + m_link_server_state->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_HAND); }); + m_link_server_state->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_ARROW); }); + + sizer_link->Add(m_link_server_state, 0, wxALL, 0); + + + wxBoxSizer* sizer_help = new wxBoxSizer(wxVERTICAL); + + m_text_proposal = new Label(this, _L("If the server is in a fault state, you can temporarily use offline printing or local network printing.")); + m_text_proposal->SetMinSize(wxSize(FromDIP(450), -1)); + m_text_proposal->SetMaxSize(wxSize(FromDIP(450), -1)); + m_text_proposal->Wrap(FromDIP(450)); + m_text_proposal->SetFont(::Label::Body_14); + m_text_proposal->SetForegroundColour(0x323A3C); + + m_text_wiki = new wxHyperlinkCtrl(this, wxID_ANY, _L("How to use LAN only mode"), ""); + m_text_wiki->SetFont(::Label::Body_13); + m_text_wiki->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {wxGetApp().link_to_lan_only_wiki(); }); + m_text_wiki->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_HAND); }); + m_text_wiki->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_ARROW); }); + + sizer_help->Add(m_text_proposal, 0, wxEXPAND, 0); + sizer_main->Add(0, 0, 0, wxTOP, 6); + sizer_help->Add(m_text_wiki, 0, wxALL, 0); + + wxBoxSizer* sizer_button = new wxBoxSizer(wxHORIZONTAL); + sizer_button->Add(0, 0, 1, wxEXPAND, 5); + + auto bt_enable = StateColor(std::pair(wxColour(27, 136, 68), StateColor::Pressed), std::pair(wxColour(61, 203, 115), StateColor::Hovered), + std::pair(wxColour(0, 174, 66), StateColor::Normal)); + + m_button_confirm = new Button(this, _L("Confirm")); + m_button_confirm->SetBackgroundColor(bt_enable); + m_button_confirm->SetBorderColor(bt_enable); + m_button_confirm->SetTextColor(StateColor::darkModeColorFor("#FFFFFE")); + m_button_confirm->SetMinSize(wxSize(FromDIP(68), FromDIP(23))); + m_button_confirm->SetMinSize(wxSize(FromDIP(68), FromDIP(23))); + m_button_confirm->SetCornerRadius(12); + m_button_confirm->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {EndModal(wxCLOSE);}); + + sizer_button->Add(m_button_confirm, 0, wxALL, 5); + + sizer_main->Add(m_line_top, 0, wxEXPAND, 0); + sizer_main->Add(0, 0, 0, wxTOP, 20); + sizer_main->Add(sizer_bacis_text, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); + sizer_main->Add(0, 0, 0, wxTOP, 6); + sizer_main->Add(sizer_link, 0, wxLEFT | wxRIGHT, 15); + sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, 8); + sizer_main->Add(sizer_help, 1, wxLEFT | wxRIGHT, 15); + sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, 8); + sizer_main->Add(sizer_button, 1, wxEXPAND | wxLEFT | wxRIGHT, 15); + sizer_main->Add(0, 0, 0, wxTOP, 18); + + SetSizer(sizer_main); + Layout(); + sizer_main->Fit(this); + Centre(wxBOTH); +} + } // namespace GUI } // namespace Slic3r diff --git a/src/slic3r/GUI/MsgDialog.hpp b/src/slic3r/GUI/MsgDialog.hpp index e62251af7d5..592eeb7345d 100644 --- a/src/slic3r/GUI/MsgDialog.hpp +++ b/src/slic3r/GUI/MsgDialog.hpp @@ -410,6 +410,22 @@ private: wxStaticText *m_msg_text = nullptr; }; + +class NetworkErrorDialog : public DPIDialog +{ +public: + NetworkErrorDialog(wxWindow* parent); + ~NetworkErrorDialog() {}; + virtual void on_dpi_changed(const wxRect& suggested_rect) {}; + +private: + Label* m_text_basic; + wxHyperlinkCtrl* m_link_server_state; + Label* m_text_proposal; + wxHyperlinkCtrl* m_text_wiki; + Button* m_button_confirm; +}; + } } diff --git a/src/slic3r/Utils/NetworkAgent.cpp b/src/slic3r/Utils/NetworkAgent.cpp index 904471848db..4541bb680f2 100644 --- a/src/slic3r/Utils/NetworkAgent.cpp +++ b/src/slic3r/Utils/NetworkAgent.cpp @@ -76,6 +76,7 @@ func_build_login_info NetworkAgent::build_login_info_ptr = nullptr func_get_model_id_from_desgin_id NetworkAgent::get_model_id_from_desgin_id_ptr = nullptr; func_ping_bind NetworkAgent::ping_bind_ptr = nullptr; func_bind_detect NetworkAgent::bind_detect_ptr = nullptr; +func_set_server_callback NetworkAgent::set_server_callback_ptr = nullptr; func_bind NetworkAgent::bind_ptr = nullptr; func_unbind NetworkAgent::unbind_ptr = nullptr; func_get_bambulab_host NetworkAgent::get_bambulab_host_ptr = nullptr; @@ -286,6 +287,7 @@ int NetworkAgent::initialize_network_module(bool using_backup) build_login_info_ptr = reinterpret_cast(get_network_function("bambu_network_build_login_info")); ping_bind_ptr = reinterpret_cast(get_network_function("bambu_network_ping_bind")); bind_detect_ptr = reinterpret_cast(get_network_function("bambu_network_bind_detect")); + set_server_callback_ptr = reinterpret_cast(get_network_function("bambu_network_set_server_callback")); get_model_id_from_desgin_id_ptr = reinterpret_cast(get_network_function("bambu_network_get_model_id_from_desgin_id")); bind_ptr = reinterpret_cast(get_network_function("bambu_network_bind")); unbind_ptr = reinterpret_cast(get_network_function("bambu_network_unbind")); @@ -1037,6 +1039,18 @@ int NetworkAgent::bind_detect(std::string dev_ip, std::string sec_link, detectRe return ret; } +int NetworkAgent::set_server_callback(OnServerErrFn fn) +{ + int ret = 0; + if (network_agent && set_server_callback_ptr) { + ret = set_server_callback_ptr(network_agent, fn); + if (ret) + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%") + % network_agent % ret; + } + return ret; +} + int NetworkAgent::bind(std::string dev_ip, std::string dev_id, std::string sec_link, std::string timezone, bool improved, OnUpdateStatusFn update_fn) { int ret = 0; diff --git a/src/slic3r/Utils/NetworkAgent.hpp b/src/slic3r/Utils/NetworkAgent.hpp index 1f419a191af..7f7d81c5f83 100644 --- a/src/slic3r/Utils/NetworkAgent.hpp +++ b/src/slic3r/Utils/NetworkAgent.hpp @@ -56,6 +56,7 @@ typedef std::string (*func_build_login_info)(void *agent); typedef int (*func_get_model_id_from_desgin_id)(void *agent, std::string& desgin_id, std::string& model_id); typedef int (*func_ping_bind)(void *agent, std::string ping_code); typedef int (*func_bind_detect)(void *agent, std::string dev_ip, std::string sec_link, detectResult& detect); +typedef int (*func_set_server_callback)(void *agent, OnServerErrFn fn); typedef int (*func_bind)(void *agent, std::string dev_ip, std::string dev_id, std::string sec_link, std::string timezone, bool improved, OnUpdateStatusFn update_fn); typedef int (*func_unbind)(void *agent, std::string dev_id); typedef std::string (*func_get_bambulab_host)(void *agent); @@ -174,6 +175,7 @@ public: int get_model_id_from_desgin_id(std::string& desgin_id, std::string& model_id); int ping_bind(std::string ping_code); int bind_detect(std::string dev_ip, std::string sec_link, detectResult& detect); + int set_server_callback(OnServerErrFn fn); int bind(std::string dev_ip, std::string dev_id, std::string sec_link, std::string timezone, bool improved, OnUpdateStatusFn update_fn); int unbind(std::string dev_id); std::string get_bambulab_host(); @@ -282,6 +284,7 @@ private: static func_get_model_id_from_desgin_id get_model_id_from_desgin_id_ptr; static func_ping_bind ping_bind_ptr; static func_bind_detect bind_detect_ptr; + static func_set_server_callback set_server_callback_ptr; static func_bind bind_ptr; static func_unbind unbind_ptr; static func_get_bambulab_host get_bambulab_host_ptr; diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index c6d12fa6e3f..c5377e087d9 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -138,6 +138,9 @@ typedef std::function ResultFn; typedef std::function CancelFn; typedef std::function info)> CheckFn; +//err callbacks +typedef std::function OnServerErrFn; + enum SendingPrintJobStage { PrintingStageCreate = 0, PrintingStageUpload = 1, From a78dc6472941b05de16ffcf2e158b3f482ac8492 Mon Sep 17 00:00:00 2001 From: tao wang Date: Thu, 10 Oct 2024 17:46:53 +0800 Subject: [PATCH 41/57] ENH:prevent 500 error pop from popping up multiple times jira:[for 500 err] Change-Id: I81c74e75ebaeb3fdc18d0fb34a63205e2be06878 (cherry picked from commit 2fcc7f826482644496db25e096f11334b7e539bf) --- src/slic3r/GUI/GUI_App.cpp | 14 +++++++++----- src/slic3r/GUI/MsgDialog.cpp | 3 +-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 0e8691cec95..cc81b7b09a7 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1572,13 +1572,17 @@ void GUI_App::init_networking_callbacks() // }); m_agent->set_server_callback([this](std::string url, int status) { - if (!m_server_error_dialog) { - m_server_error_dialog = new NetworkErrorDialog(mainframe); - } - if (!m_server_error_dialog->IsShown()) { + CallAfter([this]() { + if (m_server_error_dialog) { + m_server_error_dialog->EndModal(wxCLOSE); + m_server_error_dialog->Destroy(); + m_server_error_dialog = nullptr; + } + + m_server_error_dialog = new NetworkErrorDialog(mainframe); m_server_error_dialog->ShowModal(); - } + }); }); diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index 7be96c48d68..b9d168b8f50 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -710,7 +710,6 @@ NetworkErrorDialog::NetworkErrorDialog(wxWindow* parent) m_text_wiki->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_ARROW); }); sizer_help->Add(m_text_proposal, 0, wxEXPAND, 0); - sizer_main->Add(0, 0, 0, wxTOP, 6); sizer_help->Add(m_text_wiki, 0, wxALL, 0); wxBoxSizer* sizer_button = new wxBoxSizer(wxHORIZONTAL); @@ -735,7 +734,7 @@ NetworkErrorDialog::NetworkErrorDialog(wxWindow* parent) sizer_main->Add(sizer_bacis_text, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); sizer_main->Add(0, 0, 0, wxTOP, 6); sizer_main->Add(sizer_link, 0, wxLEFT | wxRIGHT, 15); - sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, 8); + sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(20)); sizer_main->Add(sizer_help, 1, wxLEFT | wxRIGHT, 15); sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, 8); sizer_main->Add(sizer_button, 1, wxEXPAND | wxLEFT | wxRIGHT, 15); From 2260263d3c8f84f4beb5f5c8062c67e1fc7ba91b Mon Sep 17 00:00:00 2001 From: tao wang Date: Fri, 11 Oct 2024 16:20:54 +0800 Subject: [PATCH 42/57] NEW:add options that are dont show again jira:[dont show again] Change-Id: I6a025f7eb0902a36088f712e7dd511e4c35411d2 (cherry picked from commit 3be065d5676a7b74611dedfad8c67a8661950860) --- src/slic3r/GUI/GUI_App.cpp | 16 ++++++++++++---- src/slic3r/GUI/MsgDialog.cpp | 33 +++++++++++++++++++++++++-------- src/slic3r/GUI/MsgDialog.hpp | 5 ++++- 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index cc81b7b09a7..ebcce7313e9 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1574,13 +1574,21 @@ void GUI_App::init_networking_callbacks() m_agent->set_server_callback([this](std::string url, int status) { CallAfter([this]() { - if (m_server_error_dialog) { - m_server_error_dialog->EndModal(wxCLOSE); + if (!m_server_error_dialog) { + /*m_server_error_dialog->EndModal(wxCLOSE); m_server_error_dialog->Destroy(); - m_server_error_dialog = nullptr; + m_server_error_dialog = nullptr;*/ + m_server_error_dialog = new NetworkErrorDialog(mainframe); + } + + if (m_server_error_dialog->m_show_again) { + return; + } + + if (m_server_error_dialog->IsShown()) { + return; } - m_server_error_dialog = new NetworkErrorDialog(mainframe); m_server_error_dialog->ShowModal(); }); }); diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index b9d168b8f50..dfe4de512b6 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -676,9 +676,9 @@ NetworkErrorDialog::NetworkErrorDialog(wxWindow* parent) m_text_basic = new Label(this, _L("The server is unable to respond. Please click the link below to check the server status.")); m_text_basic->SetForegroundColour(0x323A3C); - m_text_basic->SetMinSize(wxSize(FromDIP(450), -1)); - m_text_basic->SetMaxSize(wxSize(FromDIP(450), -1)); - m_text_basic->Wrap(FromDIP(450)); + m_text_basic->SetMinSize(wxSize(FromDIP(470), -1)); + m_text_basic->SetMaxSize(wxSize(FromDIP(470), -1)); + m_text_basic->Wrap(FromDIP(470)); m_text_basic->SetFont(::Label::Body_14); sizer_bacis_text->Add(m_text_basic, 0, wxALL, 0); @@ -697,9 +697,9 @@ NetworkErrorDialog::NetworkErrorDialog(wxWindow* parent) wxBoxSizer* sizer_help = new wxBoxSizer(wxVERTICAL); m_text_proposal = new Label(this, _L("If the server is in a fault state, you can temporarily use offline printing or local network printing.")); - m_text_proposal->SetMinSize(wxSize(FromDIP(450), -1)); - m_text_proposal->SetMaxSize(wxSize(FromDIP(450), -1)); - m_text_proposal->Wrap(FromDIP(450)); + m_text_proposal->SetMinSize(wxSize(FromDIP(470), -1)); + m_text_proposal->SetMaxSize(wxSize(FromDIP(470), -1)); + m_text_proposal->Wrap(FromDIP(470)); m_text_proposal->SetFont(::Label::Body_14); m_text_proposal->SetForegroundColour(0x323A3C); @@ -713,7 +713,21 @@ NetworkErrorDialog::NetworkErrorDialog(wxWindow* parent) sizer_help->Add(m_text_wiki, 0, wxALL, 0); wxBoxSizer* sizer_button = new wxBoxSizer(wxHORIZONTAL); - sizer_button->Add(0, 0, 1, wxEXPAND, 5); + + /*dont show again*/ + auto checkbox = new ::CheckBox(this); + checkbox->SetValue(false); + + + auto checkbox_title = new Label(this, _L("Dont't show this dialog again")); + checkbox_title->SetForegroundColour(0x323A3C); + checkbox_title->SetFont(::Label::Body_14); + checkbox_title->Wrap(-1); + + checkbox->Bind(wxEVT_TOGGLEBUTTON, [this, checkbox](wxCommandEvent &e) { + m_show_again = checkbox->GetValue(); + e.Skip(); + }); auto bt_enable = StateColor(std::pair(wxColour(27, 136, 68), StateColor::Pressed), std::pair(wxColour(61, 203, 115), StateColor::Hovered), std::pair(wxColour(0, 174, 66), StateColor::Normal)); @@ -727,6 +741,9 @@ NetworkErrorDialog::NetworkErrorDialog(wxWindow* parent) m_button_confirm->SetCornerRadius(12); m_button_confirm->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {EndModal(wxCLOSE);}); + sizer_button->Add(checkbox, 0, wxALL, 5); + sizer_button->Add(checkbox_title, 0, wxALL, 5); + sizer_button->Add(0, 0, 1, wxEXPAND, 5); sizer_button->Add(m_button_confirm, 0, wxALL, 5); sizer_main->Add(m_line_top, 0, wxEXPAND, 0); @@ -736,7 +753,7 @@ NetworkErrorDialog::NetworkErrorDialog(wxWindow* parent) sizer_main->Add(sizer_link, 0, wxLEFT | wxRIGHT, 15); sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(20)); sizer_main->Add(sizer_help, 1, wxLEFT | wxRIGHT, 15); - sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, 8); + sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(20)); sizer_main->Add(sizer_button, 1, wxEXPAND | wxLEFT | wxRIGHT, 15); sizer_main->Add(0, 0, 0, wxTOP, 18); diff --git a/src/slic3r/GUI/MsgDialog.hpp b/src/slic3r/GUI/MsgDialog.hpp index 592eeb7345d..84a71b37589 100644 --- a/src/slic3r/GUI/MsgDialog.hpp +++ b/src/slic3r/GUI/MsgDialog.hpp @@ -423,7 +423,10 @@ private: wxHyperlinkCtrl* m_link_server_state; Label* m_text_proposal; wxHyperlinkCtrl* m_text_wiki; - Button* m_button_confirm; + Button * m_button_confirm; + +public: + bool m_show_again{false}; }; } From 88592484075489beda0520705aa4e3687c3c1edd Mon Sep 17 00:00:00 2001 From: tao wang Date: Sat, 2 Nov 2024 17:53:17 +0800 Subject: [PATCH 43/57] FIX:will not display 500 error dialog when sending print jira:[for network error] Change-Id: Id5fbd2182d3c1948f67382d81f8bf558daffa1c6 (cherry picked from commit 5b7cc2495cdfe8889cbddc9390bf096f72e52604) --- src/slic3r/GUI/GUI_App.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index ebcce7313e9..57eabca839d 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1581,6 +1581,10 @@ void GUI_App::init_networking_callbacks() m_server_error_dialog = new NetworkErrorDialog(mainframe); } + if(plater()->get_select_machine_dialog() && plater()->get_select_machine_dialog()->IsShown()){ + return; + } + if (m_server_error_dialog->m_show_again) { return; } From ae8d1d90acc6411cfc87eeb616a1047baae42075 Mon Sep 17 00:00:00 2001 From: gerrit Date: Mon, 4 Nov 2024 10:56:49 +0800 Subject: [PATCH 44/57] ci: update network module based on commit d2e9254 Change-Id: I9d4a7c1036b0dc3ad7fe49cac5d1a225e700ca9e (cherry picked from commit 81f1ea9b03fd36865f6da4366d89fdee0692d321) --- src/slic3r/Utils/bambu_networking.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index c5377e087d9..690f30b0fea 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -95,7 +95,7 @@ namespace BBL { #define BAMBU_NETWORK_LIBRARY "bambu_networking" #define BAMBU_NETWORK_AGENT_NAME "bambu_network_agent" -#define BAMBU_NETWORK_AGENT_VERSION "01.10.00.07" +#define BAMBU_NETWORK_AGENT_VERSION "01.10.00.08" //iot preset type strings #define IOT_PRINTER_TYPE_STRING "printer" From 4bbbf9c023cb51dbaec5d23dfef2397667ccab83 Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Mon, 4 Nov 2024 14:36:18 +0800 Subject: [PATCH 45/57] FIX: Force load ams list when click sync button Change-Id: I579adc9586e0bca85c20be2784b7513361b38f7e Jira: none (cherry picked from commit 9c1afdc63c3b1f451d0c8e344eb476e490d1988d) --- src/slic3r/GUI/Plater.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 589a18aaa77..3e5474fbf3a 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1751,6 +1751,11 @@ void Sidebar::load_ams_list(std::string const &device, MachineObject* obj) void Sidebar::sync_ams_list() { + // Force load ams list + auto obj = wxGetApp().getDeviceManager()->get_selected_machine(); + if (obj) + GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj); + auto & list = wxGetApp().preset_bundle->filament_ams_list; if (list.empty()) { MessageDialog dlg(this, From ff29b67a0050e41a373a03e33f6a2d2f23deaabc Mon Sep 17 00:00:00 2001 From: tao wang Date: Tue, 5 Nov 2024 12:08:19 +0800 Subject: [PATCH 46/57] FIX:Fixed the use of wxwidget method in other threads jira:[for thread issue] Change-Id: I62f5b6913d9bc25ac6c81517ef20f28fa34d0124 (cherry picked from commit b5a6fe52b5fd2f3a07a51c05e21c6315af147f9e) --- src/slic3r/GUI/ReleaseNote.cpp | 76 +++++++++++++++++++--------------- src/slic3r/GUI/ReleaseNote.hpp | 4 ++ 2 files changed, 46 insertions(+), 34 deletions(-) diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index 50681381410..99faf79775f 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -36,11 +36,13 @@ wxDEFINE_EVENT(EVT_CHECKBOX_CHANGE, wxCommandEvent); wxDEFINE_EVENT(EVT_ENTER_IP_ADDRESS, wxCommandEvent); wxDEFINE_EVENT(EVT_CLOSE_IPADDRESS_DLG, wxCommandEvent); wxDEFINE_EVENT(EVT_CHECK_IP_ADDRESS_FAILED, wxCommandEvent); +wxDEFINE_EVENT(EVT_CHECK_IP_ADDRESS_LAYOUT, wxCommandEvent); wxDEFINE_EVENT(EVT_SECONDARY_CHECK_RETRY, wxCommandEvent); wxDEFINE_EVENT(EVT_PRINT_ERROR_STOP, wxCommandEvent); wxDEFINE_EVENT(EVT_UPDATE_NOZZLE, wxCommandEvent); wxDEFINE_EVENT(EVT_JUMP_TO_HMS, wxCommandEvent); wxDEFINE_EVENT(EVT_JUMP_TO_LIVEVIEW, wxCommandEvent); +wxDEFINE_EVENT(EVT_UPDATE_TEXT_MSG, wxCommandEvent); ReleaseNoteDialog::ReleaseNoteDialog(Plater *plater /*= nullptr*/) : DPIDialog(static_cast(wxGetApp().mainframe), wxID_ANY, _L("Release Note"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX) @@ -1754,6 +1756,14 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow *parent) on_cancel(); closeTimer->Stop(); }); + + Bind(EVT_UPDATE_TEXT_MSG, &InputIpAddressDialog::update_test_msg_event, this); + Bind(EVT_CHECK_IP_ADDRESS_LAYOUT, [this](auto& e) { + int mode = e.GetInt(); + switch_input_panel(mode); + Layout(); + Fit(); + }); } void InputIpAddressDialog::switch_input_panel(int index) @@ -1886,9 +1896,27 @@ void InputIpAddressDialog::on_ok(wxMouseEvent& evt) m_thread = new boost::thread(boost::bind(&InputIpAddressDialog::workerThreadFunc, this, str_ip, str_access_code, str_sn, str_model_id)); } +void InputIpAddressDialog::update_test_msg_event(wxCommandEvent& evt) +{ + wxString text = evt.GetString(); + bool beconnect = evt.GetInt(); + update_test_msg(text, beconnect); + Layout(); + Fit(); +} + +void InputIpAddressDialog::post_update_test_msg(wxString text, bool beconnect) +{ + wxCommandEvent event(EVT_UPDATE_TEXT_MSG); + event.SetEventObject(this); + event.SetString(text); + event.SetInt(beconnect); + wxPostEvent(this, event); +} + void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_access_code, std::string sn, std::string model_id) { - update_test_msg(_L("connecting..."), true); + post_update_test_msg(_L("connecting..."), true); detectResult detectData; auto result = -1; @@ -1903,44 +1931,31 @@ void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_ } if (result < 0) { - update_test_msg(wxEmptyString, true); + post_update_test_msg(wxEmptyString, true); if (result == -1) { - update_test_msg(_L("Failed to connect to printer."), false); + post_update_test_msg(_L("Failed to connect to printer."), false); } else if (result == -2) { - update_test_msg(_L("Failed to publish login request."), false); + post_update_test_msg(_L("Failed to publish login request."), false); } else if (result == -3) { - switch_input_panel(1); - //update_test_msg(_L("The device does not support using IP and Access Code for connection."), false); + wxCommandEvent event(EVT_CHECK_IP_ADDRESS_LAYOUT); + event.SetEventObject(this); + event.SetInt(1); + wxPostEvent(this, event); } - - - /*m_button_ok->Enable(true); - StateColor btn_bg_green(std::pair(wxColour(61, 203, 115), StateColor::Pressed), std::pair(wxColour(61, 203, 115), StateColor::Hovered), - std::pair(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal)); - m_button_ok->SetTextColor(StateColor::darkModeColorFor("#FFFFFE")); - m_button_ok->SetBackgroundColor(btn_bg_green); - m_button_ok->SetBorderColor(*wxWHITE);*/ - - Layout(); - Fit(); return; } if (detectData.bind_state == "occupied") { - update_test_msg(wxEmptyString, true); - update_test_msg(_L("The printer has already been bound."), false); - Layout(); - Fit(); + post_update_test_msg(wxEmptyString, true); + post_update_test_msg(_L("The printer has already been bound."), false); return; } if (detectData.connect_type == "cloud") { - update_test_msg(wxEmptyString, true); - update_test_msg(_L("The printer mode is incorrect, please switch to LAN Only."), false); - Layout(); - Fit(); + post_update_test_msg(wxEmptyString, true); + post_update_test_msg(_L("The printer mode is incorrect, please switch to LAN Only."), false); return; } @@ -1956,21 +1971,15 @@ void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_ closeCount = 1; - update_test_msg(wxEmptyString, true); - update_test_msg(wxString::Format(_L("Connecting to printer... The dialog will close later"), closeCount), true); + post_update_test_msg(wxEmptyString, true); + post_update_test_msg(wxString::Format(_L("Connecting to printer... The dialog will close later"), closeCount), true); closeTimer->Start(1000); - - Layout(); - Fit(); - Refresh(true); } void InputIpAddressDialog::OnTimer(wxTimerEvent& event) { if (closeCount > 0) { closeCount--; - //update_test_msg(wxString::Format(_L("Printer binding successful. The dialog will close in %d seconds"), closeCount), true); - //Refresh(); } else { closeTimer->Stop(); @@ -1993,7 +2002,6 @@ void InputIpAddressDialog::on_check_ip_address_failed(wxCommandEvent& evt) } else { update_test_msg(_L("Connection failed! If your IP and Access Code is correct, \nplease move to step 3 for troubleshooting network issues"), false); - //m_trouble_shoot->Show(); Layout(); Fit(); } diff --git a/src/slic3r/GUI/ReleaseNote.hpp b/src/slic3r/GUI/ReleaseNote.hpp index 5e8b9a52ddd..e92e7064c9f 100644 --- a/src/slic3r/GUI/ReleaseNote.hpp +++ b/src/slic3r/GUI/ReleaseNote.hpp @@ -50,6 +50,7 @@ wxDECLARE_EVENT(EVT_UPDATE_NOZZLE, wxCommandEvent); wxDECLARE_EVENT(EVT_LOAD_VAMS_TRAY, wxCommandEvent); wxDECLARE_EVENT(EVT_JUMP_TO_HMS, wxCommandEvent); wxDECLARE_EVENT(EVT_JUMP_TO_LIVEVIEW, wxCommandEvent); +wxDECLARE_EVENT(EVT_UPDATE_TEXT_MSG, wxCommandEvent); class ReleaseNoteDialog : public DPIDialog { @@ -323,6 +324,8 @@ public: void check_ip_address_failed(int result); void on_check_ip_address_failed(wxCommandEvent& evt); void on_ok(wxMouseEvent& evt); + void update_test_msg_event(wxCommandEvent &evt); + void post_update_test_msg(wxString text, bool beconnect); void workerThreadFunc(std::string str_ip, std::string str_access_code, std::string sn, std::string model_id); void OnTimer(wxTimerEvent& event); void on_text(wxCommandEvent& evt); @@ -334,6 +337,7 @@ wxDECLARE_EVENT(EVT_CLOSE_IPADDRESS_DLG, wxCommandEvent); wxDECLARE_EVENT(EVT_CHECKBOX_CHANGE, wxCommandEvent); wxDECLARE_EVENT(EVT_ENTER_IP_ADDRESS, wxCommandEvent); wxDECLARE_EVENT(EVT_CHECK_IP_ADDRESS_FAILED, wxCommandEvent); +wxDECLARE_EVENT(EVT_CHECK_IP_ADDRESS_LAYOUT, wxCommandEvent); }} // namespace Slic3r::GUI From dc544d56f7bea10f98b15fdd95a478365999c3ba Mon Sep 17 00:00:00 2001 From: tao wang Date: Wed, 6 Nov 2024 11:39:41 +0800 Subject: [PATCH 47/57] FIX:fixed that macOS will hang up as direct connected device jira:[STUDIO-8630] Change-Id: I96562bd11de807435fc6a2d81501800b0cf110b1 (cherry picked from commit c8a8d9f19758a33d713054eb93cd5084b38ac26a) --- src/slic3r/GUI/ReleaseNote.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index 99faf79775f..619c6e25f50 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -1892,8 +1892,7 @@ void InputIpAddressDialog::on_ok(wxMouseEvent& evt) Refresh(); Layout(); Fit(); - - m_thread = new boost::thread(boost::bind(&InputIpAddressDialog::workerThreadFunc, this, str_ip, str_access_code, str_sn, str_model_id)); + m_thread = new boost::thread(boost::bind(&InputIpAddressDialog::workerThreadFunc, this, str_ip, str_access_code, str_sn, str_model_id)); } void InputIpAddressDialog::update_test_msg_event(wxCommandEvent& evt) @@ -1921,7 +1920,13 @@ void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_ detectResult detectData; auto result = -1; if (current_input_index == 0) { + +#ifdef __APPLE__ + result = -3; +#else result = wxGetApp().getAgent()->bind_detect(str_ip, "secure", detectData); +#endif + } else { result = 0; detectData.dev_name = sn; @@ -1973,8 +1978,13 @@ void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_ post_update_test_msg(wxEmptyString, true); post_update_test_msg(wxString::Format(_L("Connecting to printer... The dialog will close later"), closeCount), true); - + +#ifdef __APPLE__ + wxCommandEvent event(EVT_CLOSE_IPADDRESS_DLG); + wxPostEvent(this, event); +#else closeTimer->Start(1000); +#endif } void InputIpAddressDialog::OnTimer(wxTimerEvent& event) { From 4464d3c6b2a544cdd7f82a919fdc0d0e2ba36a2a Mon Sep 17 00:00:00 2001 From: tao wang Date: Tue, 5 Nov 2024 20:35:31 +0800 Subject: [PATCH 48/57] FIX:Fixed printer name display error jira:[STUDIO-8619] Change-Id: Ie9ce0cb39623eefa3973a342b447ab2f2a765d28 (cherry picked from commit c41eb657818bb29abb3a2e7c6df7b7d489c80592) --- src/slic3r/GUI/DeviceManager.cpp | 14 ++++++++++---- src/slic3r/GUI/DeviceManager.hpp | 9 +++++---- src/slic3r/GUI/ReleaseNote.cpp | 13 +++++++++---- src/slic3r/GUI/ReleaseNote.hpp | 1 + 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 3712139d056..7da443eba0c 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -5999,9 +5999,9 @@ std::vector DeviceManager::get_compatible_machine(std::string type_ return compatible_machine; } -std::vector DeviceManager::get_all_model_id() +boost::bimaps::bimap DeviceManager::get_all_model_id_with_name() { - std::vector models; + boost::bimaps::bimap models; std::vector m_files; wxDir dir(Slic3r::resources_dir() + "/printers/"); @@ -6026,8 +6026,14 @@ std::vector DeviceManager::get_all_model_id() json_file >> jj; if (jj.contains("00.00.00.00")) { json const &printer = jj["00.00.00.00"]; - if (printer.contains("model_id")) { - for (auto res : printer["model_id"]) models.emplace_back(res.get()); + + std::string model_id; + std::string display_name; + if (printer.contains("model_id")) {model_id = printer["model_id"].get();} + if (printer.contains("display_name")) {display_name = printer["display_name"].get();} + + if (!model_id.empty() && !display_name.empty()) { + models.left.insert(make_pair(model_id, display_name)); } } } diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 466b611cb64..ec8f9abd216 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -13,6 +13,7 @@ #include "libslic3r/ProjectTask.hpp" #include "slic3r/Utils/json_diff.hpp" #include "slic3r/Utils/NetworkAgent.hpp" +#include "boost/bimap/bimap.hpp" #include "CameraPopup.hpp" #include "libslic3r/calib.hpp" #include "libslic3r/Utils.hpp" @@ -1077,12 +1078,12 @@ public: static std::string get_printer_ams_img(std::string type_str); static PrinterArch get_printer_arch(std::string type_str); static std::string get_ftp_folder(std::string type_str); - static bool get_printer_is_enclosed(std::string type_str); + static bool get_printer_is_enclosed(std::string type_str); + static bool load_filaments_blacklist_config(); + static void check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, bool& in_blacklist, std::string& ac, std::string& info); static std::vector get_resolution_supported(std::string type_str); static std::vector get_compatible_machine(std::string type_str); - static std::vector get_all_model_id(); - static bool load_filaments_blacklist_config(); - static void check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, bool& in_blacklist, std::string& ac, std::string& info); + static boost::bimaps::bimap get_all_model_id_with_name(); static std::string load_gcode(std::string type_str, std::string gcode_file); }; diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index 619c6e25f50..7af9cd5b6b7 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -1563,9 +1563,9 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow *parent) m_input_modelID->SetMinSize(wxSize(FromDIP(168), FromDIP(28))); m_input_modelID->SetMaxSize(wxSize(FromDIP(168), FromDIP(28))); - auto models = DeviceManager::get_all_model_id(); - for (int i = 0; i < models.size(); i++) { - m_input_modelID->Append(models[i]); + m_models_map = DeviceManager::get_all_model_id_with_name(); + for (auto it = m_models_map.begin(); it != m_models_map.end(); ++it) { + m_input_modelID->Append(it->right); m_input_modelID->SetSelection(0); } @@ -1883,7 +1883,12 @@ void InputIpAddressDialog::on_ok(wxMouseEvent& evt) std::string str_ip = m_input_ip->GetTextCtrl()->GetValue().ToStdString(); std::string str_access_code = m_input_access_code->GetTextCtrl()->GetValue().ToStdString(); std::string str_sn = m_input_sn->GetTextCtrl()->GetValue().ToStdString(); - std::string str_model_id = m_input_modelID->GetStringSelection().ToStdString(); + std::string str_model_id = ""; + + auto it = m_models_map.right.find(m_input_modelID->GetStringSelection().ToStdString()); + if (it != m_models_map.right.end()) { + str_model_id = it->get_left(); + } m_button_ok->Enable(false); m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90)); diff --git a/src/slic3r/GUI/ReleaseNote.hpp b/src/slic3r/GUI/ReleaseNote.hpp index e92e7064c9f..ba8901b26e9 100644 --- a/src/slic3r/GUI/ReleaseNote.hpp +++ b/src/slic3r/GUI/ReleaseNote.hpp @@ -314,6 +314,7 @@ public: int m_result; int current_input_index {0}; std::shared_ptr m_status_bar; + boost::bimaps::bimap m_models_map; void switch_input_panel(int index); void on_cancel(); From d110c90a52a62bc3fd896d4d55ae10a74b31499c Mon Sep 17 00:00:00 2001 From: gerrit Date: Fri, 15 Nov 2024 09:06:36 +0800 Subject: [PATCH 49/57] ci: update network module based on commit adbaa57 Change-Id: I34d6ae1a192e3eb629a37a175626da0007208746 (cherry picked from commit 4be224611afaa7d3a113d8f6c62c13061c8946e6) --- src/slic3r/Utils/bambu_networking.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index 690f30b0fea..62390d06fa3 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -95,7 +95,7 @@ namespace BBL { #define BAMBU_NETWORK_LIBRARY "bambu_networking" #define BAMBU_NETWORK_AGENT_NAME "bambu_network_agent" -#define BAMBU_NETWORK_AGENT_VERSION "01.10.00.08" +#define BAMBU_NETWORK_AGENT_VERSION "01.10.01.50" //iot preset type strings #define IOT_PRINTER_TYPE_STRING "printer" From 8627d45117d5b8e7c2a370fbf9bd5fc7a664b5b2 Mon Sep 17 00:00:00 2001 From: gerrit Date: Fri, 15 Nov 2024 09:40:20 +0800 Subject: [PATCH 50/57] ci: update network module based on commit bf743ea Change-Id: Ic6104cad06da962e61834d7b072f2155ae729928 (cherry picked from commit 5f8b68601b1766568ec604a5b75d8a68efb24ade) --- src/slic3r/Utils/bambu_networking.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index 62390d06fa3..0c7b4fddb12 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -95,7 +95,7 @@ namespace BBL { #define BAMBU_NETWORK_LIBRARY "bambu_networking" #define BAMBU_NETWORK_AGENT_NAME "bambu_network_agent" -#define BAMBU_NETWORK_AGENT_VERSION "01.10.01.50" +#define BAMBU_NETWORK_AGENT_VERSION "01.10.01.01" //iot preset type strings #define IOT_PRINTER_TYPE_STRING "printer" From d7b8ce0a08ef108439f0a7d6b022ad5ac99166d5 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Thu, 23 Jan 2025 11:37:27 +0800 Subject: [PATCH 51/57] Fix build --- src/slic3r/GUI/MediaPlayCtrl.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/MediaPlayCtrl.cpp b/src/slic3r/GUI/MediaPlayCtrl.cpp index 923484b0a36..c9bcef98469 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.cpp +++ b/src/slic3r/GUI/MediaPlayCtrl.cpp @@ -212,6 +212,7 @@ wxString hide_id_middle_string(wxString const &str, size_t offset = 0, size_t le wxString hide_passwd(wxString url, std::vector const &passwords) { +#if BBL_RELEASE_TO_PUBLIC for (auto &p : passwords) { auto i = url.find(p); if (i == wxString::npos) @@ -228,6 +229,7 @@ wxString hide_passwd(wxString url, std::vector const &passwords) else if (j == url.length() || url[j] == '@' || url[j] == '&') url.replace(i, l, l, wxUniChar('*')); } +#endif return url; } @@ -312,8 +314,8 @@ void MediaPlayCtrl::Play() m_disable_lan = false; m_failed_code = 0; m_last_state = MEDIASTATE_INITIALIZING; - - if (!m_remote_support) { // not support tutk + + if (!m_remote_proto) { // not support tutk m_failed_code = -1; m_url = "bambu:///local/"; Stop(_L("Please enter the IP of printer to connect.")); From 3fba0a893742d263d8213551db4db014a1aa495c Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Thu, 23 Jan 2025 12:51:05 +0800 Subject: [PATCH 52/57] Fix flatpack build --- src/slic3r/GUI/DeviceManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 7da443eba0c..2024e9451b0 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -18,6 +18,7 @@ #include #include #include "fast_float/fast_float.h" +#include #define CALI_DEBUG #define MINUTE_30 1800000 //ms From 0af769496cbdeeb0862e963b6e8e19c380190572 Mon Sep 17 00:00:00 2001 From: tao wang Date: Thu, 10 Oct 2024 16:40:18 +0800 Subject: [PATCH 53/57] NEW:clear token when account logs out jira:[for logout] Change-Id: Iafbdc9244419bb689a9626251064517ec5544c3d (cherry picked from commit 6472fbdc6a7e7380538b6e2da29f802831a93157) --- src/slic3r/GUI/GUI_App.cpp | 2 +- src/slic3r/Utils/NetworkAgent.cpp | 4 ++-- src/slic3r/Utils/NetworkAgent.hpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 57eabca839d..0e17f0dcd11 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -3730,7 +3730,7 @@ void GUI_App::request_user_logout() { if (m_agent && m_agent->is_user_login()) { // Update data first before showing dialogs - m_agent->user_logout(); + m_agent->user_logout(true); m_agent->set_user_selected_machine(""); /* delete old user settings */ bool transfer_preset_changes = false; diff --git a/src/slic3r/Utils/NetworkAgent.cpp b/src/slic3r/Utils/NetworkAgent.cpp index 4541bb680f2..47c3a7068e5 100644 --- a/src/slic3r/Utils/NetworkAgent.cpp +++ b/src/slic3r/Utils/NetworkAgent.cpp @@ -929,11 +929,11 @@ bool NetworkAgent::is_user_login() return ret; } -int NetworkAgent::user_logout() +int NetworkAgent::user_logout(bool request) { int ret = 0; if (network_agent && user_logout_ptr) { - ret = user_logout_ptr(network_agent); + ret = user_logout_ptr(network_agent, request); if (ret) BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%")%network_agent %ret; } diff --git a/src/slic3r/Utils/NetworkAgent.hpp b/src/slic3r/Utils/NetworkAgent.hpp index 7f7d81c5f83..fc006c8e093 100644 --- a/src/slic3r/Utils/NetworkAgent.hpp +++ b/src/slic3r/Utils/NetworkAgent.hpp @@ -45,7 +45,7 @@ typedef int (*func_send_message_to_printer)(void *agent, std::string dev_id, std typedef bool (*func_start_discovery)(void *agent, bool start, bool sending); typedef int (*func_change_user)(void *agent, std::string user_info); typedef bool (*func_is_user_login)(void *agent); -typedef int (*func_user_logout)(void *agent); +typedef int (*func_user_logout)(void *agent, bool request); typedef std::string (*func_get_user_id)(void *agent); typedef std::string (*func_get_user_name)(void *agent); typedef std::string (*func_get_user_avatar)(void *agent); @@ -164,7 +164,7 @@ public: bool start_discovery(bool start, bool sending); int change_user(std::string user_info); bool is_user_login(); - int user_logout(); + int user_logout(bool request = false); std::string get_user_id(); std::string get_user_name(); std::string get_user_avatar(); From c8f190b5ce0f76ee7e6b5fd8493fb14d7b34fc0d Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Thu, 23 Jan 2025 13:29:27 +0800 Subject: [PATCH 54/57] Sync with bbs --- src/slic3r/GUI/BindDialog.cpp | 2 +- src/slic3r/GUI/DeviceManager.cpp | 35 +++++++++++++------------------ src/slic3r/GUI/DeviceManager.hpp | 2 +- src/slic3r/GUI/GUI_App.cpp | 2 +- src/slic3r/GUI/GUI_App.hpp | 22 +++++++++---------- src/slic3r/GUI/MediaFilePanel.cpp | 13 ++++++------ src/slic3r/GUI/MediaFilePanel.h | 4 +++- src/slic3r/GUI/MsgDialog.cpp | 8 +++---- src/slic3r/GUI/ReleaseNote.hpp | 2 +- 9 files changed, 42 insertions(+), 48 deletions(-) diff --git a/src/slic3r/GUI/BindDialog.cpp b/src/slic3r/GUI/BindDialog.cpp index 0b3e989e8b8..3f4d3562b7b 100644 --- a/src/slic3r/GUI/BindDialog.cpp +++ b/src/slic3r/GUI/BindDialog.cpp @@ -2,10 +2,10 @@ #include "GUI_App.hpp" #include +#include #include #include #include "wx/evtloop.h" -#include #include #include #include diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 2024e9451b0..d9784422675 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -2668,7 +2668,6 @@ std::string MachineObject::setting_id_to_type(std::string setting_id, std::strin if (type.empty()) { type = tray_type; } BOOST_LOG_TRIVIAL(info) << "The values of tray_info_idx and tray_type do not match tray_info_idx " << setting_id << " tray_type " << tray_type << " system_type" << type; } - return type; } @@ -2700,7 +2699,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) if (j_pre.empty()) { return 0; } - if (j_pre.contains("print")) { if (m_active_state == NotActive) m_active_state = Active; if (j_pre["print"].contains("command")) { @@ -3083,9 +3081,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } } - if (jj.contains("command")) { - if (jj["command"].get() == "ams_change_filament") { if (jj.contains("errno")) { if (jj["errno"].is_number()) { @@ -3117,8 +3113,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } } } - - if (jj["command"].get() == "push_status") { m_push_count++; last_push_time = last_update_time; @@ -3283,7 +3277,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) if (jj.contains("project_id") && jj.contains("profile_id") && jj.contains("subtask_id") - ){ + ) { obj_subtask_id = jj["subtask_id"].get(); int plate_index = -1; @@ -3314,7 +3308,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } } - #pragma endregion #pragma region status @@ -3584,13 +3577,14 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) && jj["upgrade_state"]["dis_state"].get() == 3) { GUI::wxGetApp().CallAfter([this] { this->command_get_version(); - }); + }); } if (upgrade_display_hold_count > 0) upgrade_display_hold_count--; else upgrade_display_state = jj["upgrade_state"]["dis_state"].get(); - } else { + } + else { if (upgrade_display_hold_count > 0) upgrade_display_hold_count--; else { @@ -3641,7 +3635,8 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) new_ver_list.insert(std::make_pair(ver_info.name, ver_info)); } - } else { + } + else { new_ver_list.clear(); } } @@ -5331,6 +5326,8 @@ void DeviceManager::check_pushing() } } + + void DeviceManager::on_machine_alive(std::string json_str) { try { @@ -5855,7 +5852,7 @@ void DeviceManager::parse_user_print_info(std::string body) } } } - catch (std::exception&) { + catch (std::exception& e) { ; } } @@ -6094,15 +6091,11 @@ void DeviceManager::check_filaments_in_blacklist(std::string tag_vendor, std::st { vendor = prohibited_filament["vendor"].get(); type = prohibited_filament["type"].get(); - - if (GUI::wxGetApp().app_config->get("skip_ams_blacklist_check") == "true") { - - action = "warning"; - } - else { - - action = prohibited_filament["action"].get(); - } + if (GUI::wxGetApp().app_config->get("skip_ams_blacklist_check") == "true") { + action = "warning"; + } else { + action = prohibited_filament["action"].get(); + } description = prohibited_filament["description"].get(); description = blacklist_prompt[description].ToUTF8().data(); diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index ec8f9abd216..085d6356caf 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -2,11 +2,11 @@ #define slic3r_DeviceManager_hpp_ #include +#include #include #include #include #include -#include #include #include #include "nlohmann/json.hpp" diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 0e17f0dcd11..dbf08d54ad7 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1028,7 +1028,7 @@ void GUI_App::post_init() std::time_t lw_t = boost::filesystem::last_write_time(temp_path) ; files_vec.push_back({ lw_t, temp_path.filename().string() }); } - } catch (const std::exception &ex) { + } catch (const std::exception &) { } } std::sort(files_vec.begin(), files_vec.end(), []( diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 34428d1705a..5358795595d 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -1,13 +1,6 @@ #ifndef slic3r_GUI_App_hpp_ #define slic3r_GUI_App_hpp_ -#include -#include -#include -#include -#include -#include - #include #include #include "ImGuiWrapper.hpp" @@ -26,6 +19,13 @@ #include "slic3r/GUI/HttpServer.hpp" #include "../Utils/PrintHost.hpp" +#include +#include +#include +#include +#include +#include + #include #include @@ -275,7 +275,7 @@ private: std::unique_ptr m_other_instance_message_handler; std::unique_ptr m_single_instance_checker; std::string m_instance_hash_string; - size_t m_instance_hash_int; + size_t m_instance_hash_int; std::unique_ptr m_downloader; @@ -310,8 +310,8 @@ private: HttpServer m_http_server; bool m_show_gcode_window{true}; boost::thread m_check_network_thread; - public: - //try again when subscription fails +public: + //try again when subscription fails void on_start_subscribe_again(std::string dev_id); void check_filaments_in_blacklist(std::string tag_supplier, std::string tag_material, bool& in_blacklist, std::string& action, std::string& info); std::string get_local_models_path(); @@ -557,7 +557,7 @@ private: #endif /* __APPLE */ Sidebar& sidebar(); - GizmoObjectManipulation* obj_manipul(); + GizmoObjectManipulation *obj_manipul(); ObjectSettings* obj_settings(); ObjectList* obj_list(); ObjectLayers* obj_layers(); diff --git a/src/slic3r/GUI/MediaFilePanel.cpp b/src/slic3r/GUI/MediaFilePanel.cpp index 9ff4b7fd18a..dcc31d27ee4 100644 --- a/src/slic3r/GUI/MediaFilePanel.cpp +++ b/src/slic3r/GUI/MediaFilePanel.cpp @@ -255,7 +255,7 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj) m_button_management->Enable(false); SetSelecting(false); if (m_machine.empty()) { - m_image_grid->SetStatus(m_bmp_failed, _L("No printers.")); + m_image_grid->SetStatus(m_bmp_failed, _L("Please confirm if the printer is connected.")); } else { boost::shared_ptr fs(new PrinterFileSystem); fs->Attached(); @@ -296,7 +296,7 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj) switch (status) { case PrinterFileSystem::Initializing: icon = m_bmp_loading; msg = _L("Initializing..."); break; case PrinterFileSystem::Connecting: icon = m_bmp_loading; msg = _L("Connecting..."); break; - case PrinterFileSystem::Failed: icon = m_bmp_failed; if (extra != 1) msg = _L("Connect failed [%d]!"); break; + case PrinterFileSystem::Failed: icon = m_bmp_failed; if (extra != 1) msg = _L("Please check the network and try again, You can restart or update the printer if the issue persists."); break; case PrinterFileSystem::ListSyncing: icon = m_bmp_loading; msg = _L("Loading file list..."); break; case PrinterFileSystem::ListReady: icon = extra == 0 ? m_bmp_empty : m_bmp_failed; msg = extra == 0 ? _L("No files") : _L("Load failed"); break; } @@ -310,7 +310,6 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj) if (e.GetInt() == PrinterFileSystem::Initializing) fetchUrl(boost::weak_ptr(fs)); - err = fs->GetLastError(); if ((status == PrinterFileSystem::Failed && m_last_errors.find(err) == m_last_errors.end()) || status == PrinterFileSystem::ListReady) { m_last_errors.insert(fs->GetLastError()); @@ -429,7 +428,7 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr wfs) if (!fs || fs != m_image_grid->GetFileSystem()) return; if (!IsEnabled()) { m_waiting_enable = true; - m_image_grid->SetStatus(m_bmp_failed, _L("Initialize failed (Device connection not ready)!")); + m_image_grid->SetStatus(m_bmp_failed, _L("Please confirm if the printer is connected.")); fs->SetUrl("0"); return; } @@ -441,7 +440,7 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr wfs) return; } if (!m_sdcard_exist) { - m_image_grid->SetStatus(m_bmp_failed, _L("Initialize failed (Storage unavailable, insert SD card.)!")); + m_image_grid->SetStatus(m_bmp_failed, _L("Please check if the SD card is inserted into the printer.\nIf it still cannot be read, you can try formatting the SD card.")); fs->SetUrl("0"); return; } @@ -495,9 +494,9 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr wfs) boost::shared_ptr fs(wfs.lock()); if (!fs || fs != m_image_grid->GetFileSystem()) return; if (boost::algorithm::starts_with(url, "bambu:///")) { - fs->SetUrl(url + "&device=" + m + "&dev_ver=" + v); + fs->SetUrl(url); } else { - m_image_grid->SetStatus(m_bmp_failed, wxString::Format(_L("Initialize failed (%s)!"), url.empty() ? _L("Network unreachable") : from_u8(url))); + m_image_grid->SetStatus(m_bmp_failed, _L("Connection Failed. Please check the network and try again")); fs->SetUrl("3"); } }); diff --git a/src/slic3r/GUI/MediaFilePanel.h b/src/slic3r/GUI/MediaFilePanel.h index c22639304be..270542c5d90 100644 --- a/src/slic3r/GUI/MediaFilePanel.h +++ b/src/slic3r/GUI/MediaFilePanel.h @@ -8,9 +8,11 @@ #ifndef MediaFilePanel_h #define MediaFilePanel_h +#include + #include "GUI_Utils.hpp" #include "wxExtensions.hpp" -#include + #include class Button; diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index dfe4de512b6..f6190d24cab 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -638,7 +638,7 @@ wxBoxSizer *Newer3mfVersionDialog::get_btn_sizer() } }); } - + if (!file_version_newer) { m_later_btn = new Button(this, _L("Not for now")); m_later_btn->SetBackgroundColor(btn_bg_white); @@ -671,7 +671,7 @@ NetworkErrorDialog::NetworkErrorDialog(wxWindow* parent) auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL); m_line_top->SetBackgroundColour(wxColour(166, 169, 170)); - + wxBoxSizer* sizer_bacis_text = new wxBoxSizer(wxVERTICAL); m_text_basic = new Label(this, _L("The server is unable to respond. Please click the link below to check the server status.")); @@ -702,7 +702,7 @@ NetworkErrorDialog::NetworkErrorDialog(wxWindow* parent) m_text_proposal->Wrap(FromDIP(470)); m_text_proposal->SetFont(::Label::Body_14); m_text_proposal->SetForegroundColour(0x323A3C); - + m_text_wiki = new wxHyperlinkCtrl(this, wxID_ANY, _L("How to use LAN only mode"), ""); m_text_wiki->SetFont(::Label::Body_13); m_text_wiki->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {wxGetApp().link_to_lan_only_wiki(); }); @@ -719,7 +719,7 @@ NetworkErrorDialog::NetworkErrorDialog(wxWindow* parent) checkbox->SetValue(false); - auto checkbox_title = new Label(this, _L("Dont't show this dialog again")); + auto checkbox_title = new Label(this, _L("Don't show this dialog again")); checkbox_title->SetForegroundColour(0x323A3C); checkbox_title->SetFont(::Label::Body_14); checkbox_title->Wrap(-1); diff --git a/src/slic3r/GUI/ReleaseNote.hpp b/src/slic3r/GUI/ReleaseNote.hpp index ba8901b26e9..a290a9c2910 100644 --- a/src/slic3r/GUI/ReleaseNote.hpp +++ b/src/slic3r/GUI/ReleaseNote.hpp @@ -313,7 +313,7 @@ public: bool m_show_access_code{ false }; int m_result; int current_input_index {0}; - std::shared_ptr m_status_bar; + std::shared_ptr m_status_bar; boost::bimaps::bimap m_models_map; void switch_input_panel(int index); From f43ef2bdc04f73d42ed16e5659ffd5fb94a9ab15 Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Fri, 15 Nov 2024 08:10:51 +0800 Subject: [PATCH 55/57] ENH: version: bumped to 1.10.1 jira: no-jira Change-Id: Ic2acf61195d4290d5c4742f18a5d769ba3030e63 (cherry picked from commit aed9dd9dff74bb8ed93c34b5fde2cac0b3dfc88c) --- version.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.inc b/version.inc index 7eb37fdde40..a7f65e3ffe2 100644 --- a/version.inc +++ b/version.inc @@ -17,4 +17,4 @@ set(ORCA_VERSION_MAJOR ${CMAKE_MATCH_1}) set(ORCA_VERSION_MINOR ${CMAKE_MATCH_2}) set(ORCA_VERSION_PATCH ${CMAKE_MATCH_3}) -set(SLIC3R_VERSION "01.09.05.51") +set(SLIC3R_VERSION "01.10.01.50") From 95ff50acd6a70bd9fd1b61d596efe340e795ac14 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Thu, 23 Jan 2025 14:43:24 +0800 Subject: [PATCH 56/57] Fix stop button --- src/slic3r/GUI/MediaPlayCtrl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/slic3r/GUI/MediaPlayCtrl.cpp b/src/slic3r/GUI/MediaPlayCtrl.cpp index c9bcef98469..92367a5975e 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.cpp +++ b/src/slic3r/GUI/MediaPlayCtrl.cpp @@ -314,6 +314,7 @@ void MediaPlayCtrl::Play() m_disable_lan = false; m_failed_code = 0; m_last_state = MEDIASTATE_INITIALIZING; + m_button_play->SetIcon("media_stop"); if (!m_remote_proto) { // not support tutk m_failed_code = -1; From 38b587dbb490b7557d817a9bd6eed026243e6d73 Mon Sep 17 00:00:00 2001 From: tao wang Date: Tue, 15 Oct 2024 20:42:46 +0800 Subject: [PATCH 57/57] NEW:update printer config version Change-Id: I85432494b2e9a27dc97a1bb464f9f3b04bf5bc2f (cherry picked from commit 6fd4bda1d62e3e3921945bdcd9db71942b754fed) --- resources/printers/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/printers/version.txt b/resources/printers/version.txt index 0ba31624a9b..6b8ecb25504 100644 --- a/resources/printers/version.txt +++ b/resources/printers/version.txt @@ -1 +1 @@ -01.08.03.01 \ No newline at end of file +01.10.00.01 \ No newline at end of file