summaryrefslogtreecommitdiff
path: root/devices
diff options
context:
space:
mode:
Diffstat (limited to 'devices')
-rw-r--r--devices/serial_device.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/devices/serial_device.py b/devices/serial_device.py
index 458aec8..8b8de04 100644
--- a/devices/serial_device.py
+++ b/devices/serial_device.py
@@ -142,7 +142,10 @@ class SerialDevice(BaseDevice):
raw = self._layer.read()
if not raw:
return {}
- # Protocol layers already use channel_id keys — pass through.
+ if self._fmt not in _GENERIC_FORMATS:
+ # Protocol layers already key by channel_id — pass through untouched.
+ # (Write-only channels, e.g. CML "M1_VS", never appear in raw — correctly dropped.)
+ return raw
# Generic (ArduinoLayer) may use arbitrary names — remap by position.
mapped: Dict[str, float] = {}
raw_vals = list(raw.values())
@@ -276,16 +279,20 @@ class SerialDevice(BaseDevice):
elif fmt == "mark10":
from api_layers.protocols.mark10 import UNITS as _MARK10_UNITS
return [
- ChannelConfig("force", "Force", "N", -5000.0, 5000.0, color=_COLORS[0]),
- ChannelConfig("unit_code", "Unit Code", "", 0.0, float(len(_MARK10_UNITS) - 1), color=_COLORS[1]),
+ ChannelConfig("force", "Force", "N", -5000.0, 5000.0, color=_COLORS[0]),
+ ChannelConfig("unit_code", "Unit Code", "", 0.0, float(len(_MARK10_UNITS) - 1), color=_COLORS[1]),
+ # Write-only action channels (no reading — for control buttons)
+ ChannelConfig("zero", "Zero Gauge", "", 0.0, 1.0, color=_COLORS[2]),
+ ChannelConfig("cycle_units", "Cycle Units", "", 0.0, 1.0, color=_COLORS[3]),
]
elif fmt == "cml":
_CMD_UNITS = {"TP": "counts", "TV": "counts/s", "TC": "%×10", "TS": "flags"}
+ _WRITE_UNITS = {"VS": "counts/s", "MA": "counts"}
channels = []
color_idx = 0
for motor in self._motors:
+ mid = motor.get("motor_id", "M1")
for cmd in motor.get("read_cmds", ["TP", "TV", "TC"]):
- mid = motor.get("motor_id", "M1")
channels.append(ChannelConfig(
channel_id=f"{mid}_{cmd}",
name=f"{mid} {cmd}",
@@ -294,6 +301,16 @@ class SerialDevice(BaseDevice):
color=_COLORS[color_idx % len(_COLORS)],
))
color_idx += 1
+ # Write-only setpoint channels (no reading — for control widgets)
+ for cmd in ("VS", "MA"):
+ channels.append(ChannelConfig(
+ channel_id=f"{mid}_{cmd}",
+ name=f"{mid} {cmd}",
+ unit=_WRITE_UNITS.get(cmd, ""),
+ min_value=-1e6, max_value=1e6,
+ color=_COLORS[color_idx % len(_COLORS)],
+ ))
+ color_idx += 1
return channels or [ChannelConfig("M1_TP", "M1 TP", "counts", color=_COLORS[0])]
return []