From 1c405f8a2c1d174649e4af451195461b8398c07e Mon Sep 17 00:00:00 2001 From: SoftFever Date: Fri, 21 Aug 2026 18:34:20 +0800 Subject: [PATCH] filament_id v4.1: resolve retired QD_* ids in the Qidi box miss path QidiPrinterAgent composes QD___ setting ids from device enums and previously degraded any slot whose id matched no visible preset to generic-by-type. Plan v4.2 retires every QD_* preset id to the succession ledger, so insert the ledger walk between the direct match and the generic fallback: a composed QD_* id now forwards to its family's minted OF* successor exactly like every other retired id. Behavior-neutral until the ids are actually retired (the ledger holds no QD_* keys yet, and live QD_* presets still match directly). Also documents the code<->ledger lockstep on the hardcoded non-numeric- series fallback table (QD_1_0_1/_11/_41/_50) and adds a C++ test pinning that the succession walk is key-format agnostic. Gates: libslic3r_tests [filament_id] 14 assertions green; libslic3r_gui compiles. --- src/slic3r/Utils/QidiPrinterAgent.cpp | 12 +++++++++++- tests/libslic3r/test_filament_id_succession.cpp | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/slic3r/Utils/QidiPrinterAgent.cpp b/src/slic3r/Utils/QidiPrinterAgent.cpp index 6b05480194..22b8d37735 100644 --- a/src/slic3r/Utils/QidiPrinterAgent.cpp +++ b/src/slic3r/Utils/QidiPrinterAgent.cpp @@ -188,7 +188,13 @@ bool QidiPrinterAgent::fetch_slot_info(const std::string& base_url, } else if (!setting_id.empty() && has_visible_base_preset(bundle->filaments, setting_id)) { tray.tray_info_idx = setting_id; } else { - tray.tray_info_idx = bundle->filaments.filament_id_by_type(tray.tray_type); + // Retired QD_* protocol ids forward to their minted successors via the shipped ledger. + const std::string successor = setting_id.empty() ? std::string() + : resolve_filament_id_succession(setting_id); + if (!successor.empty() && has_visible_base_preset(bundle->filaments, successor)) + tray.tray_info_idx = successor; + else + tray.tray_info_idx = bundle->filaments.filament_id_by_type(tray.tray_type); } // Look up color from dictionary @@ -324,6 +330,10 @@ void QidiPrinterAgent::parse_filament_sections(const std::string& content, std:: std::string QidiPrinterAgent::map_filament_type_to_setting_id(const std::string& filament_type) { + // These QD_* protocol ids no longer appear on any preset: they are retired ledger keys + // that parse_box_status resolves through resolve_filament_id_succession(). Each literal + // must stay a ledger key whose chain ends at a live preset id — + // scripts/tests/test_filament_id.py parses this function and enforces that. const std::string upper = trim_and_upper(filament_type); if (upper == "PLA") { diff --git a/tests/libslic3r/test_filament_id_succession.cpp b/tests/libslic3r/test_filament_id_succession.cpp index 36268277f8..12fa82f9bb 100644 --- a/tests/libslic3r/test_filament_id_succession.cpp +++ b/tests/libslic3r/test_filament_id_succession.cpp @@ -34,6 +34,14 @@ TEST_CASE("filament_id succession follows forwarding chains", "[Preset][filament CHECK(follow_filament_id_succession("OFchainB", forwards) == "OFlive00"); CHECK(follow_filament_id_succession("OFchainC", forwards) == "OFlive00"); } + + // QidiPrinterAgent resolves device-composed QD_* protocol ids through this same walk; + // the map key format carries no OF assumption. + SECTION("device-protocol QD_* keys forward like any other id") { + const std::map qd = {{"QD_2_1_11", "OFnew001"}}; + CHECK(follow_filament_id_succession("QD_2_1_11", qd) == "OFnew001"); + CHECK(follow_filament_id_succession("QD_2_1_12", qd).empty()); + } } // Cycles are a ledger-validation error (script check 9) and never ship, but the client