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