Skip to content

Commit c0bf122

Browse files
committed
TST: switch from 'caproto' to 'softioc' IOC
1 parent 4a82575 commit c0bf122

File tree

3 files changed

+56
-27
lines changed

3 files changed

+56
-27
lines changed

ioc/sim_ioc.py

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
1-
from textwrap import dedent
1+
# Import the basic framework components.
2+
from softioc import asyncio_dispatcher, builder, softioc
23

3-
from caproto.server import PVGroup, ioc_arg_parser, pvproperty, run
4+
# Create an asyncio dispatcher, the event loop is now running
5+
dispatcher = asyncio_dispatcher.AsyncioDispatcher()
46

7+
# Set the record prefix
8+
builder.SetDeviceName("simulated")
59

6-
class SimpleIOC(PVGroup):
7-
"""
8-
An IOC with three uncoupled read/writable PVs.
10+
# Create records
11+
AA = builder.aOut("A", initial_value=1.0)
12+
BB = builder.aOut("B", initial_value=1.0)
13+
CC = builder.aOut("C", initial_value=1.0)
14+
DD = builder.aOut("D", initial_value=1.0)
15+
EE = builder.aOut("E", initial_value=1.0)
16+
FF = builder.aOut("F", initial_value=1.0)
17+
GG = builder.aOut("G", initial_value=1.0)
18+
HH = builder.aOut("H", initial_value=1.0)
19+
II = builder.aOut("I", initial_value=1.0)
20+
JJ = builder.aOut("J", initial_value=1.0)
921

10-
Scalar PVs
11-
----------
12-
A, B, C, D, E, F, G, H, I, J (float)
13-
"""
22+
# Get the IOC started
23+
builder.LoadDatabase()
24+
softioc.iocInit(dispatcher)
1425

15-
A = pvproperty(value=1.0, doc="Value A")
16-
B = pvproperty(value=1.0, doc="Value B")
17-
C = pvproperty(value=1.0, doc="Value C")
18-
D = pvproperty(value=1.0, doc="Value D")
19-
E = pvproperty(value=1.0, doc="Value E")
20-
F = pvproperty(value=1.0, doc="Value F")
21-
G = pvproperty(value=1.0, doc="Value G")
22-
H = pvproperty(value=1.0, doc="Value H")
23-
I = pvproperty(value=1.0, doc="Value I") # noqa:E741
24-
J = pvproperty(value=1.0, doc="Value J")
25-
26-
27-
if __name__ == "__main__":
28-
ioc_options, run_options = ioc_arg_parser(default_prefix="simulated:", desc=dedent(SimpleIOC.__doc__))
29-
ioc = SimpleIOC(**ioc_options)
30-
run(ioc.pvdb, **run_options)
26+
# Finally leave the IOC running with an interactive shell.
27+
# softioc.interactive_ioc(globals())
28+
softioc.non_interactive_ioc()

ioc/sim_ioc_caproto.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from textwrap import dedent
2+
3+
from caproto.server import PVGroup, ioc_arg_parser, pvproperty, run
4+
5+
6+
class SimpleIOC(PVGroup):
7+
"""
8+
An IOC with three uncoupled read/writable PVs.
9+
10+
Scalar PVs
11+
----------
12+
A, B, C, D, E, F, G, H, I, J (float)
13+
"""
14+
15+
A = pvproperty(value=1.0, doc="Value A")
16+
B = pvproperty(value=1.0, doc="Value B")
17+
C = pvproperty(value=1.0, doc="Value C")
18+
D = pvproperty(value=1.0, doc="Value D")
19+
E = pvproperty(value=1.0, doc="Value E")
20+
F = pvproperty(value=1.0, doc="Value F")
21+
G = pvproperty(value=1.0, doc="Value G")
22+
H = pvproperty(value=1.0, doc="Value H")
23+
I = pvproperty(value=1.0, doc="Value I") # noqa:E741
24+
J = pvproperty(value=1.0, doc="Value J")
25+
26+
27+
if __name__ == "__main__":
28+
ioc_options, run_options = ioc_arg_parser(default_prefix="simulated:", desc=dedent(SimpleIOC.__doc__))
29+
ioc = SimpleIOC(**ioc_options)
30+
run(ioc.pvdb, **run_options)

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ dev = [
4141
"pytest-asyncio",
4242
"pre-commit",
4343
"ruff",
44-
"caproto !=1.2.0",
44+
# "caproto !=1.2.0",
45+
"softioc",
4546
"pyepics",
4647
]
4748
docs = [
@@ -62,7 +63,7 @@ minversion = "6.0"
6263
# Run pytest with all our checkers, and don't spam us with massive tracebacks on error
6364
# Don't collect the interactive directory which is intended for manual execution
6465
addopts = """
65-
--tb=native -vv --doctest-modules --doctest-glob="*.rst" --ignore docs
66+
--tb=native -vv --doctest-modules --doctest-glob="*.rst" --ignore docs --ignore ioc
6667
"""
6768
# https://iscinumpy.gitlab.io/post/bound-version-constraints/#watch-for-warnings
6869
filterwarnings = [

0 commit comments

Comments
 (0)