fix(spoolman): repair dead slot-map persistence + isolate it per printer #83
Reference in New Issue
Block a user
No description provided.
Delete Branch "walterioo/KX-Bridge-Release:fix/spoolman-persist-per-printer"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
Fixes the two Spoolman slot→spool persistence bugs from #80.
Bug 1 — persistence was a no-op. The load (
__init__) and save (handle_kx_spoolman_set_active) calledconfig_loader.…, but the module is imported asenv_loader(kobrax_moonraker_bridge.py:32), so it threw aNameErrorthat the bareexceptswallowed. The mapping was never read on startup or written on change — it only survived in memory for the session. Now it goes through a local import and logs failures vialog.warninginstead of silently eating them.Bug 2 — the map was global. It lived in one
[spoolman] slot_spoolskey shared by every printer instance, so two AMS units clobbered each other. Now each printer gets its own[spoolman_<id>]section, with a read-fallback to the legacy global key so existing single-printer setups keep working. Mirrors the[filament_profiles_<id>]pattern from #75.Also in here:
_build_mmu_objectemits a realgate_spool_idfrom the per-printer map (was hardcoded[-1]), so Happy-Hare/OrcaSlicer can show the bound spool.[object Object]instead of the vendor name — it usedsp.filament.vendor(the object) instead ofsp.filament.vendor.name; aligned it with the slot-card builder that already does this.config.ini.exampledocuments the[spoolman]section.Related Issue
Closes #80
Type
Tested with
After a restart each printer loads its own
[spoolman_<id>]map, isolated. A real 2-color print on the second printer deducted per slot — the dominant color landed at 38.81 g vs the slicer's 38.73 g estimate, the other color went to its own spool, and the unused slots stayed at 0 — confirming the mm-based deduction hits the right printer's spools. New tests intests/test_spoolman_slot_map.py;flake8clean on the changed code andpytestgreen locally.Checklist