77import os
88import atexit
99import pytest
10+ import time
1011
1112PV_PREFIX = "" .join (random .choice (string .ascii_uppercase ) for _ in range (12 ))
1213
@@ -33,7 +34,7 @@ def asyncio_ioc():
3334@pytest .mark .asyncio
3435async def test_asyncio_ioc (asyncio_ioc ):
3536 import asyncio
36- from aioca import caget , caput , camonitor , CANothing , _catools , FORMAT_CTRL
37+ from aioca import caget , caput , camonitor , CANothing , _catools , FORMAT_TIME
3738 # Unregister the aioca atexit handler as it conflicts with the one installed
3839 # by cothread. If we don't do this we get a seg fault. This is not a problem
3940 # in production as we won't mix aioca and cothread, but we do mix them in
@@ -48,19 +49,25 @@ async def test_asyncio_ioc(asyncio_ioc):
4849 m = camonitor (PV_PREFIX + ":SIN" , q .put , notify_disconnect = True )
4950 assert len (await asyncio .wait_for (q .get (), 1 )) == 4
5051 # AO
51- ao_val = await caget (PV_PREFIX + ":AO2 " , format = FORMAT_CTRL )
52+ ao_val = await caget (PV_PREFIX + ":ALARM " , format = FORMAT_TIME )
5253 assert ao_val == 0
5354 assert ao_val .severity == 3 # INVALID
5455 assert ao_val .status == 17 # UDF
55- await caput (PV_PREFIX + ":AO2 " , 3.56 , wait = True )
56+ await caput (PV_PREFIX + ":ALARM " , 3 , wait = True )
5657 await asyncio .sleep (0.1 )
57- assert await caget (PV_PREFIX + ":AI" ) == 12.34
58+ ai_val = await caget (PV_PREFIX + ":AI" , format = FORMAT_TIME )
59+ assert ai_val == 23.45
60+ assert ai_val .severity == 0
61+ assert ai_val .status == 0
5862 await asyncio .sleep (0.8 )
59- assert await caget (PV_PREFIX + ":AI" ) == 3.56
63+ ai_val = await caget (PV_PREFIX + ":AI" , format = FORMAT_TIME )
64+ assert ai_val == 23.45
65+ assert ai_val .severity == 3
66+ assert ai_val .status == 7 # STATE_ALARM
6067 # Check pvaccess works
6168 from p4p .client .asyncio import Context
6269 with Context ("pva" ) as ctx :
63- assert await ctx .get (PV_PREFIX + ":AI" ) == 3.56
70+ assert await ctx .get (PV_PREFIX + ":AI" ) == 23.45
6471 # Wait for a bit longer for the print output to flush
6572 await asyncio .sleep (2 )
6673 # Stop
@@ -73,8 +80,9 @@ async def test_asyncio_ioc(asyncio_ioc):
7380 # check closed and output
7481 assert "%s:SINN.VAL 1024 -> 4" % PV_PREFIX in out
7582 assert 'update_sin_wf 4' in out
76- assert "%s:AO2.VAL 0 -> 3.56" % PV_PREFIX in out
77- assert 'async update 3.56' in out
83+ assert "%s:ALARM.VAL 0 -> 3" % PV_PREFIX in out
84+ assert 'on_update %s:AO : 3.0' % PV_PREFIX in out
85+ assert 'async update 3.0 (23.45)' in out
7886 assert 'Starting iocInit' in err
7987 assert 'iocRun: All initialization complete' in err
8088 assert '(InteractiveConsole)' in err
0 commit comments