diff --git a/src/genie_python/genie.py b/src/genie_python/genie.py index b32ccfbf..edd3e32c 100644 --- a/src/genie_python/genie.py +++ b/src/genie_python/genie.py @@ -859,9 +859,9 @@ def connected_pvs_in_list(pv_list: list[str], is_local: bool = False) -> list[st def begin( period: int = 1, meas_id: str | None = None, - meas_type: str = "", - meas_subid: str = "", - sample_id: str = "", + meas_type: str | None = None, + meas_subid: str | None = None, + sample_id: str | None = None, delayed: bool = False, quiet: bool = False, paused: bool = False, diff --git a/src/genie_python/genie_epics_api.py b/src/genie_python/genie_epics_api.py index 559ea99f..3fdb6971 100644 --- a/src/genie_python/genie_epics_api.py +++ b/src/genie_python/genie_epics_api.py @@ -77,6 +77,8 @@ def __init__( self.motion_suffix = "CS:MOT:MOVING" self.pre_post_cmd_manager = PrePostCmdManager() self.logger = GenieLogger() + self._sample_par_names_cache = None + self._beamline_par_names_cache = None if environment_details is None: self._environment_details = EnvironmentDetails() @@ -680,19 +682,21 @@ def set_sample_par(self, name: str, value: "PVValue") -> None: name: the name of the parameter to change value: the new value """ + assert self.blockserver is not None - names = self.blockserver.get_sample_par_names() - if ( - names is not None - and isinstance(names, list) - and all(isinstance(elem, str) for elem in names) - ): + try: + names = self.blockserver.get_sample_par_names() + self._sample_par_names_cache = names + except Exception: + names = self._sample_par_names_cache + if names is not None and isinstance(names, list): for n in names: - m = re.match(".+:SAMPLE:%s" % name.upper(), n) - if m is not None: - # Found it! - self.set_pv_value(self.prefix_pv_name(n), value) - return + if isinstance(n, str): + m = re.match(".+:SAMPLE:%s" % name.upper(), n) + if m is not None: + # Found it! + self.set_pv_value(self.prefix_pv_name(n), value) + return raise Exception("Sample parameter %s does not exist" % name) def get_beamline_pars(self) -> "_GetbeamlineparsReturn": @@ -712,8 +716,14 @@ def set_beamline_par(self, name: str, value: "PVValue") -> None: name: the name of the parameter to change value: the new value """ + assert self.blockserver is not None - names = self.blockserver.get_beamline_par_names() + try: + names = self.blockserver.get_beamline_par_names() + self._beamline_par_names_cache = names + except Exception: + names = self._beamline_par_names_cache + if names is not None: for n in names: m = re.match(".+:BL:%s" % name.upper(), n)