Skip to content

Commit

Permalink
ENH #567 XIA slits
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Jan 9, 2022
1 parent 1094510 commit cf2bdd9
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apstools/devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
from .xia_pf4 import Pf4FilterSingle
from .xia_pf4 import Pf4FilterTriple

from .xia_slit import XiaSlitController

# synApps
from ..synApps import AsynRecord
from ..synApps import BusyRecord
Expand Down
123 changes: 123 additions & 0 deletions apstools/devices/xia_slit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
"""
XIA Slit from EPICS synApps optics: xia_slit.db
+++++++++++++++++++++++++++++++++++++++++++++++
Coordinates (viewing from detector towards source):
top
inb out
bot
Each blade [#]_ (in the XIA slit controller) travels in a _cylindrical_
coordinate system. Positive motion moves a blade **outwards** from the center
with a backlash correction. No backlash correction is applied for negative
motion (as the blades close).
hsize = inb + out
vsize = top + bot
.. [#] Note that the blade names here are different than the EPICS support.
The difference is to make the names of the blades consistent with other
slits with the Bluesky framework.
USAGE:
slit = XiaSlitController("IOC:hsc1:", name="slit")
print(slit.geometry)
.. autosummary::
~XiaSlit2D
"""

from ophyd import Component
from ophyd import Device
from ophyd import EpicsSignal
from ophyd import EpicsSignalRO
from ..devices import PVPositionerSoftDone
from ophyd import Signal

from ..utils import SlitGeometry


class XiaSlitController(Device):
"""
EPICS synApps optics xia_slit.db 1D support: inb out bot top ...
"""

inb = Component(
PVPositionerSoftDone, "", setpoint_pv="l", readback_pv="lRB"
)
out = Component(
PVPositionerSoftDone, "", setpoint_pv="r", readback_pv="rRB"
)
bot = Component(
PVPositionerSoftDone, "", setpoint_pv="b", readback_pv="bRB"
)
top = Component(
PVPositionerSoftDone, "", setpoint_pv="t", readback_pv="tRB"
)

hsize = Component(
PVPositionerSoftDone, "", setpoint_pv="width", readback_pv="widthRB"
)
vsize = Component(
PVPositionerSoftDone, "", setpoint_pv="height", readback_pv="heightRB"
)
hcenter = Component(
PVPositionerSoftDone, "", setpoint_pv="h0", readback_pv="h0RB"
)
vcenter = Component(
PVPositionerSoftDone, "", setpoint_pv="v0", readback_pv="v0RB"
)

hID = Component(EpicsSignal, "hID", kind="config", string=True)
horientation = Component(EpicsSignal, "hOrient", kind="config", string=True)
hbusy = Component(EpicsSignalRO, "hBusy", kind="omitted", string=True)

vID = Component(EpicsSignal, "vID", kind="config", string=True)
vorientation = Component(EpicsSignal, "vOrient", kind="config", string=True)
vbusy = Component(EpicsSignalRO, "vBusy", kind="omitted", string=True)

enable = Component(EpicsSignal, "enable", kind="config", string=True)

# diagnostics
error_code = Component(EpicsSignalRO, "err", kind="config")
error_message = Component(EpicsSignalRO, "errMsg", kind="config", string=True)
message1 = Component(EpicsSignalRO, "msg1", kind="config", string=True)
message2 = Component(EpicsSignalRO, "msg2", kind="config", string=True)
message3 = Component(EpicsSignalRO, "msg3", kind="config", string=True)

# configuration
calibrate = Component(EpicsSignal, "calib", kind="omitted", put_complete=True)
initialize = Component(EpicsSignal, "init", kind="omitted", put_complete=True)
locate = Component(EpicsSignal, "locate", kind="omitted", put_complete=True)
stop_button = Component(EpicsSignal, "stop", kind="omitted", put_complete=True)

precision = Component(Signal, value=3)

@property
def geometry(self):
"""Return the slit 2D size and center as a namedtuple."""
pppp = [
round(obj.position, self.precision.get())
for obj in (
self.hsize,
self.vsize,
self.hcenter,
self.vcenter
)
]

return SlitGeometry(*pppp)


# -----------------------------------------------------------------------------
# :author: Pete R. Jemian
# :email: jemian@anl.gov
# :copyright: (c) 2017-2022, UChicago Argonne, LLC
#
# Distributed under the terms of the Creative Commons Attribution 4.0 International Public License.
#
# The full license is in the file LICENSE.txt, distributed with this software.
# -----------------------------------------------------------------------------

0 comments on commit cf2bdd9

Please sign in to comment.