diff options
| author | Christian Kolset <ckolset@colostate.edu> | 2026-07-29 15:44:24 -0600 |
|---|---|---|
| committer | Christian Kolset <ckolset@colostate.edu> | 2026-07-29 15:44:24 -0600 |
| commit | 767f1b013dffb8124a389997a2dbf2f06937a1d4 (patch) | |
| tree | 06f20f442ed0e810eb544b740e47089ebb8d8a41 /devices/serial_device.py | |
| parent | 34c8b0950398c07e84777479f3534615907f4f58 (diff) | |
| parent | 9360dea6e6327004b905eb6d7c782cc7c0d3ba13 (diff) | |
Merge branch 'fix/control-channel-direction-filter'
# Conflicts:
# ui/control_editor.py
Diffstat (limited to 'devices/serial_device.py')
| -rw-r--r-- | devices/serial_device.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/devices/serial_device.py b/devices/serial_device.py index 449956b..fb131aa 100644 --- a/devices/serial_device.py +++ b/devices/serial_device.py @@ -273,6 +273,7 @@ class SerialDevice(BaseDevice): unit=sc.get("unit", ""), min_value=-1e9, max_value=1e9, color=_COLORS[i % len(_COLORS)], + writable=bool(sc.get("write_cmd")), ) for i, sc in enumerate(self._scpi_channels) ] @@ -284,6 +285,8 @@ class SerialDevice(BaseDevice): unit=mc.get("unit", ""), min_value=-1e9, max_value=1e9, color=_COLORS[i % len(_COLORS)], + # Holding registers (FC03) accept writes (FC06); input registers (FC04) don't. + writable=(mc.get("function_code", 0x03) == 0x03), ) for i, mc in enumerate(self._mb_channels) ] @@ -293,8 +296,8 @@ class SerialDevice(BaseDevice): 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]), + ChannelConfig("zero", "Zero Gauge", "", 0.0, 1.0, color=_COLORS[2], writable=True), + ChannelConfig("cycle_units", "Cycle Units", "", 0.0, 1.0, color=_COLORS[3], writable=True), ] elif fmt == "cml": _CMD_UNITS = {"TP": "counts", "TV": "counts/s", "TC": "%×10", "TS": "flags"} @@ -320,6 +323,7 @@ class SerialDevice(BaseDevice): unit=_WRITE_UNITS.get(cmd, ""), min_value=-1e6, max_value=1e6, color=_COLORS[color_idx % len(_COLORS)], + writable=True, )) color_idx += 1 # Write-only action channels — motor must be enabled (ME) before VS/MA take effect @@ -330,6 +334,7 @@ class SerialDevice(BaseDevice): unit="", min_value=0.0, max_value=1.0, color=_COLORS[color_idx % len(_COLORS)], + writable=True, )) color_idx += 1 return channels or [ChannelConfig("M1_TP", "M1 TP", "counts", color=_COLORS[0])] |
