Skip to content

Commit 33fb5a0

Browse files
committed
Rename option_config_items and do not cast their values to strings
1 parent b0a569b commit 33fb5a0

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

python/src/eiger_detector/control/eiger_detector.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import zmq
1515
from odin.adapters.parameter_tree import ParameterAccessor, ParameterTree
1616

17-
from .eiger_options import option_config_options
17+
from .eiger_options import eiger_config_options
1818

1919

2020
class EigerDetector(object):
@@ -484,11 +484,7 @@ def set(self, path, value):
484484
return self.initialize_detector()
485485
elif path == 'command/hv_reset':
486486
return self.hv_reset_detector()
487-
else:
488-
# mbbi record will send integers; change to string
489-
if any(option == path.split("/")[-1] for option in option_config_options):
490-
value = str(value)
491-
return self._params.set(path, value)
487+
return self._params.set(path, value)
492488

493489
def get_value(self, item):
494490
# Check if the item has a value field. If it does then return it
@@ -500,7 +496,7 @@ def set_mode(self, mode_type, value):
500496
logging.info("Setting {} mode to {}".format(mode_type, value))
501497
# Intercept integer values and convert to string values where
502498
# option not index is expected
503-
value = option_config_options["mode"].get_option(value)
499+
value = eiger_config_options["mode"].get_option(value)
504500
if mode_type == self.STR_STREAM:
505501
response = self.write_stream_config('mode', value)
506502
param = self.read_stream_config('mode')
@@ -519,8 +515,8 @@ def set_value(self, item, value):
519515
logging.info("Setting {} to {}".format(item, value))
520516
# Intercept integer values and convert to string values where
521517
# option not index is expected
522-
if any(option == item for option in option_config_options):
523-
value = option_config_options[item].get_option(value)
518+
if any(option == item for option in eiger_config_options):
519+
value = eiger_config_options[item].get_option(value)
524520
# First write the value to the hardware
525521
if item in self.DETECTOR_CONFIG:
526522
response = self.write_detector_config(item, value)
@@ -730,12 +726,12 @@ def read_detector_live_image(self):
730726
def intercept_reply(self, item, reply):
731727
# Intercept detector config for options where we convert to index for
732728
# unamabiguous definition and update config to allow these
733-
if any(option == item for option in option_config_options):
729+
if any(option == item for option in eiger_config_options):
734730
# Inconsitency over mapping of index to string
735731
# communication via integer, uniquely converted to mapping as defined in eiger_options
736732
value = reply[u'value']
737-
reply[u'value'] = option_config_options[item].get_index(value)
738-
reply[u'allowed_values'] = option_config_options[item].get_allowed_values()
733+
reply[u'value'] = eiger_config_options[item].get_index(value)
734+
reply[u'allowed_values'] = eiger_config_options[item].get_allowed_values()
739735
return reply
740736

741737
def arm_detector(self):
@@ -803,7 +799,7 @@ def has_stale_parameters(self):
803799

804800
def get_trigger_mode(self):
805801
trigger_idx = self.get_value(self.trigger_mode)
806-
return option_config_options['trigger_mode'].get_option(trigger_idx)
802+
return eiger_config_options['trigger_mode'].get_option(trigger_idx)
807803

808804
def start_acquisition(self):
809805
# Perform the start sequence

python/src/eiger_detector/control/eiger_options.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ def __init__(self, options):
44
self.options = options
55

66
def get_allowed_values(self):
7-
return list(map(str, range(len(self.options))))
7+
return list(range(len(self.options)))
88

99
def get_option(self, idx):
1010
return self.options[int(idx)]
1111

1212
def get_index(self, val):
13-
return str(self.options.index(val))
13+
return self.options.index(val)
1414

1515

16-
option_config_options = {'compression': EigerOption(['lz4', 'bslz4']),
16+
eiger_config_options = {'compression': EigerOption(['lz4', 'bslz4']),
1717
'trigger_mode': EigerOption(['ints', 'inte', 'exts', 'exte']),
1818
'header_detail': EigerOption(['all', 'basic', 'none']),
1919
'mode': EigerOption(['disabled', 'enabled'])}

0 commit comments

Comments
 (0)