Skip to content

Commit

Permalink
Have DeviceWithLocations.locations return a named tuple that maps loc…
Browse files Browse the repository at this point in the history
…ations to a bool
  • Loading branch information
awalter-bnl committed Aug 5, 2024
1 parent 3975b39 commit ea7453a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
Binary file modified src/ari_sxn_common/__pycache__/ari_ophyd.cpython-312.pyc
Binary file not shown.
Binary file modified src/ari_sxn_common/__pycache__/common_bluesky.cpython-312.pyc
Binary file not shown.
Binary file modified src/ari_sxn_common/__pycache__/common_ophyd.cpython-312.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions src/ari_sxn_common/ari_ophyd.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __init__(self, *args, **kwargs):
# baffle slit sub-device
slits = Component(BaffleSlit, "baffle:", name='slits', kind='normal',
labels=('device',),
locations_data={'in': {'top': (-12.7, 0.1),
locations_data={'all_in': {'top': (-12.7, 0.1),
'bottom': (12.7, 0.1),
'inboard': (12.7, 0.1),
'outboard': (-12.7, 0.1)},
Expand All @@ -104,7 +104,7 @@ def __init__(self, *args, **kwargs):
'bottom': (-12.7, 0.1),
'inboard': (-12.7, 0.1),
'outboard': (12.7, 0.1)},
'out': {'top': (28, 0.1),
'all_out': {'top': (28, 0.1),
'bottom': (-28, 0.1),
'inboard': (-28, 0.1),
'outboard': (28, 0.1)}})
Expand Down
17 changes: 11 additions & 6 deletions src/ari_sxn_common/common_ophyd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections import defaultdict
from collections import defaultdict, namedtuple
from nslsii.devices import TwoButtonShutter
from ophyd import (Component, Device, EpicsMotor)
from ophyd.areadetector.base import ADComponent
Expand Down Expand Up @@ -474,7 +474,7 @@ def get(self, **kwargs):
Returns the result of super().get(**kwargs)
"""
# Determine the locations we are currently 'in'.
locations = []
locations = {}
# Note the next line gives an 'accessing a protected member,
# _locations_data' warning in my editor. I accept the risk !-).
for location, location_data in self.parent._locations_data.items():
Expand Down Expand Up @@ -524,9 +524,11 @@ def get(self, **kwargs):
f'DeviceWithLocations '
f'LocationSignal signals')
if all(value_check):
locations.append(location)

self.put(locations) # Set the value at read time.
locations[location] = True
else:
locations[location] = False
# Set the value at read time.
self.put(self.parent._LocationsTuple(**locations))

return super().get(**kwargs) # run the parent get function.

Expand Down Expand Up @@ -596,7 +598,10 @@ class specific attributes. See the class doc-string for parameter
locations_data = {}
self._locations_data = locations_data

locations = Component(LocationSignal, value=[], name='locations',
self._LocationsTuple = namedtuple('Locations',
self._locations_data.keys())

locations = Component(LocationSignal, name='locations',
kind='config', labels=('position',))


Expand Down

0 comments on commit ea7453a

Please sign in to comment.