Files
OrcaSlicer/src/slic3r/Utils/BBLPrinterAgent.hpp
T
HanifKoh 4895bc03b4 Remove Unused Project Includes and Forward-Declare Where a Type Is Only Referenced (#16099)
* Remove Unused Project Includes and Forward-Declare Where a Type Is Only Referenced

Generated with include-what-you-use and applied conservatively. Only OrcaSlicer's own headers, the ones under src/ and tests/, are removed or forward-declared; standard-library and third-party includes are left alone. An include is removed only when both the Release and the Debug configuration leave it unused, never from inside a conditional block, and never from a file with platform-specific blocks, which only gain includes. Files whose only use of a header sits behind a feature or debug macro (libvgcode's OpenGL ES and marker code, the ARACHNE/TESTS_EXPORT_SVGS debug output) keep their includes.

clonable_ptr.hpp gains #pragma once; it had no include guard and was only safe while Config.hpp was its sole includer.

* Remove Unused Project Includes From Files With Platform-Specific Code

A Linux include-what-you-use run cannot see the code inside _WIN32, __APPLE__ or __linux__ blocks, so its verdict is only taken where nothing the removed header declares, directly or through what it includes, is named inside those blocks. Removals also have to hold in both the Release and Debug configuration and never touch a line inside a conditional block.

* Restore the libslic3r Precompiled Header and Direct Includes Lost in the Platform Pass

The platform-file pass treated pchheader.hpp as an ordinary header and
emptied it, and left GUI_Preview.hpp and 14 other files relying on
headers they no longer reached directly.

* Restore MainFrame.hpp in ParamsDialog.cpp for the Windows-Only Reparent Call

* Include Headers That Files Reached Through Ones the Cleanup Removed

* Drop Includes Duplicated by the Cleanup or by Main's Own Additions

* Leave PreciseSeam.cpp as Main Has It After the Precise Seam Rework
2026-10-05 16:47:17 +08:00

119 lines
5.8 KiB
C++

#ifndef __BBL_PRINTER_AGENT_HPP__
#define __BBL_PRINTER_AGENT_HPP__
#include "IPrinterAgent.hpp"
#include "bambu_networking.hpp"
#include <functional>
#include <string>
#include <memory>
#include <nlohmann/json.hpp>
#include <vector>
namespace Slic3r { class ICloudServiceAgent; }
namespace Slic3r {
/**
* BBLPrinterAgent - BBL DLL wrapper implementation of IPrinterAgent.
*
* Delegates all printer operations to the proprietary BBL network DLL
* through function pointers obtained from BBLNetworkPlugin singleton.
*/
class BBLPrinterAgent : public IPrinterAgent {
public:
BBLPrinterAgent();
~BBLPrinterAgent() override;
// Cloud Agent Dependency (not used by BBL - tokens managed internally)
void set_cloud_agent(std::shared_ptr<ICloudServiceAgent> cloud) override;
// ========================================================================
// IPrinterAgent Interface Implementation
// ========================================================================
// Communication
int send_message(std::string dev_id, std::string json_str, int qos, int flag) override;
int command_ams_refresh_rfid(std::string dev_id, int ams_id, int slot_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 command_axis_control(std::string dev_id, std::string axis, double unit, double input_val, int speed,
bool is_core_xy, bool supports_mqtt_axis_control, int sequence_id, bool lan_mode) override;
std::string default_lan_username() const override { return "bblp"; }
int connect_printer(const PrinterConnectionParams& params) override;
int disconnect_printer() override;
int send_message_to_printer(std::string dev_id, std::string json_str, int qos, int flag) override;
// Certificates
int check_cert() override;
void install_device_cert(std::string dev_id, bool lan_only) override;
// Discovery
bool start_discovery(bool start, bool sending) override;
// Binding
int ping_bind(std::string ping_code) override;
int bind_detect(std::string dev_ip, std::string sec_link, detectResult& detect) override;
int bind(std::string dev_ip, std::string dev_id, std::string dev_model, std::string sec_link, std::string timezone, bool improved, OnUpdateStatusFn update_fn) override;
int unbind(std::string dev_id) override;
int request_bind_ticket(std::string* ticket) override;
int get_hms_snapshot(std::string dev_id, std::string file_name, std::function<void(std::string, int)> callback) override;
int set_server_callback(OnServerErrFn fn) override;
// Machine Selection
std::string get_user_selected_machine() override;
int set_user_selected_machine(std::string dev_id) override;
// Subscriptions
int start_subscribe(std::string module) override;
int stop_subscribe(std::string module) override;
int add_subscribe(std::vector<std::string> dev_list) override;
int del_subscribe(std::vector<std::string> dev_list) override;
/**
* Get agent information.
*
* @return AgentInfo struct containing agent identification and descriptive information
*/
static AgentInfo get_agent_info_static();
AgentInfo get_agent_info() override { return get_agent_info_static(); }
// Print Job Operations
int start_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn) override;
int start_local_print_with_record(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn) override;
int start_send_gcode_to_sdcard(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn) override;
int start_local_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn) override;
int start_sdcard_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn) override;
// Callbacks
int set_on_ssdp_msg_fn(OnMsgArrivedFn fn) override;
int set_on_printer_connected_fn(OnPrinterConnectedFn fn) override;
int set_on_subscribe_failure_fn(GetSubscribeFailureFn fn) override;
int set_on_message_fn(OnMessageFn fn) override;
int set_on_user_message_fn(OnMessageFn fn) override;
int set_on_local_connect_fn(OnLocalConnectedFn fn) override;
int set_on_local_message_fn(OnMessageFn fn) override;
int set_queue_on_main_fn(QueueOnMainFn fn) override;
FilamentSyncMode get_filament_sync_mode() const override;
// Bambu's own catalog ids. Orca content-addresses every system filament, Bambu's included;
// the printer, the AMS and Bambu's cloud know only Bambu's ids, so this agent translates at
// the boundary through resources/printers/bambu_filament_ids.json (generated by
// scripts/update_bambu_filament_ids.py). An id without a map row is returned as it is.
std::string to_orca_filament_id(const std::string& printer_filament_id) const override;
std::string from_orca_filament_id(const std::string& orca_filament_id) const override;
// Rewrite every string under "tray_info_idx", "filament_id" or "filamentId", at any depth,
// in a JSON document (an MQTT payload or PrintParams::ams_mapping_info). Text that does not
// parse, or contains none of the keys, is returned unchanged.
// Taken by value: most outbound traffic carries no filament id and is moved straight back out.
static std::string to_orca_payload(std::string json_text);
static std::string from_orca_payload(std::string json_text);
private:
int publish(const std::string& dev_id, const nlohmann::json& j, bool lan_mode);
};
} // namespace Slic3r
#endif // __BBL_PRINTER_AGENT_HPP__