mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-15 13:07:33 +00:00
fix: printer agent virutal optional functions
This commit is contained in:
@@ -39,34 +39,14 @@ public:
|
||||
int set_user_selected_machine(std::string dev_id) override = 0;
|
||||
int start_send_gcode_to_sdcard(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn) override = 0;
|
||||
int start_local_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn) override = 0;
|
||||
FilamentSyncMode get_filament_sync_mode() const override = 0;
|
||||
bool fetch_filament_info(std::string dev_id, FilamentSyncMode sync_mode = FilamentSyncMode::pull) override = 0;
|
||||
CameraStreamMode get_camera_stream_mode() const override = 0;
|
||||
std::string get_camera_url() const override = 0;
|
||||
|
||||
int check_cert() override = 0;
|
||||
void install_device_cert(std::string dev_id, bool lan_only) override = 0;
|
||||
int ping_bind(std::string ping_code) override = 0;
|
||||
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 = 0;
|
||||
int unbind(std::string dev_id) override = 0;
|
||||
// request_bind_ticket has a std::string* out-param that cannot round-trip through a
|
||||
// pybind11 override directly; the trampoline wraps it (the Python plugin returns a
|
||||
// (result, ticket) tuple), so it stays pure here like the rest.
|
||||
int request_bind_ticket(std::string* ticket) override = 0;
|
||||
int get_hms_snapshot(std::string dev_id, std::string file_name, std::function<void(std::string, int)> callback) override = 0;
|
||||
int set_server_callback(OnServerErrFn fn) override = 0;
|
||||
int start_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn) override = 0;
|
||||
int set_server_callback(OnServerErrFn fn) override = 0;
|
||||
int start_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn) override = 0;
|
||||
int start_local_print_with_record(PrintParams params,
|
||||
OnUpdateStatusFn update_fn,
|
||||
WasCancelledFn cancel_fn,
|
||||
OnWaitFn wait_fn) override = 0;
|
||||
int start_sdcard_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn) override = 0;
|
||||
OnWaitFn wait_fn) override = 0;
|
||||
int start_sdcard_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn) override = 0;
|
||||
|
||||
int set_on_ssdp_msg_fn(OnMsgArrivedFn fn) override = 0;
|
||||
int set_on_printer_connected_fn(OnPrinterConnectedFn fn) override = 0;
|
||||
@@ -76,6 +56,32 @@ public:
|
||||
int set_on_local_connect_fn(OnLocalConnectedFn fn) override = 0;
|
||||
int set_on_local_message_fn(OnMessageFn fn) override = 0;
|
||||
int set_queue_on_main_fn(QueueOnMainFn fn) override = 0;
|
||||
|
||||
// The following functions are not required to be implemented for the printer agent to work.
|
||||
// Each default mirrors IPrinterAgent's own "not supported" fallback, so a plugin that skips
|
||||
// one of these behaves like an agent that never had the capability.
|
||||
FilamentSyncMode get_filament_sync_mode() const override { return FilamentSyncMode::none; }
|
||||
bool fetch_filament_info(std::string dev_id, FilamentSyncMode sync_mode) override { return false; }
|
||||
CameraStreamMode get_camera_stream_mode() const override { return CameraStreamMode::none; }
|
||||
std::string get_camera_url() const override { return {}; }
|
||||
void install_device_cert(std::string dev_id, bool lan_only) override {}
|
||||
int check_cert() override { return ORCA_NETWORK_ERR_CAP_NOT_AVAILABLE; }
|
||||
int ping_bind(std::string ping_code) override { return ORCA_NETWORK_ERR_CAP_NOT_AVAILABLE; }
|
||||
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
|
||||
{ return ORCA_NETWORK_ERR_CAP_NOT_AVAILABLE; }
|
||||
int unbind(std::string dev_id) override { return ORCA_NETWORK_ERR_CAP_NOT_AVAILABLE; }
|
||||
// request_bind_ticket has a std::string* out-param that cannot round-trip through a
|
||||
// pybind11 override directly; the trampoline dispatches it manually (the Python plugin
|
||||
// returns a (result, ticket) tuple) and falls back to this default when there's no override.
|
||||
int request_bind_ticket(std::string* ticket) override { return ORCA_NETWORK_ERR_CAP_NOT_AVAILABLE; }
|
||||
int get_hms_snapshot(std::string dev_id, std::string file_name, std::function<void(std::string, int)> callback) override
|
||||
{ return ORCA_NETWORK_ERR_CAP_NOT_AVAILABLE; }
|
||||
};
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
@@ -95,59 +95,59 @@ public:
|
||||
FilamentSyncMode get_filament_sync_mode() const override
|
||||
{
|
||||
ORCA_PY_OVERRIDE_AUDITED(
|
||||
[] {}, PYBIND11_OVERRIDE_PURE, FilamentSyncMode, PrinterAgentPluginCapability,
|
||||
[] {}, PYBIND11_OVERRIDE, FilamentSyncMode, PrinterAgentPluginCapability,
|
||||
get_filament_sync_mode);
|
||||
}
|
||||
|
||||
CameraStreamMode get_camera_stream_mode() const override
|
||||
{
|
||||
ORCA_PY_OVERRIDE_AUDITED(
|
||||
[] {}, PYBIND11_OVERRIDE_PURE, CameraStreamMode, PrinterAgentPluginCapability,
|
||||
[] {}, PYBIND11_OVERRIDE, CameraStreamMode, PrinterAgentPluginCapability,
|
||||
get_camera_stream_mode);
|
||||
}
|
||||
|
||||
std::string get_camera_url() const override
|
||||
{
|
||||
ORCA_PY_OVERRIDE_AUDITED(
|
||||
[] {}, PYBIND11_OVERRIDE_PURE, std::string, PrinterAgentPluginCapability, get_camera_url);
|
||||
[] {}, PYBIND11_OVERRIDE, std::string, PrinterAgentPluginCapability, get_camera_url);
|
||||
}
|
||||
|
||||
bool fetch_filament_info(std::string dev_id, FilamentSyncMode sync_mode = FilamentSyncMode::pull) override
|
||||
bool fetch_filament_info(std::string dev_id, FilamentSyncMode sync_mode) override
|
||||
{
|
||||
ORCA_PY_OVERRIDE_AUDITED(
|
||||
[] {}, PYBIND11_OVERRIDE_PURE, bool, PrinterAgentPluginCapability, fetch_filament_info, dev_id);
|
||||
[] {}, PYBIND11_OVERRIDE, bool, PrinterAgentPluginCapability, fetch_filament_info, dev_id, sync_mode);
|
||||
}
|
||||
|
||||
int check_cert() override
|
||||
{
|
||||
ORCA_PY_OVERRIDE_AUDITED(
|
||||
[] {}, PYBIND11_OVERRIDE_PURE, int, PrinterAgentPluginCapability, check_cert);
|
||||
[] {}, PYBIND11_OVERRIDE, int, PrinterAgentPluginCapability, check_cert);
|
||||
}
|
||||
|
||||
void install_device_cert(std::string dev_id, bool lan_only) override
|
||||
{
|
||||
ORCA_PY_OVERRIDE_AUDITED(
|
||||
[] {}, PYBIND11_OVERRIDE_PURE, void, PrinterAgentPluginCapability, install_device_cert, dev_id,
|
||||
[] {}, PYBIND11_OVERRIDE, void, PrinterAgentPluginCapability, install_device_cert, dev_id,
|
||||
lan_only);
|
||||
}
|
||||
|
||||
int ping_bind(std::string ping_code) override
|
||||
{
|
||||
ORCA_PY_OVERRIDE_AUDITED(
|
||||
[] {}, PYBIND11_OVERRIDE_PURE, int, PrinterAgentPluginCapability, ping_bind, ping_code);
|
||||
[] {}, PYBIND11_OVERRIDE, int, PrinterAgentPluginCapability, ping_bind, ping_code);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
ORCA_PY_OVERRIDE_AUDITED(
|
||||
[] {}, PYBIND11_OVERRIDE_PURE, int, PrinterAgentPluginCapability, bind, dev_ip, dev_id,
|
||||
[] {}, PYBIND11_OVERRIDE, int, PrinterAgentPluginCapability, bind, dev_ip, dev_id,
|
||||
dev_model, sec_link, timezone, improved, update_fn);
|
||||
}
|
||||
|
||||
int unbind(std::string dev_id) override
|
||||
{
|
||||
ORCA_PY_OVERRIDE_AUDITED(
|
||||
[] {}, PYBIND11_OVERRIDE_PURE, int, PrinterAgentPluginCapability, unbind, dev_id);
|
||||
[] {}, PYBIND11_OVERRIDE, int, PrinterAgentPluginCapability, unbind, dev_id);
|
||||
}
|
||||
|
||||
int start_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn) override
|
||||
@@ -174,7 +174,7 @@ public:
|
||||
int get_hms_snapshot(std::string dev_id, std::string file_name, std::function<void(std::string, int)> callback) override
|
||||
{
|
||||
ORCA_PY_OVERRIDE_AUDITED(
|
||||
[] {}, PYBIND11_OVERRIDE_PURE, int, PrinterAgentPluginCapability, get_hms_snapshot, dev_id,
|
||||
[] {}, PYBIND11_OVERRIDE, int, PrinterAgentPluginCapability, get_hms_snapshot, dev_id,
|
||||
file_name, callback);
|
||||
}
|
||||
|
||||
@@ -237,6 +237,8 @@ public:
|
||||
// request_bind_ticket returns its ticket through a std::string* out-param, which pybind11
|
||||
// cannot marshal back through a plain override. We dispatch manually: the Python plugin
|
||||
// returns a (result, ticket) tuple, which we unpack into the int result and the out-param.
|
||||
// Not required to be implemented, so a missing override falls back to the base default
|
||||
// instead of failing, mirroring what PYBIND11_OVERRIDE does for the other optional methods.
|
||||
int request_bind_ticket(std::string* ticket) override
|
||||
{
|
||||
ORCA_PY_AUDIT_SCOPE();
|
||||
@@ -247,7 +249,7 @@ public:
|
||||
pybind11::function override =
|
||||
pybind11::get_override(static_cast<const PrinterAgentPluginCapability*>(this), "request_bind_ticket");
|
||||
if (!override)
|
||||
pybind11::pybind11_fail("Tried to call pure virtual function \"PrinterAgentPluginCapability::request_bind_ticket\"");
|
||||
return PrinterAgentPluginCapability::request_bind_ticket(ticket);
|
||||
try {
|
||||
pybind11::tuple result = override().cast<pybind11::tuple>();
|
||||
if (ticket)
|
||||
|
||||
Reference in New Issue
Block a user