Skip to content

Commit 35a0061

Browse files
author
James Souter
committed
also test initial values of AttrRs and AttrWs in CA transport
1 parent a238e80 commit 35a0061

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

tests/example_softioc.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
class InitialEnum(enum.Enum):
1515
A = 0
1616
B = 1
17+
C = 2
1718

1819

1920
class ParentController(Controller):
@@ -39,6 +40,21 @@ class InitialValuesController(Controller):
3940
Waveform(np.int64, shape=(10,)),
4041
initial_value=np.array(range(10), dtype=np.int64),
4142
)
43+
int_r = AttrR(Int(), initial_value=5)
44+
float_r = AttrR(Float(), initial_value=4.1)
45+
bool_r = AttrR(Bool(), initial_value=False)
46+
enum_r = AttrR(Enum(InitialEnum), initial_value=InitialEnum.C)
47+
str_r = AttrR(String(), initial_value="initial_r")
48+
waveform_r = AttrR(
49+
Waveform(np.int64, shape=(10,)),
50+
initial_value=np.array(range(10, 20), dtype=np.int64),
51+
)
52+
int_w = AttrW(Int())
53+
float_w = AttrW(Float())
54+
bool_w = AttrW(Bool())
55+
enum_w = AttrW(Enum(InitialEnum))
56+
str_w = AttrW(String())
57+
waveform_w = AttrW(Waveform(np.int64, shape=(10,)))
4258

4359

4460
def run(pv_prefix="SOFTIOC_TEST_DEVICE"):

tests/transport/epics/ca/test_softioc_system.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def test_ioc(softioc_subprocess: tuple[str, Queue]):
3838
async def test_initial_values_set_in_ca(initial_softioc_subprocess):
3939
pv_prefix, _ = initial_softioc_subprocess
4040
# combine cagets to reduce timeouts
41+
42+
# AttrRWs
43+
4144
scalar_sets = await caget(
4245
[
4346
f"{pv_prefix}:Int",
@@ -60,3 +63,30 @@ async def test_initial_values_set_in_ca(initial_softioc_subprocess):
6063
assert np.array_equal((await caget(f"{pv_prefix}:Waveform")), list(range(10)))
6164
assert (await caget(f"{pv_prefix}:Str_RBV")).tobytes() == b"initial\0"
6265
assert np.array_equal((await caget(f"{pv_prefix}:Waveform_RBV")), list(range(10)))
66+
67+
# AttrRs
68+
scalars = await caget(
69+
[
70+
f"{pv_prefix}:IntR",
71+
f"{pv_prefix}:FloatR",
72+
f"{pv_prefix}:BoolR",
73+
f"{pv_prefix}:EnumR",
74+
]
75+
)
76+
assert scalars == [5, 4.1, 0, 2]
77+
assert (await caget(f"{pv_prefix}:StrR")).tobytes() == b"initial_r\0"
78+
assert np.array_equal((await caget(f"{pv_prefix}:WaveformR")), list(range(10, 20)))
79+
80+
# Check AttrWs use the datatype initial value
81+
w_scalars = await caget(
82+
[
83+
f"{pv_prefix}:IntW",
84+
f"{pv_prefix}:FloatW",
85+
f"{pv_prefix}:BoolW",
86+
f"{pv_prefix}:EnumW",
87+
]
88+
)
89+
return
90+
assert w_scalars == [0, 0, 0, 0]
91+
assert (await caget(f"{pv_prefix}:StrW")).tobytes() == b"\0"
92+
assert np.array_equal((await caget(f"{pv_prefix}:WaveformW")), 10 * [0])

0 commit comments

Comments
 (0)