mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-19 07:33:18 +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:
@@ -0,0 +1,25 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
import { getAmsLabel } from '../../utils/amsHelpers';
|
||||
|
||||
describe('getAmsLabel', () => {
|
||||
it('labels regular AMS units A/B/C by id', () => {
|
||||
expect(getAmsLabel(0, 4)).toBe('AMS-A');
|
||||
expect(getAmsLabel(1, 4)).toBe('AMS-B');
|
||||
});
|
||||
|
||||
it('labels AMS-HT units (single tray, id >= 128)', () => {
|
||||
expect(getAmsLabel(128, 1)).toBe('HT-A');
|
||||
expect(getAmsLabel(129, 1)).toBe('HT-B');
|
||||
});
|
||||
|
||||
it('labels the external spool', () => {
|
||||
expect(getAmsLabel(255, 1)).toBe('External');
|
||||
});
|
||||
|
||||
it('labels the A2L AMS Lite (normalised unit id 6) distinctly', () => {
|
||||
// The backend normalises the A2L Lite's physical unit 16 -> 6; no regular
|
||||
// AMS uses id 6, so it never collides with the A/B/C range.
|
||||
expect(getAmsLabel(6, 4)).toBe('AMS Lite');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user