-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from DiamondLightSource/hyperion_796_xbpm_fee…
…dback Add XBPM feedback for i03
- Loading branch information
Showing
4 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,24 @@ | ||
from ophyd import Component, Device, EpicsSignal, EpicsSignalRO | ||
from ophyd.status import StatusBase, SubscriptionStatus | ||
|
||
|
||
class XBPMFeedback(Device): | ||
"""The XBPM feedback device is an IOC that moves the DCM, HFM and VFM to automatically | ||
hold the beam into place, as measured by the XBPM sensor.""" | ||
|
||
# We need to wait for the beam to be locked into position for this amount of time | ||
# until we are certain that it is stable. | ||
STABILITY_TIME = 3 | ||
|
||
pos_ok: EpicsSignalRO = Component(EpicsSignalRO, "-EA-FDBK-01:XBPM2POSITION_OK") | ||
pos_stable: EpicsSignalRO = Component(EpicsSignalRO, "-EA-FDBK-01:XBPM2_STABLE") | ||
pause_feedback: EpicsSignal = Component(EpicsSignal, "-EA-FDBK-01:FB_PAUSE") | ||
x: EpicsSignalRO = Component(EpicsSignalRO, "-EA-XBPM-02:PosX:MeanValue_RBV") | ||
y: EpicsSignalRO = Component(EpicsSignalRO, "-EA-XBPM-02:PosY:MeanValue_RBV") | ||
|
||
def trigger(self) -> StatusBase: | ||
return SubscriptionStatus( | ||
self.pos_stable, | ||
lambda *, old_value, value, **kwargs: value == 1, | ||
timeout=60, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import pytest | ||
from ophyd.sim import make_fake_device | ||
|
||
from dodal.devices.xbpm_feedback import XBPMFeedback | ||
|
||
|
||
@pytest.fixture | ||
def fake_xbpm_feedback(): | ||
FakeXBPMFeedback = make_fake_device(XBPMFeedback) | ||
return FakeXBPMFeedback(name="xbpm") | ||
|
||
|
||
def test_given_pos_stable_when_xbpm_feedback_kickoff_then_return_immediately( | ||
fake_xbpm_feedback: XBPMFeedback, | ||
): | ||
fake_xbpm_feedback.pos_stable.sim_put(1) | ||
status = fake_xbpm_feedback.trigger() | ||
status.wait(0.1) | ||
assert status.done and status.success | ||
|
||
|
||
def test_given_pos_not_stable_and_goes_stable_when_xbpm_feedback_kickoff_then_return( | ||
fake_xbpm_feedback: XBPMFeedback, | ||
): | ||
fake_xbpm_feedback.pos_stable.sim_put(0) | ||
status = fake_xbpm_feedback.trigger() | ||
|
||
assert not status.done | ||
|
||
fake_xbpm_feedback.pos_stable.sim_put(1) | ||
status.wait(0.1) | ||
assert status.done and status.success |