feat(galil-rio): Add di_out channels to GalilRIO

This commit is contained in:
2026-02-16 14:57:02 +01:00
parent 9db56f5273
commit 16ea7f410e
3 changed files with 161 additions and 36 deletions
+24 -2
View File
@@ -274,11 +274,18 @@ def test_galil_rio_signal_read(galil_rio):
assert galil_rio.an_ch0._READ_TIMEOUT == 0.1 # Default read timeout of 100ms
# Mock the socket to return specific values
galil_rio.controller.sock.buffer_recv = [b" 1.234 2.345 3.456 4.567 5.678 6.789 7.890 8.901"]
an_buffer = b" 1.234 2.345 3.456 4.567 5.678 6.789 7.890 8.901\r\n"
di_buffer = b"0.0\r\n"
galil_rio.controller.sock.buffer_recv = [] # Clear any existing buffer
for name in galil_rio.component_names:
if name.startswith("an_ch"):
galil_rio.controller.sock.buffer_recv.append(an_buffer)
elif name.startswith("di_ou"):
galil_rio.controller.sock.buffer_recv.append(di_buffer)
galil_rio._last_readback = 0 # Force read from controller
read_values = galil_rio.read()
assert len(read_values) == 8 # 8 channels
assert len(read_values) == 16 # 16 channels
expected_values = {
galil_rio.an_ch0.name: {"value": 1.234},
galil_rio.an_ch1.name: {"value": 2.345},
@@ -356,3 +363,18 @@ def test_galil_rio_signal_read(galil_rio):
for value in value_callback_buffer[0].values()
]
)
def test_galil_rio_digital_out_signal(galil_rio):
"""
Test that the Galil RIO digital output signal can be set correctly.
"""
# Set digital output channel 0 to high
galil_rio.controller.sock.buffer_recv = [b":"] # Mock response for readback]
galil_rio.di_out0.put(1)
assert galil_rio.controller.sock.buffer_put == [b"SB0\r"]
galil_rio.controller.sock.buffer_recv = [b":"] # Mock response for readback
# Set digital output channel 0 to low
galil_rio.di_out0.put(0)
assert galil_rio.controller.sock.buffer_put == [b"SB0\r", b"CB0\r"]