-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathsim_cothread_ioc.py
More file actions
42 lines (29 loc) · 1.14 KB
/
sim_cothread_ioc.py
File metadata and controls
42 lines (29 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from argparse import ArgumentParser
from multiprocessing.connection import Client
import sys
from softioc import softioc, builder, pvlog
from conftest import ADDRESS, log, select_and_recv
if __name__ == "__main__":
log("sim_cothread_ioc starting")
with Client(ADDRESS) as conn:
import cothread
# Being run as an IOC, so parse args and set prefix
parser = ArgumentParser()
parser.add_argument('prefix', help="The PV prefix for the records")
parsed_args = parser.parse_args()
builder.SetDeviceName(parsed_args.prefix)
import sim_records
log("sim_cothread_ioc records created")
# Run the IOC
builder.LoadDatabase()
softioc.iocInit()
log("sim_cothread_ioc ready")
conn.send("R") # "Ready"
log("sim_cothread_ioc waiting for Done")
select_and_recv(conn, "D") # "Done"
# Attempt to ensure all buffers flushed - C code (from `import pvlog`)
# may not be affected by these calls...
sys.stdout.flush()
sys.stderr.flush()
log("sim_cothread_ioc sending Done")
conn.send("D") # "Ready"