##// END OF EJS Templates
Version: 2.1.3.2...
Miguel Valdez -
r672:a1a5642b5594
parent child
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -1,19 +1,23
1 VERSIONS:
1 VERSIONS:
2
2
3 2.1.2:
3 2.1.2:
4 -jroutils_ftp.py: Bug fixed, Any error sending file stopped the Server Thread
4 -jroutils_ftp.py: Bug fixed, Any error sending file stopped the Server Thread
5 Server thread opens and closes remote server each time file list is sent
5 Server thread opens and closes remote server each time file list is sent
6 -jroplot_spectra.py: Noise path was not being created saving noise data.
6 -jroplot_spectra.py: Noise path was not being created saving noise data.
7 -jroIO_base.py: startTime can be greater than endTime
7 -jroIO_base.py: startTime can be greater than endTime
8
8
9 2.1.3:
9 2.1.3:
10 -jroplot_heispectra.py: SpectraHeisScope was not showing the right channels
10 -jroplot_heispectra.py: SpectraHeisScope was not showing the right channels
11 -jroproc_voltage.py: Bug fixed selecting profiles (self.nProfiles took a wrong value),
11 -jroproc_voltage.py: Bug fixed selecting profiles (self.nProfiles took a wrong value),
12 Bug fixed selecting heights by block (selecting profiles instead heights)
12 Bug fixed selecting heights by block (selecting profiles instead heights)
13 -jroproc_voltage.py: New feature added: decoding data by block using FFT.
13 -jroproc_voltage.py: New feature added: decoding data by block using FFT.
14 -jroIO_heispectra.py: Bug fixed in FitsReader. Using local Fits object instead schainpy.mode.data.jrodata.Fits object.
14 -jroIO_heispectra.py: Bug fixed in FitsReader. Using local Fits object instead schainpy.mode.data.jrodata.Fits object.
15 -jroIO_heispectra.py: Channel index list does not exist.
15 -jroIO_heispectra.py: Channel index list does not exist.
16
16
17 2.1.3.1:
17 2.1.3.1:
18 -GUI: every icon were resized
18 -GUI: every icon were resized
19 -jroproc_voltage.py: Print a message when "Read from code" option is selected and the code is not defined inside data file
19 -jroproc_voltage.py: Print a message when "Read from code" option is selected and the code is not defined inside data file
20
21 2.1.3.2:
22 -GUI: user interaction enhanced
23 -controller_api.py: Safe access to ControllerThead No newline at end of file
@@ -1,7 +1,7
1 '''
1 '''
2 Created on Feb 7, 2012
2 Created on Feb 7, 2012
3
3
4 @author $Author$
4 @author $Author$
5 @version $Id$
5 @version $Id$
6 '''
6 '''
7 __version__ = "2.1.3.1" No newline at end of file
7 __version__ = "2.1.3.2" No newline at end of file
@@ -1,1096 +1,1142
1 '''
1 '''
2 Created on September , 2012
2 Created on September , 2012
3 @author:
3 @author:
4 '''
4 '''
5 from xml.etree.ElementTree import ElementTree, Element, SubElement, tostring
5 from xml.etree.ElementTree import ElementTree, Element, SubElement, tostring
6 from xml.dom import minidom
6 from xml.dom import minidom
7
7
8 from model import *
8 from model import *
9
9 from time import sleep
10 try:
11 from gevent import sleep
12 except:
13 from time import sleep
14
10
11 import sys
15 import ast
12 import ast
13 import traceback
14
15 SCHAIN_MAIL = "miguel.urco@jro.igp.gob.pe"
16 EMAIL_SERVER = "jro.igp.gob.pe"
16
17
17 def prettify(elem):
18 def prettify(elem):
18 """Return a pretty-printed XML string for the Element.
19 """Return a pretty-printed XML string for the Element.
19 """
20 """
20 rough_string = tostring(elem, 'utf-8')
21 rough_string = tostring(elem, 'utf-8')
21 reparsed = minidom.parseString(rough_string)
22 reparsed = minidom.parseString(rough_string)
22 return reparsed.toprettyxml(indent=" ")
23 return reparsed.toprettyxml(indent=" ")
23
24
24 class ParameterConf():
25 class ParameterConf():
25
26
26 id = None
27 id = None
27 name = None
28 name = None
28 value = None
29 value = None
29 format = None
30 format = None
30
31
31 __formated_value = None
32 __formated_value = None
32
33
33 ELEMENTNAME = 'Parameter'
34 ELEMENTNAME = 'Parameter'
34
35
35 def __init__(self):
36 def __init__(self):
36
37
37 self.format = 'str'
38 self.format = 'str'
38
39
39 def getElementName(self):
40 def getElementName(self):
40
41
41 return self.ELEMENTNAME
42 return self.ELEMENTNAME
42
43
43 def getValue(self):
44 def getValue(self):
44
45
45 value = self.value
46 value = self.value
46 format = self.format
47 format = self.format
47
48
48 if self.__formated_value != None:
49 if self.__formated_value != None:
49
50
50 return self.__formated_value
51 return self.__formated_value
51
52
52 if format == 'str':
53 if format == 'str':
53 self.__formated_value = str(value)
54 self.__formated_value = str(value)
54 return self.__formated_value
55 return self.__formated_value
55
56
56 if value == '':
57 if value == '':
57 raise ValueError, "%s: This parameter value is empty" %self.name
58 raise ValueError, "%s: This parameter value is empty" %self.name
58
59
59 if format == 'bool':
60 if format == 'bool':
60 value = int(value)
61 value = int(value)
61
62
62 if format == 'list':
63 if format == 'list':
63 strList = value.split(',')
64 strList = value.split(',')
64
65
65 self.__formated_value = strList
66 self.__formated_value = strList
66
67
67 return self.__formated_value
68 return self.__formated_value
68
69
69 if format == 'intlist':
70 if format == 'intlist':
70 """
71 """
71 Example:
72 Example:
72 value = (0,1,2)
73 value = (0,1,2)
73 """
74 """
74 value = value.replace('(', '')
75 value = value.replace('(', '')
75 value = value.replace(')', '')
76 value = value.replace(')', '')
76
77
77 value = value.replace('[', '')
78 value = value.replace('[', '')
78 value = value.replace(']', '')
79 value = value.replace(']', '')
79
80
80 strList = value.split(',')
81 strList = value.split(',')
81 intList = [int(float(x)) for x in strList]
82 intList = [int(float(x)) for x in strList]
82
83
83 self.__formated_value = intList
84 self.__formated_value = intList
84
85
85 return self.__formated_value
86 return self.__formated_value
86
87
87 if format == 'floatlist':
88 if format == 'floatlist':
88 """
89 """
89 Example:
90 Example:
90 value = (0.5, 1.4, 2.7)
91 value = (0.5, 1.4, 2.7)
91 """
92 """
92
93
93 value = value.replace('(', '')
94 value = value.replace('(', '')
94 value = value.replace(')', '')
95 value = value.replace(')', '')
95
96
96 value = value.replace('[', '')
97 value = value.replace('[', '')
97 value = value.replace(']', '')
98 value = value.replace(']', '')
98
99
99 strList = value.split(',')
100 strList = value.split(',')
100 floatList = [float(x) for x in strList]
101 floatList = [float(x) for x in strList]
101
102
102 self.__formated_value = floatList
103 self.__formated_value = floatList
103
104
104 return self.__formated_value
105 return self.__formated_value
105
106
106 if format == 'date':
107 if format == 'date':
107 strList = value.split('/')
108 strList = value.split('/')
108 intList = [int(x) for x in strList]
109 intList = [int(x) for x in strList]
109 date = datetime.date(intList[0], intList[1], intList[2])
110 date = datetime.date(intList[0], intList[1], intList[2])
110
111
111 self.__formated_value = date
112 self.__formated_value = date
112
113
113 return self.__formated_value
114 return self.__formated_value
114
115
115 if format == 'time':
116 if format == 'time':
116 strList = value.split(':')
117 strList = value.split(':')
117 intList = [int(x) for x in strList]
118 intList = [int(x) for x in strList]
118 time = datetime.time(intList[0], intList[1], intList[2])
119 time = datetime.time(intList[0], intList[1], intList[2])
119
120
120 self.__formated_value = time
121 self.__formated_value = time
121
122
122 return self.__formated_value
123 return self.__formated_value
123
124
124 if format == 'pairslist':
125 if format == 'pairslist':
125 """
126 """
126 Example:
127 Example:
127 value = (0,1),(1,2)
128 value = (0,1),(1,2)
128 """
129 """
129
130
130 value = value.replace('(', '')
131 value = value.replace('(', '')
131 value = value.replace(')', '')
132 value = value.replace(')', '')
132
133
133 value = value.replace('[', '')
134 value = value.replace('[', '')
134 value = value.replace(']', '')
135 value = value.replace(']', '')
135
136
136 strList = value.split(',')
137 strList = value.split(',')
137 intList = [int(item) for item in strList]
138 intList = [int(item) for item in strList]
138 pairList = []
139 pairList = []
139 for i in range(len(intList)/2):
140 for i in range(len(intList)/2):
140 pairList.append((intList[i*2], intList[i*2 + 1]))
141 pairList.append((intList[i*2], intList[i*2 + 1]))
141
142
142 self.__formated_value = pairList
143 self.__formated_value = pairList
143
144
144 return self.__formated_value
145 return self.__formated_value
145
146
146 if format == 'multilist':
147 if format == 'multilist':
147 """
148 """
148 Example:
149 Example:
149 value = (0,1,2),(3,4,5)
150 value = (0,1,2),(3,4,5)
150 """
151 """
151 multiList = ast.literal_eval(value)
152 multiList = ast.literal_eval(value)
152
153
153 if type(multiList[0]) == int:
154 if type(multiList[0]) == int:
154 multiList = ast.literal_eval("(" + value + ")")
155 multiList = ast.literal_eval("(" + value + ")")
155
156
156 self.__formated_value = multiList
157 self.__formated_value = multiList
157
158
158 return self.__formated_value
159 return self.__formated_value
159
160
160 format_func = eval(format)
161 format_func = eval(format)
161
162
162 self.__formated_value = format_func(value)
163 self.__formated_value = format_func(value)
163
164
164 return self.__formated_value
165 return self.__formated_value
165
166
166 def updateId(self, new_id):
167 def updateId(self, new_id):
167
168
168 self.id = str(new_id)
169 self.id = str(new_id)
169
170
170 def setup(self, id, name, value, format='str'):
171 def setup(self, id, name, value, format='str'):
171
172
172 self.id = str(id)
173 self.id = str(id)
173 self.name = name
174 self.name = name
174 self.value = str(value)
175 self.value = str(value)
175 self.format = str.lower(format)
176 self.format = str.lower(format)
176
177
177 try:
178 try:
178 self.getValue()
179 self.getValue()
179 except:
180 except:
180 return 0
181 return 0
181
182
182 return 1
183 return 1
183
184
184 def update(self, name, value, format='str'):
185 def update(self, name, value, format='str'):
185
186
186 self.name = name
187 self.name = name
187 self.value = str(value)
188 self.value = str(value)
188 self.format = format
189 self.format = format
189
190
190 def makeXml(self, opElement):
191 def makeXml(self, opElement):
191
192
192 parmElement = SubElement(opElement, self.ELEMENTNAME)
193 parmElement = SubElement(opElement, self.ELEMENTNAME)
193 parmElement.set('id', str(self.id))
194 parmElement.set('id', str(self.id))
194 parmElement.set('name', self.name)
195 parmElement.set('name', self.name)
195 parmElement.set('value', self.value)
196 parmElement.set('value', self.value)
196 parmElement.set('format', self.format)
197 parmElement.set('format', self.format)
197
198
198 def readXml(self, parmElement):
199 def readXml(self, parmElement):
199
200
200 self.id = parmElement.get('id')
201 self.id = parmElement.get('id')
201 self.name = parmElement.get('name')
202 self.name = parmElement.get('name')
202 self.value = parmElement.get('value')
203 self.value = parmElement.get('value')
203 self.format = str.lower(parmElement.get('format'))
204 self.format = str.lower(parmElement.get('format'))
204
205
205 #Compatible with old signal chain version
206 #Compatible with old signal chain version
206 if self.format == 'int' and self.name == 'idfigure':
207 if self.format == 'int' and self.name == 'idfigure':
207 self.name = 'id'
208 self.name = 'id'
208
209
209 def printattr(self):
210 def printattr(self):
210
211
211 print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format)
212 print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format)
212
213
213 class OperationConf():
214 class OperationConf():
214
215
215 id = None
216 id = None
216 name = None
217 name = None
217 priority = None
218 priority = None
218 type = None
219 type = None
219
220
220 parmConfObjList = []
221 parmConfObjList = []
221
222
222 ELEMENTNAME = 'Operation'
223 ELEMENTNAME = 'Operation'
223
224
224 def __init__(self):
225 def __init__(self):
225
226
226 self.id = '0'
227 self.id = '0'
227 self.name = None
228 self.name = None
228 self.priority = None
229 self.priority = None
229 self.type = 'self'
230 self.type = 'self'
230
231
231
232
232 def __getNewId(self):
233 def __getNewId(self):
233
234
234 return int(self.id)*10 + len(self.parmConfObjList) + 1
235 return int(self.id)*10 + len(self.parmConfObjList) + 1
235
236
236 def updateId(self, new_id):
237 def updateId(self, new_id):
237
238
238 self.id = str(new_id)
239 self.id = str(new_id)
239
240
240 n = 1
241 n = 1
241 for parmObj in self.parmConfObjList:
242 for parmObj in self.parmConfObjList:
242
243
243 idParm = str(int(new_id)*10 + n)
244 idParm = str(int(new_id)*10 + n)
244 parmObj.updateId(idParm)
245 parmObj.updateId(idParm)
245
246
246 n += 1
247 n += 1
247
248
248 def getElementName(self):
249 def getElementName(self):
249
250
250 return self.ELEMENTNAME
251 return self.ELEMENTNAME
251
252
252 def getParameterObjList(self):
253 def getParameterObjList(self):
253
254
254 return self.parmConfObjList
255 return self.parmConfObjList
255
256
256 def getParameterObj(self, parameterName):
257 def getParameterObj(self, parameterName):
257
258
258 for parmConfObj in self.parmConfObjList:
259 for parmConfObj in self.parmConfObjList:
259
260
260 if parmConfObj.name != parameterName:
261 if parmConfObj.name != parameterName:
261 continue
262 continue
262
263
263 return parmConfObj
264 return parmConfObj
264
265
265 return None
266 return None
266
267
267 def getParameterObjfromValue(self, parameterValue):
268 def getParameterObjfromValue(self, parameterValue):
268
269
269 for parmConfObj in self.parmConfObjList:
270 for parmConfObj in self.parmConfObjList:
270
271
271 if parmConfObj.getValue() != parameterValue:
272 if parmConfObj.getValue() != parameterValue:
272 continue
273 continue
273
274
274 return parmConfObj.getValue()
275 return parmConfObj.getValue()
275
276
276 return None
277 return None
277
278
278 def getParameterValue(self, parameterName):
279 def getParameterValue(self, parameterName):
279
280
280 parameterObj = self.getParameterObj(parameterName)
281 parameterObj = self.getParameterObj(parameterName)
281
282
282 # if not parameterObj:
283 # if not parameterObj:
283 # return None
284 # return None
284
285
285 value = parameterObj.getValue()
286 value = parameterObj.getValue()
286
287
287 return value
288 return value
288
289
289 def setup(self, id, name, priority, type):
290 def setup(self, id, name, priority, type):
290
291
291 self.id = str(id)
292 self.id = str(id)
292 self.name = name
293 self.name = name
293 self.type = type
294 self.type = type
294 self.priority = priority
295 self.priority = priority
295
296
296 self.parmConfObjList = []
297 self.parmConfObjList = []
297
298
298 def removeParameters(self):
299 def removeParameters(self):
299
300
300 for obj in self.parmConfObjList:
301 for obj in self.parmConfObjList:
301 del obj
302 del obj
302
303
303 self.parmConfObjList = []
304 self.parmConfObjList = []
304
305
305 def addParameter(self, name, value, format='str'):
306 def addParameter(self, name, value, format='str'):
306
307
307 id = self.__getNewId()
308 id = self.__getNewId()
308
309
309 parmConfObj = ParameterConf()
310 parmConfObj = ParameterConf()
310 if not parmConfObj.setup(id, name, value, format):
311 if not parmConfObj.setup(id, name, value, format):
311 return None
312 return None
312
313
313 self.parmConfObjList.append(parmConfObj)
314 self.parmConfObjList.append(parmConfObj)
314
315
315 return parmConfObj
316 return parmConfObj
316
317
317 def changeParameter(self, name, value, format='str'):
318 def changeParameter(self, name, value, format='str'):
318
319
319 parmConfObj = self.getParameterObj(name)
320 parmConfObj = self.getParameterObj(name)
320 parmConfObj.update(name, value, format)
321 parmConfObj.update(name, value, format)
321
322
322 return parmConfObj
323 return parmConfObj
323
324
324 def makeXml(self, upElement):
325 def makeXml(self, upElement):
325
326
326 opElement = SubElement(upElement, self.ELEMENTNAME)
327 opElement = SubElement(upElement, self.ELEMENTNAME)
327 opElement.set('id', str(self.id))
328 opElement.set('id', str(self.id))
328 opElement.set('name', self.name)
329 opElement.set('name', self.name)
329 opElement.set('type', self.type)
330 opElement.set('type', self.type)
330 opElement.set('priority', str(self.priority))
331 opElement.set('priority', str(self.priority))
331
332
332 for parmConfObj in self.parmConfObjList:
333 for parmConfObj in self.parmConfObjList:
333 parmConfObj.makeXml(opElement)
334 parmConfObj.makeXml(opElement)
334
335
335 def readXml(self, opElement):
336 def readXml(self, opElement):
336
337
337 self.id = opElement.get('id')
338 self.id = opElement.get('id')
338 self.name = opElement.get('name')
339 self.name = opElement.get('name')
339 self.type = opElement.get('type')
340 self.type = opElement.get('type')
340 self.priority = opElement.get('priority')
341 self.priority = opElement.get('priority')
341
342
342 #Compatible with old signal chain version
343 #Compatible with old signal chain version
343 #Use of 'run' method instead 'init'
344 #Use of 'run' method instead 'init'
344 if self.type == 'self' and self.name == 'init':
345 if self.type == 'self' and self.name == 'init':
345 self.name = 'run'
346 self.name = 'run'
346
347
347 self.parmConfObjList = []
348 self.parmConfObjList = []
348
349
349 parmElementList = opElement.getiterator(ParameterConf().getElementName())
350 parmElementList = opElement.getiterator(ParameterConf().getElementName())
350
351
351 for parmElement in parmElementList:
352 for parmElement in parmElementList:
352 parmConfObj = ParameterConf()
353 parmConfObj = ParameterConf()
353 parmConfObj.readXml(parmElement)
354 parmConfObj.readXml(parmElement)
354
355
355 #Compatible with old signal chain version
356 #Compatible with old signal chain version
356 #If an 'plot' OPERATION is found, changes name operation by the value of its type PARAMETER
357 #If an 'plot' OPERATION is found, changes name operation by the value of its type PARAMETER
357 if self.type != 'self' and self.name == 'Plot':
358 if self.type != 'self' and self.name == 'Plot':
358 if parmConfObj.format == 'str' and parmConfObj.name == 'type':
359 if parmConfObj.format == 'str' and parmConfObj.name == 'type':
359 self.name = parmConfObj.value
360 self.name = parmConfObj.value
360 continue
361 continue
361
362
362 self.parmConfObjList.append(parmConfObj)
363 self.parmConfObjList.append(parmConfObj)
363
364
364 def printattr(self):
365 def printattr(self):
365
366
366 print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME,
367 print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME,
367 self.id,
368 self.id,
368 self.name,
369 self.name,
369 self.type,
370 self.type,
370 self.priority)
371 self.priority)
371
372
372 for parmConfObj in self.parmConfObjList:
373 for parmConfObj in self.parmConfObjList:
373 parmConfObj.printattr()
374 parmConfObj.printattr()
374
375
375 def createObject(self):
376 def createObject(self):
376
377
377 if self.type == 'self':
378 if self.type == 'self':
378 raise ValueError, "This operation type cannot be created"
379 raise ValueError, "This operation type cannot be created"
379
380
380 if self.type == 'external' or self.type == 'other':
381 if self.type == 'external' or self.type == 'other':
381 className = eval(self.name)
382 className = eval(self.name)
382 opObj = className()
383 opObj = className()
383
384
384 return opObj
385 return opObj
385
386
386 class ProcUnitConf():
387 class ProcUnitConf():
387
388
388 id = None
389 id = None
389 name = None
390 name = None
390 datatype = None
391 datatype = None
391 inputId = None
392 inputId = None
392 parentId = None
393 parentId = None
393
394
394 opConfObjList = []
395 opConfObjList = []
395
396
396 procUnitObj = None
397 procUnitObj = None
397 opObjList = []
398 opObjList = []
398
399
399 ELEMENTNAME = 'ProcUnit'
400 ELEMENTNAME = 'ProcUnit'
400
401
401 def __init__(self):
402 def __init__(self):
402
403
403 self.id = None
404 self.id = None
404 self.datatype = None
405 self.datatype = None
405 self.name = None
406 self.name = None
406 self.inputId = None
407 self.inputId = None
407
408
408 self.opConfObjList = []
409 self.opConfObjList = []
409
410
410 self.procUnitObj = None
411 self.procUnitObj = None
411 self.opObjDict = {}
412 self.opObjDict = {}
412
413
413 def __getPriority(self):
414 def __getPriority(self):
414
415
415 return len(self.opConfObjList)+1
416 return len(self.opConfObjList)+1
416
417
417 def __getNewId(self):
418 def __getNewId(self):
418
419
419 return int(self.id)*10 + len(self.opConfObjList) + 1
420 return int(self.id)*10 + len(self.opConfObjList) + 1
420
421
421 def getElementName(self):
422 def getElementName(self):
422
423
423 return self.ELEMENTNAME
424 return self.ELEMENTNAME
424
425
425 def getId(self):
426 def getId(self):
426
427
427 return self.id
428 return self.id
428
429
429 def updateId(self, new_id, parentId=parentId):
430 def updateId(self, new_id, parentId=parentId):
430
431
431
432
432 new_id = int(parentId)*10 + (int(self.id) % 10)
433 new_id = int(parentId)*10 + (int(self.id) % 10)
433 new_inputId = int(parentId)*10 + (int(self.inputId) % 10)
434 new_inputId = int(parentId)*10 + (int(self.inputId) % 10)
434
435
435 #If this proc unit has not inputs
436 #If this proc unit has not inputs
436 if self.inputId == '0':
437 if self.inputId == '0':
437 new_inputId = 0
438 new_inputId = 0
438
439
439 n = 1
440 n = 1
440 for opConfObj in self.opConfObjList:
441 for opConfObj in self.opConfObjList:
441
442
442 idOp = str(int(new_id)*10 + n)
443 idOp = str(int(new_id)*10 + n)
443 opConfObj.updateId(idOp)
444 opConfObj.updateId(idOp)
444
445
445 n += 1
446 n += 1
446
447
447 self.parentId = str(parentId)
448 self.parentId = str(parentId)
448 self.id = str(new_id)
449 self.id = str(new_id)
449 self.inputId = str(new_inputId)
450 self.inputId = str(new_inputId)
450
451
451
452
452 def getInputId(self):
453 def getInputId(self):
453
454
454 return self.inputId
455 return self.inputId
455
456
456 def getOperationObjList(self):
457 def getOperationObjList(self):
457
458
458 return self.opConfObjList
459 return self.opConfObjList
459
460
460 def getOperationObj(self, name=None):
461 def getOperationObj(self, name=None):
461
462
462 for opConfObj in self.opConfObjList:
463 for opConfObj in self.opConfObjList:
463
464
464 if opConfObj.name != name:
465 if opConfObj.name != name:
465 continue
466 continue
466
467
467 return opConfObj
468 return opConfObj
468
469
469 return None
470 return None
470
471
471 def getOpObjfromParamValue(self, value=None):
472 def getOpObjfromParamValue(self, value=None):
472
473
473 for opConfObj in self.opConfObjList:
474 for opConfObj in self.opConfObjList:
474 if opConfObj.getParameterObjfromValue(parameterValue=value) != value:
475 if opConfObj.getParameterObjfromValue(parameterValue=value) != value:
475 continue
476 continue
476 return opConfObj
477 return opConfObj
477 return None
478 return None
478
479
479 def getProcUnitObj(self):
480 def getProcUnitObj(self):
480
481
481 return self.procUnitObj
482 return self.procUnitObj
482
483
483 def setup(self, id, name, datatype, inputId, parentId=None):
484 def setup(self, id, name, datatype, inputId, parentId=None):
484
485
485 #Compatible with old signal chain version
486 #Compatible with old signal chain version
486 if datatype==None and name==None:
487 if datatype==None and name==None:
487 raise ValueError, "datatype or name should be defined"
488 raise ValueError, "datatype or name should be defined"
488
489
489 if name==None:
490 if name==None:
490 if 'Proc' in datatype:
491 if 'Proc' in datatype:
491 name = datatype
492 name = datatype
492 else:
493 else:
493 name = '%sProc' %(datatype)
494 name = '%sProc' %(datatype)
494
495
495 if datatype==None:
496 if datatype==None:
496 datatype = name.replace('Proc','')
497 datatype = name.replace('Proc','')
497
498
498 self.id = str(id)
499 self.id = str(id)
499 self.name = name
500 self.name = name
500 self.datatype = datatype
501 self.datatype = datatype
501 self.inputId = inputId
502 self.inputId = inputId
502 self.parentId = parentId
503 self.parentId = parentId
503
504
504 self.opConfObjList = []
505 self.opConfObjList = []
505
506
506 self.addOperation(name='run', optype='self')
507 self.addOperation(name='run', optype='self')
507
508
508 def removeOperations(self):
509 def removeOperations(self):
509
510
510 for obj in self.opConfObjList:
511 for obj in self.opConfObjList:
511 del obj
512 del obj
512
513
513 self.opConfObjList = []
514 self.opConfObjList = []
514 self.addOperation(name='run')
515 self.addOperation(name='run')
515
516
516 def addParameter(self, **kwargs):
517 def addParameter(self, **kwargs):
517 '''
518 '''
518 Add parameters to "run" operation
519 Add parameters to "run" operation
519 '''
520 '''
520 opObj = self.opConfObjList[0]
521 opObj = self.opConfObjList[0]
521
522
522 opObj.addParameter(**kwargs)
523 opObj.addParameter(**kwargs)
523
524
524 return opObj
525 return opObj
525
526
526 def addOperation(self, name, optype='self'):
527 def addOperation(self, name, optype='self'):
527
528
528 id = self.__getNewId()
529 id = self.__getNewId()
529 priority = self.__getPriority()
530 priority = self.__getPriority()
530
531
531 opConfObj = OperationConf()
532 opConfObj = OperationConf()
532 opConfObj.setup(id, name=name, priority=priority, type=optype)
533 opConfObj.setup(id, name=name, priority=priority, type=optype)
533
534
534 self.opConfObjList.append(opConfObj)
535 self.opConfObjList.append(opConfObj)
535
536
536 return opConfObj
537 return opConfObj
537
538
538 def makeXml(self, procUnitElement):
539 def makeXml(self, procUnitElement):
539
540
540 upElement = SubElement(procUnitElement, self.ELEMENTNAME)
541 upElement = SubElement(procUnitElement, self.ELEMENTNAME)
541 upElement.set('id', str(self.id))
542 upElement.set('id', str(self.id))
542 upElement.set('name', self.name)
543 upElement.set('name', self.name)
543 upElement.set('datatype', self.datatype)
544 upElement.set('datatype', self.datatype)
544 upElement.set('inputId', str(self.inputId))
545 upElement.set('inputId', str(self.inputId))
545
546
546 for opConfObj in self.opConfObjList:
547 for opConfObj in self.opConfObjList:
547 opConfObj.makeXml(upElement)
548 opConfObj.makeXml(upElement)
548
549
549 def readXml(self, upElement):
550 def readXml(self, upElement):
550
551
551 self.id = upElement.get('id')
552 self.id = upElement.get('id')
552 self.name = upElement.get('name')
553 self.name = upElement.get('name')
553 self.datatype = upElement.get('datatype')
554 self.datatype = upElement.get('datatype')
554 self.inputId = upElement.get('inputId')
555 self.inputId = upElement.get('inputId')
555
556
556 if self.ELEMENTNAME == "ReadUnit":
557 if self.ELEMENTNAME == "ReadUnit":
557 self.datatype = self.datatype.replace("Reader", "")
558 self.datatype = self.datatype.replace("Reader", "")
558
559
559 if self.ELEMENTNAME == "ProcUnit":
560 if self.ELEMENTNAME == "ProcUnit":
560 self.datatype = self.datatype.replace("Proc", "")
561 self.datatype = self.datatype.replace("Proc", "")
561
562
562 if self.inputId == 'None':
563 if self.inputId == 'None':
563 self.inputId = '0'
564 self.inputId = '0'
564
565
565 self.opConfObjList = []
566 self.opConfObjList = []
566
567
567 opElementList = upElement.getiterator(OperationConf().getElementName())
568 opElementList = upElement.getiterator(OperationConf().getElementName())
568
569
569 for opElement in opElementList:
570 for opElement in opElementList:
570 opConfObj = OperationConf()
571 opConfObj = OperationConf()
571 opConfObj.readXml(opElement)
572 opConfObj.readXml(opElement)
572 self.opConfObjList.append(opConfObj)
573 self.opConfObjList.append(opConfObj)
573
574
574 def printattr(self):
575 def printattr(self):
575
576
576 print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME,
577 print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME,
577 self.id,
578 self.id,
578 self.name,
579 self.name,
579 self.datatype,
580 self.datatype,
580 self.inputId)
581 self.inputId)
581
582
582 for opConfObj in self.opConfObjList:
583 for opConfObj in self.opConfObjList:
583 opConfObj.printattr()
584 opConfObj.printattr()
584
585
585 def createObjects(self):
586 def createObjects(self):
586
587
587 className = eval(self.name)
588 className = eval(self.name)
588 procUnitObj = className()
589 procUnitObj = className()
589
590
590 for opConfObj in self.opConfObjList:
591 for opConfObj in self.opConfObjList:
591
592
592 if opConfObj.type == 'self':
593 if opConfObj.type == 'self':
593 continue
594 continue
594
595
595 opObj = opConfObj.createObject()
596 opObj = opConfObj.createObject()
596
597
597 self.opObjDict[opConfObj.id] = opObj
598 self.opObjDict[opConfObj.id] = opObj
598 procUnitObj.addOperation(opObj, opConfObj.id)
599 procUnitObj.addOperation(opObj, opConfObj.id)
599
600
600 self.procUnitObj = procUnitObj
601 self.procUnitObj = procUnitObj
601
602
602 return procUnitObj
603 return procUnitObj
603
604
604 def run(self):
605 def run(self):
605
606
606 finalSts = False
607 is_ok = False
607
608
608 for opConfObj in self.opConfObjList:
609 for opConfObj in self.opConfObjList:
609
610
610 kwargs = {}
611 kwargs = {}
611 for parmConfObj in opConfObj.getParameterObjList():
612 for parmConfObj in opConfObj.getParameterObjList():
612 if opConfObj.name == 'run' and parmConfObj.name == 'datatype':
613 if opConfObj.name == 'run' and parmConfObj.name == 'datatype':
613 continue
614 continue
614
615
615 kwargs[parmConfObj.name] = parmConfObj.getValue()
616 kwargs[parmConfObj.name] = parmConfObj.getValue()
616
617
617 #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id)
618 #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id)
618 sts = self.procUnitObj.call(opType = opConfObj.type,
619 sts = self.procUnitObj.call(opType = opConfObj.type,
619 opName = opConfObj.name,
620 opName = opConfObj.name,
620 opId = opConfObj.id,
621 opId = opConfObj.id,
621 **kwargs)
622 **kwargs)
622 finalSts = finalSts or sts
623 is_ok = is_ok or sts
623
624
624 return finalSts
625 return is_ok
625
626
626 def close(self):
627 def close(self):
627
628
628 for opConfObj in self.opConfObjList:
629 for opConfObj in self.opConfObjList:
629 if opConfObj.type == 'self':
630 if opConfObj.type == 'self':
630 continue
631 continue
631
632
632 opObj = self.procUnitObj.getOperationObj(opConfObj.id)
633 opObj = self.procUnitObj.getOperationObj(opConfObj.id)
633 opObj.close()
634 opObj.close()
634
635
635 self.procUnitObj.close()
636 self.procUnitObj.close()
636
637
637 return
638 return
638
639
639 class ReadUnitConf(ProcUnitConf):
640 class ReadUnitConf(ProcUnitConf):
640
641
641 path = None
642 path = None
642 startDate = None
643 startDate = None
643 endDate = None
644 endDate = None
644 startTime = None
645 startTime = None
645 endTime = None
646 endTime = None
646
647
647 ELEMENTNAME = 'ReadUnit'
648 ELEMENTNAME = 'ReadUnit'
648
649
649 def __init__(self):
650 def __init__(self):
650
651
651 self.id = None
652 self.id = None
652 self.datatype = None
653 self.datatype = None
653 self.name = None
654 self.name = None
654 self.inputId = None
655 self.inputId = None
655
656
656 self.parentId = None
657 self.parentId = None
657
658
658 self.opConfObjList = []
659 self.opConfObjList = []
659 self.opObjList = []
660 self.opObjList = []
660
661
661 def getElementName(self):
662 def getElementName(self):
662
663
663 return self.ELEMENTNAME
664 return self.ELEMENTNAME
664
665
665 def setup(self, id, name, datatype, path, startDate="", endDate="", startTime="", endTime="", parentId=None, **kwargs):
666 def setup(self, id, name, datatype, path, startDate="", endDate="", startTime="", endTime="", parentId=None, **kwargs):
666
667
667 #Compatible with old signal chain version
668 #Compatible with old signal chain version
668 if datatype==None and name==None:
669 if datatype==None and name==None:
669 raise ValueError, "datatype or name should be defined"
670 raise ValueError, "datatype or name should be defined"
670
671
671 if name==None:
672 if name==None:
672 if 'Reader' in datatype:
673 if 'Reader' in datatype:
673 name = datatype
674 name = datatype
674 else:
675 else:
675 name = '%sReader' %(datatype)
676 name = '%sReader' %(datatype)
676
677
677 if datatype==None:
678 if datatype==None:
678 datatype = name.replace('Reader','')
679 datatype = name.replace('Reader','')
679
680
680 self.id = id
681 self.id = id
681 self.name = name
682 self.name = name
682 self.datatype = datatype
683 self.datatype = datatype
683
684
684 self.path = path
685 self.path = path
685 self.startDate = startDate
686 self.startDate = startDate
686 self.endDate = endDate
687 self.endDate = endDate
687 self.startTime = startTime
688 self.startTime = startTime
688 self.endTime = endTime
689 self.endTime = endTime
689
690
690 self.inputId = '0'
691 self.inputId = '0'
691 self.parentId = parentId
692 self.parentId = parentId
692
693
693 self.addRunOperation(**kwargs)
694 self.addRunOperation(**kwargs)
694
695
695 def update(self, datatype, path, startDate, endDate, startTime, endTime, parentId=None, name=None, **kwargs):
696 def update(self, datatype, path, startDate, endDate, startTime, endTime, parentId=None, name=None, **kwargs):
696
697
697 #Compatible with old signal chain version
698 #Compatible with old signal chain version
698 if datatype==None and name==None:
699 if datatype==None and name==None:
699 raise ValueError, "datatype or name should be defined"
700 raise ValueError, "datatype or name should be defined"
700
701
701 if name==None:
702 if name==None:
702 if 'Reader' in datatype:
703 if 'Reader' in datatype:
703 name = datatype
704 name = datatype
704 else:
705 else:
705 name = '%sReader' %(datatype)
706 name = '%sReader' %(datatype)
706
707
707 if datatype==None:
708 if datatype==None:
708 datatype = name.replace('Reader','')
709 datatype = name.replace('Reader','')
709
710
710 self.datatype = datatype
711 self.datatype = datatype
711 self.name = name
712 self.name = name
712 self.path = path
713 self.path = path
713 self.startDate = startDate
714 self.startDate = startDate
714 self.endDate = endDate
715 self.endDate = endDate
715 self.startTime = startTime
716 self.startTime = startTime
716 self.endTime = endTime
717 self.endTime = endTime
717
718
718 self.inputId = '0'
719 self.inputId = '0'
719 self.parentId = parentId
720 self.parentId = parentId
720
721
721 self.updateRunOperation(**kwargs)
722 self.updateRunOperation(**kwargs)
722
723
723 def addRunOperation(self, **kwargs):
724 def addRunOperation(self, **kwargs):
724
725
725 opObj = self.addOperation(name = 'run', optype = 'self')
726 opObj = self.addOperation(name = 'run', optype = 'self')
726
727
727 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
728 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
728 opObj.addParameter(name='path' , value=self.path, format='str')
729 opObj.addParameter(name='path' , value=self.path, format='str')
729 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
730 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
730 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
731 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
731 opObj.addParameter(name='startTime' , value=self.startTime, format='time')
732 opObj.addParameter(name='startTime' , value=self.startTime, format='time')
732 opObj.addParameter(name='endTime' , value=self.endTime, format='time')
733 opObj.addParameter(name='endTime' , value=self.endTime, format='time')
733
734
734 for key, value in kwargs.items():
735 for key, value in kwargs.items():
735 opObj.addParameter(name=key, value=value, format=type(value).__name__)
736 opObj.addParameter(name=key, value=value, format=type(value).__name__)
736
737
737 return opObj
738 return opObj
738
739
739 def updateRunOperation(self, **kwargs):
740 def updateRunOperation(self, **kwargs):
740
741
741 opObj = self.getOperationObj(name = 'run')
742 opObj = self.getOperationObj(name = 'run')
742 opObj.removeParameters()
743 opObj.removeParameters()
743
744
744 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
745 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
745 opObj.addParameter(name='path' , value=self.path, format='str')
746 opObj.addParameter(name='path' , value=self.path, format='str')
746 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
747 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
747 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
748 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
748 opObj.addParameter(name='startTime' , value=self.startTime, format='time')
749 opObj.addParameter(name='startTime' , value=self.startTime, format='time')
749 opObj.addParameter(name='endTime' , value=self.endTime, format='time')
750 opObj.addParameter(name='endTime' , value=self.endTime, format='time')
750
751
751 for key, value in kwargs.items():
752 for key, value in kwargs.items():
752 opObj.addParameter(name=key, value=value, format=type(value).__name__)
753 opObj.addParameter(name=key, value=value, format=type(value).__name__)
753
754
754 return opObj
755 return opObj
755
756
756 class Project():
757 class Project():
757
758
758 id = None
759 id = None
759 name = None
760 name = None
760 description = None
761 description = None
761 # readUnitConfObjList = None
762 # readUnitConfObjList = None
762 procUnitConfObjDict = None
763 procUnitConfObjDict = None
763
764
764 ELEMENTNAME = 'Project'
765 ELEMENTNAME = 'Project'
765
766
766 def __init__(self, control=None, dataq=None):
767 def __init__(self):
767
768
768 self.id = None
769 self.id = None
769 self.name = None
770 self.name = None
770 self.description = None
771 self.description = None
771
772
772 self.procUnitConfObjDict = {}
773 self.procUnitConfObjDict = {}
773
774
774 #global data_q
775 #data_q = dataq
776
777 if control==None:
778 control = {'stop':False,'pause':False}
779
780 self.control = control
781
782 def __getNewId(self):
775 def __getNewId(self):
783
776
784 id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1
777 id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1
785
778
786 return str(id)
779 return str(id)
787
780
788 def getElementName(self):
781 def getElementName(self):
789
782
790 return self.ELEMENTNAME
783 return self.ELEMENTNAME
791
784
792 def getId(self):
785 def getId(self):
793
786
794 return self.id
787 return self.id
795
788
796 def updateId(self, new_id):
789 def updateId(self, new_id):
797
790
798 self.id = str(new_id)
791 self.id = str(new_id)
799
792
800 keyList = self.procUnitConfObjDict.keys()
793 keyList = self.procUnitConfObjDict.keys()
801 keyList.sort()
794 keyList.sort()
802
795
803 n = 1
796 n = 1
804 newProcUnitConfObjDict = {}
797 newProcUnitConfObjDict = {}
805
798
806 for procKey in keyList:
799 for procKey in keyList:
807
800
808 procUnitConfObj = self.procUnitConfObjDict[procKey]
801 procUnitConfObj = self.procUnitConfObjDict[procKey]
809 idProcUnit = str(int(self.id)*10 + n)
802 idProcUnit = str(int(self.id)*10 + n)
810 procUnitConfObj.updateId(idProcUnit, parentId = self.id)
803 procUnitConfObj.updateId(idProcUnit, parentId = self.id)
811
804
812 newProcUnitConfObjDict[idProcUnit] = procUnitConfObj
805 newProcUnitConfObjDict[idProcUnit] = procUnitConfObj
813 n += 1
806 n += 1
814
807
815 self.procUnitConfObjDict = newProcUnitConfObjDict
808 self.procUnitConfObjDict = newProcUnitConfObjDict
816
809
817 def setup(self, id, name, description):
810 def setup(self, id, name, description):
818
811
819 self.id = str(id)
812 self.id = str(id)
820 self.name = name
813 self.name = name
821 self.description = description
814 self.description = description
822
815
823 def update(self, name, description):
816 def update(self, name, description):
824
817
825 self.name = name
818 self.name = name
826 self.description = description
819 self.description = description
827
820
828 def addReadUnit(self, datatype=None, name=None, **kwargs):
821 def addReadUnit(self, datatype=None, name=None, **kwargs):
829
822
830 idReadUnit = self.__getNewId()
823 idReadUnit = self.__getNewId()
831
824
832 readUnitConfObj = ReadUnitConf()
825 readUnitConfObj = ReadUnitConf()
833 readUnitConfObj.setup(idReadUnit, name, datatype, parentId=self.id, **kwargs)
826 readUnitConfObj.setup(idReadUnit, name, datatype, parentId=self.id, **kwargs)
834
827
835 self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
828 self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
836
829
837 return readUnitConfObj
830 return readUnitConfObj
838
831
839 def addProcUnit(self, inputId='0', datatype=None, name=None):
832 def addProcUnit(self, inputId='0', datatype=None, name=None):
840
833
841 idProcUnit = self.__getNewId()
834 idProcUnit = self.__getNewId()
842
835
843 procUnitConfObj = ProcUnitConf()
836 procUnitConfObj = ProcUnitConf()
844 procUnitConfObj.setup(idProcUnit, name, datatype, inputId, parentId=self.id)
837 procUnitConfObj.setup(idProcUnit, name, datatype, inputId, parentId=self.id)
845
838
846 self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
839 self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
847
840
848 return procUnitConfObj
841 return procUnitConfObj
849
842
850 def removeProcUnit(self, id):
843 def removeProcUnit(self, id):
851
844
852 if id in self.procUnitConfObjDict.keys():
845 if id in self.procUnitConfObjDict.keys():
853 self.procUnitConfObjDict.pop(id)
846 self.procUnitConfObjDict.pop(id)
854
847
855 def getReadUnitId(self):
848 def getReadUnitId(self):
856
849
857 readUnitConfObj = self.getReadUnitObj()
850 readUnitConfObj = self.getReadUnitObj()
858
851
859 return readUnitConfObj.id
852 return readUnitConfObj.id
860
853
861 def getReadUnitObj(self):
854 def getReadUnitObj(self):
862
855
863 for obj in self.procUnitConfObjDict.values():
856 for obj in self.procUnitConfObjDict.values():
864 if obj.getElementName() == "ReadUnit":
857 if obj.getElementName() == "ReadUnit":
865 return obj
858 return obj
866
859
867 return None
860 return None
868
861
869 def getProcUnitObj(self, id=None, name=None):
862 def getProcUnitObj(self, id=None, name=None):
870
863
871 if id != None:
864 if id != None:
872 return self.procUnitConfObjDict[id]
865 return self.procUnitConfObjDict[id]
873
866
874 if name != None:
867 if name != None:
875 return self.getProcUnitObjByName(name)
868 return self.getProcUnitObjByName(name)
876
869
877 return None
870 return None
878
871
879 def getProcUnitObjByName(self, name):
872 def getProcUnitObjByName(self, name):
880
873
881 for obj in self.procUnitConfObjDict.values():
874 for obj in self.procUnitConfObjDict.values():
882 if obj.name == name:
875 if obj.name == name:
883 return obj
876 return obj
884
877
885 return None
878 return None
886
879
887 def procUnitItems(self):
880 def procUnitItems(self):
888
881
889 return self.procUnitConfObjDict.items()
882 return self.procUnitConfObjDict.items()
890
883
891 def makeXml(self):
884 def makeXml(self):
892
885
893 projectElement = Element('Project')
886 projectElement = Element('Project')
894 projectElement.set('id', str(self.id))
887 projectElement.set('id', str(self.id))
895 projectElement.set('name', self.name)
888 projectElement.set('name', self.name)
896 projectElement.set('description', self.description)
889 projectElement.set('description', self.description)
897
890
898 for procUnitConfObj in self.procUnitConfObjDict.values():
891 for procUnitConfObj in self.procUnitConfObjDict.values():
899 procUnitConfObj.makeXml(projectElement)
892 procUnitConfObj.makeXml(projectElement)
900
893
901 self.projectElement = projectElement
894 self.projectElement = projectElement
902
895
903 def writeXml(self, filename):
896 def writeXml(self, filename):
904
897
905 self.makeXml()
898 self.makeXml()
906
899
907 #print prettify(self.projectElement)
900 #print prettify(self.projectElement)
908
901
909 ElementTree(self.projectElement).write(filename, method='xml')
902 ElementTree(self.projectElement).write(filename, method='xml')
910
903
911 def readXml(self, filename):
904 def readXml(self, filename):
912
905
913 self.projectElement = None
906 self.projectElement = None
914 self.procUnitConfObjDict = {}
907 self.procUnitConfObjDict = {}
915
908
916 self.projectElement = ElementTree().parse(filename)
909 self.projectElement = ElementTree().parse(filename)
917
910
918 self.project = self.projectElement.tag
911 self.project = self.projectElement.tag
919
912
920 self.id = self.projectElement.get('id')
913 self.id = self.projectElement.get('id')
921 self.name = self.projectElement.get('name')
914 self.name = self.projectElement.get('name')
922 self.description = self.projectElement.get('description')
915 self.description = self.projectElement.get('description')
923
916
924 readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName())
917 readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName())
925
918
926 for readUnitElement in readUnitElementList:
919 for readUnitElement in readUnitElementList:
927 readUnitConfObj = ReadUnitConf()
920 readUnitConfObj = ReadUnitConf()
928 readUnitConfObj.readXml(readUnitElement)
921 readUnitConfObj.readXml(readUnitElement)
929
922
930 if readUnitConfObj.parentId == None:
923 if readUnitConfObj.parentId == None:
931 readUnitConfObj.parentId = self.id
924 readUnitConfObj.parentId = self.id
932
925
933 self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
926 self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
934
927
935 procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName())
928 procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName())
936
929
937 for procUnitElement in procUnitElementList:
930 for procUnitElement in procUnitElementList:
938 procUnitConfObj = ProcUnitConf()
931 procUnitConfObj = ProcUnitConf()
939 procUnitConfObj.readXml(procUnitElement)
932 procUnitConfObj.readXml(procUnitElement)
940
933
941 if procUnitConfObj.parentId == None:
934 if procUnitConfObj.parentId == None:
942 procUnitConfObj.parentId = self.id
935 procUnitConfObj.parentId = self.id
943
936
944 self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
937 self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
945
938
946 def printattr(self):
939 def printattr(self):
947
940
948 print "Project[%s]: name = %s, description = %s" %(self.id,
941 print "Project[%s]: name = %s, description = %s" %(self.id,
949 self.name,
942 self.name,
950 self.description)
943 self.description)
951
944
952 for procUnitConfObj in self.procUnitConfObjDict.values():
945 for procUnitConfObj in self.procUnitConfObjDict.values():
953 procUnitConfObj.printattr()
946 procUnitConfObj.printattr()
954
947
955 def createObjects(self):
948 def createObjects(self):
956
949
957 for procUnitConfObj in self.procUnitConfObjDict.values():
950 for procUnitConfObj in self.procUnitConfObjDict.values():
958 procUnitConfObj.createObjects()
951 procUnitConfObj.createObjects()
959
952
960 def __connect(self, objIN, thisObj):
953 def __connect(self, objIN, thisObj):
961
954
962 thisObj.setInput(objIN.getOutputObj())
955 thisObj.setInput(objIN.getOutputObj())
963
956
964 def connectObjects(self):
957 def connectObjects(self):
965
958
966 for thisPUConfObj in self.procUnitConfObjDict.values():
959 for thisPUConfObj in self.procUnitConfObjDict.values():
967
960
968 inputId = thisPUConfObj.getInputId()
961 inputId = thisPUConfObj.getInputId()
969
962
970 if int(inputId) == 0:
963 if int(inputId) == 0:
971 continue
964 continue
972
965
973 #Get input object
966 #Get input object
974 puConfINObj = self.procUnitConfObjDict[inputId]
967 puConfINObj = self.procUnitConfObjDict[inputId]
975 puObjIN = puConfINObj.getProcUnitObj()
968 puObjIN = puConfINObj.getProcUnitObj()
976
969
977 #Get current object
970 #Get current object
978 thisPUObj = thisPUConfObj.getProcUnitObj()
971 thisPUObj = thisPUConfObj.getProcUnitObj()
979
972
980 self.__connect(puObjIN, thisPUObj)
973 self.__connect(puObjIN, thisPUObj)
981
974
975 def isPaused(self):
976 return 0
977
978 def isStopped(self):
979 return 0
980
981 def runController(self):
982 """
983 returns 0 when this process has been stopped, 1 otherwise
984 """
985
986 if self.isPaused():
987 print "Process suspended"
988
989 while True:
990 sleep(0.1)
991
992 if not self.isPaused():
993 break
994
995 if self.isStopped():
996 break
997
998 print "Process reinitialized"
999
1000 if self.isStopped():
1001 print "Process stopped"
1002 return 0
1003
1004 return 1
1005
982 def run(self):
1006 def run(self):
983
1007
984 print
1008 print
985 print "*"*50
1009 print "*"*60
986 print " Starting SIGNAL CHAIN PROCESSING "
1010 print " Starting SIGNAL CHAIN PROCESSING "
987 print "*"*50
1011 print "*"*60
988 print
1012 print
989
1013
990 keyList = self.procUnitConfObjDict.keys()
1014 keyList = self.procUnitConfObjDict.keys()
991 keyList.sort()
1015 keyList.sort()
992
1016
993 while(True):
1017 while(True):
994
1018
995 finalSts = False
1019 is_ok = False
996
1020
997 for procKey in keyList:
1021 for procKey in keyList:
998 # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id)
1022 # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id)
999
1023
1000 procUnitConfObj = self.procUnitConfObjDict[procKey]
1024 procUnitConfObj = self.procUnitConfObjDict[procKey]
1001 sts = procUnitConfObj.run()
1025
1002 finalSts = finalSts or sts
1026 message = ""
1027 try:
1028 sts = procUnitConfObj.run()
1029 is_ok = is_ok or sts
1030 except:
1031 sleep(1)
1032 err = traceback.format_exception(sys.exc_info()[0],
1033 sys.exc_info()[1],
1034 sys.exc_info()[2])
1035
1036 for thisLine in err:
1037 message += thisLine
1038
1039 print message
1040 # self.sendReport(message)
1041 sleep(0.1)
1042 is_ok = False
1043
1044 break
1003
1045
1004 #If every process unit finished so end process
1046 #If every process unit finished so end process
1005 if not(finalSts):
1047 if not(is_ok):
1048 print message
1006 print "Every process unit have finished"
1049 print "Every process unit have finished"
1007 break
1050 break
1008
1051
1009 if self.control['pause']:
1052 if not self.runController():
1010 print "Process suspended"
1011
1012 while True:
1013 sleep(0.1)
1014
1015 if not self.control['pause']:
1016 break
1017
1018 if self.control['stop']:
1019 break
1020 print "Process reinitialized"
1021
1022 if self.control['stop']:
1023 # print "Process stopped"
1024 break
1053 break
1025
1054
1026 #Closing every process
1055 #Closing every process
1027 for procKey in keyList:
1056 for procKey in keyList:
1028 procUnitConfObj = self.procUnitConfObjDict[procKey]
1057 procUnitConfObj = self.procUnitConfObjDict[procKey]
1029 procUnitConfObj.close()
1058 procUnitConfObj.close()
1030
1059
1031 print "Process finished"
1060 print "Process finished"
1032
1061
1033 def start(self, filename):
1062 def start(self, filename):
1034
1063
1035 self.writeXml(filename)
1064 self.writeXml(filename)
1036 self.readXml(filename)
1065 self.readXml(filename)
1037
1066
1038 self.createObjects()
1067 self.createObjects()
1039 self.connectObjects()
1068 self.connectObjects()
1040 self.run()
1069 self.run()
1070
1071 def sendReport(self, message, subject="Error occurred in Signal Chain", email=SCHAIN_MAIL):
1072
1073 import smtplib
1074
1075 print subject
1076 print "Sending report to %s ..." %email
1077
1078 message = 'From: (Python Signal Chain API) ' + email + '\n' + \
1079 'To: ' + email + '\n' + \
1080 'Subject: ' + str(subject) + '\n' + \
1081 'Content-type: text/html\n\n' + message
1082
1083 server = smtplib.SMTP(EMAIL_SERVER)
1084 server.sendmail(email.split(',')[0],
1085 email.split(','), message)
1086 server.quit()
1041
1087
1042 if __name__ == '__main__':
1088 if __name__ == '__main__':
1043
1089
1044 desc = "Segundo Test"
1090 desc = "Segundo Test"
1045 filename = "schain.xml"
1091 filename = "schain.xml"
1046
1092
1047 controllerObj = Project()
1093 controllerObj = Project()
1048
1094
1049 controllerObj.setup(id = '191', name='test01', description=desc)
1095 controllerObj.setup(id = '191', name='test01', description=desc)
1050
1096
1051 readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage',
1097 readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage',
1052 path='data/rawdata/',
1098 path='data/rawdata/',
1053 startDate='2011/01/01',
1099 startDate='2011/01/01',
1054 endDate='2012/12/31',
1100 endDate='2012/12/31',
1055 startTime='00:00:00',
1101 startTime='00:00:00',
1056 endTime='23:59:59',
1102 endTime='23:59:59',
1057 online=1,
1103 online=1,
1058 walk=1)
1104 walk=1)
1059
1105
1060 procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId())
1106 procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId())
1061
1107
1062 opObj10 = procUnitConfObj0.addOperation(name='selectChannels')
1108 opObj10 = procUnitConfObj0.addOperation(name='selectChannels')
1063 opObj10.addParameter(name='channelList', value='3,4,5', format='intlist')
1109 opObj10.addParameter(name='channelList', value='3,4,5', format='intlist')
1064
1110
1065 opObj10 = procUnitConfObj0.addOperation(name='selectHeights')
1111 opObj10 = procUnitConfObj0.addOperation(name='selectHeights')
1066 opObj10.addParameter(name='minHei', value='90', format='float')
1112 opObj10.addParameter(name='minHei', value='90', format='float')
1067 opObj10.addParameter(name='maxHei', value='180', format='float')
1113 opObj10.addParameter(name='maxHei', value='180', format='float')
1068
1114
1069 opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='external')
1115 opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='external')
1070 opObj12.addParameter(name='n', value='10', format='int')
1116 opObj12.addParameter(name='n', value='10', format='int')
1071
1117
1072 procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId())
1118 procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId())
1073 procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int')
1119 procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int')
1074 # procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='')
1120 # procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='')
1075
1121
1076
1122
1077 opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external')
1123 opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external')
1078 opObj11.addParameter(name='idfigure', value='1', format='int')
1124 opObj11.addParameter(name='idfigure', value='1', format='int')
1079 opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str')
1125 opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str')
1080 opObj11.addParameter(name='zmin', value='40', format='int')
1126 opObj11.addParameter(name='zmin', value='40', format='int')
1081 opObj11.addParameter(name='zmax', value='90', format='int')
1127 opObj11.addParameter(name='zmax', value='90', format='int')
1082 opObj11.addParameter(name='showprofile', value='1', format='int')
1128 opObj11.addParameter(name='showprofile', value='1', format='int')
1083
1129
1084 print "Escribiendo el archivo XML"
1130 print "Escribiendo el archivo XML"
1085
1131
1086 controllerObj.writeXml(filename)
1132 controllerObj.writeXml(filename)
1087
1133
1088 print "Leyendo el archivo XML"
1134 print "Leyendo el archivo XML"
1089 controllerObj.readXml(filename)
1135 controllerObj.readXml(filename)
1090 #controllerObj.printattr()
1136 #controllerObj.printattr()
1091
1137
1092 controllerObj.createObjects()
1138 controllerObj.createObjects()
1093 controllerObj.connectObjects()
1139 controllerObj.connectObjects()
1094 controllerObj.run()
1140 controllerObj.run()
1095
1141
1096 No newline at end of file
1142
@@ -1,139 +1,141
1 import threading
1 import threading
2
2
3 from PyQt4 import QtCore
3 from PyQt4 import QtCore
4 from PyQt4.QtCore import SIGNAL
4 from PyQt4.QtCore import SIGNAL
5
5
6 from schainpy.controller import Project
6 from schainpy.controller import Project
7
7
8 class ControllerThread(threading.Thread, Project):
8 class ControllerThread(threading.Thread, Project):
9
9
10 def __init__(self, filename):
10 def __init__(self, filename):
11
11
12 threading.Thread.__init__(self)
12 threading.Thread.__init__(self)
13 Project.__init__(self)
13 Project.__init__(self)
14
14
15 self.setDaemon(True)
15 self.setDaemon(True)
16
16
17 self.filename = filename
17 self.filename = filename
18
19 self.lock = threading.Lock()
18 self.control = {'stop':False, 'pause':False}
20 self.control = {'stop':False, 'pause':False}
19
21
20 def __del__(self):
22 def __del__(self):
21
23
22 self.control['stop'] = True
24 self.control['stop'] = True
23 # self.pause(1)
24 # self.wait()
25
25
26 def stop(self):
26 def stop(self):
27
28 self.lock.acquire()
29
27 self.control['stop'] = True
30 self.control['stop'] = True
28
31
32 self.lock.release()
33
29 def pause(self):
34 def pause(self):
35
36 self.lock.acquire()
37
30 self.control['pause'] = not(self.control['pause'])
38 self.control['pause'] = not(self.control['pause'])
39 paused = self.control['pause']
40
41 self.lock.release()
31
42
32 return self.control['pause']
43 return paused
33
44
34 def __run(self):
45 def isPaused(self):
35
46
36 print
47 self.lock.acquire()
37 print "*"*40
48 paused = self.control['pause']
38 print " Starting SIGNAL CHAIN PROCESSING "
49 self.lock.release()
39 print "*"*40
40 print
41
50
42 keyList = self.procUnitConfObjDict.keys()
51 return paused
43 keyList.sort()
52
44
53 def isStopped(self):
45 while(True):
46
47 finalSts = False
48 #executed proc units
49 procUnitExecutedList = []
50
51 for procKey in keyList:
52 # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id)
53
54 procUnitConfObj = self.procUnitConfObjDict[procKey]
55
56 inputId = procUnitConfObj.getInputId()
57
58 sts = procUnitConfObj.run()
59 finalSts = finalSts or sts
60
61 procUnitExecutedList.append(procUnitConfObj.id)
62
63 #If every process unit finished so end process
64 if not(finalSts):
65 print "Every process unit have finished"
66 break
67
68 if self.control['pause']:
69 print "Process suspended"
70
71 while True:
72 sleep(0.1)
73
74 if not self.control['pause']:
75 break
76
77 if self.control['stop']:
78 break
79 print "Process reinitialized"
80
81 if self.control['stop']:
82 # print "Process stopped"
83 break
84
85 #Closing every process
86 for procKey in keyList:
87 procUnitConfObj = self.procUnitConfObjDict[procKey]
88 procUnitConfObj.close()
89
90 print "Process finished"
91
54
55 self.lock.acquire()
56 stopped = self.control['stop']
57 self.lock.release()
58
59 return stopped
60
92 def run(self):
61 def run(self):
93 self.control['stop'] = False
62 self.control['stop'] = False
94 self.control['pause'] = False
63 self.control['pause'] = False
95
64
96 self.readXml(self.filename)
65 self.readXml(self.filename)
97 self.createObjects()
66 self.createObjects()
98 self.connectObjects()
67 self.connectObjects()
99 Project.run(self)
68 Project.run(self)
100
69
101 def isRunning(self):
70 def isRunning(self):
102
71
103 return self.is_alive()
72 return self.is_alive()
104
73
105 def isFinished(self):
74 def isFinished(self):
106
75
107 return not self.is_alive()
76 return not self.is_alive()
108
77
109 class ControllerQThread(QtCore.QThread, Project):
78 class ControllerQThread(QtCore.QThread, Project):
110
79
111 def __init__(self, filename):
80 def __init__(self, filename):
112
81
113 QtCore.QThread.__init__(self)
82 QtCore.QThread.__init__(self)
114 Project.__init__(self)
83 Project.__init__(self)
115
84
116 self.filename = filename
85 self.filename = filename
86
87 self.lock = threading.Lock()
117 self.control = {'stop':False, 'pause':False}
88 self.control = {'stop':False, 'pause':False}
118
89
119 def __del__(self):
90 def __del__(self):
120
91
121 self.control['stop'] = True
92 self.control['stop'] = True
122 self.wait()
93 self.wait()
123
94
124 def stop(self):
95 def stop(self):
96
97 self.lock.acquire()
98
125 self.control['stop'] = True
99 self.control['stop'] = True
126
100
101 self.lock.release()
102
127 def pause(self):
103 def pause(self):
104
105 self.lock.acquire()
106
128 self.control['pause'] = not(self.control['pause'])
107 self.control['pause'] = not(self.control['pause'])
129
108 paused = self.control['pause']
109
110 self.lock.release()
111
112 return paused
113
114 def isPaused(self):
115
116 self.lock.acquire()
117 paused = self.control['pause']
118 self.lock.release()
119
120 return paused
121
122 def isStopped(self):
123
124 self.lock.acquire()
125 stopped = self.control['stop']
126 self.lock.release()
127
128 return stopped
129
130 def run(self):
130 def run(self):
131
131 self.control['stop'] = False
132 self.control['stop'] = False
132 self.control['pause'] = False
133 self.control['pause'] = False
133
134
134 self.readXml(self.filename)
135 self.readXml(self.filename)
135 self.createObjects()
136 self.createObjects()
136 self.connectObjects()
137 self.connectObjects()
137 self.emit( SIGNAL( "jobStarted( PyQt_PyObject )" ), 1)
138 self.emit( SIGNAL( "jobStarted( PyQt_PyObject )" ), 1)
138 Project.run(self)
139 Project.run(self)
139 self.emit( SIGNAL( "jobFinished( PyQt_PyObject )" ), 1) No newline at end of file
140 self.emit( SIGNAL( "jobFinished( PyQt_PyObject )" ), 1)
141 No newline at end of file
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
@@ -1,344 +1,343
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Form implementation generated from reading ui file '/home/alex/ui/MainWindow_21_02_13_v49.ui'
3 # Form implementation generated from reading ui file '/home/alex/ui/MainWindow_21_02_13_v49.ui'
4 #
4 #
5 # Created: Mon Mar 24 13:28:36 2014
5 # Created: Mon Mar 24 13:28:36 2014
6 # by: PyQt4 UI code generator 4.10
6 # by: PyQt4 UI code generator 4.10
7 #
7 #
8 # WARNING! All changes made in this file will be lost!
8 # WARNING! All changes made in this file will be lost!
9
9
10 from PyQt4 import QtCore, QtGui
10 from PyQt4 import QtCore, QtGui
11 from windows import *
11 from windows import *
12
12
13 try:
13 try:
14 _fromUtf8 = QtCore.QString.fromUtf8
14 _fromUtf8 = QtCore.QString.fromUtf8
15 except AttributeError:
15 except AttributeError:
16 def _fromUtf8(s):
16 def _fromUtf8(s):
17 return s
17 return s
18
18
19 try:
19 try:
20 _encoding = QtGui.QApplication.UnicodeUTF8
20 _encoding = QtGui.QApplication.UnicodeUTF8
21 def _translate(context, text, disambig):
21 def _translate(context, text, disambig):
22 return QtGui.QApplication.translate(context, text, disambig, _encoding)
22 return QtGui.QApplication.translate(context, text, disambig, _encoding)
23 except AttributeError:
23 except AttributeError:
24 def _translate(context, text, disambig):
24 def _translate(context, text, disambig):
25 return QtGui.QApplication.translate(context, text, disambig)
25 return QtGui.QApplication.translate(context, text, disambig)
26
26
27 import os
27 import os
28 from schainpy.gui.figures import tools
28 from schainpy.gui.figures import tools
29 from schainpy import __version__
29 from schainpy import __version__
30
30
31 FIGURES_PATH = tools.get_path()
31 FIGURES_PATH = tools.get_path()
32
32
33 class Ui_EnvWindow(object):
33 class Ui_EnvWindow(object):
34 paused = False
34 paused = False
35
35
36 def restorePauseIcon(self):
36 def restorePauseIcon(self):
37
37
38 icon_name = "pause.png"
38 icon_name = "pause.png"
39 iconPause = QtGui.QIcon()
39 iconPause = QtGui.QIcon()
40 iconPause.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH, icon_name) )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
40 iconPause.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH, icon_name) )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
41 self.actionPauseToolbar.setIcon(iconPause)
41 self.actionPauseToolbar.setIcon(iconPause)
42
42
43 def restoreStartIcon(self):
43 def restoreStartIcon(self):
44
44
45 icon_name = "start.png"
45 icon_name = "start.png"
46 iconStart = QtGui.QIcon()
46 iconStart = QtGui.QIcon()
47 iconStart.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH, icon_name) )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
47 iconStart.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH, icon_name) )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
48 self.actionStarToolbar.setIcon(iconStart)
48 self.actionStarToolbar.setIcon(iconStart)
49
49
50 def changePauseIcon(self, paused=False):
50 def changePauseIcon(self, paused=False):
51
51
52 if paused == True:
52 if paused == True:
53 icon_name = "pausered.png"
53 icon_name = "pausered.png"
54 else:
54 else:
55 icon_name = "pause.png"
55 icon_name = "pause.png"
56
56
57 iconPause = QtGui.QIcon()
57 iconPause = QtGui.QIcon()
58 iconPause.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH, icon_name) )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
58 iconPause.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH, icon_name) )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
59 self.actionPauseToolbar.setIcon(iconPause)
59 self.actionPauseToolbar.setIcon(iconPause)
60
60
61 return
61 return
62
62
63 def changeStartIcon(self, started=False):
63 def changeStartIcon(self, started=False):
64
64
65 if started == True:
65 if started == True:
66 icon_name = "startred.png"
66 icon_name = "startred.png"
67 else:
67 else:
68 icon_name = "start.png"
68 icon_name = "start.png"
69
69
70 iconStart = QtGui.QIcon()
70 iconStart = QtGui.QIcon()
71 iconStart.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH, icon_name) )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
71 iconStart.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH, icon_name) )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
72 self.actionStarToolbar.setIcon(iconStart)
72 self.actionStarToolbar.setIcon(iconStart)
73
73
74 return
74 return
75
75
76 def setupUi(self, MainWindow):
76 def setupUi(self, MainWindow):
77
77
78 self.paused=False
78 self.paused=False
79
79
80 MainWindow.setObjectName(_fromUtf8("MainWindow"))
80 MainWindow.setObjectName(_fromUtf8("MainWindow"))
81 MainWindow.resize(1200, 800)
81 MainWindow.resize(1200, 800)
82
82
83 self.centralWidget = QtGui.QWidget(MainWindow)
83 self.centralWidget = QtGui.QWidget(MainWindow)
84 self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
84 self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
85 self.gridLayout_16 = QtGui.QGridLayout(self.centralWidget)
85 self.gridLayout_16 = QtGui.QGridLayout(self.centralWidget)
86 self.gridLayout_16.setObjectName(_fromUtf8("gridLayout_16"))
86 self.gridLayout_16.setObjectName(_fromUtf8("gridLayout_16"))
87 self.splitter_2 = QtGui.QSplitter(self.centralWidget)
87 self.splitter_2 = QtGui.QSplitter(self.centralWidget)
88 self.splitter_2.setOrientation(QtCore.Qt.Horizontal)
88 self.splitter_2.setOrientation(QtCore.Qt.Horizontal)
89 self.splitter_2.setObjectName(_fromUtf8("splitter_2"))
89 self.splitter_2.setObjectName(_fromUtf8("splitter_2"))
90 self.projectExplorerTree = QtGui.QTreeView(self.splitter_2)
90 self.projectExplorerTree = QtGui.QTreeView(self.splitter_2)
91 self.projectExplorerTree.setObjectName(_fromUtf8("projectExplorerTree"))
91 self.projectExplorerTree.setObjectName(_fromUtf8("projectExplorerTree"))
92 self.splitter = QtGui.QSplitter(self.splitter_2)
92 self.splitter = QtGui.QSplitter(self.splitter_2)
93 self.splitter.setOrientation(QtCore.Qt.Vertical)
93 self.splitter.setOrientation(QtCore.Qt.Vertical)
94 self.splitter.setObjectName(_fromUtf8("splitter"))
94 self.splitter.setObjectName(_fromUtf8("splitter"))
95 self.tabWidgetProject = QtGui.QTabWidget(self.splitter)
95 self.tabWidgetProject = QtGui.QTabWidget(self.splitter)
96 self.tabWidgetProject.setMinimumSize(QtCore.QSize(0, 278))
96 self.tabWidgetProject.setMinimumSize(QtCore.QSize(0, 278))
97 self.tabWidgetProject.setMaximumSize(QtCore.QSize(16777215, 16777215))
97 self.tabWidgetProject.setMaximumSize(QtCore.QSize(16777215, 16777215))
98 self.tabWidgetProject.setObjectName(_fromUtf8("tabWidgetProject"))
98 self.tabWidgetProject.setObjectName(_fromUtf8("tabWidgetProject"))
99
99
100 self.tabConsole = QtGui.QTabWidget(self.splitter)
100 self.tabConsole = QtGui.QTabWidget(self.splitter)
101 self.tabConsole.setMinimumSize(QtCore.QSize(0, 0))
101 self.tabConsole.setMinimumSize(QtCore.QSize(0, 0))
102 self.tabConsole.setObjectName(_fromUtf8("tabConsole"))
102 self.tabConsole.setObjectName(_fromUtf8("tabConsole"))
103 self.tab_5 = QtGui.QWidget()
103 self.tab_5 = QtGui.QWidget()
104 self.tab_5.setObjectName(_fromUtf8("tab_5"))
104 self.tab_5.setObjectName(_fromUtf8("tab_5"))
105 self.gridLayout_4 = QtGui.QGridLayout(self.tab_5)
105 self.gridLayout_4 = QtGui.QGridLayout(self.tab_5)
106 self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4"))
106 self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4"))
107 self.console = QtGui.QTextEdit(self.tab_5)
107 self.console = QtGui.QTextEdit(self.tab_5)
108 self.console.setObjectName(_fromUtf8("console"))
108 self.console.setObjectName(_fromUtf8("console"))
109 self.gridLayout_4.addWidget(self.console, 0, 0, 1, 1)
109 self.gridLayout_4.addWidget(self.console, 0, 0, 1, 1)
110 self.tabConsole.addTab(self.tab_5, _fromUtf8(""))
110 self.tabConsole.addTab(self.tab_5, _fromUtf8(""))
111 self.tabWidget = QtGui.QTabWidget(self.splitter_2)
111 self.tabWidget = QtGui.QTabWidget(self.splitter_2)
112 self.tabWidget.setObjectName(_fromUtf8("tabWidget"))
112 self.tabWidget.setObjectName(_fromUtf8("tabWidget"))
113 self.tabProjectProperty = QtGui.QWidget()
113 self.tabProjectProperty = QtGui.QWidget()
114 self.tabProjectProperty.setObjectName(_fromUtf8("tabProjectProperty"))
114 self.tabProjectProperty.setObjectName(_fromUtf8("tabProjectProperty"))
115 self.gridLayout_8 = QtGui.QGridLayout(self.tabProjectProperty)
115 self.gridLayout_8 = QtGui.QGridLayout(self.tabProjectProperty)
116 self.gridLayout_8.setObjectName(_fromUtf8("gridLayout_8"))
116 self.gridLayout_8.setObjectName(_fromUtf8("gridLayout_8"))
117 self.treeProjectProperties = QtGui.QTreeView(self.tabProjectProperty)
117 self.treeProjectProperties = QtGui.QTreeView(self.tabProjectProperty)
118 self.treeProjectProperties.setObjectName(_fromUtf8("treeProjectProperties"))
118 self.treeProjectProperties.setObjectName(_fromUtf8("treeProjectProperties"))
119 self.gridLayout_8.addWidget(self.treeProjectProperties, 0, 0, 1, 1)
119 self.gridLayout_8.addWidget(self.treeProjectProperties, 0, 0, 1, 1)
120 self.tabWidget.addTab(self.tabProjectProperty, _fromUtf8(""))
120 self.tabWidget.addTab(self.tabProjectProperty, _fromUtf8(""))
121 self.gridLayout_16.addWidget(self.splitter_2, 1, 0, 1, 1)
121 self.gridLayout_16.addWidget(self.splitter_2, 1, 0, 1, 1)
122
122
123 MainWindow.setCentralWidget(self.centralWidget)
123 MainWindow.setCentralWidget(self.centralWidget)
124 self.toolBar = QtGui.QToolBar(MainWindow)
124 self.toolBar = QtGui.QToolBar(MainWindow)
125 self.toolBar.setObjectName(_fromUtf8("toolBar"))
125 self.toolBar.setObjectName(_fromUtf8("toolBar"))
126 MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
126 MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
127
127
128 self.menuBar = QtGui.QMenuBar(MainWindow)
128 self.menuBar = QtGui.QMenuBar(MainWindow)
129 self.menuBar.setGeometry(QtCore.QRect(0, 0, 1065, 25))
129 self.menuBar.setGeometry(QtCore.QRect(0, 0, 1065, 25))
130 self.menuBar.setObjectName(_fromUtf8("menuBar"))
130 self.menuBar.setObjectName(_fromUtf8("menuBar"))
131 self.menuProject = QtGui.QMenu(self.menuBar)
131 self.menuProject = QtGui.QMenu(self.menuBar)
132 self.menuProject.setObjectName(_fromUtf8("menuProject"))
132 self.menuProject.setObjectName(_fromUtf8("menuProject"))
133 self.menuRun = QtGui.QMenu(self.menuBar)
133 self.menuRun = QtGui.QMenu(self.menuBar)
134 self.menuRun.setObjectName(_fromUtf8("menuRun"))
134 self.menuRun.setObjectName(_fromUtf8("menuRun"))
135 self.menuOptions = QtGui.QMenu(self.menuBar)
135 self.menuOptions = QtGui.QMenu(self.menuBar)
136 self.menuOptions.setObjectName(_fromUtf8("menuOptions"))
136 self.menuOptions.setObjectName(_fromUtf8("menuOptions"))
137 self.menuHelp = QtGui.QMenu(self.menuBar)
137 self.menuHelp = QtGui.QMenu(self.menuBar)
138 self.menuHelp.setObjectName(_fromUtf8("menuHelp"))
138 self.menuHelp.setObjectName(_fromUtf8("menuHelp"))
139 MainWindow.setMenuBar(self.menuBar)
139 MainWindow.setMenuBar(self.menuBar)
140
140
141 iconOpen = QtGui.QIcon()
141 iconOpen = QtGui.QIcon()
142 iconOpen.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"open.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
142 iconOpen.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"open.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
143 iconCreate = QtGui.QIcon()
143 iconCreate = QtGui.QIcon()
144 iconCreate.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"new.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
144 iconCreate.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"new.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
145 iconSave = QtGui.QIcon()
145 iconSave = QtGui.QIcon()
146 iconSave.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"save.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
146 iconSave.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"save.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
147 iconStart = QtGui.QIcon()
147 iconStart = QtGui.QIcon()
148 iconStart.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"start.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
148 iconStart.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"start.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
149 iconStop = QtGui.QIcon()
149 iconStop = QtGui.QIcon()
150 iconStop.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"stop.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
150 iconStop.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"stop.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
151 iconPause = QtGui.QIcon()
151 iconPause = QtGui.QIcon()
152 iconPause.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"pause.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
152 iconPause.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"pause.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
153 iconAddPU = QtGui.QIcon()
153 iconAddPU = QtGui.QIcon()
154 iconAddPU.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"branch.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
154 iconAddPU.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"branch.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
155 iconClose = QtGui.QIcon()
155 iconClose = QtGui.QIcon()
156 iconClose.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"close.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
156 iconClose.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"close.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off)
157
157
158
158
159 self.actionOpen = QtGui.QAction(MainWindow)
159 self.actionOpen = QtGui.QAction(MainWindow)
160 self.actionOpen.setIcon(iconOpen)
160 self.actionOpen.setIcon(iconOpen)
161 self.actionOpen.setObjectName(_fromUtf8("actionOpen"))
161 self.actionOpen.setObjectName(_fromUtf8("actionOpen"))
162 self.actionCreate = QtGui.QAction(MainWindow)
162 self.actionCreate = QtGui.QAction(MainWindow)
163 self.actionCreate.setIcon(iconCreate)
163 self.actionCreate.setIcon(iconCreate)
164 self.actionCreate.setObjectName(_fromUtf8("actionCreate"))
164 self.actionCreate.setObjectName(_fromUtf8("actionCreate"))
165 self.actionSave = QtGui.QAction(MainWindow)
165 self.actionSave = QtGui.QAction(MainWindow)
166 self.actionSave.setIcon(iconSave)
166 self.actionSave.setIcon(iconSave)
167 self.actionSave.setObjectName(_fromUtf8("actionSave"))
167 self.actionSave.setObjectName(_fromUtf8("actionSave"))
168 self.actionClose = QtGui.QAction(MainWindow)
168 self.actionClose = QtGui.QAction(MainWindow)
169 self.actionClose.setIcon(iconClose)
169 self.actionClose.setIcon(iconClose)
170 self.actionClose.setObjectName(_fromUtf8("actionClose"))
170 self.actionClose.setObjectName(_fromUtf8("actionClose"))
171 self.actionStart = QtGui.QAction(MainWindow)
171 self.actionStart = QtGui.QAction(MainWindow)
172 self.actionStart.setIcon(iconStart)
172 self.actionStart.setIcon(iconStart)
173 self.actionStart.setObjectName(_fromUtf8("actionStart"))
173 self.actionStart.setObjectName(_fromUtf8("actionStart"))
174 self.actionPause = QtGui.QAction(MainWindow)
174 self.actionPause = QtGui.QAction(MainWindow)
175 self.actionPause.setIcon(iconPause)
175 self.actionPause.setIcon(iconPause)
176 self.actionPause.setObjectName(_fromUtf8("actionPause"))
176 self.actionPause.setObjectName(_fromUtf8("actionPause"))
177 self.actionStop = QtGui.QAction(MainWindow)
177 self.actionStop = QtGui.QAction(MainWindow)
178 self.actionStop.setIcon(iconStop)
178 self.actionStop.setIcon(iconStop)
179 self.actionStop.setObjectName(_fromUtf8("actionStop"))
179 self.actionStop.setObjectName(_fromUtf8("actionStop"))
180 self.actionAbout = QtGui.QAction(MainWindow)
180 self.actionAbout = QtGui.QAction(MainWindow)
181 self.actionAbout.setObjectName(_fromUtf8("actionAbout"))
181 self.actionAbout.setObjectName(_fromUtf8("actionAbout"))
182
182
183 self.actionOpenToolbar = QtGui.QAction(MainWindow)
183 self.actionOpenToolbar = QtGui.QAction(MainWindow)
184 self.actionOpenToolbar.setIcon(iconOpen)
184 self.actionOpenToolbar.setIcon(iconOpen)
185 self.actionOpenToolbar.setObjectName(_fromUtf8("actionOpenToolbar"))
185 self.actionOpenToolbar.setObjectName(_fromUtf8("actionOpenToolbar"))
186 self.actionCreateToolbar = QtGui.QAction(MainWindow)
186 self.actionCreateToolbar = QtGui.QAction(MainWindow)
187 self.actionCreateToolbar.setIcon(iconCreate)
187 self.actionCreateToolbar.setIcon(iconCreate)
188 self.actionCreateToolbar.setObjectName(_fromUtf8("actionCreateToolbar"))
188 self.actionCreateToolbar.setObjectName(_fromUtf8("actionCreateToolbar"))
189 self.actionSaveToolbar = QtGui.QAction(MainWindow)
189 self.actionSaveToolbar = QtGui.QAction(MainWindow)
190 self.actionSaveToolbar.setIcon(iconSave)
190 self.actionSaveToolbar.setIcon(iconSave)
191 self.actionSaveToolbar.setObjectName(_fromUtf8("actionSaveToolbar"))
191 self.actionSaveToolbar.setObjectName(_fromUtf8("actionSaveToolbar"))
192 self.actionStarToolbar = QtGui.QAction(MainWindow)
192 self.actionStarToolbar = QtGui.QAction(MainWindow)
193 self.actionStarToolbar.setIcon(iconStart)
193 self.actionStarToolbar.setIcon(iconStart)
194 self.actionStarToolbar.setObjectName(_fromUtf8("actionStarToolbar"))
194 self.actionStarToolbar.setObjectName(_fromUtf8("actionStarToolbar"))
195 self.actionStopToolbar = QtGui.QAction(MainWindow)
195 self.actionStopToolbar = QtGui.QAction(MainWindow)
196 self.actionStopToolbar.setIcon(iconStop)
196 self.actionStopToolbar.setIcon(iconStop)
197 self.actionStopToolbar.setObjectName(_fromUtf8("actionStopToolbar"))
197 self.actionStopToolbar.setObjectName(_fromUtf8("actionStopToolbar"))
198 self.actionPauseToolbar = QtGui.QAction(MainWindow)
198 self.actionPauseToolbar = QtGui.QAction(MainWindow)
199 self.actionPause.setIcon(iconPause)
199 self.actionPause.setIcon(iconPause)
200 self.actionPauseToolbar.setIcon(iconPause)
200 self.actionPauseToolbar.setIcon(iconPause)
201 self.actionPauseToolbar.setObjectName(_fromUtf8("actionPauseToolbar"))
201 self.actionPauseToolbar.setObjectName(_fromUtf8("actionPauseToolbar"))
202 self.actionAddPU = QtGui.QAction(MainWindow)
202 self.actionAddPU = QtGui.QAction(MainWindow)
203 self.actionAddPU.setIcon(iconAddPU)
203 self.actionAddPU.setIcon(iconAddPU)
204 self.actionAddPU.setObjectName(_fromUtf8("actionAddPU"))
204 self.actionAddPU.setObjectName(_fromUtf8("actionAddPU"))
205 self.actionFTP = QtGui.QAction(MainWindow)
205 self.actionFTP = QtGui.QAction(MainWindow)
206 self.actionFTP.setObjectName(_fromUtf8("actionFTP"))
206 self.actionFTP.setObjectName(_fromUtf8("actionFTP"))
207 self.toolBar.addAction(self.actionOpenToolbar)
207 self.toolBar.addAction(self.actionOpenToolbar)
208 self.toolBar.addSeparator()
208 self.toolBar.addSeparator()
209 self.toolBar.addAction(self.actionCreateToolbar)
209 self.toolBar.addAction(self.actionCreateToolbar)
210 self.toolBar.addSeparator()
210 self.toolBar.addSeparator()
211 self.toolBar.addAction(self.actionAddPU)
211 self.toolBar.addAction(self.actionAddPU)
212 self.toolBar.addSeparator()
212 self.toolBar.addSeparator()
213 self.toolBar.addAction(self.actionSaveToolbar)
213 self.toolBar.addAction(self.actionSaveToolbar)
214 self.toolBar.addSeparator()
214 self.toolBar.addSeparator()
215 self.toolBar.addAction(self.actionStarToolbar)
215 self.toolBar.addAction(self.actionStarToolbar)
216 self.toolBar.addSeparator()
216 self.toolBar.addSeparator()
217 self.toolBar.addAction(self.actionPauseToolbar)
217 self.toolBar.addAction(self.actionPauseToolbar)
218 self.toolBar.addSeparator()
218 self.toolBar.addSeparator()
219 self.toolBar.addAction(self.actionStopToolbar)
219 self.toolBar.addAction(self.actionStopToolbar)
220 self.toolBar.addSeparator()
220 self.toolBar.addSeparator()
221
221
222 # self.actionPause.triggered.connect(self.changePauseIcon)
222 # self.actionPause.triggered.connect(self.changePauseIcon)
223 # self.actionPauseToolbar.triggered.connect(self.changePauseIcon)
223 # self.actionPauseToolbar.triggered.connect(self.changePauseIcon)
224
224
225 self.menuProject.addAction(self.actionOpen)
225 self.menuProject.addAction(self.actionOpen)
226 self.menuProject.addAction(self.actionCreate)
226 self.menuProject.addAction(self.actionCreate)
227 self.menuProject.addAction(self.actionSave)
227 self.menuProject.addAction(self.actionSave)
228 self.menuProject.addAction(self.actionClose)
228 self.menuProject.addAction(self.actionClose)
229 self.menuRun.addAction(self.actionStart)
229 self.menuRun.addAction(self.actionStart)
230 self.menuRun.addAction(self.actionPause)
230 self.menuRun.addAction(self.actionPause)
231 self.menuRun.addAction(self.actionStop)
231 self.menuRun.addAction(self.actionStop)
232 self.menuOptions.addAction(self.actionFTP)
232 self.menuOptions.addAction(self.actionFTP)
233 self.menuHelp.addAction(self.actionAbout)
233 self.menuHelp.addAction(self.actionAbout)
234 self.menuBar.addAction(self.menuProject.menuAction())
234 self.menuBar.addAction(self.menuProject.menuAction())
235 self.menuBar.addAction(self.menuRun.menuAction())
235 self.menuBar.addAction(self.menuRun.menuAction())
236 self.menuBar.addAction(self.menuOptions.menuAction())
236 self.menuBar.addAction(self.menuOptions.menuAction())
237 self.menuBar.addAction(self.menuHelp.menuAction())
237 self.menuBar.addAction(self.menuHelp.menuAction())
238
238
239 self.tabConsole.setCurrentIndex(0)
239 self.tabConsole.setCurrentIndex(0)
240 self.tabWidget.setCurrentIndex(0)
240 self.tabWidget.setCurrentIndex(0)
241
241
242 def retranslateUi(self, MainWindow):
242 def retranslateUi(self, MainWindow):
243
243
244 MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
244 MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
245
245
246 self.tabConsole.setTabText(self.tabConsole.indexOf(self.tab_5), _translate("MainWindow", "Console", None))
246 self.tabConsole.setTabText(self.tabConsole.indexOf(self.tab_5), _translate("MainWindow", "Console", None))
247
247
248 self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabProjectProperty), _translate("MainWindow", "Project Property", None))
248 self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabProjectProperty), _translate("MainWindow", "Project Property", None))
249 self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar", None))
249 self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar", None))
250 self.menuProject.setTitle(_translate("MainWindow", "Project", None))
250 self.menuProject.setTitle(_translate("MainWindow", "Project", None))
251 self.menuRun.setTitle(_translate("MainWindow", "Run", None))
251 self.menuRun.setTitle(_translate("MainWindow", "Run", None))
252 self.menuOptions.setTitle(_translate("MainWindow", "Options", None))
252 self.menuOptions.setTitle(_translate("MainWindow", "Options", None))
253 self.menuHelp.setTitle(_translate("MainWindow", "Help", None))
253 self.menuHelp.setTitle(_translate("MainWindow", "Help", None))
254 self.actionOpen.setText(_translate("MainWindow", "Open", None))
254 self.actionOpen.setText(_translate("MainWindow", "Open", None))
255 self.actionCreate.setText(_translate("MainWindow", "Create", None))
255 self.actionCreate.setText(_translate("MainWindow", "Create", None))
256 self.actionSave.setText(_translate("MainWindow", "Save", None))
256 self.actionSave.setText(_translate("MainWindow", "Save", None))
257 self.actionClose.setText(_translate("MainWindow", "Close", None))
257 self.actionClose.setText(_translate("MainWindow", "Close", None))
258 self.actionStart.setText(_translate("MainWindow", "Start", None))
258 self.actionStart.setText(_translate("MainWindow", "Start", None))
259 self.actionPause.setText(_translate("MainWindow", "Pause", None))
259 self.actionPause.setText(_translate("MainWindow", "Pause", None))
260 self.actionStop.setText(_translate("MainWindow", "Stop", None))
260 self.actionStop.setText(_translate("MainWindow", "Stop", None))
261 self.actionAbout.setText(_translate("MainWindow", "About SChain", None))
261 self.actionAbout.setText(_translate("MainWindow", "About SChain", None))
262 self.actionOpenToolbar.setText(_translate("MainWindow", "openToolbar", None))
262 self.actionOpenToolbar.setText(_translate("MainWindow", "openToolbar", None))
263 self.actionOpenToolbar.setToolTip(_translate("MainWindow", "Open a project", None))
263 self.actionOpenToolbar.setToolTip(_translate("MainWindow", "Open a project", None))
264 self.actionCreateToolbar.setText(_translate("MainWindow", "createToolbar", None))
264 self.actionCreateToolbar.setText(_translate("MainWindow", "createToolbar", None))
265 self.actionCreateToolbar.setToolTip(_translate("MainWindow", "Create a new project", None))
265 self.actionCreateToolbar.setToolTip(_translate("MainWindow", "Create a new project", None))
266 self.actionSaveToolbar.setText(_translate("MainWindow", "saveToolbar", None))
266 self.actionSaveToolbar.setText(_translate("MainWindow", "saveToolbar", None))
267 self.actionSaveToolbar.setToolTip(_translate("MainWindow", "Save a project", None))
267 self.actionSaveToolbar.setToolTip(_translate("MainWindow", "Save a project", None))
268 self.actionStarToolbar.setText(_translate("MainWindow", "starToolbar", None))
268 self.actionStarToolbar.setText(_translate("MainWindow", "starToolbar", None))
269 self.actionStarToolbar.setToolTip(_translate("MainWindow", "Start process", None))
269 self.actionStarToolbar.setToolTip(_translate("MainWindow", "Start process", None))
270 self.actionStopToolbar.setText(_translate("MainWindow", "stopToolbar", None))
270 self.actionStopToolbar.setText(_translate("MainWindow", "stopToolbar", None))
271 self.actionStopToolbar.setToolTip(_translate("MainWindow", "Stop process", None))
271 self.actionStopToolbar.setToolTip(_translate("MainWindow", "Stop process", None))
272 self.actionPauseToolbar.setText(_translate("MainWindow", "pauseToolbar", None))
272 self.actionPauseToolbar.setText(_translate("MainWindow", "pauseToolbar", None))
273 self.actionPauseToolbar.setToolTip(_translate("MainWindow", "Pause process", None))
273 self.actionPauseToolbar.setToolTip(_translate("MainWindow", "Pause process", None))
274 self.actionAddPU.setText(_translate("MainWindow", "Add Processing Unit", None))
274 self.actionAddPU.setText(_translate("MainWindow", "Add Processing Unit", None))
275 self.actionFTP.setText(_translate("MainWindow", "FTP", None))
275 self.actionFTP.setText(_translate("MainWindow", "FTP", None))
276
276
277 def closeEvent(self, event):
277 def closeEvent(self, event):
278
278
279 reply = QtGui.QMessageBox.question(self, 'Message',
279 reply = QtGui.QMessageBox.question(self, 'Message',
280 "Are you sure to quit?", QtGui.QMessageBox.Yes |
280 "Are you sure to quit?", QtGui.QMessageBox.Yes |
281 QtGui.QMessageBox.No, QtGui.QMessageBox.No)
281 QtGui.QMessageBox.No, QtGui.QMessageBox.No)
282 if reply == QtGui.QMessageBox.Yes:
282 if reply == QtGui.QMessageBox.Yes:
283 event.accept()
283 event.accept()
284 else:
284 else:
285 event.ignore()
285 event.ignore()
286
286
287 def aboutEvent(self):
287 def aboutEvent(self):
288 title = "Signal Chain Processing Software v%s" %__version__
288 title = "Signal Chain Processing Software v%s" %__version__
289 message = """
289 message = """
290 Developed by Jicamarca Radio Observatory
290 Developed by Jicamarca Radio Observatory
291 Any comment to miguel.urco@jro.igp.gob.pe
291 Any comment to miguel.urco@jro.igp.gob.pe
292 """
292 """
293
294 QtGui.QMessageBox.about(self, title, message)
293 QtGui.QMessageBox.about(self, title, message)
295
294
296
295
297 class Ui_BasicWindow(Ui_EnvWindow, Ui_ProjectTab, Ui_VoltageTab, Ui_SpectraTab, Ui_SpectraHeisTab, Ui_CorrelationTab):
296 class Ui_BasicWindow(Ui_EnvWindow, Ui_ProjectTab, Ui_VoltageTab, Ui_SpectraTab, Ui_SpectraHeisTab, Ui_CorrelationTab):
298
297
299 def setupUi(self, MainWindow):
298 def setupUi(self, MainWindow):
300
299
301 Ui_EnvWindow.setupUi(self, MainWindow)
300 Ui_EnvWindow.setupUi(self, MainWindow)
302
301
303 Ui_ProjectTab.setupUi(self)
302 Ui_ProjectTab.setupUi(self)
304 Ui_VoltageTab.setupUi(self)
303 Ui_VoltageTab.setupUi(self)
305 Ui_SpectraTab.setupUi(self)
304 Ui_SpectraTab.setupUi(self)
306 Ui_SpectraHeisTab.setupUi(self)
305 Ui_SpectraHeisTab.setupUi(self)
307 Ui_CorrelationTab.setupUi(self)
306 Ui_CorrelationTab.setupUi(self)
308
307
309 self.retranslateUi(MainWindow)
308 self.retranslateUi(MainWindow)
310
309
311 QtCore.QMetaObject.connectSlotsByName(MainWindow)
310 QtCore.QMetaObject.connectSlotsByName(MainWindow)
312
311
313 def retranslateUi(self, MainWindow):
312 def retranslateUi(self, MainWindow):
314
313
315 Ui_EnvWindow.retranslateUi(self, MainWindow)
314 Ui_EnvWindow.retranslateUi(self, MainWindow)
316
315
317 Ui_ProjectTab.retranslateUi(self)
316 Ui_ProjectTab.retranslateUi(self)
318 Ui_VoltageTab.retranslateUi(self)
317 Ui_VoltageTab.retranslateUi(self)
319 Ui_SpectraTab.retranslateUi(self)
318 Ui_SpectraTab.retranslateUi(self)
320 Ui_SpectraHeisTab.retranslateUi(self)
319 Ui_SpectraHeisTab.retranslateUi(self)
321 Ui_CorrelationTab.retranslateUi(self)
320 Ui_CorrelationTab.retranslateUi(self)
322
321
323
322
324 class Ui_AdvancedWindow(Ui_EnvWindow):
323 class Ui_AdvancedWindow(Ui_EnvWindow):
325
324
326 def setupUi(self, AdvancedWindow):
325 def setupUi(self, AdvancedWindow):
327
326
328 Ui_MainWindow.setupUi(self, AdvancedWindow)
327 Ui_MainWindow.setupUi(self, AdvancedWindow)
329
328
330 def retranslateUi(self, AdvancedWindow):
329 def retranslateUi(self, AdvancedWindow):
331
330
332 Ui_MainWindow.retranslateUi(self, AdvancedWindow)
331 Ui_MainWindow.retranslateUi(self, AdvancedWindow)
333
332
334
333
335
334
336 if __name__ == "__main__":
335 if __name__ == "__main__":
337 import sys
336 import sys
338 app = QtGui.QApplication(sys.argv)
337 app = QtGui.QApplication(sys.argv)
339 MainWindow = QtGui.QMainWindow()
338 MainWindow = QtGui.QMainWindow()
340 ui = Ui_BasicWindow()
339 ui = Ui_BasicWindow()
341 ui.setupUi(MainWindow)
340 ui.setupUi(MainWindow)
342 MainWindow.show()
341 MainWindow.show()
343 sys.exit(app.exec_())
342 sys.exit(app.exec_())
344
343
@@ -1,721 +1,724
1 '''
1 '''
2
2
3 $Author: murco $
3 $Author: murco $
4 $Id: JROHeaderIO.py 151 2012-10-31 19:00:51Z murco $
4 $Id: JROHeaderIO.py 151 2012-10-31 19:00:51Z murco $
5 '''
5 '''
6 import numpy
6 import numpy
7 import copy
7 import copy
8 import datetime
8 import datetime
9
9
10 SPEED_OF_LIGHT = 299792458
10 SPEED_OF_LIGHT = 299792458
11 SPEED_OF_LIGHT = 3e8
11 SPEED_OF_LIGHT = 3e8
12
12
13 BASIC_STRUCTURE = numpy.dtype([
13 BASIC_STRUCTURE = numpy.dtype([
14 ('nSize','<u4'),
14 ('nSize','<u4'),
15 ('nVersion','<u2'),
15 ('nVersion','<u2'),
16 ('nDataBlockId','<u4'),
16 ('nDataBlockId','<u4'),
17 ('nUtime','<u4'),
17 ('nUtime','<u4'),
18 ('nMilsec','<u2'),
18 ('nMilsec','<u2'),
19 ('nTimezone','<i2'),
19 ('nTimezone','<i2'),
20 ('nDstflag','<i2'),
20 ('nDstflag','<i2'),
21 ('nErrorCount','<u4')
21 ('nErrorCount','<u4')
22 ])
22 ])
23
23
24 SYSTEM_STRUCTURE = numpy.dtype([
24 SYSTEM_STRUCTURE = numpy.dtype([
25 ('nSize','<u4'),
25 ('nSize','<u4'),
26 ('nNumSamples','<u4'),
26 ('nNumSamples','<u4'),
27 ('nNumProfiles','<u4'),
27 ('nNumProfiles','<u4'),
28 ('nNumChannels','<u4'),
28 ('nNumChannels','<u4'),
29 ('nADCResolution','<u4'),
29 ('nADCResolution','<u4'),
30 ('nPCDIOBusWidth','<u4'),
30 ('nPCDIOBusWidth','<u4'),
31 ])
31 ])
32
32
33 RADAR_STRUCTURE = numpy.dtype([
33 RADAR_STRUCTURE = numpy.dtype([
34 ('nSize','<u4'),
34 ('nSize','<u4'),
35 ('nExpType','<u4'),
35 ('nExpType','<u4'),
36 ('nNTx','<u4'),
36 ('nNTx','<u4'),
37 ('fIpp','<f4'),
37 ('fIpp','<f4'),
38 ('fTxA','<f4'),
38 ('fTxA','<f4'),
39 ('fTxB','<f4'),
39 ('fTxB','<f4'),
40 ('nNumWindows','<u4'),
40 ('nNumWindows','<u4'),
41 ('nNumTaus','<u4'),
41 ('nNumTaus','<u4'),
42 ('nCodeType','<u4'),
42 ('nCodeType','<u4'),
43 ('nLine6Function','<u4'),
43 ('nLine6Function','<u4'),
44 ('nLine5Function','<u4'),
44 ('nLine5Function','<u4'),
45 ('fClock','<f4'),
45 ('fClock','<f4'),
46 ('nPrePulseBefore','<u4'),
46 ('nPrePulseBefore','<u4'),
47 ('nPrePulseAfter','<u4'),
47 ('nPrePulseAfter','<u4'),
48 ('sRangeIPP','<a20'),
48 ('sRangeIPP','<a20'),
49 ('sRangeTxA','<a20'),
49 ('sRangeTxA','<a20'),
50 ('sRangeTxB','<a20'),
50 ('sRangeTxB','<a20'),
51 ])
51 ])
52
52
53 SAMPLING_STRUCTURE = numpy.dtype([('h0','<f4'),('dh','<f4'),('nsa','<u4')])
53 SAMPLING_STRUCTURE = numpy.dtype([('h0','<f4'),('dh','<f4'),('nsa','<u4')])
54
54
55
55
56 PROCESSING_STRUCTURE = numpy.dtype([
56 PROCESSING_STRUCTURE = numpy.dtype([
57 ('nSize','<u4'),
57 ('nSize','<u4'),
58 ('nDataType','<u4'),
58 ('nDataType','<u4'),
59 ('nSizeOfDataBlock','<u4'),
59 ('nSizeOfDataBlock','<u4'),
60 ('nProfilesperBlock','<u4'),
60 ('nProfilesperBlock','<u4'),
61 ('nDataBlocksperFile','<u4'),
61 ('nDataBlocksperFile','<u4'),
62 ('nNumWindows','<u4'),
62 ('nNumWindows','<u4'),
63 ('nProcessFlags','<u4'),
63 ('nProcessFlags','<u4'),
64 ('nCoherentIntegrations','<u4'),
64 ('nCoherentIntegrations','<u4'),
65 ('nIncoherentIntegrations','<u4'),
65 ('nIncoherentIntegrations','<u4'),
66 ('nTotalSpectra','<u4')
66 ('nTotalSpectra','<u4')
67 ])
67 ])
68
68
69 class Header(object):
69 class Header(object):
70
70
71 def __init__(self):
71 def __init__(self):
72 raise
72 raise
73
73
74 def copy(self):
74 def copy(self):
75 return copy.deepcopy(self)
75 return copy.deepcopy(self)
76
76
77 def read(self):
77 def read(self):
78
78
79 raise ValueError
79 raise ValueError
80
80
81 def write(self):
81 def write(self):
82
82
83 raise ValueError
83 raise ValueError
84
84
85 def printInfo(self):
85 def printInfo(self):
86
86
87 print "#"*100
87 message = "#"*50 + "\n"
88 print self.__class__.__name__.upper()
88 message += self.__class__.__name__.upper() + "\n"
89 print "#"*100
89 message += "#"*50 + "\n"
90
90 for key in self.__dict__.keys():
91 for key in self.__dict__.keys():
91 print "%s = %s" %(key, self.__dict__[key])
92 message += "%s = %s" %(key, self.__dict__[key]) + "\n"
93
94 print message
92
95
93 class BasicHeader(Header):
96 class BasicHeader(Header):
94
97
95 size = None
98 size = None
96 version = None
99 version = None
97 dataBlock = None
100 dataBlock = None
98 utc = None
101 utc = None
99 ltc = None
102 ltc = None
100 miliSecond = None
103 miliSecond = None
101 timeZone = None
104 timeZone = None
102 dstFlag = None
105 dstFlag = None
103 errorCount = None
106 errorCount = None
104 datatime = None
107 datatime = None
105
108
106 __LOCALTIME = None
109 __LOCALTIME = None
107
110
108 def __init__(self, useLocalTime=True):
111 def __init__(self, useLocalTime=True):
109
112
110 self.size = 24
113 self.size = 24
111 self.version = 0
114 self.version = 0
112 self.dataBlock = 0
115 self.dataBlock = 0
113 self.utc = 0
116 self.utc = 0
114 self.miliSecond = 0
117 self.miliSecond = 0
115 self.timeZone = 0
118 self.timeZone = 0
116 self.dstFlag = 0
119 self.dstFlag = 0
117 self.errorCount = 0
120 self.errorCount = 0
118
121
119 self.useLocalTime = useLocalTime
122 self.useLocalTime = useLocalTime
120
123
121 def read(self, fp):
124 def read(self, fp):
122 try:
125 try:
123
126
124 header = numpy.fromfile(fp, BASIC_STRUCTURE,1)
127 header = numpy.fromfile(fp, BASIC_STRUCTURE,1)
125
128
126 self.size = int(header['nSize'][0])
129 self.size = int(header['nSize'][0])
127 self.version = int(header['nVersion'][0])
130 self.version = int(header['nVersion'][0])
128 self.dataBlock = int(header['nDataBlockId'][0])
131 self.dataBlock = int(header['nDataBlockId'][0])
129 self.utc = int(header['nUtime'][0])
132 self.utc = int(header['nUtime'][0])
130 self.miliSecond = int(header['nMilsec'][0])
133 self.miliSecond = int(header['nMilsec'][0])
131 self.timeZone = int(header['nTimezone'][0])
134 self.timeZone = int(header['nTimezone'][0])
132 self.dstFlag = int(header['nDstflag'][0])
135 self.dstFlag = int(header['nDstflag'][0])
133 self.errorCount = int(header['nErrorCount'][0])
136 self.errorCount = int(header['nErrorCount'][0])
134
137
135 except Exception, e:
138 except Exception, e:
136 print "BasicHeader: "
139 print "BasicHeader: "
137 print e
140 print e
138 return 0
141 return 0
139
142
140 return 1
143 return 1
141
144
142 def write(self, fp):
145 def write(self, fp):
143
146
144 headerTuple = (self.size,self.version,self.dataBlock,self.utc,self.miliSecond,self.timeZone,self.dstFlag,self.errorCount)
147 headerTuple = (self.size,self.version,self.dataBlock,self.utc,self.miliSecond,self.timeZone,self.dstFlag,self.errorCount)
145 header = numpy.array(headerTuple, BASIC_STRUCTURE)
148 header = numpy.array(headerTuple, BASIC_STRUCTURE)
146 header.tofile(fp)
149 header.tofile(fp)
147
150
148 return 1
151 return 1
149
152
150 def get_ltc(self):
153 def get_ltc(self):
151
154
152 return self.utc - self.timeZone*60
155 return self.utc - self.timeZone*60
153
156
154 def set_ltc(self, value):
157 def set_ltc(self, value):
155
158
156 self.utc = value + self.timeZone*60
159 self.utc = value + self.timeZone*60
157
160
158 def get_datatime(self):
161 def get_datatime(self):
159
162
160 return datetime.datetime.utcfromtimestamp(self.ltc)
163 return datetime.datetime.utcfromtimestamp(self.ltc)
161
164
162 ltc = property(get_ltc, set_ltc)
165 ltc = property(get_ltc, set_ltc)
163 datatime = property(get_datatime)
166 datatime = property(get_datatime)
164
167
165 class SystemHeader(Header):
168 class SystemHeader(Header):
166
169
167 size = None
170 size = None
168 nSamples = None
171 nSamples = None
169 nProfiles = None
172 nProfiles = None
170 nChannels = None
173 nChannels = None
171 adcResolution = None
174 adcResolution = None
172 pciDioBusWidth = None
175 pciDioBusWidth = None
173
176
174 def __init__(self, nSamples=0, nProfiles=0, nChannels=0, adcResolution=14, pciDioBusWith=0):
177 def __init__(self, nSamples=0, nProfiles=0, nChannels=0, adcResolution=14, pciDioBusWith=0):
175
178
176 self.size = 24
179 self.size = 24
177 self.nSamples = nSamples
180 self.nSamples = nSamples
178 self.nProfiles = nProfiles
181 self.nProfiles = nProfiles
179 self.nChannels = nChannels
182 self.nChannels = nChannels
180 self.adcResolution = adcResolution
183 self.adcResolution = adcResolution
181 self.pciDioBusWidth = pciDioBusWith
184 self.pciDioBusWidth = pciDioBusWith
182
185
183 def read(self, fp):
186 def read(self, fp):
184
187
185 startFp = fp.tell()
188 startFp = fp.tell()
186
189
187 try:
190 try:
188 header = numpy.fromfile(fp,SYSTEM_STRUCTURE,1)
191 header = numpy.fromfile(fp,SYSTEM_STRUCTURE,1)
189
192
190 self.size = header['nSize'][0]
193 self.size = header['nSize'][0]
191 self.nSamples = header['nNumSamples'][0]
194 self.nSamples = header['nNumSamples'][0]
192 self.nProfiles = header['nNumProfiles'][0]
195 self.nProfiles = header['nNumProfiles'][0]
193 self.nChannels = header['nNumChannels'][0]
196 self.nChannels = header['nNumChannels'][0]
194 self.adcResolution = header['nADCResolution'][0]
197 self.adcResolution = header['nADCResolution'][0]
195 self.pciDioBusWidth = header['nPCDIOBusWidth'][0]
198 self.pciDioBusWidth = header['nPCDIOBusWidth'][0]
196
199
197 except Exception, e:
200 except Exception, e:
198 print "SystemHeader: " + e
201 print "SystemHeader: " + e
199 return 0
202 return 0
200
203
201 endFp = self.size + startFp
204 endFp = self.size + startFp
202
205
203 if fp.tell() != endFp:
206 if fp.tell() != endFp:
204 raise IOError, "System Header is not consistent"
207 raise IOError, "System Header is not consistent"
205
208
206 return 1
209 return 1
207
210
208 def write(self, fp):
211 def write(self, fp):
209
212
210 headerTuple = (self.size,self.nSamples,self.nProfiles,self.nChannels,self.adcResolution,self.pciDioBusWidth)
213 headerTuple = (self.size,self.nSamples,self.nProfiles,self.nChannels,self.adcResolution,self.pciDioBusWidth)
211 header = numpy.array(headerTuple,SYSTEM_STRUCTURE)
214 header = numpy.array(headerTuple,SYSTEM_STRUCTURE)
212 header.tofile(fp)
215 header.tofile(fp)
213
216
214 return 1
217 return 1
215
218
216 class RadarControllerHeader(Header):
219 class RadarControllerHeader(Header):
217
220
218 size = None
221 size = None
219 expType = None
222 expType = None
220 nTx = None
223 nTx = None
221 ipp = None
224 ipp = None
222 txA = None
225 txA = None
223 txB = None
226 txB = None
224 nWindows = None
227 nWindows = None
225 numTaus = None
228 numTaus = None
226 codeType = None
229 codeType = None
227 line6Function = None
230 line6Function = None
228 line5Function = None
231 line5Function = None
229 fClock = None
232 fClock = None
230 prePulseBefore = None
233 prePulseBefore = None
231 prePulserAfter = None
234 prePulserAfter = None
232 rangeIpp = None
235 rangeIpp = None
233 rangeTxA = None
236 rangeTxA = None
234 rangeTxB = None
237 rangeTxB = None
235
238
236 __size = None
239 __size = None
237
240
238 def __init__(self, expType=2, nTx=1,
241 def __init__(self, expType=2, nTx=1,
239 ippKm=None, txA=0, txB=0,
242 ippKm=None, txA=0, txB=0,
240 nWindows=None, nHeights=None, firstHeight=None, deltaHeight=None,
243 nWindows=None, nHeights=None, firstHeight=None, deltaHeight=None,
241 numTaus=0, line6Function=0, line5Function=0, fClock=None,
244 numTaus=0, line6Function=0, line5Function=0, fClock=None,
242 prePulseBefore=0, prePulseAfter=0,
245 prePulseBefore=0, prePulseAfter=0,
243 codeType=0, nCode=0, nBaud=0, code=None,
246 codeType=0, nCode=0, nBaud=0, code=None,
244 flip1=0, flip2=0):
247 flip1=0, flip2=0):
245
248
246 self.size = 116
249 self.size = 116
247 self.expType = expType
250 self.expType = expType
248 self.nTx = nTx
251 self.nTx = nTx
249 self.ipp = ippKm
252 self.ipp = ippKm
250 self.txA = txA
253 self.txA = txA
251 self.txB = txB
254 self.txB = txB
252 self.rangeIpp = ippKm
255 self.rangeIpp = ippKm
253 self.rangeTxA = txA
256 self.rangeTxA = txA
254 self.rangeTxB = txB
257 self.rangeTxB = txB
255
258
256 self.nWindows = nWindows
259 self.nWindows = nWindows
257 self.numTaus = numTaus
260 self.numTaus = numTaus
258 self.codeType = codeType
261 self.codeType = codeType
259 self.line6Function = line6Function
262 self.line6Function = line6Function
260 self.line5Function = line5Function
263 self.line5Function = line5Function
261 self.fClock = fClock
264 self.fClock = fClock
262 self.prePulseBefore = prePulseBefore
265 self.prePulseBefore = prePulseBefore
263 self.prePulserAfter = prePulseAfter
266 self.prePulserAfter = prePulseAfter
264
267
265 self.nHeights = nHeights
268 self.nHeights = nHeights
266 self.firstHeight = firstHeight
269 self.firstHeight = firstHeight
267 self.deltaHeight = deltaHeight
270 self.deltaHeight = deltaHeight
268 self.samplesWin = nHeights
271 self.samplesWin = nHeights
269
272
270 self.nCode = nCode
273 self.nCode = nCode
271 self.nBaud = nBaud
274 self.nBaud = nBaud
272 self.code = code
275 self.code = code
273 self.flip1 = flip1
276 self.flip1 = flip1
274 self.flip2 = flip2
277 self.flip2 = flip2
275
278
276 self.code_size = int(numpy.ceil(self.nBaud/32.))*self.nCode*4
279 self.code_size = int(numpy.ceil(self.nBaud/32.))*self.nCode*4
277 # self.dynamic = numpy.array([],numpy.dtype('byte'))
280 # self.dynamic = numpy.array([],numpy.dtype('byte'))
278
281
279 if self.fClock is None and self.deltaHeight is not None:
282 if self.fClock is None and self.deltaHeight is not None:
280 self.fClock = 0.15/(deltaHeight*1e-6) #0.15Km / (height * 1u)
283 self.fClock = 0.15/(deltaHeight*1e-6) #0.15Km / (height * 1u)
281
284
282 def read(self, fp):
285 def read(self, fp):
283
286
284
287
285 startFp = fp.tell()
288 startFp = fp.tell()
286 header = numpy.fromfile(fp,RADAR_STRUCTURE,1)
289 header = numpy.fromfile(fp,RADAR_STRUCTURE,1)
287
290
288 size = int(header['nSize'][0])
291 size = int(header['nSize'][0])
289 self.expType = int(header['nExpType'][0])
292 self.expType = int(header['nExpType'][0])
290 self.nTx = int(header['nNTx'][0])
293 self.nTx = int(header['nNTx'][0])
291 self.ipp = float(header['fIpp'][0])
294 self.ipp = float(header['fIpp'][0])
292 self.txA = float(header['fTxA'][0])
295 self.txA = float(header['fTxA'][0])
293 self.txB = float(header['fTxB'][0])
296 self.txB = float(header['fTxB'][0])
294 self.nWindows = int(header['nNumWindows'][0])
297 self.nWindows = int(header['nNumWindows'][0])
295 self.numTaus = int(header['nNumTaus'][0])
298 self.numTaus = int(header['nNumTaus'][0])
296 self.codeType = int(header['nCodeType'][0])
299 self.codeType = int(header['nCodeType'][0])
297 self.line6Function = int(header['nLine6Function'][0])
300 self.line6Function = int(header['nLine6Function'][0])
298 self.line5Function = int(header['nLine5Function'][0])
301 self.line5Function = int(header['nLine5Function'][0])
299 self.fClock = float(header['fClock'][0])
302 self.fClock = float(header['fClock'][0])
300 self.prePulseBefore = int(header['nPrePulseBefore'][0])
303 self.prePulseBefore = int(header['nPrePulseBefore'][0])
301 self.prePulserAfter = int(header['nPrePulseAfter'][0])
304 self.prePulserAfter = int(header['nPrePulseAfter'][0])
302 self.rangeIpp = header['sRangeIPP'][0]
305 self.rangeIpp = header['sRangeIPP'][0]
303 self.rangeTxA = header['sRangeTxA'][0]
306 self.rangeTxA = header['sRangeTxA'][0]
304 self.rangeTxB = header['sRangeTxB'][0]
307 self.rangeTxB = header['sRangeTxB'][0]
305
308
306 samplingWindow = numpy.fromfile(fp,SAMPLING_STRUCTURE,self.nWindows)
309 samplingWindow = numpy.fromfile(fp,SAMPLING_STRUCTURE,self.nWindows)
307
310
308 self.nHeights = int(numpy.sum(samplingWindow['nsa']))
311 self.nHeights = int(numpy.sum(samplingWindow['nsa']))
309 self.firstHeight = samplingWindow['h0']
312 self.firstHeight = samplingWindow['h0']
310 self.deltaHeight = samplingWindow['dh']
313 self.deltaHeight = samplingWindow['dh']
311 self.samplesWin = samplingWindow['nsa']
314 self.samplesWin = samplingWindow['nsa']
312
315
313 self.Taus = numpy.fromfile(fp,'<f4',self.numTaus)
316 self.Taus = numpy.fromfile(fp,'<f4',self.numTaus)
314
317
315 self.code_size = 0
318 self.code_size = 0
316 if self.codeType != 0:
319 if self.codeType != 0:
317 self.nCode = int(numpy.fromfile(fp,'<u4',1))
320 self.nCode = int(numpy.fromfile(fp,'<u4',1))
318 self.nBaud = int(numpy.fromfile(fp,'<u4',1))
321 self.nBaud = int(numpy.fromfile(fp,'<u4',1))
319
322
320 code = numpy.empty([self.nCode,self.nBaud],dtype='i1')
323 code = numpy.empty([self.nCode,self.nBaud],dtype='i1')
321 for ic in range(self.nCode):
324 for ic in range(self.nCode):
322 temp = numpy.fromfile(fp,'u4',int(numpy.ceil(self.nBaud/32.)))
325 temp = numpy.fromfile(fp,'u4',int(numpy.ceil(self.nBaud/32.)))
323 for ib in range(self.nBaud-1,-1,-1):
326 for ib in range(self.nBaud-1,-1,-1):
324 code[ic,ib] = temp[ib/32]%2
327 code[ic,ib] = temp[ib/32]%2
325 temp[ib/32] = temp[ib/32]/2
328 temp[ib/32] = temp[ib/32]/2
326
329
327 self.code = 2.0*code - 1.0
330 self.code = 2.0*code - 1.0
328 self.code_size = int(numpy.ceil(self.nBaud/32.))*self.nCode*4
331 self.code_size = int(numpy.ceil(self.nBaud/32.))*self.nCode*4
329
332
330 # if self.line5Function == RCfunction.FLIP:
333 # if self.line5Function == RCfunction.FLIP:
331 # self.flip1 = numpy.fromfile(fp,'<u4',1)
334 # self.flip1 = numpy.fromfile(fp,'<u4',1)
332 #
335 #
333 # if self.line6Function == RCfunction.FLIP:
336 # if self.line6Function == RCfunction.FLIP:
334 # self.flip2 = numpy.fromfile(fp,'<u4',1)
337 # self.flip2 = numpy.fromfile(fp,'<u4',1)
335
338
336 endFp = size + startFp
339 endFp = size + startFp
337
340
338 if fp.tell() != endFp:
341 if fp.tell() != endFp:
339 raise IOError, "Radar Controller Header is not consistent"
342 raise IOError, "Radar Controller Header is not consistent"
340
343
341 return 1
344 return 1
342
345
343 def write(self, fp):
346 def write(self, fp):
344
347
345 headerTuple = (self.size,
348 headerTuple = (self.size,
346 self.expType,
349 self.expType,
347 self.nTx,
350 self.nTx,
348 self.ipp,
351 self.ipp,
349 self.txA,
352 self.txA,
350 self.txB,
353 self.txB,
351 self.nWindows,
354 self.nWindows,
352 self.numTaus,
355 self.numTaus,
353 self.codeType,
356 self.codeType,
354 self.line6Function,
357 self.line6Function,
355 self.line5Function,
358 self.line5Function,
356 self.fClock,
359 self.fClock,
357 self.prePulseBefore,
360 self.prePulseBefore,
358 self.prePulserAfter,
361 self.prePulserAfter,
359 self.rangeIpp,
362 self.rangeIpp,
360 self.rangeTxA,
363 self.rangeTxA,
361 self.rangeTxB)
364 self.rangeTxB)
362
365
363 header = numpy.array(headerTuple,RADAR_STRUCTURE)
366 header = numpy.array(headerTuple,RADAR_STRUCTURE)
364 header.tofile(fp)
367 header.tofile(fp)
365
368
366 sampleWindowTuple = (self.firstHeight,self.deltaHeight,self.samplesWin)
369 sampleWindowTuple = (self.firstHeight,self.deltaHeight,self.samplesWin)
367 samplingWindow = numpy.array(sampleWindowTuple,SAMPLING_STRUCTURE)
370 samplingWindow = numpy.array(sampleWindowTuple,SAMPLING_STRUCTURE)
368 samplingWindow.tofile(fp)
371 samplingWindow.tofile(fp)
369
372
370 if self.numTaus > 0:
373 if self.numTaus > 0:
371 self.Taus.tofile(fp)
374 self.Taus.tofile(fp)
372
375
373 if self.codeType !=0:
376 if self.codeType !=0:
374 nCode = numpy.array(self.nCode, '<u4')
377 nCode = numpy.array(self.nCode, '<u4')
375 nCode.tofile(fp)
378 nCode.tofile(fp)
376 nBaud = numpy.array(self.nBaud, '<u4')
379 nBaud = numpy.array(self.nBaud, '<u4')
377 nBaud.tofile(fp)
380 nBaud.tofile(fp)
378 code1 = (self.code + 1.0)/2.
381 code1 = (self.code + 1.0)/2.
379
382
380 for ic in range(self.nCode):
383 for ic in range(self.nCode):
381 tempx = numpy.zeros(numpy.ceil(self.nBaud/32.))
384 tempx = numpy.zeros(numpy.ceil(self.nBaud/32.))
382 start = 0
385 start = 0
383 end = 32
386 end = 32
384 for i in range(len(tempx)):
387 for i in range(len(tempx)):
385 code_selected = code1[ic,start:end]
388 code_selected = code1[ic,start:end]
386 for j in range(len(code_selected)-1,-1,-1):
389 for j in range(len(code_selected)-1,-1,-1):
387 if code_selected[j] == 1:
390 if code_selected[j] == 1:
388 tempx[i] = tempx[i] + 2**(len(code_selected)-1-j)
391 tempx[i] = tempx[i] + 2**(len(code_selected)-1-j)
389 start = start + 32
392 start = start + 32
390 end = end + 32
393 end = end + 32
391
394
392 tempx = tempx.astype('u4')
395 tempx = tempx.astype('u4')
393 tempx.tofile(fp)
396 tempx.tofile(fp)
394
397
395 # if self.line5Function == RCfunction.FLIP:
398 # if self.line5Function == RCfunction.FLIP:
396 # self.flip1.tofile(fp)
399 # self.flip1.tofile(fp)
397 #
400 #
398 # if self.line6Function == RCfunction.FLIP:
401 # if self.line6Function == RCfunction.FLIP:
399 # self.flip2.tofile(fp)
402 # self.flip2.tofile(fp)
400
403
401 return 1
404 return 1
402
405
403 def get_ippSeconds(self):
406 def get_ippSeconds(self):
404 '''
407 '''
405 '''
408 '''
406 ippSeconds = 2.0 * 1000 * self.ipp / SPEED_OF_LIGHT
409 ippSeconds = 2.0 * 1000 * self.ipp / SPEED_OF_LIGHT
407
410
408 return ippSeconds
411 return ippSeconds
409
412
410 def set_ippSeconds(self, ippSeconds):
413 def set_ippSeconds(self, ippSeconds):
411 '''
414 '''
412 '''
415 '''
413
416
414 self.ipp = ippSeconds * SPEED_OF_LIGHT / (2.0*1000)
417 self.ipp = ippSeconds * SPEED_OF_LIGHT / (2.0*1000)
415
418
416 return
419 return
417
420
418 def get_size(self):
421 def get_size(self):
419
422
420 self.__size = 116 + 12*self.nWindows + 4*self.numTaus
423 self.__size = 116 + 12*self.nWindows + 4*self.numTaus
421
424
422 if self.codeType != 0:
425 if self.codeType != 0:
423 self.__size += 4 + 4 + 4*self.nCode*numpy.ceil(self.nBaud/32.)
426 self.__size += 4 + 4 + 4*self.nCode*numpy.ceil(self.nBaud/32.)
424
427
425 return self.__size
428 return self.__size
426
429
427 def set_size(self, value):
430 def set_size(self, value):
428
431
429 self.__size = value
432 self.__size = value
430
433
431 return
434 return
432
435
433 ippSeconds = property(get_ippSeconds, set_ippSeconds)
436 ippSeconds = property(get_ippSeconds, set_ippSeconds)
434 size = property(get_size, set_size)
437 size = property(get_size, set_size)
435
438
436 class ProcessingHeader(Header):
439 class ProcessingHeader(Header):
437
440
438 # size = None
441 # size = None
439 dtype = None
442 dtype = None
440 blockSize = None
443 blockSize = None
441 profilesPerBlock = None
444 profilesPerBlock = None
442 dataBlocksPerFile = None
445 dataBlocksPerFile = None
443 nWindows = None
446 nWindows = None
444 processFlags = None
447 processFlags = None
445 nCohInt = None
448 nCohInt = None
446 nIncohInt = None
449 nIncohInt = None
447 totalSpectra = None
450 totalSpectra = None
448
451
449 flag_dc = None
452 flag_dc = None
450 flag_cspc = None
453 flag_cspc = None
451
454
452 def __init__(self):
455 def __init__(self):
453
456
454 # self.size = 0
457 # self.size = 0
455 self.dtype = 0
458 self.dtype = 0
456 self.blockSize = 0
459 self.blockSize = 0
457 self.profilesPerBlock = 0
460 self.profilesPerBlock = 0
458 self.dataBlocksPerFile = 0
461 self.dataBlocksPerFile = 0
459 self.nWindows = 0
462 self.nWindows = 0
460 self.processFlags = 0
463 self.processFlags = 0
461 self.nCohInt = 0
464 self.nCohInt = 0
462 self.nIncohInt = 0
465 self.nIncohInt = 0
463 self.totalSpectra = 0
466 self.totalSpectra = 0
464
467
465 self.nHeights = 0
468 self.nHeights = 0
466 self.firstHeight = 0
469 self.firstHeight = 0
467 self.deltaHeight = 0
470 self.deltaHeight = 0
468 self.samplesWin = 0
471 self.samplesWin = 0
469 self.spectraComb = 0
472 self.spectraComb = 0
470 self.nCode = None
473 self.nCode = None
471 self.code = None
474 self.code = None
472 self.nBaud = None
475 self.nBaud = None
473
476
474 self.shif_fft = False
477 self.shif_fft = False
475 self.flag_dc = False
478 self.flag_dc = False
476 self.flag_cspc = False
479 self.flag_cspc = False
477 self.flag_decode = False
480 self.flag_decode = False
478 self.flag_deflip = False
481 self.flag_deflip = False
479
482
480 def read(self, fp):
483 def read(self, fp):
481
484
482 startFp = fp.tell()
485 startFp = fp.tell()
483
486
484 header = numpy.fromfile(fp,PROCESSING_STRUCTURE,1)
487 header = numpy.fromfile(fp,PROCESSING_STRUCTURE,1)
485
488
486 size = int(header['nSize'][0])
489 size = int(header['nSize'][0])
487 self.dtype = int(header['nDataType'][0])
490 self.dtype = int(header['nDataType'][0])
488 self.blockSize = int(header['nSizeOfDataBlock'][0])
491 self.blockSize = int(header['nSizeOfDataBlock'][0])
489 self.profilesPerBlock = int(header['nProfilesperBlock'][0])
492 self.profilesPerBlock = int(header['nProfilesperBlock'][0])
490 self.dataBlocksPerFile = int(header['nDataBlocksperFile'][0])
493 self.dataBlocksPerFile = int(header['nDataBlocksperFile'][0])
491 self.nWindows = int(header['nNumWindows'][0])
494 self.nWindows = int(header['nNumWindows'][0])
492 self.processFlags = header['nProcessFlags']
495 self.processFlags = header['nProcessFlags']
493 self.nCohInt = int(header['nCoherentIntegrations'][0])
496 self.nCohInt = int(header['nCoherentIntegrations'][0])
494 self.nIncohInt = int(header['nIncoherentIntegrations'][0])
497 self.nIncohInt = int(header['nIncoherentIntegrations'][0])
495 self.totalSpectra = int(header['nTotalSpectra'][0])
498 self.totalSpectra = int(header['nTotalSpectra'][0])
496
499
497 samplingWindow = numpy.fromfile(fp,SAMPLING_STRUCTURE,self.nWindows)
500 samplingWindow = numpy.fromfile(fp,SAMPLING_STRUCTURE,self.nWindows)
498
501
499 self.nHeights = int(numpy.sum(samplingWindow['nsa']))
502 self.nHeights = int(numpy.sum(samplingWindow['nsa']))
500 self.firstHeight = float(samplingWindow['h0'][0])
503 self.firstHeight = float(samplingWindow['h0'][0])
501 self.deltaHeight = float(samplingWindow['dh'][0])
504 self.deltaHeight = float(samplingWindow['dh'][0])
502 self.samplesWin = samplingWindow['nsa'][0]
505 self.samplesWin = samplingWindow['nsa'][0]
503
506
504 self.spectraComb = numpy.fromfile(fp,'u1',2*self.totalSpectra)
507 self.spectraComb = numpy.fromfile(fp,'u1',2*self.totalSpectra)
505
508
506 if ((self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE) == PROCFLAG.DEFINE_PROCESS_CODE):
509 if ((self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE) == PROCFLAG.DEFINE_PROCESS_CODE):
507 self.nCode = int(numpy.fromfile(fp,'<u4',1))
510 self.nCode = int(numpy.fromfile(fp,'<u4',1))
508 self.nBaud = int(numpy.fromfile(fp,'<u4',1))
511 self.nBaud = int(numpy.fromfile(fp,'<u4',1))
509 self.code = numpy.fromfile(fp,'<f4',self.nCode*self.nBaud).reshape(self.nCode,self.nBaud)
512 self.code = numpy.fromfile(fp,'<f4',self.nCode*self.nBaud).reshape(self.nCode,self.nBaud)
510
513
511 if ((self.processFlags & PROCFLAG.EXP_NAME_ESP) == PROCFLAG.EXP_NAME_ESP):
514 if ((self.processFlags & PROCFLAG.EXP_NAME_ESP) == PROCFLAG.EXP_NAME_ESP):
512 exp_name_len = int(numpy.fromfile(fp,'<u4',1))
515 exp_name_len = int(numpy.fromfile(fp,'<u4',1))
513 exp_name = numpy.fromfile(fp,'u1',exp_name_len+1)
516 exp_name = numpy.fromfile(fp,'u1',exp_name_len+1)
514
517
515 if ((self.processFlags & PROCFLAG.SHIFT_FFT_DATA) == PROCFLAG.SHIFT_FFT_DATA):
518 if ((self.processFlags & PROCFLAG.SHIFT_FFT_DATA) == PROCFLAG.SHIFT_FFT_DATA):
516 self.shif_fft = True
519 self.shif_fft = True
517 else:
520 else:
518 self.shif_fft = False
521 self.shif_fft = False
519
522
520 if ((self.processFlags & PROCFLAG.SAVE_CHANNELS_DC) == PROCFLAG.SAVE_CHANNELS_DC):
523 if ((self.processFlags & PROCFLAG.SAVE_CHANNELS_DC) == PROCFLAG.SAVE_CHANNELS_DC):
521 self.flag_dc = True
524 self.flag_dc = True
522 else:
525 else:
523 self.flag_dc = False
526 self.flag_dc = False
524
527
525 if ((self.processFlags & PROCFLAG.DECODE_DATA) == PROCFLAG.DECODE_DATA):
528 if ((self.processFlags & PROCFLAG.DECODE_DATA) == PROCFLAG.DECODE_DATA):
526 self.flag_decode = True
529 self.flag_decode = True
527 else:
530 else:
528 self.flag_decode = False
531 self.flag_decode = False
529
532
530 if ((self.processFlags & PROCFLAG.DEFLIP_DATA) == PROCFLAG.DEFLIP_DATA):
533 if ((self.processFlags & PROCFLAG.DEFLIP_DATA) == PROCFLAG.DEFLIP_DATA):
531 self.flag_deflip = True
534 self.flag_deflip = True
532 else:
535 else:
533 self.flag_deflip = False
536 self.flag_deflip = False
534
537
535 nChannels = 0
538 nChannels = 0
536 nPairs = 0
539 nPairs = 0
537 pairList = []
540 pairList = []
538
541
539 for i in range( 0, self.totalSpectra*2, 2 ):
542 for i in range( 0, self.totalSpectra*2, 2 ):
540 if self.spectraComb[i] == self.spectraComb[i+1]:
543 if self.spectraComb[i] == self.spectraComb[i+1]:
541 nChannels = nChannels + 1 #par de canales iguales
544 nChannels = nChannels + 1 #par de canales iguales
542 else:
545 else:
543 nPairs = nPairs + 1 #par de canales diferentes
546 nPairs = nPairs + 1 #par de canales diferentes
544 pairList.append( (self.spectraComb[i], self.spectraComb[i+1]) )
547 pairList.append( (self.spectraComb[i], self.spectraComb[i+1]) )
545
548
546 self.flag_cspc = False
549 self.flag_cspc = False
547 if nPairs > 0:
550 if nPairs > 0:
548 self.flag_cspc = True
551 self.flag_cspc = True
549
552
550 endFp = size + startFp
553 endFp = size + startFp
551
554
552 if fp.tell() != endFp:
555 if fp.tell() != endFp:
553 raise IOError, "Processing Header is not consistent"
556 raise IOError, "Processing Header is not consistent"
554
557
555 return 1
558 return 1
556
559
557 def write(self, fp):
560 def write(self, fp):
558 #Clear DEFINE_PROCESS_CODE
561 #Clear DEFINE_PROCESS_CODE
559 # self.processFlags = self.processFlags & (~PROCFLAG.DEFINE_PROCESS_CODE)
562 # self.processFlags = self.processFlags & (~PROCFLAG.DEFINE_PROCESS_CODE)
560
563
561 headerTuple = (self.size,
564 headerTuple = (self.size,
562 self.dtype,
565 self.dtype,
563 self.blockSize,
566 self.blockSize,
564 self.profilesPerBlock,
567 self.profilesPerBlock,
565 self.dataBlocksPerFile,
568 self.dataBlocksPerFile,
566 self.nWindows,
569 self.nWindows,
567 self.processFlags,
570 self.processFlags,
568 self.nCohInt,
571 self.nCohInt,
569 self.nIncohInt,
572 self.nIncohInt,
570 self.totalSpectra)
573 self.totalSpectra)
571
574
572 header = numpy.array(headerTuple,PROCESSING_STRUCTURE)
575 header = numpy.array(headerTuple,PROCESSING_STRUCTURE)
573 header.tofile(fp)
576 header.tofile(fp)
574
577
575 if self.nWindows != 0:
578 if self.nWindows != 0:
576 sampleWindowTuple = (self.firstHeight,self.deltaHeight,self.samplesWin)
579 sampleWindowTuple = (self.firstHeight,self.deltaHeight,self.samplesWin)
577 samplingWindow = numpy.array(sampleWindowTuple,SAMPLING_STRUCTURE)
580 samplingWindow = numpy.array(sampleWindowTuple,SAMPLING_STRUCTURE)
578 samplingWindow.tofile(fp)
581 samplingWindow.tofile(fp)
579
582
580 if self.totalSpectra != 0:
583 if self.totalSpectra != 0:
581 # spectraComb = numpy.array([],numpy.dtype('u1'))
584 # spectraComb = numpy.array([],numpy.dtype('u1'))
582 spectraComb = self.spectraComb
585 spectraComb = self.spectraComb
583 spectraComb.tofile(fp)
586 spectraComb.tofile(fp)
584
587
585 if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE:
588 if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE:
586 nCode = numpy.array([self.nCode], numpy.dtype('u4')) #Probar con un dato que almacene codigo, hasta el momento no se hizo la prueba
589 nCode = numpy.array([self.nCode], numpy.dtype('u4')) #Probar con un dato que almacene codigo, hasta el momento no se hizo la prueba
587 nCode.tofile(fp)
590 nCode.tofile(fp)
588
591
589 nBaud = numpy.array([self.nBaud], numpy.dtype('u4'))
592 nBaud = numpy.array([self.nBaud], numpy.dtype('u4'))
590 nBaud.tofile(fp)
593 nBaud.tofile(fp)
591
594
592 code = self.code.reshape(self.nCode*self.nBaud)
595 code = self.code.reshape(self.nCode*self.nBaud)
593 code = code.astype(numpy.dtype('<f4'))
596 code = code.astype(numpy.dtype('<f4'))
594 code.tofile(fp)
597 code.tofile(fp)
595
598
596 return 1
599 return 1
597
600
598 def get_size(self):
601 def get_size(self):
599
602
600 self.__size = 40 + 12*self.nWindows + 2*self.totalSpectra
603 self.__size = 40 + 12*self.nWindows + 2*self.totalSpectra
601
604
602 if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE:
605 if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE:
603 # self.__size += 4 + 4 + 4*self.nCode*numpy.ceil(self.nBaud/32.)
606 # self.__size += 4 + 4 + 4*self.nCode*numpy.ceil(self.nBaud/32.)
604 self.__size += 4 + 4 + 4 * self.nCode * self.nBaud
607 self.__size += 4 + 4 + 4 * self.nCode * self.nBaud
605
608
606 return self.__size
609 return self.__size
607
610
608 def set_size(self, value):
611 def set_size(self, value):
609
612
610 self.__size = value
613 self.__size = value
611
614
612 return
615 return
613
616
614 size = property(get_size, set_size)
617 size = property(get_size, set_size)
615
618
616 class RCfunction:
619 class RCfunction:
617 NONE=0
620 NONE=0
618 FLIP=1
621 FLIP=1
619 CODE=2
622 CODE=2
620 SAMPLING=3
623 SAMPLING=3
621 LIN6DIV256=4
624 LIN6DIV256=4
622 SYNCHRO=5
625 SYNCHRO=5
623
626
624 class nCodeType:
627 class nCodeType:
625 NONE=0
628 NONE=0
626 USERDEFINE=1
629 USERDEFINE=1
627 BARKER2=2
630 BARKER2=2
628 BARKER3=3
631 BARKER3=3
629 BARKER4=4
632 BARKER4=4
630 BARKER5=5
633 BARKER5=5
631 BARKER7=6
634 BARKER7=6
632 BARKER11=7
635 BARKER11=7
633 BARKER13=8
636 BARKER13=8
634 AC128=9
637 AC128=9
635 COMPLEMENTARYCODE2=10
638 COMPLEMENTARYCODE2=10
636 COMPLEMENTARYCODE4=11
639 COMPLEMENTARYCODE4=11
637 COMPLEMENTARYCODE8=12
640 COMPLEMENTARYCODE8=12
638 COMPLEMENTARYCODE16=13
641 COMPLEMENTARYCODE16=13
639 COMPLEMENTARYCODE32=14
642 COMPLEMENTARYCODE32=14
640 COMPLEMENTARYCODE64=15
643 COMPLEMENTARYCODE64=15
641 COMPLEMENTARYCODE128=16
644 COMPLEMENTARYCODE128=16
642 CODE_BINARY28=17
645 CODE_BINARY28=17
643
646
644 class PROCFLAG:
647 class PROCFLAG:
645
648
646 COHERENT_INTEGRATION = numpy.uint32(0x00000001)
649 COHERENT_INTEGRATION = numpy.uint32(0x00000001)
647 DECODE_DATA = numpy.uint32(0x00000002)
650 DECODE_DATA = numpy.uint32(0x00000002)
648 SPECTRA_CALC = numpy.uint32(0x00000004)
651 SPECTRA_CALC = numpy.uint32(0x00000004)
649 INCOHERENT_INTEGRATION = numpy.uint32(0x00000008)
652 INCOHERENT_INTEGRATION = numpy.uint32(0x00000008)
650 POST_COHERENT_INTEGRATION = numpy.uint32(0x00000010)
653 POST_COHERENT_INTEGRATION = numpy.uint32(0x00000010)
651 SHIFT_FFT_DATA = numpy.uint32(0x00000020)
654 SHIFT_FFT_DATA = numpy.uint32(0x00000020)
652
655
653 DATATYPE_CHAR = numpy.uint32(0x00000040)
656 DATATYPE_CHAR = numpy.uint32(0x00000040)
654 DATATYPE_SHORT = numpy.uint32(0x00000080)
657 DATATYPE_SHORT = numpy.uint32(0x00000080)
655 DATATYPE_LONG = numpy.uint32(0x00000100)
658 DATATYPE_LONG = numpy.uint32(0x00000100)
656 DATATYPE_INT64 = numpy.uint32(0x00000200)
659 DATATYPE_INT64 = numpy.uint32(0x00000200)
657 DATATYPE_FLOAT = numpy.uint32(0x00000400)
660 DATATYPE_FLOAT = numpy.uint32(0x00000400)
658 DATATYPE_DOUBLE = numpy.uint32(0x00000800)
661 DATATYPE_DOUBLE = numpy.uint32(0x00000800)
659
662
660 DATAARRANGE_CONTIGUOUS_CH = numpy.uint32(0x00001000)
663 DATAARRANGE_CONTIGUOUS_CH = numpy.uint32(0x00001000)
661 DATAARRANGE_CONTIGUOUS_H = numpy.uint32(0x00002000)
664 DATAARRANGE_CONTIGUOUS_H = numpy.uint32(0x00002000)
662 DATAARRANGE_CONTIGUOUS_P = numpy.uint32(0x00004000)
665 DATAARRANGE_CONTIGUOUS_P = numpy.uint32(0x00004000)
663
666
664 SAVE_CHANNELS_DC = numpy.uint32(0x00008000)
667 SAVE_CHANNELS_DC = numpy.uint32(0x00008000)
665 DEFLIP_DATA = numpy.uint32(0x00010000)
668 DEFLIP_DATA = numpy.uint32(0x00010000)
666 DEFINE_PROCESS_CODE = numpy.uint32(0x00020000)
669 DEFINE_PROCESS_CODE = numpy.uint32(0x00020000)
667
670
668 ACQ_SYS_NATALIA = numpy.uint32(0x00040000)
671 ACQ_SYS_NATALIA = numpy.uint32(0x00040000)
669 ACQ_SYS_ECHOTEK = numpy.uint32(0x00080000)
672 ACQ_SYS_ECHOTEK = numpy.uint32(0x00080000)
670 ACQ_SYS_ADRXD = numpy.uint32(0x000C0000)
673 ACQ_SYS_ADRXD = numpy.uint32(0x000C0000)
671 ACQ_SYS_JULIA = numpy.uint32(0x00100000)
674 ACQ_SYS_JULIA = numpy.uint32(0x00100000)
672 ACQ_SYS_XXXXXX = numpy.uint32(0x00140000)
675 ACQ_SYS_XXXXXX = numpy.uint32(0x00140000)
673
676
674 EXP_NAME_ESP = numpy.uint32(0x00200000)
677 EXP_NAME_ESP = numpy.uint32(0x00200000)
675 CHANNEL_NAMES_ESP = numpy.uint32(0x00400000)
678 CHANNEL_NAMES_ESP = numpy.uint32(0x00400000)
676
679
677 OPERATION_MASK = numpy.uint32(0x0000003F)
680 OPERATION_MASK = numpy.uint32(0x0000003F)
678 DATATYPE_MASK = numpy.uint32(0x00000FC0)
681 DATATYPE_MASK = numpy.uint32(0x00000FC0)
679 DATAARRANGE_MASK = numpy.uint32(0x00007000)
682 DATAARRANGE_MASK = numpy.uint32(0x00007000)
680 ACQ_SYS_MASK = numpy.uint32(0x001C0000)
683 ACQ_SYS_MASK = numpy.uint32(0x001C0000)
681
684
682 dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')])
685 dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')])
683 dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')])
686 dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')])
684 dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')])
687 dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')])
685 dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')])
688 dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')])
686 dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')])
689 dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')])
687 dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')])
690 dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')])
688
691
689 NUMPY_DTYPE_LIST = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5]
692 NUMPY_DTYPE_LIST = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5]
690
693
691 PROCFLAG_DTYPE_LIST = [PROCFLAG.DATATYPE_CHAR,
694 PROCFLAG_DTYPE_LIST = [PROCFLAG.DATATYPE_CHAR,
692 PROCFLAG.DATATYPE_SHORT,
695 PROCFLAG.DATATYPE_SHORT,
693 PROCFLAG.DATATYPE_LONG,
696 PROCFLAG.DATATYPE_LONG,
694 PROCFLAG.DATATYPE_INT64,
697 PROCFLAG.DATATYPE_INT64,
695 PROCFLAG.DATATYPE_FLOAT,
698 PROCFLAG.DATATYPE_FLOAT,
696 PROCFLAG.DATATYPE_DOUBLE]
699 PROCFLAG.DATATYPE_DOUBLE]
697
700
698 DTYPE_WIDTH = [1, 2, 4, 8, 4, 8]
701 DTYPE_WIDTH = [1, 2, 4, 8, 4, 8]
699
702
700 def get_dtype_index(numpy_dtype):
703 def get_dtype_index(numpy_dtype):
701
704
702 index = None
705 index = None
703
706
704 for i in range(len(NUMPY_DTYPE_LIST)):
707 for i in range(len(NUMPY_DTYPE_LIST)):
705 if numpy_dtype == NUMPY_DTYPE_LIST[i]:
708 if numpy_dtype == NUMPY_DTYPE_LIST[i]:
706 index = i
709 index = i
707 break
710 break
708
711
709 return index
712 return index
710
713
711 def get_numpy_dtype(index):
714 def get_numpy_dtype(index):
712
715
713 return NUMPY_DTYPE_LIST[index]
716 return NUMPY_DTYPE_LIST[index]
714
717
715 def get_procflag_dtype(index):
718 def get_procflag_dtype(index):
716
719
717 return PROCFLAG_DTYPE_LIST[index]
720 return PROCFLAG_DTYPE_LIST[index]
718
721
719 def get_dtype_width(index):
722 def get_dtype_width(index):
720
723
721 return DTYPE_WIDTH[index] No newline at end of file
724 return DTYPE_WIDTH[index]
@@ -1,442 +1,442
1 import numpy
1 import numpy
2 import datetime
2 import datetime
3 import sys
3 import sys
4 import matplotlib
4 import matplotlib
5
5
6 if 'linux' in sys.platform:
6 if 'linux' in sys.platform:
7 matplotlib.use("TKAgg")
7 matplotlib.use("TKAgg")
8
8
9 if 'darwin' in sys.platform:
9 if 'darwin' in sys.platform:
10 matplotlib.use('GTKAgg')
10 matplotlib.use('WXAgg')
11 #Qt4Agg', 'GTK', 'GTKAgg', 'ps', 'agg', 'cairo', 'MacOSX', 'GTKCairo', 'WXAgg', 'template', 'TkAgg', 'GTK3Cairo', 'GTK3Agg', 'svg', 'WebAgg', 'CocoaAgg', 'emf', 'gdk', 'WX'
11 #Qt4Agg', 'GTK', 'GTKAgg', 'ps', 'agg', 'cairo', 'MacOSX', 'GTKCairo', 'WXAgg', 'template', 'TkAgg', 'GTK3Cairo', 'GTK3Agg', 'svg', 'WebAgg', 'CocoaAgg', 'emf', 'gdk', 'WX'
12 import matplotlib.pyplot
12 import matplotlib.pyplot
13
13
14 from mpl_toolkits.axes_grid1 import make_axes_locatable
14 from mpl_toolkits.axes_grid1 import make_axes_locatable
15 from matplotlib.ticker import *
15 from matplotlib.ticker import *
16
16
17 ###########################################
17 ###########################################
18 #Actualizacion de las funciones del driver
18 #Actualizacion de las funciones del driver
19 ###########################################
19 ###########################################
20
20
21 def createFigure(id, wintitle, width, height, facecolor="w", show=True):
21 def createFigure(id, wintitle, width, height, facecolor="w", show=True):
22
22
23 matplotlib.pyplot.ioff()
23 matplotlib.pyplot.ioff()
24 fig = matplotlib.pyplot.figure(num=id, facecolor=facecolor)
24 fig = matplotlib.pyplot.figure(num=id, facecolor=facecolor)
25 fig.canvas.manager.set_window_title(wintitle)
25 fig.canvas.manager.set_window_title(wintitle)
26 fig.canvas.manager.resize(width, height)
26 fig.canvas.manager.resize(width, height)
27 matplotlib.pyplot.ion()
27 matplotlib.pyplot.ion()
28 if show:
28 if show:
29 matplotlib.pyplot.show()
29 matplotlib.pyplot.show()
30
30
31 return fig
31 return fig
32
32
33 def closeFigure(show=False, fig=None):
33 def closeFigure(show=False, fig=None):
34
34
35 matplotlib.pyplot.ioff()
35 matplotlib.pyplot.ioff()
36 matplotlib.pyplot.pause(0.1)
36 # matplotlib.pyplot.pause(0.1)
37
37
38 if show:
38 if show:
39 matplotlib.pyplot.show()
39 matplotlib.pyplot.show()
40
40
41 if fig != None:
41 if fig != None:
42 matplotlib.pyplot.close(fig)
42 matplotlib.pyplot.close(fig.number)
43 matplotlib.pyplot.pause(0.1)
43 # matplotlib.pyplot.pause(0.1)
44 matplotlib.pyplot.ion()
44 # matplotlib.pyplot.ion()
45 return
45 return
46
46
47 matplotlib.pyplot.close("all")
47 matplotlib.pyplot.close("all")
48 matplotlib.pyplot.pause(0.1)
48 # matplotlib.pyplot.pause(0.1)
49 matplotlib.pyplot.ion()
49 # matplotlib.pyplot.ion()
50 return
50 return
51
51
52 def saveFigure(fig, filename):
52 def saveFigure(fig, filename):
53
53
54 matplotlib.pyplot.ioff()
54 # matplotlib.pyplot.ioff()
55 fig.savefig(filename)
55 fig.savefig(filename)
56 matplotlib.pyplot.ion()
56 # matplotlib.pyplot.ion()
57
57
58 def setWinTitle(fig, title):
58 def setWinTitle(fig, title):
59
59
60 fig.canvas.manager.set_window_title(title)
60 fig.canvas.manager.set_window_title(title)
61
61
62 def setTitle(fig, title):
62 def setTitle(fig, title):
63
63
64 fig.suptitle(title)
64 fig.suptitle(title)
65
65
66 def createAxes(fig, nrow, ncol, xpos, ypos, colspan, rowspan, polar=False):
66 def createAxes(fig, nrow, ncol, xpos, ypos, colspan, rowspan, polar=False):
67
67
68 matplotlib.pyplot.ioff()
68 matplotlib.pyplot.ioff()
69 matplotlib.pyplot.figure(fig.number)
69 matplotlib.pyplot.figure(fig.number)
70 axes = matplotlib.pyplot.subplot2grid((nrow, ncol),
70 axes = matplotlib.pyplot.subplot2grid((nrow, ncol),
71 (xpos, ypos),
71 (xpos, ypos),
72 colspan=colspan,
72 colspan=colspan,
73 rowspan=rowspan,
73 rowspan=rowspan,
74 polar=polar)
74 polar=polar)
75
75
76 matplotlib.pyplot.ion()
76 matplotlib.pyplot.ion()
77 return axes
77 return axes
78
78
79 def setAxesText(ax, text):
79 def setAxesText(ax, text):
80
80
81 ax.annotate(text,
81 ax.annotate(text,
82 xy = (.1, .99),
82 xy = (.1, .99),
83 xycoords = 'figure fraction',
83 xycoords = 'figure fraction',
84 horizontalalignment = 'left',
84 horizontalalignment = 'left',
85 verticalalignment = 'top',
85 verticalalignment = 'top',
86 fontsize = 10)
86 fontsize = 10)
87
87
88 def printLabels(ax, xlabel, ylabel, title):
88 def printLabels(ax, xlabel, ylabel, title):
89
89
90 ax.set_xlabel(xlabel, size=11)
90 ax.set_xlabel(xlabel, size=11)
91 ax.set_ylabel(ylabel, size=11)
91 ax.set_ylabel(ylabel, size=11)
92 ax.set_title(title, size=8)
92 ax.set_title(title, size=8)
93
93
94 def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='',
94 def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='',
95 ticksize=9, xtick_visible=True, ytick_visible=True,
95 ticksize=9, xtick_visible=True, ytick_visible=True,
96 nxticks=4, nyticks=10,
96 nxticks=4, nyticks=10,
97 grid=None,color='blue'):
97 grid=None,color='blue'):
98
98
99 """
99 """
100
100
101 Input:
101 Input:
102 grid : None, 'both', 'x', 'y'
102 grid : None, 'both', 'x', 'y'
103 """
103 """
104
104
105 matplotlib.pyplot.ioff()
105 matplotlib.pyplot.ioff()
106
106
107 ax.set_xlim([xmin,xmax])
107 ax.set_xlim([xmin,xmax])
108 ax.set_ylim([ymin,ymax])
108 ax.set_ylim([ymin,ymax])
109
109
110 printLabels(ax, xlabel, ylabel, title)
110 printLabels(ax, xlabel, ylabel, title)
111
111
112 ######################################################
112 ######################################################
113 if (xmax-xmin)<=1:
113 if (xmax-xmin)<=1:
114 xtickspos = numpy.linspace(xmin,xmax,nxticks)
114 xtickspos = numpy.linspace(xmin,xmax,nxticks)
115 xtickspos = numpy.array([float("%.1f"%i) for i in xtickspos])
115 xtickspos = numpy.array([float("%.1f"%i) for i in xtickspos])
116 ax.set_xticks(xtickspos)
116 ax.set_xticks(xtickspos)
117 else:
117 else:
118 xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
118 xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
119 # xtickspos = numpy.arange(nxticks)*float(xmax-xmin)/float(nxticks) + int(xmin)
119 # xtickspos = numpy.arange(nxticks)*float(xmax-xmin)/float(nxticks) + int(xmin)
120 ax.set_xticks(xtickspos)
120 ax.set_xticks(xtickspos)
121
121
122 for tick in ax.get_xticklabels():
122 for tick in ax.get_xticklabels():
123 tick.set_visible(xtick_visible)
123 tick.set_visible(xtick_visible)
124
124
125 for tick in ax.xaxis.get_major_ticks():
125 for tick in ax.xaxis.get_major_ticks():
126 tick.label.set_fontsize(ticksize)
126 tick.label.set_fontsize(ticksize)
127
127
128 ######################################################
128 ######################################################
129 for tick in ax.get_yticklabels():
129 for tick in ax.get_yticklabels():
130 tick.set_visible(ytick_visible)
130 tick.set_visible(ytick_visible)
131
131
132 for tick in ax.yaxis.get_major_ticks():
132 for tick in ax.yaxis.get_major_ticks():
133 tick.label.set_fontsize(ticksize)
133 tick.label.set_fontsize(ticksize)
134
134
135 ax.plot(x, y, color=color)
135 ax.plot(x, y, color=color)
136 iplot = ax.lines[-1]
136 iplot = ax.lines[-1]
137
137
138 ######################################################
138 ######################################################
139 if '0.' in matplotlib.__version__[0:2]:
139 if '0.' in matplotlib.__version__[0:2]:
140 print "The matplotlib version has to be updated to 1.1 or newer"
140 print "The matplotlib version has to be updated to 1.1 or newer"
141 return iplot
141 return iplot
142
142
143 if '1.0.' in matplotlib.__version__[0:4]:
143 if '1.0.' in matplotlib.__version__[0:4]:
144 print "The matplotlib version has to be updated to 1.1 or newer"
144 print "The matplotlib version has to be updated to 1.1 or newer"
145 return iplot
145 return iplot
146
146
147 if grid != None:
147 if grid != None:
148 ax.grid(b=True, which='major', axis=grid)
148 ax.grid(b=True, which='major', axis=grid)
149
149
150 matplotlib.pyplot.tight_layout()
150 matplotlib.pyplot.tight_layout()
151
151
152 matplotlib.pyplot.ion()
152 matplotlib.pyplot.ion()
153
153
154 return iplot
154 return iplot
155
155
156 def set_linedata(ax, x, y, idline):
156 def set_linedata(ax, x, y, idline):
157
157
158 ax.lines[idline].set_data(x,y)
158 ax.lines[idline].set_data(x,y)
159
159
160 def pline(iplot, x, y, xlabel='', ylabel='', title=''):
160 def pline(iplot, x, y, xlabel='', ylabel='', title=''):
161
161
162 ax = iplot.get_axes()
162 ax = iplot.get_axes()
163
163
164 printLabels(ax, xlabel, ylabel, title)
164 printLabels(ax, xlabel, ylabel, title)
165
165
166 set_linedata(ax, x, y, idline=0)
166 set_linedata(ax, x, y, idline=0)
167
167
168 def addpline(ax, x, y, color, linestyle, lw):
168 def addpline(ax, x, y, color, linestyle, lw):
169
169
170 ax.plot(x,y,color=color,linestyle=linestyle,lw=lw)
170 ax.plot(x,y,color=color,linestyle=linestyle,lw=lw)
171
171
172
172
173 def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax,
173 def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax,
174 xlabel='', ylabel='', title='', ticksize = 9,
174 xlabel='', ylabel='', title='', ticksize = 9,
175 colormap='jet',cblabel='', cbsize="5%",
175 colormap='jet',cblabel='', cbsize="5%",
176 XAxisAsTime=False):
176 XAxisAsTime=False):
177
177
178 matplotlib.pyplot.ioff()
178 matplotlib.pyplot.ioff()
179
179
180 divider = make_axes_locatable(ax)
180 divider = make_axes_locatable(ax)
181 ax_cb = divider.new_horizontal(size=cbsize, pad=0.05)
181 ax_cb = divider.new_horizontal(size=cbsize, pad=0.05)
182 fig = ax.get_figure()
182 fig = ax.get_figure()
183 fig.add_axes(ax_cb)
183 fig.add_axes(ax_cb)
184
184
185 ax.set_xlim([xmin,xmax])
185 ax.set_xlim([xmin,xmax])
186 ax.set_ylim([ymin,ymax])
186 ax.set_ylim([ymin,ymax])
187
187
188 printLabels(ax, xlabel, ylabel, title)
188 printLabels(ax, xlabel, ylabel, title)
189
189
190 imesh = ax.pcolormesh(x,y,z.T, vmin=zmin, vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
190 imesh = ax.pcolormesh(x,y,z.T, vmin=zmin, vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
191 cb = matplotlib.pyplot.colorbar(imesh, cax=ax_cb)
191 cb = matplotlib.pyplot.colorbar(imesh, cax=ax_cb)
192 cb.set_label(cblabel)
192 cb.set_label(cblabel)
193
193
194 # for tl in ax_cb.get_yticklabels():
194 # for tl in ax_cb.get_yticklabels():
195 # tl.set_visible(True)
195 # tl.set_visible(True)
196
196
197 for tick in ax.yaxis.get_major_ticks():
197 for tick in ax.yaxis.get_major_ticks():
198 tick.label.set_fontsize(ticksize)
198 tick.label.set_fontsize(ticksize)
199
199
200 for tick in ax.xaxis.get_major_ticks():
200 for tick in ax.xaxis.get_major_ticks():
201 tick.label.set_fontsize(ticksize)
201 tick.label.set_fontsize(ticksize)
202
202
203 for tick in cb.ax.get_yticklabels():
203 for tick in cb.ax.get_yticklabels():
204 tick.set_fontsize(ticksize)
204 tick.set_fontsize(ticksize)
205
205
206 ax_cb.yaxis.tick_right()
206 ax_cb.yaxis.tick_right()
207
207
208 if '0.' in matplotlib.__version__[0:2]:
208 if '0.' in matplotlib.__version__[0:2]:
209 print "The matplotlib version has to be updated to 1.1 or newer"
209 print "The matplotlib version has to be updated to 1.1 or newer"
210 return imesh
210 return imesh
211
211
212 if '1.0.' in matplotlib.__version__[0:4]:
212 if '1.0.' in matplotlib.__version__[0:4]:
213 print "The matplotlib version has to be updated to 1.1 or newer"
213 print "The matplotlib version has to be updated to 1.1 or newer"
214 return imesh
214 return imesh
215
215
216 matplotlib.pyplot.tight_layout()
216 matplotlib.pyplot.tight_layout()
217
217
218 if XAxisAsTime:
218 if XAxisAsTime:
219
219
220 func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S"))
220 func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S"))
221 ax.xaxis.set_major_formatter(FuncFormatter(func))
221 ax.xaxis.set_major_formatter(FuncFormatter(func))
222 ax.xaxis.set_major_locator(LinearLocator(7))
222 ax.xaxis.set_major_locator(LinearLocator(7))
223
223
224 matplotlib.pyplot.ion()
224 matplotlib.pyplot.ion()
225 return imesh
225 return imesh
226
226
227 def pcolor(imesh, z, xlabel='', ylabel='', title=''):
227 def pcolor(imesh, z, xlabel='', ylabel='', title=''):
228
228
229 z = z.T
229 z = z.T
230 ax = imesh.get_axes()
230 ax = imesh.get_axes()
231 printLabels(ax, xlabel, ylabel, title)
231 printLabels(ax, xlabel, ylabel, title)
232 imesh.set_array(z.ravel())
232 imesh.set_array(z.ravel())
233
233
234 def addpcolor(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'):
234 def addpcolor(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'):
235
235
236 printLabels(ax, xlabel, ylabel, title)
236 printLabels(ax, xlabel, ylabel, title)
237
237
238 ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
238 ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
239
239
240 def addpcolorbuffer(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'):
240 def addpcolorbuffer(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'):
241
241
242 printLabels(ax, xlabel, ylabel, title)
242 printLabels(ax, xlabel, ylabel, title)
243
243
244 ax.collections.remove(ax.collections[0])
244 ax.collections.remove(ax.collections[0])
245
245
246 ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
246 ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
247
247
248 def createPmultiline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None,
248 def createPmultiline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None,
249 ticksize=9, xtick_visible=True, ytick_visible=True,
249 ticksize=9, xtick_visible=True, ytick_visible=True,
250 nxticks=4, nyticks=10,
250 nxticks=4, nyticks=10,
251 grid=None):
251 grid=None):
252
252
253 """
253 """
254
254
255 Input:
255 Input:
256 grid : None, 'both', 'x', 'y'
256 grid : None, 'both', 'x', 'y'
257 """
257 """
258
258
259 matplotlib.pyplot.ioff()
259 matplotlib.pyplot.ioff()
260
260
261 lines = ax.plot(x.T, y)
261 lines = ax.plot(x.T, y)
262 leg = ax.legend(lines, legendlabels, loc='upper right')
262 leg = ax.legend(lines, legendlabels, loc='upper right')
263 leg.get_frame().set_alpha(0.5)
263 leg.get_frame().set_alpha(0.5)
264 ax.set_xlim([xmin,xmax])
264 ax.set_xlim([xmin,xmax])
265 ax.set_ylim([ymin,ymax])
265 ax.set_ylim([ymin,ymax])
266 printLabels(ax, xlabel, ylabel, title)
266 printLabels(ax, xlabel, ylabel, title)
267
267
268 xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
268 xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
269 ax.set_xticks(xtickspos)
269 ax.set_xticks(xtickspos)
270
270
271 for tick in ax.get_xticklabels():
271 for tick in ax.get_xticklabels():
272 tick.set_visible(xtick_visible)
272 tick.set_visible(xtick_visible)
273
273
274 for tick in ax.xaxis.get_major_ticks():
274 for tick in ax.xaxis.get_major_ticks():
275 tick.label.set_fontsize(ticksize)
275 tick.label.set_fontsize(ticksize)
276
276
277 for tick in ax.get_yticklabels():
277 for tick in ax.get_yticklabels():
278 tick.set_visible(ytick_visible)
278 tick.set_visible(ytick_visible)
279
279
280 for tick in ax.yaxis.get_major_ticks():
280 for tick in ax.yaxis.get_major_ticks():
281 tick.label.set_fontsize(ticksize)
281 tick.label.set_fontsize(ticksize)
282
282
283 iplot = ax.lines[-1]
283 iplot = ax.lines[-1]
284
284
285 if '0.' in matplotlib.__version__[0:2]:
285 if '0.' in matplotlib.__version__[0:2]:
286 print "The matplotlib version has to be updated to 1.1 or newer"
286 print "The matplotlib version has to be updated to 1.1 or newer"
287 return iplot
287 return iplot
288
288
289 if '1.0.' in matplotlib.__version__[0:4]:
289 if '1.0.' in matplotlib.__version__[0:4]:
290 print "The matplotlib version has to be updated to 1.1 or newer"
290 print "The matplotlib version has to be updated to 1.1 or newer"
291 return iplot
291 return iplot
292
292
293 if grid != None:
293 if grid != None:
294 ax.grid(b=True, which='major', axis=grid)
294 ax.grid(b=True, which='major', axis=grid)
295
295
296 matplotlib.pyplot.tight_layout()
296 matplotlib.pyplot.tight_layout()
297
297
298 matplotlib.pyplot.ion()
298 matplotlib.pyplot.ion()
299
299
300 return iplot
300 return iplot
301
301
302
302
303 def pmultiline(iplot, x, y, xlabel='', ylabel='', title=''):
303 def pmultiline(iplot, x, y, xlabel='', ylabel='', title=''):
304
304
305 ax = iplot.get_axes()
305 ax = iplot.get_axes()
306
306
307 printLabels(ax, xlabel, ylabel, title)
307 printLabels(ax, xlabel, ylabel, title)
308
308
309 for i in range(len(ax.lines)):
309 for i in range(len(ax.lines)):
310 line = ax.lines[i]
310 line = ax.lines[i]
311 line.set_data(x[i,:],y)
311 line.set_data(x[i,:],y)
312
312
313 def createPmultilineYAxis(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None,
313 def createPmultilineYAxis(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None,
314 ticksize=9, xtick_visible=True, ytick_visible=True,
314 ticksize=9, xtick_visible=True, ytick_visible=True,
315 nxticks=4, nyticks=10, marker='.', markersize=10, linestyle="None",
315 nxticks=4, nyticks=10, marker='.', markersize=10, linestyle="None",
316 grid=None, XAxisAsTime=False):
316 grid=None, XAxisAsTime=False):
317
317
318 """
318 """
319
319
320 Input:
320 Input:
321 grid : None, 'both', 'x', 'y'
321 grid : None, 'both', 'x', 'y'
322 """
322 """
323
323
324 matplotlib.pyplot.ioff()
324 matplotlib.pyplot.ioff()
325
325
326 # lines = ax.plot(x, y.T, marker=marker,markersize=markersize,linestyle=linestyle)
326 # lines = ax.plot(x, y.T, marker=marker,markersize=markersize,linestyle=linestyle)
327 lines = ax.plot(x, y.T, linestyle=linestyle, marker=marker, markersize=markersize)
327 lines = ax.plot(x, y.T, linestyle=linestyle, marker=marker, markersize=markersize)
328 leg = ax.legend(lines, legendlabels, loc='upper left', bbox_to_anchor=(1.01, 1.00), numpoints=1, handlelength=1.5, \
328 leg = ax.legend(lines, legendlabels, loc='upper left', bbox_to_anchor=(1.01, 1.00), numpoints=1, handlelength=1.5, \
329 handletextpad=0.5, borderpad=0.5, labelspacing=0.5, borderaxespad=0.)
329 handletextpad=0.5, borderpad=0.5, labelspacing=0.5, borderaxespad=0.)
330
330
331 for label in leg.get_texts(): label.set_fontsize(9)
331 for label in leg.get_texts(): label.set_fontsize(9)
332
332
333 ax.set_xlim([xmin,xmax])
333 ax.set_xlim([xmin,xmax])
334 ax.set_ylim([ymin,ymax])
334 ax.set_ylim([ymin,ymax])
335 printLabels(ax, xlabel, ylabel, title)
335 printLabels(ax, xlabel, ylabel, title)
336
336
337 # xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
337 # xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
338 # ax.set_xticks(xtickspos)
338 # ax.set_xticks(xtickspos)
339
339
340 for tick in ax.get_xticklabels():
340 for tick in ax.get_xticklabels():
341 tick.set_visible(xtick_visible)
341 tick.set_visible(xtick_visible)
342
342
343 for tick in ax.xaxis.get_major_ticks():
343 for tick in ax.xaxis.get_major_ticks():
344 tick.label.set_fontsize(ticksize)
344 tick.label.set_fontsize(ticksize)
345
345
346 for tick in ax.get_yticklabels():
346 for tick in ax.get_yticklabels():
347 tick.set_visible(ytick_visible)
347 tick.set_visible(ytick_visible)
348
348
349 for tick in ax.yaxis.get_major_ticks():
349 for tick in ax.yaxis.get_major_ticks():
350 tick.label.set_fontsize(ticksize)
350 tick.label.set_fontsize(ticksize)
351
351
352 iplot = ax.lines[-1]
352 iplot = ax.lines[-1]
353
353
354 if '0.' in matplotlib.__version__[0:2]:
354 if '0.' in matplotlib.__version__[0:2]:
355 print "The matplotlib version has to be updated to 1.1 or newer"
355 print "The matplotlib version has to be updated to 1.1 or newer"
356 return iplot
356 return iplot
357
357
358 if '1.0.' in matplotlib.__version__[0:4]:
358 if '1.0.' in matplotlib.__version__[0:4]:
359 print "The matplotlib version has to be updated to 1.1 or newer"
359 print "The matplotlib version has to be updated to 1.1 or newer"
360 return iplot
360 return iplot
361
361
362 if grid != None:
362 if grid != None:
363 ax.grid(b=True, which='major', axis=grid)
363 ax.grid(b=True, which='major', axis=grid)
364
364
365 matplotlib.pyplot.tight_layout()
365 matplotlib.pyplot.tight_layout()
366
366
367 if XAxisAsTime:
367 if XAxisAsTime:
368
368
369 func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S"))
369 func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S"))
370 ax.xaxis.set_major_formatter(FuncFormatter(func))
370 ax.xaxis.set_major_formatter(FuncFormatter(func))
371 ax.xaxis.set_major_locator(LinearLocator(7))
371 ax.xaxis.set_major_locator(LinearLocator(7))
372
372
373 matplotlib.pyplot.ion()
373 matplotlib.pyplot.ion()
374
374
375 return iplot
375 return iplot
376
376
377 def pmultilineyaxis(iplot, x, y, xlabel='', ylabel='', title=''):
377 def pmultilineyaxis(iplot, x, y, xlabel='', ylabel='', title=''):
378
378
379 ax = iplot.get_axes()
379 ax = iplot.get_axes()
380
380
381 printLabels(ax, xlabel, ylabel, title)
381 printLabels(ax, xlabel, ylabel, title)
382
382
383 for i in range(len(ax.lines)):
383 for i in range(len(ax.lines)):
384 line = ax.lines[i]
384 line = ax.lines[i]
385 line.set_data(x,y[i,:])
385 line.set_data(x,y[i,:])
386
386
387 def createPolar(ax, x, y,
387 def createPolar(ax, x, y,
388 xlabel='', ylabel='', title='', ticksize = 9,
388 xlabel='', ylabel='', title='', ticksize = 9,
389 colormap='jet',cblabel='', cbsize="5%",
389 colormap='jet',cblabel='', cbsize="5%",
390 XAxisAsTime=False):
390 XAxisAsTime=False):
391
391
392 matplotlib.pyplot.ioff()
392 matplotlib.pyplot.ioff()
393
393
394 ax.plot(x,y,'bo', markersize=5)
394 ax.plot(x,y,'bo', markersize=5)
395 # ax.set_rmax(90)
395 # ax.set_rmax(90)
396 ax.set_ylim(0,90)
396 ax.set_ylim(0,90)
397 ax.set_yticks(numpy.arange(0,90,20))
397 ax.set_yticks(numpy.arange(0,90,20))
398 # ax.text(0, -110, ylabel, rotation='vertical', va ='center', ha = 'center' ,size='11')
398 # ax.text(0, -110, ylabel, rotation='vertical', va ='center', ha = 'center' ,size='11')
399 # ax.text(0, 50, ylabel, rotation='vertical', va ='center', ha = 'left' ,size='11')
399 # ax.text(0, 50, ylabel, rotation='vertical', va ='center', ha = 'left' ,size='11')
400 # ax.text(100, 100, 'example', ha='left', va='center', rotation='vertical')
400 # ax.text(100, 100, 'example', ha='left', va='center', rotation='vertical')
401 ax.yaxis.labelpad = 230
401 ax.yaxis.labelpad = 230
402 printLabels(ax, xlabel, ylabel, title)
402 printLabels(ax, xlabel, ylabel, title)
403 iplot = ax.lines[-1]
403 iplot = ax.lines[-1]
404
404
405 if '0.' in matplotlib.__version__[0:2]:
405 if '0.' in matplotlib.__version__[0:2]:
406 print "The matplotlib version has to be updated to 1.1 or newer"
406 print "The matplotlib version has to be updated to 1.1 or newer"
407 return iplot
407 return iplot
408
408
409 if '1.0.' in matplotlib.__version__[0:4]:
409 if '1.0.' in matplotlib.__version__[0:4]:
410 print "The matplotlib version has to be updated to 1.1 or newer"
410 print "The matplotlib version has to be updated to 1.1 or newer"
411 return iplot
411 return iplot
412
412
413 # if grid != None:
413 # if grid != None:
414 # ax.grid(b=True, which='major', axis=grid)
414 # ax.grid(b=True, which='major', axis=grid)
415
415
416 matplotlib.pyplot.tight_layout()
416 matplotlib.pyplot.tight_layout()
417
417
418 matplotlib.pyplot.ion()
418 matplotlib.pyplot.ion()
419
419
420
420
421 return iplot
421 return iplot
422
422
423 def polar(iplot, x, y, xlabel='', ylabel='', title=''):
423 def polar(iplot, x, y, xlabel='', ylabel='', title=''):
424
424
425 ax = iplot.get_axes()
425 ax = iplot.get_axes()
426
426
427 # ax.text(0, -110, ylabel, rotation='vertical', va ='center', ha = 'center',size='11')
427 # ax.text(0, -110, ylabel, rotation='vertical', va ='center', ha = 'center',size='11')
428 printLabels(ax, xlabel, ylabel, title)
428 printLabels(ax, xlabel, ylabel, title)
429
429
430 set_linedata(ax, x, y, idline=0)
430 set_linedata(ax, x, y, idline=0)
431
431
432 def draw(fig):
432 def draw(fig):
433
433
434 if type(fig) == 'int':
434 if type(fig) == 'int':
435 raise ValueError, "Error drawing: Fig parameter should be a matplotlib figure object figure"
435 raise ValueError, "Error drawing: Fig parameter should be a matplotlib figure object figure"
436
436
437 fig.canvas.draw()
437 fig.canvas.draw()
438
438
439 def pause(interval=0.000001):
439 def pause(interval=0.000001):
440
440
441 matplotlib.pyplot.pause(interval)
441 matplotlib.pyplot.pause(interval)
442 No newline at end of file
442
@@ -1,38 +1,39
1 '''
1 '''
2 Created on Jul 16, 2014
2 Created on Jul 16, 2014
3
3
4 @author: roj-idl71
4 @author: roj-idl71
5 '''
5 '''
6
6
7 from schainpy import __version__
7 from schainpy import __version__
8 from setuptools import setup, Extension
8 from setuptools import setup, Extension
9
9
10 setup(name="schainpy",
10 setup(name="schainpy",
11 version=__version__,
11 version=__version__,
12 description="Python tools to read, write and process Jicamarca data",
12 description="Python tools to read, write and process Jicamarca data",
13 author="Miguel Urco",
13 author="Miguel Urco",
14 author_email="miguel.urco@jro.igp.gob.pe",
14 author_email="miguel.urco@jro.igp.gob.pe",
15 url="http://jro.igp.gob.pe",
15 url="http://jro.igp.gob.pe",
16 packages = {'schainpy',
16 packages = {'schainpy',
17 'schainpy.model',
17 'schainpy.model',
18 'schainpy.model.data',
18 'schainpy.model.data',
19 'schainpy.model.graphics',
19 'schainpy.model.graphics',
20 'schainpy.model.io',
20 'schainpy.model.io',
21 'schainpy.model.proc',
21 'schainpy.model.proc',
22 'schainpy.model.utils',
22 'schainpy.model.utils',
23 'schainpy.gui',
23 'schainpy.gui',
24 'schainpy.gui.figures',
24 'schainpy.gui.figures',
25 'schainpy.gui.viewcontroller',
25 'schainpy.gui.viewcontroller',
26 'schainpy.gui.viewer',
26 'schainpy.gui.viewer',
27 'schainpy.gui.viewer.windows'},
27 'schainpy.gui.viewer.windows'},
28 py_modules=['schainpy.serializer.DataTranslate',
28 py_modules=['schainpy.serializer.DataTranslate',
29 'schainpy.serializer.JROSerializer'],
29 'schainpy.serializer.JROSerializer'],
30 package_data={'schainpy.gui.figures': ['*.png']},
30 package_data={'schainpy.gui.figures': ['*.png']},
31 include_package_data=True,
31 include_package_data=True,
32 scripts =['schainpy/gui/schainGUI'],
32 scripts =['schainpy/gui/schainGUI'],
33 install_requires=["numpy >= 1.6.0",
33 install_requires=["numpy >= 1.6.0",
34 "scipy >= 0.9.0",
34 "scipy >= 0.9.0",
35 "h5py >= 2.0.1",
35 "h5py >= 2.0.1",
36 "wxpython >= 2.8",
36 "matplotlib >= 1.0.0"
37 "matplotlib >= 1.0.0"
37 ],
38 ],
38 ) No newline at end of file
39 )
General Comments 0
You need to be logged in to leave comments. Login now