Skip to content

Commit fcbcfcf

Browse files
Update the asyncio example file
It still doesn't work as I expect - the second caget on AI always returns 5.0, not 999...
1 parent b9a991d commit fcbcfcf

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed
Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Import the basic framework components.
2-
import atexit
32
from softioc import softioc, builder
4-
from aioca import caget, caput, _catools
3+
from aioca import caget, caput
54
import asyncio
65

76
# Set the record prefix
@@ -10,7 +9,9 @@
109
# Create some records
1110
ai = builder.aIn('AI', initial_value=5)
1211

13-
async def update(val):
12+
def update(val):
13+
print("got here")
14+
print(val)
1415
ai.set(val)
1516

1617
ao = builder.aOut('AO', initial_value=12.45, on_update=update)
@@ -21,10 +22,21 @@ async def update(val):
2122

2223
# Perform some reading/writing to the PVs
2324
async def do_read_write():
24-
ai_val = await caget("MY-DEVICE-PREFIX:AI")
25+
print(await caget("MY-DEVICE-PREFIX:AO"))
26+
print(await caget("MY-DEVICE-PREFIX:AI"))
2527
await caput("MY-DEVICE-PREFIX:AO", "999")
28+
await asyncio.sleep(10)
29+
print(await caget("MY-DEVICE-PREFIX:AI"))
30+
print(await caget("MY-DEVICE-PREFIX:AO"))
2631

32+
#asyncio.run(do_read_write())
2733

28-
asyncio.run(do_read_write())
34+
print(asyncio.run(caget("MY-DEVICE-PREFIX:AI")))
35+
print(asyncio.run(caget("MY-DEVICE-PREFIX:AO")))
36+
print(asyncio.run(caput("MY-DEVICE-PREFIX:AO","999")))
2937

38+
print(asyncio.run(caget("MY-DEVICE-PREFIX:AI")))
39+
print(asyncio.run(caget("MY-DEVICE-PREFIX:AO")))
3040

41+
42+
softioc.interactive_ioc(globals())

0 commit comments

Comments
 (0)