@@ -1,736 +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 |
|
233 | |||
226 | opConfObjList = [] |
|
234 | opConfObjList = [] | |
227 |
|
235 | |||
228 | procUnitObj = None |
|
236 | procUnitObj = None | |
229 | opObjList = [] |
|
237 | opObjList = [] | |
230 |
|
238 | |||
231 | ELEMENTNAME = 'ProcUnit' |
|
239 | ELEMENTNAME = 'ProcUnit' | |
232 |
|
240 | |||
233 | def __init__(self): |
|
241 | def __init__(self): | |
234 |
|
242 | |||
235 | self.id = None |
|
243 | self.id = None | |
236 | self.datatype = None |
|
244 | self.datatype = None | |
237 | self.name = None |
|
245 | self.name = None | |
238 | self.inputId = None |
|
246 | self.inputId = None | |
239 |
|
247 | |||
240 | self.opConfObjList = [] |
|
248 | self.opConfObjList = [] | |
241 |
|
249 | |||
242 | self.procUnitObj = None |
|
250 | self.procUnitObj = None | |
243 | self.opObjDict = {} |
|
251 | self.opObjDict = {} | |
244 |
|
252 | |||
245 | def __getPriority(self): |
|
253 | def __getPriority(self): | |
246 |
|
254 | |||
247 | return len(self.opConfObjList)+1 |
|
255 | return len(self.opConfObjList)+1 | |
248 |
|
256 | |||
249 | def __getNewId(self): |
|
257 | def __getNewId(self): | |
250 |
|
258 | |||
251 | return int(self.id)*10 + len(self.opConfObjList) + 1 |
|
259 | return int(self.id)*10 + len(self.opConfObjList) + 1 | |
252 |
|
260 | |||
253 | def getElementName(self): |
|
261 | def getElementName(self): | |
254 |
|
262 | |||
255 | return self.ELEMENTNAME |
|
263 | return self.ELEMENTNAME | |
256 |
|
264 | |||
257 | def getId(self): |
|
265 | def getId(self): | |
258 |
|
266 | |||
259 | return str(self.id) |
|
267 | return str(self.id) | |
260 |
|
268 | |||
261 | def getInputId(self): |
|
269 | def getInputId(self): | |
262 |
|
270 | |||
263 | return str(self.inputId) |
|
271 | return str(self.inputId) | |
264 |
|
272 | |||
265 | def getOperationObjList(self): |
|
273 | def getOperationObjList(self): | |
266 |
|
274 | |||
267 | return self.opConfObjList |
|
275 | return self.opConfObjList | |
268 |
|
276 | |||
269 | def getProcUnitObj(self): |
|
277 | def getProcUnitObj(self): | |
270 |
|
278 | |||
271 | return self.procUnitObj |
|
279 | return self.procUnitObj | |
272 |
|
280 | |||
273 | def setup(self, id, name, datatype, inputId): |
|
281 | def setup(self, id, name, datatype, inputId): | |
274 |
|
282 | |||
275 | self.id = id |
|
283 | self.id = id | |
276 | self.name = name |
|
284 | self.name = name | |
277 | self.datatype = datatype |
|
285 | self.datatype = datatype | |
278 | self.inputId = inputId |
|
286 | self.inputId = inputId | |
279 |
|
287 | |||
280 | self.opConfObjList = [] |
|
288 | self.opConfObjList = [] | |
281 |
|
289 | |||
282 | self.addOperation(name='init', optype='self') |
|
290 | self.addOperation(name='init', optype='self') | |
283 |
|
291 | |||
284 | def addParameter(self, **kwargs): |
|
292 | def addParameter(self, **kwargs): | |
285 |
|
293 | |||
286 | opObj = self.opConfObjList[0] |
|
294 | opObj = self.opConfObjList[0] | |
287 |
|
295 | |||
288 | opObj.addParameter(**kwargs) |
|
296 | opObj.addParameter(**kwargs) | |
289 |
|
297 | |||
290 | return opObj |
|
298 | return opObj | |
291 |
|
299 | |||
292 | def addOperation(self, name, optype='self'): |
|
300 | def addOperation(self, name, optype='self'): | |
293 |
|
301 | |||
294 | id = self.__getNewId() |
|
302 | id = self.__getNewId() | |
295 | priority = self.__getPriority() |
|
303 | priority = self.__getPriority() | |
296 |
|
304 | |||
297 | opConfObj = OperationConf() |
|
305 | opConfObj = OperationConf() | |
298 | opConfObj.setup(id, name=name, priority=priority, type=optype) |
|
306 | opConfObj.setup(id, name=name, priority=priority, type=optype) | |
299 |
|
307 | |||
300 | self.opConfObjList.append(opConfObj) |
|
308 | self.opConfObjList.append(opConfObj) | |
301 |
|
309 | |||
302 | return opConfObj |
|
310 | return opConfObj | |
303 |
|
311 | |||
304 | def makeXml(self, procUnitElement): |
|
312 | def makeXml(self, procUnitElement): | |
305 |
|
313 | |||
306 | upElement = SubElement(procUnitElement, self.ELEMENTNAME) |
|
314 | upElement = SubElement(procUnitElement, self.ELEMENTNAME) | |
307 | upElement.set('id', str(self.id)) |
|
315 | upElement.set('id', str(self.id)) | |
308 | upElement.set('name', self.name) |
|
316 | upElement.set('name', self.name) | |
309 | upElement.set('datatype', self.datatype) |
|
317 | upElement.set('datatype', self.datatype) | |
310 | upElement.set('inputId', str(self.inputId)) |
|
318 | upElement.set('inputId', str(self.inputId)) | |
311 |
|
319 | |||
312 | for opConfObj in self.opConfObjList: |
|
320 | for opConfObj in self.opConfObjList: | |
313 | opConfObj.makeXml(upElement) |
|
321 | opConfObj.makeXml(upElement) | |
314 |
|
322 | |||
315 | def readXml(self, upElement): |
|
323 | def readXml(self, upElement): | |
316 |
|
324 | |||
317 | self.id = upElement.get('id') |
|
325 | self.id = upElement.get('id') | |
318 | self.name = upElement.get('name') |
|
326 | self.name = upElement.get('name') | |
319 | self.datatype = upElement.get('datatype') |
|
327 | self.datatype = upElement.get('datatype') | |
320 | self.inputId = upElement.get('inputId') |
|
328 | self.inputId = upElement.get('inputId') | |
321 |
|
329 | |||
322 | self.opConfObjList = [] |
|
330 | self.opConfObjList = [] | |
323 |
|
331 | |||
324 | opElementList = upElement.getiterator(OperationConf().getElementName()) |
|
332 | opElementList = upElement.getiterator(OperationConf().getElementName()) | |
325 |
|
333 | |||
326 | for opElement in opElementList: |
|
334 | for opElement in opElementList: | |
327 | opConfObj = OperationConf() |
|
335 | opConfObj = OperationConf() | |
328 | opConfObj.readXml(opElement) |
|
336 | opConfObj.readXml(opElement) | |
329 | self.opConfObjList.append(opConfObj) |
|
337 | self.opConfObjList.append(opConfObj) | |
330 |
|
338 | |||
331 | def printattr(self): |
|
339 | def printattr(self): | |
332 |
|
340 | |||
333 | print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME, |
|
341 | print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME, | |
334 | self.id, |
|
342 | self.id, | |
335 | self.name, |
|
343 | self.name, | |
336 | self.datatype, |
|
344 | self.datatype, | |
337 | self.inputId) |
|
345 | self.inputId) | |
338 |
|
346 | |||
339 | for opConfObj in self.opConfObjList: |
|
347 | for opConfObj in self.opConfObjList: | |
340 | opConfObj.printattr() |
|
348 | opConfObj.printattr() | |
341 |
|
349 | |||
342 | def createObjects(self): |
|
350 | def createObjects(self): | |
343 |
|
351 | |||
344 | className = eval(self.name) |
|
352 | className = eval(self.name) | |
345 | procUnitObj = className() |
|
353 | procUnitObj = className() | |
346 |
|
354 | |||
347 | for opConfObj in self.opConfObjList: |
|
355 | for opConfObj in self.opConfObjList: | |
348 |
|
356 | |||
349 | if opConfObj.type == 'self': |
|
357 | if opConfObj.type == 'self': | |
350 | continue |
|
358 | continue | |
351 |
|
359 | |||
352 | opObj = opConfObj.createObject() |
|
360 | opObj = opConfObj.createObject() | |
353 |
|
361 | |||
354 | self.opObjDict[opConfObj.id] = opObj |
|
362 | self.opObjDict[opConfObj.id] = opObj | |
355 | procUnitObj.addOperation(opObj, opConfObj.id) |
|
363 | procUnitObj.addOperation(opObj, opConfObj.id) | |
356 |
|
364 | |||
357 | self.procUnitObj = procUnitObj |
|
365 | self.procUnitObj = procUnitObj | |
358 |
|
366 | |||
359 | return procUnitObj |
|
367 | return procUnitObj | |
360 |
|
368 | |||
361 | def run(self): |
|
369 | def run(self): | |
362 |
|
370 | |||
363 | finalSts = False |
|
371 | finalSts = False | |
364 |
|
372 | |||
365 | for opConfObj in self.opConfObjList: |
|
373 | for opConfObj in self.opConfObjList: | |
366 |
|
374 | |||
367 | kwargs = {} |
|
375 | kwargs = {} | |
368 | for parmConfObj in opConfObj.getParameterObjList(): |
|
376 | for parmConfObj in opConfObj.getParameterObjList(): | |
369 | kwargs[parmConfObj.name] = parmConfObj.getValue() |
|
377 | kwargs[parmConfObj.name] = parmConfObj.getValue() | |
370 |
|
378 | |||
371 | #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id) |
|
379 | #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id) | |
372 | sts = self.procUnitObj.call(opConfObj, **kwargs) |
|
380 | sts = self.procUnitObj.call(opConfObj, **kwargs) | |
373 | finalSts = finalSts or sts |
|
381 | finalSts = finalSts or sts | |
374 |
|
382 | |||
375 | return finalSts |
|
383 | return finalSts | |
376 |
|
384 | |||
377 | class ReadUnitConf(ProcUnitConf): |
|
385 | class ReadUnitConf(ProcUnitConf): | |
378 |
|
386 | |||
379 | path = None |
|
387 | path = None | |
380 | startDate = None |
|
388 | startDate = None | |
381 | endDate = None |
|
389 | endDate = None | |
382 | startTime = None |
|
390 | startTime = None | |
383 | endTime = None |
|
391 | endTime = None | |
384 |
|
392 | |||
385 | ELEMENTNAME = 'ReadUnit' |
|
393 | ELEMENTNAME = 'ReadUnit' | |
386 |
|
394 | |||
387 | def __init__(self): |
|
395 | def __init__(self): | |
388 |
|
396 | |||
389 | self.id = None |
|
397 | self.id = None | |
390 | self.datatype = None |
|
398 | self.datatype = None | |
391 | self.name = None |
|
399 | self.name = None | |
392 | self.inputId = 0 |
|
400 | self.inputId = 0 | |
393 |
|
401 | |||
394 | self.opConfObjList = [] |
|
402 | self.opConfObjList = [] | |
395 | self.opObjList = [] |
|
403 | self.opObjList = [] | |
396 |
|
404 | |||
397 | def getElementName(self): |
|
405 | def getElementName(self): | |
398 |
|
406 | |||
399 | return self.ELEMENTNAME |
|
407 | return self.ELEMENTNAME | |
400 |
|
408 | |||
401 | 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): | |
402 |
|
410 | |||
403 | self.id = id |
|
411 | self.id = id | |
404 | self.name = name |
|
412 | self.name = name | |
405 | self.datatype = datatype |
|
413 | self.datatype = datatype | |
406 |
|
414 | |||
407 | self.path = path |
|
415 | self.path = path | |
408 | self.startDate = startDate |
|
416 | self.startDate = startDate | |
409 | self.endDate = endDate |
|
417 | self.endDate = endDate | |
410 | self.startTime = startTime |
|
418 | self.startTime = startTime | |
411 | self.endTime = endTime |
|
419 | self.endTime = endTime | |
412 |
|
420 | |||
413 | self.addRunOperation(**kwargs) |
|
421 | self.addRunOperation(**kwargs) | |
414 |
|
422 | |||
415 | def addRunOperation(self, **kwargs): |
|
423 | def addRunOperation(self, **kwargs): | |
416 |
|
424 | |||
417 | opObj = self.addOperation(name = 'run', optype = 'self') |
|
425 | opObj = self.addOperation(name = 'run', optype = 'self') | |
418 |
|
426 | |||
419 | opObj.addParameter(name='path' , value=self.path, format='str') |
|
427 | opObj.addParameter(name='path' , value=self.path, format='str') | |
420 | opObj.addParameter(name='startDate' , value=self.startDate, format='date') |
|
428 | opObj.addParameter(name='startDate' , value=self.startDate, format='date') | |
421 | opObj.addParameter(name='endDate' , value=self.endDate, format='date') |
|
429 | opObj.addParameter(name='endDate' , value=self.endDate, format='date') | |
422 | opObj.addParameter(name='startTime' , value=self.startTime, format='time') |
|
430 | opObj.addParameter(name='startTime' , value=self.startTime, format='time') | |
423 | opObj.addParameter(name='endTime' , value=self.endTime, format='time') |
|
431 | opObj.addParameter(name='endTime' , value=self.endTime, format='time') | |
424 |
|
432 | |||
425 | for key, value in kwargs.items(): |
|
433 | for key, value in kwargs.items(): | |
426 | opObj.addParameter(name=key, value=value, format=type(value).__name__) |
|
434 | opObj.addParameter(name=key, value=value, format=type(value).__name__) | |
427 |
|
435 | |||
428 | return opObj |
|
436 | return opObj | |
429 |
|
437 | |||
430 |
|
438 | |||
431 | class Project(): |
|
439 | class Project(): | |
432 |
|
440 | |||
433 | id = None |
|
441 | id = None | |
434 | name = None |
|
442 | name = None | |
435 | description = None |
|
443 | description = None | |
436 | # readUnitConfObjList = None |
|
444 | # readUnitConfObjList = None | |
437 | procUnitConfObjDict = None |
|
445 | procUnitConfObjDict = None | |
438 |
|
446 | |||
439 | ELEMENTNAME = 'Project' |
|
447 | ELEMENTNAME = 'Project' | |
440 |
|
448 | |||
441 | def __init__(self): |
|
449 | def __init__(self): | |
442 |
|
450 | |||
443 | self.id = None |
|
451 | self.id = None | |
444 | self.name = None |
|
452 | self.name = None | |
445 | self.description = None |
|
453 | self.description = None | |
446 |
|
454 | |||
447 | # self.readUnitConfObjList = [] |
|
455 | # self.readUnitConfObjList = [] | |
448 | self.procUnitConfObjDict = {} |
|
456 | self.procUnitConfObjDict = {} | |
449 |
|
457 | |||
450 | def __getNewId(self): |
|
458 | def __getNewId(self): | |
451 |
|
459 | |||
452 | id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1 |
|
460 | id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1 | |
453 |
|
461 | |||
454 | return str(id) |
|
462 | return str(id) | |
455 |
|
463 | |||
456 | def getElementName(self): |
|
464 | def getElementName(self): | |
457 |
|
465 | |||
458 | return self.ELEMENTNAME |
|
466 | return self.ELEMENTNAME | |
459 |
|
467 | |||
460 | def setup(self, id, name, description): |
|
468 | def setup(self, id, name, description): | |
461 |
|
469 | |||
462 | self.id = id |
|
470 | self.id = id | |
463 | self.name = name |
|
471 | self.name = name | |
464 | self.description = description |
|
472 | self.description = description | |
465 |
|
473 | |||
466 | def addReadUnit(self, datatype, path, startDate='', endDate='', startTime='', endTime='', **kwargs): |
|
474 | def addReadUnit(self, datatype, path, startDate='', endDate='', startTime='', endTime='', **kwargs): | |
467 |
|
475 | |||
468 | id = self.__getNewId() |
|
476 | id = self.__getNewId() | |
469 | name = '%sReader' %(datatype) |
|
477 | name = '%sReader' %(datatype) | |
470 |
|
478 | |||
471 | readUnitConfObj = ReadUnitConf() |
|
479 | readUnitConfObj = ReadUnitConf() | |
472 | readUnitConfObj.setup(id, name, datatype, path, startDate, endDate, startTime, endTime, **kwargs) |
|
480 | readUnitConfObj.setup(id, name, datatype, path, startDate, endDate, startTime, endTime, **kwargs) | |
473 |
|
481 | |||
474 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj |
|
482 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj | |
475 |
|
483 | |||
476 | return readUnitConfObj |
|
484 | return readUnitConfObj | |
477 |
|
485 | |||
478 | def addProcUnit(self, datatype, inputId): |
|
486 | def addProcUnit(self, datatype, inputId): | |
479 |
|
487 | |||
480 | id = self.__getNewId() |
|
488 | id = self.__getNewId() | |
481 | name = '%sProc' %(datatype) |
|
489 | name = '%sProc' %(datatype) | |
482 |
|
490 | |||
483 | procUnitConfObj = ProcUnitConf() |
|
491 | procUnitConfObj = ProcUnitConf() | |
484 | procUnitConfObj.setup(id, name, datatype, inputId) |
|
492 | procUnitConfObj.setup(id, name, datatype, inputId) | |
485 |
|
493 | |||
486 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj |
|
494 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj | |
487 |
|
495 | |||
488 | return procUnitConfObj |
|
496 | return procUnitConfObj | |
489 |
|
497 | |||
490 | def makeXml(self): |
|
498 | def makeXml(self): | |
491 |
|
499 | |||
492 | projectElement = Element('Project') |
|
500 | projectElement = Element('Project') | |
493 | projectElement.set('id', str(self.id)) |
|
501 | projectElement.set('id', str(self.id)) | |
494 | projectElement.set('name', self.name) |
|
502 | projectElement.set('name', self.name) | |
495 | projectElement.set('description', self.description) |
|
503 | projectElement.set('description', self.description) | |
496 |
|
504 | |||
497 | # for readUnitConfObj in self.readUnitConfObjList: |
|
505 | # for readUnitConfObj in self.readUnitConfObjList: | |
498 | # readUnitConfObj.makeXml(projectElement) |
|
506 | # readUnitConfObj.makeXml(projectElement) | |
499 |
|
507 | |||
500 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
508 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
501 | procUnitConfObj.makeXml(projectElement) |
|
509 | procUnitConfObj.makeXml(projectElement) | |
502 |
|
510 | |||
503 | self.projectElement = projectElement |
|
511 | self.projectElement = projectElement | |
504 |
|
512 | |||
505 | def writeXml(self, filename): |
|
513 | def writeXml(self, filename): | |
506 |
|
514 | |||
507 | self.makeXml() |
|
515 | self.makeXml() | |
508 |
|
516 | |||
509 | print prettify(self.projectElement) |
|
517 | print prettify(self.projectElement) | |
510 |
|
518 | |||
511 | ElementTree(self.projectElement).write(filename, method='xml') |
|
519 | ElementTree(self.projectElement).write(filename, method='xml') | |
512 |
|
520 | |||
513 | def readXml(self, filename): |
|
521 | def readXml(self, filename): | |
514 |
|
522 | |||
515 | #tree = ET.parse(filename) |
|
523 | #tree = ET.parse(filename) | |
516 | self.projectElement = None |
|
524 | self.projectElement = None | |
517 | # self.readUnitConfObjList = [] |
|
525 | # self.readUnitConfObjList = [] | |
518 | self.procUnitConfObjDict = {} |
|
526 | self.procUnitConfObjDict = {} | |
519 |
|
527 | |||
520 | self.projectElement = ElementTree().parse(filename) |
|
528 | self.projectElement = ElementTree().parse(filename) | |
521 |
|
529 | |||
522 | self.project = self.projectElement.tag |
|
530 | self.project = self.projectElement.tag | |
523 |
|
531 | |||
524 | self.id = self.projectElement.get('id') |
|
532 | self.id = self.projectElement.get('id') | |
525 | self.name = self.projectElement.get('name') |
|
533 | self.name = self.projectElement.get('name') | |
526 | self.description = self.projectElement.get('description') |
|
534 | self.description = self.projectElement.get('description') | |
527 |
|
535 | |||
528 | readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName()) |
|
536 | readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName()) | |
529 |
|
537 | |||
530 | for readUnitElement in readUnitElementList: |
|
538 | for readUnitElement in readUnitElementList: | |
531 | readUnitConfObj = ReadUnitConf() |
|
539 | readUnitConfObj = ReadUnitConf() | |
532 | readUnitConfObj.readXml(readUnitElement) |
|
540 | readUnitConfObj.readXml(readUnitElement) | |
533 |
|
541 | |||
534 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj |
|
542 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj | |
535 |
|
543 | |||
536 | procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName()) |
|
544 | procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName()) | |
537 |
|
545 | |||
538 | for procUnitElement in procUnitElementList: |
|
546 | for procUnitElement in procUnitElementList: | |
539 | procUnitConfObj = ProcUnitConf() |
|
547 | procUnitConfObj = ProcUnitConf() | |
540 | procUnitConfObj.readXml(procUnitElement) |
|
548 | procUnitConfObj.readXml(procUnitElement) | |
541 |
|
549 | |||
542 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj |
|
550 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj | |
543 |
|
551 | |||
544 | def printattr(self): |
|
552 | def printattr(self): | |
545 |
|
553 | |||
546 | print "Project[%s]: name = %s, description = %s" %(self.id, |
|
554 | print "Project[%s]: name = %s, description = %s" %(self.id, | |
547 | self.name, |
|
555 | self.name, | |
548 | self.description) |
|
556 | self.description) | |
549 |
|
557 | |||
550 | # for readUnitConfObj in self.readUnitConfObjList: |
|
558 | # for readUnitConfObj in self.readUnitConfObjList: | |
551 | # readUnitConfObj.printattr() |
|
559 | # readUnitConfObj.printattr() | |
552 |
|
560 | |||
553 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
561 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
554 | procUnitConfObj.printattr() |
|
562 | procUnitConfObj.printattr() | |
555 |
|
563 | |||
556 | def createObjects(self): |
|
564 | def createObjects(self): | |
557 |
|
565 | |||
558 | # for readUnitConfObj in self.readUnitConfObjList: |
|
566 | # for readUnitConfObj in self.readUnitConfObjList: | |
559 | # readUnitConfObj.createObjects() |
|
567 | # readUnitConfObj.createObjects() | |
560 |
|
568 | |||
561 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
569 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
562 | procUnitConfObj.createObjects() |
|
570 | procUnitConfObj.createObjects() | |
563 |
|
571 | |||
564 | def __connect(self, objIN, obj): |
|
572 | def __connect(self, objIN, obj): | |
565 |
|
573 | |||
566 | obj.setInput(objIN.getOutput()) |
|
574 | obj.setInput(objIN.getOutput()) | |
567 |
|
575 | |||
568 | def connectObjects(self): |
|
576 | def connectObjects(self): | |
569 |
|
577 | |||
570 | for puConfObj in self.procUnitConfObjDict.values(): |
|
578 | for puConfObj in self.procUnitConfObjDict.values(): | |
571 |
|
579 | |||
572 | inputId = puConfObj.getInputId() |
|
580 | inputId = puConfObj.getInputId() | |
573 |
|
581 | |||
574 | if int(inputId) == 0: |
|
582 | if int(inputId) == 0: | |
575 | continue |
|
583 | continue | |
576 |
|
584 | |||
577 | puConfINObj = self.procUnitConfObjDict[inputId] |
|
585 | puConfINObj = self.procUnitConfObjDict[inputId] | |
578 |
|
586 | |||
579 | puObj = puConfObj.getProcUnitObj() |
|
587 | puObj = puConfObj.getProcUnitObj() | |
580 | puINObj = puConfINObj.getProcUnitObj() |
|
588 | puINObj = puConfINObj.getProcUnitObj() | |
581 |
|
589 | |||
582 | self.__connect(puINObj, puObj) |
|
590 | self.__connect(puINObj, puObj) | |
583 |
|
591 | |||
584 | def run(self): |
|
592 | def run(self): | |
585 |
|
593 | |||
586 | # for readUnitConfObj in self.readUnitConfObjList: |
|
594 | # for readUnitConfObj in self.readUnitConfObjList: | |
587 | # readUnitConfObj.run() |
|
595 | # readUnitConfObj.run() | |
588 |
|
596 | |||
589 | while(True): |
|
597 | while(True): | |
590 |
|
598 | |||
591 | finalSts = False |
|
599 | finalSts = False | |
592 |
|
600 | |||
593 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
601 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
594 | #print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id) |
|
602 | #print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id) | |
595 | sts = procUnitConfObj.run() |
|
603 | sts = procUnitConfObj.run() | |
596 | finalSts = finalSts or sts |
|
604 | finalSts = finalSts or sts | |
597 |
|
605 | |||
598 | #If every process unit finished so end process |
|
606 | #If every process unit finished so end process | |
599 | if not(finalSts): |
|
607 | if not(finalSts): | |
600 | print "Every process units have finished" |
|
608 | print "Every process units have finished" | |
601 | break |
|
609 | break | |
602 |
|
610 | |||
603 | if __name__ == '__main__': |
|
611 | if __name__ == '__main__': | |
604 |
|
612 | |||
605 | desc = "Segundo Test" |
|
613 | desc = "Segundo Test" | |
606 | filename = "schain.xml" |
|
614 | filename = "schain.xml" | |
607 |
|
615 | |||
608 | controllerObj = Project() |
|
616 | controllerObj = Project() | |
609 |
|
617 | |||
610 | controllerObj.setup(id = '191', name='test01', description=desc) |
|
618 | controllerObj.setup(id = '191', name='test01', description=desc) | |
611 |
|
619 | |||
612 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', |
|
620 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', | |
613 | path='data/rawdata/', |
|
621 | path='data/rawdata/', | |
614 | startDate='2011/01/01', |
|
622 | startDate='2011/01/01', | |
615 | endDate='2012/12/31', |
|
623 | endDate='2012/12/31', | |
616 | startTime='00:00:00', |
|
624 | startTime='00:00:00', | |
617 | endTime='23:59:59', |
|
625 | endTime='23:59:59', | |
618 | online=1, |
|
626 | online=1, | |
619 | walk=1) |
|
627 | walk=1) | |
620 |
|
628 | |||
621 | # opObj00 = readUnitConfObj.addOperation(name='printInfo') |
|
629 | # opObj00 = readUnitConfObj.addOperation(name='printInfo') | |
622 |
|
630 | |||
623 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) |
|
631 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |
624 |
|
632 | |||
625 | opObj10 = procUnitConfObj0.addOperation(name='selectChannels') |
|
633 | opObj10 = procUnitConfObj0.addOperation(name='selectChannels') | |
626 | opObj10.addParameter(name='channelList', value='3,4,5', format='intlist') |
|
634 | opObj10.addParameter(name='channelList', value='3,4,5', format='intlist') | |
627 |
|
635 | |||
628 | opObj10 = procUnitConfObj0.addOperation(name='selectHeights') |
|
636 | opObj10 = procUnitConfObj0.addOperation(name='selectHeights') | |
629 | opObj10.addParameter(name='minHei', value='90', format='float') |
|
637 | opObj10.addParameter(name='minHei', value='90', format='float') | |
630 | opObj10.addParameter(name='maxHei', value='180', format='float') |
|
638 | opObj10.addParameter(name='maxHei', value='180', format='float') | |
631 |
|
639 | |||
632 | opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='other') |
|
640 | opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='other') | |
633 | opObj12.addParameter(name='n', value='10', format='int') |
|
641 | opObj12.addParameter(name='n', value='10', format='int') | |
634 |
|
642 | |||
635 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) |
|
643 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) | |
636 | procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int') |
|
644 | procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int') | |
637 | # 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='') | |
638 |
|
646 | |||
639 |
|
647 | |||
640 | opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') |
|
648 | opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') | |
641 | opObj11.addParameter(name='idfigure', value='1', format='int') |
|
649 | opObj11.addParameter(name='idfigure', value='1', format='int') | |
642 | opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str') |
|
650 | opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str') | |
643 | opObj11.addParameter(name='zmin', value='40', format='int') |
|
651 | opObj11.addParameter(name='zmin', value='40', format='int') | |
644 | opObj11.addParameter(name='zmax', value='90', format='int') |
|
652 | opObj11.addParameter(name='zmax', value='90', format='int') | |
645 | opObj11.addParameter(name='showprofile', value='1', format='int') |
|
653 | opObj11.addParameter(name='showprofile', value='1', format='int') | |
646 |
|
654 | |||
647 | # opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other') |
|
655 | # opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other') | |
648 | # opObj11.addParameter(name='idfigure', value='2', format='int') |
|
656 | # opObj11.addParameter(name='idfigure', value='2', format='int') | |
649 | # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str') |
|
657 | # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str') | |
650 | # opObj11.addParameter(name='zmin', value='40', format='int') |
|
658 | # opObj11.addParameter(name='zmin', value='40', format='int') | |
651 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
659 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
652 |
|
660 | |||
653 |
|
661 | |||
654 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Voltage', inputId=procUnitConfObj0.getId()) |
|
662 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Voltage', inputId=procUnitConfObj0.getId()) | |
655 | # |
|
663 | # | |
656 | # opObj12 = procUnitConfObj2.addOperation(name='CohInt', optype='other') |
|
664 | # opObj12 = procUnitConfObj2.addOperation(name='CohInt', optype='other') | |
657 | # opObj12.addParameter(name='n', value='2', format='int') |
|
665 | # opObj12.addParameter(name='n', value='2', format='int') | |
658 | # opObj12.addParameter(name='overlapping', value='1', format='int') |
|
666 | # opObj12.addParameter(name='overlapping', value='1', format='int') | |
659 | # |
|
667 | # | |
660 | # procUnitConfObj3 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj2.getId()) |
|
668 | # procUnitConfObj3 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj2.getId()) | |
661 | # procUnitConfObj3.addParameter(name='nFFTPoints', value='32', format='int') |
|
669 | # procUnitConfObj3.addParameter(name='nFFTPoints', value='32', format='int') | |
662 | # |
|
670 | # | |
663 | # opObj11 = procUnitConfObj3.addOperation(name='SpectraPlot', optype='other') |
|
671 | # opObj11 = procUnitConfObj3.addOperation(name='SpectraPlot', optype='other') | |
664 | # opObj11.addParameter(name='idfigure', value='2', format='int') |
|
672 | # opObj11.addParameter(name='idfigure', value='2', format='int') | |
665 | # opObj11.addParameter(name='wintitle', value='SpectraPlot1', format='str') |
|
673 | # opObj11.addParameter(name='wintitle', value='SpectraPlot1', format='str') | |
666 | # opObj11.addParameter(name='zmin', value='40', format='int') |
|
674 | # opObj11.addParameter(name='zmin', value='40', format='int') | |
667 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
675 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
668 | # opObj11.addParameter(name='showprofile', value='1', format='int') |
|
676 | # opObj11.addParameter(name='showprofile', value='1', format='int') | |
669 |
|
677 | |||
670 | # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') |
|
678 | # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') | |
671 | # opObj11.addParameter(name='idfigure', value='10', format='int') |
|
679 | # opObj11.addParameter(name='idfigure', value='10', format='int') | |
672 | # opObj11.addParameter(name='wintitle', value='RTI', format='str') |
|
680 | # opObj11.addParameter(name='wintitle', value='RTI', format='str') | |
673 | ## opObj11.addParameter(name='xmin', value='21', format='float') |
|
681 | ## opObj11.addParameter(name='xmin', value='21', format='float') | |
674 | ## opObj11.addParameter(name='xmax', value='22', format='float') |
|
682 | ## opObj11.addParameter(name='xmax', value='22', format='float') | |
675 | # opObj11.addParameter(name='zmin', value='40', format='int') |
|
683 | # opObj11.addParameter(name='zmin', value='40', format='int') | |
676 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
684 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
677 | # opObj11.addParameter(name='showprofile', value='1', format='int') |
|
685 | # opObj11.addParameter(name='showprofile', value='1', format='int') | |
678 | # opObj11.addParameter(name='timerange', value=str(60), format='int') |
|
686 | # opObj11.addParameter(name='timerange', value=str(60), format='int') | |
679 |
|
687 | |||
680 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') |
|
688 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') | |
681 | # opObj10.addParameter(name='channelList', value='0,2,4,6', format='intlist') |
|
689 | # opObj10.addParameter(name='channelList', value='0,2,4,6', format='intlist') | |
682 | # |
|
690 | # | |
683 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') |
|
691 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') | |
684 | # opObj12.addParameter(name='n', value='2', format='int') |
|
692 | # opObj12.addParameter(name='n', value='2', format='int') | |
685 | # |
|
693 | # | |
686 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') |
|
694 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') | |
687 | # opObj11.addParameter(name='idfigure', value='2', format='int') |
|
695 | # opObj11.addParameter(name='idfigure', value='2', format='int') | |
688 | # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') |
|
696 | # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') | |
689 | # opObj11.addParameter(name='zmin', value='70', format='int') |
|
697 | # opObj11.addParameter(name='zmin', value='70', format='int') | |
690 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
698 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
691 | # |
|
699 | # | |
692 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') |
|
700 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') | |
693 | # opObj10.addParameter(name='channelList', value='2,6', format='intlist') |
|
701 | # opObj10.addParameter(name='channelList', value='2,6', format='intlist') | |
694 | # |
|
702 | # | |
695 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') |
|
703 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') | |
696 | # opObj12.addParameter(name='n', value='2', format='int') |
|
704 | # opObj12.addParameter(name='n', value='2', format='int') | |
697 | # |
|
705 | # | |
698 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') |
|
706 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') | |
699 | # opObj11.addParameter(name='idfigure', value='3', format='int') |
|
707 | # opObj11.addParameter(name='idfigure', value='3', format='int') | |
700 | # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') |
|
708 | # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') | |
701 | # opObj11.addParameter(name='zmin', value='70', format='int') |
|
709 | # opObj11.addParameter(name='zmin', value='70', format='int') | |
702 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
710 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
703 |
|
711 | |||
704 |
|
712 | |||
705 | # opObj12 = procUnitConfObj1.addOperation(name='decoder') |
|
713 | # opObj12 = procUnitConfObj1.addOperation(name='decoder') | |
706 | # opObj12.addParameter(name='ncode', value='2', format='int') |
|
714 | # opObj12.addParameter(name='ncode', value='2', format='int') | |
707 | # opObj12.addParameter(name='nbauds', value='8', format='int') |
|
715 | # opObj12.addParameter(name='nbauds', value='8', format='int') | |
708 | # opObj12.addParameter(name='code0', value='001110011', format='int') |
|
716 | # opObj12.addParameter(name='code0', value='001110011', format='int') | |
709 | # opObj12.addParameter(name='code1', value='001110011', format='int') |
|
717 | # opObj12.addParameter(name='code1', value='001110011', format='int') | |
710 |
|
718 | |||
711 |
|
719 | |||
712 |
|
720 | |||
713 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj1.getId()) |
|
721 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj1.getId()) | |
714 | # |
|
722 | # | |
715 | # opObj21 = procUnitConfObj2.addOperation(name='IncohInt', optype='other') |
|
723 | # opObj21 = procUnitConfObj2.addOperation(name='IncohInt', optype='other') | |
716 | # opObj21.addParameter(name='n', value='2', format='int') |
|
724 | # opObj21.addParameter(name='n', value='2', format='int') | |
717 | # |
|
725 | # | |
718 | # opObj11 = procUnitConfObj2.addOperation(name='SpectraPlot', optype='other') |
|
726 | # opObj11 = procUnitConfObj2.addOperation(name='SpectraPlot', optype='other') | |
719 | # opObj11.addParameter(name='idfigure', value='4', format='int') |
|
727 | # opObj11.addParameter(name='idfigure', value='4', format='int') | |
720 | # opObj11.addParameter(name='wintitle', value='SpectraPlot OBJ 2', format='str') |
|
728 | # opObj11.addParameter(name='wintitle', value='SpectraPlot OBJ 2', format='str') | |
721 | # opObj11.addParameter(name='zmin', value='70', format='int') |
|
729 | # opObj11.addParameter(name='zmin', value='70', format='int') | |
722 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
730 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
723 |
|
731 | |||
724 | print "Escribiendo el archivo XML" |
|
732 | print "Escribiendo el archivo XML" | |
725 |
|
733 | |||
726 | controllerObj.writeXml(filename) |
|
734 | controllerObj.writeXml(filename) | |
727 |
|
735 | |||
728 | print "Leyendo el archivo XML" |
|
736 | print "Leyendo el archivo XML" | |
729 | controllerObj.readXml(filename) |
|
737 | controllerObj.readXml(filename) | |
730 | #controllerObj.printattr() |
|
738 | #controllerObj.printattr() | |
731 |
|
739 | |||
732 | controllerObj.createObjects() |
|
740 | controllerObj.createObjects() | |
733 | controllerObj.connectObjects() |
|
741 | controllerObj.connectObjects() | |
734 | controllerObj.run() |
|
742 | controllerObj.run() | |
735 |
|
743 | |||
736 | No newline at end of file |
|
744 |
General Comments 0
You need to be logged in to leave comments.
Login now