Skip to content

Commit e945684

Browse files
Cache sample and beamline par names
1 parent debd067 commit e945684

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/genie_python/genie_epics_api.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ def __init__(
6868
self.motion_suffix = "CS:MOT:MOVING"
6969
self.pre_post_cmd_manager = PrePostCmdManager()
7070
self.logger = GenieLogger()
71+
self._sample_par_names_cache = None
72+
self._beamline_par_names_cache = None
7173

7274
if environment_details is None:
7375
self._environment_details = EnvironmentDetails()
@@ -624,7 +626,11 @@ def set_sample_par(self, name: str, value: "PVValue") -> None:
624626
name: the name of the parameter to change
625627
value: the new value
626628
"""
627-
names = self.blockserver.get_sample_par_names()
629+
try:
630+
names = self.blockserver.get_sample_par_names()
631+
self._sample_par_names_cache = names
632+
except Exception:
633+
names = self._sample_par_names_cache
628634
if names is not None:
629635
for n in names:
630636
m = re.match(".+:SAMPLE:%s" % name.upper(), n)
@@ -648,7 +654,11 @@ def set_beamline_par(self, name: str, value: "PVValue") -> None:
648654
name: the name of the parameter to change
649655
value: the new value
650656
"""
651-
names = self.blockserver.get_beamline_par_names()
657+
try:
658+
names = self.blockserver.get_beamline_par_names()
659+
self._beamline_par_names_cache = names
660+
except Exception:
661+
names = self._beamline_par_names_cache
652662
if names is not None:
653663
for n in names:
654664
m = re.match(".+:BL:%s" % name.upper(), n)

0 commit comments

Comments
 (0)