@@ -1,719 +1,736 | |||||
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, ElementTree |
|
5 | from xml.etree.ElementTree import Element, SubElement, ElementTree | |
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 | import sys |
|
9 | import sys | |
10 | import datetime |
|
10 | import datetime | |
11 | from model.jrodataIO import * |
|
11 | from model.jrodataIO import * | |
12 | from model.jroprocessing import * |
|
12 | from model.jroprocessing import * | |
13 | from model.jroplot import * |
|
13 | from model.jroplot import * | |
14 |
|
14 | |||
15 | def prettify(elem): |
|
15 | def prettify(elem): | |
16 | """Return a pretty-printed XML string for the Element. |
|
16 | """Return a pretty-printed XML string for the Element. | |
17 | """ |
|
17 | """ | |
18 | rough_string = ET.tostring(elem, 'utf-8') |
|
18 | rough_string = ET.tostring(elem, 'utf-8') | |
19 | reparsed = minidom.parseString(rough_string) |
|
19 | reparsed = minidom.parseString(rough_string) | |
20 | return reparsed.toprettyxml(indent=" ") |
|
20 | return reparsed.toprettyxml(indent=" ") | |
21 |
|
21 | |||
22 | class ParameterConf(): |
|
22 | class ParameterConf(): | |
23 |
|
23 | |||
24 | id = None |
|
24 | id = None | |
25 | name = None |
|
25 | name = None | |
26 | value = None |
|
26 | value = None | |
27 | format = None |
|
27 | format = None | |
28 |
|
28 | |||
29 | ELEMENTNAME = 'Parameter' |
|
29 | ELEMENTNAME = 'Parameter' | |
30 |
|
30 | |||
31 | def __init__(self): |
|
31 | def __init__(self): | |
32 |
|
32 | |||
33 | self.format = 'str' |
|
33 | self.format = 'str' | |
34 |
|
34 | |||
35 | def getElementName(self): |
|
35 | def getElementName(self): | |
36 |
|
36 | |||
37 | return self.ELEMENTNAME |
|
37 | return self.ELEMENTNAME | |
38 |
|
38 | |||
39 | def getValue(self): |
|
39 | def getValue(self): | |
40 |
|
40 | |||
41 | value = self.value |
|
41 | value = self.value | |
42 |
|
42 | |||
43 | if self.format == 'list': |
|
43 | if self.format == 'list': | |
44 | strList = value.split(',') |
|
44 | strList = value.split(',') | |
45 | return strList |
|
45 | return strList | |
46 |
|
46 | |||
47 | if self.format == 'intlist': |
|
47 | if self.format == 'intlist': | |
48 | strList = value.split(',') |
|
48 | strList = value.split(',') | |
49 | intList = [int(x) for x in strList] |
|
49 | intList = [int(x) for x in strList] | |
50 | return intList |
|
50 | return intList | |
51 |
|
51 | |||
52 | if self.format == 'floatlist': |
|
52 | if self.format == 'floatlist': | |
53 | strList = value.split(',') |
|
53 | strList = value.split(',') | |
54 | floatList = [float(x) for x in strList] |
|
54 | floatList = [float(x) for x in strList] | |
55 | return floatList |
|
55 | return floatList | |
56 |
|
56 | |||
57 | if self.format == 'date': |
|
57 | if self.format == 'date': | |
58 | strList = value.split('/') |
|
58 | strList = value.split('/') | |
59 | intList = [int(x) for x in strList] |
|
59 | intList = [int(x) for x in strList] | |
60 | date = datetime.date(intList[0], intList[1], intList[2]) |
|
60 | date = datetime.date(intList[0], intList[1], intList[2]) | |
61 | return date |
|
61 | return date | |
62 |
|
62 | |||
63 | if self.format == 'time': |
|
63 | if self.format == 'time': | |
64 | strList = value.split(':') |
|
64 | strList = value.split(':') | |
65 | intList = [int(x) for x in strList] |
|
65 | intList = [int(x) for x in strList] | |
66 | time = datetime.time(intList[0], intList[1], intList[2]) |
|
66 | time = datetime.time(intList[0], intList[1], intList[2]) | |
67 | return time |
|
67 | return time | |
68 |
|
68 | |||
69 | if self.format == 'bool': |
|
69 | if self.format == 'bool': | |
70 | value = int(value) |
|
70 | value = int(value) | |
71 |
|
71 | |||
|
72 | if self.format == 'pairslist': | |||
|
73 | """ | |||
|
74 | Example: | |||
|
75 | value = (0,1),(1,2) | |||
|
76 | """ | |||
|
77 | ||||
|
78 | value = value.replace('(', '') | |||
|
79 | value = value.replace(')', '') | |||
|
80 | ||||
|
81 | strList = value.split(',') | |||
|
82 | intList = [int(item) for item in strList] | |||
|
83 | pairList = [] | |||
|
84 | for i in range(len(intList)/2): | |||
|
85 | pairList.append((intList[i*2], intList[i*2 + 1])) | |||
|
86 | ||||
|
87 | return pairList | |||
|
88 | ||||
72 | func = eval(self.format) |
|
89 | func = eval(self.format) | |
73 |
|
90 | |||
74 | return func(value) |
|
91 | return func(value) | |
75 |
|
92 | |||
76 | def setup(self, id, name, value, format='str'): |
|
93 | def setup(self, id, name, value, format='str'): | |
77 |
|
94 | |||
78 | self.id = id |
|
95 | self.id = id | |
79 | self.name = name |
|
96 | self.name = name | |
80 | self.value = str(value) |
|
97 | self.value = str(value) | |
81 | self.format = format |
|
98 | self.format = format | |
82 |
|
99 | |||
83 | def makeXml(self, opElement): |
|
100 | def makeXml(self, opElement): | |
84 |
|
101 | |||
85 | parmElement = SubElement(opElement, self.ELEMENTNAME) |
|
102 | parmElement = SubElement(opElement, self.ELEMENTNAME) | |
86 | parmElement.set('id', str(self.id)) |
|
103 | parmElement.set('id', str(self.id)) | |
87 | parmElement.set('name', self.name) |
|
104 | parmElement.set('name', self.name) | |
88 | parmElement.set('value', self.value) |
|
105 | parmElement.set('value', self.value) | |
89 | parmElement.set('format', self.format) |
|
106 | parmElement.set('format', self.format) | |
90 |
|
107 | |||
91 | def readXml(self, parmElement): |
|
108 | def readXml(self, parmElement): | |
92 |
|
109 | |||
93 | self.id = parmElement.get('id') |
|
110 | self.id = parmElement.get('id') | |
94 | self.name = parmElement.get('name') |
|
111 | self.name = parmElement.get('name') | |
95 | self.value = parmElement.get('value') |
|
112 | self.value = parmElement.get('value') | |
96 | self.format = parmElement.get('format') |
|
113 | self.format = parmElement.get('format') | |
97 |
|
114 | |||
98 | def printattr(self): |
|
115 | def printattr(self): | |
99 |
|
116 | |||
100 | print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format) |
|
117 | print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format) | |
101 |
|
118 | |||
102 | class OperationConf(): |
|
119 | class OperationConf(): | |
103 |
|
120 | |||
104 | id = None |
|
121 | id = None | |
105 | name = None |
|
122 | name = None | |
106 | priority = None |
|
123 | priority = None | |
107 | type = None |
|
124 | type = None | |
108 |
|
125 | |||
109 | parmConfObjList = [] |
|
126 | parmConfObjList = [] | |
110 |
|
127 | |||
111 | ELEMENTNAME = 'Operation' |
|
128 | ELEMENTNAME = 'Operation' | |
112 |
|
129 | |||
113 | def __init__(self): |
|
130 | def __init__(self): | |
114 |
|
131 | |||
115 | id = 0 |
|
132 | id = 0 | |
116 | name = None |
|
133 | name = None | |
117 | priority = None |
|
134 | priority = None | |
118 | type = 'self' |
|
135 | type = 'self' | |
119 |
|
136 | |||
120 |
|
137 | |||
121 | def __getNewId(self): |
|
138 | def __getNewId(self): | |
122 |
|
139 | |||
123 | return int(self.id)*10 + len(self.parmConfObjList) + 1 |
|
140 | return int(self.id)*10 + len(self.parmConfObjList) + 1 | |
124 |
|
141 | |||
125 | def getElementName(self): |
|
142 | def getElementName(self): | |
126 |
|
143 | |||
127 | return self.ELEMENTNAME |
|
144 | return self.ELEMENTNAME | |
128 |
|
145 | |||
129 | def getParameterObjList(self): |
|
146 | def getParameterObjList(self): | |
130 |
|
147 | |||
131 | return self.parmConfObjList |
|
148 | return self.parmConfObjList | |
132 |
|
149 | |||
133 | def setup(self, id, name, priority, type): |
|
150 | def setup(self, id, name, priority, type): | |
134 |
|
151 | |||
135 | self.id = id |
|
152 | self.id = id | |
136 | self.name = name |
|
153 | self.name = name | |
137 | self.type = type |
|
154 | self.type = type | |
138 | self.priority = priority |
|
155 | self.priority = priority | |
139 |
|
156 | |||
140 | self.parmConfObjList = [] |
|
157 | self.parmConfObjList = [] | |
141 |
|
158 | |||
142 | def addParameter(self, name, value, format='str'): |
|
159 | def addParameter(self, name, value, format='str'): | |
143 |
|
160 | |||
144 | id = self.__getNewId() |
|
161 | id = self.__getNewId() | |
145 |
|
162 | |||
146 | parmConfObj = ParameterConf() |
|
163 | parmConfObj = ParameterConf() | |
147 | parmConfObj.setup(id, name, value, format) |
|
164 | parmConfObj.setup(id, name, value, format) | |
148 |
|
165 | |||
149 | self.parmConfObjList.append(parmConfObj) |
|
166 | self.parmConfObjList.append(parmConfObj) | |
150 |
|
167 | |||
151 | return parmConfObj |
|
168 | return parmConfObj | |
152 |
|
169 | |||
153 | def makeXml(self, upElement): |
|
170 | def makeXml(self, upElement): | |
154 |
|
171 | |||
155 | opElement = SubElement(upElement, self.ELEMENTNAME) |
|
172 | opElement = SubElement(upElement, self.ELEMENTNAME) | |
156 | opElement.set('id', str(self.id)) |
|
173 | opElement.set('id', str(self.id)) | |
157 | opElement.set('name', self.name) |
|
174 | opElement.set('name', self.name) | |
158 | opElement.set('type', self.type) |
|
175 | opElement.set('type', self.type) | |
159 | opElement.set('priority', str(self.priority)) |
|
176 | opElement.set('priority', str(self.priority)) | |
160 |
|
177 | |||
161 | for parmConfObj in self.parmConfObjList: |
|
178 | for parmConfObj in self.parmConfObjList: | |
162 | parmConfObj.makeXml(opElement) |
|
179 | parmConfObj.makeXml(opElement) | |
163 |
|
180 | |||
164 | def readXml(self, opElement): |
|
181 | def readXml(self, opElement): | |
165 |
|
182 | |||
166 | self.id = opElement.get('id') |
|
183 | self.id = opElement.get('id') | |
167 | self.name = opElement.get('name') |
|
184 | self.name = opElement.get('name') | |
168 | self.type = opElement.get('type') |
|
185 | self.type = opElement.get('type') | |
169 | self.priority = opElement.get('priority') |
|
186 | self.priority = opElement.get('priority') | |
170 |
|
187 | |||
171 | self.parmConfObjList = [] |
|
188 | self.parmConfObjList = [] | |
172 |
|
189 | |||
173 | parmElementList = opElement.getiterator(ParameterConf().getElementName()) |
|
190 | parmElementList = opElement.getiterator(ParameterConf().getElementName()) | |
174 |
|
191 | |||
175 | for parmElement in parmElementList: |
|
192 | for parmElement in parmElementList: | |
176 | parmConfObj = ParameterConf() |
|
193 | parmConfObj = ParameterConf() | |
177 | parmConfObj.readXml(parmElement) |
|
194 | parmConfObj.readXml(parmElement) | |
178 | self.parmConfObjList.append(parmConfObj) |
|
195 | self.parmConfObjList.append(parmConfObj) | |
179 |
|
196 | |||
180 | def printattr(self): |
|
197 | def printattr(self): | |
181 |
|
198 | |||
182 | print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME, |
|
199 | print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME, | |
183 | self.id, |
|
200 | self.id, | |
184 | self.name, |
|
201 | self.name, | |
185 | self.type, |
|
202 | self.type, | |
186 | self.priority) |
|
203 | self.priority) | |
187 |
|
204 | |||
188 | for parmConfObj in self.parmConfObjList: |
|
205 | for parmConfObj in self.parmConfObjList: | |
189 | parmConfObj.printattr() |
|
206 | parmConfObj.printattr() | |
190 |
|
207 | |||
191 | def createObject(self): |
|
208 | def createObject(self): | |
192 |
|
209 | |||
193 | if self.type == 'self': |
|
210 | if self.type == 'self': | |
194 | raise ValueError, "This operation type cannot be created" |
|
211 | raise ValueError, "This operation type cannot be created" | |
195 |
|
212 | |||
196 | if self.type == 'other': |
|
213 | if self.type == 'other': | |
197 | className = eval(self.name) |
|
214 | className = eval(self.name) | |
198 | opObj = className() |
|
215 | opObj = className() | |
199 |
|
216 | |||
200 | return opObj |
|
217 | return opObj | |
201 |
|
218 | |||
202 | class ProcUnitConf(): |
|
219 | class ProcUnitConf(): | |
203 |
|
220 | |||
204 | id = None |
|
221 | id = None | |
205 | name = None |
|
222 | name = None | |
206 | datatype = None |
|
223 | datatype = None | |
207 | inputId = None |
|
224 | inputId = None | |
208 |
|
225 | |||
209 | opConfObjList = [] |
|
226 | opConfObjList = [] | |
210 |
|
227 | |||
211 | procUnitObj = None |
|
228 | procUnitObj = None | |
212 | opObjList = [] |
|
229 | opObjList = [] | |
213 |
|
230 | |||
214 | ELEMENTNAME = 'ProcUnit' |
|
231 | ELEMENTNAME = 'ProcUnit' | |
215 |
|
232 | |||
216 | def __init__(self): |
|
233 | def __init__(self): | |
217 |
|
234 | |||
218 | self.id = None |
|
235 | self.id = None | |
219 | self.datatype = None |
|
236 | self.datatype = None | |
220 | self.name = None |
|
237 | self.name = None | |
221 | self.inputId = None |
|
238 | self.inputId = None | |
222 |
|
239 | |||
223 | self.opConfObjList = [] |
|
240 | self.opConfObjList = [] | |
224 |
|
241 | |||
225 | self.procUnitObj = None |
|
242 | self.procUnitObj = None | |
226 | self.opObjDict = {} |
|
243 | self.opObjDict = {} | |
227 |
|
244 | |||
228 | def __getPriority(self): |
|
245 | def __getPriority(self): | |
229 |
|
246 | |||
230 | return len(self.opConfObjList)+1 |
|
247 | return len(self.opConfObjList)+1 | |
231 |
|
248 | |||
232 | def __getNewId(self): |
|
249 | def __getNewId(self): | |
233 |
|
250 | |||
234 | return int(self.id)*10 + len(self.opConfObjList) + 1 |
|
251 | return int(self.id)*10 + len(self.opConfObjList) + 1 | |
235 |
|
252 | |||
236 | def getElementName(self): |
|
253 | def getElementName(self): | |
237 |
|
254 | |||
238 | return self.ELEMENTNAME |
|
255 | return self.ELEMENTNAME | |
239 |
|
256 | |||
240 | def getId(self): |
|
257 | def getId(self): | |
241 |
|
258 | |||
242 | return str(self.id) |
|
259 | return str(self.id) | |
243 |
|
260 | |||
244 | def getInputId(self): |
|
261 | def getInputId(self): | |
245 |
|
262 | |||
246 | return str(self.inputId) |
|
263 | return str(self.inputId) | |
247 |
|
264 | |||
248 | def getOperationObjList(self): |
|
265 | def getOperationObjList(self): | |
249 |
|
266 | |||
250 | return self.opConfObjList |
|
267 | return self.opConfObjList | |
251 |
|
268 | |||
252 | def getProcUnitObj(self): |
|
269 | def getProcUnitObj(self): | |
253 |
|
270 | |||
254 | return self.procUnitObj |
|
271 | return self.procUnitObj | |
255 |
|
272 | |||
256 | def setup(self, id, name, datatype, inputId): |
|
273 | def setup(self, id, name, datatype, inputId): | |
257 |
|
274 | |||
258 | self.id = id |
|
275 | self.id = id | |
259 | self.name = name |
|
276 | self.name = name | |
260 | self.datatype = datatype |
|
277 | self.datatype = datatype | |
261 | self.inputId = inputId |
|
278 | self.inputId = inputId | |
262 |
|
279 | |||
263 | self.opConfObjList = [] |
|
280 | self.opConfObjList = [] | |
264 |
|
281 | |||
265 | self.addOperation(name='init', optype='self') |
|
282 | self.addOperation(name='init', optype='self') | |
266 |
|
283 | |||
267 | def addParameter(self, **kwargs): |
|
284 | def addParameter(self, **kwargs): | |
268 |
|
285 | |||
269 | opObj = self.opConfObjList[0] |
|
286 | opObj = self.opConfObjList[0] | |
270 |
|
287 | |||
271 | opObj.addParameter(**kwargs) |
|
288 | opObj.addParameter(**kwargs) | |
272 |
|
289 | |||
273 | return opObj |
|
290 | return opObj | |
274 |
|
291 | |||
275 | def addOperation(self, name, optype='self'): |
|
292 | def addOperation(self, name, optype='self'): | |
276 |
|
293 | |||
277 | id = self.__getNewId() |
|
294 | id = self.__getNewId() | |
278 | priority = self.__getPriority() |
|
295 | priority = self.__getPriority() | |
279 |
|
296 | |||
280 | opConfObj = OperationConf() |
|
297 | opConfObj = OperationConf() | |
281 | opConfObj.setup(id, name=name, priority=priority, type=optype) |
|
298 | opConfObj.setup(id, name=name, priority=priority, type=optype) | |
282 |
|
299 | |||
283 | self.opConfObjList.append(opConfObj) |
|
300 | self.opConfObjList.append(opConfObj) | |
284 |
|
301 | |||
285 | return opConfObj |
|
302 | return opConfObj | |
286 |
|
303 | |||
287 | def makeXml(self, procUnitElement): |
|
304 | def makeXml(self, procUnitElement): | |
288 |
|
305 | |||
289 | upElement = SubElement(procUnitElement, self.ELEMENTNAME) |
|
306 | upElement = SubElement(procUnitElement, self.ELEMENTNAME) | |
290 | upElement.set('id', str(self.id)) |
|
307 | upElement.set('id', str(self.id)) | |
291 | upElement.set('name', self.name) |
|
308 | upElement.set('name', self.name) | |
292 | upElement.set('datatype', self.datatype) |
|
309 | upElement.set('datatype', self.datatype) | |
293 | upElement.set('inputId', str(self.inputId)) |
|
310 | upElement.set('inputId', str(self.inputId)) | |
294 |
|
311 | |||
295 | for opConfObj in self.opConfObjList: |
|
312 | for opConfObj in self.opConfObjList: | |
296 | opConfObj.makeXml(upElement) |
|
313 | opConfObj.makeXml(upElement) | |
297 |
|
314 | |||
298 | def readXml(self, upElement): |
|
315 | def readXml(self, upElement): | |
299 |
|
316 | |||
300 | self.id = upElement.get('id') |
|
317 | self.id = upElement.get('id') | |
301 | self.name = upElement.get('name') |
|
318 | self.name = upElement.get('name') | |
302 | self.datatype = upElement.get('datatype') |
|
319 | self.datatype = upElement.get('datatype') | |
303 | self.inputId = upElement.get('inputId') |
|
320 | self.inputId = upElement.get('inputId') | |
304 |
|
321 | |||
305 | self.opConfObjList = [] |
|
322 | self.opConfObjList = [] | |
306 |
|
323 | |||
307 | opElementList = upElement.getiterator(OperationConf().getElementName()) |
|
324 | opElementList = upElement.getiterator(OperationConf().getElementName()) | |
308 |
|
325 | |||
309 | for opElement in opElementList: |
|
326 | for opElement in opElementList: | |
310 | opConfObj = OperationConf() |
|
327 | opConfObj = OperationConf() | |
311 | opConfObj.readXml(opElement) |
|
328 | opConfObj.readXml(opElement) | |
312 | self.opConfObjList.append(opConfObj) |
|
329 | self.opConfObjList.append(opConfObj) | |
313 |
|
330 | |||
314 | def printattr(self): |
|
331 | def printattr(self): | |
315 |
|
332 | |||
316 | print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME, |
|
333 | print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME, | |
317 | self.id, |
|
334 | self.id, | |
318 | self.name, |
|
335 | self.name, | |
319 | self.datatype, |
|
336 | self.datatype, | |
320 | self.inputId) |
|
337 | self.inputId) | |
321 |
|
338 | |||
322 | for opConfObj in self.opConfObjList: |
|
339 | for opConfObj in self.opConfObjList: | |
323 | opConfObj.printattr() |
|
340 | opConfObj.printattr() | |
324 |
|
341 | |||
325 | def createObjects(self): |
|
342 | def createObjects(self): | |
326 |
|
343 | |||
327 | className = eval(self.name) |
|
344 | className = eval(self.name) | |
328 | procUnitObj = className() |
|
345 | procUnitObj = className() | |
329 |
|
346 | |||
330 | for opConfObj in self.opConfObjList: |
|
347 | for opConfObj in self.opConfObjList: | |
331 |
|
348 | |||
332 | if opConfObj.type == 'self': |
|
349 | if opConfObj.type == 'self': | |
333 | continue |
|
350 | continue | |
334 |
|
351 | |||
335 | opObj = opConfObj.createObject() |
|
352 | opObj = opConfObj.createObject() | |
336 |
|
353 | |||
337 | self.opObjDict[opConfObj.id] = opObj |
|
354 | self.opObjDict[opConfObj.id] = opObj | |
338 | procUnitObj.addOperation(opObj, opConfObj.id) |
|
355 | procUnitObj.addOperation(opObj, opConfObj.id) | |
339 |
|
356 | |||
340 | self.procUnitObj = procUnitObj |
|
357 | self.procUnitObj = procUnitObj | |
341 |
|
358 | |||
342 | return procUnitObj |
|
359 | return procUnitObj | |
343 |
|
360 | |||
344 | def run(self): |
|
361 | def run(self): | |
345 |
|
362 | |||
346 | finalSts = False |
|
363 | finalSts = False | |
347 |
|
364 | |||
348 | for opConfObj in self.opConfObjList: |
|
365 | for opConfObj in self.opConfObjList: | |
349 |
|
366 | |||
350 | kwargs = {} |
|
367 | kwargs = {} | |
351 | for parmConfObj in opConfObj.getParameterObjList(): |
|
368 | for parmConfObj in opConfObj.getParameterObjList(): | |
352 | kwargs[parmConfObj.name] = parmConfObj.getValue() |
|
369 | kwargs[parmConfObj.name] = parmConfObj.getValue() | |
353 |
|
370 | |||
354 | #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id) |
|
371 | #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id) | |
355 | sts = self.procUnitObj.call(opConfObj, **kwargs) |
|
372 | sts = self.procUnitObj.call(opConfObj, **kwargs) | |
356 | finalSts = finalSts or sts |
|
373 | finalSts = finalSts or sts | |
357 |
|
374 | |||
358 | return finalSts |
|
375 | return finalSts | |
359 |
|
376 | |||
360 | class ReadUnitConf(ProcUnitConf): |
|
377 | class ReadUnitConf(ProcUnitConf): | |
361 |
|
378 | |||
362 | path = None |
|
379 | path = None | |
363 | startDate = None |
|
380 | startDate = None | |
364 | endDate = None |
|
381 | endDate = None | |
365 | startTime = None |
|
382 | startTime = None | |
366 | endTime = None |
|
383 | endTime = None | |
367 |
|
384 | |||
368 | ELEMENTNAME = 'ReadUnit' |
|
385 | ELEMENTNAME = 'ReadUnit' | |
369 |
|
386 | |||
370 | def __init__(self): |
|
387 | def __init__(self): | |
371 |
|
388 | |||
372 | self.id = None |
|
389 | self.id = None | |
373 | self.datatype = None |
|
390 | self.datatype = None | |
374 | self.name = None |
|
391 | self.name = None | |
375 | self.inputId = 0 |
|
392 | self.inputId = 0 | |
376 |
|
393 | |||
377 | self.opConfObjList = [] |
|
394 | self.opConfObjList = [] | |
378 | self.opObjList = [] |
|
395 | self.opObjList = [] | |
379 |
|
396 | |||
380 | def getElementName(self): |
|
397 | def getElementName(self): | |
381 |
|
398 | |||
382 | return self.ELEMENTNAME |
|
399 | return self.ELEMENTNAME | |
383 |
|
400 | |||
384 | def setup(self, id, name, datatype, path, startDate, endDate, startTime, endTime, **kwargs): |
|
401 | def setup(self, id, name, datatype, path, startDate, endDate, startTime, endTime, **kwargs): | |
385 |
|
402 | |||
386 | self.id = id |
|
403 | self.id = id | |
387 | self.name = name |
|
404 | self.name = name | |
388 | self.datatype = datatype |
|
405 | self.datatype = datatype | |
389 |
|
406 | |||
390 | self.path = path |
|
407 | self.path = path | |
391 | self.startDate = startDate |
|
408 | self.startDate = startDate | |
392 | self.endDate = endDate |
|
409 | self.endDate = endDate | |
393 | self.startTime = startTime |
|
410 | self.startTime = startTime | |
394 | self.endTime = endTime |
|
411 | self.endTime = endTime | |
395 |
|
412 | |||
396 | self.addRunOperation(**kwargs) |
|
413 | self.addRunOperation(**kwargs) | |
397 |
|
414 | |||
398 | def addRunOperation(self, **kwargs): |
|
415 | def addRunOperation(self, **kwargs): | |
399 |
|
416 | |||
400 | opObj = self.addOperation(name = 'run', optype = 'self') |
|
417 | opObj = self.addOperation(name = 'run', optype = 'self') | |
401 |
|
418 | |||
402 | opObj.addParameter(name='path' , value=self.path, format='str') |
|
419 | opObj.addParameter(name='path' , value=self.path, format='str') | |
403 | opObj.addParameter(name='startDate' , value=self.startDate, format='date') |
|
420 | opObj.addParameter(name='startDate' , value=self.startDate, format='date') | |
404 | opObj.addParameter(name='endDate' , value=self.endDate, format='date') |
|
421 | opObj.addParameter(name='endDate' , value=self.endDate, format='date') | |
405 | opObj.addParameter(name='startTime' , value=self.startTime, format='time') |
|
422 | opObj.addParameter(name='startTime' , value=self.startTime, format='time') | |
406 | opObj.addParameter(name='endTime' , value=self.endTime, format='time') |
|
423 | opObj.addParameter(name='endTime' , value=self.endTime, format='time') | |
407 |
|
424 | |||
408 | for key, value in kwargs.items(): |
|
425 | for key, value in kwargs.items(): | |
409 | opObj.addParameter(name=key, value=value, format=type(value).__name__) |
|
426 | opObj.addParameter(name=key, value=value, format=type(value).__name__) | |
410 |
|
427 | |||
411 | return opObj |
|
428 | return opObj | |
412 |
|
429 | |||
413 |
|
430 | |||
414 | class Project(): |
|
431 | class Project(): | |
415 |
|
432 | |||
416 | id = None |
|
433 | id = None | |
417 | name = None |
|
434 | name = None | |
418 | description = None |
|
435 | description = None | |
419 | # readUnitConfObjList = None |
|
436 | # readUnitConfObjList = None | |
420 | procUnitConfObjDict = None |
|
437 | procUnitConfObjDict = None | |
421 |
|
438 | |||
422 | ELEMENTNAME = 'Project' |
|
439 | ELEMENTNAME = 'Project' | |
423 |
|
440 | |||
424 | def __init__(self): |
|
441 | def __init__(self): | |
425 |
|
442 | |||
426 | self.id = None |
|
443 | self.id = None | |
427 | self.name = None |
|
444 | self.name = None | |
428 | self.description = None |
|
445 | self.description = None | |
429 |
|
446 | |||
430 | # self.readUnitConfObjList = [] |
|
447 | # self.readUnitConfObjList = [] | |
431 | self.procUnitConfObjDict = {} |
|
448 | self.procUnitConfObjDict = {} | |
432 |
|
449 | |||
433 | def __getNewId(self): |
|
450 | def __getNewId(self): | |
434 |
|
451 | |||
435 | id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1 |
|
452 | id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1 | |
436 |
|
453 | |||
437 | return str(id) |
|
454 | return str(id) | |
438 |
|
455 | |||
439 | def getElementName(self): |
|
456 | def getElementName(self): | |
440 |
|
457 | |||
441 | return self.ELEMENTNAME |
|
458 | return self.ELEMENTNAME | |
442 |
|
459 | |||
443 | def setup(self, id, name, description): |
|
460 | def setup(self, id, name, description): | |
444 |
|
461 | |||
445 | self.id = id |
|
462 | self.id = id | |
446 | self.name = name |
|
463 | self.name = name | |
447 | self.description = description |
|
464 | self.description = description | |
448 |
|
465 | |||
449 | def addReadUnit(self, datatype, path, startDate='', endDate='', startTime='', endTime='', **kwargs): |
|
466 | def addReadUnit(self, datatype, path, startDate='', endDate='', startTime='', endTime='', **kwargs): | |
450 |
|
467 | |||
451 | id = self.__getNewId() |
|
468 | id = self.__getNewId() | |
452 | name = '%sReader' %(datatype) |
|
469 | name = '%sReader' %(datatype) | |
453 |
|
470 | |||
454 | readUnitConfObj = ReadUnitConf() |
|
471 | readUnitConfObj = ReadUnitConf() | |
455 | readUnitConfObj.setup(id, name, datatype, path, startDate, endDate, startTime, endTime, **kwargs) |
|
472 | readUnitConfObj.setup(id, name, datatype, path, startDate, endDate, startTime, endTime, **kwargs) | |
456 |
|
473 | |||
457 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj |
|
474 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj | |
458 |
|
475 | |||
459 | return readUnitConfObj |
|
476 | return readUnitConfObj | |
460 |
|
477 | |||
461 | def addProcUnit(self, datatype, inputId): |
|
478 | def addProcUnit(self, datatype, inputId): | |
462 |
|
479 | |||
463 | id = self.__getNewId() |
|
480 | id = self.__getNewId() | |
464 | name = '%sProc' %(datatype) |
|
481 | name = '%sProc' %(datatype) | |
465 |
|
482 | |||
466 | procUnitConfObj = ProcUnitConf() |
|
483 | procUnitConfObj = ProcUnitConf() | |
467 | procUnitConfObj.setup(id, name, datatype, inputId) |
|
484 | procUnitConfObj.setup(id, name, datatype, inputId) | |
468 |
|
485 | |||
469 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj |
|
486 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj | |
470 |
|
487 | |||
471 | return procUnitConfObj |
|
488 | return procUnitConfObj | |
472 |
|
489 | |||
473 | def makeXml(self): |
|
490 | def makeXml(self): | |
474 |
|
491 | |||
475 | projectElement = Element('Project') |
|
492 | projectElement = Element('Project') | |
476 | projectElement.set('id', str(self.id)) |
|
493 | projectElement.set('id', str(self.id)) | |
477 | projectElement.set('name', self.name) |
|
494 | projectElement.set('name', self.name) | |
478 | projectElement.set('description', self.description) |
|
495 | projectElement.set('description', self.description) | |
479 |
|
496 | |||
480 | # for readUnitConfObj in self.readUnitConfObjList: |
|
497 | # for readUnitConfObj in self.readUnitConfObjList: | |
481 | # readUnitConfObj.makeXml(projectElement) |
|
498 | # readUnitConfObj.makeXml(projectElement) | |
482 |
|
499 | |||
483 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
500 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
484 | procUnitConfObj.makeXml(projectElement) |
|
501 | procUnitConfObj.makeXml(projectElement) | |
485 |
|
502 | |||
486 | self.projectElement = projectElement |
|
503 | self.projectElement = projectElement | |
487 |
|
504 | |||
488 | def writeXml(self, filename): |
|
505 | def writeXml(self, filename): | |
489 |
|
506 | |||
490 | self.makeXml() |
|
507 | self.makeXml() | |
491 |
|
508 | |||
492 | print prettify(self.projectElement) |
|
509 | print prettify(self.projectElement) | |
493 |
|
510 | |||
494 | ElementTree(self.projectElement).write(filename, method='xml') |
|
511 | ElementTree(self.projectElement).write(filename, method='xml') | |
495 |
|
512 | |||
496 | def readXml(self, filename): |
|
513 | def readXml(self, filename): | |
497 |
|
514 | |||
498 | #tree = ET.parse(filename) |
|
515 | #tree = ET.parse(filename) | |
499 | self.projectElement = None |
|
516 | self.projectElement = None | |
500 | # self.readUnitConfObjList = [] |
|
517 | # self.readUnitConfObjList = [] | |
501 | self.procUnitConfObjDict = {} |
|
518 | self.procUnitConfObjDict = {} | |
502 |
|
519 | |||
503 | self.projectElement = ElementTree().parse(filename) |
|
520 | self.projectElement = ElementTree().parse(filename) | |
504 |
|
521 | |||
505 | self.project = self.projectElement.tag |
|
522 | self.project = self.projectElement.tag | |
506 |
|
523 | |||
507 | self.id = self.projectElement.get('id') |
|
524 | self.id = self.projectElement.get('id') | |
508 | self.name = self.projectElement.get('name') |
|
525 | self.name = self.projectElement.get('name') | |
509 | self.description = self.projectElement.get('description') |
|
526 | self.description = self.projectElement.get('description') | |
510 |
|
527 | |||
511 | readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName()) |
|
528 | readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName()) | |
512 |
|
529 | |||
513 | for readUnitElement in readUnitElementList: |
|
530 | for readUnitElement in readUnitElementList: | |
514 | readUnitConfObj = ReadUnitConf() |
|
531 | readUnitConfObj = ReadUnitConf() | |
515 | readUnitConfObj.readXml(readUnitElement) |
|
532 | readUnitConfObj.readXml(readUnitElement) | |
516 |
|
533 | |||
517 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj |
|
534 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj | |
518 |
|
535 | |||
519 | procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName()) |
|
536 | procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName()) | |
520 |
|
537 | |||
521 | for procUnitElement in procUnitElementList: |
|
538 | for procUnitElement in procUnitElementList: | |
522 | procUnitConfObj = ProcUnitConf() |
|
539 | procUnitConfObj = ProcUnitConf() | |
523 | procUnitConfObj.readXml(procUnitElement) |
|
540 | procUnitConfObj.readXml(procUnitElement) | |
524 |
|
541 | |||
525 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj |
|
542 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj | |
526 |
|
543 | |||
527 | def printattr(self): |
|
544 | def printattr(self): | |
528 |
|
545 | |||
529 | print "Project[%s]: name = %s, description = %s" %(self.id, |
|
546 | print "Project[%s]: name = %s, description = %s" %(self.id, | |
530 | self.name, |
|
547 | self.name, | |
531 | self.description) |
|
548 | self.description) | |
532 |
|
549 | |||
533 | # for readUnitConfObj in self.readUnitConfObjList: |
|
550 | # for readUnitConfObj in self.readUnitConfObjList: | |
534 | # readUnitConfObj.printattr() |
|
551 | # readUnitConfObj.printattr() | |
535 |
|
552 | |||
536 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
553 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
537 | procUnitConfObj.printattr() |
|
554 | procUnitConfObj.printattr() | |
538 |
|
555 | |||
539 | def createObjects(self): |
|
556 | def createObjects(self): | |
540 |
|
557 | |||
541 | # for readUnitConfObj in self.readUnitConfObjList: |
|
558 | # for readUnitConfObj in self.readUnitConfObjList: | |
542 | # readUnitConfObj.createObjects() |
|
559 | # readUnitConfObj.createObjects() | |
543 |
|
560 | |||
544 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
561 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
545 | procUnitConfObj.createObjects() |
|
562 | procUnitConfObj.createObjects() | |
546 |
|
563 | |||
547 | def __connect(self, objIN, obj): |
|
564 | def __connect(self, objIN, obj): | |
548 |
|
565 | |||
549 | obj.setInput(objIN.getOutput()) |
|
566 | obj.setInput(objIN.getOutput()) | |
550 |
|
567 | |||
551 | def connectObjects(self): |
|
568 | def connectObjects(self): | |
552 |
|
569 | |||
553 | for puConfObj in self.procUnitConfObjDict.values(): |
|
570 | for puConfObj in self.procUnitConfObjDict.values(): | |
554 |
|
571 | |||
555 | inputId = puConfObj.getInputId() |
|
572 | inputId = puConfObj.getInputId() | |
556 |
|
573 | |||
557 | if int(inputId) == 0: |
|
574 | if int(inputId) == 0: | |
558 | continue |
|
575 | continue | |
559 |
|
576 | |||
560 | puConfINObj = self.procUnitConfObjDict[inputId] |
|
577 | puConfINObj = self.procUnitConfObjDict[inputId] | |
561 |
|
578 | |||
562 | puObj = puConfObj.getProcUnitObj() |
|
579 | puObj = puConfObj.getProcUnitObj() | |
563 | puINObj = puConfINObj.getProcUnitObj() |
|
580 | puINObj = puConfINObj.getProcUnitObj() | |
564 |
|
581 | |||
565 | self.__connect(puINObj, puObj) |
|
582 | self.__connect(puINObj, puObj) | |
566 |
|
583 | |||
567 | def run(self): |
|
584 | def run(self): | |
568 |
|
585 | |||
569 | # for readUnitConfObj in self.readUnitConfObjList: |
|
586 | # for readUnitConfObj in self.readUnitConfObjList: | |
570 | # readUnitConfObj.run() |
|
587 | # readUnitConfObj.run() | |
571 |
|
588 | |||
572 | while(True): |
|
589 | while(True): | |
573 |
|
590 | |||
574 | finalSts = False |
|
591 | finalSts = False | |
575 |
|
592 | |||
576 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
593 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
577 | #print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id) |
|
594 | #print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id) | |
578 | sts = procUnitConfObj.run() |
|
595 | sts = procUnitConfObj.run() | |
579 | finalSts = finalSts or sts |
|
596 | finalSts = finalSts or sts | |
580 |
|
597 | |||
581 | #If every process unit finished so end process |
|
598 | #If every process unit finished so end process | |
582 | if not(finalSts): |
|
599 | if not(finalSts): | |
583 | print "Every process units have finished" |
|
600 | print "Every process units have finished" | |
584 | break |
|
601 | break | |
585 |
|
602 | |||
586 | if __name__ == '__main__': |
|
603 | if __name__ == '__main__': | |
587 |
|
604 | |||
588 | desc = "Segundo Test" |
|
605 | desc = "Segundo Test" | |
589 | filename = "schain.xml" |
|
606 | filename = "schain.xml" | |
590 |
|
607 | |||
591 | controllerObj = Project() |
|
608 | controllerObj = Project() | |
592 |
|
609 | |||
593 | controllerObj.setup(id = '191', name='test01', description=desc) |
|
610 | controllerObj.setup(id = '191', name='test01', description=desc) | |
594 |
|
611 | |||
595 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', |
|
612 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', | |
596 | path='data/rawdata/', |
|
613 | path='data/rawdata/', | |
597 | startDate='2011/01/01', |
|
614 | startDate='2011/01/01', | |
598 | endDate='2012/12/31', |
|
615 | endDate='2012/12/31', | |
599 | startTime='00:00:00', |
|
616 | startTime='00:00:00', | |
600 | endTime='23:59:59', |
|
617 | endTime='23:59:59', | |
601 | online=1, |
|
618 | online=1, | |
602 | walk=1) |
|
619 | walk=1) | |
603 |
|
620 | |||
604 | # opObj00 = readUnitConfObj.addOperation(name='printInfo') |
|
621 | # opObj00 = readUnitConfObj.addOperation(name='printInfo') | |
605 |
|
622 | |||
606 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) |
|
623 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |
607 |
|
624 | |||
608 | opObj10 = procUnitConfObj0.addOperation(name='selectChannels') |
|
625 | opObj10 = procUnitConfObj0.addOperation(name='selectChannels') | |
609 | opObj10.addParameter(name='channelList', value='3,4,5', format='intlist') |
|
626 | opObj10.addParameter(name='channelList', value='3,4,5', format='intlist') | |
610 |
|
627 | |||
611 | opObj10 = procUnitConfObj0.addOperation(name='selectHeights') |
|
628 | opObj10 = procUnitConfObj0.addOperation(name='selectHeights') | |
612 | opObj10.addParameter(name='minHei', value='90', format='float') |
|
629 | opObj10.addParameter(name='minHei', value='90', format='float') | |
613 | opObj10.addParameter(name='maxHei', value='180', format='float') |
|
630 | opObj10.addParameter(name='maxHei', value='180', format='float') | |
614 |
|
631 | |||
615 | opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='other') |
|
632 | opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='other') | |
616 | opObj12.addParameter(name='n', value='10', format='int') |
|
633 | opObj12.addParameter(name='n', value='10', format='int') | |
617 |
|
634 | |||
618 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) |
|
635 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) | |
619 | procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int') |
|
636 | procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int') | |
620 | # procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='') |
|
637 | # procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='') | |
621 |
|
638 | |||
622 |
|
639 | |||
623 | opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') |
|
640 | opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') | |
624 | opObj11.addParameter(name='idfigure', value='1', format='int') |
|
641 | opObj11.addParameter(name='idfigure', value='1', format='int') | |
625 | opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str') |
|
642 | opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str') | |
626 | opObj11.addParameter(name='zmin', value='40', format='int') |
|
643 | opObj11.addParameter(name='zmin', value='40', format='int') | |
627 | opObj11.addParameter(name='zmax', value='90', format='int') |
|
644 | opObj11.addParameter(name='zmax', value='90', format='int') | |
628 | opObj11.addParameter(name='showprofile', value='1', format='int') |
|
645 | opObj11.addParameter(name='showprofile', value='1', format='int') | |
629 |
|
646 | |||
630 | # opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other') |
|
647 | # opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other') | |
631 | # opObj11.addParameter(name='idfigure', value='2', format='int') |
|
648 | # opObj11.addParameter(name='idfigure', value='2', format='int') | |
632 | # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str') |
|
649 | # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str') | |
633 | # opObj11.addParameter(name='zmin', value='40', format='int') |
|
650 | # opObj11.addParameter(name='zmin', value='40', format='int') | |
634 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
651 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
635 |
|
652 | |||
636 |
|
653 | |||
637 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Voltage', inputId=procUnitConfObj0.getId()) |
|
654 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Voltage', inputId=procUnitConfObj0.getId()) | |
638 | # |
|
655 | # | |
639 | # opObj12 = procUnitConfObj2.addOperation(name='CohInt', optype='other') |
|
656 | # opObj12 = procUnitConfObj2.addOperation(name='CohInt', optype='other') | |
640 | # opObj12.addParameter(name='n', value='2', format='int') |
|
657 | # opObj12.addParameter(name='n', value='2', format='int') | |
641 | # opObj12.addParameter(name='overlapping', value='1', format='int') |
|
658 | # opObj12.addParameter(name='overlapping', value='1', format='int') | |
642 | # |
|
659 | # | |
643 | # procUnitConfObj3 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj2.getId()) |
|
660 | # procUnitConfObj3 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj2.getId()) | |
644 | # procUnitConfObj3.addParameter(name='nFFTPoints', value='32', format='int') |
|
661 | # procUnitConfObj3.addParameter(name='nFFTPoints', value='32', format='int') | |
645 | # |
|
662 | # | |
646 | # opObj11 = procUnitConfObj3.addOperation(name='SpectraPlot', optype='other') |
|
663 | # opObj11 = procUnitConfObj3.addOperation(name='SpectraPlot', optype='other') | |
647 | # opObj11.addParameter(name='idfigure', value='2', format='int') |
|
664 | # opObj11.addParameter(name='idfigure', value='2', format='int') | |
648 | # opObj11.addParameter(name='wintitle', value='SpectraPlot1', format='str') |
|
665 | # opObj11.addParameter(name='wintitle', value='SpectraPlot1', format='str') | |
649 | # opObj11.addParameter(name='zmin', value='40', format='int') |
|
666 | # opObj11.addParameter(name='zmin', value='40', format='int') | |
650 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
667 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
651 | # opObj11.addParameter(name='showprofile', value='1', format='int') |
|
668 | # opObj11.addParameter(name='showprofile', value='1', format='int') | |
652 |
|
669 | |||
653 | # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') |
|
670 | # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') | |
654 | # opObj11.addParameter(name='idfigure', value='10', format='int') |
|
671 | # opObj11.addParameter(name='idfigure', value='10', format='int') | |
655 | # opObj11.addParameter(name='wintitle', value='RTI', format='str') |
|
672 | # opObj11.addParameter(name='wintitle', value='RTI', format='str') | |
656 | ## opObj11.addParameter(name='xmin', value='21', format='float') |
|
673 | ## opObj11.addParameter(name='xmin', value='21', format='float') | |
657 | ## opObj11.addParameter(name='xmax', value='22', format='float') |
|
674 | ## opObj11.addParameter(name='xmax', value='22', format='float') | |
658 | # opObj11.addParameter(name='zmin', value='40', format='int') |
|
675 | # opObj11.addParameter(name='zmin', value='40', format='int') | |
659 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
676 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
660 | # opObj11.addParameter(name='showprofile', value='1', format='int') |
|
677 | # opObj11.addParameter(name='showprofile', value='1', format='int') | |
661 | # opObj11.addParameter(name='timerange', value=str(60), format='int') |
|
678 | # opObj11.addParameter(name='timerange', value=str(60), format='int') | |
662 |
|
679 | |||
663 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') |
|
680 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') | |
664 | # opObj10.addParameter(name='channelList', value='0,2,4,6', format='intlist') |
|
681 | # opObj10.addParameter(name='channelList', value='0,2,4,6', format='intlist') | |
665 | # |
|
682 | # | |
666 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') |
|
683 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') | |
667 | # opObj12.addParameter(name='n', value='2', format='int') |
|
684 | # opObj12.addParameter(name='n', value='2', format='int') | |
668 | # |
|
685 | # | |
669 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') |
|
686 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') | |
670 | # opObj11.addParameter(name='idfigure', value='2', format='int') |
|
687 | # opObj11.addParameter(name='idfigure', value='2', format='int') | |
671 | # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') |
|
688 | # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') | |
672 | # opObj11.addParameter(name='zmin', value='70', format='int') |
|
689 | # opObj11.addParameter(name='zmin', value='70', format='int') | |
673 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
690 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
674 | # |
|
691 | # | |
675 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') |
|
692 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') | |
676 | # opObj10.addParameter(name='channelList', value='2,6', format='intlist') |
|
693 | # opObj10.addParameter(name='channelList', value='2,6', format='intlist') | |
677 | # |
|
694 | # | |
678 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') |
|
695 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') | |
679 | # opObj12.addParameter(name='n', value='2', format='int') |
|
696 | # opObj12.addParameter(name='n', value='2', format='int') | |
680 | # |
|
697 | # | |
681 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') |
|
698 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') | |
682 | # opObj11.addParameter(name='idfigure', value='3', format='int') |
|
699 | # opObj11.addParameter(name='idfigure', value='3', format='int') | |
683 | # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') |
|
700 | # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') | |
684 | # opObj11.addParameter(name='zmin', value='70', format='int') |
|
701 | # opObj11.addParameter(name='zmin', value='70', format='int') | |
685 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
702 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
686 |
|
703 | |||
687 |
|
704 | |||
688 | # opObj12 = procUnitConfObj1.addOperation(name='decoder') |
|
705 | # opObj12 = procUnitConfObj1.addOperation(name='decoder') | |
689 | # opObj12.addParameter(name='ncode', value='2', format='int') |
|
706 | # opObj12.addParameter(name='ncode', value='2', format='int') | |
690 | # opObj12.addParameter(name='nbauds', value='8', format='int') |
|
707 | # opObj12.addParameter(name='nbauds', value='8', format='int') | |
691 | # opObj12.addParameter(name='code0', value='001110011', format='int') |
|
708 | # opObj12.addParameter(name='code0', value='001110011', format='int') | |
692 | # opObj12.addParameter(name='code1', value='001110011', format='int') |
|
709 | # opObj12.addParameter(name='code1', value='001110011', format='int') | |
693 |
|
710 | |||
694 |
|
711 | |||
695 |
|
712 | |||
696 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj1.getId()) |
|
713 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj1.getId()) | |
697 | # |
|
714 | # | |
698 | # opObj21 = procUnitConfObj2.addOperation(name='IncohInt', optype='other') |
|
715 | # opObj21 = procUnitConfObj2.addOperation(name='IncohInt', optype='other') | |
699 | # opObj21.addParameter(name='n', value='2', format='int') |
|
716 | # opObj21.addParameter(name='n', value='2', format='int') | |
700 | # |
|
717 | # | |
701 | # opObj11 = procUnitConfObj2.addOperation(name='SpectraPlot', optype='other') |
|
718 | # opObj11 = procUnitConfObj2.addOperation(name='SpectraPlot', optype='other') | |
702 | # opObj11.addParameter(name='idfigure', value='4', format='int') |
|
719 | # opObj11.addParameter(name='idfigure', value='4', format='int') | |
703 | # opObj11.addParameter(name='wintitle', value='SpectraPlot OBJ 2', format='str') |
|
720 | # opObj11.addParameter(name='wintitle', value='SpectraPlot OBJ 2', format='str') | |
704 | # opObj11.addParameter(name='zmin', value='70', format='int') |
|
721 | # opObj11.addParameter(name='zmin', value='70', format='int') | |
705 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
722 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
706 |
|
723 | |||
707 | print "Escribiendo el archivo XML" |
|
724 | print "Escribiendo el archivo XML" | |
708 |
|
725 | |||
709 | controllerObj.writeXml(filename) |
|
726 | controllerObj.writeXml(filename) | |
710 |
|
727 | |||
711 | print "Leyendo el archivo XML" |
|
728 | print "Leyendo el archivo XML" | |
712 | controllerObj.readXml(filename) |
|
729 | controllerObj.readXml(filename) | |
713 | #controllerObj.printattr() |
|
730 | #controllerObj.printattr() | |
714 |
|
731 | |||
715 | controllerObj.createObjects() |
|
732 | controllerObj.createObjects() | |
716 | controllerObj.connectObjects() |
|
733 | controllerObj.connectObjects() | |
717 | controllerObj.run() |
|
734 | controllerObj.run() | |
718 |
|
735 | |||
719 | No newline at end of file |
|
736 |
General Comments 0
You need to be logged in to leave comments.
Login now