Open GDYendell opened 1 year ago
I saw this today and thought it might be something straightforward I could pick up.
I see that __init__
performs more checks as part of the loop through DETECTOR_CONFIG
. Can this whole loop be introduced to read_all_config
and then the code block in __init__
can be replaced by a call to it?
In init
# Initialise configuration parameters and populate the parameter tree
for cfg in self.DETECTOR_CONFIG:
param = self.read_detector_config(cfg)
if param is not None:
setattr(self, cfg, param)
# Check if the config item is read/write
writeable = False
if 'access_mode' in param:
if param['access_mode'] == 'rw':
writeable = True
if writeable is True:
param_tree[self.STR_DETECTOR][self.STR_API][self._api_version][self.STR_CONFIG][cfg] = (lambda x=cfg: self.get_value(getattr(self, x)),
lambda value, x=cfg: self.set_value(x, value),
self.get_meta(getattr(self, cfg)))
else:
param_tree[self.STR_DETECTOR][self.STR_API][self._api_version][self.STR_CONFIG][cfg] = (lambda x=cfg: self.get_value(getattr(self, x)), self.get_meta(getattr(self, cfg)))
else:
logging.error("Parameter {} has not been implemented for API {}".format(cfg, self._api_version))
self.missing_parameters.append(cfg)
read_all_config
def read_all_config(self):
for cfg in self.DETECTOR_CONFIG:
param = self.read_detector_config(cfg)
setattr(self, cfg, param)
Yeah that does seem wrong. I think it makes sense to only do those checks at the start when deciding to add things to the parameter tree, but it should then read the configs in the parameter tree, not DETECTOR_CONFIG
. I don't know how easy it is to get the list of configs back out from the parameter tree, though.
Call
read_all_config
in__init__
, currently only used after aninitialize
.