Skip to content

Commit

Permalink
Merge pull request #1002 from BCDA-APS/975-2M-undulator
Browse files Browse the repository at this point in the history
2M & 4M undulators

@MDecarabas Thanks!
  • Loading branch information
prjemian authored Jul 9, 2024
2 parents 2f4d2f0 + 60a4166 commit d423327
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 8 deletions.
4 changes: 4 additions & 0 deletions apstools/devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
from .aps_machine import ApsMachineParametersDevice

from .aps_undulator import PlanarUndulator
from .aps_undulator import Revolver_Undulator
from .aps_undulator import STI_Undulator
from .aps_undulator import Undulator2M
from .aps_undulator import Undulator4M

from .area_detector_support import AD_EpicsFileNameMixin
from .area_detector_support import AD_FrameType_schemes
Expand Down
45 changes: 44 additions & 1 deletion apstools/devices/aps_undulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
~PlanarUndulator
~Revolver_Undulator
~STI_Undulator
~Undulator2M
~Undulator4M
.. note:: The ``ApsUndulator`` and ``ApsUndulatorDual`` device support
classes have been removed. These devices are not used in the APS-U era.
"""

import logging
Expand Down Expand Up @@ -166,7 +171,7 @@ class Revolver_Undulator(ID_Spectrum_Mixin, ID_Controls_Mixin, ID_Misc_Mixin, De
class STI_Undulator(PlanarUndulator):
"""APS Planar Undulator built by STI Optronics.
.. index::
.. index::
Ophyd Device; PlanarUndulator
Ophyd Device; STI_Undulator
Expand All @@ -178,6 +183,44 @@ class STI_Undulator(PlanarUndulator):
"""


class Undulator2M(ID_Spectrum_Mixin, ID_Controls_Mixin, ID_Misc_Mixin, Device):
"""APS 2M Undulator.
.. index::
Ophyd Device; PlanarUndulator
Ophyd Device; Undulator2M
APS Use: 1ID, downstream.
EXAMPLE::
undulator = Undulator2M("S01ID:DSID:", name="undulator")
"""

# PVs not found
busy = None
magnet = None
version_plc = None
version_hpmu = None

done = Component(EpicsSignalRO, "BusyM.VAL", kind="omitted")
done_value = 0


class Undulator4M(Undulator2M):
"""APS 4M Undulator.
.. index::
Ophyd Device; PlanarUndulator
Ophyd Device; Undulator4M
APS Use: 11ID, downstream & upstream.
EXAMPLE::
undulator = Undulator4M("S11ID:DSID:", name="undulator")
"""

# -----------------------------------------------------------------------------
# :author: Pete R. Jemian
# :email: [email protected]
Expand Down
26 changes: 20 additions & 6 deletions apstools/devices/tests/test_aps_undulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,36 @@
from ophyd.sim import instantiate_fake_device

from ..aps_undulator import PlanarUndulator
from ..aps_undulator import Revolver_Undulator
from ..aps_undulator import STI_Undulator
from ..aps_undulator import Undulator2M
from ..aps_undulator import Undulator4M


@pytest.fixture()
def undulator():
undulator = instantiate_fake_device(PlanarUndulator, prefix="PSS:255ID:", name="undulator")
return undulator
TEST_PV_PREFIX = "TEST:PREFIX:"
TEST_CASES = [
[PlanarUndulator, TEST_PV_PREFIX],
[Revolver_Undulator, TEST_PV_PREFIX],
[STI_Undulator, TEST_PV_PREFIX],
[Undulator2M, TEST_PV_PREFIX],
[Undulator4M, TEST_PV_PREFIX],
]


def test_set_energy(undulator):
@pytest.mark.parametrize("klass, prefix", TEST_CASES)
def test_set_energy(klass, prefix):
undulator = instantiate_fake_device(klass, prefix=prefix, name="undulator")

assert undulator.start_button.get() == 0
undulator.energy.set(5)
assert undulator.energy.setpoint.get() == 5
assert undulator.start_button.get() == 1


def test_stop_energy(undulator):
@pytest.mark.parametrize("klass, prefix", TEST_CASES)
def test_stop_energy(klass, prefix):
undulator = instantiate_fake_device(klass, prefix=prefix, name="undulator")

assert undulator.stop_button.get() == 0
undulator.stop()
assert undulator.stop_button.get() == 1
2 changes: 1 addition & 1 deletion apstools/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
IOC_GP = "gp:" # general purpose IOC: motors, scalers, slits, ...
IOC_AD = "ad:" # ADSimDetector IOC

MASTER_TIMEOUT = 3
MASTER_TIMEOUT = 10
MAX_TESTING_RETRIES = 3
SHORT_DELAY_FOR_EPICS_IOC_DATABASE_PROCESSING = 2.0 / 60 # two 60Hz clock cycles

Expand Down
17 changes: 17 additions & 0 deletions docs/source/api/_devices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ See these categories:
* :ref:`devices.aps_support`
* :ref:`devices.area_detector`
* :ref:`devices.flyers`
* :ref:`devices.insertion_devices`
* :ref:`devices.motors`
* :ref:`devices.scalers`
* :ref:`devices.shutters`
Expand Down Expand Up @@ -104,6 +105,22 @@ Fly Scan Support
``ScalerMotorFlyer()`` support withdrawn pending issue #763.

.. _devices.insertion_devices:

Insertion Devices
+++++++++++++++++

.. autosummary::

~apstools.devices.aps_undulator.PlanarUndulator
~apstools.devices.aps_undulator.Revolver_Undulator
~apstools.devices.aps_undulator.STI_Undulator
~apstools.devices.aps_undulator.Undulator2M
~apstools.devices.aps_undulator.Undulator4M

.. note:: The ``ApsUndulator`` and ``ApsUndulatorDual`` device support
classes have been removed. These devices are not used in the APS-U era.

.. _devices.motors:

Motors, Positioners, Axes, ...
Expand Down

0 comments on commit d423327

Please sign in to comment.