-
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.
Added watsonmarlow323 device for i22 ppump. (#575)
* Added watsonmarlow323 device for i22 ppump. * Changes from code review: improved naming, made enabled read/write, and used ophyd-async assert_reading utility function for tests. * Fixed linting errors. * Changes from code review: added device details to docstring, removed skip device, enabled fake_with_ophyd_sim, and don't specify read write pv if they are the same. * Change from code review: added simulated pump to p38. * Change from code review: Removed limits that are now propagted by their corresponding signal. * Rebased, updated to use add_children_as_readables to fix deprecated errors, and updated enum baseclass to use ophyd_async's. --------- Co-authored-by: William Barnett <[email protected]> Co-authored-by: Will Barnett <[email protected]>
- Loading branch information
1 parent
8ab51b1
commit fc296b5
Showing
4 changed files
with
120 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from ophyd_async.core import ConfigSignal, StandardReadable, StrictEnum | ||
from ophyd_async.epics.signal import epics_signal_rw | ||
|
||
|
||
class WatsonMarlow323PumpEnable(StrictEnum): | ||
DISABLED = "Disabled" | ||
ENABLED = "Enabled" | ||
|
||
|
||
class WatsonMarlow323PumpDirection(StrictEnum): | ||
CLOCKWISE = "CW" | ||
COUNTER_CLOCKWISE = "CCW" | ||
|
||
|
||
class WatsonMarlow323PumpState(StrictEnum): | ||
STOPPED = "STOP" | ||
STARTED = "START" | ||
|
||
|
||
class WatsonMarlow323Pump(StandardReadable): | ||
"""Watson Marlow 323 Peristaltic Pump device""" | ||
|
||
def __init__(self, prefix: str, name: str = "") -> None: | ||
with self.add_children_as_readables(): | ||
self.direction = epics_signal_rw( | ||
WatsonMarlow323PumpDirection, | ||
read_pv=prefix + "INFO:DIR", | ||
write_pv=prefix + "SET:DIR", | ||
) | ||
self.state = epics_signal_rw( | ||
WatsonMarlow323PumpState, | ||
read_pv=prefix + "INFO:RUN", | ||
write_pv=prefix + "SET:RUN", | ||
) | ||
self.speed = epics_signal_rw( | ||
float, read_pv=prefix + "INFO:SPD", write_pv=prefix + "SET:SPD" | ||
) | ||
|
||
with self.add_children_as_readables(ConfigSignal): | ||
self.enabled = epics_signal_rw( | ||
WatsonMarlow323PumpEnable, | ||
prefix + "DISABLE", | ||
) | ||
|
||
super().__init__(name=name) |
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,47 @@ | ||
from unittest.mock import ANY | ||
|
||
import pytest | ||
from ophyd_async.core import DeviceCollector, assert_reading, set_mock_value | ||
|
||
from dodal.devices.watsonmarlow323_pump import ( | ||
WatsonMarlow323Pump, | ||
WatsonMarlow323PumpDirection, | ||
WatsonMarlow323PumpState, | ||
) | ||
|
||
|
||
@pytest.fixture | ||
async def watsonmarlow323() -> WatsonMarlow323Pump: | ||
async with DeviceCollector(mock=True): | ||
wm_pump = WatsonMarlow323Pump("DEMO-WMPUMP-01:") | ||
|
||
return wm_pump | ||
|
||
|
||
async def test_reading_pump_reads_state_speed_and_direction( | ||
watsonmarlow323: WatsonMarlow323Pump, | ||
): | ||
set_mock_value(watsonmarlow323.state, WatsonMarlow323PumpState.STOPPED) | ||
set_mock_value(watsonmarlow323.speed, 25) | ||
set_mock_value(watsonmarlow323.direction, WatsonMarlow323PumpDirection.CLOCKWISE) | ||
|
||
await assert_reading( | ||
watsonmarlow323, | ||
{ | ||
"wm_pump-state": { | ||
"value": WatsonMarlow323PumpState.STOPPED, | ||
"timestamp": ANY, | ||
"alarm_severity": 0, | ||
}, | ||
"wm_pump-speed": { | ||
"value": 25, | ||
"timestamp": ANY, | ||
"alarm_severity": 0, | ||
}, | ||
"wm_pump-direction": { | ||
"value": WatsonMarlow323PumpDirection.CLOCKWISE, | ||
"timestamp": ANY, | ||
"alarm_severity": 0, | ||
}, | ||
}, | ||
) |