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