Fix live wiresheet links and DOM structure to match .sax format
- Build root children directly under <app> instead of wrapping them in a <comp name="app"> element. This matches the .sax DOM structure where <app> is the container, so component paths like /AHU/TmpCont/X match between link references and get_component_path. - Fix _comp_path to produce /AHU/TmpCont/X format (skip root id 0, leading /) matching the .sax link path convention. - Format float property values to 4 decimal places instead of full Python float precision (22.0116 vs 22.011558532714844). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+15
-3
@@ -237,7 +237,15 @@ class DeviceSession:
|
||||
|
||||
app_elem = ET.SubElement(sax_root, "app")
|
||||
if root_comp is not None:
|
||||
self._build_comp_element(app_elem, root_comp)
|
||||
# Build children of root directly under <app>, matching .sax format
|
||||
# where <app> IS the root container (not a <comp>)
|
||||
for child_id in root_comp.children:
|
||||
child_comp = self.sox_client.cache_get(child_id)
|
||||
if child_comp is not None:
|
||||
self._build_comp_element(app_elem, child_comp)
|
||||
else:
|
||||
ET.SubElement(app_elem, "comp",
|
||||
name="...", id=str(child_id), type="")
|
||||
|
||||
return sax_root
|
||||
|
||||
@@ -259,8 +267,12 @@ class DeviceSession:
|
||||
name = slot["name"]
|
||||
if name in sox_comp.values:
|
||||
val = sox_comp.values[name]
|
||||
if isinstance(val, float):
|
||||
val_str = f"{val:.4f}".rstrip("0").rstrip(".")
|
||||
else:
|
||||
val_str = str(val)
|
||||
ET.SubElement(comp_elem, "prop",
|
||||
name=name, val=str(val))
|
||||
name=name, val=val_str)
|
||||
|
||||
for child_id in sox_comp.children:
|
||||
child_comp = self.sox_client.cache_get(child_id)
|
||||
@@ -330,7 +342,7 @@ class DeviceSession:
|
||||
if not parts:
|
||||
return None
|
||||
parts.reverse()
|
||||
return "/".join(parts)
|
||||
return "/" + "/".join(parts)
|
||||
|
||||
# ── Update DOM from COV ─────────────────────────────────────
|
||||
|
||||
|
||||
Reference in New Issue
Block a user