mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-05 06:41:10 +00:00
* Add developer flag for printer agents
* Parse user print info on the UI thread to prevent heap corruption (#119)
get_user_print_info()'s HTTP fetch can run on a worker thread (e.g. BindJob),
but parse_user_print_info() mutates userMachineList (insert/erase/delete
MachineObject). on_machine_alive (SSDP) mutates the same maps on the UI thread
without locking, so parsing off-thread races the map and frees MachineObjects
out from under it -> heap corruption.
Keep all device-list mutation on the UI thread: parse inline when already on
the main thread, otherwise marshal via CallAfter so it stays serialized with
on_machine_alive.
* Prevent loss of user access code on LAN reselect
Keep user access code intact to maintain access rights even if
device slot is unpopulated, ensuring continuous connection
and status message reception.
* Harden send flow and separate upload failure recovery (#111)
* fix(send): harden FT send path + IP pre-flight UX
* Remove early returns
* Working Moonraker and Qidi printer agent transport (#104)
Folds the Qidi AMS box-mapping print
overrides (apply_box_mapping +
start_* wrappers) that the transport
fix builds on.
* Add support for runtime error status in plugins
Distinguish a loaded plugin whose
capability errored (RuntimeError,
warn-styled, stays checked) from a
load-time Error. Status now derives
via resolve_plugin_status(); enum
ordinal keeps dialog sort priority.
Unloading clears stale errors.
* Resolve duplicate agent ID conflicts
Reject a printer-agent capability
whose agent ID is already owned by
another capability or built-in:
flag the plugin error, disable the
capability, and warn the user
instead of silently ignoring it.
* fix: checkbox should depend on plugin is_loaded status
* Replace fake-enum printer agent dropdown (#121)
A dedicated PrinterAgentChoice field
reads rows straight from the live
agent registry and stores the agent
id string, replacing the fake-coEnum
index mapping. The field moves to
TabPrinter and registers with the
searcher so UnsavedChanges renders
it; the PhysicalPrinterDialog copy
and its update hook are removed
(#125). switch_printer_agent now
resolves ids via
resolve_printer_agent_id.
* Reset device selection on agent swap or unload (#124)
set_live_printer_agent centralizes
the swap: deselect the machine,
clear stale sidebar state and the
previous agent's Other Devices, then
install the new agent (or null when
its provider vanished). Plugin
load/unload callbacks refresh the
dropdown and re-run agent selection.
load_last_machine no longer falls
back to the first available machine.
* Gate agent mode behind use_printer_agents toggle
Replace per-printer auto-activation
(is_current_printer_agent_plugin)
with a global experimental AppConfig
toggle, default off: legacy
print-host behavior is unchanged
until the user opts in. The toggle
drives device-tab routing, print
button defaults, connect-button
visibility and sidebar layout, and
dedups machine-select dialog opens.
* Track BBLPrinterAgentPlugin.py
* Add printer-agent and plugin status tests
Ports the agent lifecycle, duplicate
agent-id, built-in-id clash and
status-resolution tests. The loader
runs on a detached worker thread, so
the lifecycle tests live in their own
executable. Tests install the
production unload-side registry
wiring themselves (no GUI in the
test binary) and register agents
manually so concurrent loads stay
deterministic.
* fix: pin HTTP to prevent connection refusal
Set `use_ssl` to false to ensure Moonraker
connectivity, as the service uses HTTP rather
than HTTPS, preventing connection issues. Initialize
device info early for reliable name resolution.
* Bring Moonraker device panel to feature parity
The monitor panel showed wrong or missing
data for Moonraker printers, and its
controls did nothing.
Push payload now carries layer number and
total layers. Remaining time replaces the
wrong total_duration - print_duration
formula. The chamber light toggle maps to
Klipper SET_PIN / SET_LED, and pause,
resume and stop post to
/printer/print/{action}. Task thumbnails
resolve via /server/files/thumbnails onto
a new MachineObject thumbnail url.
Filament sync switches to pull mode so the
agent is queried on demand.
Not compiled or run.
* Stop blocking print on unreported nozzle data
* fix: make Klipper macro lamp control reliable
* Surface Moonraker webcams and gate unrunnable controls
* Keep Bambu AMS dialect out of the agent waist
M620 is Bambu firmware dialect, not a
neutral command. Composing it in
MachineObject let non-Bambu agents
(Moonraker/Klipper) forward it and
report success on firmware that
cannot run it.
Agents now own the dialect: the
default refusal on IPrinterAgent
returns not-supported so the UI
can say so; BBLPrinterAgent keeps
the byte-identical composition.
* Fix multi-color filament logic
Reuse color decoding across functions to improve
code readability and maintain consistency in
multi-color filament handling.
* Move Moonraker commands off the UI thread
Pause/resume/stop, g-code sends, temps, and
light ran synchronous HTTP on the UI thread,
freezing the app up to 10s per click on slow
or unreachable printers.
Run them on a single agent-owned FIFO worker
so g-code ordering is preserved, while command
translation stays synchronous so unsupported-
command dialogs still work.
Add a pending-disabled state to the pause,
resume, and abort buttons for Moonraker-family
printers: the icon only flips once the
WebSocket reports the real state, which also
rules out double-click races.
* Show Snapmaker U1 camera in Device tab
The U1 exposes no /server/webcams/list entry;
its camera only captures after an explicit
camera.start_monitor RPC, which the Moonraker
websocket executes unauthenticated but only
answers over MQTT - so the call is fire and
forget.
Start the camera when the camera view is
shown and renew every 300 s: the printer
retires the capture task at ~362 s and
stop_monitor is accepted but ineffective,
so teardown is simply to stop renewing.
Frames land in monitor.jpg as still JPEGs
(~2 fps at interval 0), so the webview loads
a local HTML wrapper that repolls with a
cache buster.
* fix: start stream when camera URL changes
* fix: stop Qidi slot parse throwing on null
* Keep printer-agent progress in sync
Keep the shared task progress aligned with agent
reports that lack Bambu cloud task identity.
Release the lazily allocated task during reset to
avoid leaks when machine objects reconnect.
* docs: document the printer-agent subsystem
* fix: merge access codes into one
* Reconcile implementation split with PR tip
* feat: abstract remaining gcode commands in devicemanager
* refactor: abstract bambu specific protocol to printer agent
* refactor: push bbl workflows to bbl printer agent
* remove unused
* fix: default impl
* fix callback error
* fix: remove redundant cache
* specify api for getting file transfer url
* revert file transfer abstraction
* fix: ams filament mapping workflow
* feat: update qidi to use subscription based filament sync mode
* fix: resolve stubgen byte header conflict
* fix: ams sync info and periodic ams sync via subscription workflow
* fix: skip filament sync dialog if filamentSyncMode is none
* feat: parse nozzle information for qidi and moonraker printer agents
* fix: extend access code requirements t 0, 8 or more characters.
* remove irrelevant docs
* fix: remove heavy includes from IPrinterAgent
* fix: defer filesystem and camera abstractions
* fix: remote do_fetch_filament_info from tests
* cleanup moonraker and snapmaker printer agents
* fix: access codes regression
* fix: tests
* fix: printer agent switching on preset change
* fix: remove unused variable
* fix: snapmaker U1 SelectMachineDialog blocking print
* fix: merge artifact
* fix: clear up some unrelated changes
* feat: connect to cloud printer and monitor
* feat: connect to cloud printer and monitor
* feat: generic camera stream support for http snapshot and rtsp
* fix: build & access code UI
* feat: generic camera stream support for http snapshot and rtsp
* fix: build & access code UI
* feat: connect to cloud printer and monitor
* feat: connect to cloud printer and monitor
* fix: build errors
* feat: camera via webrtc
* fix: build
* fix: cmake
* feat: remove frame assembler and change config to set protocol
* fix: orcaprinteragent refactor
* fix: LAN paths and camera stream
* feat: use ffmpeg to render http camera stream
* fix: make model_id/dev_type optional instead of blocking
* fix: connect via ip dialog
* feat: LAN impl for Orca Printer Agent
* fix: model_id resolution method for non bambu printers
* fix: ffmpeg http camera stream jittering due to incomplete frames
* fix: revert sdcard check
* feat: check printer storage status before sending
* fix: moonraker printer agent hang on printer power cut
* fix: shim layer for any compatibiliity changes
* fix: cloud printers were using the wrong MQTT endpoint
* feat: cloud download via HTTP
* temp: doc for intended change
* fix: warnings
* fix: warnings
* fix: camera auto-play on startup
* fix: split infra from impl
* fix: uninitialized ams state blocking print
* Fixes nullptr deref
* Log first before std::move
* fix: printer agent virutal optional functions
* fix: parameterize orcaslicer_copy_test_dlls() for printer_agent_plugin_tests
* Revert "fix: parameterize orcaslicer_copy_test_dlls() for printer_agent_plugin_tests"
This reverts commit 2f566e3779.
* Guard libdatachannel. Remove unused code
* fix: unit tests & unused variables
* fix(ci): deps build order for datachannel
* Resolve printer agent first before getting cloud printer agent
* fix(ci): set depends openssl
* fix: re-include apply header guarded by ifdef __APPLE__
* fix(ci): add libdatachannel to flatpak manifest
* fix: add internal_developer_mode chekc back to MediaPlayCtrl::load()
* fix: invoke js clearInterval on WebMediaController::stop
* fix: change rtc log level
* fix: inject provider, agent id and generation to get_user_print_info to ensure correct metadata
* fix: revert moonraker specific behavior
* fix: remove stale comment
* fix: use ORCA_CLOUD_PROVIDER instead of hardcoded string
* fix: remove hardcoded ICE servers
* feat: enable https camera stream mode
* fix: move non-mandatory printer agent function stubs to IPrinterAgent
* fix: dedupe compatible printer type check
* fix: stop the correct media controller
* fix: scope get_my_machine_list to printers listed under the current printer agent
* fix: move printer agent plugin tests into test_plugin_lifecycle.cpp
* fix: always build bundled DataChannel dep
* fix: disable unused DataChannel media support
* revert: filament sync work
* fix: wrap command_* with small wrapper
* fix: regression bug, connecting to bambu needs bblp username
* fix: default impl for vendor agnostic gcode commansd
* refactor: media controller playback routing and ownership
* fix: bump libdatachannel ver & update flatpak to use tar instead
* fix: stop flatpak DataChannel build from re-cloning over the sandboxed network
* fix: update windows ffmpeg prebuild
* fix: update printer agent plugin API
* fix: shift camera signaling channel to network agent
* fix: follow external-packages for flatpak libdatachannel deps & add flatpak path to use source_dir
* feat: add printer-agent.md doc to HLSD
* fix: guard DeviceManager command dispatch when no printer agent is bound
* fix: port BBL implementations from #15711
* refactor: connect_printer api and dialog
* fix(tests): make omitted printer agent operations answer like a missing agent
* fix: preserve printer agent defaults in PrinterAgentPluginCapabilityTrampoline
* test: cover printer agent default command dispatch
* fix: validate windows FFmpeg avformat library
* feat: extend optional printer model warnings to calibration & ams workflows
* fix: handle malformed printer progress values safely
* fix: clear webview document on stop
* chore: reduce diagnostic logging level to trace
* refactor: centralize printer compatibility checks
* tests: add device manager integration coverage
* tests: cover WebMediaController lifecycle with wxWebView stub
* fix: make integration tests headless
* refactor: collapse command_ams_refresh_rfid and command_ams_refresh_rfid2
* refactor: make printer connection SSL agent-specific
* fix: persist input printer host and port
* fix: use correct device id for Moonraker connections
* fix: make moonraker gcode commands asynchronous
* fix: preserve moonraker device names
* fix: add include for non BBL_RELEASE_TO_PUBLIC path in BBLPrinterAgent
---------
Co-authored-by: Andrew <159703254+andrewsoonqn@users.noreply.github.com>
Co-authored-by: SoftFever <softfeverever@gmail.com>
Co-authored-by: Lam Wei Lun <weilun.lam@gmail.com>
226 lines
15 KiB
C++
226 lines
15 KiB
C++
#ifndef __NETWORK_Agent_HPP__
|
|
#define __NETWORK_Agent_HPP__
|
|
|
|
#include "bambu_networking.hpp"
|
|
|
|
#include "libslic3r/ProjectTask.hpp"
|
|
#include "ICloudServiceAgent.hpp"
|
|
#include "IPrinterAgent.hpp"
|
|
|
|
#include <map>
|
|
#include <atomic>
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace Slic3r {
|
|
|
|
class IPrinterAgent;
|
|
|
|
// Forward declaration
|
|
class BBLNetworkPlugin;
|
|
|
|
// The NetworkAgent class
|
|
class NetworkAgent
|
|
{
|
|
public:
|
|
// Static utility methods - delegate to BBLNetworkPlugin
|
|
static std::string get_libpath_in_current_directory(std::string library_name);
|
|
static std::string get_versioned_library_path(const std::string& version);
|
|
static bool versioned_library_exists(const std::string& version);
|
|
static bool legacy_library_exists();
|
|
static void remove_legacy_library();
|
|
static std::vector<std::string> scan_plugin_versions();
|
|
static int initialize_network_module(bool using_backup = false, const std::string& version = "");
|
|
static int unload_network_module();
|
|
static bool is_network_module_loaded();
|
|
#if defined(_MSC_VER) || defined(_WIN32)
|
|
static HMODULE get_bambu_source_entry();
|
|
#else
|
|
static void* get_bambu_source_entry();
|
|
#endif
|
|
static std::string get_version();
|
|
static void* get_network_function(const char* name);
|
|
|
|
static NetworkLibraryLoadError get_load_error();
|
|
static void clear_load_error();
|
|
static void set_load_error(const std::string& message, const std::string& technical_details, const std::string& attempted_path);
|
|
|
|
// Sub-agent composition constructor (uses injected sub-agents)
|
|
NetworkAgent(std::shared_ptr<ICloudServiceAgent> cloud_agent,
|
|
std::shared_ptr<IPrinterAgent> printer_agent);
|
|
|
|
~NetworkAgent();
|
|
|
|
// Sub-agent accessors
|
|
std::shared_ptr<ICloudServiceAgent> get_cloud_agent(const std::string& provider = ORCA_CLOUD_PROVIDER) const;
|
|
std::shared_ptr<IPrinterAgent> get_printer_agent() const { return m_printer_agent; }
|
|
std::uint64_t get_user_machine_list_generation() const { return m_user_machine_list_generation.load(); }
|
|
|
|
// Shared agent management
|
|
void add_cloud_agent(const std::string& provider, std::shared_ptr<ICloudServiceAgent> agent);
|
|
void set_printer_agent(std::shared_ptr<IPrinterAgent> printer_agent);
|
|
int set_queue_on_main_fn(QueueOnMainFn fn, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
|
|
// Get underlying agent handle from BBLNetworkPlugin
|
|
void* get_network_agent();
|
|
|
|
// Cloud agent methods
|
|
// These methods will be forwarded to all cloud agents
|
|
int init_log();
|
|
int set_config_dir(std::string config_dir);
|
|
int set_cert_file(std::string folder, std::string filename);
|
|
int set_country_code(std::string country_code);
|
|
int start();
|
|
int set_on_server_connected_fn(AppOnServerConnectedFn fn);
|
|
int set_on_http_error_fn(AppOnHttpErrorFn fn);
|
|
int set_get_country_code_fn(GetCountryCodeFn fn);
|
|
int connect_server();
|
|
int refresh_connection(const std::string& provider = "");
|
|
|
|
int change_user(std::string user_info, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
bool is_user_login(const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int user_logout(bool request = false, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
std::string get_user_id(const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
std::string get_user_name(const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
std::string get_user_avatar(const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
std::string get_user_nickname(const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
std::string build_login_cmd(const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
std::string build_logout_cmd(const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
std::string build_login_info(const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
std::string get_cloud_service_host(const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
std::string get_cloud_login_url(const std::string& language = "", const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
bool is_server_connected(const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
|
|
void enable_multi_machine(bool enable, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
|
|
// Profile synchronization methods
|
|
// NOTE: this should always call only OrcaCloud
|
|
int get_user_presets(std::map<std::string, std::map<std::string, std::string>>* user_presets, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
std::string request_setting_id(std::string name, std::map<std::string, std::string>* values_map, unsigned int* http_code, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int put_setting(std::string setting_id, std::string name, std::map<std::string, std::string>* values_map, unsigned int* http_code, const std::string& provider = ORCA_CLOUD_PROVIDER, bool force = false);
|
|
int get_setting_list(std::string bundle_version, ProgressFn pro_fn = nullptr, WasCancelledFn cancel_fn = nullptr, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int get_setting_list2(std::string bundle_version, CheckFn chk_fn, ProgressFn pro_fn = nullptr, WasCancelledFn cancel_fn = nullptr, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int delete_setting(std::string setting_id, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
|
|
int get_my_message(int type, int after, int limit, unsigned int* http_code, std::string* http_body, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int check_user_task_report(int* task_id, bool* printable, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int get_user_print_info(unsigned int* http_code, std::string* http_body, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int get_user_tasks(TaskQueryParams params, std::string* http_body, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int get_printer_firmware(std::string dev_id, unsigned* http_code, std::string* http_body, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int get_task_plate_index(std::string task_id, int* plate_index, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int get_user_info(int* identifier, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int get_subtask_info(std::string subtask_id, std::string* task_json, unsigned int* http_code, std::string* http_body, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int get_slice_info(std::string project_id, std::string profile_id, int plate_index, std::string* slice_json, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int query_bind_status(std::vector<std::string> query_list, unsigned int* http_code, std::string* http_body, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int modify_printer_name(std::string dev_id, std::string dev_name, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int get_camera_url(std::string dev_id, std::function<void(std::string)> callback, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
std::unique_ptr<ICameraSignalingChannel> create_camera_signaling_channel(const std::string& dev_id, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int get_design_staffpick(int offset, int limit, std::function<void(std::string)> callback, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int start_publish(PublishParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, std::string* out, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int get_model_publish_url(std::string* url, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int get_subtask(BBLModelTask* task, OnGetSubTaskFn getsub_fn, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int get_model_mall_home_url(std::string* url, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int get_model_mall_detail_url(std::string* url, std::string id, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int get_my_profile(std::string token, unsigned int* http_code, std::string* http_body, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int get_my_token(std::string ticket, unsigned int* http_code, std::string* http_body, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
// Orca: telemetry only exists on the BBL cloud agent (Orca cloud has no track events).
|
|
int track_enable(bool enable);
|
|
int track_remove_files();
|
|
int track_event(std::string evt_key, std::string content, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int track_header(std::string header, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int track_update_property(std::string name, std::string value, std::string type = "string", const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int track_get_property(std::string name, std::string& value, std::string type = "string", const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int put_model_mall_rating(int design_id, int score, std::string content, std::vector<std::string> images, unsigned int &http_code, std::string &http_error, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int get_oss_config(std::string &config, std::string country_code, unsigned int &http_code, std::string &http_error, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int put_rating_picture_oss(std::string &config, std::string &pic_oss_path, std::string model_id, int profile_id, unsigned int &http_code, std::string &http_error, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int get_model_mall_rating_result(int job_id, std::string &rating_result, unsigned int &http_code, std::string &http_error, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
bool get_track_enable() { return enable_track; }
|
|
int get_mw_user_preference(std::function<void(std::string)> callback, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
int get_mw_user_4ulist(int seed, int limit, std::function<void(std::string)> callback, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
|
|
|
// Printer agent methods
|
|
int set_on_ssdp_msg_fn(OnMsgArrivedFn fn);
|
|
int set_on_printer_connected_fn(OnPrinterConnectedFn fn);
|
|
int set_on_subscribe_failure_fn(GetSubscribeFailureFn fn);
|
|
int set_on_message_fn(OnMessageFn fn);
|
|
int set_on_user_message_fn(OnMessageFn fn);
|
|
int set_on_local_connect_fn(OnLocalConnectedFn fn);
|
|
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, int ams_id, int slot_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 command_start_camera(std::string dev_id);
|
|
int command_xyz_abs(std::string dev_id, int sequence_id, bool lan_mode);
|
|
int command_auto_leveling(std::string dev_id, int sequence_id, bool lan_mode);
|
|
int command_go_home(std::string dev_id, bool is_printing, bool supports_mqtt_homing, int sequence_id, bool lan_mode);
|
|
int command_set_bed(std::string dev_id, int temp, bool supports_mqtt_bed_ctrl, int sequence_id, bool lan_mode);
|
|
int command_set_nozzle(std::string dev_id, int temp, int sequence_id, bool lan_mode);
|
|
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);
|
|
int connect_printer(const PrinterConnectionParams& params);
|
|
int disconnect_printer();
|
|
int send_message_to_printer(std::string dev_id, std::string json_str, int qos, int flag);
|
|
std::string default_lan_username() const;
|
|
int check_cert();
|
|
void install_device_cert(std::string dev_id, bool lan_only);
|
|
bool start_discovery(bool start, bool sending);
|
|
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 dev_model, std::string sec_link, std::string timezone, bool improved, OnUpdateStatusFn update_fn);
|
|
int unbind(std::string dev_id);
|
|
std::string get_user_selected_machine();
|
|
int set_user_selected_machine(std::string dev_id);
|
|
int start_subscribe(std::string module);
|
|
int stop_subscribe(std::string module);
|
|
int add_subscribe(std::vector<std::string> dev_list);
|
|
int del_subscribe(std::vector<std::string> dev_list);
|
|
int start_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn);
|
|
int start_local_print_with_record(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn);
|
|
int start_send_gcode_to_sdcard(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn);
|
|
int start_local_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn);
|
|
int start_sdcard_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn);
|
|
FilamentSyncMode get_filament_sync_mode() const;
|
|
bool fetch_filament_info(std::string dev_id, FilamentSyncMode sync_mode = FilamentSyncMode::pull);
|
|
CameraStreamMode get_camera_stream_mode() const;
|
|
std::string get_local_camera_stream_url() const;
|
|
std::string to_orca_filament_id(const std::string& printer_filament_id) const;
|
|
std::string from_orca_filament_id(const std::string& orca_filament_id) const;
|
|
int request_bind_ticket(std::string* ticket);
|
|
int get_hms_snapshot(std::string dev_id, std::string file_name, std::function<void(std::string, int)> callback);
|
|
|
|
private:
|
|
struct PrinterCallbacks {
|
|
OnMsgArrivedFn on_ssdp_msg_fn = nullptr;
|
|
OnPrinterConnectedFn on_printer_connected_fn = nullptr;
|
|
GetSubscribeFailureFn on_subscribe_failure_fn = nullptr;
|
|
OnMessageFn on_message_fn = nullptr;
|
|
OnMessageFn on_user_message_fn = nullptr;
|
|
OnLocalConnectedFn on_local_connect_fn = nullptr;
|
|
OnMessageFn on_local_message_fn = nullptr;
|
|
QueueOnMainFn queue_on_main_fn = nullptr;
|
|
OnServerErrFn on_server_err_fn = nullptr;
|
|
};
|
|
|
|
void apply_printer_callbacks(const std::shared_ptr<IPrinterAgent>& printer_agent,
|
|
const PrinterCallbacks& callbacks);
|
|
PrinterCallbacks m_printer_callbacks;
|
|
bool enable_track = false;
|
|
|
|
// Sub-agent composition
|
|
// We support dynamic switching of printer agents (e.g. for different printer types), but the cloud agent is fixed at construction since
|
|
// it's tied to the user's cloud account OrcaCloudServiceAgent is designed to be the primary cloud agent, but we support the possibility
|
|
// of adding third-party cloud agents (e.g. BBLCloudServiceAgent) and delegating calls to them as needed
|
|
std::map<std::string, std::shared_ptr<ICloudServiceAgent>> m_cloud_agents;
|
|
std::shared_ptr<IPrinterAgent> m_printer_agent;
|
|
std::string m_printer_agent_id;
|
|
std::atomic<std::uint64_t> m_user_machine_list_generation{0};
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|