Skip to content

Commit f88d2a7

Browse files
committed
Provide default values for commands so Merlin RESET command does something
Fix default value of operating energy Move merlin parameters to parameters.py access merlin commands through dictionary
1 parent f6acda3 commit f88d2a7

File tree

4 files changed

+250
-255
lines changed

4 files changed

+250
-255
lines changed

src/tickit_devices/merlin/adapters.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
from tickit.adapters.specifications.regex_command import RegexCommand
1111
from tickit.adapters.tcp import CommandAdapter
1212

13-
from tickit_devices.merlin.commands import (
13+
from tickit_devices.merlin.merlin import MerlinDetector, State
14+
from tickit_devices.merlin.parameters import (
1415
DLIM,
1516
PREFIX,
1617
CommandType,
1718
ErrorCode,
1819
commands,
1920
)
20-
from tickit_devices.merlin.merlin import MerlinDetector, State
2121
from tickit_devices.merlin.tcp import TcpPushAdapter
2222

2323
LOGGER = logging.getLogger("MerlinControlAdapter")
@@ -48,7 +48,8 @@ async def get(self, parameter: str) -> bytes:
4848
value = "0"
4949
code = ErrorCode.UNDERSTOOD
5050
if (
51-
parameter not in commands[CommandType.GET] + commands[CommandType.SET]
51+
parameter
52+
not in list(commands[CommandType.GET]) + list(commands[CommandType.SET])
5253
or not parameter in self.detector.parameters
5354
):
5455
code = ErrorCode.UNRECOGNISED
@@ -69,7 +70,7 @@ async def get(self, parameter: str) -> bytes:
6970

7071
@RegexCommand(r"MPX,[0-9]{10},CMD,([a-zA-Z0-9]*)$", format="utf-8")
7172
async def cmd(self, command_name: str) -> bytes:
72-
command = getattr(self.detector, f"{command_name}_cmd", None)
73+
command = self.detector.commands.get(command_name, None)
7374
if command_name not in commands[CommandType.CMD] or command is None:
7475
LOGGER.error(f"Merlin does not have a command {command}")
7576
code = ErrorCode.UNRECOGNISED

src/tickit_devices/merlin/commands.py

Lines changed: 0 additions & 104 deletions
This file was deleted.

0 commit comments

Comments
 (0)