Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/genie_python/genie.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
34 changes: 22 additions & 12 deletions src/genie_python/genie_epics_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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":
Expand All @@ -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)
Expand Down
Loading