Ensure live float values always display with a decimal point

Adds _fmt_float() helper that formats 32-bit floats with :.6g precision
but appends .0 when the result has no decimal point, matching Niagara
and .sax file display conventions (e.g. 175.0 not 175, 0.0 not 0).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-12 14:10:35 +03:00
co-authored by Claude Opus 4.6
parent ef80bf9a37
commit 48671585dd
2 changed files with 11 additions and 3 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 os
VERSION = "0.0.0.088"
VERSION = "0.0.0.089"
PROPERTIES_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "editor.properties")
DEFAULT_GRID_SIZE = 10
DEFAULT_ADD_TIMESTAMP = True
+10 -2
View File
@@ -13,6 +13,14 @@ import schema
from sox import SoxClient, SoxComponent, TREE, CONFIG, RUNTIME, LINKS, ALL
def _fmt_float(val):
"""Format a 32-bit float for display: 6 significant digits, always with a decimal point."""
s = f"{val:.6g}"
if "." not in s and "e" not in s and "E" not in s:
s += ".0"
return s
class DeviceSession:
"""High-level session manager for a live Sedona device connection."""
@@ -268,7 +276,7 @@ class DeviceSession:
if name in sox_comp.values:
val = sox_comp.values[name]
if isinstance(val, float):
val_str = f"{val:.6g}"
val_str = _fmt_float(val)
else:
val_str = str(val)
ET.SubElement(comp_elem, "prop",
@@ -366,7 +374,7 @@ class DeviceSession:
name = slot["name"]
if name in sox_comp.values:
raw = sox_comp.values[name]
val = f"{raw:.6g}" if isinstance(raw, float) else str(raw)
val = _fmt_float(raw) if isinstance(raw, float) else str(raw)
if name in existing_props:
existing_props[name].set("val", val)
else: