From 9d37ee4709fdb60bcbfe2b98778b73e604a4d47b Mon Sep 17 00:00:00 2001 From: Ian Chua Date: Fri, 14 Aug 2026 15:12:18 +0800 Subject: [PATCH] removed changes that are out of scope --- src/slic3r/GUI/DeviceManager.cpp | 24 ++++------- src/slic3r/Utils/BBLPrinterAgent.cpp | 61 ---------------------------- src/slic3r/Utils/BBLPrinterAgent.hpp | 10 ----- src/slic3r/Utils/IPrinterAgent.hpp | 10 ----- src/slic3r/Utils/NetworkAgent.cpp | 21 ---------- src/slic3r/Utils/NetworkAgent.hpp | 3 -- 6 files changed, 9 insertions(+), 120 deletions(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 48f3cb60fc..d8487f4660 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -1731,11 +1731,9 @@ int MachineObject::command_ams_user_settings(bool start_read_opt, bool tray_read int MachineObject::command_ams_calibrate(int ams_id) { - if (!m_agent) return -1; - int rtn = m_agent->command_ams_calibrate(get_dev_id(), ams_id, MachineObject::m_sequence_id++, is_lan_mode_printer()); - if (rtn == ORCA_NETWORK_ERR_CMD_NOT_SUPPORTED || rtn == ORCA_NETWORK_ERR_CAP_NOT_AVAILABLE) - show_unsupported_dlg(rtn); - return rtn; + std::string gcode_cmd = (boost::format("M620 C%1% \n") % ams_id).str(); + BOOST_LOG_TRIVIAL(trace) << "ams_debug: gcode_cmd" << gcode_cmd; + return this->publish_gcode(gcode_cmd); } int MachineObject::command_ams_filament_settings(int ams_id, int slot_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) @@ -1773,11 +1771,9 @@ int MachineObject::command_ams_filament_settings(int ams_id, int slot_id, std::s int MachineObject::command_ams_refresh_rfid(std::string tray_id) { - if (!m_agent) return -1; - int rtn = m_agent->command_ams_refresh_rfid(get_dev_id(), tray_id, MachineObject::m_sequence_id++, is_lan_mode_printer()); - if (rtn == ORCA_NETWORK_ERR_CMD_NOT_SUPPORTED || rtn == ORCA_NETWORK_ERR_CAP_NOT_AVAILABLE) - show_unsupported_dlg(rtn); - return rtn; + std::string gcode_cmd = (boost::format("M620 R%1% \n") % tray_id).str(); + BOOST_LOG_TRIVIAL(trace) << "ams_debug: gcode_cmd" << gcode_cmd; + return this->publish_gcode(gcode_cmd); } int MachineObject::command_ams_refresh_rfid2(int ams_id, int slot_id) @@ -1793,11 +1789,9 @@ int MachineObject::command_ams_refresh_rfid2(int ams_id, int slot_id) int MachineObject::command_ams_select_tray(std::string tray_id) { - if (!m_agent) return -1; - int rtn = m_agent->command_ams_select_tray(get_dev_id(), tray_id, MachineObject::m_sequence_id++, is_lan_mode_printer()); - if (rtn == ORCA_NETWORK_ERR_CMD_NOT_SUPPORTED || rtn == ORCA_NETWORK_ERR_CAP_NOT_AVAILABLE) - show_unsupported_dlg(rtn); - return rtn; + std::string gcode_cmd = (boost::format("M620 P%1% \n") % tray_id).str(); + BOOST_LOG_TRIVIAL(trace) << "ams_debug: gcode_cmd" << gcode_cmd; + return this->publish_gcode(gcode_cmd); } int MachineObject::command_ams_control(std::string action) diff --git a/src/slic3r/Utils/BBLPrinterAgent.cpp b/src/slic3r/Utils/BBLPrinterAgent.cpp index 9d422552fe..ef85e0a1ff 100644 --- a/src/slic3r/Utils/BBLPrinterAgent.cpp +++ b/src/slic3r/Utils/BBLPrinterAgent.cpp @@ -2,9 +2,7 @@ #include "BBLNetworkPlugin.hpp" #include "NetworkAgentFactory.hpp" -#include #include -#include namespace Slic3r { @@ -22,65 +20,6 @@ void BBLPrinterAgent::set_cloud_agent(std::shared_ptr cloud) // Communication // ============================================================================ -std::string BBLPrinterAgent::ams_refresh_rfid_gcode(const std::string& tray_id) -{ - return (boost::format("M620 R%1% \n") % tray_id).str(); -} - -std::string BBLPrinterAgent::ams_calibrate_gcode(int ams_id) -{ - return (boost::format("M620 C%1% \n") % ams_id).str(); -} - -std::string BBLPrinterAgent::ams_select_tray_gcode(const std::string& tray_id) -{ - return (boost::format("M620 P%1% \n") % tray_id).str(); -} - -int BBLPrinterAgent::command_ams_refresh_rfid(std::string dev_id, std::string tray_id, int sequence_id, bool lan_mode) -{ - const std::string gcode = ams_refresh_rfid_gcode(tray_id); - BOOST_LOG_TRIVIAL(trace) << "ams_debug: gcode_cmd" << gcode; - nlohmann::json j; - j["print"]["command"] = "gcode_line"; - j["print"]["param"] = gcode; - j["print"]["sequence_id"] = std::to_string(sequence_id); - return publish(dev_id, j, lan_mode); -} - -int BBLPrinterAgent::command_ams_calibrate(std::string dev_id, int ams_id, int sequence_id, bool lan_mode) -{ - const std::string gcode = ams_calibrate_gcode(ams_id); - BOOST_LOG_TRIVIAL(trace) << "ams_debug: gcode_cmd" << gcode; - nlohmann::json j; - j["print"]["command"] = "gcode_line"; - j["print"]["param"] = gcode; - j["print"]["sequence_id"] = std::to_string(sequence_id); - return publish(dev_id, j, lan_mode); -} - -int BBLPrinterAgent::command_ams_select_tray(std::string dev_id, std::string tray_id, int sequence_id, bool lan_mode) -{ - const std::string gcode = ams_select_tray_gcode(tray_id); - BOOST_LOG_TRIVIAL(trace) << "ams_debug: gcode_cmd" << gcode; - nlohmann::json j; - j["print"]["command"] = "gcode_line"; - j["print"]["param"] = gcode; - j["print"]["sequence_id"] = std::to_string(sequence_id); - return publish(dev_id, j, lan_mode); -} - -int BBLPrinterAgent::publish(const std::string& dev_id, const nlohmann::json& j, bool lan_mode) -{ - const int rtn = lan_mode ? send_message_to_printer(dev_id, j.dump(), 0, 0) : send_message(dev_id, j.dump(), 0, 0); - if (rtn == 0) { - BOOST_LOG_TRIVIAL(info) << "publish_json: " << j.dump() << " code: " << rtn; - } else { - BOOST_LOG_TRIVIAL(error) << "publish_json: " << j.dump() << " code: " << rtn; - } - return rtn; -} - int BBLPrinterAgent::send_message(std::string dev_id, std::string json_str, int qos, int flag) { auto& plugin = BBLNetworkPlugin::instance(); diff --git a/src/slic3r/Utils/BBLPrinterAgent.hpp b/src/slic3r/Utils/BBLPrinterAgent.hpp index a04cd00175..a8880bf6bf 100644 --- a/src/slic3r/Utils/BBLPrinterAgent.hpp +++ b/src/slic3r/Utils/BBLPrinterAgent.hpp @@ -5,7 +5,6 @@ #include "ICloudServiceAgent.hpp" #include #include -#include namespace Slic3r { @@ -29,12 +28,6 @@ public: // Communication int send_message(std::string dev_id, std::string json_str, int qos, int flag) override; - static std::string ams_refresh_rfid_gcode(const std::string& tray_id); - static std::string ams_calibrate_gcode(int ams_id); - static std::string ams_select_tray_gcode(const std::string& tray_id); - int command_ams_refresh_rfid(std::string dev_id, std::string tray_id, int sequence_id, bool lan_mode) override; - int command_ams_calibrate(std::string dev_id, int ams_id, int sequence_id, bool lan_mode) override; - int command_ams_select_tray(std::string dev_id, std::string tray_id, int sequence_id, bool lan_mode) override; int connect_printer(std::string dev_id, std::string dev_ip, std::string username, std::string password, bool use_ssl) override; int disconnect_printer() override; int send_message_to_printer(std::string dev_id, std::string json_str, int qos, int flag) override; @@ -92,9 +85,6 @@ public: FilamentSyncMode get_filament_sync_mode() const override; private: - // why: the lan/cloud DECISION stays machine-side; keep this mechanical branch in sync with publish_json. - int publish(const std::string& dev_id, const nlohmann::json& j, bool lan_mode); - std::shared_ptr m_cloud_agent; }; diff --git a/src/slic3r/Utils/IPrinterAgent.hpp b/src/slic3r/Utils/IPrinterAgent.hpp index 85a1ffb8fc..0fa3616344 100644 --- a/src/slic3r/Utils/IPrinterAgent.hpp +++ b/src/slic3r/Utils/IPrinterAgent.hpp @@ -84,16 +84,6 @@ public: */ virtual int send_message(std::string dev_id, std::string json_str, int qos, int flag) = 0; - // why: gcode is firmware dialect, not a waist concept - commands whose body is Bambu-dialect - // gcode live on the agent that speaks it; the default is an honest refusal that MachineObject's - // publish funnel turns into a dialog. - virtual int command_ams_refresh_rfid(std::string, std::string, int, bool) - { return ORCA_NETWORK_ERR_CMD_NOT_SUPPORTED; } - virtual int command_ams_calibrate(std::string, int, int, bool) - { return ORCA_NETWORK_ERR_CMD_NOT_SUPPORTED; } - virtual int command_ams_select_tray(std::string, std::string, int, bool) - { return ORCA_NETWORK_ERR_CMD_NOT_SUPPORTED; } - /** * Establish a direct LAN connection to a printer. */ diff --git a/src/slic3r/Utils/NetworkAgent.cpp b/src/slic3r/Utils/NetworkAgent.cpp index b169fca052..0d77e5e660 100644 --- a/src/slic3r/Utils/NetworkAgent.cpp +++ b/src/slic3r/Utils/NetworkAgent.cpp @@ -767,27 +767,6 @@ int NetworkAgent::send_message(std::string dev_id, std::string json_str, int qos return -1; } -int NetworkAgent::command_ams_refresh_rfid(std::string dev_id, std::string tray_id, int sequence_id, bool lan_mode) -{ - if (m_printer_agent) - return m_printer_agent->command_ams_refresh_rfid(dev_id, tray_id, sequence_id, lan_mode); - return -1; -} - -int NetworkAgent::command_ams_calibrate(std::string dev_id, int ams_id, int sequence_id, bool lan_mode) -{ - if (m_printer_agent) - return m_printer_agent->command_ams_calibrate(dev_id, ams_id, sequence_id, lan_mode); - return -1; -} - -int NetworkAgent::command_ams_select_tray(std::string dev_id, std::string tray_id, int sequence_id, bool lan_mode) -{ - if (m_printer_agent) - return m_printer_agent->command_ams_select_tray(dev_id, tray_id, sequence_id, lan_mode); - return -1; -} - int NetworkAgent::connect_printer(std::string dev_id, std::string dev_ip, std::string username, std::string password, bool use_ssl) { if (m_printer_agent) diff --git a/src/slic3r/Utils/NetworkAgent.hpp b/src/slic3r/Utils/NetworkAgent.hpp index 317a357135..d7032b7a20 100644 --- a/src/slic3r/Utils/NetworkAgent.hpp +++ b/src/slic3r/Utils/NetworkAgent.hpp @@ -142,9 +142,6 @@ public: int set_on_local_message_fn(OnMessageFn fn); int set_server_callback(OnServerErrFn fn); int send_message(std::string dev_id, std::string json_str, int qos, int flag); - int command_ams_refresh_rfid(std::string dev_id, std::string tray_id, int sequence_id, bool lan_mode); - int command_ams_calibrate(std::string dev_id, int ams_id, int sequence_id, bool lan_mode); - int command_ams_select_tray(std::string dev_id, std::string tray_id, int sequence_id, bool lan_mode); int connect_printer(std::string dev_id, std::string dev_ip, std::string username, std::string password, bool use_ssl); int disconnect_printer(); int send_message_to_printer(std::string dev_id, std::string json_str, int qos, int flag);