@@ -3,10 +3,17 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 element import prettify |
|
|||
7 | from xml.etree import ElementTree as ET |
|
6 | from xml.etree import ElementTree as ET | |
|
7 | from xml.dom import minidom | |||
|
8 | ||||
8 | import sys |
|
9 | import sys | |
9 |
|
10 | |||
|
11 | def prettify(elem): | |||
|
12 | """Return a pretty-printed XML string for the Element. | |||
|
13 | """ | |||
|
14 | rough_string = ET.tostring(elem, 'utf-8') | |||
|
15 | reparsed = minidom.parseString(rough_string) | |||
|
16 | return reparsed.toprettyxml(indent=" ") | |||
10 |
|
17 | |||
11 | #def save(a, b): |
|
18 | #def save(a, b): | |
12 | # |
|
19 | # | |
@@ -86,13 +93,24 class Project(): | |||||
86 | ElementTree(self.projectElement).write(filename, method='xml') |
|
93 | ElementTree(self.projectElement).write(filename, method='xml') | |
87 | print prettify(self.projectElement) |
|
94 | print prettify(self.projectElement) | |
88 |
|
95 | |||
89 |
def readXml(self, |
|
96 | def readXml(self, filename): | |
90 | print "Aqui estoy leyendo" |
|
97 | ||
91 |
tree=ET.parse( |
|
98 | #tree = ET.parse(filename) | |
92 | root=tree.getroot() |
|
99 | self.projectElement = None | |
93 | self.project=root.tag |
|
100 | tree = ElementTree(self.projectElement).parse(filename) | |
94 | self.idProyect= root.attrib.get('id') |
|
101 | ||
95 | self.nameProyect= root.attrib.get('name') |
|
102 | self.project = self.projectElement.tag | |
|
103 | ||||
|
104 | self.id = self.projectElement.get('id') | |||
|
105 | self.name = self.projectElement.get('name') | |||
|
106 | ||||
|
107 | readElement = self.projectElement.getiterator('readBranch') | |||
|
108 | ||||
|
109 | root = tree.getroot() | |||
|
110 | self.project = root.tag | |||
|
111 | self.id = root.attrib.get('id') | |||
|
112 | self.name = root.attrib.get('name') | |||
|
113 | ||||
96 | for description in root.findall('description'): |
|
114 | for description in root.findall('description'): | |
97 | description = description.get('description') |
|
115 | description = description.get('description') | |
98 |
|
116 | |||
@@ -108,15 +126,6 class Project(): | |||||
108 | self.idpb=id |
|
126 | self.idpb=id | |
109 | self.nameBranch=name |
|
127 | self.nameBranch=name | |
110 | # |
|
128 | # | |
111 | # |
|
|||
112 | print self.project |
|
|||
113 | print self.idProyect |
|
|||
114 | print self.nameProyect |
|
|||
115 | print self.description |
|
|||
116 | print self.idrb |
|
|||
117 | print self.idpb |
|
|||
118 | print self.nameBranch |
|
|||
119 | # |
|
|||
120 | ####ESTO DEL MEDIO ESTABA COMENTADO |
|
129 | ####ESTO DEL MEDIO ESTABA COMENTADO | |
121 | # print root.tag , root.attrib |
|
130 | # print root.tag , root.attrib | |
122 | # |
|
131 | # | |
@@ -132,7 +141,7 class Project(): | |||||
132 | # description=root.find('description').text |
|
141 | # description=root.find('description').text | |
133 | # print description |
|
142 | # print description | |
134 | # ESTO FUNCIONABA HACIA ABAJO |
|
143 | # ESTO FUNCIONABA HACIA ABAJO | |
135 | print "Otra forma " |
|
144 | ||
136 | root=tree.getroot() |
|
145 | root=tree.getroot() | |
137 | print root.tag , root.attrib |
|
146 | print root.tag , root.attrib | |
138 | for child in root: |
|
147 | for child in root: | |
@@ -331,7 +340,11 class Parameter(): | |||||
331 | parmElement = SubElement(opElement, 'Parameter') |
|
340 | parmElement = SubElement(opElement, 'Parameter') | |
332 | parmElement.set('name', self.name) |
|
341 | parmElement.set('name', self.name) | |
333 | parmElement.set('value', self.value) |
|
342 | parmElement.set('value', self.value) | |
|
343 | ||||
|
344 | def readXml(self, opElement): | |||
334 |
|
345 | |||
|
346 | ||||
|
347 | pass | |||
335 | # se = SubElement(parmElement, 'value')#ESTO ES LO ULTIMO QUE SE TRABAJO |
|
348 | # se = SubElement(parmElement, 'value')#ESTO ES LO ULTIMO QUE SE TRABAJO | |
336 | # se.text = self.value |
|
349 | # se.text = self.value | |
337 |
|
350 | |||
@@ -340,8 +353,6 if __name__ == '__main__': | |||||
340 | desc = "Este es un test" |
|
353 | desc = "Este es un test" | |
341 | filename = "test.xml" |
|
354 | filename = "test.xml" | |
342 |
|
355 | |||
343 | workspace=str("C:\\Users\\alex\\workspace\\GUIV2.0\\test.xml") |
|
|||
344 |
|
||||
345 | projectObj = Project() |
|
356 | projectObj = Project() | |
346 |
|
357 | |||
347 | projectObj.setParms(id = '11', name='test01', description=desc) |
|
358 | projectObj.setParms(id = '11', name='test01', description=desc) | |
@@ -364,7 +375,10 if __name__ == '__main__': | |||||
364 | opObj12.addParameter(name='code1', value='001110011') |
|
375 | opObj12.addParameter(name='code1', value='001110011') | |
365 | opObj12.addParameter(name='code2', value='001110011') |
|
376 | opObj12.addParameter(name='code2', value='001110011') | |
366 |
|
377 | |||
|
378 | print "Escribiendo el XML" | |||
|
379 | ||||
367 | projectObj.writeXml(filename) |
|
380 | projectObj.writeXml(filename) | |
368 |
|
381 | |||
369 | projectObj.readXml(workspace) |
|
382 | print "Leyendo el XML" | |
|
383 | projectObj.readXml(filename) | |||
370 | No newline at end of file |
|
384 |
1 | NO CONTENT: file renamed from schainpy/Controller/controller1.py to schainpy/controller/controller1.py |
|
NO CONTENT: file renamed from schainpy/Controller/controller1.py to schainpy/controller/controller1.py |
1 | NO CONTENT: file renamed from schainpy/Model/JROData.py to schainpy/model/jrodata.py |
|
NO CONTENT: file renamed from schainpy/Model/JROData.py to schainpy/model/jrodata.py |
1 | NO CONTENT: file renamed from schainpy/Model/JRODataIO.py to schainpy/model/jrodataIO.py |
|
NO CONTENT: file renamed from schainpy/Model/JRODataIO.py to schainpy/model/jrodataIO.py |
1 | NO CONTENT: file renamed from schainpy/Model/JROHeaderIO.py to schainpy/model/jroheaderIO.py |
|
NO CONTENT: file renamed from schainpy/Model/JROHeaderIO.py to schainpy/model/jroheaderIO.py |
1 | NO CONTENT: file renamed from schainpy/Model/JROPlot.py to schainpy/model/jroplot.py |
|
NO CONTENT: file renamed from schainpy/Model/JROPlot.py to schainpy/model/jroplot.py |
@@ -155,6 +155,7 class Operation(): | |||||
155 | """ |
|
155 | """ | |
156 |
|
156 | |||
157 | __buffer = None |
|
157 | __buffer = None | |
|
158 | __isConfig = False | |||
158 |
|
159 | |||
159 | def __init__(self): |
|
160 | def __init__(self): | |
160 |
|
161 | |||
@@ -255,6 +256,7 class CohInt(Operation): | |||||
255 |
|
256 | |||
256 | __byTime = False |
|
257 | __byTime = False | |
257 | __initime = None |
|
258 | __initime = None | |
|
259 | __lastdatatime = None | |||
258 | __integrationtime = None |
|
260 | __integrationtime = None | |
259 |
|
261 | |||
260 | __buffer = None |
|
262 | __buffer = None | |
@@ -266,7 +268,7 class CohInt(Operation): | |||||
266 |
|
268 | |||
267 | def __init__(self): |
|
269 | def __init__(self): | |
268 |
|
270 | |||
269 | pass |
|
271 | self.__isConfig = False | |
270 |
|
272 | |||
271 | def setup(self, nCohInt=None, timeInterval=None, overlapping=False): |
|
273 | def setup(self, nCohInt=None, timeInterval=None, overlapping=False): | |
272 | """ |
|
274 | """ | |
@@ -281,6 +283,7 class CohInt(Operation): | |||||
281 | """ |
|
283 | """ | |
282 |
|
284 | |||
283 | self.__initime = None |
|
285 | self.__initime = None | |
|
286 | self.__lastdatatime = 0 | |||
284 | self.__buffer = None |
|
287 | self.__buffer = None | |
285 | self.__dataReady = False |
|
288 | self.__dataReady = False | |
286 |
|
289 | |||
@@ -311,8 +314,6 class CohInt(Operation): | |||||
311 | Add a profile to the __buffer and increase in one the __profileIndex |
|
314 | Add a profile to the __buffer and increase in one the __profileIndex | |
312 |
|
315 | |||
313 | """ |
|
316 | """ | |
314 | if self.__initime == None: |
|
|||
315 | self.__initime = datatime |
|
|||
316 |
|
317 | |||
317 | if not self.__withOverapping: |
|
318 | if not self.__withOverapping: | |
318 | self.__buffer += data |
|
319 | self.__buffer += data | |
@@ -352,8 +353,6 class CohInt(Operation): | |||||
352 |
|
353 | |||
353 | """ |
|
354 | """ | |
354 |
|
355 | |||
355 | self.__initime = None |
|
|||
356 |
|
||||
357 | if not self.__withOverapping: |
|
356 | if not self.__withOverapping: | |
358 | data = self.__buffer |
|
357 | data = self.__buffer | |
359 | nCohInt = self.__profIndex |
|
358 | nCohInt = self.__profIndex | |
@@ -373,6 +372,7 class CohInt(Operation): | |||||
373 |
|
372 | |||
374 | self.__dataReady = False |
|
373 | self.__dataReady = False | |
375 | avg_data = None |
|
374 | avg_data = None | |
|
375 | nCohInt = None | |||
376 |
|
376 | |||
377 | self.putData(data) |
|
377 | self.putData(data) | |
378 |
|
378 | |||
@@ -387,7 +387,8 class CohInt(Operation): | |||||
387 |
|
387 | |||
388 | self.__dataReady = False |
|
388 | self.__dataReady = False | |
389 | avg_data = None |
|
389 | avg_data = None | |
390 |
|
390 | nCohInt = None | ||
|
391 | ||||
391 | self.putData(data) |
|
392 | self.putData(data) | |
392 |
|
393 | |||
393 | if (datatime - self.__initime) >= self.__integrationtime: |
|
394 | if (datatime - self.__initime) >= self.__integrationtime: | |
@@ -399,25 +400,45 class CohInt(Operation): | |||||
399 |
|
400 | |||
400 | def integrate(self, data, datatime=None): |
|
401 | def integrate(self, data, datatime=None): | |
401 |
|
402 | |||
402 |
if |
|
403 | if self.__initime == None: | |
403 | avg_data = self.byProfiles(data) |
|
404 | self.__initime = datatime | |
|
405 | ||||
|
406 | if self.__byTime: | |||
|
407 | avgdata = self.byTime(data, datatime) | |||
404 | else: |
|
408 | else: | |
405 |
avg |
|
409 | avgdata = self.byProfiles(data) | |
406 |
|
410 | |||
407 | self.data = avg_data |
|
|||
408 |
|
411 | |||
|
412 | self.__lastdatatime = datatime | |||
|
413 | ||||
|
414 | if avgdata == None: | |||
|
415 | return None | |||
|
416 | ||||
|
417 | avgdatatime = self.__initime | |||
|
418 | ||||
|
419 | deltatime = datatime -self.__lastdatatime | |||
|
420 | ||||
|
421 | if not self.__withOverapping: | |||
|
422 | self.__initime = datatime | |||
|
423 | else: | |||
|
424 | self.__initime += deltatime | |||
|
425 | ||||
|
426 | return avgdata, avgdatatime | |||
409 |
|
427 | |||
410 | def run(self, dataOut, nCohInt=None, timeInterval=None, overlapping=False): |
|
428 | def run(self, dataOut, nCohInt=None, timeInterval=None, overlapping=False): | |
411 |
|
429 | |||
|
430 | if not self.__isConfig: | |||
|
431 | self.setup(nCohInt, timeInterval, overlapping) | |||
|
432 | self.__isConfig = True | |||
|
433 | ||||
|
434 | avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime) | |||
412 |
|
435 | |||
413 | # self.dataOutObj.timeInterval *= nCohInt |
|
436 | # self.dataOutObj.timeInterval *= nCohInt | |
414 | self.dataOutObj.flagNoData = True |
|
437 | self.dataOutObj.flagNoData = True | |
415 |
|
438 | |||
416 |
if |
|
439 | if self.__dataReady: | |
417 |
|
|
440 | dataOutObj.data = avgdata | |
418 |
|
|
441 | dataOutObj.timeInterval *= self.nCohInt | |
419 |
|
|
442 | dataOutObj.nCohInt *= self.nCohInt | |
420 |
|
|
443 | dataOutObj.utctime = avgdatatime | |
421 |
|
|
444 | dataOutObj.flagNoData = False No newline at end of file | |
422 |
|
||||
423 | return avg_data No newline at end of file |
|
General Comments 0
You need to be logged in to leave comments.
Login now