mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-21 18:02:09 +00:00
harktech: move CFS sync into CrealityPrintAgent::fetch_filament_info
Address SoftFever review item 1 on #13752: CFS sync now lives in CrealityPrintAgent::fetch_filament_info, matching the MoonrakerPrinterAgent / QidiPrinterAgent / SnapmakerPrinterAgent shape. The standard Sidebar::sync_ams_list -> DeviceManager::get_selected_machine() -> Sidebar::load_ams_list(obj) -> Sidebar::build_filament_ams_list(obj) -> agent->fetch_filament_info(dev_id) -> build_ams_payload(box_count, max_lane_index, trays) path now applies to CrealityPrint hosts identically to the other Klipper-flavoured agents. CrealityPrintAgent inherits MoonrakerPrinterAgent, so the inherited connect_printer() -> announce_printhost_device() -> SSDP callback already triggers MachineObject creation in DeviceManager's localMachineList for K-series LAN hosts; the Plater-side special case was simply bypassing get_selected_machine() before it could fire. Removed: * The if (host_type == htCrealityPrint) block in Sidebar::sync_ams_list (and the CrealityPrintAgent.hpp include it required). * The static CrealityPrintAgent::sync_filaments_into_ams_list() helper that wrote directly to PresetBundle::filament_ams_list, plus the CFSAmsListResult status struct that surfaced dialog text back to the Sidebar. CrealityPrintAgent::fetch_filament_info itself is unchanged - it was already calling the inherited build_ams_payload() correctly. Net diff: 227 deletions / 4 insertions across 3 files. No behaviour change. Discovery + WS protocol parsing unchanged.
This commit is contained in:
@@ -66,7 +66,6 @@
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "slic3r/Utils/CrealityPrint.hpp"
|
||||
#include "slic3r/Utils/CrealityPrintAgent.hpp"
|
||||
#include "libslic3r/ClipperUtils.hpp"
|
||||
#include "libslic3r/ObjColorUtils.hpp"
|
||||
// For stl export
|
||||
@@ -3481,68 +3480,6 @@ void Sidebar::load_ams_list(MachineObject* obj)
|
||||
|
||||
void Sidebar::sync_ams_list(bool is_from_big_sync_btn)
|
||||
{
|
||||
// K-series Creality CFS hosts don't bind a MachineObject (BBL cloud-printer
|
||||
// concept), so the dispatch below would early-return. Delegate to
|
||||
// CrealityPrintAgent which queries CFS state and populates filament_ams_list
|
||||
// directly, then surface the result here as the appropriate dialog + refresh.
|
||||
if (auto* preset_bundle = wxGetApp().preset_bundle) {
|
||||
const auto& printer_cfg = preset_bundle->printers.get_edited_preset().config;
|
||||
const auto* host_type_opt = printer_cfg.option<ConfigOptionEnum<PrintHostType>>("host_type");
|
||||
if (host_type_opt && host_type_opt->value == htCrealityPrint) {
|
||||
wxBusyCursor cursor;
|
||||
auto result = CrealityPrintAgent::sync_filaments_into_ams_list(printer_cfg, preset_bundle);
|
||||
using R = CrealityPrintAgent::CFSAmsListResult;
|
||||
switch (result.status) {
|
||||
case R::NotCfsCapable: {
|
||||
MessageDialog dlg(this,
|
||||
_L("This printer is not a CFS-capable K-series board, or could not be reached at its configured IP."),
|
||||
_L("Sync filaments from CFS"), wxOK);
|
||||
dlg.ShowModal();
|
||||
return;
|
||||
}
|
||||
case R::QueryFailed: {
|
||||
MessageDialog dlg(this,
|
||||
_L("Could not read CFS slot information from the printer.") + "\n" + from_u8(result.detail),
|
||||
_L("Sync filaments from CFS"), wxOK);
|
||||
dlg.ShowModal();
|
||||
return;
|
||||
}
|
||||
case R::EmptySlots: {
|
||||
MessageDialog dlg(this,
|
||||
_L("No loaded filament slots detected on the CFS."),
|
||||
_L("Sync filaments from CFS"), wxOK);
|
||||
dlg.ShowModal();
|
||||
return;
|
||||
}
|
||||
case R::NoMatches: {
|
||||
MessageDialog dlg(this,
|
||||
_L("CFS slots were read but no compatible filament presets resolved. "
|
||||
"Enable the relevant filament profiles via the Filaments tickbox in printer settings."),
|
||||
_L("Sync filaments from CFS"), wxOK);
|
||||
dlg.ShowModal();
|
||||
return;
|
||||
}
|
||||
case R::Success:
|
||||
break; // fall through to UI refresh below
|
||||
}
|
||||
|
||||
// Mirror the BBL post-sync refresh sequence.
|
||||
auto& filament_presets = preset_bundle->filament_presets;
|
||||
wxGetApp().plater()->on_filament_count_change(result.applied_filament_count);
|
||||
for (auto& c : p->combos_filament)
|
||||
c->update();
|
||||
update_filaments_area_height();
|
||||
Layout();
|
||||
wxGetApp().get_tab(Preset::TYPE_FILAMENT)->select_preset(filament_presets[0]);
|
||||
preset_bundle->export_selections(*wxGetApp().app_config);
|
||||
update_dynamic_filament_list();
|
||||
|
||||
BOOST_LOG_TRIVIAL(warning)
|
||||
<< "Sidebar::sync_ams_list: CFS sync applied " << result.applied_filament_count << " slot(s)";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
wxBusyCursor cursor;
|
||||
// Force load ams list
|
||||
auto obj = wxGetApp().getDeviceManager()->get_selected_machine();
|
||||
|
||||
Reference in New Issue
Block a user