diff options
| author | Eddy Pedroni <eddy@0xf7.com> | 2022-06-05 16:49:33 +0200 | 
|---|---|---|
| committer | Eddy Pedroni <eddy@0xf7.com> | 2022-06-05 16:49:33 +0200 | 
| commit | d37252c9b6044ce540db54e8b480a85dfc1ec25d (patch) | |
| tree | 74d9c6381dc5f37ed76be42995852e817755c371 /lab_control/test/mock_sds1000xe_device.py | |
| parent | ed42c1a47bc96f6453bb50008481d3467e9254e6 (diff) | |
Moved mocks to separate module
Diffstat (limited to 'lab_control/test/mock_sds1000xe_device.py')
| -rw-r--r-- | lab_control/test/mock_sds1000xe_device.py | 47 | 
1 files changed, 0 insertions, 47 deletions
| diff --git a/lab_control/test/mock_sds1000xe_device.py b/lab_control/test/mock_sds1000xe_device.py deleted file mode 100644 index 04ec07a..0000000 --- a/lab_control/test/mock_sds1000xe_device.py +++ /dev/null @@ -1,47 +0,0 @@ -import re - -class MockSDS1000XEDevice: -    def __init__(self): -        # Mock internal values -        self._channels = [{"AMPL" : None, "VDIV" : None} for i in range(0, 4)] - -    def _handleRequest(self, request: str) -> str: -        m = re.search(r"C(?P<channel>\d):(?P<opcode>\w+)\??\s(?P<arg>.+)", request.strip()) -        if not m: -            return None -         -        channelIndex = int(m.group("channel")) - 1 -        opcode = m.group("opcode") - -        if opcode == "PAVA": -            arg = m.group("arg") -            value = self._channels[channelIndex].get(arg) -            unit = "Hz" if arg == "FREQ" else "V" -             -            if value is None: -                return None -            else: -                response = f"C{m.group('channel')}:PAVA {arg},{value:.6E}{unit}" -                return response -        elif opcode == "VDIV": -            arg = float(m.group("arg").rstrip("V")) -            self._channels[channelIndex]["VDIV"] = arg -            return None - -        return None - -    def setAmplitude(self, channel: int, value: float) -> None: -        self._channels[channel - 1]["AMPL"] = value - -    def setPeakToPeak(self, channel: int, value: float) -> None: -        self._channels[channel - 1]["PKPK"] = value - -    def setRMS(self, channel: int, value: float) -> None: -        self._channels[channel - 1]["RMS"] = value - -    def setFrequency(self, channel: int, value: float) -> None: -        self._channels[channel - 1]["FREQ"] = value - -    def getVoltsPerDivision(self, channel: int) -> float: -        return self._channels[channel - 1]["VDIV"] - | 
