From b82e8852b3752b18e38a6e8934f6bcacf3d89075 Mon Sep 17 00:00:00 2001 From: Martino Ferrari Date: Wed, 24 Jun 2026 11:12:05 +0200 Subject: [PATCH] feat(logic): round-trip array statevar attributes in panel XML Co-Authored-By: Claude Opus 4.6 --- web/src/lib/xml.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/web/src/lib/xml.ts b/web/src/lib/xml.ts index 4f77fa2..d655f99 100644 --- a/web/src/lib/xml.ts +++ b/web/src/lib/xml.ts @@ -73,6 +73,11 @@ export function serializeInterface(iface: Interface): string { if (sv.unit) attrs.push(`unit="${xmlEsc(sv.unit)}"`); if (sv.low !== undefined) attrs.push(`low="${sv.low}"`); if (sv.high !== undefined) attrs.push(`high="${sv.high}"`); + if (sv.type === 'array') { + if (sv.elem) attrs.push(`elem="${sv.elem}"`); + if (sv.sizing) attrs.push(`sizing="${sv.sizing}"`); + if (sv.capacity !== undefined) attrs.push(`capacity="${sv.capacity}"`); + } lines.push(` `); } if (iface.logic && (iface.logic.nodes.length > 0 || iface.logic.wires.length > 0)) { @@ -213,13 +218,21 @@ export function parseInterface(xml: string): Interface { const low = el.getAttribute('low'); const high = el.getAttribute('high'); const unit = el.getAttribute('unit'); + const elem = el.getAttribute('elem'); + const sizing = el.getAttribute('sizing'); + const capacityAttr = el.getAttribute('capacity'); + const svType: StateVar['type'] = + type === 'bool' || type === 'string' || type === 'array' ? type : 'number'; statevars.push({ name, - type: type === 'bool' || type === 'string' ? type : 'number', + type: svType, initial: el.getAttribute('initial') ?? '', ...(unit ? { unit } : {}), ...(low !== null ? { low: parseFloat(low) } : {}), ...(high !== null ? { high: parseFloat(high) } : {}), + ...(elem ? { elem: elem as StateVar['elem'] } : {}), + ...(sizing ? { sizing: sizing as StateVar['sizing'] } : {}), + ...(capacityAttr !== null ? { capacity: Number(capacityAttr) } : {}), }); }