mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-18 11:56:01 +02:00
fix(a2l): normalise AMS Lite unit 16->6 so slots load and deduct (#a2l-am-unit-16)
The A2L reports its 4-slot AMS Lite as unit id 16, but its slot-presence
bitmasks sit at bit base 24 (id 6) and it reports tray_now as a local 0-3
slot. Fed the raw id 16, the ams_id*4+slot convention probed bits 64-67
(always zero) and marked loaded slots empty; the local tray_now was read as
global, so usage deducted from the wrong spool (or not at all); and the
ams_id<=7 DB constraint rejected id-16 Spoolman links.
Normalise the Lite 16->6 at the MQTT ingest boundary so global tray ids land
at 24-27 - matching the firmware's own bit base, working with every existing
ams_id*4+slot consumer, colliding with nothing, and passing the DB
constraint. Globalise tray_now to 24+slot, widen the valid-tray guards, label
the unit "AMS Lite", and build the confirmed ams_mapping2 {ams_id:16,
slot_id:0-3} / flat 0-3 for dispatch. Outbound slot commands translate 6->16
on the wire via a single helper. Self-scoping: only unit id 16 is touched, so
all other printers/AMS types are unaffected. One uncaptured wire field (the
physical global tray on load/cali) is extrapolated and isolated to the helper.
This commit is contained in:
@@ -42,6 +42,10 @@ export function getAmsLabel(amsId: number | string, trayCount: number): string {
|
||||
const id = typeof amsId === 'string' ? parseInt(amsId, 10) : amsId;
|
||||
const safeId = isNaN(id) ? 0 : id;
|
||||
if (safeId === 255) return 'External';
|
||||
// A2L "AMS Lite": the backend normalises its physical unit id 16 to 6 at
|
||||
// ingest (see a2l-am-unit-16). No regular AMS uses id 6, so this is a safe,
|
||||
// self-scoping label for the Lite's 4-slot unit.
|
||||
if (safeId === 6) return 'AMS Lite';
|
||||
const isHt = trayCount === 1;
|
||||
const normalizedId = safeId >= 128 ? safeId - 128 : safeId;
|
||||
const letter = String.fromCharCode(65 + normalizedId);
|
||||
|
||||
Reference in New Issue
Block a user