From 0fa9194813cf727bedfc5c21f932a23e22aec425 Mon Sep 17 00:00:00 2001 From: thysson2701 Date: Tue, 16 Jun 2026 19:52:09 +0200 Subject: [PATCH] fix(ams): leerer AMS-Slot zeigt kein altes Filament mehr (Moonraker/KX-Bridge) Bei Pull-Mode-Agents (Moonraker/AMS-Lite) wird das DevAmsTray-Objekt zwischen Updates gemergt statt neu aufgebaut. Ein Slot, der zuvor belegt war und jetzt leer ist (placeholder bzw. exist-Bit nicht gesetzt), behielt Name/Typ/Farbe des alten Filaments und wurde als belegt gerendert. - ParseV1_0: is_slot_placeholder jedes Update neu setzen; bei leerem Slot setting_id/m_fila_type/color/sub_brands/cols aktiv zuruecksetzen. - AMSItem::parse_ams_info: Placeholder-Slot unabhaengig von stale is_exists als leer (grau) rendern, Position bleibt erhalten. --- src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp | 22 ++++++++++++++++++--- src/slic3r/GUI/Widgets/AMSItem.cpp | 8 +++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp b/src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp index 8f35ccf4548..02a3ab34381 100644 --- a/src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp +++ b/src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp @@ -612,9 +612,10 @@ void DevFilaSystemParser::ParseV1_0(const json& jj, MachineObject* obj, DevFilaS { curr_tray->remain = -1; } - if (tray_it->contains("tray_slot_placeholder")) { - curr_tray->is_slot_placeholder = true; - } + // Reset the placeholder flag every update so a slot that + // was empty before but is now loaded does not stay marked + // as a placeholder (and vice versa). + curr_tray->is_slot_placeholder = tray_it->contains("tray_slot_placeholder"); int ams_id_int = 0; int tray_id_int = 0; try @@ -638,6 +639,21 @@ void DevFilaSystemParser::ParseV1_0(const json& jj, MachineObject* obj, DevFilaS catch (...) { } + // An empty slot (placeholder or exist-bit not set) must not + // keep the previously loaded filament's name/type/color from + // an earlier update. The Moonraker/AMS-Lite bridge reports + // empty slots with a placeholder + cleared fields, but the + // tray object is merged (not rebuilt) between updates, so the + // stale values would otherwise survive and the slot would + // render as loaded. Reset them explicitly. + if (curr_tray->is_slot_placeholder || !curr_tray->is_exists) + { + curr_tray->setting_id = ""; + curr_tray->m_fila_type = ""; + curr_tray->color = ""; + curr_tray->sub_brands = ""; + curr_tray->cols.clear(); + } if (tray_it->contains("setting_id")) { curr_tray->filament_setting_id = (*tray_it)["setting_id"].get(); diff --git a/src/slic3r/GUI/Widgets/AMSItem.cpp b/src/slic3r/GUI/Widgets/AMSItem.cpp index 129eec9c618..831c6e086a6 100644 --- a/src/slic3r/GUI/Widgets/AMSItem.cpp +++ b/src/slic3r/GUI/Widgets/AMSItem.cpp @@ -69,7 +69,13 @@ bool AMSinfo::parse_ams_info(MachineObject *obj, DevAms *ams, bool remain_flag, auto it = ams->GetTrays().find(std::to_string(i)); Caninfo info; // tray is exists - if (it != ams->GetTrays().end() && it->second->is_exists) { + // A placeholder slot is explicitly empty (reported by the Moonraker/AMS-Lite + // bridge): treat it as empty regardless of any stale is_exists/filament data + // left over from a previous update, so it renders grey at its position + // instead of showing the previously loaded filament. + const bool tray_present = it != ams->GetTrays().end() && it->second->is_exists + && !it->second->is_slot_placeholder; + if (tray_present) { if (it->second->is_tray_info_ready()) { info.can_id = it->second->id; info.ctype = it->second->ctype;