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