Skip to content

Commit

Permalink
Merge pull request #1227 from spc-group/set_many_args
Browse files Browse the repository at this point in the history
ENH: The set_many utility now works with Ophyd positioners as well as…
  • Loading branch information
ZLLentz authored May 28, 2024
2 parents 2780c5f + e70fddc commit e1be5bf
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 78 deletions.
29 changes: 27 additions & 2 deletions pcdsdevices/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

import pytest
from ophyd import Component as Cpt
from ophyd import Device, Signal
from ophyd import Device, PVPositionerDone, Signal

from .. import utils
from ..device import GroupDevice
from ..utils import (move_subdevices_to_start, post_ophyds_to_elog,
reorder_components, set_standard_ordering,
reorder_components, set_many, set_standard_ordering,
sort_components_by_kind, sort_components_by_name)

try:
Expand Down Expand Up @@ -262,3 +262,28 @@ class ChessPieces(Device):
get_order(ChessPieces)
== ['queen', 'rook', 'king', 'bishop', 'knight', 'pawn']
)


def test_set_many():
"""Checks that set_many sets multiple ophyd objects, and that it works
with signals as well as positioners.
Positioners and signals need different keyword arguments to their
``set()`` methods, so this implicitly tests that those are done
properly.
"""
# Create a dummy positioner with an extra signal
class MyPositioner(PVPositionerDone):
setpoint = Cpt(Signal)
another_signal = Cpt(Signal)

device = MyPositioner()
assert device.done.get() == 0
# Set the positioner and the extra signal together
st = set_many({device: 5, device.another_signal: 7}, raise_on_set_failure=True)
st.wait(timeout=3)
# Check that all the signals were set properly
assert device.done.get() == 1
assert device.setpoint.get() == 5
assert device.another_signal.get() == 7
Loading

0 comments on commit e1be5bf

Please sign in to comment.