Skip to content

Commit

Permalink
Add test for NTNDArray-type PVA variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Willemsen committed Aug 18, 2023
1 parent bac95c2 commit b74fdc0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
25 changes: 25 additions & 0 deletions ophyd/v2/tests/test_epics.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,31 @@ async def test_pva_table(ioc: IOC) -> None:
q.close()


async def test_pva_ntdarray(ioc: IOC):
if ioc.protocol == "ca":
# CA can't do ndarray
return
initial = np.zeros(4, np.int64)
put = np.ones_like(initial)

descriptor = dict(dtype="array", shape=[4])

for i, p in [(initial, put), (put, initial)]:
backend = await ioc.make_backend(npt.NDArray[np.int64], "ntndarray")
# Make a monitor queue that will monitor for updates
q = MonitorQueue(backend)
try:
# Check descriptor
assert dict(source=backend.source, **descriptor) == await backend.get_descriptor()
# Check initial value
await q.assert_updates(pytest.approx(i))
# Put to new value and check that
await backend.put(p)
await q.assert_updates(pytest.approx(p))
finally:
q.close()


async def test_non_existant_errors(ioc: IOC):
backend = await ioc.make_backend(str, "non-existant", connect=False)
# Can't use asyncio.wait_for on python3.8 because of
Expand Down
21 changes: 20 additions & 1 deletion ophyd/v2/tests/test_records.db
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,23 @@ record(waveform, "$(P)table:enum")
"": {"+type": "meta", "+channel": "VAL"}
}
})
}
}

record(waveform, "$(P)ntndarray")
{
field(FTVL, "INT64")
field(NELM, "4")
field(INP, {const:[0, 0, 0, 0]})
field(PINI, "YES")
info(Q:group, {
"$(P)ntndarray":{
+id:"epics:nt/NTNDArray:1.0",
"value":{
+type:"any",
+channel:"VAL",
+trigger:"*",
},
"": {+type:"meta", +channel:"VAL"}
}
})
}

0 comments on commit b74fdc0

Please sign in to comment.