-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5a2e33
commit 55e7c13
Showing
4 changed files
with
79 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python3 | ||
from textwrap import dedent | ||
|
||
from caproto.server import PVGroup, ioc_arg_parser, pvproperty, run | ||
|
||
|
||
class MockSysResetIOC(PVGroup): | ||
""" | ||
IOC to mock SLACEPICS IOCs with respect to how they increment heartbeat and are reset | ||
""" | ||
|
||
heartbeat = pvproperty( | ||
name="HEARTBEAT", | ||
value=0, | ||
dtype=int, | ||
doc="Represents heartbeat of IOC, monotonically increasing (until reset)") | ||
sys_reset = pvproperty( | ||
name="SysReset", | ||
value=0, | ||
dtype=int, | ||
doc="Rising edge indicates requested reset, put high to request reset") | ||
|
||
@sys_reset.putter | ||
async def sys_reset(self, instance, value): | ||
await self.heartbeat.write(0) | ||
return 0 | ||
|
||
@heartbeat.scan(period=1.0) | ||
async def heartbeat(self, instance, async_lib): | ||
print(instance.value) | ||
await instance.write(instance.value+1) | ||
|
||
|
||
if __name__ == "__main__": | ||
ioc_options, run_options = ioc_arg_parser( | ||
default_prefix="SysResetTest:", desc=dedent(MockSysResetIOC.__doc__) | ||
) | ||
ioc = MockSysResetIOC(**ioc_options) | ||
run(ioc.pvdb, **run_options) |
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,30 @@ | ||
import time | ||
from pathlib import Path | ||
|
||
import py_trees | ||
from caproto.tests.conftest import run_example_ioc | ||
|
||
from beams.tree_config.utility_trees.reset_ioc import ResetIOCItem | ||
|
||
|
||
def test_sys_reset(request, bt_cleaner): | ||
reset_ioc_tree = ResetIOCItem( | ||
ioc_prefix="SysResetTest").get_tree() | ||
|
||
bt_cleaner.register(reset_ioc_tree) | ||
|
||
# start mock IOC # NOTE: assumes test is being run from top level of | ||
run_example_ioc( | ||
"beams.tests.mock_iocs.SysResetIOC", | ||
request=request, | ||
pv_to_check="SysResetTest:HEARTBEAT", | ||
) | ||
|
||
reset_ioc_tree.setup_with_descendants() | ||
while reset_ioc_tree.status not in ( | ||
py_trees.common.Status.SUCCESS, | ||
py_trees.common.Status.FAILURE, | ||
): | ||
for n in reset_ioc_tree.tick(): | ||
print(n) | ||
time.sleep(1) |
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