diff options
Diffstat (limited to 'devices')
| -rw-r--r-- | devices/arduino_device.py | 1 | ||||
| -rw-r--r-- | devices/base_device.py | 1 | ||||
| -rw-r--r-- | devices/digital_io.py | 1 | ||||
| -rw-r--r-- | devices/nidaqmx_device.py | 1 | ||||
| -rw-r--r-- | devices/serial_device.py | 9 |
5 files changed, 11 insertions, 2 deletions
diff --git a/devices/arduino_device.py b/devices/arduino_device.py index 8293a23..2f5e8e6 100644 --- a/devices/arduino_device.py +++ b/devices/arduino_device.py @@ -108,6 +108,7 @@ class ArduinoDevice(BaseDevice): channels.append(ChannelConfig( channel_id=f"do{i}", name=f"DO {i}", unit="", min_value=0.0, max_value=1.0, + writable=True, color=_DO_COLORS[i % len(_DO_COLORS)], )) diff --git a/devices/base_device.py b/devices/base_device.py index 32fe787..83b8536 100644 --- a/devices/base_device.py +++ b/devices/base_device.py @@ -29,6 +29,7 @@ class ChannelConfig: max_value: float = 100.0 enabled: bool = True color: str = "#00d4ff" + writable: bool = False # True if this channel accepts write_channel() calls extra: Dict[str, Any] = field(default_factory=dict) diff --git a/devices/digital_io.py b/devices/digital_io.py index f60c330..7cda61f 100644 --- a/devices/digital_io.py +++ b/devices/digital_io.py @@ -60,6 +60,7 @@ class DigitalIODevice(BaseDevice): channel_id=f"do{i}", name=f"DO {i}", unit="", min_value=0.0, max_value=1.0, color=_OUT_COLORS[i % len(_OUT_COLORS)], + writable=True, )) info = DeviceInfo( diff --git a/devices/nidaqmx_device.py b/devices/nidaqmx_device.py index 9d9747e..9ebec0f 100644 --- a/devices/nidaqmx_device.py +++ b/devices/nidaqmx_device.py @@ -69,6 +69,7 @@ class NidaqmxDevice(BaseDevice): channel_id=f"do{i}", name=f"DO {i}", unit="", min_value=0.0, max_value=1.0, color=_DO_COLORS[i % len(_DO_COLORS)], + writable=True, )) info = DeviceInfo( 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])] |
