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:
2026-09-12 13:55:12 +03:00
co-authored by Claude Opus 4.6
parent 4e38847f91
commit 89aab50948
2 changed files with 16 additions and 4 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ so later rebinding would only ever be seen by the module that did it.
import configparser import configparser
import os import os
VERSION = "0.0.0.085" VERSION = "0.0.0.086"
PROPERTIES_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "editor.properties") PROPERTIES_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "editor.properties")
DEFAULT_GRID_SIZE = 10 DEFAULT_GRID_SIZE = 10
DEFAULT_ADD_TIMESTAMP = True DEFAULT_ADD_TIMESTAMP = True
+15 -3
View File
@@ -237,7 +237,15 @@ class DeviceSession:
app_elem = ET.SubElement(sax_root, "app") app_elem = ET.SubElement(sax_root, "app")
if root_comp is not None: 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 return sax_root
@@ -259,8 +267,12 @@ class DeviceSession:
name = slot["name"] name = slot["name"]
if name in sox_comp.values: if name in sox_comp.values:
val = sox_comp.values[name] 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", ET.SubElement(comp_elem, "prop",
name=name, val=str(val)) name=name, val=val_str)
for child_id in sox_comp.children: for child_id in sox_comp.children:
child_comp = self.sox_client.cache_get(child_id) child_comp = self.sox_client.cache_get(child_id)
@@ -330,7 +342,7 @@ class DeviceSession:
if not parts: if not parts:
return None return None
parts.reverse() parts.reverse()
return "/".join(parts) return "/" + "/".join(parts)
# ── Update DOM from COV ───────────────────────────────────── # ── Update DOM from COV ─────────────────────────────────────