|
@@
-1,1289
+1,1269
|
|
1
|
'''
|
|
1
|
'''
|
|
2
|
Created on September , 2012
|
|
2
|
Created on September , 2012
|
|
3
|
@author:
|
|
3
|
@author:
|
|
4
|
'''
|
|
4
|
'''
|
|
5
|
|
|
5
|
|
|
6
|
import sys
|
|
6
|
import sys
|
|
7
|
import ast
|
|
7
|
import ast
|
|
8
|
import datetime
|
|
8
|
import datetime
|
|
9
|
import traceback
|
|
9
|
import traceback
|
|
10
|
import schainpy
|
|
10
|
import schainpy
|
|
11
|
import schainpy.admin
|
|
11
|
import schainpy.admin
|
|
12
|
|
|
12
|
|
|
13
|
from xml.etree.ElementTree import ElementTree, Element, SubElement, tostring
|
|
13
|
from xml.etree.ElementTree import ElementTree, Element, SubElement, tostring
|
|
14
|
from xml.dom import minidom
|
|
14
|
from xml.dom import minidom
|
|
15
|
|
|
15
|
|
|
16
|
from schainpy.model import *
|
|
16
|
from schainpy.model import *
|
|
17
|
from time import sleep
|
|
17
|
from time import sleep
|
|
18
|
|
|
18
|
|
|
19
|
def prettify(elem):
|
|
19
|
def prettify(elem):
|
|
20
|
"""Return a pretty-printed XML string for the Element.
|
|
20
|
"""Return a pretty-printed XML string for the Element.
|
|
21
|
"""
|
|
21
|
"""
|
|
22
|
rough_string = tostring(elem, 'utf-8')
|
|
22
|
rough_string = tostring(elem, 'utf-8')
|
|
23
|
reparsed = minidom.parseString(rough_string)
|
|
23
|
reparsed = minidom.parseString(rough_string)
|
|
24
|
return reparsed.toprettyxml(indent=" ")
|
|
24
|
return reparsed.toprettyxml(indent=" ")
|
|
25
|
|
|
25
|
|
|
26
|
class ParameterConf():
|
|
26
|
class ParameterConf():
|
|
27
|
|
|
27
|
|
|
28
|
id = None
|
|
28
|
id = None
|
|
29
|
name = None
|
|
29
|
name = None
|
|
30
|
value = None
|
|
30
|
value = None
|
|
31
|
format = None
|
|
31
|
format = None
|
|
32
|
|
|
32
|
|
|
33
|
__formated_value = None
|
|
33
|
__formated_value = None
|
|
34
|
|
|
34
|
|
|
35
|
ELEMENTNAME = 'Parameter'
|
|
35
|
ELEMENTNAME = 'Parameter'
|
|
36
|
|
|
36
|
|
|
37
|
def __init__(self):
|
|
37
|
def __init__(self):
|
|
38
|
|
|
38
|
|
|
39
|
self.format = 'str'
|
|
39
|
self.format = 'str'
|
|
40
|
|
|
40
|
|
|
41
|
def getElementName(self):
|
|
41
|
def getElementName(self):
|
|
42
|
|
|
42
|
|
|
43
|
return self.ELEMENTNAME
|
|
43
|
return self.ELEMENTNAME
|
|
44
|
|
|
44
|
|
|
45
|
def getValue(self):
|
|
45
|
def getValue(self):
|
|
46
|
|
|
46
|
|
|
47
|
value = self.value
|
|
47
|
value = self.value
|
|
48
|
format = self.format
|
|
48
|
format = self.format
|
|
49
|
|
|
49
|
|
|
50
|
if self.__formated_value != None:
|
|
50
|
if self.__formated_value != None:
|
|
51
|
|
|
51
|
|
|
52
|
return self.__formated_value
|
|
52
|
return self.__formated_value
|
|
53
|
|
|
53
|
|
|
54
|
if format == 'str':
|
|
54
|
if format == 'str':
|
|
55
|
self.__formated_value = str(value)
|
|
55
|
self.__formated_value = str(value)
|
|
56
|
return self.__formated_value
|
|
56
|
return self.__formated_value
|
|
57
|
|
|
57
|
|
|
58
|
if value == '':
|
|
58
|
if value == '':
|
|
59
|
raise ValueError, "%s: This parameter value is empty" %self.name
|
|
59
|
raise ValueError, "%s: This parameter value is empty" %self.name
|
|
60
|
|
|
60
|
|
|
61
|
if format == 'list':
|
|
61
|
if format == 'list':
|
|
62
|
strList = value.split(',')
|
|
62
|
strList = value.split(',')
|
|
63
|
|
|
63
|
|
|
64
|
self.__formated_value = strList
|
|
64
|
self.__formated_value = strList
|
|
65
|
|
|
65
|
|
|
66
|
return self.__formated_value
|
|
66
|
return self.__formated_value
|
|
67
|
|
|
67
|
|
|
68
|
if format == 'intlist':
|
|
68
|
if format == 'intlist':
|
|
69
|
"""
|
|
69
|
"""
|
|
70
|
Example:
|
|
70
|
Example:
|
|
71
|
value = (0,1,2)
|
|
71
|
value = (0,1,2)
|
|
72
|
"""
|
|
72
|
"""
|
|
73
|
value = value.replace('(', '')
|
|
73
|
value = value.replace('(', '')
|
|
74
|
value = value.replace(')', '')
|
|
74
|
value = value.replace(')', '')
|
|
75
|
|
|
75
|
|
|
76
|
value = value.replace('[', '')
|
|
76
|
value = value.replace('[', '')
|
|
77
|
value = value.replace(']', '')
|
|
77
|
value = value.replace(']', '')
|
|
78
|
|
|
78
|
|
|
79
|
strList = value.split(',')
|
|
79
|
strList = value.split(',')
|
|
80
|
intList = [int(float(x)) for x in strList]
|
|
80
|
intList = [int(float(x)) for x in strList]
|
|
81
|
|
|
81
|
|
|
82
|
self.__formated_value = intList
|
|
82
|
self.__formated_value = intList
|
|
83
|
|
|
83
|
|
|
84
|
return self.__formated_value
|
|
84
|
return self.__formated_value
|
|
85
|
|
|
85
|
|
|
86
|
if format == 'floatlist':
|
|
86
|
if format == 'floatlist':
|
|
87
|
"""
|
|
87
|
"""
|
|
88
|
Example:
|
|
88
|
Example:
|
|
89
|
value = (0.5, 1.4, 2.7)
|
|
89
|
value = (0.5, 1.4, 2.7)
|
|
90
|
"""
|
|
90
|
"""
|
|
91
|
|
|
91
|
|
|
92
|
value = value.replace('(', '')
|
|
92
|
value = value.replace('(', '')
|
|
93
|
value = value.replace(')', '')
|
|
93
|
value = value.replace(')', '')
|
|
94
|
|
|
94
|
|
|
95
|
value = value.replace('[', '')
|
|
95
|
value = value.replace('[', '')
|
|
96
|
value = value.replace(']', '')
|
|
96
|
value = value.replace(']', '')
|
|
97
|
|
|
97
|
|
|
98
|
strList = value.split(',')
|
|
98
|
strList = value.split(',')
|
|
99
|
floatList = [float(x) for x in strList]
|
|
99
|
floatList = [float(x) for x in strList]
|
|
100
|
|
|
100
|
|
|
101
|
self.__formated_value = floatList
|
|
101
|
self.__formated_value = floatList
|
|
102
|
|
|
102
|
|
|
103
|
return self.__formated_value
|
|
103
|
return self.__formated_value
|
|
104
|
|
|
104
|
|
|
105
|
if format == 'date':
|
|
105
|
if format == 'date':
|
|
106
|
strList = value.split('/')
|
|
106
|
strList = value.split('/')
|
|
107
|
intList = [int(x) for x in strList]
|
|
107
|
intList = [int(x) for x in strList]
|
|
108
|
date = datetime.date(intList[0], intList[1], intList[2])
|
|
108
|
date = datetime.date(intList[0], intList[1], intList[2])
|
|
109
|
|
|
109
|
|
|
110
|
self.__formated_value = date
|
|
110
|
self.__formated_value = date
|
|
111
|
|
|
111
|
|
|
112
|
return self.__formated_value
|
|
112
|
return self.__formated_value
|
|
113
|
|
|
113
|
|
|
114
|
if format == 'time':
|
|
114
|
if format == 'time':
|
|
115
|
strList = value.split(':')
|
|
115
|
strList = value.split(':')
|
|
116
|
intList = [int(x) for x in strList]
|
|
116
|
intList = [int(x) for x in strList]
|
|
117
|
time = datetime.time(intList[0], intList[1], intList[2])
|
|
117
|
time = datetime.time(intList[0], intList[1], intList[2])
|
|
118
|
|
|
118
|
|
|
119
|
self.__formated_value = time
|
|
119
|
self.__formated_value = time
|
|
120
|
|
|
120
|
|
|
121
|
return self.__formated_value
|
|
121
|
return self.__formated_value
|
|
122
|
|
|
122
|
|
|
123
|
if format == 'pairslist':
|
|
123
|
if format == 'pairslist':
|
|
124
|
"""
|
|
124
|
"""
|
|
125
|
Example:
|
|
125
|
Example:
|
|
126
|
value = (0,1),(1,2)
|
|
126
|
value = (0,1),(1,2)
|
|
127
|
"""
|
|
127
|
"""
|
|
128
|
|
|
128
|
|
|
129
|
value = value.replace('(', '')
|
|
129
|
value = value.replace('(', '')
|
|
130
|
value = value.replace(')', '')
|
|
130
|
value = value.replace(')', '')
|
|
131
|
|
|
131
|
|
|
132
|
value = value.replace('[', '')
|
|
132
|
value = value.replace('[', '')
|
|
133
|
value = value.replace(']', '')
|
|
133
|
value = value.replace(']', '')
|
|
134
|
|
|
134
|
|
|
135
|
strList = value.split(',')
|
|
135
|
strList = value.split(',')
|
|
136
|
intList = [int(item) for item in strList]
|
|
136
|
intList = [int(item) for item in strList]
|
|
137
|
pairList = []
|
|
137
|
pairList = []
|
|
138
|
for i in range(len(intList)/2):
|
|
138
|
for i in range(len(intList)/2):
|
|
139
|
pairList.append((intList[i*2], intList[i*2 + 1]))
|
|
139
|
pairList.append((intList[i*2], intList[i*2 + 1]))
|
|
140
|
|
|
140
|
|
|
141
|
self.__formated_value = pairList
|
|
141
|
self.__formated_value = pairList
|
|
142
|
|
|
142
|
|
|
143
|
return self.__formated_value
|
|
143
|
return self.__formated_value
|
|
144
|
|
|
144
|
|
|
145
|
if format == 'multilist':
|
|
145
|
if format == 'multilist':
|
|
146
|
"""
|
|
146
|
"""
|
|
147
|
Example:
|
|
147
|
Example:
|
|
148
|
value = (0,1,2),(3,4,5)
|
|
148
|
value = (0,1,2),(3,4,5)
|
|
149
|
"""
|
|
149
|
"""
|
|
150
|
multiList = ast.literal_eval(value)
|
|
150
|
multiList = ast.literal_eval(value)
|
|
151
|
|
|
151
|
|
|
152
|
if type(multiList[0]) == int:
|
|
152
|
if type(multiList[0]) == int:
|
|
153
|
multiList = ast.literal_eval("(" + value + ")")
|
|
153
|
multiList = ast.literal_eval("(" + value + ")")
|
|
154
|
|
|
154
|
|
|
155
|
self.__formated_value = multiList
|
|
155
|
self.__formated_value = multiList
|
|
156
|
|
|
156
|
|
|
157
|
return self.__formated_value
|
|
157
|
return self.__formated_value
|
|
158
|
|
|
158
|
|
|
159
|
if format == 'bool':
|
|
159
|
if format == 'bool':
|
|
160
|
value = int(value)
|
|
160
|
value = int(value)
|
|
161
|
|
|
161
|
|
|
162
|
if format == 'int':
|
|
162
|
if format == 'int':
|
|
163
|
value = float(value)
|
|
163
|
value = float(value)
|
|
164
|
|
|
164
|
|
|
165
|
format_func = eval(format)
|
|
165
|
format_func = eval(format)
|
|
166
|
|
|
166
|
|
|
167
|
self.__formated_value = format_func(value)
|
|
167
|
self.__formated_value = format_func(value)
|
|
168
|
|
|
168
|
|
|
169
|
return self.__formated_value
|
|
169
|
return self.__formated_value
|
|
170
|
|
|
170
|
|
|
171
|
def updateId(self, new_id):
|
|
171
|
def updateId(self, new_id):
|
|
172
|
|
|
172
|
|
|
173
|
self.id = str(new_id)
|
|
173
|
self.id = str(new_id)
|
|
174
|
|
|
174
|
|
|
175
|
def setup(self, id, name, value, format='str'):
|
|
175
|
def setup(self, id, name, value, format='str'):
|
|
176
|
|
|
176
|
|
|
177
|
self.id = str(id)
|
|
177
|
self.id = str(id)
|
|
178
|
self.name = name
|
|
178
|
self.name = name
|
|
179
|
self.value = str(value)
|
|
179
|
self.value = str(value)
|
|
180
|
self.format = str.lower(format)
|
|
180
|
self.format = str.lower(format)
|
|
181
|
|
|
181
|
|
|
182
|
try:
|
|
182
|
try:
|
|
183
|
self.getValue()
|
|
183
|
self.getValue()
|
|
184
|
except:
|
|
184
|
except:
|
|
185
|
return 0
|
|
185
|
return 0
|
|
186
|
|
|
186
|
|
|
187
|
return 1
|
|
187
|
return 1
|
|
188
|
|
|
188
|
|
|
189
|
def update(self, name, value, format='str'):
|
|
189
|
def update(self, name, value, format='str'):
|
|
190
|
|
|
190
|
|
|
191
|
self.name = name
|
|
191
|
self.name = name
|
|
192
|
self.value = str(value)
|
|
192
|
self.value = str(value)
|
|
193
|
self.format = format
|
|
193
|
self.format = format
|
|
194
|
|
|
194
|
|
|
195
|
def makeXml(self, opElement):
|
|
195
|
def makeXml(self, opElement):
|
|
196
|
|
|
196
|
|
|
197
|
parmElement = SubElement(opElement, self.ELEMENTNAME)
|
|
197
|
parmElement = SubElement(opElement, self.ELEMENTNAME)
|
|
198
|
parmElement.set('id', str(self.id))
|
|
198
|
parmElement.set('id', str(self.id))
|
|
199
|
parmElement.set('name', self.name)
|
|
199
|
parmElement.set('name', self.name)
|
|
200
|
parmElement.set('value', self.value)
|
|
200
|
parmElement.set('value', self.value)
|
|
201
|
parmElement.set('format', self.format)
|
|
201
|
parmElement.set('format', self.format)
|
|
202
|
|
|
202
|
|
|
203
|
def readXml(self, parmElement):
|
|
203
|
def readXml(self, parmElement):
|
|
204
|
|
|
204
|
|
|
205
|
self.id = parmElement.get('id')
|
|
205
|
self.id = parmElement.get('id')
|
|
206
|
self.name = parmElement.get('name')
|
|
206
|
self.name = parmElement.get('name')
|
|
207
|
self.value = parmElement.get('value')
|
|
207
|
self.value = parmElement.get('value')
|
|
208
|
self.format = str.lower(parmElement.get('format'))
|
|
208
|
self.format = str.lower(parmElement.get('format'))
|
|
209
|
|
|
209
|
|
|
210
|
#Compatible with old signal chain version
|
|
210
|
#Compatible with old signal chain version
|
|
211
|
if self.format == 'int' and self.name == 'idfigure':
|
|
211
|
if self.format == 'int' and self.name == 'idfigure':
|
|
212
|
self.name = 'id'
|
|
212
|
self.name = 'id'
|
|
213
|
|
|
213
|
|
|
214
|
def printattr(self):
|
|
214
|
def printattr(self):
|
|
215
|
|
|
215
|
|
|
216
|
print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format)
|
|
216
|
print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format)
|
|
217
|
|
|
217
|
|
|
218
|
class OperationConf():
|
|
218
|
class OperationConf():
|
|
219
|
|
|
219
|
|
|
220
|
id = None
|
|
220
|
id = None
|
|
221
|
name = None
|
|
221
|
name = None
|
|
222
|
priority = None
|
|
222
|
priority = None
|
|
223
|
type = None
|
|
223
|
type = None
|
|
224
|
|
|
224
|
|
|
225
|
parmConfObjList = []
|
|
225
|
parmConfObjList = []
|
|
226
|
|
|
226
|
|
|
227
|
ELEMENTNAME = 'Operation'
|
|
227
|
ELEMENTNAME = 'Operation'
|
|
228
|
|
|
228
|
|
|
229
|
def __init__(self):
|
|
229
|
def __init__(self):
|
|
230
|
|
|
230
|
|
|
231
|
self.id = '0'
|
|
231
|
self.id = '0'
|
|
232
|
self.name = None
|
|
232
|
self.name = None
|
|
233
|
self.priority = None
|
|
233
|
self.priority = None
|
|
234
|
self.type = 'self'
|
|
234
|
self.type = 'self'
|
|
235
|
|
|
235
|
|
|
236
|
|
|
236
|
|
|
237
|
def __getNewId(self):
|
|
237
|
def __getNewId(self):
|
|
238
|
|
|
238
|
|
|
239
|
return int(self.id)*10 + len(self.parmConfObjList) + 1
|
|
239
|
return int(self.id)*10 + len(self.parmConfObjList) + 1
|
|
240
|
|
|
240
|
|
|
241
|
def updateId(self, new_id):
|
|
241
|
def updateId(self, new_id):
|
|
242
|
|
|
242
|
|
|
243
|
self.id = str(new_id)
|
|
243
|
self.id = str(new_id)
|
|
244
|
|
|
244
|
|
|
245
|
n = 1
|
|
245
|
n = 1
|
|
246
|
for parmObj in self.parmConfObjList:
|
|
246
|
for parmObj in self.parmConfObjList:
|
|
247
|
|
|
247
|
|
|
248
|
idParm = str(int(new_id)*10 + n)
|
|
248
|
idParm = str(int(new_id)*10 + n)
|
|
249
|
parmObj.updateId(idParm)
|
|
249
|
parmObj.updateId(idParm)
|
|
250
|
|
|
250
|
|
|
251
|
n += 1
|
|
251
|
n += 1
|
|
252
|
|
|
252
|
|
|
253
|
def getElementName(self):
|
|
253
|
def getElementName(self):
|
|
254
|
|
|
254
|
|
|
255
|
return self.ELEMENTNAME
|
|
255
|
return self.ELEMENTNAME
|
|
256
|
|
|
256
|
|
|
257
|
def getParameterObjList(self):
|
|
257
|
def getParameterObjList(self):
|
|
258
|
|
|
258
|
|
|
259
|
return self.parmConfObjList
|
|
259
|
return self.parmConfObjList
|
|
260
|
|
|
260
|
|
|
261
|
def getParameterObj(self, parameterName):
|
|
261
|
def getParameterObj(self, parameterName):
|
|
262
|
|
|
262
|
|
|
263
|
for parmConfObj in self.parmConfObjList:
|
|
263
|
for parmConfObj in self.parmConfObjList:
|
|
264
|
|
|
264
|
|
|
265
|
if parmConfObj.name != parameterName:
|
|
265
|
if parmConfObj.name != parameterName:
|
|
266
|
continue
|
|
266
|
continue
|
|
267
|
|
|
267
|
|
|
268
|
return parmConfObj
|
|
268
|
return parmConfObj
|
|
269
|
|
|
269
|
|
|
270
|
return None
|
|
270
|
return None
|
|
271
|
|
|
271
|
|
|
272
|
def getParameterObjfromValue(self, parameterValue):
|
|
272
|
def getParameterObjfromValue(self, parameterValue):
|
|
273
|
|
|
273
|
|
|
274
|
for parmConfObj in self.parmConfObjList:
|
|
274
|
for parmConfObj in self.parmConfObjList:
|
|
275
|
|
|
275
|
|
|
276
|
if parmConfObj.getValue() != parameterValue:
|
|
276
|
if parmConfObj.getValue() != parameterValue:
|
|
277
|
continue
|
|
277
|
continue
|
|
278
|
|
|
278
|
|
|
279
|
return parmConfObj.getValue()
|
|
279
|
return parmConfObj.getValue()
|
|
280
|
|
|
280
|
|
|
281
|
return None
|
|
281
|
return None
|
|
282
|
|
|
282
|
|
|
283
|
def getParameterValue(self, parameterName):
|
|
283
|
def getParameterValue(self, parameterName):
|
|
284
|
|
|
284
|
|
|
285
|
parameterObj = self.getParameterObj(parameterName)
|
|
285
|
parameterObj = self.getParameterObj(parameterName)
|
|
286
|
|
|
286
|
|
|
287
|
# if not parameterObj:
|
|
287
|
# if not parameterObj:
|
|
288
|
# return None
|
|
288
|
# return None
|
|
289
|
|
|
289
|
|
|
290
|
value = parameterObj.getValue()
|
|
290
|
value = parameterObj.getValue()
|
|
291
|
|
|
291
|
|
|
292
|
return value
|
|
292
|
return value
|
|
293
|
|
|
293
|
|
|
294
|
def setup(self, id, name, priority, type):
|
|
294
|
def setup(self, id, name, priority, type):
|
|
295
|
|
|
295
|
|
|
296
|
self.id = str(id)
|
|
296
|
self.id = str(id)
|
|
297
|
self.name = name
|
|
297
|
self.name = name
|
|
298
|
self.type = type
|
|
298
|
self.type = type
|
|
299
|
self.priority = priority
|
|
299
|
self.priority = priority
|
|
300
|
|
|
300
|
|
|
301
|
self.parmConfObjList = []
|
|
301
|
self.parmConfObjList = []
|
|
302
|
|
|
302
|
|
|
303
|
def removeParameters(self):
|
|
303
|
def removeParameters(self):
|
|
304
|
|
|
304
|
|
|
305
|
for obj in self.parmConfObjList:
|
|
305
|
for obj in self.parmConfObjList:
|
|
306
|
del obj
|
|
306
|
del obj
|
|
307
|
|
|
307
|
|
|
308
|
self.parmConfObjList = []
|
|
308
|
self.parmConfObjList = []
|
|
309
|
|
|
309
|
|
|
310
|
def addParameter(self, name, value, format='str'):
|
|
310
|
def addParameter(self, name, value, format='str'):
|
|
311
|
|
|
311
|
|
|
312
|
id = self.__getNewId()
|
|
312
|
id = self.__getNewId()
|
|
313
|
|
|
313
|
|
|
314
|
parmConfObj = ParameterConf()
|
|
314
|
parmConfObj = ParameterConf()
|
|
315
|
if not parmConfObj.setup(id, name, value, format):
|
|
315
|
if not parmConfObj.setup(id, name, value, format):
|
|
316
|
return None
|
|
316
|
return None
|
|
317
|
|
|
317
|
|
|
318
|
self.parmConfObjList.append(parmConfObj)
|
|
318
|
self.parmConfObjList.append(parmConfObj)
|
|
319
|
|
|
319
|
|
|
320
|
return parmConfObj
|
|
320
|
return parmConfObj
|
|
321
|
|
|
321
|
|
|
322
|
def changeParameter(self, name, value, format='str'):
|
|
322
|
def changeParameter(self, name, value, format='str'):
|
|
323
|
|
|
323
|
|
|
324
|
parmConfObj = self.getParameterObj(name)
|
|
324
|
parmConfObj = self.getParameterObj(name)
|
|
325
|
parmConfObj.update(name, value, format)
|
|
325
|
parmConfObj.update(name, value, format)
|
|
326
|
|
|
326
|
|
|
327
|
return parmConfObj
|
|
327
|
return parmConfObj
|
|
328
|
|
|
328
|
|
|
329
|
def makeXml(self, procUnitElement):
|
|
329
|
def makeXml(self, procUnitElement):
|
|
330
|
|
|
330
|
|
|
331
|
opElement = SubElement(procUnitElement, self.ELEMENTNAME)
|
|
331
|
opElement = SubElement(procUnitElement, self.ELEMENTNAME)
|
|
332
|
opElement.set('id', str(self.id))
|
|
332
|
opElement.set('id', str(self.id))
|
|
333
|
opElement.set('name', self.name)
|
|
333
|
opElement.set('name', self.name)
|
|
334
|
opElement.set('type', self.type)
|
|
334
|
opElement.set('type', self.type)
|
|
335
|
opElement.set('priority', str(self.priority))
|
|
335
|
opElement.set('priority', str(self.priority))
|
|
336
|
|
|
336
|
|
|
337
|
for parmConfObj in self.parmConfObjList:
|
|
337
|
for parmConfObj in self.parmConfObjList:
|
|
338
|
parmConfObj.makeXml(opElement)
|
|
338
|
parmConfObj.makeXml(opElement)
|
|
339
|
|
|
339
|
|
|
340
|
def readXml(self, opElement):
|
|
340
|
def readXml(self, opElement):
|
|
341
|
|
|
341
|
|
|
342
|
self.id = opElement.get('id')
|
|
342
|
self.id = opElement.get('id')
|
|
343
|
self.name = opElement.get('name')
|
|
343
|
self.name = opElement.get('name')
|
|
344
|
self.type = opElement.get('type')
|
|
344
|
self.type = opElement.get('type')
|
|
345
|
self.priority = opElement.get('priority')
|
|
345
|
self.priority = opElement.get('priority')
|
|
346
|
|
|
346
|
|
|
347
|
#Compatible with old signal chain version
|
|
347
|
#Compatible with old signal chain version
|
|
348
|
#Use of 'run' method instead 'init'
|
|
348
|
#Use of 'run' method instead 'init'
|
|
349
|
if self.type == 'self' and self.name == 'init':
|
|
349
|
if self.type == 'self' and self.name == 'init':
|
|
350
|
self.name = 'run'
|
|
350
|
self.name = 'run'
|
|
351
|
|
|
351
|
|
|
352
|
self.parmConfObjList = []
|
|
352
|
self.parmConfObjList = []
|
|
353
|
|
|
353
|
|
|
354
|
parmElementList = opElement.getiterator(ParameterConf().getElementName())
|
|
354
|
parmElementList = opElement.getiterator(ParameterConf().getElementName())
|
|
355
|
|
|
355
|
|
|
356
|
for parmElement in parmElementList:
|
|
356
|
for parmElement in parmElementList:
|
|
357
|
parmConfObj = ParameterConf()
|
|
357
|
parmConfObj = ParameterConf()
|
|
358
|
parmConfObj.readXml(parmElement)
|
|
358
|
parmConfObj.readXml(parmElement)
|
|
359
|
|
|
359
|
|
|
360
|
#Compatible with old signal chain version
|
|
360
|
#Compatible with old signal chain version
|
|
361
|
#If an 'plot' OPERATION is found, changes name operation by the value of its type PARAMETER
|
|
361
|
#If an 'plot' OPERATION is found, changes name operation by the value of its type PARAMETER
|
|
362
|
if self.type != 'self' and self.name == 'Plot':
|
|
362
|
if self.type != 'self' and self.name == 'Plot':
|
|
363
|
if parmConfObj.format == 'str' and parmConfObj.name == 'type':
|
|
363
|
if parmConfObj.format == 'str' and parmConfObj.name == 'type':
|
|
364
|
self.name = parmConfObj.value
|
|
364
|
self.name = parmConfObj.value
|
|
365
|
continue
|
|
365
|
continue
|
|
366
|
|
|
366
|
|
|
367
|
self.parmConfObjList.append(parmConfObj)
|
|
367
|
self.parmConfObjList.append(parmConfObj)
|
|
368
|
|
|
368
|
|
|
369
|
def printattr(self):
|
|
369
|
def printattr(self):
|
|
370
|
|
|
370
|
|
|
371
|
print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME,
|
|
371
|
print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME,
|
|
372
|
self.id,
|
|
372
|
self.id,
|
|
373
|
self.name,
|
|
373
|
self.name,
|
|
374
|
self.type,
|
|
374
|
self.type,
|
|
375
|
self.priority)
|
|
375
|
self.priority)
|
|
376
|
|
|
376
|
|
|
377
|
for parmConfObj in self.parmConfObjList:
|
|
377
|
for parmConfObj in self.parmConfObjList:
|
|
378
|
parmConfObj.printattr()
|
|
378
|
parmConfObj.printattr()
|
|
379
|
|
|
379
|
|
|
380
|
def createObject(self, plotter_queue=None):
|
|
380
|
def createObject(self, plotter_queue=None):
|
|
381
|
|
|
381
|
|
|
382
|
if self.type == 'self':
|
|
382
|
if self.type == 'self':
|
|
383
|
raise ValueError, "This operation type cannot be created"
|
|
383
|
raise ValueError, "This operation type cannot be created"
|
|
384
|
|
|
384
|
|
|
385
|
if self.type == 'plotter':
|
|
385
|
if self.type == 'plotter':
|
|
386
|
#Plotter(plotter_name)
|
|
386
|
#Plotter(plotter_name)
|
|
387
|
if not plotter_queue:
|
|
387
|
if not plotter_queue:
|
|
388
|
raise ValueError, "plotter_queue is not defined. Use:\nmyProject = Project()\nmyProject.setPlotterQueue(plotter_queue)"
|
|
388
|
raise ValueError, "plotter_queue is not defined. Use:\nmyProject = Project()\nmyProject.setPlotterQueue(plotter_queue)"
|
|
389
|
|
|
389
|
|
|
390
|
opObj = Plotter(self.name, plotter_queue)
|
|
390
|
opObj = Plotter(self.name, plotter_queue)
|
|
391
|
|
|
391
|
|
|
392
|
if self.type == 'external' or self.type == 'other':
|
|
392
|
if self.type == 'external' or self.type == 'other':
|
|
393
|
className = eval(self.name)
|
|
393
|
className = eval(self.name)
|
|
394
|
opObj = className()
|
|
394
|
opObj = className()
|
|
395
|
|
|
395
|
|
|
396
|
return opObj
|
|
396
|
return opObj
|
|
397
|
|
|
397
|
|
|
398
|
class ProcUnitConf():
|
|
398
|
class ProcUnitConf():
|
|
399
|
|
|
399
|
|
|
400
|
id = None
|
|
400
|
id = None
|
|
401
|
name = None
|
|
401
|
name = None
|
|
402
|
datatype = None
|
|
402
|
datatype = None
|
|
403
|
inputId = None
|
|
403
|
inputId = None
|
|
404
|
parentId = None
|
|
404
|
parentId = None
|
|
405
|
|
|
405
|
|
|
406
|
opConfObjList = []
|
|
406
|
opConfObjList = []
|
|
407
|
|
|
407
|
|
|
408
|
procUnitObj = None
|
|
408
|
procUnitObj = None
|
|
409
|
opObjList = []
|
|
409
|
opObjList = []
|
|
410
|
|
|
410
|
|
|
411
|
ELEMENTNAME = 'ProcUnit'
|
|
411
|
ELEMENTNAME = 'ProcUnit'
|
|
412
|
|
|
412
|
|
|
413
|
def __init__(self):
|
|
413
|
def __init__(self):
|
|
414
|
|
|
414
|
|
|
415
|
self.id = None
|
|
415
|
self.id = None
|
|
416
|
self.datatype = None
|
|
416
|
self.datatype = None
|
|
417
|
self.name = None
|
|
417
|
self.name = None
|
|
418
|
self.inputId = None
|
|
418
|
self.inputId = None
|
|
419
|
|
|
419
|
|
|
420
|
self.opConfObjList = []
|
|
420
|
self.opConfObjList = []
|
|
421
|
|
|
421
|
|
|
422
|
self.procUnitObj = None
|
|
422
|
self.procUnitObj = None
|
|
423
|
self.opObjDict = {}
|
|
423
|
self.opObjDict = {}
|
|
424
|
|
|
424
|
|
|
425
|
def __getPriority(self):
|
|
425
|
def __getPriority(self):
|
|
426
|
|
|
426
|
|
|
427
|
return len(self.opConfObjList)+1
|
|
427
|
return len(self.opConfObjList)+1
|
|
428
|
|
|
428
|
|
|
429
|
def __getNewId(self):
|
|
429
|
def __getNewId(self):
|
|
430
|
|
|
430
|
|
|
431
|
return int(self.id)*10 + len(self.opConfObjList) + 1
|
|
431
|
return int(self.id)*10 + len(self.opConfObjList) + 1
|
|
432
|
|
|
432
|
|
|
433
|
def getElementName(self):
|
|
433
|
def getElementName(self):
|
|
434
|
|
|
434
|
|
|
435
|
return self.ELEMENTNAME
|
|
435
|
return self.ELEMENTNAME
|
|
436
|
|
|
436
|
|
|
437
|
def getId(self):
|
|
437
|
def getId(self):
|
|
438
|
|
|
438
|
|
|
439
|
return self.id
|
|
439
|
return self.id
|
|
440
|
|
|
440
|
|
|
441
|
def updateId(self, new_id, parentId=parentId):
|
|
441
|
def updateId(self, new_id, parentId=parentId):
|
|
442
|
|
|
442
|
|
|
443
|
|
|
443
|
|
|
444
|
new_id = int(parentId)*10 + (int(self.id) % 10)
|
|
444
|
new_id = int(parentId)*10 + (int(self.id) % 10)
|
|
445
|
new_inputId = int(parentId)*10 + (int(self.inputId) % 10)
|
|
445
|
new_inputId = int(parentId)*10 + (int(self.inputId) % 10)
|
|
446
|
|
|
446
|
|
|
447
|
#If this proc unit has not inputs
|
|
447
|
#If this proc unit has not inputs
|
|
448
|
if self.inputId == '0':
|
|
448
|
if self.inputId == '0':
|
|
449
|
new_inputId = 0
|
|
449
|
new_inputId = 0
|
|
450
|
|
|
450
|
|
|
451
|
n = 1
|
|
451
|
n = 1
|
|
452
|
for opConfObj in self.opConfObjList:
|
|
452
|
for opConfObj in self.opConfObjList:
|
|
453
|
|
|
453
|
|
|
454
|
idOp = str(int(new_id)*10 + n)
|
|
454
|
idOp = str(int(new_id)*10 + n)
|
|
455
|
opConfObj.updateId(idOp)
|
|
455
|
opConfObj.updateId(idOp)
|
|
456
|
|
|
456
|
|
|
457
|
n += 1
|
|
457
|
n += 1
|
|
458
|
|
|
458
|
|
|
459
|
self.parentId = str(parentId)
|
|
459
|
self.parentId = str(parentId)
|
|
460
|
self.id = str(new_id)
|
|
460
|
self.id = str(new_id)
|
|
461
|
self.inputId = str(new_inputId)
|
|
461
|
self.inputId = str(new_inputId)
|
|
462
|
|
|
462
|
|
|
463
|
|
|
463
|
|
|
464
|
def getInputId(self):
|
|
464
|
def getInputId(self):
|
|
465
|
|
|
465
|
|
|
466
|
return self.inputId
|
|
466
|
return self.inputId
|
|
467
|
|
|
467
|
|
|
468
|
def getOperationObjList(self):
|
|
468
|
def getOperationObjList(self):
|
|
469
|
|
|
469
|
|
|
470
|
return self.opConfObjList
|
|
470
|
return self.opConfObjList
|
|
471
|
|
|
471
|
|
|
472
|
def getOperationObj(self, name=None):
|
|
472
|
def getOperationObj(self, name=None):
|
|
473
|
|
|
473
|
|
|
474
|
for opConfObj in self.opConfObjList:
|
|
474
|
for opConfObj in self.opConfObjList:
|
|
475
|
|
|
475
|
|
|
476
|
if opConfObj.name != name:
|
|
476
|
if opConfObj.name != name:
|
|
477
|
continue
|
|
477
|
continue
|
|
478
|
|
|
478
|
|
|
479
|
return opConfObj
|
|
479
|
return opConfObj
|
|
480
|
|
|
480
|
|
|
481
|
return None
|
|
481
|
return None
|
|
482
|
|
|
482
|
|
|
483
|
def getOpObjfromParamValue(self, value=None):
|
|
483
|
def getOpObjfromParamValue(self, value=None):
|
|
484
|
|
|
484
|
|
|
485
|
for opConfObj in self.opConfObjList:
|
|
485
|
for opConfObj in self.opConfObjList:
|
|
486
|
if opConfObj.getParameterObjfromValue(parameterValue=value) != value:
|
|
486
|
if opConfObj.getParameterObjfromValue(parameterValue=value) != value:
|
|
487
|
continue
|
|
487
|
continue
|
|
488
|
return opConfObj
|
|
488
|
return opConfObj
|
|
489
|
return None
|
|
489
|
return None
|
|
490
|
|
|
490
|
|
|
491
|
def getProcUnitObj(self):
|
|
491
|
def getProcUnitObj(self):
|
|
492
|
|
|
492
|
|
|
493
|
return self.procUnitObj
|
|
493
|
return self.procUnitObj
|
|
494
|
|
|
494
|
|
|
495
|
def setup(self, id, name, datatype, inputId, parentId=None):
|
|
495
|
def setup(self, id, name, datatype, inputId, parentId=None):
|
|
496
|
|
|
496
|
|
|
497
|
#Compatible with old signal chain version
|
|
497
|
#Compatible with old signal chain version
|
|
498
|
if datatype==None and name==None:
|
|
498
|
if datatype==None and name==None:
|
|
499
|
raise ValueError, "datatype or name should be defined"
|
|
499
|
raise ValueError, "datatype or name should be defined"
|
|
500
|
|
|
500
|
|
|
501
|
if name==None:
|
|
501
|
if name==None:
|
|
502
|
if 'Proc' in datatype:
|
|
502
|
if 'Proc' in datatype:
|
|
503
|
name = datatype
|
|
503
|
name = datatype
|
|
504
|
else:
|
|
504
|
else:
|
|
505
|
name = '%sProc' %(datatype)
|
|
505
|
name = '%sProc' %(datatype)
|
|
506
|
|
|
506
|
|
|
507
|
if datatype==None:
|
|
507
|
if datatype==None:
|
|
508
|
datatype = name.replace('Proc','')
|
|
508
|
datatype = name.replace('Proc','')
|
|
509
|
|
|
509
|
|
|
510
|
self.id = str(id)
|
|
510
|
self.id = str(id)
|
|
511
|
self.name = name
|
|
511
|
self.name = name
|
|
512
|
self.datatype = datatype
|
|
512
|
self.datatype = datatype
|
|
513
|
self.inputId = inputId
|
|
513
|
self.inputId = inputId
|
|
514
|
self.parentId = parentId
|
|
514
|
self.parentId = parentId
|
|
515
|
|
|
515
|
|
|
516
|
self.opConfObjList = []
|
|
516
|
self.opConfObjList = []
|
|
517
|
|
|
517
|
|
|
518
|
self.addOperation(name='run', optype='self')
|
|
518
|
self.addOperation(name='run', optype='self')
|
|
519
|
|
|
519
|
|
|
520
|
def removeOperations(self):
|
|
520
|
def removeOperations(self):
|
|
521
|
|
|
521
|
|
|
522
|
for obj in self.opConfObjList:
|
|
522
|
for obj in self.opConfObjList:
|
|
523
|
del obj
|
|
523
|
del obj
|
|
524
|
|
|
524
|
|
|
525
|
self.opConfObjList = []
|
|
525
|
self.opConfObjList = []
|
|
526
|
self.addOperation(name='run')
|
|
526
|
self.addOperation(name='run')
|
|
527
|
|
|
527
|
|
|
528
|
def addParameter(self, **kwargs):
|
|
528
|
def addParameter(self, **kwargs):
|
|
529
|
'''
|
|
529
|
'''
|
|
530
|
Add parameters to "run" operation
|
|
530
|
Add parameters to "run" operation
|
|
531
|
'''
|
|
531
|
'''
|
|
532
|
opObj = self.opConfObjList[0]
|
|
532
|
opObj = self.opConfObjList[0]
|
|
533
|
|
|
533
|
|
|
534
|
opObj.addParameter(**kwargs)
|
|
534
|
opObj.addParameter(**kwargs)
|
|
535
|
|
|
535
|
|
|
536
|
return opObj
|
|
536
|
return opObj
|
|
537
|
|
|
537
|
|
|
538
|
def addOperation(self, name, optype='self'):
|
|
538
|
def addOperation(self, name, optype='self'):
|
|
539
|
|
|
539
|
|
|
540
|
id = self.__getNewId()
|
|
540
|
id = self.__getNewId()
|
|
541
|
priority = self.__getPriority()
|
|
541
|
priority = self.__getPriority()
|
|
542
|
|
|
542
|
|
|
543
|
opConfObj = OperationConf()
|
|
543
|
opConfObj = OperationConf()
|
|
544
|
opConfObj.setup(id, name=name, priority=priority, type=optype)
|
|
544
|
opConfObj.setup(id, name=name, priority=priority, type=optype)
|
|
545
|
|
|
545
|
|
|
546
|
self.opConfObjList.append(opConfObj)
|
|
546
|
self.opConfObjList.append(opConfObj)
|
|
547
|
|
|
547
|
|
|
548
|
return opConfObj
|
|
548
|
return opConfObj
|
|
549
|
|
|
549
|
|
|
550
|
def makeXml(self, projectElement):
|
|
550
|
def makeXml(self, projectElement):
|
|
551
|
|
|
551
|
|
|
552
|
procUnitElement = SubElement(projectElement, self.ELEMENTNAME)
|
|
552
|
procUnitElement = SubElement(projectElement, self.ELEMENTNAME)
|
|
553
|
procUnitElement.set('id', str(self.id))
|
|
553
|
procUnitElement.set('id', str(self.id))
|
|
554
|
procUnitElement.set('name', self.name)
|
|
554
|
procUnitElement.set('name', self.name)
|
|
555
|
procUnitElement.set('datatype', self.datatype)
|
|
555
|
procUnitElement.set('datatype', self.datatype)
|
|
556
|
procUnitElement.set('inputId', str(self.inputId))
|
|
556
|
procUnitElement.set('inputId', str(self.inputId))
|
|
557
|
|
|
557
|
|
|
558
|
for opConfObj in self.opConfObjList:
|
|
558
|
for opConfObj in self.opConfObjList:
|
|
559
|
opConfObj.makeXml(procUnitElement)
|
|
559
|
opConfObj.makeXml(procUnitElement)
|
|
560
|
|
|
560
|
|
|
561
|
def readXml(self, upElement):
|
|
561
|
def readXml(self, upElement):
|
|
562
|
|
|
562
|
|
|
563
|
self.id = upElement.get('id')
|
|
563
|
self.id = upElement.get('id')
|
|
564
|
self.name = upElement.get('name')
|
|
564
|
self.name = upElement.get('name')
|
|
565
|
self.datatype = upElement.get('datatype')
|
|
565
|
self.datatype = upElement.get('datatype')
|
|
566
|
self.inputId = upElement.get('inputId')
|
|
566
|
self.inputId = upElement.get('inputId')
|
|
567
|
|
|
567
|
|
|
568
|
if self.ELEMENTNAME == "ReadUnit":
|
|
568
|
if self.ELEMENTNAME == "ReadUnit":
|
|
569
|
self.datatype = self.datatype.replace("Reader", "")
|
|
569
|
self.datatype = self.datatype.replace("Reader", "")
|
|
570
|
|
|
570
|
|
|
571
|
if self.ELEMENTNAME == "ProcUnit":
|
|
571
|
if self.ELEMENTNAME == "ProcUnit":
|
|
572
|
self.datatype = self.datatype.replace("Proc", "")
|
|
572
|
self.datatype = self.datatype.replace("Proc", "")
|
|
573
|
|
|
573
|
|
|
574
|
if self.inputId == 'None':
|
|
574
|
if self.inputId == 'None':
|
|
575
|
self.inputId = '0'
|
|
575
|
self.inputId = '0'
|
|
576
|
|
|
576
|
|
|
577
|
self.opConfObjList = []
|
|
577
|
self.opConfObjList = []
|
|
578
|
|
|
578
|
|
|
579
|
opElementList = upElement.getiterator(OperationConf().getElementName())
|
|
579
|
opElementList = upElement.getiterator(OperationConf().getElementName())
|
|
580
|
|
|
580
|
|
|
581
|
for opElement in opElementList:
|
|
581
|
for opElement in opElementList:
|
|
582
|
opConfObj = OperationConf()
|
|
582
|
opConfObj = OperationConf()
|
|
583
|
opConfObj.readXml(opElement)
|
|
583
|
opConfObj.readXml(opElement)
|
|
584
|
self.opConfObjList.append(opConfObj)
|
|
584
|
self.opConfObjList.append(opConfObj)
|
|
585
|
|
|
585
|
|
|
586
|
def printattr(self):
|
|
586
|
def printattr(self):
|
|
587
|
|
|
587
|
|
|
588
|
print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME,
|
|
588
|
print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME,
|
|
589
|
self.id,
|
|
589
|
self.id,
|
|
590
|
self.name,
|
|
590
|
self.name,
|
|
591
|
self.datatype,
|
|
591
|
self.datatype,
|
|
592
|
self.inputId)
|
|
592
|
self.inputId)
|
|
593
|
|
|
593
|
|
|
594
|
for opConfObj in self.opConfObjList:
|
|
594
|
for opConfObj in self.opConfObjList:
|
|
595
|
opConfObj.printattr()
|
|
595
|
opConfObj.printattr()
|
|
596
|
|
|
596
|
|
|
597
|
def createObjects(self, plotter_queue=None):
|
|
597
|
def createObjects(self, plotter_queue=None):
|
|
598
|
|
|
598
|
|
|
599
|
className = eval(self.name)
|
|
599
|
className = eval(self.name)
|
|
600
|
procUnitObj = className()
|
|
600
|
procUnitObj = className()
|
|
601
|
|
|
601
|
|
|
602
|
for opConfObj in self.opConfObjList:
|
|
602
|
for opConfObj in self.opConfObjList:
|
|
603
|
|
|
603
|
|
|
604
|
if opConfObj.type == 'self':
|
|
604
|
if opConfObj.type == 'self':
|
|
605
|
continue
|
|
605
|
continue
|
|
606
|
|
|
606
|
|
|
607
|
opObj = opConfObj.createObject(plotter_queue)
|
|
607
|
opObj = opConfObj.createObject(plotter_queue)
|
|
608
|
|
|
608
|
|
|
609
|
self.opObjDict[opConfObj.id] = opObj
|
|
609
|
self.opObjDict[opConfObj.id] = opObj
|
|
610
|
procUnitObj.addOperation(opObj, opConfObj.id)
|
|
610
|
procUnitObj.addOperation(opObj, opConfObj.id)
|
|
611
|
|
|
611
|
|
|
612
|
self.procUnitObj = procUnitObj
|
|
612
|
self.procUnitObj = procUnitObj
|
|
613
|
|
|
613
|
|
|
614
|
return procUnitObj
|
|
614
|
return procUnitObj
|
|
615
|
|
|
615
|
|
|
616
|
def run(self):
|
|
616
|
def run(self):
|
|
617
|
|
|
617
|
|
|
618
|
is_ok = False
|
|
618
|
is_ok = False
|
|
619
|
|
|
619
|
|
|
620
|
for opConfObj in self.opConfObjList:
|
|
620
|
for opConfObj in self.opConfObjList:
|
|
621
|
|
|
621
|
|
|
622
|
kwargs = {}
|
|
622
|
kwargs = {}
|
|
623
|
for parmConfObj in opConfObj.getParameterObjList():
|
|
623
|
for parmConfObj in opConfObj.getParameterObjList():
|
|
624
|
if opConfObj.name == 'run' and parmConfObj.name == 'datatype':
|
|
624
|
if opConfObj.name == 'run' and parmConfObj.name == 'datatype':
|
|
625
|
continue
|
|
625
|
continue
|
|
626
|
|
|
626
|
|
|
627
|
kwargs[parmConfObj.name] = parmConfObj.getValue()
|
|
627
|
kwargs[parmConfObj.name] = parmConfObj.getValue()
|
|
628
|
|
|
628
|
|
|
629
|
#print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id)
|
|
629
|
#print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id)
|
|
630
|
sts = self.procUnitObj.call(opType = opConfObj.type,
|
|
630
|
sts = self.procUnitObj.call(opType = opConfObj.type,
|
|
631
|
opName = opConfObj.name,
|
|
631
|
opName = opConfObj.name,
|
|
632
|
opId = opConfObj.id,
|
|
632
|
opId = opConfObj.id,
|
|
633
|
**kwargs)
|
|
633
|
**kwargs)
|
|
634
|
is_ok = is_ok or sts
|
|
634
|
is_ok = is_ok or sts
|
|
635
|
|
|
635
|
|
|
636
|
return is_ok
|
|
636
|
return is_ok
|
|
637
|
|
|
637
|
|
|
638
|
def close(self):
|
|
638
|
def close(self):
|
|
639
|
|
|
639
|
|
|
640
|
for opConfObj in self.opConfObjList:
|
|
640
|
for opConfObj in self.opConfObjList:
|
|
641
|
if opConfObj.type == 'self':
|
|
641
|
if opConfObj.type == 'self':
|
|
642
|
continue
|
|
642
|
continue
|
|
643
|
|
|
643
|
|
|
644
|
opObj = self.procUnitObj.getOperationObj(opConfObj.id)
|
|
644
|
opObj = self.procUnitObj.getOperationObj(opConfObj.id)
|
|
645
|
opObj.close()
|
|
645
|
opObj.close()
|
|
646
|
|
|
646
|
|
|
647
|
self.procUnitObj.close()
|
|
647
|
self.procUnitObj.close()
|
|
648
|
|
|
648
|
|
|
649
|
return
|
|
649
|
return
|
|
650
|
|
|
650
|
|
|
651
|
class ReadUnitConf(ProcUnitConf):
|
|
651
|
class ReadUnitConf(ProcUnitConf):
|
|
652
|
|
|
652
|
|
|
653
|
path = None
|
|
653
|
path = None
|
|
654
|
startDate = None
|
|
654
|
startDate = None
|
|
655
|
endDate = None
|
|
655
|
endDate = None
|
|
656
|
startTime = None
|
|
656
|
startTime = None
|
|
657
|
endTime = None
|
|
657
|
endTime = None
|
|
658
|
|
|
658
|
|
|
659
|
ELEMENTNAME = 'ReadUnit'
|
|
659
|
ELEMENTNAME = 'ReadUnit'
|
|
660
|
|
|
660
|
|
|
661
|
def __init__(self):
|
|
661
|
def __init__(self):
|
|
662
|
|
|
662
|
|
|
663
|
self.id = None
|
|
663
|
self.id = None
|
|
664
|
self.datatype = None
|
|
664
|
self.datatype = None
|
|
665
|
self.name = None
|
|
665
|
self.name = None
|
|
666
|
self.inputId = None
|
|
666
|
self.inputId = None
|
|
667
|
|
|
667
|
|
|
668
|
self.parentId = None
|
|
668
|
self.parentId = None
|
|
669
|
|
|
669
|
|
|
670
|
self.opConfObjList = []
|
|
670
|
self.opConfObjList = []
|
|
671
|
self.opObjList = []
|
|
671
|
self.opObjList = []
|
|
672
|
|
|
672
|
|
|
673
|
def getElementName(self):
|
|
673
|
def getElementName(self):
|
|
674
|
|
|
674
|
|
|
675
|
return self.ELEMENTNAME
|
|
675
|
return self.ELEMENTNAME
|
|
676
|
|
|
676
|
|
|
677
|
def setup(self, id, name, datatype, path, startDate="", endDate="", startTime="", endTime="", parentId=None, **kwargs):
|
|
677
|
def setup(self, id, name, datatype, path, startDate="", endDate="", startTime="", endTime="", parentId=None, **kwargs):
|
|
678
|
|
|
678
|
|
|
679
|
#Compatible with old signal chain version
|
|
679
|
#Compatible with old signal chain version
|
|
680
|
if datatype==None and name==None:
|
|
680
|
if datatype==None and name==None:
|
|
681
|
raise ValueError, "datatype or name should be defined"
|
|
681
|
raise ValueError, "datatype or name should be defined"
|
|
682
|
|
|
682
|
|
|
683
|
if name==None:
|
|
683
|
if name==None:
|
|
684
|
if 'Reader' in datatype:
|
|
684
|
if 'Reader' in datatype:
|
|
685
|
name = datatype
|
|
685
|
name = datatype
|
|
686
|
else:
|
|
686
|
else:
|
|
687
|
name = '%sReader' %(datatype)
|
|
687
|
name = '%sReader' %(datatype)
|
|
688
|
|
|
688
|
|
|
689
|
if datatype==None:
|
|
689
|
if datatype==None:
|
|
690
|
datatype = name.replace('Reader','')
|
|
690
|
datatype = name.replace('Reader','')
|
|
691
|
|
|
691
|
|
|
692
|
self.id = id
|
|
692
|
self.id = id
|
|
693
|
self.name = name
|
|
693
|
self.name = name
|
|
694
|
self.datatype = datatype
|
|
694
|
self.datatype = datatype
|
|
695
|
|
|
695
|
|
|
696
|
self.path = os.path.abspath(path)
|
|
696
|
self.path = os.path.abspath(path)
|
|
697
|
self.startDate = startDate
|
|
697
|
self.startDate = startDate
|
|
698
|
self.endDate = endDate
|
|
698
|
self.endDate = endDate
|
|
699
|
self.startTime = startTime
|
|
699
|
self.startTime = startTime
|
|
700
|
self.endTime = endTime
|
|
700
|
self.endTime = endTime
|
|
701
|
|
|
701
|
|
|
702
|
self.inputId = '0'
|
|
702
|
self.inputId = '0'
|
|
703
|
self.parentId = parentId
|
|
703
|
self.parentId = parentId
|
|
704
|
|
|
704
|
|
|
705
|
self.addRunOperation(**kwargs)
|
|
705
|
self.addRunOperation(**kwargs)
|
|
706
|
|
|
706
|
|
|
707
|
def update(self, datatype, path, startDate, endDate, startTime, endTime, parentId=None, name=None, **kwargs):
|
|
707
|
def update(self, datatype, path, startDate, endDate, startTime, endTime, parentId=None, name=None, **kwargs):
|
|
708
|
|
|
708
|
|
|
709
|
#Compatible with old signal chain version
|
|
709
|
#Compatible with old signal chain version
|
|
710
|
if datatype==None and name==None:
|
|
710
|
if datatype==None and name==None:
|
|
711
|
raise ValueError, "datatype or name should be defined"
|
|
711
|
raise ValueError, "datatype or name should be defined"
|
|
712
|
|
|
712
|
|
|
713
|
if name==None:
|
|
713
|
if name==None:
|
|
714
|
if 'Reader' in datatype:
|
|
714
|
if 'Reader' in datatype:
|
|
715
|
name = datatype
|
|
715
|
name = datatype
|
|
716
|
else:
|
|
716
|
else:
|
|
717
|
name = '%sReader' %(datatype)
|
|
717
|
name = '%sReader' %(datatype)
|
|
718
|
|
|
718
|
|
|
719
|
if datatype==None:
|
|
719
|
if datatype==None:
|
|
720
|
datatype = name.replace('Reader','')
|
|
720
|
datatype = name.replace('Reader','')
|
|
721
|
|
|
721
|
|
|
722
|
self.datatype = datatype
|
|
722
|
self.datatype = datatype
|
|
723
|
self.name = name
|
|
723
|
self.name = name
|
|
724
|
self.path = path
|
|
724
|
self.path = path
|
|
725
|
self.startDate = startDate
|
|
725
|
self.startDate = startDate
|
|
726
|
self.endDate = endDate
|
|
726
|
self.endDate = endDate
|
|
727
|
self.startTime = startTime
|
|
727
|
self.startTime = startTime
|
|
728
|
self.endTime = endTime
|
|
728
|
self.endTime = endTime
|
|
729
|
|
|
729
|
|
|
730
|
self.inputId = '0'
|
|
730
|
self.inputId = '0'
|
|
731
|
self.parentId = parentId
|
|
731
|
self.parentId = parentId
|
|
732
|
|
|
732
|
|
|
733
|
self.updateRunOperation(**kwargs)
|
|
733
|
self.updateRunOperation(**kwargs)
|
|
734
|
|
|
734
|
|
|
735
|
def removeOperations(self):
|
|
735
|
def removeOperations(self):
|
|
736
|
|
|
736
|
|
|
737
|
for obj in self.opConfObjList:
|
|
737
|
for obj in self.opConfObjList:
|
|
738
|
del obj
|
|
738
|
del obj
|
|
739
|
|
|
739
|
|
|
740
|
self.opConfObjList = []
|
|
740
|
self.opConfObjList = []
|
|
741
|
|
|
741
|
|
|
742
|
def addRunOperation(self, **kwargs):
|
|
742
|
def addRunOperation(self, **kwargs):
|
|
743
|
|
|
743
|
|
|
744
|
opObj = self.addOperation(name = 'run', optype = 'self')
|
|
744
|
opObj = self.addOperation(name = 'run', optype = 'self')
|
|
745
|
|
|
745
|
|
|
746
|
opObj.addParameter(name='datatype' , value=self.datatype, format='str')
|
|
746
|
opObj.addParameter(name='datatype' , value=self.datatype, format='str')
|
|
747
|
opObj.addParameter(name='path' , value=self.path, format='str')
|
|
747
|
opObj.addParameter(name='path' , value=self.path, format='str')
|
|
748
|
opObj.addParameter(name='startDate' , value=self.startDate, format='date')
|
|
748
|
opObj.addParameter(name='startDate' , value=self.startDate, format='date')
|
|
749
|
opObj.addParameter(name='endDate' , value=self.endDate, format='date')
|
|
749
|
opObj.addParameter(name='endDate' , value=self.endDate, format='date')
|
|
750
|
opObj.addParameter(name='startTime' , value=self.startTime, format='time')
|
|
750
|
opObj.addParameter(name='startTime' , value=self.startTime, format='time')
|
|
751
|
opObj.addParameter(name='endTime' , value=self.endTime, format='time')
|
|
751
|
opObj.addParameter(name='endTime' , value=self.endTime, format='time')
|
|
752
|
|
|
752
|
|
|
753
|
for key, value in kwargs.items():
|
|
753
|
for key, value in kwargs.items():
|
|
754
|
opObj.addParameter(name=key, value=value, format=type(value).__name__)
|
|
754
|
opObj.addParameter(name=key, value=value, format=type(value).__name__)
|
|
755
|
|
|
755
|
|
|
756
|
return opObj
|
|
756
|
return opObj
|
|
757
|
|
|
757
|
|
|
758
|
def updateRunOperation(self, **kwargs):
|
|
758
|
def updateRunOperation(self, **kwargs):
|
|
759
|
|
|
759
|
|
|
760
|
opObj = self.getOperationObj(name = 'run')
|
|
760
|
opObj = self.getOperationObj(name = 'run')
|
|
761
|
opObj.removeParameters()
|
|
761
|
opObj.removeParameters()
|
|
762
|
|
|
762
|
|
|
763
|
opObj.addParameter(name='datatype' , value=self.datatype, format='str')
|
|
763
|
opObj.addParameter(name='datatype' , value=self.datatype, format='str')
|
|
764
|
opObj.addParameter(name='path' , value=self.path, format='str')
|
|
764
|
opObj.addParameter(name='path' , value=self.path, format='str')
|
|
765
|
opObj.addParameter(name='startDate' , value=self.startDate, format='date')
|
|
765
|
opObj.addParameter(name='startDate' , value=self.startDate, format='date')
|
|
766
|
opObj.addParameter(name='endDate' , value=self.endDate, format='date')
|
|
766
|
opObj.addParameter(name='endDate' , value=self.endDate, format='date')
|
|
767
|
opObj.addParameter(name='startTime' , value=self.startTime, format='time')
|
|
767
|
opObj.addParameter(name='startTime' , value=self.startTime, format='time')
|
|
768
|
opObj.addParameter(name='endTime' , value=self.endTime, format='time')
|
|
768
|
opObj.addParameter(name='endTime' , value=self.endTime, format='time')
|
|
769
|
|
|
769
|
|
|
770
|
for key, value in kwargs.items():
|
|
770
|
for key, value in kwargs.items():
|
|
771
|
opObj.addParameter(name=key, value=value, format=type(value).__name__)
|
|
771
|
opObj.addParameter(name=key, value=value, format=type(value).__name__)
|
|
772
|
|
|
772
|
|
|
773
|
return opObj
|
|
773
|
return opObj
|
|
774
|
|
|
774
|
|
|
775
|
# def makeXml(self, projectElement):
|
|
775
|
# def makeXml(self, projectElement):
|
|
776
|
#
|
|
776
|
#
|
|
777
|
# procUnitElement = SubElement(projectElement, self.ELEMENTNAME)
|
|
777
|
# procUnitElement = SubElement(projectElement, self.ELEMENTNAME)
|
|
778
|
# procUnitElement.set('id', str(self.id))
|
|
778
|
# procUnitElement.set('id', str(self.id))
|
|
779
|
# procUnitElement.set('name', self.name)
|
|
779
|
# procUnitElement.set('name', self.name)
|
|
780
|
# procUnitElement.set('datatype', self.datatype)
|
|
780
|
# procUnitElement.set('datatype', self.datatype)
|
|
781
|
# procUnitElement.set('inputId', str(self.inputId))
|
|
781
|
# procUnitElement.set('inputId', str(self.inputId))
|
|
782
|
#
|
|
782
|
#
|
|
783
|
# for opConfObj in self.opConfObjList:
|
|
783
|
# for opConfObj in self.opConfObjList:
|
|
784
|
# opConfObj.makeXml(procUnitElement)
|
|
784
|
# opConfObj.makeXml(procUnitElement)
|
|
785
|
|
|
785
|
|
|
786
|
def readXml(self, upElement):
|
|
786
|
def readXml(self, upElement):
|
|
787
|
|
|
787
|
|
|
788
|
self.id = upElement.get('id')
|
|
788
|
self.id = upElement.get('id')
|
|
789
|
self.name = upElement.get('name')
|
|
789
|
self.name = upElement.get('name')
|
|
790
|
self.datatype = upElement.get('datatype')
|
|
790
|
self.datatype = upElement.get('datatype')
|
|
791
|
self.inputId = upElement.get('inputId')
|
|
791
|
self.inputId = upElement.get('inputId')
|
|
792
|
|
|
792
|
|
|
793
|
if self.ELEMENTNAME == "ReadUnit":
|
|
793
|
if self.ELEMENTNAME == "ReadUnit":
|
|
794
|
self.datatype = self.datatype.replace("Reader", "")
|
|
794
|
self.datatype = self.datatype.replace("Reader", "")
|
|
795
|
|
|
795
|
|
|
796
|
if self.inputId == 'None':
|
|
796
|
if self.inputId == 'None':
|
|
797
|
self.inputId = '0'
|
|
797
|
self.inputId = '0'
|
|
798
|
|
|
798
|
|
|
799
|
self.opConfObjList = []
|
|
799
|
self.opConfObjList = []
|
|
800
|
|
|
800
|
|
|
801
|
opElementList = upElement.getiterator(OperationConf().getElementName())
|
|
801
|
opElementList = upElement.getiterator(OperationConf().getElementName())
|
|
802
|
|
|
802
|
|
|
803
|
for opElement in opElementList:
|
|
803
|
for opElement in opElementList:
|
|
804
|
opConfObj = OperationConf()
|
|
804
|
opConfObj = OperationConf()
|
|
805
|
opConfObj.readXml(opElement)
|
|
805
|
opConfObj.readXml(opElement)
|
|
806
|
self.opConfObjList.append(opConfObj)
|
|
806
|
self.opConfObjList.append(opConfObj)
|
|
807
|
|
|
807
|
|
|
808
|
if opConfObj.name == 'run':
|
|
808
|
if opConfObj.name == 'run':
|
|
809
|
self.path = opConfObj.getParameterValue('path')
|
|
809
|
self.path = opConfObj.getParameterValue('path')
|
|
810
|
self.startDate = opConfObj.getParameterValue('startDate')
|
|
810
|
self.startDate = opConfObj.getParameterValue('startDate')
|
|
811
|
self.endDate = opConfObj.getParameterValue('endDate')
|
|
811
|
self.endDate = opConfObj.getParameterValue('endDate')
|
|
812
|
self.startTime = opConfObj.getParameterValue('startTime')
|
|
812
|
self.startTime = opConfObj.getParameterValue('startTime')
|
|
813
|
self.endTime = opConfObj.getParameterValue('endTime')
|
|
813
|
self.endTime = opConfObj.getParameterValue('endTime')
|
|
814
|
|
|
814
|
|
|
815
|
class Project():
|
|
815
|
class Project():
|
|
816
|
|
|
816
|
|
|
817
|
id = None
|
|
817
|
id = None
|
|
818
|
name = None
|
|
818
|
name = None
|
|
819
|
description = None
|
|
819
|
description = None
|
|
820
|
filename = None
|
|
820
|
filename = None
|
|
821
|
|
|
821
|
|
|
822
|
procUnitConfObjDict = None
|
|
822
|
procUnitConfObjDict = None
|
|
823
|
|
|
823
|
|
|
824
|
ELEMENTNAME = 'Project'
|
|
824
|
ELEMENTNAME = 'Project'
|
|
825
|
|
|
825
|
|
|
826
|
__plotterQueue = None
|
|
826
|
plotterQueue = None
|
|
827
|
|
|
827
|
|
|
828
|
def __init__(self, plotter_queue=None):
|
|
828
|
def __init__(self, plotter_queue=None):
|
|
829
|
|
|
829
|
|
|
830
|
self.id = None
|
|
830
|
self.id = None
|
|
831
|
self.name = None
|
|
831
|
self.name = None
|
|
832
|
self.description = None
|
|
832
|
self.description = None
|
|
833
|
|
|
833
|
|
|
834
|
self.__plotterQueue = plotter_queue
|
|
834
|
self.plotterQueue = plotter_queue
|
|
835
|
|
|
835
|
|
|
836
|
self.procUnitConfObjDict = {}
|
|
836
|
self.procUnitConfObjDict = {}
|
|
837
|
|
|
837
|
|
|
838
|
def __getNewId(self):
|
|
838
|
def __getNewId(self):
|
|
839
|
|
|
839
|
|
|
840
|
id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1
|
|
840
|
id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1
|
|
841
|
|
|
841
|
|
|
842
|
return str(id)
|
|
842
|
return str(id)
|
|
843
|
|
|
843
|
|
|
844
|
def getElementName(self):
|
|
844
|
def getElementName(self):
|
|
845
|
|
|
845
|
|
|
846
|
return self.ELEMENTNAME
|
|
846
|
return self.ELEMENTNAME
|
|
847
|
|
|
847
|
|
|
848
|
def getId(self):
|
|
848
|
def getId(self):
|
|
849
|
|
|
849
|
|
|
850
|
return self.id
|
|
850
|
return self.id
|
|
851
|
|
|
851
|
|
|
852
|
def updateId(self, new_id):
|
|
852
|
def updateId(self, new_id):
|
|
853
|
|
|
853
|
|
|
854
|
self.id = str(new_id)
|
|
854
|
self.id = str(new_id)
|
|
855
|
|
|
855
|
|
|
856
|
keyList = self.procUnitConfObjDict.keys()
|
|
856
|
keyList = self.procUnitConfObjDict.keys()
|
|
857
|
keyList.sort()
|
|
857
|
keyList.sort()
|
|
858
|
|
|
858
|
|
|
859
|
n = 1
|
|
859
|
n = 1
|
|
860
|
newProcUnitConfObjDict = {}
|
|
860
|
newProcUnitConfObjDict = {}
|
|
861
|
|
|
861
|
|
|
862
|
for procKey in keyList:
|
|
862
|
for procKey in keyList:
|
|
863
|
|
|
863
|
|
|
864
|
procUnitConfObj = self.procUnitConfObjDict[procKey]
|
|
864
|
procUnitConfObj = self.procUnitConfObjDict[procKey]
|
|
865
|
idProcUnit = str(int(self.id)*10 + n)
|
|
865
|
idProcUnit = str(int(self.id)*10 + n)
|
|
866
|
procUnitConfObj.updateId(idProcUnit, parentId = self.id)
|
|
866
|
procUnitConfObj.updateId(idProcUnit, parentId = self.id)
|
|
867
|
|
|
867
|
|
|
868
|
newProcUnitConfObjDict[idProcUnit] = procUnitConfObj
|
|
868
|
newProcUnitConfObjDict[idProcUnit] = procUnitConfObj
|
|
869
|
n += 1
|
|
869
|
n += 1
|
|
870
|
|
|
870
|
|
|
871
|
self.procUnitConfObjDict = newProcUnitConfObjDict
|
|
871
|
self.procUnitConfObjDict = newProcUnitConfObjDict
|
|
872
|
|
|
872
|
|
|
873
|
def setup(self, id, name, description):
|
|
873
|
def setup(self, id, name, description):
|
|
874
|
|
|
874
|
|
|
875
|
self.id = str(id)
|
|
875
|
self.id = str(id)
|
|
876
|
self.name = name
|
|
876
|
self.name = name
|
|
877
|
self.description = description
|
|
877
|
self.description = description
|
|
878
|
|
|
878
|
|
|
879
|
def update(self, name, description):
|
|
879
|
def update(self, name, description):
|
|
880
|
|
|
880
|
|
|
881
|
self.name = name
|
|
881
|
self.name = name
|
|
882
|
self.description = description
|
|
882
|
self.description = description
|
|
883
|
|
|
883
|
|
|
884
|
def addReadUnit(self, id=None, datatype=None, name=None, **kwargs):
|
|
884
|
def addReadUnit(self, id=None, datatype=None, name=None, **kwargs):
|
|
885
|
|
|
885
|
|
|
886
|
if id is None:
|
|
886
|
if id is None:
|
|
887
|
idReadUnit = self.__getNewId()
|
|
887
|
idReadUnit = self.__getNewId()
|
|
888
|
else:
|
|
888
|
else:
|
|
889
|
idReadUnit = str(id)
|
|
889
|
idReadUnit = str(id)
|
|
890
|
|
|
890
|
|
|
891
|
readUnitConfObj = ReadUnitConf()
|
|
891
|
readUnitConfObj = ReadUnitConf()
|
|
892
|
readUnitConfObj.setup(idReadUnit, name, datatype, parentId=self.id, **kwargs)
|
|
892
|
readUnitConfObj.setup(idReadUnit, name, datatype, parentId=self.id, **kwargs)
|
|
893
|
|
|
893
|
|
|
894
|
self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
|
|
894
|
self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
|
|
895
|
|
|
895
|
|
|
896
|
return readUnitConfObj
|
|
896
|
return readUnitConfObj
|
|
897
|
|
|
897
|
|
|
898
|
def addProcUnit(self, inputId='0', datatype=None, name=None):
|
|
898
|
def addProcUnit(self, inputId='0', datatype=None, name=None):
|
|
899
|
|
|
899
|
|
|
900
|
idProcUnit = self.__getNewId()
|
|
900
|
idProcUnit = self.__getNewId()
|
|
901
|
|
|
901
|
|
|
902
|
procUnitConfObj = ProcUnitConf()
|
|
902
|
procUnitConfObj = ProcUnitConf()
|
|
903
|
procUnitConfObj.setup(idProcUnit, name, datatype, inputId, parentId=self.id)
|
|
903
|
procUnitConfObj.setup(idProcUnit, name, datatype, inputId, parentId=self.id)
|
|
904
|
|
|
904
|
|
|
905
|
self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
|
|
905
|
self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
|
|
906
|
|
|
906
|
|
|
907
|
return procUnitConfObj
|
|
907
|
return procUnitConfObj
|
|
908
|
|
|
908
|
|
|
909
|
def removeProcUnit(self, id):
|
|
909
|
def removeProcUnit(self, id):
|
|
910
|
|
|
910
|
|
|
911
|
if id in self.procUnitConfObjDict.keys():
|
|
911
|
if id in self.procUnitConfObjDict.keys():
|
|
912
|
self.procUnitConfObjDict.pop(id)
|
|
912
|
self.procUnitConfObjDict.pop(id)
|
|
913
|
|
|
913
|
|
|
914
|
def getReadUnitId(self):
|
|
914
|
def getReadUnitId(self):
|
|
915
|
|
|
915
|
|
|
916
|
readUnitConfObj = self.getReadUnitObj()
|
|
916
|
readUnitConfObj = self.getReadUnitObj()
|
|
917
|
|
|
917
|
|
|
918
|
return readUnitConfObj.id
|
|
918
|
return readUnitConfObj.id
|
|
919
|
|
|
919
|
|
|
920
|
def getReadUnitObj(self):
|
|
920
|
def getReadUnitObj(self):
|
|
921
|
|
|
921
|
|
|
922
|
for obj in self.procUnitConfObjDict.values():
|
|
922
|
for obj in self.procUnitConfObjDict.values():
|
|
923
|
if obj.getElementName() == "ReadUnit":
|
|
923
|
if obj.getElementName() == "ReadUnit":
|
|
924
|
return obj
|
|
924
|
return obj
|
|
925
|
|
|
925
|
|
|
926
|
return None
|
|
926
|
return None
|
|
927
|
|
|
927
|
|
|
928
|
def getProcUnitObj(self, id=None, name=None):
|
|
928
|
def getProcUnitObj(self, id=None, name=None):
|
|
929
|
|
|
929
|
|
|
930
|
if id != None:
|
|
930
|
if id != None:
|
|
931
|
return self.procUnitConfObjDict[id]
|
|
931
|
return self.procUnitConfObjDict[id]
|
|
932
|
|
|
932
|
|
|
933
|
if name != None:
|
|
933
|
if name != None:
|
|
934
|
return self.getProcUnitObjByName(name)
|
|
934
|
return self.getProcUnitObjByName(name)
|
|
935
|
|
|
935
|
|
|
936
|
return None
|
|
936
|
return None
|
|
937
|
|
|
937
|
|
|
938
|
def getProcUnitObjByName(self, name):
|
|
938
|
def getProcUnitObjByName(self, name):
|
|
939
|
|
|
939
|
|
|
940
|
for obj in self.procUnitConfObjDict.values():
|
|
940
|
for obj in self.procUnitConfObjDict.values():
|
|
941
|
if obj.name == name:
|
|
941
|
if obj.name == name:
|
|
942
|
return obj
|
|
942
|
return obj
|
|
943
|
|
|
943
|
|
|
944
|
return None
|
|
944
|
return None
|
|
945
|
|
|
945
|
|
|
946
|
def procUnitItems(self):
|
|
946
|
def procUnitItems(self):
|
|
947
|
|
|
947
|
|
|
948
|
return self.procUnitConfObjDict.items()
|
|
948
|
return self.procUnitConfObjDict.items()
|
|
949
|
|
|
949
|
|
|
950
|
def makeXml(self):
|
|
950
|
def makeXml(self):
|
|
951
|
|
|
951
|
|
|
952
|
projectElement = Element('Project')
|
|
952
|
projectElement = Element('Project')
|
|
953
|
projectElement.set('id', str(self.id))
|
|
953
|
projectElement.set('id', str(self.id))
|
|
954
|
projectElement.set('name', self.name)
|
|
954
|
projectElement.set('name', self.name)
|
|
955
|
projectElement.set('description', self.description)
|
|
955
|
projectElement.set('description', self.description)
|
|
956
|
|
|
956
|
|
|
957
|
for procUnitConfObj in self.procUnitConfObjDict.values():
|
|
957
|
for procUnitConfObj in self.procUnitConfObjDict.values():
|
|
958
|
procUnitConfObj.makeXml(projectElement)
|
|
958
|
procUnitConfObj.makeXml(projectElement)
|
|
959
|
|
|
959
|
|
|
960
|
self.projectElement = projectElement
|
|
960
|
self.projectElement = projectElement
|
|
961
|
|
|
961
|
|
|
962
|
def writeXml(self, filename=None):
|
|
962
|
def writeXml(self, filename=None):
|
|
963
|
|
|
963
|
|
|
964
|
if filename == None:
|
|
964
|
if filename == None:
|
|
965
|
if self.filename:
|
|
965
|
if self.filename:
|
|
966
|
filename = self.filename
|
|
966
|
filename = self.filename
|
|
967
|
else:
|
|
967
|
else:
|
|
968
|
filename = "schain.xml"
|
|
968
|
filename = "schain.xml"
|
|
969
|
|
|
969
|
|
|
970
|
if not filename:
|
|
970
|
if not filename:
|
|
971
|
print "filename has not been defined. Use setFilename(filename) for do it."
|
|
971
|
print "filename has not been defined. Use setFilename(filename) for do it."
|
|
972
|
return 0
|
|
972
|
return 0
|
|
973
|
|
|
973
|
|
|
974
|
abs_file = os.path.abspath(filename)
|
|
974
|
abs_file = os.path.abspath(filename)
|
|
975
|
|
|
975
|
|
|
976
|
if not os.access(os.path.dirname(abs_file), os.W_OK):
|
|
976
|
if not os.access(os.path.dirname(abs_file), os.W_OK):
|
|
977
|
print "No write permission on %s" %os.path.dirname(abs_file)
|
|
977
|
print "No write permission on %s" %os.path.dirname(abs_file)
|
|
978
|
return 0
|
|
978
|
return 0
|
|
979
|
|
|
979
|
|
|
980
|
if os.path.isfile(abs_file) and not(os.access(abs_file, os.W_OK)):
|
|
980
|
if os.path.isfile(abs_file) and not(os.access(abs_file, os.W_OK)):
|
|
981
|
print "File %s already exists and it could not be overwriten" %abs_file
|
|
981
|
print "File %s already exists and it could not be overwriten" %abs_file
|
|
982
|
return 0
|
|
982
|
return 0
|
|
983
|
|
|
983
|
|
|
984
|
self.makeXml()
|
|
984
|
self.makeXml()
|
|
985
|
|
|
985
|
|
|
986
|
ElementTree(self.projectElement).write(abs_file, method='xml')
|
|
986
|
ElementTree(self.projectElement).write(abs_file, method='xml')
|
|
987
|
|
|
987
|
|
|
988
|
self.filename = abs_file
|
|
988
|
self.filename = abs_file
|
|
989
|
|
|
989
|
|
|
990
|
return 1
|
|
990
|
return 1
|
|
991
|
|
|
991
|
|
|
992
|
def readXml(self, filename = None):
|
|
992
|
def readXml(self, filename = None):
|
|
993
|
|
|
993
|
|
|
994
|
abs_file = os.path.abspath(filename)
|
|
994
|
abs_file = os.path.abspath(filename)
|
|
995
|
|
|
995
|
|
|
996
|
if not os.path.isfile(abs_file):
|
|
996
|
if not os.path.isfile(abs_file):
|
|
997
|
print "%s does not exist" %abs_file
|
|
997
|
print "%s does not exist" %abs_file
|
|
998
|
return 0
|
|
998
|
return 0
|
|
999
|
|
|
999
|
|
|
1000
|
self.projectElement = None
|
|
1000
|
self.projectElement = None
|
|
1001
|
self.procUnitConfObjDict = {}
|
|
1001
|
self.procUnitConfObjDict = {}
|
|
1002
|
|
|
1002
|
|
|
1003
|
self.projectElement = ElementTree().parse(abs_file)
|
|
1003
|
self.projectElement = ElementTree().parse(abs_file)
|
|
1004
|
|
|
1004
|
|
|
1005
|
self.project = self.projectElement.tag
|
|
1005
|
self.project = self.projectElement.tag
|
|
1006
|
|
|
1006
|
|
|
1007
|
self.id = self.projectElement.get('id')
|
|
1007
|
self.id = self.projectElement.get('id')
|
|
1008
|
self.name = self.projectElement.get('name')
|
|
1008
|
self.name = self.projectElement.get('name')
|
|
1009
|
self.description = self.projectElement.get('description')
|
|
1009
|
self.description = self.projectElement.get('description')
|
|
1010
|
|
|
1010
|
|
|
1011
|
readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName())
|
|
1011
|
readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName())
|
|
1012
|
|
|
1012
|
|
|
1013
|
for readUnitElement in readUnitElementList:
|
|
1013
|
for readUnitElement in readUnitElementList:
|
|
1014
|
readUnitConfObj = ReadUnitConf()
|
|
1014
|
readUnitConfObj = ReadUnitConf()
|
|
1015
|
readUnitConfObj.readXml(readUnitElement)
|
|
1015
|
readUnitConfObj.readXml(readUnitElement)
|
|
1016
|
|
|
1016
|
|
|
1017
|
if readUnitConfObj.parentId == None:
|
|
1017
|
if readUnitConfObj.parentId == None:
|
|
1018
|
readUnitConfObj.parentId = self.id
|
|
1018
|
readUnitConfObj.parentId = self.id
|
|
1019
|
|
|
1019
|
|
|
1020
|
self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
|
|
1020
|
self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
|
|
1021
|
|
|
1021
|
|
|
1022
|
procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName())
|
|
1022
|
procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName())
|
|
1023
|
|
|
1023
|
|
|
1024
|
for procUnitElement in procUnitElementList:
|
|
1024
|
for procUnitElement in procUnitElementList:
|
|
1025
|
procUnitConfObj = ProcUnitConf()
|
|
1025
|
procUnitConfObj = ProcUnitConf()
|
|
1026
|
procUnitConfObj.readXml(procUnitElement)
|
|
1026
|
procUnitConfObj.readXml(procUnitElement)
|
|
1027
|
|
|
1027
|
|
|
1028
|
if procUnitConfObj.parentId == None:
|
|
1028
|
if procUnitConfObj.parentId == None:
|
|
1029
|
procUnitConfObj.parentId = self.id
|
|
1029
|
procUnitConfObj.parentId = self.id
|
|
1030
|
|
|
1030
|
|
|
1031
|
self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
|
|
1031
|
self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
|
|
1032
|
|
|
1032
|
|
|
1033
|
self.filename = abs_file
|
|
1033
|
self.filename = abs_file
|
|
1034
|
|
|
1034
|
|
|
1035
|
return 1
|
|
1035
|
return 1
|
|
1036
|
|
|
1036
|
|
|
1037
|
def printattr(self):
|
|
1037
|
def printattr(self):
|
|
1038
|
|
|
1038
|
|
|
1039
|
print "Project[%s]: name = %s, description = %s" %(self.id,
|
|
1039
|
print "Project[%s]: name = %s, description = %s" %(self.id,
|
|
1040
|
self.name,
|
|
1040
|
self.name,
|
|
1041
|
self.description)
|
|
1041
|
self.description)
|
|
1042
|
|
|
1042
|
|
|
1043
|
for procUnitConfObj in self.procUnitConfObjDict.values():
|
|
1043
|
for procUnitConfObj in self.procUnitConfObjDict.values():
|
|
1044
|
procUnitConfObj.printattr()
|
|
1044
|
procUnitConfObj.printattr()
|
|
1045
|
|
|
1045
|
|
|
1046
|
def createObjects(self):
|
|
1046
|
def createObjects(self):
|
|
1047
|
|
|
1047
|
|
|
1048
|
for procUnitConfObj in self.procUnitConfObjDict.values():
|
|
1048
|
for procUnitConfObj in self.procUnitConfObjDict.values():
|
|
1049
|
procUnitConfObj.createObjects(self.__plotterQueue)
|
|
1049
|
procUnitConfObj.createObjects(self.plotterQueue)
|
|
1050
|
|
|
1050
|
|
|
1051
|
def __connect(self, objIN, thisObj):
|
|
1051
|
def __connect(self, objIN, thisObj):
|
|
1052
|
|
|
1052
|
|
|
1053
|
thisObj.setInput(objIN.getOutputObj())
|
|
1053
|
thisObj.setInput(objIN.getOutputObj())
|
|
1054
|
|
|
1054
|
|
|
1055
|
def connectObjects(self):
|
|
1055
|
def connectObjects(self):
|
|
1056
|
|
|
1056
|
|
|
1057
|
for thisPUConfObj in self.procUnitConfObjDict.values():
|
|
1057
|
for thisPUConfObj in self.procUnitConfObjDict.values():
|
|
1058
|
|
|
1058
|
|
|
1059
|
inputId = thisPUConfObj.getInputId()
|
|
1059
|
inputId = thisPUConfObj.getInputId()
|
|
1060
|
|
|
1060
|
|
|
1061
|
if int(inputId) == 0:
|
|
1061
|
if int(inputId) == 0:
|
|
1062
|
continue
|
|
1062
|
continue
|
|
1063
|
|
|
1063
|
|
|
1064
|
#Get input object
|
|
1064
|
#Get input object
|
|
1065
|
puConfINObj = self.procUnitConfObjDict[inputId]
|
|
1065
|
puConfINObj = self.procUnitConfObjDict[inputId]
|
|
1066
|
puObjIN = puConfINObj.getProcUnitObj()
|
|
1066
|
puObjIN = puConfINObj.getProcUnitObj()
|
|
1067
|
|
|
1067
|
|
|
1068
|
#Get current object
|
|
1068
|
#Get current object
|
|
1069
|
thisPUObj = thisPUConfObj.getProcUnitObj()
|
|
1069
|
thisPUObj = thisPUConfObj.getProcUnitObj()
|
|
1070
|
|
|
1070
|
|
|
1071
|
self.__connect(puObjIN, thisPUObj)
|
|
1071
|
self.__connect(puObjIN, thisPUObj)
|
|
1072
|
|
|
1072
|
|
|
1073
|
def __handleError(self, procUnitConfObj):
|
|
1073
|
def __handleError(self, procUnitConfObj):
|
|
1074
|
|
|
1074
|
|
|
1075
|
import socket
|
|
1075
|
import socket
|
|
1076
|
|
|
1076
|
|
|
1077
|
err = traceback.format_exception(sys.exc_info()[0],
|
|
1077
|
err = traceback.format_exception(sys.exc_info()[0],
|
|
1078
|
sys.exc_info()[1],
|
|
1078
|
sys.exc_info()[1],
|
|
1079
|
sys.exc_info()[2])
|
|
1079
|
sys.exc_info()[2])
|
|
1080
|
|
|
1080
|
|
|
1081
|
subject = "SChain v%s: Error running %s\n" %(schainpy.__version__, procUnitConfObj.name)
|
|
1081
|
subject = "SChain v%s: Error running %s\n" %(schainpy.__version__, procUnitConfObj.name)
|
|
1082
|
|
|
1082
|
|
|
1083
|
subtitle = "%s: %s\n" %(procUnitConfObj.getElementName() ,procUnitConfObj.name)
|
|
1083
|
subtitle = "%s: %s\n" %(procUnitConfObj.getElementName() ,procUnitConfObj.name)
|
|
1084
|
subtitle += "Hostname: %s\n" %socket.gethostbyname(socket.gethostname())
|
|
1084
|
subtitle += "Hostname: %s\n" %socket.gethostbyname(socket.gethostname())
|
|
1085
|
subtitle += "Working directory: %s\n" %os.path.abspath("./")
|
|
1085
|
subtitle += "Working directory: %s\n" %os.path.abspath("./")
|
|
1086
|
subtitle += "Configuration file: %s\n" %self.filename
|
|
1086
|
subtitle += "Configuration file: %s\n" %self.filename
|
|
1087
|
subtitle += "Time: %s\n" %str(datetime.datetime.now())
|
|
1087
|
subtitle += "Time: %s\n" %str(datetime.datetime.now())
|
|
1088
|
|
|
1088
|
|
|
1089
|
readUnitConfObj = self.getReadUnitObj()
|
|
1089
|
readUnitConfObj = self.getReadUnitObj()
|
|
1090
|
if readUnitConfObj:
|
|
1090
|
if readUnitConfObj:
|
|
1091
|
subtitle += "\nInput parameters:\n"
|
|
1091
|
subtitle += "\nInput parameters:\n"
|
|
1092
|
subtitle += "[Data path = %s]\n" %readUnitConfObj.path
|
|
1092
|
subtitle += "[Data path = %s]\n" %readUnitConfObj.path
|
|
1093
|
subtitle += "[Data type = %s]\n" %readUnitConfObj.datatype
|
|
1093
|
subtitle += "[Data type = %s]\n" %readUnitConfObj.datatype
|
|
1094
|
subtitle += "[Start date = %s]\n" %readUnitConfObj.startDate
|
|
1094
|
subtitle += "[Start date = %s]\n" %readUnitConfObj.startDate
|
|
1095
|
subtitle += "[End date = %s]\n" %readUnitConfObj.endDate
|
|
1095
|
subtitle += "[End date = %s]\n" %readUnitConfObj.endDate
|
|
1096
|
subtitle += "[Start time = %s]\n" %readUnitConfObj.startTime
|
|
1096
|
subtitle += "[Start time = %s]\n" %readUnitConfObj.startTime
|
|
1097
|
subtitle += "[End time = %s]\n" %readUnitConfObj.endTime
|
|
1097
|
subtitle += "[End time = %s]\n" %readUnitConfObj.endTime
|
|
1098
|
|
|
1098
|
|
|
1099
|
message = "".join(err)
|
|
1099
|
message = "".join(err)
|
|
1100
|
|
|
1100
|
|
|
1101
|
sys.stderr.write(message)
|
|
1101
|
sys.stderr.write(message)
|
|
1102
|
|
|
1102
|
|
|
1103
|
adminObj = schainpy.admin.SchainNotify()
|
|
1103
|
adminObj = schainpy.admin.SchainNotify()
|
|
1104
|
adminObj.sendAlert(message=message,
|
|
1104
|
adminObj.sendAlert(message=message,
|
|
1105
|
subject=subject,
|
|
1105
|
subject=subject,
|
|
1106
|
subtitle=subtitle,
|
|
1106
|
subtitle=subtitle,
|
|
1107
|
filename=self.filename)
|
|
1107
|
filename=self.filename)
|
|
1108
|
|
|
1108
|
|
|
1109
|
def isPaused(self):
|
|
1109
|
def isPaused(self):
|
|
1110
|
return 0
|
|
1110
|
return 0
|
|
1111
|
|
|
1111
|
|
|
1112
|
def isStopped(self):
|
|
1112
|
def isStopped(self):
|
|
1113
|
return 0
|
|
1113
|
return 0
|
|
1114
|
|
|
1114
|
|
|
1115
|
def runController(self):
|
|
1115
|
def runController(self):
|
|
1116
|
"""
|
|
1116
|
"""
|
|
1117
|
returns 0 when this process has been stopped, 1 otherwise
|
|
1117
|
returns 0 when this process has been stopped, 1 otherwise
|
|
1118
|
"""
|
|
1118
|
"""
|
|
1119
|
|
|
1119
|
|
|
1120
|
if self.isPaused():
|
|
1120
|
if self.isPaused():
|
|
1121
|
print "Process suspended"
|
|
1121
|
print "Process suspended"
|
|
1122
|
|
|
1122
|
|
|
1123
|
while True:
|
|
1123
|
while True:
|
|
1124
|
sleep(0.1)
|
|
1124
|
sleep(0.1)
|
|
1125
|
|
|
1125
|
|
|
1126
|
if not self.isPaused():
|
|
1126
|
if not self.isPaused():
|
|
1127
|
break
|
|
1127
|
break
|
|
1128
|
|
|
1128
|
|
|
1129
|
if self.isStopped():
|
|
1129
|
if self.isStopped():
|
|
1130
|
break
|
|
1130
|
break
|
|
1131
|
|
|
1131
|
|
|
1132
|
print "Process reinitialized"
|
|
1132
|
print "Process reinitialized"
|
|
1133
|
|
|
1133
|
|
|
1134
|
if self.isStopped():
|
|
1134
|
if self.isStopped():
|
|
1135
|
print "Process stopped"
|
|
1135
|
print "Process stopped"
|
|
1136
|
return 0
|
|
1136
|
return 0
|
|
1137
|
|
|
1137
|
|
|
1138
|
return 1
|
|
1138
|
return 1
|
|
1139
|
|
|
1139
|
|
|
1140
|
def setFilename(self, filename):
|
|
1140
|
def setFilename(self, filename):
|
|
1141
|
|
|
1141
|
|
|
1142
|
self.filename = filename
|
|
1142
|
self.filename = filename
|
|
1143
|
|
|
1143
|
|
|
1144
|
def setPlotterQueue(self, plotter_queue):
|
|
1144
|
def setPlotterQueue(self, plotter_queue):
|
|
1145
|
|
|
1145
|
|
|
1146
|
self.__plotterQueue = plotter_queue
|
|
1146
|
raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class"
|
|
1147
|
|
|
1147
|
|
|
1148
|
def getPlotterQueue(self):
|
|
1148
|
def getPlotterQueue(self):
|
|
1149
|
|
|
1149
|
|
|
1150
|
return self.__plotterQueue
|
|
1150
|
raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class"
|
|
1151
|
|
|
1151
|
|
|
1152
|
def useExternalPlotManager(self):
|
|
1152
|
def useExternalPlotter(self):
|
|
1153
|
|
|
|
|
|
1154
|
plotterList = ['Scope',
|
|
|
|
|
1155
|
'SpectraPlot', 'RTIPlot',
|
|
|
|
|
1156
|
'CrossSpectraPlot', 'CoherenceMap',
|
|
|
|
|
1157
|
'PowerProfilePlot', 'Noise', 'BeaconPhase',
|
|
|
|
|
1158
|
'CorrelationPlot',
|
|
|
|
|
1159
|
'SpectraHeisScope','RTIfromSpectraHeis']
|
|
|
|
|
1160
|
|
|
1153
|
|
|
1161
|
for thisPUConfObj in self.procUnitConfObjDict.values():
|
|
1154
|
raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class"
|
|
1162
|
|
|
|
|
|
1163
|
inputId = thisPUConfObj.getInputId()
|
|
|
|
|
1164
|
|
|
|
|
|
1165
|
if int(inputId) == 0:
|
|
|
|
|
1166
|
continue
|
|
|
|
|
1167
|
|
|
|
|
|
1168
|
for thisOpObj in thisPUConfObj.getOperationObjList():
|
|
|
|
|
1169
|
|
|
|
|
|
1170
|
if thisOpObj.type == "self":
|
|
|
|
|
1171
|
continue
|
|
|
|
|
1172
|
|
|
|
|
|
1173
|
if thisOpObj.name in plotterList:
|
|
|
|
|
1174
|
thisOpObj.type = "plotter"
|
|
|
|
|
1175
|
|
|
1155
|
|
|
1176
|
def run(self):
|
|
1156
|
def run(self):
|
|
1177
|
|
|
1157
|
|
|
1178
|
print
|
|
1158
|
print
|
|
1179
|
print "*"*60
|
|
1159
|
print "*"*60
|
|
1180
|
print " Starting SIGNAL CHAIN PROCESSING v%s " %schainpy.__version__
|
|
1160
|
print " Starting SIGNAL CHAIN PROCESSING v%s " %schainpy.__version__
|
|
1181
|
print "*"*60
|
|
1161
|
print "*"*60
|
|
1182
|
print
|
|
1162
|
print
|
|
1183
|
|
|
1163
|
|
|
1184
|
keyList = self.procUnitConfObjDict.keys()
|
|
1164
|
keyList = self.procUnitConfObjDict.keys()
|
|
1185
|
keyList.sort()
|
|
1165
|
keyList.sort()
|
|
1186
|
|
|
1166
|
|
|
1187
|
while(True):
|
|
1167
|
while(True):
|
|
1188
|
|
|
1168
|
|
|
1189
|
is_ok = False
|
|
1169
|
is_ok = False
|
|
1190
|
|
|
1170
|
|
|
1191
|
for procKey in keyList:
|
|
1171
|
for procKey in keyList:
|
|
1192
|
# print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id)
|
|
1172
|
# print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id)
|
|
1193
|
|
|
1173
|
|
|
1194
|
procUnitConfObj = self.procUnitConfObjDict[procKey]
|
|
1174
|
procUnitConfObj = self.procUnitConfObjDict[procKey]
|
|
1195
|
|
|
1175
|
|
|
1196
|
try:
|
|
1176
|
try:
|
|
1197
|
sts = procUnitConfObj.run()
|
|
1177
|
sts = procUnitConfObj.run()
|
|
1198
|
is_ok = is_ok or sts
|
|
1178
|
is_ok = is_ok or sts
|
|
1199
|
except ValueError, e:
|
|
1179
|
except ValueError, e:
|
|
1200
|
print "***** Error occurred in %s *****" %(procUnitConfObj.name)
|
|
1180
|
print "***** Error occurred in %s *****" %(procUnitConfObj.name)
|
|
1201
|
sleep(0.5)
|
|
1181
|
sleep(0.5)
|
|
1202
|
print e
|
|
1182
|
print e
|
|
1203
|
is_ok = False
|
|
1183
|
is_ok = False
|
|
1204
|
break
|
|
1184
|
break
|
|
1205
|
except:
|
|
1185
|
except:
|
|
1206
|
print "***** Error occurred in %s *****" %(procUnitConfObj.name)
|
|
1186
|
print "***** Error occurred in %s *****" %(procUnitConfObj.name)
|
|
1207
|
sleep(0.5)
|
|
1187
|
sleep(0.5)
|
|
1208
|
self.__handleError(procUnitConfObj)
|
|
1188
|
self.__handleError(procUnitConfObj)
|
|
1209
|
is_ok = False
|
|
1189
|
is_ok = False
|
|
1210
|
break
|
|
1190
|
break
|
|
1211
|
|
|
1191
|
|
|
1212
|
#If every process unit finished so end process
|
|
1192
|
#If every process unit finished so end process
|
|
1213
|
if not(is_ok):
|
|
1193
|
if not(is_ok):
|
|
1214
|
print "Every process unit have finished"
|
|
1194
|
print "Every process unit have finished"
|
|
1215
|
break
|
|
1195
|
break
|
|
1216
|
|
|
1196
|
|
|
1217
|
if not self.runController():
|
|
1197
|
if not self.runController():
|
|
1218
|
break
|
|
1198
|
break
|
|
1219
|
|
|
1199
|
|
|
1220
|
#Closing every process
|
|
1200
|
#Closing every process
|
|
1221
|
for procKey in keyList:
|
|
1201
|
for procKey in keyList:
|
|
1222
|
procUnitConfObj = self.procUnitConfObjDict[procKey]
|
|
1202
|
procUnitConfObj = self.procUnitConfObjDict[procKey]
|
|
1223
|
procUnitConfObj.close()
|
|
1203
|
procUnitConfObj.close()
|
|
1224
|
|
|
1204
|
|
|
1225
|
print "Process finished"
|
|
1205
|
print "Process finished"
|
|
1226
|
|
|
1206
|
|
|
1227
|
def start(self):
|
|
1207
|
def start(self):
|
|
1228
|
|
|
1208
|
|
|
1229
|
self.writeXml()
|
|
1209
|
self.writeXml()
|
|
1230
|
|
|
1210
|
|
|
1231
|
self.createObjects()
|
|
1211
|
self.createObjects()
|
|
1232
|
self.connectObjects()
|
|
1212
|
self.connectObjects()
|
|
1233
|
self.run()
|
|
1213
|
self.run()
|
|
1234
|
|
|
1214
|
|
|
1235
|
if __name__ == '__main__':
|
|
1215
|
if __name__ == '__main__':
|
|
1236
|
|
|
1216
|
|
|
1237
|
desc = "Segundo Test"
|
|
1217
|
desc = "Segundo Test"
|
|
1238
|
filename = "schain.xml"
|
|
1218
|
filename = "schain.xml"
|
|
1239
|
|
|
1219
|
|
|
1240
|
controllerObj = Project()
|
|
1220
|
controllerObj = Project()
|
|
1241
|
|
|
1221
|
|
|
1242
|
controllerObj.setup(id = '191', name='test01', description=desc)
|
|
1222
|
controllerObj.setup(id = '191', name='test01', description=desc)
|
|
1243
|
|
|
1223
|
|
|
1244
|
readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage',
|
|
1224
|
readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage',
|
|
1245
|
path='data/rawdata/',
|
|
1225
|
path='data/rawdata/',
|
|
1246
|
startDate='2011/01/01',
|
|
1226
|
startDate='2011/01/01',
|
|
1247
|
endDate='2012/12/31',
|
|
1227
|
endDate='2012/12/31',
|
|
1248
|
startTime='00:00:00',
|
|
1228
|
startTime='00:00:00',
|
|
1249
|
endTime='23:59:59',
|
|
1229
|
endTime='23:59:59',
|
|
1250
|
online=1,
|
|
1230
|
online=1,
|
|
1251
|
walk=1)
|
|
1231
|
walk=1)
|
|
1252
|
|
|
1232
|
|
|
1253
|
procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId())
|
|
1233
|
procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId())
|
|
1254
|
|
|
1234
|
|
|
1255
|
opObj10 = procUnitConfObj0.addOperation(name='selectChannels')
|
|
1235
|
opObj10 = procUnitConfObj0.addOperation(name='selectChannels')
|
|
1256
|
opObj10.addParameter(name='channelList', value='3,4,5', format='intlist')
|
|
1236
|
opObj10.addParameter(name='channelList', value='3,4,5', format='intlist')
|
|
1257
|
|
|
1237
|
|
|
1258
|
opObj10 = procUnitConfObj0.addOperation(name='selectHeights')
|
|
1238
|
opObj10 = procUnitConfObj0.addOperation(name='selectHeights')
|
|
1259
|
opObj10.addParameter(name='minHei', value='90', format='float')
|
|
1239
|
opObj10.addParameter(name='minHei', value='90', format='float')
|
|
1260
|
opObj10.addParameter(name='maxHei', value='180', format='float')
|
|
1240
|
opObj10.addParameter(name='maxHei', value='180', format='float')
|
|
1261
|
|
|
1241
|
|
|
1262
|
opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='external')
|
|
1242
|
opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='external')
|
|
1263
|
opObj12.addParameter(name='n', value='10', format='int')
|
|
1243
|
opObj12.addParameter(name='n', value='10', format='int')
|
|
1264
|
|
|
1244
|
|
|
1265
|
procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId())
|
|
1245
|
procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId())
|
|
1266
|
procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int')
|
|
1246
|
procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int')
|
|
1267
|
# procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='')
|
|
1247
|
# procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='')
|
|
1268
|
|
|
1248
|
|
|
1269
|
|
|
1249
|
|
|
1270
|
opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external')
|
|
1250
|
opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external')
|
|
1271
|
opObj11.addParameter(name='idfigure', value='1', format='int')
|
|
1251
|
opObj11.addParameter(name='idfigure', value='1', format='int')
|
|
1272
|
opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str')
|
|
1252
|
opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str')
|
|
1273
|
opObj11.addParameter(name='zmin', value='40', format='int')
|
|
1253
|
opObj11.addParameter(name='zmin', value='40', format='int')
|
|
1274
|
opObj11.addParameter(name='zmax', value='90', format='int')
|
|
1254
|
opObj11.addParameter(name='zmax', value='90', format='int')
|
|
1275
|
opObj11.addParameter(name='showprofile', value='1', format='int')
|
|
1255
|
opObj11.addParameter(name='showprofile', value='1', format='int')
|
|
1276
|
|
|
1256
|
|
|
1277
|
print "Escribiendo el archivo XML"
|
|
1257
|
print "Escribiendo el archivo XML"
|
|
1278
|
|
|
1258
|
|
|
1279
|
controllerObj.writeXml(filename)
|
|
1259
|
controllerObj.writeXml(filename)
|
|
1280
|
|
|
1260
|
|
|
1281
|
print "Leyendo el archivo XML"
|
|
1261
|
print "Leyendo el archivo XML"
|
|
1282
|
controllerObj.readXml(filename)
|
|
1262
|
controllerObj.readXml(filename)
|
|
1283
|
#controllerObj.printattr()
|
|
1263
|
#controllerObj.printattr()
|
|
1284
|
|
|
1264
|
|
|
1285
|
controllerObj.createObjects()
|
|
1265
|
controllerObj.createObjects()
|
|
1286
|
controllerObj.connectObjects()
|
|
1266
|
controllerObj.connectObjects()
|
|
1287
|
controllerObj.run()
|
|
1267
|
controllerObj.run()
|
|
1288
|
|
|
1268
|
|
|
1289
|
No newline at end of file
|
|
1269
|
|