Support non-0.4mm nozzles in AMS Slot config + guard dispatch (#1899)

The Configure AMS Slot picker was hardwired to 0.4mm (nozzleDiameter
prop never passed from PrintersPage / SpoolBuddyAmsPage), so a 0.6
machine could only set 0.4 profiles on its trays. Resolve the real
installed nozzle per-AMS (ams_extruder_map on dual-nozzle) and pass it
in. Separately, nothing validated the sliced nozzle against the
installed one, so a mismatch reached the printer as a cryptic HMS
_8012 "Failed to get AMS mapping table". Add a fail-safe pre-dispatch
guard in _start_print that fails the item with an actionable message
before upload; no slice diameter or no reported nozzles = no-op.
This commit is contained in:
maziggy
2026-07-08 08:57:56 +02:00
parent 55ea4b19c9
commit bb3e2a710e
9 changed files with 568 additions and 143 deletions
+26
View File
@@ -343,6 +343,32 @@ export function filterFilamentsByNozzle<T extends { extruderId?: number }>(
);
}
/**
* Resolve the installed nozzle diameter feeding a given AMS unit, so the
* Configure-AMS-Slot picker filters filament presets by the nozzle actually on
* the machine instead of assuming 0.4mm (#1899).
*
* On dual-nozzle printers (H2D) each AMS is bound to one extruder via
* `ams_extruder_map` (amsId → extruder index, 0=left/primary, 1=right), so we
* read that nozzle's diameter. Single-nozzle printers have no map entry and
* fall back to the primary nozzle (index 0). Returns undefined when the printer
* hasn't reported nozzle hardware yet, letting the caller keep its own default.
* Diameter is the bare decimal string the status carries, e.g. "0.4" / "0.6".
*/
export function resolveSlotNozzleDiameter(
status: {
nozzles?: { nozzle_diameter?: string }[];
ams_extruder_map?: Record<string, number>;
} | null | undefined,
amsId: number,
): string | undefined {
const nozzles = status?.nozzles;
if (!nozzles || nozzles.length === 0) return undefined;
const extruderIdx = status?.ams_extruder_map?.[String(amsId)] ?? 0;
const diameter = nozzles[extruderIdx]?.nozzle_diameter || nozzles[0]?.nozzle_diameter;
return diameter || undefined;
}
/**
* Detect Bambu Lab RFID-tagged spool by tray_uuid (32 hex) or tag_uid (16 hex).
*