summaryrefslogtreecommitdiffstats
path: root/lab_control/test/mock_jds6600_device.py
diff options
context:
space:
mode:
Diffstat (limited to 'lab_control/test/mock_jds6600_device.py')
-rw-r--r--lab_control/test/mock_jds6600_device.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/lab_control/test/mock_jds6600_device.py b/lab_control/test/mock_jds6600_device.py
index 6e036d5..a8f755b 100644
--- a/lab_control/test/mock_jds6600_device.py
+++ b/lab_control/test/mock_jds6600_device.py
@@ -5,12 +5,17 @@ import threading
import re
class MockJDS6600Device():
+ class ChannelState:
+ def __init__(self):
+ self.on = False
+ self.frequency = 0.0
+
def __init__(self):
self._master, self._slave = pty.openpty()
self._masterFile = os.fdopen(self._master, mode="r+b", closefd=False, buffering=0)
self._portName = os.ttyname(self._slave)
- self._channels = [False, False]
+ self._channels = [MockJDS6600Device.ChannelState() for i in [1, 2]]
self._mainThread = threading.Thread(target=self._mainLoop)
self._mainThread.start()
@@ -38,12 +43,20 @@ class MockJDS6600Device():
args = m.group("args").split(",")
if opcode == "w":
+ # channel on/off
if function == 20:
- self._channels[0] = args[0] == "1"
- self._channels[1] = args[1] == "1"
+ self._channels[0].on = args[0] == "1"
+ self._channels[1].on = args[1] == "1"
+
+ # channel frequency
+ elif function == 23 or function == 24:
+ ch = function - 23
+ frequency = float(args[0])
+ self._channels[ch].frequency = frequency
+
elif opcode == "r":
if function == 20:
- return f":r20={int(self._channels[0])},{int(self._channels[1])}.\r\n"
+ return f":r20={int(self._channels[0].on)},{int(self._channels[1].on)}.\r\n"
return ":ok\r\n"
@@ -67,5 +80,8 @@ class MockJDS6600Device():
return self._portName
def isOn(self, ch: int) -> bool:
- return self._channels[ch - 1]
+ return self._channels[ch - 1].on
+
+ def getFrequency(self, ch: int) -> float:
+ return self._channels[ch - 1].frequency