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