Add CrealityPrintAgent for CFS filament sync

Subclass of MoonrakerPrinterAgent for K-series Creality printers
(K2, K2 Plus, K2 Pro) with CFS support. Registers in
NetworkAgentFactory under host_type=crealityprint. Overrides
fetch_filament_info() to defer to base when the host is not a
CFS-capable K-series board, otherwise query the boxsInfo WebSocket
on port 9999, parse the box hierarchy into CFSSlot[], and publish
each loaded slot as an AmsTrayData entry via build_ams_payload()
so they surface in Orca filament UI.

boxsInfo schema reference (verified against K2 Combo F021 firmware
v1.1.260206):
  materialBoxs[].materials[] fields: id, state, vendor, type, name,
  color, pressure, rfid, percent. state=1 means loaded; box.type=0
  is a CFS unit, type=1 is the external spool holder (handled by
  the upload dialog).

Accepted CFS boxes are renumbered sequentially since the K2 raw
box.id has gaps for the external spool holder. Model detection is
delegated to CrealityPrint::supports_multi_color_print() added in
PR #13291.
This commit is contained in:
grant0013
2026-05-19 16:01:13 +00:00
parent 4e4dd708b9
commit d1a33d2efd
4 changed files with 299 additions and 0 deletions
+4
View File
@@ -6,6 +6,7 @@
#include "QidiPrinterAgent.hpp"
#include "SnapmakerPrinterAgent.hpp"
#include "MoonrakerPrinterAgent.hpp"
#include "CrealityPrintAgent.hpp"
#include <boost/log/trivial.hpp>
#include <map>
#include <mutex>
@@ -133,6 +134,9 @@ void NetworkAgentFactory::register_all_agents()
register_agent<OrcaPrinterAgent>();
register_agent<QidiPrinterAgent>();
register_agent<SnapmakerPrinterAgent>();
register_agent<CrealityPrintAgent>(); // Must come BEFORE MoonrakerPrinterAgent —
// CrealityPrintAgent extends Moonraker behaviour
// for K-series boards with CFS support.
register_agent<MoonrakerPrinterAgent>();
// BBLPrinterAgent takes no constructor args, so register manually