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