-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_epics_code_fragment.py
executable file
·44 lines (27 loc) · 1.31 KB
/
generate_epics_code_fragment.py
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
#!/usr/bin/python
# Simple script to make sure that run is going and the fesimdaq program is going...
import urllib2
import json
import time
from subprocess import Popen, PIPE
from time import localtime, gmtime, strftime
# Get Program/fesimsaq
simdaqODB = urllib2.urlopen("http://localhost:8082/?cmd=jcopy&encoding=json&odb=/Equipment/SourceEpics/Settings").read()
json_obj = json.loads(simdaqODB)['Names']
init_str = ""
branch_str = ""
assign_str = ""
index = -1;
for oname in json_obj:
index = index + 1
if "Default" in oname or "default" in oname:
continue
name = oname.replace(":","_")
# print name,index
init_str += " double " + name + ";\n"
branch_str += ' tSource->Branch("'+name + '",&' + name + ', "' + name + '/D");\n'
assign_str += ' ' + name + ' = data->GetFloat()[' + str(index) + '];\n'
print "// midas2root code fragments generated by epics2mdias/generate_epics_code_fragment.py"
print init_str
print branch_str
print assign_str