Skip to content

Commit

Permalink
bug fix names_of_states
Browse files Browse the repository at this point in the history
  • Loading branch information
kay-jahnke committed Nov 16, 2020
1 parent b88b20b commit 96afe10
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion hardware/switches/osw12.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class OSW12(Base, SwitchInterface):
module.Class: 'switches.osw12.OSW12'
interface: 'ASRL1::INSTR'
names_of_states: ['Off', 'On']
names_of_switches: ['Detection']
names_of_switches: 'Detection'
name: 'MEMS Fibre Switch'
"""

Expand Down Expand Up @@ -100,6 +100,9 @@ def on_activate(self):
and len(self._names_of_states[0]) > 1:
self._names_of_states = {switch: [str(name) for name in self._names_of_states[index]]
for index, switch in enumerate(self._names_of_switches)}
elif isinstance(self._names_of_states, (list, tuple)) \
and isinstance(self._names_of_states[0], str):
self._names_of_states = {self._names_of_switches[0]: list(self._names_of_states)}
else:
self.log.error(f'names_of_states must be a list of length {len(self._names_of_switches)}, '
f'with the elements being a list of two or more names for the states.')
Expand Down

0 comments on commit 96afe10

Please sign in to comment.