##// END OF EJS Templates
Miguel Valdez -
r577:bea3bacb993a
parent child
Show More

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

@@ -0,0 +1,7
1 # ~/.bash_logout: executed by bash(1) when login shell exits.
2
3 # when leaving the console clear the screen to increase privacy
4
5 if [ "$SHLVL" = 1 ]; then
6 [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
7 fi
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
@@ -0,0 +1,29
1 #!/usr/bin/env python
2 import os, sys
3 from PyQt4 import QtCore, QtGui
4 from PyQt4.QtGui import QApplication
5
6 from schainpy.gui.viewcontroller.initwindow import InitWindow
7 from schainpy.gui.viewcontroller.basicwindow import BasicWindow
8 from schainpy.gui.viewcontroller.workspace import Workspace
9
10 def main():
11
12 app = QtGui.QApplication(sys.argv)
13
14 Welcome=InitWindow()
15
16 if not Welcome.exec_():
17 sys.exit(-1)
18
19 WorkPathspace=Workspace()
20 if not WorkPathspace.exec_():
21 sys.exit(-1)
22
23 MainGUI=BasicWindow()
24 MainGUI.setWorkSpaceGUI(WorkPathspace.dirComBox.currentText())
25 MainGUI.show()
26 sys.exit(app.exec_())
27
28 if __name__ == "__main__":
29 main() No newline at end of file
@@ -0,0 +1,29
1 #!/usr/bin/env python
2 import os, sys
3 from PyQt4 import QtCore, QtGui
4 from PyQt4.QtGui import QApplication
5
6 from schainpy.gui.viewcontroller.initwindow import InitWindow
7 from schainpy.gui.viewcontroller.basicwindow import BasicWindow
8 from schainpy.gui.viewcontroller.workspace import Workspace
9
10 def main():
11
12 app = QtGui.QApplication(sys.argv)
13
14 Welcome=InitWindow()
15
16 if not Welcome.exec_():
17 sys.exit(-1)
18
19 WorkPathspace=Workspace()
20 if not WorkPathspace.exec_():
21 sys.exit(-1)
22
23 MainGUI=BasicWindow()
24 MainGUI.setWorkSpaceGUI(WorkPathspace.dirComBox.currentText())
25 MainGUI.show()
26 sys.exit(app.exec_())
27
28 if __name__ == "__main__":
29 main() No newline at end of file
@@ -0,0 +1,97
1 import threading
2 import Queue
3 import pickle
4 import numpy, os, sys
5
6 from schainpy.controller import Project
7 from command import *
8
9 class ControllerThread(threading.Thread):
10 def __init__(self, filename, data_q):
11 super(ControllerThread, self).__init__()
12 self.filename = filename
13 self.data_q = data_q
14 self.control = {'stop':False,'pause':False}
15
16 def stop(self):
17 self.control['stop'] = True
18
19 def pause(self):
20 self.control['pause'] = not(self.control['pause'])
21
22 def run(self):
23 self.control['stop'] = False
24 self.control['pause'] = False
25 self.controllerObj = Project(self.control, self.data_q)
26 self.controllerObj.readXml(self.filename)
27 self.controllerObj.createObjects()
28 self.controllerObj.connectObjects()
29 self.controllerObj.run()
30
31 class CommCtrlProcessThread(threading.Thread):
32 """ Implements the threading.Thread interface (start, join, etc.) and
33 can be controlled via the cmd_q Queue attribute. Replies are placed in
34 the reply_q Queue attribute.
35 """
36 def __init__(self, cmd_q=Queue.Queue(), reply_q=Queue.Queue()):
37 super(CommCtrlProcessThread, self).__init__()
38 self.cmd_q = cmd_q
39 self.reply_q = reply_q
40
41 # self.print_q = Queue.Queue()
42 self.data_q = Queue.Queue()
43
44 self.alive = threading.Event()
45 self.alive.set()
46 self.socket = None
47
48 self.socketIO = None
49 self.mySocket = None
50
51
52 self.handlers = {
53 ProcessCommand.PROCESS: self._handle_ioPROCESSTHREAD,
54 ProcessCommand.MESSAGE: self._handle_ioMESSAGE,
55 ProcessCommand.DATA: self._handle_ioDATA,
56 ProcessCommand.STOP: self._handle_ioSTOP,
57 ProcessCommand.PAUSE: self._handle_ioPAUSE
58 }
59
60 def run(self):
61 while self.alive.isSet():
62 try:
63 cmd = self.cmd_q.get(True, 0.1)
64 self.handlers[cmd.type](cmd)
65 except Queue.Empty as e:
66 continue
67
68
69 def _handle_ioPROCESSTHREAD(self, cmd):
70 filename = cmd.data
71 self.controllerObj = ControllerThread(filename=filename, data_q=self.data_q)
72 self.controllerObj.start()
73
74 def _handle_ioPAUSE(self, cmd):
75 self.controllerObj.pause()
76
77 def _handle_ioSTOP(self, cmd):
78 self.controllerObj.stop()
79
80 def _handle_ioDATA(self, cmd):
81 self.reply_q.put(self._success_reply_data(data=cmd.data))
82
83 def _handle_ioMESSAGE(self, cmd):
84 self.reply_q.put(self._success_reply_message(data=cmd.data))
85
86 def _success_reply_data(self, data=None):
87 return ClientReply(ClientReply.DATA, data)
88
89 def _success_reply_message(self, data=None):
90 return ClientReply(ClientReply.MESSAGE, data)
91
92 def join(self, timeout=None):
93 self.alive.clear()
94 threading.Thread.join(self, timeout)
95
96
97 No newline at end of file
@@ -0,0 +1,50
1 class ProcessCommand(object):
2 """ A command to the client thread.
3 Each command type has its associated data:
4
5 DATA: Data Radar Object
6 MESSAGE: Data String
7 STOP: Event to Stop the process thread
8 PAUSE: Event to Pause the process thread
9 """
10 PROCESS, DATA, MESSAGE, STOP, PAUSE = range(5)
11
12 def __init__(self, type, data=None):
13 self.type = type
14 self.data = data
15
16
17 class ClientCommand(object):
18 """ A command to the client thread.
19 Each command type has its associated data:
20
21 CONNECT: (host, port) tuple
22 SEND: Data string
23 RECEIVE: None
24 CLOSE: None
25 PROCESS: to processing
26 SEND: send a data
27 SENDXML: send xml file
28 """
29 CONNECT, SEND, SENDXML, RECEIVE, CLOSE, PROCESS = range(6)
30
31 def __init__(self, type, data=None):
32 self.type = type
33 self.data = data
34
35
36 class ClientReply(object):
37 """ A reply from the client thread.
38 Each reply type has its associated data:
39
40 ERROR: The error string
41 MESSAGE: Data String
42 DATA: Data
43 SUCCESS: Depends on the command - for RECEIVE it's the received
44 data string, for others None.
45 """
46 ERROR, SUCCESS, MESSAGE, DATA= range(4)
47
48 def __init__(self, type, data=None):
49 self.type = type
50 self.data = data
@@ -0,0 +1,21
1 # -*- coding: utf-8 -*-
2
3 """
4 Module implementing Ftp.
5 """
6
7 from PyQt4.QtGui import QMainWindow
8 from PyQt4.QtCore import pyqtSignature
9
10 from schainpy.gui.viewer.ftp import Ui_Ftp
11
12 class Ftp(QMainWindow, Ui_MainWindow):
13 """
14 Class documentation goes here.
15 """
16 def __init__(self, parent = None):
17 """
18 Constructor
19 """
20 QMainWindow.__init__(self, parent)
21 self.setupUi(self)
1 NO CONTENT: new file 100644
@@ -0,0 +1,298
1 import os.path
2 import ftplib
3
4
5 class Ftp():
6 """
7 Ftp is a public class used to define custom File Transfer Protocol from "ftplib" python module
8
9 Non-standard Python modules used: None
10
11 Written by "Daniel Suarez":mailto:daniel.suarez@jro.igp.gob.pe Oct. 26, 2010
12 """
13
14 def __init__(self,host = None, username=None, passw=None, remotefolder=None):
15 """
16 This method is used to setting parameters for FTP and establishing connection to remote host
17
18 Inputs:
19 host - remote host IP Address
20
21 username - remote host Username
22
23 passw - remote host Passw
24
25 remotefolder - remote host current working directory
26
27 Return: void
28
29 Affects:
30 self.status - in Error Case or Connection Failed this parameter is set to 1 else 0
31
32 self.folderList - sub-folder list of remote folder
33
34 self.fileList - file list of remote folder
35
36
37 """
38
39 if ((host == None) and (username==None) and (passw==None) and (remotefolder==None)):
40 host, username, passw, remotefolder = self.parmsByDefault()
41
42 self.host = host
43 self.username = username
44 self.passw = passw
45 self.remotefolder = remotefolder
46 self.file = None
47 self.ftp = None
48 self.status = 0
49
50 try:
51 self.ftp = ftplib.FTP(self.host)
52 self.ftp.login(self.username,self.passw)
53 self.ftp.cwd(self.remotefolder)
54 # print 'Connect to FTP Server: Successfully'
55
56 except ftplib.all_errors:
57 print 'Error FTP Service'
58 self.status = 1
59 return
60
61
62
63 self.dirList = []
64
65 try:
66 self.dirList = self.ftp.nlst()
67
68 except ftplib.error_perm, resp:
69 if str(resp) == "550 No files found":
70 print "no files in this directory"
71 self.status = 1
72 return
73
74 except ftplib.all_errors:
75 print 'Error Displaying Dir-Files'
76 self.status = 1
77 return
78
79 self.fileList = []
80 self.folderList = []
81 #only for test
82 for f in self.dirList:
83 name, ext = os.path.splitext(f)
84 if ext != '':
85 self.fileList.append(f)
86 # print 'filename: %s - size: %d'%(f,self.ftp.size(f))
87
88 def parmsByDefault(self):
89 host = 'jro-app.igp.gob.pe'
90 username = 'wmaster'
91 passw = 'mst2010vhf'
92 remotefolder = '/home/wmaster/graficos'
93
94 # host = 'jro.igp.gob.pe'
95 # username = 'operaciones'
96 # passw = 'mst2010vhf'
97 # remotefolder = '/users/databases/on-line'
98
99 return host, username, passw, remotefolder
100
101
102 def mkd(self,dirname):
103 """
104 mkd is used to make directory in remote host
105
106 Input:
107 dirname - directory name
108
109 Return:
110 1 in error case else 0
111 """
112 try:
113 self.ftp.mkd(dirname)
114 except:
115 print 'Error creating remote folder:%s'%dirname
116 return 1
117
118 return 0
119
120
121 def delete(self,filename):
122 """
123 delete is used to delete file in current working directory of remote host
124
125 Input:
126 filename - filename to delete in remote folder
127
128 Return:
129 1 in error case else 0
130 """
131
132 try:
133 self.ftp.delete(filename)
134 except:
135 print 'Error deleting remote file:%s'%filename
136 return 1
137
138 return 0
139
140 def download(self,filename,localfolder):
141 """
142 download is used to downloading file from remote folder into local folder
143
144 Inputs:
145 filename - filename to donwload
146
147 localfolder - directory local to store filename
148
149 Returns:
150 self.status - 1 in error case else 0
151 """
152
153 self.status = 0
154
155
156 if not(filename in self.fileList):
157 print 'filename:%s not exists'%filename
158 self.status = 1
159 return self.status
160
161 newfilename = os.path.join(localfolder,filename)
162
163 self.file = open(newfilename, 'wb')
164
165 try:
166 print 'Download: ' + filename
167 self.ftp.retrbinary('RETR ' + filename, self.__handleDownload)
168 print 'Download Complete'
169 except ftplib.all_errors:
170 print 'Error Downloading ' + filename
171 self.status = 1
172 return self.status
173
174 self.file.close()
175
176 return self.status
177
178
179 def __handleDownload(self,block):
180 """
181 __handleDownload is used to handle writing file
182 """
183 self.file.write(block)
184
185
186 def upload(self,filename,remotefolder=None):
187 """
188 upload is used to uploading local file to remote directory
189
190 Inputs:
191 filename - full path name of local file to store in remote directory
192
193 remotefolder - remote directory
194
195 Returns:
196 self.status - 1 in error case else 0
197 """
198
199 if remotefolder == None:
200 remotefolder = self.remotefolder
201
202 self.status = 0
203
204 try:
205 self.ftp.cwd(remotefolder)
206
207 self.file = open(filename, 'rb')
208
209 (head, tail) = os.path.split(filename)
210
211 command = "STOR " + tail
212
213 print 'Uploading: ' + tail
214 self.ftp.storbinary(command, self.file)
215 print 'Upload Completed'
216
217 except ftplib.all_errors:
218 print 'Error Uploading ' + tail
219 self.status = 1
220 return self.status
221
222 self.file.close()
223
224 #back to initial directory in __init__()
225 self.ftp.cwd(self.remotefolder)
226
227 return self.status
228
229
230 def dir(self,remotefolder):
231 """
232 dir is used to change working directory of remote host and get folder and file list
233
234 Input:
235 remotefolder - current working directory
236
237 Affects:
238 self.fileList - file list of working directory
239
240 Return:
241 infoList - list with filenames and size of file in bytes
242
243 self.folderList - folder list
244 """
245
246 self.remotefolder = remotefolder
247 print 'Change to ' + self.remotefolder
248 try:
249 self.ftp.cwd(remotefolder)
250 except ftplib.all_errors:
251 print 'Error Change to ' + self.remotefolder
252 infoList = None
253 self.folderList = None
254 return infoList,self.folderList
255
256 self.dirList = []
257
258 try:
259 self.dirList = self.ftp.nlst()
260
261 except ftplib.error_perm, resp:
262 if str(resp) == "550 No files found":
263 print "no files in this directory"
264 infoList = None
265 self.folderList = None
266 return infoList,self.folderList
267 except ftplib.all_errors:
268 print 'Error Displaying Dir-Files'
269 infoList = None
270 self.folderList = None
271 return infoList,self.folderList
272
273 infoList = []
274 self.fileList = []
275 self.folderList = []
276 for f in self.dirList:
277 name,ext = os.path.splitext(f)
278 if ext != '':
279 self.fileList.append(f)
280 value = (f,self.ftp.size(f))
281 infoList.append(value)
282
283 if ext == '':
284 self.folderList.append(f)
285
286 return infoList,self.folderList
287
288
289 def close(self):
290 """
291 close is used to close and end FTP connection
292
293 Inputs: None
294
295 Return: void
296
297 """
298 self.ftp.close() No newline at end of file
This diff has been collapsed as it changes many lines, (538 lines changed) Show them Hide them
@@ -0,0 +1,538
1 import os
2 import numpy
3 import time, datetime
4 import mpldriver_gui
5 from customftp import *
6 import Queue
7 import threading
8
9 class FTP_Thread (threading.Thread):
10 def __init__(self):
11 threading.Thread.__init__(self)
12 self.exitFlag = 0
13 self.queueLock = threading.Lock()
14 self.workQueue = Queue.Queue()
15
16 def run(self):
17 self.send_data()
18
19 def fin(self):
20 self.exitFlag = 1
21
22 def put_data(self, data):
23 # Fill the queue
24 self.queueLock.acquire()
25 self.workQueue.put(data)
26 self.queueLock.release()
27
28 def send_data(self):
29 while not self.exitFlag:
30 if self.workQueue.qsize():
31
32 data = self.workQueue.get(True)
33
34 try:
35 ftpObj = Ftp(host=data['server'],
36 username=data['username'],
37 passw=data['password'],
38 remotefolder=data['folder'])
39
40 ftpObj.upload(data['figfilename'])
41 ftpObj.close()
42 except:
43 print ValueError, 'Error FTP'
44 print "don't worry still running the program"
45
46
47 class Figure():
48
49 __driver = mpldriver_gui
50 __isConfigThread = False
51 fig = None
52
53 id = None
54 wintitle = None
55 width = None
56 height = None
57 nplots = None
58 timerange = None
59
60 axesObjList = []
61
62 WIDTH = None
63 HEIGHT = None
64 PREFIX = 'fig'
65
66 FTP_WEI = None #(WW)
67 EXP_CODE = None #(EXP)
68 SUB_EXP_CODE = None #(SS)
69 PLOT_CODE = None #(TT)
70 PLOT_POS = None #(NN)
71
72
73
74 def __init__(self):
75
76 raise ValueError, "This method is not implemented"
77
78 def getSubplots(self):
79
80 raise ValueError, "Abstract method: This method should be defined"
81
82 def getAxesObjList(self):
83
84 return self.axesObjList
85
86 def getScreenDim(self, widthplot, heightplot):
87
88 nrow, ncol = self.getSubplots()
89 widthscreen = widthplot*ncol
90 heightscreen = heightplot*nrow
91
92 return widthscreen, heightscreen
93
94 def getFilename(self, name, ext='.png'):
95 path = '%s%03d' %(self.PREFIX, self.id)
96 filename = '%s_%s%s' %(self.PREFIX, name, ext)
97 return os.path.join(path, filename)
98
99 def createFigure(self, id, wintitle, widthplot=None, heightplot=None):
100
101 if widthplot == None:
102 widthplot = self.WIDTH
103
104 if heightplot == None:
105 heightplot = self.HEIGHT
106
107 self.id = id
108
109 self.wintitle = wintitle
110
111 self.widthscreen, self.heightscreen = self.getScreenDim(widthplot, heightplot)
112
113 self.fig = self.__driver.createFigure(id=self.id,
114 wintitle=self.wintitle,
115 width=self.widthscreen,
116 height=self.heightscreen)
117
118 self.axesObjList = []
119
120 return self.fig
121
122 def clearAxes(self):
123 self.axesObjList = []
124
125 def addAxes(self, *args):
126 axesObj = Axes(self.fig, *args)
127 self.axesObjList.append(axesObj)
128
129 def saveFigure(self, figpath, figfile, *args):
130
131 filename = os.path.join(figpath, figfile)
132
133 fullpath = os.path.split(filename)[0]
134
135 if not os.path.exists(fullpath):
136 subpath = os.path.split(fullpath)[0]
137
138 if not os.path.exists(subpath):
139 os.mkdir(subpath)
140
141 os.mkdir(fullpath)
142
143 self.__driver.saveFigure(self.fig, filename, *args)
144
145 def getTimeLim(self, x, xmin, xmax):
146
147 if self.timerange != None:
148 txmin = x[0] - x[0]%self.timerange
149 else:
150 txmin = numpy.min(x)
151
152 thisdatetime = datetime.datetime.utcfromtimestamp(txmin)
153 thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0))
154
155 ####################################################
156 #If the x is out of xrange
157 if xmax < (thisdatetime - thisdate).seconds/(60*60.):
158 xmin = None
159 xmax = None
160
161 if xmin == None:
162 td = thisdatetime - thisdate
163 xmin = td.seconds/(60*60.)
164
165 if xmax == None:
166 xmax = xmin + self.timerange/(60*60.)
167
168 mindt = thisdate + datetime.timedelta(hours=xmin) - datetime.timedelta(seconds=time.timezone)
169 tmin = time.mktime(mindt.timetuple())
170
171 maxdt = thisdate + datetime.timedelta(hours=xmax) - datetime.timedelta(seconds=time.timezone)
172 tmax = time.mktime(maxdt.timetuple())
173
174 self.timerange = tmax - tmin
175
176 return tmin, tmax
177
178 def sendByFTP(self, figfilename, server, folder, username, password):
179 ftpObj = Ftp(host=server, username=username, passw=password, remotefolder=folder)
180 ftpObj.upload(figfilename)
181 ftpObj.close()
182
183 def sendByFTP_Thread(self, figfilename, server, folder, username, password):
184 data = {'figfilename':figfilename,'server':server,'folder':folder,'username':username,'password':password}
185
186 if not(self.__isConfigThread):
187
188 self.thread = FTP_Thread()
189 self.thread.start()
190 self.__isConfigThread = True
191
192 self.thread.put_data(data)
193
194
195 def getNameToFtp(self, thisDatetime, FTP_WEI, EXP_CODE, SUB_EXP_CODE, PLOT_CODE, PLOT_POS):
196 YEAR_STR = '%4.4d'%thisDatetime.timetuple().tm_year
197 DOY_STR = '%3.3d'%thisDatetime.timetuple().tm_yday
198 FTP_WEI = '%2.2d'%FTP_WEI
199 EXP_CODE = '%3.3d'%EXP_CODE
200 SUB_EXP_CODE = '%2.2d'%SUB_EXP_CODE
201 PLOT_CODE = '%2.2d'%PLOT_CODE
202 PLOT_POS = '%2.2d'%PLOT_POS
203 name = YEAR_STR + DOY_STR + FTP_WEI + EXP_CODE + SUB_EXP_CODE + PLOT_CODE + PLOT_POS
204 return name
205
206 def draw(self):
207 self.__driver.draw(self.fig)
208
209 axesList = property(getAxesObjList)
210
211 class Axes:
212
213 __driver = mpldriver_gui
214 fig = None
215 ax = None
216 plot = None
217 __missing = 1E30
218 __firsttime = None
219
220 __showprofile = False
221
222 xmin = None
223 xmax = None
224 ymin = None
225 ymax = None
226 zmin = None
227 zmax = None
228
229 x_buffer = None
230 z_buffer = None
231
232 decimationx = None
233 decimationy = None
234
235 __MAXNUMX = 1000.
236 __MAXNUMY = 500.
237
238 def __init__(self, *args):
239
240 """
241
242 Input:
243 *args : Los parametros necesarios son
244 fig, nrow, ncol, xpos, ypos, colspan, rowspan
245 """
246
247 ax = self.__driver.createAxes(*args)
248 self.fig = args[0]
249 self.ax = ax
250 self.plot = None
251
252 self.__firsttime = True
253 self.idlineList = []
254
255 self.x_buffer = numpy.array([])
256 self.z_buffer = numpy.array([])
257
258 def pcolor(self, x, y, z,
259 xmin=None, xmax=None,
260 ymin=None, ymax=None,
261 zmin=None, zmax=None,
262 xlabel='', ylabel='',
263 title='', rti = False, colormap='jet',
264 **kwargs):
265
266 """
267 Input:
268 x :
269 y :
270 x :
271 xmin :
272 xmax :
273 ymin :
274 ymax :
275 zmin :
276 zmax :
277 xlabel :
278 ylabel :
279 title :
280 **kwargs : Los parametros aceptados son
281 ticksize=9,
282 cblabel=''
283 rti = True or False
284 """
285
286 if self.__firsttime:
287
288 if xmin == None: xmin = numpy.nanmin(x)
289 if xmax == None: xmax = numpy.nanmax(x)
290 if ymin == None: ymin = numpy.nanmin(y)
291 if ymax == None: ymax = numpy.nanmax(y)
292 if zmin == None: zmin = numpy.nanmin(z)
293 if zmax == None: zmax = numpy.nanmax(z)
294
295
296 self.plot = self.__driver.createPcolor(self.ax, x, y, z,
297 xmin, xmax,
298 ymin, ymax,
299 zmin, zmax,
300 xlabel=xlabel,
301 ylabel=ylabel,
302 title=title,
303 colormap=colormap,
304 **kwargs)
305
306 if self.xmin == None: self.xmin = xmin
307 if self.xmax == None: self.xmax = xmax
308 if self.ymin == None: self.ymin = ymin
309 if self.ymax == None: self.ymax = ymax
310 if self.zmin == None: self.zmin = zmin
311 if self.zmax == None: self.zmax = zmax
312
313 self.__firsttime = False
314 return
315
316 if rti:
317 self.__driver.addpcolor(self.ax, x, y, z, self.zmin, self.zmax,
318 xlabel=xlabel,
319 ylabel=ylabel,
320 title=title,
321 colormap=colormap)
322 return
323
324 self.__driver.pcolor(self.plot, z,
325 xlabel=xlabel,
326 ylabel=ylabel,
327 title=title)
328
329
330 def pline(self, x, y,
331 xmin=None, xmax=None,
332 ymin=None, ymax=None,
333 xlabel='', ylabel='',
334 title='',
335 **kwargs):
336
337 """
338
339 Input:
340 x :
341 y :
342 xmin :
343 xmax :
344 ymin :
345 ymax :
346 xlabel :
347 ylabel :
348 title :
349 **kwargs : Los parametros aceptados son
350
351 ticksize
352 ytick_visible
353 """
354
355 if self.__firsttime:
356
357 if xmin == None: xmin = numpy.nanmin(x)
358 if xmax == None: xmax = numpy.nanmax(x)
359 if ymin == None: ymin = numpy.nanmin(y)
360 if ymax == None: ymax = numpy.nanmax(y)
361
362 self.plot = self.__driver.createPline(self.ax, x, y,
363 xmin, xmax,
364 ymin, ymax,
365 xlabel=xlabel,
366 ylabel=ylabel,
367 title=title,
368 **kwargs)
369
370 self.idlineList.append(0)
371 self.__firsttime = False
372 return
373
374 self.__driver.pline(self.plot, x, y, xlabel=xlabel,
375 ylabel=ylabel,
376 title=title)
377
378 def pmultiline(self, x, y,
379 xmin=None, xmax=None,
380 ymin=None, ymax=None,
381 xlabel='', ylabel='',
382 title='',
383 **kwargs):
384
385 if self.__firsttime:
386
387 if xmin == None: xmin = numpy.nanmin(x)
388 if xmax == None: xmax = numpy.nanmax(x)
389 if ymin == None: ymin = numpy.nanmin(y)
390 if ymax == None: ymax = numpy.nanmax(y)
391
392 self.plot = self.__driver.createPmultiline(self.ax, x, y,
393 xmin, xmax,
394 ymin, ymax,
395 xlabel=xlabel,
396 ylabel=ylabel,
397 title=title,
398 **kwargs)
399 self.__firsttime = False
400 return
401
402 self.__driver.pmultiline(self.plot, x, y, xlabel=xlabel,
403 ylabel=ylabel,
404 title=title)
405
406 def pmultilineyaxis(self, x, y,
407 xmin=None, xmax=None,
408 ymin=None, ymax=None,
409 xlabel='', ylabel='',
410 title='',
411 **kwargs):
412
413 if self.__firsttime:
414
415 if xmin == None: xmin = numpy.nanmin(x)
416 if xmax == None: xmax = numpy.nanmax(x)
417 if ymin == None: ymin = numpy.nanmin(y)
418 if ymax == None: ymax = numpy.nanmax(y)
419
420 self.plot = self.__driver.createPmultilineYAxis(self.ax, x, y,
421 xmin, xmax,
422 ymin, ymax,
423 xlabel=xlabel,
424 ylabel=ylabel,
425 title=title,
426 **kwargs)
427 if self.xmin == None: self.xmin = xmin
428 if self.xmax == None: self.xmax = xmax
429 if self.ymin == None: self.ymin = ymin
430 if self.ymax == None: self.ymax = ymax
431
432 self.__firsttime = False
433 return
434
435 self.__driver.pmultilineyaxis(self.plot, x, y, xlabel=xlabel,
436 ylabel=ylabel,
437 title=title)
438
439 def addpline(self, x, y, idline, **kwargs):
440 lines = self.ax.lines
441
442 if idline in self.idlineList:
443 self.__driver.set_linedata(self.ax, x, y, idline)
444
445 if idline not in(self.idlineList):
446 self.__driver.addpline(self.ax, x, y, **kwargs)
447 self.idlineList.append(idline)
448
449 return
450
451 def pcolorbuffer(self, x, y, z,
452 xmin=None, xmax=None,
453 ymin=None, ymax=None,
454 zmin=None, zmax=None,
455 xlabel='', ylabel='',
456 title='', rti = True, colormap='jet',
457 maxNumX = None, maxNumY = None,
458 **kwargs):
459
460 if maxNumX == None:
461 maxNumX = self.__MAXNUMX
462
463 if maxNumY == None:
464 maxNumY = self.__MAXNUMY
465
466 if self.__firsttime:
467 self.z_buffer = z
468 self.x_buffer = numpy.hstack((self.x_buffer, x))
469
470 if xmin == None: xmin = numpy.nanmin(x)
471 if xmax == None: xmax = numpy.nanmax(x)
472 if ymin == None: ymin = numpy.nanmin(y)
473 if ymax == None: ymax = numpy.nanmax(y)
474 if zmin == None: zmin = numpy.nanmin(z)
475 if zmax == None: zmax = numpy.nanmax(z)
476
477
478 self.plot = self.__driver.createPcolor(self.ax, self.x_buffer, y, z,
479 xmin, xmax,
480 ymin, ymax,
481 zmin, zmax,
482 xlabel=xlabel,
483 ylabel=ylabel,
484 title=title,
485 colormap=colormap,
486 **kwargs)
487
488 if self.xmin == None: self.xmin = xmin
489 if self.xmax == None: self.xmax = xmax
490 if self.ymin == None: self.ymin = ymin
491 if self.ymax == None: self.ymax = ymax
492 if self.zmin == None: self.zmin = zmin
493 if self.zmax == None: self.zmax = zmax
494
495 self.__firsttime = False
496 return
497
498 self.x_buffer = numpy.hstack((self.x_buffer, x[-1]))
499 self.z_buffer = numpy.hstack((self.z_buffer, z))
500
501 if self.decimationx == None:
502 deltax = float(self.xmax - self.xmin)/maxNumX
503 deltay = float(self.ymax - self.ymin)/maxNumY
504
505 resolutionx = self.x_buffer[2]-self.x_buffer[0]
506 resolutiony = y[1]-y[0]
507
508 self.decimationx = numpy.ceil(deltax / resolutionx)
509 self.decimationy = numpy.ceil(deltay / resolutiony)
510
511 z_buffer = self.z_buffer.reshape(-1,len(y))
512
513 x_buffer = self.x_buffer[::self.decimationx]
514 y_buffer = y[::self.decimationy]
515 z_buffer = z_buffer[::self.decimationx, ::self.decimationy]
516 #===================================================
517
518 x_buffer, y_buffer, z_buffer = self.__fillGaps(x_buffer, y_buffer, z_buffer)
519
520 self.__driver.addpcolorbuffer(self.ax, x_buffer, y_buffer, z_buffer, self.zmin, self.zmax,
521 xlabel=xlabel,
522 ylabel=ylabel,
523 title=title,
524 colormap=colormap)
525 def __fillGaps(self, x_buffer, y_buffer, z_buffer):
526
527 deltas = x_buffer[1:] - x_buffer[0:-1]
528 x_median = numpy.median(deltas)
529
530 index = numpy.where(deltas >= 2*x_median)
531
532 if len(index[0]) != 0:
533 z_buffer[index[0],::] = self.__missing
534 z_buffer = numpy.ma.masked_inside(z_buffer,0.99*self.__missing,1.01*self.__missing)
535
536 return x_buffer, y_buffer, z_buffer
537
538 No newline at end of file
@@ -0,0 +1,326
1 import numpy
2 import datetime
3 import sys
4
5 from matplotlib.figure import Figure
6 from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
7
8 from mpl_toolkits.axes_grid1 import make_axes_locatable
9 from matplotlib.ticker import *
10 import matplotlib.gridspec as gridspec
11 import matplotlib.cm as cm
12 import matplotlib.colorbar
13
14 def createFigure(id, wintitle, width, height, facecolor="w"):
15 figsize = (width,height)
16 fig = Figure(figsize=figsize, facecolor=facecolor)
17
18 return fig
19
20 def createAxes(fig, nrow, ncol, x, y, ratio):
21 width_ratios = []
22 for i in range(ncol):
23 if i%2==0:
24 width_ratios.append(ratio)
25 else:
26 width_ratios.append(1)
27
28 gs = gridspec.GridSpec(nrow, ncol, width_ratios=width_ratios)
29 ax = fig.add_subplot(gs[x,y])
30
31 return ax
32
33 def saveFigure(fig, filename):
34 fig.savefig(filename)
35
36
37 def printLabels(ax, xlabel, ylabel, title):
38
39 ax.set_xlabel(xlabel, size=11)
40 ax.set_ylabel(ylabel, size=11)
41 ax.set_title(title, size=12)
42
43 def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax,
44 xlabel='', ylabel='', title='', ticksize = 9,
45 colormap='jet',cblabel='', cbsize="5%",
46 XAxisAsTime=False):
47
48 divider = make_axes_locatable(ax)
49 ax_cb = divider.new_horizontal(size=cbsize, pad=0.05)
50 fig = ax.get_figure()
51 fig.add_axes(ax_cb)
52
53 ax.set_xlim([xmin,xmax])
54 ax.set_ylim([ymin,ymax])
55
56 printLabels(ax, xlabel, ylabel, title)
57
58 imesh = ax.pcolormesh(x,y,z.T, vmin=zmin, vmax=zmax, cmap=cm.get_cmap(colormap))
59 cb = fig.colorbar(imesh, cax=ax_cb)
60 cb.set_label(cblabel)
61
62 for tick in ax.yaxis.get_major_ticks():
63 tick.label.set_fontsize(ticksize)
64
65 for tick in ax.xaxis.get_major_ticks():
66 tick.label.set_fontsize(ticksize)
67
68 for tick in cb.ax.get_yticklabels():
69 tick.set_fontsize(ticksize)
70
71 ax_cb.yaxis.tick_right()
72
73 if '0.' in matplotlib.__version__[0:2]:
74 print "The matplotlib version has to be updated to 1.1 or newer"
75 return imesh
76
77 if '1.0.' in matplotlib.__version__[0:4]:
78 print "The matplotlib version has to be updated to 1.1 or newer"
79 return imesh
80
81 fig.tight_layout()
82
83 if XAxisAsTime:
84
85 func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S"))
86 ax.xaxis.set_major_formatter(FuncFormatter(func))
87 ax.xaxis.set_major_locator(LinearLocator(7))
88
89 return imesh
90
91 def pcolor(imesh, z, xlabel='', ylabel='', title=''):
92
93 z = z.T
94
95 ax = imesh.get_axes()
96
97 printLabels(ax, xlabel, ylabel, title)
98
99 imesh.set_array(z.ravel())
100
101 def addpcolorbuffer(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'):
102
103 printLabels(ax, xlabel, ylabel, title)
104
105 ax.collections.remove(ax.collections[0])
106
107 ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
108
109
110 def draw(fig):
111
112 if type(fig) == 'int':
113 raise ValueError, "This parameter should be of tpye matplotlib figure"
114
115 fig.canvas.draw()
116
117
118 def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='',
119 ticksize=9, xtick_visible=True, ytick_visible=True,
120 nxticks=4, nyticks=10,
121 grid=None):
122
123 """
124
125 Input:
126 grid : None, 'both', 'x', 'y'
127 """
128 fig = ax.get_figure()
129 ax.set_xlim([xmin,xmax])
130 ax.set_ylim([ymin,ymax])
131
132 printLabels(ax, xlabel, ylabel, title)
133
134 ######################################################
135 if (xmax-xmin)<=1:
136 xtickspos = numpy.linspace(xmin,xmax,nxticks)
137 xtickspos = numpy.array([float("%.1f"%i) for i in xtickspos])
138 ax.set_xticks(xtickspos)
139 else:
140 xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
141 # xtickspos = numpy.arange(nxticks)*float(xmax-xmin)/float(nxticks) + int(xmin)
142 ax.set_xticks(xtickspos)
143
144 for tick in ax.get_xticklabels():
145 tick.set_visible(xtick_visible)
146
147 for tick in ax.xaxis.get_major_ticks():
148 tick.label.set_fontsize(ticksize)
149
150 ######################################################
151 for tick in ax.get_yticklabels():
152 tick.set_visible(ytick_visible)
153
154 for tick in ax.yaxis.get_major_ticks():
155 tick.label.set_fontsize(ticksize)
156
157 ax.plot(x, y)
158 iplot = ax.lines[-1]
159
160 ######################################################
161 if '0.' in matplotlib.__version__[0:2]:
162 print "The matplotlib version has to be updated to 1.1 or newer"
163 return iplot
164
165 if '1.0.' in matplotlib.__version__[0:4]:
166 print "The matplotlib version has to be updated to 1.1 or newer"
167 return iplot
168
169 if grid != None:
170 ax.grid(b=True, which='major', axis=grid)
171 fig.tight_layout()
172 return iplot
173
174 def set_linedata(ax, x, y, idline):
175
176 ax.lines[idline].set_data(x,y)
177
178 def pline(iplot, x, y, xlabel='', ylabel='', title=''):
179
180 ax = iplot.get_axes()
181
182 printLabels(ax, xlabel, ylabel, title)
183
184 set_linedata(ax, x, y, idline=0)
185
186 def addpline(ax, x, y, color, linestyle, lw):
187
188 ax.plot(x,y,color=color,linestyle=linestyle,lw=lw)
189
190 def createPmultiline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None,
191 ticksize=9, xtick_visible=True, ytick_visible=True,
192 nxticks=4, nyticks=10,
193 grid=None):
194
195 """
196
197 Input:
198 grid : None, 'both', 'x', 'y'
199 """
200
201 # matplotlib.pyplot.ioff()
202 fig = ax.get_figure()
203
204 lines = ax.plot(x.T, y)
205 leg = ax.legend(lines, legendlabels, loc='upper right')
206 leg.get_frame().set_alpha(0.5)
207 ax.set_xlim([xmin,xmax])
208 ax.set_ylim([ymin,ymax])
209 printLabels(ax, xlabel, ylabel, title)
210
211 xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
212 ax.set_xticks(xtickspos)
213
214 for tick in ax.get_xticklabels():
215 tick.set_visible(xtick_visible)
216
217 for tick in ax.xaxis.get_major_ticks():
218 tick.label.set_fontsize(ticksize)
219
220 for tick in ax.get_yticklabels():
221 tick.set_visible(ytick_visible)
222
223 for tick in ax.yaxis.get_major_ticks():
224 tick.label.set_fontsize(ticksize)
225
226 iplot = ax.lines[-1]
227
228 if '0.' in matplotlib.__version__[0:2]:
229 print "The matplotlib version has to be updated to 1.1 or newer"
230 return iplot
231
232 if '1.0.' in matplotlib.__version__[0:4]:
233 print "The matplotlib version has to be updated to 1.1 or newer"
234 return iplot
235
236 if grid != None:
237 ax.grid(b=True, which='major', axis=grid)
238
239 # matplotlib.pyplot.tight_layout()
240 #
241 # matplotlib.pyplot.ion()
242
243 fig.tight_layout()
244
245 return iplot
246
247
248 def pmultiline(iplot, x, y, xlabel='', ylabel='', title=''):
249
250 ax = iplot.get_axes()
251
252 printLabels(ax, xlabel, ylabel, title)
253
254 for i in range(len(ax.lines)):
255 line = ax.lines[i]
256 line.set_data(x[i,:],y)
257
258 def createPmultilineYAxis(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None,
259 ticksize=9, xtick_visible=True, ytick_visible=True,
260 nxticks=4, nyticks=10, marker='.', markersize=10, linestyle="None",
261 grid=None, XAxisAsTime=False):
262
263
264 # matplotlib.pyplot.ioff()
265 fig = ax.get_figure()
266
267 lines = ax.plot(x, y.T, linestyle='None', marker='.', markersize=markersize)
268 leg = ax.legend(lines, legendlabels, loc='upper left', bbox_to_anchor=(1.01, 1.00), numpoints=1, handlelength=1.5, \
269 handletextpad=0.5, borderpad=0.5, labelspacing=0.5, borderaxespad=0.)
270
271 for label in leg.get_texts(): label.set_fontsize(9)
272
273 ax.set_xlim([xmin,xmax])
274 ax.set_ylim([ymin,ymax])
275 printLabels(ax, xlabel, ylabel, title)
276
277 # xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
278 # ax.set_xticks(xtickspos)
279
280 for tick in ax.get_xticklabels():
281 tick.set_visible(xtick_visible)
282
283 for tick in ax.xaxis.get_major_ticks():
284 tick.label.set_fontsize(ticksize)
285
286 for tick in ax.get_yticklabels():
287 tick.set_visible(ytick_visible)
288
289 for tick in ax.yaxis.get_major_ticks():
290 tick.label.set_fontsize(ticksize)
291
292 iplot = ax.lines[-1]
293
294 if '0.' in matplotlib.__version__[0:2]:
295 print "The matplotlib version has to be updated to 1.1 or newer"
296 return iplot
297
298 if '1.0.' in matplotlib.__version__[0:4]:
299 print "The matplotlib version has to be updated to 1.1 or newer"
300 return iplot
301
302 if grid != None:
303 ax.grid(b=True, which='major', axis=grid)
304
305 # matplotlib.pyplot.tight_layout()
306
307 if XAxisAsTime:
308
309 func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S"))
310 ax.xaxis.set_major_formatter(FuncFormatter(func))
311 ax.xaxis.set_major_locator(LinearLocator(7))
312
313 fig.tight_layout()
314 # matplotlib.pyplot.ion()
315
316 return iplot
317
318 def pmultilineyaxis(iplot, x, y, xlabel='', ylabel='', title=''):
319
320 ax = iplot.get_axes()
321
322 printLabels(ax, xlabel, ylabel, title)
323
324 for i in range(len(ax.lines)):
325 line = ax.lines[i]
326 line.set_data(x,y[i,:]) No newline at end of file
@@ -0,0 +1,139
1 # -*- coding: utf-8 -*-
2
3 # Form implementation generated from reading ui file '/home/alex/ui/ftpConfig4.ui'
4 #
5 # Created: Tue Aug 20 08:24:35 2013
6 # by: PyQt4 UI code generator 4.10
7 #
8 # WARNING! All changes made in this file will be lost!
9
10 from PyQt4 import QtCore, QtGui
11
12 try:
13 _fromUtf8 = QtCore.QString.fromUtf8
14 except AttributeError:
15 def _fromUtf8(s):
16 return s
17
18 try:
19 _encoding = QtGui.QApplication.UnicodeUTF8
20 def _translate(context, text, disambig):
21 return QtGui.QApplication.translate(context, text, disambig, _encoding)
22 except AttributeError:
23 def _translate(context, text, disambig):
24 return QtGui.QApplication.translate(context, text, disambig)
25
26 class Ui_Ftp(object):
27 def setupUi(self, MainWindow):
28 MainWindow.setObjectName(_fromUtf8("MainWindow"))
29 MainWindow.resize(374, 399)
30 MainWindow.setMinimumSize(QtCore.QSize(374, 399))
31 MainWindow.setMaximumSize(QtCore.QSize(374, 399))
32 self.centralWidget = QtGui.QWidget(MainWindow)
33 self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
34 self.label = QtGui.QLabel(self.centralWidget)
35 self.label.setGeometry(QtCore.QRect(9, 38, 47, 17))
36 self.label.setObjectName(_fromUtf8("label"))
37 self.label_2 = QtGui.QLabel(self.centralWidget)
38 self.label_2.setGeometry(QtCore.QRect(9, 133, 77, 17))
39 self.label_2.setObjectName(_fromUtf8("label_2"))
40 self.label_3 = QtGui.QLabel(self.centralWidget)
41 self.label_3.setGeometry(QtCore.QRect(9, 166, 68, 17))
42 self.label_3.setObjectName(_fromUtf8("label_3"))
43 self.label_4 = QtGui.QLabel(self.centralWidget)
44 self.label_4.setGeometry(QtCore.QRect(9, 9, 101, 17))
45 font = QtGui.QFont()
46 font.setBold(True)
47 font.setWeight(75)
48 self.label_4.setFont(font)
49 self.label_4.setObjectName(_fromUtf8("label_4"))
50 self.label_5 = QtGui.QLabel(self.centralWidget)
51 self.label_5.setGeometry(QtCore.QRect(9, 104, 87, 17))
52 font = QtGui.QFont()
53 font.setBold(True)
54 font.setWeight(75)
55 self.label_5.setFont(font)
56 self.label_5.setObjectName(_fromUtf8("label_5"))
57 self.label_6 = QtGui.QLabel(self.centralWidget)
58 self.label_6.setGeometry(QtCore.QRect(9, 71, 47, 17))
59 self.label_6.setObjectName(_fromUtf8("label_6"))
60 self.serverFTP = QtGui.QLineEdit(self.centralWidget)
61 self.serverFTP.setGeometry(QtCore.QRect(130, 40, 231, 27))
62 self.serverFTP.setObjectName(_fromUtf8("serverFTP"))
63 self.folderFTP = QtGui.QLineEdit(self.centralWidget)
64 self.folderFTP.setGeometry(QtCore.QRect(130, 70, 231, 27))
65 self.folderFTP.setObjectName(_fromUtf8("folderFTP"))
66 self.usernameFTP = QtGui.QLineEdit(self.centralWidget)
67 self.usernameFTP.setGeometry(QtCore.QRect(130, 130, 231, 27))
68 self.usernameFTP.setObjectName(_fromUtf8("usernameFTP"))
69 self.passwordFTP = QtGui.QLineEdit(self.centralWidget)
70 self.passwordFTP.setGeometry(QtCore.QRect(130, 160, 231, 27))
71 self.passwordFTP.setObjectName(_fromUtf8("passwordFTP"))
72 self.ftpCancelButton = QtGui.QPushButton(self.centralWidget)
73 self.ftpCancelButton.setGeometry(QtCore.QRect(130, 360, 111, 27))
74 self.ftpCancelButton.setObjectName(_fromUtf8("ftpCancelButton"))
75 self.ftpOkButton = QtGui.QPushButton(self.centralWidget)
76 self.ftpOkButton.setGeometry(QtCore.QRect(250, 360, 111, 27))
77 self.ftpOkButton.setObjectName(_fromUtf8("ftpOkButton"))
78 self.label_7 = QtGui.QLabel(self.centralWidget)
79 self.label_7.setGeometry(QtCore.QRect(10, 200, 66, 17))
80 font = QtGui.QFont()
81 font.setBold(True)
82 font.setWeight(75)
83 self.label_7.setFont(font)
84 self.label_7.setObjectName(_fromUtf8("label_7"))
85 self.label_8 = QtGui.QLabel(self.centralWidget)
86 self.label_8.setGeometry(QtCore.QRect(10, 230, 81, 17))
87 self.label_8.setObjectName(_fromUtf8("label_8"))
88 self.label_9 = QtGui.QLabel(self.centralWidget)
89 self.label_9.setGeometry(QtCore.QRect(10, 260, 81, 17))
90 self.label_9.setObjectName(_fromUtf8("label_9"))
91 self.label_10 = QtGui.QLabel(self.centralWidget)
92 self.label_10.setGeometry(QtCore.QRect(10, 290, 81, 17))
93 self.label_10.setObjectName(_fromUtf8("label_10"))
94 self.label_11 = QtGui.QLabel(self.centralWidget)
95 self.label_11.setGeometry(QtCore.QRect(10, 320, 81, 17))
96 self.label_11.setObjectName(_fromUtf8("label_11"))
97 self.weightFTP = QtGui.QLineEdit(self.centralWidget)
98 self.weightFTP.setGeometry(QtCore.QRect(130, 230, 231, 27))
99 self.weightFTP.setObjectName(_fromUtf8("weightFTP"))
100 self.expcodeFTP = QtGui.QLineEdit(self.centralWidget)
101 self.expcodeFTP.setGeometry(QtCore.QRect(130, 260, 231, 27))
102 self.expcodeFTP.setObjectName(_fromUtf8("expcodeFTP"))
103 self.subexpFTP = QtGui.QLineEdit(self.centralWidget)
104 self.subexpFTP.setGeometry(QtCore.QRect(130, 290, 231, 27))
105 self.subexpFTP.setObjectName(_fromUtf8("subexpFTP"))
106 self.plotposFTP = QtGui.QLineEdit(self.centralWidget)
107 self.plotposFTP.setGeometry(QtCore.QRect(130, 320, 231, 27))
108 self.plotposFTP.setObjectName(_fromUtf8("plotposFTP"))
109 MainWindow.setCentralWidget(self.centralWidget)
110
111 self.retranslateUi(MainWindow)
112 QtCore.QMetaObject.connectSlotsByName(MainWindow)
113
114 def retranslateUi(self, MainWindow):
115 MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
116 self.label.setText(_translate("MainWindow", "Server:", None))
117 self.label_2.setText(_translate("MainWindow", "User Name:", None))
118 self.label_3.setText(_translate("MainWindow", "Password:", None))
119 self.label_4.setText(_translate("MainWindow", "Server Details", None))
120 self.label_5.setText(_translate("MainWindow", "User Details", None))
121 self.label_6.setText(_translate("MainWindow", "Folder:", None))
122 self.ftpCancelButton.setText(_translate("MainWindow", "Cancel", None))
123 self.ftpOkButton.setText(_translate("MainWindow", "Ok", None))
124 self.label_7.setText(_translate("MainWindow", "Others", None))
125 self.label_8.setText(_translate("MainWindow", "Ftp_wei:", None))
126 self.label_9.setText(_translate("MainWindow", "Exp_code:", None))
127 self.label_10.setText(_translate("MainWindow", "Sub_exp:", None))
128 self.label_11.setText(_translate("MainWindow", "Plot_pos:", None))
129
130
131 if __name__ == "__main__":
132 import sys
133 app = QtGui.QApplication(sys.argv)
134 MainWindow = QtGui.QMainWindow()
135 ui = Ui_Ftp()
136 ui.setupUi(MainWindow)
137 MainWindow.show()
138 sys.exit(app.exec_())
139
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
@@ -1,855 +1,1024
1 1 '''
2 2 Created on September , 2012
3 3 @author:
4 4 '''
5 5 from xml.etree.ElementTree import Element, SubElement
6 6 from xml.etree import ElementTree as ET
7 7 from xml.dom import minidom
8 8
9 9 #import datetime
10 10 from model import *
11 11
12 12 import ast
13 13
14 14 def prettify(elem):
15 15 """Return a pretty-printed XML string for the Element.
16 16 """
17 17 rough_string = ET.tostring(elem, 'utf-8')
18 18 reparsed = minidom.parseString(rough_string)
19 19 return reparsed.toprettyxml(indent=" ")
20 20
21 21 class ParameterConf():
22 22
23 23 id = None
24 24 name = None
25 25 value = None
26 26 format = None
27 27
28 28 __formated_value = None
29 29
30 30 ELEMENTNAME = 'Parameter'
31 31
32 32 def __init__(self):
33 33
34 34 self.format = 'str'
35 35
36 36 def getElementName(self):
37 37
38 38 return self.ELEMENTNAME
39 39
40 40 def getValue(self):
41 41
42 42 if self.__formated_value != None:
43 43
44 44 return self.__formated_value
45 45
46 46 value = self.value
47 47
48 48 if self.format == 'bool':
49 49 value = int(value)
50 50
51 51 if self.format == 'list':
52 52 strList = value.split(',')
53 53
54 54 self.__formated_value = strList
55 55
56 56 return self.__formated_value
57 57
58 58 if self.format == 'intlist':
59 59 """
60 60 Example:
61 61 value = (0,1,2)
62 62 """
63 63 strList = value.split(',')
64 64 intList = [int(x) for x in strList]
65 65
66 66 self.__formated_value = intList
67 67
68 68 return self.__formated_value
69 69
70 70 if self.format == 'floatlist':
71 71 """
72 72 Example:
73 73 value = (0.5, 1.4, 2.7)
74 74 """
75 75 strList = value.split(',')
76 76 floatList = [float(x) for x in strList]
77 77
78 78 self.__formated_value = floatList
79 79
80 80 return self.__formated_value
81 81
82 82 if self.format == 'date':
83 83 strList = value.split('/')
84 84 intList = [int(x) for x in strList]
85 85 date = datetime.date(intList[0], intList[1], intList[2])
86 86
87 87 self.__formated_value = date
88 88
89 89 return self.__formated_value
90 90
91 91 if self.format == 'time':
92 92 strList = value.split(':')
93 93 intList = [int(x) for x in strList]
94 94 time = datetime.time(intList[0], intList[1], intList[2])
95 95
96 96 self.__formated_value = time
97 97
98 98 return self.__formated_value
99 99
100 100 if self.format == 'pairslist':
101 101 """
102 102 Example:
103 103 value = (0,1),(1,2)
104 104 """
105 105
106 106 value = value.replace('(', '')
107 107 value = value.replace(')', '')
108 108
109 109 strList = value.split(',')
110 110 intList = [int(item) for item in strList]
111 111 pairList = []
112 112 for i in range(len(intList)/2):
113 113 pairList.append((intList[i*2], intList[i*2 + 1]))
114 114
115 115 self.__formated_value = pairList
116 116
117 117 return self.__formated_value
118 118
119 119 if self.format == 'multilist':
120 120 """
121 121 Example:
122 122 value = (0,1,2),(3,4,5)
123 123 """
124 124 multiList = ast.literal_eval(value)
125 125
126 126 self.__formated_value = multiList
127 127
128 128 return self.__formated_value
129 129
130 130 format_func = eval(self.format)
131 131
132 132 self.__formated_value = format_func(value)
133 133
134 134 return self.__formated_value
135 135
136 136 def setup(self, id, name, value, format='str'):
137 137
138 138 self.id = id
139 139 self.name = name
140 140 self.value = str(value)
141 141 self.format = str.lower(format)
142 142
143 def update(self, name, value, format='str'):
144
145 self.name = name
146 self.value = str(value)
147 self.format = format
148
143 149 def makeXml(self, opElement):
144 150
145 151 parmElement = SubElement(opElement, self.ELEMENTNAME)
146 152 parmElement.set('id', str(self.id))
147 153 parmElement.set('name', self.name)
148 154 parmElement.set('value', self.value)
149 155 parmElement.set('format', self.format)
150 156
151 157 def readXml(self, parmElement):
152 158
153 159 self.id = parmElement.get('id')
154 160 self.name = parmElement.get('name')
155 161 self.value = parmElement.get('value')
156 162 self.format = str.lower(parmElement.get('format'))
157 163
158 164 #Compatible with old signal chain version
159 165 if self.format == 'int' and self.name == 'idfigure':
160 166 self.name = 'id'
161 167
162 168 def printattr(self):
163 169
164 170 print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format)
165 171
166 172 class OperationConf():
167 173
168 174 id = None
169 175 name = None
170 176 priority = None
171 177 type = None
172 178
173 179 parmConfObjList = []
174 180
175 181 ELEMENTNAME = 'Operation'
176 182
177 183 def __init__(self):
178 184
179 185 self.id = 0
180 186 self.name = None
181 187 self.priority = None
182 188 self.type = 'self'
183 189
184 190
185 191 def __getNewId(self):
186 192
187 193 return int(self.id)*10 + len(self.parmConfObjList) + 1
188 194
189 195 def getElementName(self):
190 196
191 197 return self.ELEMENTNAME
192 198
193 199 def getParameterObjList(self):
194 200
195 201 return self.parmConfObjList
196 202
203 def getParameterObj(self, parameterName):
204
205 for parmConfObj in self.parmConfObjList:
206
207 if parmConfObj.name != parameterName:
208 continue
209
210 return parmConfObj
211
212 return None
213
214 def getParameterObjfromValue(self,parameterValue):
215 for parmConfObj in self.parmConfObjList:
216
217 if parmConfObj.getValue() != parameterValue:
218 continue
219
220 return parmConfObj.getValue()
221
222 return None
223
224 def getParameterValue(self, parameterName):
225
226 parameterObj = self.getParameterObj(parameterName)
227 value = parameterObj.getValue()
228
229 return value
230
197 231 def setup(self, id, name, priority, type):
198 232
199 233 self.id = id
200 234 self.name = name
201 235 self.type = type
202 236 self.priority = priority
203 237
204 238 self.parmConfObjList = []
205 239
240 def removeParameters(self):
241
242 for obj in self.parmConfObjList:
243 del obj
244
245 self.parmConfObjList = []
246
206 247 def addParameter(self, name, value, format='str'):
207 248
208 249 id = self.__getNewId()
209 250
210 251 parmConfObj = ParameterConf()
211 252 parmConfObj.setup(id, name, value, format)
212 253
213 254 self.parmConfObjList.append(parmConfObj)
214 255
215 256 return parmConfObj
216 257
258 def changeParameter(self, name, value, format='str'):
259
260 parmConfObj = self.getParameterObj(name)
261 parmConfObj.update(name, value, format)
262
263 return parmConfObj
264
217 265 def makeXml(self, upElement):
218 266
219 267 opElement = SubElement(upElement, self.ELEMENTNAME)
220 268 opElement.set('id', str(self.id))
221 269 opElement.set('name', self.name)
222 270 opElement.set('type', self.type)
223 271 opElement.set('priority', str(self.priority))
224 272
225 273 for parmConfObj in self.parmConfObjList:
226 274 parmConfObj.makeXml(opElement)
227 275
228 276 def readXml(self, opElement):
229 277
230 278 self.id = opElement.get('id')
231 279 self.name = opElement.get('name')
232 280 self.type = opElement.get('type')
233 281 self.priority = opElement.get('priority')
234 282
235 283 #Compatible with old signal chain version
236 284 #Use of 'run' method instead 'init'
237 285 if self.type == 'self' and self.name == 'init':
238 286 self.name = 'run'
239 287
240 288 self.parmConfObjList = []
241 289
242 290 parmElementList = opElement.getiterator(ParameterConf().getElementName())
243 291
244 292 for parmElement in parmElementList:
245 293 parmConfObj = ParameterConf()
246 294 parmConfObj.readXml(parmElement)
247 295
248 296 #Compatible with old signal chain version
249 297 #If an 'plot' OPERATION is found, changes name operation by the value of its type PARAMETER
250 298 if self.type != 'self' and self.name == 'Plot':
251 299 if parmConfObj.format == 'str' and parmConfObj.name == 'type':
252 300 self.name = parmConfObj.value
253 301 continue
254 302
255 303 self.parmConfObjList.append(parmConfObj)
256 304
257 305 def printattr(self):
258 306
259 307 print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME,
260 308 self.id,
261 309 self.name,
262 310 self.type,
263 311 self.priority)
264 312
265 313 for parmConfObj in self.parmConfObjList:
266 314 parmConfObj.printattr()
267 315
268 316 def createObject(self):
269 317
270 318 if self.type == 'self':
271 319 raise ValueError, "This operation type cannot be created"
272 320
273 321 if self.type == 'external' or self.type == 'other':
274 322 className = eval(self.name)
275 323 opObj = className()
276 324
277 325 return opObj
278 326
279 327 class ProcUnitConf():
280 328
281 329 id = None
282 330 name = None
283 331 datatype = None
284 332 inputId = None
333 parentId = None
285 334
286 335 opConfObjList = []
287 336
288 337 procUnitObj = None
289 338 opObjList = []
290 339
291 340 ELEMENTNAME = 'ProcUnit'
292 341
293 342 def __init__(self):
294 343
295 344 self.id = None
296 345 self.datatype = None
297 346 self.name = None
298 347 self.inputId = None
299 348
300 349 self.opConfObjList = []
301 350
302 351 self.procUnitObj = None
303 352 self.opObjDict = {}
304 353
305 354 def __getPriority(self):
306 355
307 356 return len(self.opConfObjList)+1
308 357
309 358 def __getNewId(self):
310 359
311 360 return int(self.id)*10 + len(self.opConfObjList) + 1
312 361
313 362 def getElementName(self):
314 363
315 364 return self.ELEMENTNAME
316 365
317 366 def getId(self):
318 367
319 368 return str(self.id)
320 369
321 370 def getInputId(self):
322 371
323 372 return str(self.inputId)
324 373
325 374 def getOperationObjList(self):
326 375
327 376 return self.opConfObjList
328 377
378 def getOperationObj(self, name=None):
379
380 for opConfObj in self.opConfObjList:
381
382 if opConfObj.name != name:
383 continue
384
385 return opConfObj
386
387 return None
388
389 def getOpObjfromParamValue(self,value=None):
390
391 for opConfObj in self.opConfObjList:
392 if opConfObj.getParameterObjfromValue(parameterValue=value) != value:
393 continue
394 return opConfObj
395 return None
396
329 397 def getProcUnitObj(self):
330 398
331 399 return self.procUnitObj
332 400
333 def setup(self, id, name, datatype, inputId):
401 def setup(self, id, name, datatype, inputId, parentId=None):
334 402
335 403 self.id = id
336 404 self.name = name
337 405 self.datatype = datatype
338 406 self.inputId = inputId
407 self.parentId = parentId
339 408
340 409 self.opConfObjList = []
341 410
342 411 self.addOperation(name='run', optype='self')
343 412
413 def removeOperations(self):
414
415 for obj in self.opConfObjList:
416 del obj
417
418 self.opConfObjList = []
419 self.addOperation(name='run')
420
344 421 def addParameter(self, **kwargs):
345 422
346 423 opObj = self.opConfObjList[0]
347 424
348 425 opObj.addParameter(**kwargs)
349 426
350 427 return opObj
351 428
352 429 def addOperation(self, name, optype='self'):
353 430
354 431 id = self.__getNewId()
355 432 priority = self.__getPriority()
356 433
357 434 opConfObj = OperationConf()
358 435 opConfObj.setup(id, name=name, priority=priority, type=optype)
359 436
360 437 self.opConfObjList.append(opConfObj)
361 438
362 439 return opConfObj
363 440
364 441 def makeXml(self, procUnitElement):
365 442
366 443 upElement = SubElement(procUnitElement, self.ELEMENTNAME)
367 444 upElement.set('id', str(self.id))
368 445 upElement.set('name', self.name)
369 446 upElement.set('datatype', self.datatype)
370 447 upElement.set('inputId', str(self.inputId))
371 448
372 449 for opConfObj in self.opConfObjList:
373 450 opConfObj.makeXml(upElement)
374 451
375 452 def readXml(self, upElement):
376 453
377 454 self.id = upElement.get('id')
378 455 self.name = upElement.get('name')
379 456 self.datatype = upElement.get('datatype')
380 457 self.inputId = upElement.get('inputId')
381 458
382 459 self.opConfObjList = []
383 460
384 461 opElementList = upElement.getiterator(OperationConf().getElementName())
385 462
386 463 for opElement in opElementList:
387 464 opConfObj = OperationConf()
388 465 opConfObj.readXml(opElement)
389 466 self.opConfObjList.append(opConfObj)
390 467
391 468 def printattr(self):
392 469
393 470 print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME,
394 471 self.id,
395 472 self.name,
396 473 self.datatype,
397 474 self.inputId)
398 475
399 476 for opConfObj in self.opConfObjList:
400 477 opConfObj.printattr()
401 478
402 479 def createObjects(self):
403 480
404 481 className = eval(self.name)
405 482 procUnitObj = className()
406 483
407 484 for opConfObj in self.opConfObjList:
408 485
409 486 if opConfObj.type == 'self':
410 487 continue
411 488
412 489 opObj = opConfObj.createObject()
413 490
414 491 self.opObjDict[opConfObj.id] = opObj
415 492 procUnitObj.addOperation(opObj, opConfObj.id)
416 493
417 494 self.procUnitObj = procUnitObj
418 495
419 496 return procUnitObj
420 497
421 498 def run(self):
422 499
423 500 finalSts = False
424 501
425 502 for opConfObj in self.opConfObjList:
426 503
427 504 kwargs = {}
428 505 for parmConfObj in opConfObj.getParameterObjList():
506 if opConfObj.name == 'run' and parmConfObj.name == 'datatype':
507 continue
508
429 509 kwargs[parmConfObj.name] = parmConfObj.getValue()
430 510
431 511 #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id)
432 512 sts = self.procUnitObj.call(opType = opConfObj.type,
433 513 opName = opConfObj.name,
434 514 opId = opConfObj.id,
435 515 **kwargs)
436 516 finalSts = finalSts or sts
437 517
438 518 return finalSts
439 519
440 520 def close(self):
441 521
522 for opConfObj in self.opConfObjList:
523 if opConfObj.type == 'self':
524 continue
525
526 opObj = self.procUnitObj.getOperationObj(opConfObj.id)
527 opObj.close()
528
442 529 self.procUnitObj.close()
443 530
444 531 return
445 532
446 533 class ReadUnitConf(ProcUnitConf):
447 534
448 535 path = None
449 536 startDate = None
450 537 endDate = None
451 538 startTime = None
452 539 endTime = None
453 540
454 541 ELEMENTNAME = 'ReadUnit'
455 542
456 543 def __init__(self):
457 544
458 545 self.id = None
459 546 self.datatype = None
460 547 self.name = None
461 548 self.inputId = 0
462 549
463 550 self.opConfObjList = []
464 551 self.opObjList = []
465 552
466 553 def getElementName(self):
467 554
468 555 return self.ELEMENTNAME
469 556
470 def setup(self, id, name, datatype, path="", startDate="", endDate="", startTime="", endTime="", **kwargs):
557 def setup(self, id, name, datatype, path, startDate="", endDate="", startTime="", endTime="", parentId=None, **kwargs):
471 558
472 559 self.id = id
473 560 self.name = name
474 561 self.datatype = datatype
475 562
476 563 self.path = path
477 564 self.startDate = startDate
478 565 self.endDate = endDate
479 566 self.startTime = startTime
480 567 self.endTime = endTime
481 568
482 569 self.addRunOperation(**kwargs)
483 570
571 def update(self, datatype, path, startDate, endDate, startTime, endTime, parentId=None, **kwargs):
572
573 self.datatype = datatype
574 self.path = path
575 self.startDate = startDate
576 self.endDate = endDate
577 self.startTime = startTime
578 self.endTime = endTime
579
580 self.updateRunOperation(**kwargs)
581
484 582 def addRunOperation(self, **kwargs):
485 583
486 584 opObj = self.addOperation(name = 'run', optype = 'self')
487 585
586 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
488 587 opObj.addParameter(name='path' , value=self.path, format='str')
489 588 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
490 589 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
491 590 opObj.addParameter(name='startTime' , value=self.startTime, format='time')
492 591 opObj.addParameter(name='endTime' , value=self.endTime, format='time')
493 592
494 593 for key, value in kwargs.items():
495 594 opObj.addParameter(name=key, value=value, format=type(value).__name__)
496 595
497 596 return opObj
498 597
598 def updateRunOperation(self, **kwargs):
599
600 opObj = self.getOperationObj(name = 'run')
601 opObj.removeParameters()
602
603 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
604 opObj.addParameter(name='path' , value=self.path, format='str')
605 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
606 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
607 opObj.addParameter(name='startTime' , value=self.startTime, format='time')
608 opObj.addParameter(name='endTime' , value=self.endTime, format='time')
609
610 for key, value in kwargs.items():
611 opObj.addParameter(name=key, value=value, format=type(value).__name__)
612
613 return opObj
499 614
500 615 class Project():
501 616
502 617 id = None
503 618 name = None
504 619 description = None
505 620 # readUnitConfObjList = None
506 621 procUnitConfObjDict = None
507 622
508 623 ELEMENTNAME = 'Project'
509 624
510 def __init__(self):
625 def __init__(self, control=None, dataq=None):
511 626
512 627 self.id = None
513 628 self.name = None
514 629 self.description = None
515 630
516 # self.readUnitConfObjList = []
517 631 self.procUnitConfObjDict = {}
518 632
633 #global data_q
634 #data_q = dataq
635
636 if control==None:
637 control = {}
638 control['stop'] = False
639 control['pause'] = False
640
641 self.control = control
642
519 643 def __getNewId(self):
520 644
521 645 id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1
522 646
523 647 return str(id)
524 648
525 649 def getElementName(self):
526 650
527 651 return self.ELEMENTNAME
528 652
653 def getId(self):
654
655 return self.id
656
529 657 def setup(self, id, name, description):
530 658
531 659 self.id = id
532 660 self.name = name
533 661 self.description = description
534 662
663 def update(self, name, description):
664
665 self.name = name
666 self.description = description
667
535 668 def addReadUnit(self, datatype=None, name=None, **kwargs):
536 669
537 670 #Compatible with old signal chain version
538 671 if datatype==None and name==None:
539 672 raise ValueError, "datatype or name should be defined"
540 673
541 674 if name==None:
542 675 if 'Reader' in datatype:
543 676 name = datatype
544 677 else:
545 678 name = '%sReader' %(datatype)
546 679
547 680 if datatype==None:
548 681 datatype = name.replace('Reader','')
549 682
550 683 id = self.__getNewId()
551 684
552 685 readUnitConfObj = ReadUnitConf()
553 readUnitConfObj.setup(id, name, datatype, **kwargs)
686 readUnitConfObj.setup(id, name, datatype, parentId=self.id, **kwargs)
554 687
555 688 self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
556 689
557 690 return readUnitConfObj
558 691
559 692 def addProcUnit(self, inputId=0, datatype=None, name=None):
560 693
561 694 #Compatible with old signal chain version
562 695 if datatype==None and name==None:
563 696 raise ValueError, "datatype or name should be defined"
564 697
565 698 if name==None:
566 699 if 'Proc' in datatype:
567 700 name = datatype
568 701 else:
569 702 name = '%sProc' %(datatype)
570 703
571 704 if datatype==None:
572 705 datatype = name.replace('Proc','')
573 706
574 707 id = self.__getNewId()
575 708
576 709 procUnitConfObj = ProcUnitConf()
577 procUnitConfObj.setup(id, name, datatype, inputId)
710 procUnitConfObj.setup(id, name, datatype, inputId, parentId=self.id)
578 711
579 712 self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
580 713
581 714 return procUnitConfObj
582 715
716 def getReadUnitId(self):
717
718 readUnitConfObj = self.getReadUnitObj()
719
720 return readUnitConfObj.id
721
722 def getReadUnitObj(self):
723
724 for obj in self.procUnitConfObjDict.values():
725 if obj.getElementName() == "ReadUnit":
726 return obj
727
728 return None
729
730 def getProcUnitObj(self, id):
731
732 return self.procUnitConfObjDict[id]
733
583 734 def makeXml(self):
584 735
585 736 projectElement = Element('Project')
586 737 projectElement.set('id', str(self.id))
587 738 projectElement.set('name', self.name)
588 739 projectElement.set('description', self.description)
589 740
590 741 # for readUnitConfObj in self.readUnitConfObjList:
591 742 # readUnitConfObj.makeXml(projectElement)
592 743
593 744 for procUnitConfObj in self.procUnitConfObjDict.values():
594 745 procUnitConfObj.makeXml(projectElement)
595 746
596 747 self.projectElement = projectElement
597 748
598 749 def writeXml(self, filename):
599 750
600 751 self.makeXml()
601 752
602 753 #print prettify(self.projectElement)
603 754
604 755 ElementTree(self.projectElement).write(filename, method='xml')
605 756
606 757 def readXml(self, filename):
607 758
608 759 #tree = ET.parse(filename)
609 760 self.projectElement = None
610 761 # self.readUnitConfObjList = []
611 762 self.procUnitConfObjDict = {}
612 763
613 764 self.projectElement = ElementTree().parse(filename)
614 765
615 766 self.project = self.projectElement.tag
616 767
617 768 self.id = self.projectElement.get('id')
618 769 self.name = self.projectElement.get('name')
619 770 self.description = self.projectElement.get('description')
620 771
621 772 readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName())
622 773
623 774 for readUnitElement in readUnitElementList:
624 775 readUnitConfObj = ReadUnitConf()
625 776 readUnitConfObj.readXml(readUnitElement)
626 777
627 778 self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
628 779
629 780 procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName())
630 781
631 782 for procUnitElement in procUnitElementList:
632 783 procUnitConfObj = ProcUnitConf()
633 784 procUnitConfObj.readXml(procUnitElement)
634 785
635 786 self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
636 787
637 788 def printattr(self):
638 789
639 790 print "Project[%s]: name = %s, description = %s" %(self.id,
640 791 self.name,
641 792 self.description)
642 793
643 794 # for readUnitConfObj in self.readUnitConfObjList:
644 795 # readUnitConfObj.printattr()
645 796
646 797 for procUnitConfObj in self.procUnitConfObjDict.values():
647 798 procUnitConfObj.printattr()
648 799
649 800 def createObjects(self):
650 801
651 802 # for readUnitConfObj in self.readUnitConfObjList:
652 803 # readUnitConfObj.createObjects()
653 804
654 805 for procUnitConfObj in self.procUnitConfObjDict.values():
655 806 procUnitConfObj.createObjects()
656 807
657 808 def __connect(self, objIN, thisObj):
658 809
659 810 thisObj.setInput(objIN.getOutputObj())
660 811
661 812 def connectObjects(self):
662 813
663 814 for thisPUConfObj in self.procUnitConfObjDict.values():
664 815
665 816 inputId = thisPUConfObj.getInputId()
666 817
667 818 if int(inputId) == 0:
668 819 continue
669 820
670 821 #Get input object
671 822 puConfINObj = self.procUnitConfObjDict[inputId]
672 823 puObjIN = puConfINObj.getProcUnitObj()
673 824
674 825 #Get current object
675 826 thisPUObj = thisPUConfObj.getProcUnitObj()
676 827
677 828 self.__connect(puObjIN, thisPUObj)
678 829
679 830 def run(self):
680 831
681 832 # for readUnitConfObj in self.readUnitConfObjList:
682 833 # readUnitConfObj.run()
683 834 print
684 835 print "*"*40
685 836 print " Starting SIGNAL CHAIN PROCESSING "
686 837 print "*"*40
687 838 print
688 839
689 840 keyList = self.procUnitConfObjDict.keys()
690 841 keyList.sort()
691 842
692 843 while(True):
693 844
694 845 finalSts = False
695 846
696 847 for procKey in keyList:
697 848 # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id)
698 849
699 850 procUnitConfObj = self.procUnitConfObjDict[procKey]
700 851 sts = procUnitConfObj.run()
701 852 finalSts = finalSts or sts
702 853
703 854 #If every process unit finished so end process
704 855 if not(finalSts):
705 856 print "Every process unit have finished"
706 857 break
707 858
859 if self.control['pause']:
860 print "Pause..."
861
862 while True:
863 time.sleep(0.1)
864
865 if not self.control['pause']:
866 break
867
868 if self.control['stop']:
869 break
870
871 if self.control['stop']:
872 print "Stopping process"
873 break
874
708 875 #Closing every process
709 876 for procKey in keyList:
710 877 procUnitConfObj = self.procUnitConfObjDict[procKey]
711 878 procUnitConfObj.close()
712 879
880 print "Process stopped"
881
713 882 def start(self, filename):
714 883
715 884 self.writeXml(filename)
716 885 self.readXml(filename)
717 886
718 887 self.createObjects()
719 888 self.connectObjects()
720 889 self.run()
721 890
722 891 if __name__ == '__main__':
723 892
724 893 desc = "Segundo Test"
725 894 filename = "schain.xml"
726 895
727 896 controllerObj = Project()
728 897
729 898 controllerObj.setup(id = '191', name='test01', description=desc)
730 899
731 900 readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage',
732 901 path='data/rawdata/',
733 902 startDate='2011/01/01',
734 903 endDate='2012/12/31',
735 904 startTime='00:00:00',
736 905 endTime='23:59:59',
737 906 online=1,
738 907 walk=1)
739 908
740 909 # opObj00 = readUnitConfObj.addOperation(name='printInfo')
741 910
742 911 procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId())
743 912
744 913 opObj10 = procUnitConfObj0.addOperation(name='selectChannels')
745 914 opObj10.addParameter(name='channelList', value='3,4,5', format='intlist')
746 915
747 916 opObj10 = procUnitConfObj0.addOperation(name='selectHeights')
748 917 opObj10.addParameter(name='minHei', value='90', format='float')
749 918 opObj10.addParameter(name='maxHei', value='180', format='float')
750 919
751 920 opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='external')
752 921 opObj12.addParameter(name='n', value='10', format='int')
753 922
754 923 procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId())
755 924 procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int')
756 925 # procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='')
757 926
758 927
759 928 opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external')
760 929 opObj11.addParameter(name='idfigure', value='1', format='int')
761 930 opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str')
762 931 opObj11.addParameter(name='zmin', value='40', format='int')
763 932 opObj11.addParameter(name='zmax', value='90', format='int')
764 933 opObj11.addParameter(name='showprofile', value='1', format='int')
765 934
766 935 # opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='external')
767 936 # opObj11.addParameter(name='idfigure', value='2', format='int')
768 937 # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str')
769 938 # opObj11.addParameter(name='zmin', value='40', format='int')
770 939 # opObj11.addParameter(name='zmax', value='90', format='int')
771 940
772 941
773 942 # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Voltage', inputId=procUnitConfObj0.getId())
774 943 #
775 944 # opObj12 = procUnitConfObj2.addOperation(name='CohInt', optype='external')
776 945 # opObj12.addParameter(name='n', value='2', format='int')
777 946 # opObj12.addParameter(name='overlapping', value='1', format='int')
778 947 #
779 948 # procUnitConfObj3 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj2.getId())
780 949 # procUnitConfObj3.addParameter(name='nFFTPoints', value='32', format='int')
781 950 #
782 951 # opObj11 = procUnitConfObj3.addOperation(name='SpectraPlot', optype='external')
783 952 # opObj11.addParameter(name='idfigure', value='2', format='int')
784 953 # opObj11.addParameter(name='wintitle', value='SpectraPlot1', format='str')
785 954 # opObj11.addParameter(name='zmin', value='40', format='int')
786 955 # opObj11.addParameter(name='zmax', value='90', format='int')
787 956 # opObj11.addParameter(name='showprofile', value='1', format='int')
788 957
789 958 # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='external')
790 959 # opObj11.addParameter(name='idfigure', value='10', format='int')
791 960 # opObj11.addParameter(name='wintitle', value='RTI', format='str')
792 961 ## opObj11.addParameter(name='xmin', value='21', format='float')
793 962 ## opObj11.addParameter(name='xmax', value='22', format='float')
794 963 # opObj11.addParameter(name='zmin', value='40', format='int')
795 964 # opObj11.addParameter(name='zmax', value='90', format='int')
796 965 # opObj11.addParameter(name='showprofile', value='1', format='int')
797 966 # opObj11.addParameter(name='timerange', value=str(60), format='int')
798 967
799 968 # opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
800 969 # opObj10.addParameter(name='channelList', value='0,2,4,6', format='intlist')
801 970 #
802 971 # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='external')
803 972 # opObj12.addParameter(name='n', value='2', format='int')
804 973 #
805 974 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external')
806 975 # opObj11.addParameter(name='idfigure', value='2', format='int')
807 976 # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str')
808 977 # opObj11.addParameter(name='zmin', value='70', format='int')
809 978 # opObj11.addParameter(name='zmax', value='90', format='int')
810 979 #
811 980 # opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
812 981 # opObj10.addParameter(name='channelList', value='2,6', format='intlist')
813 982 #
814 983 # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='external')
815 984 # opObj12.addParameter(name='n', value='2', format='int')
816 985 #
817 986 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external')
818 987 # opObj11.addParameter(name='idfigure', value='3', format='int')
819 988 # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str')
820 989 # opObj11.addParameter(name='zmin', value='70', format='int')
821 990 # opObj11.addParameter(name='zmax', value='90', format='int')
822 991
823 992
824 993 # opObj12 = procUnitConfObj1.addOperation(name='decoder')
825 994 # opObj12.addParameter(name='ncode', value='2', format='int')
826 995 # opObj12.addParameter(name='nbauds', value='8', format='int')
827 996 # opObj12.addParameter(name='code0', value='001110011', format='int')
828 997 # opObj12.addParameter(name='code1', value='001110011', format='int')
829 998
830 999
831 1000
832 1001 # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj1.getId())
833 1002 #
834 1003 # opObj21 = procUnitConfObj2.addOperation(name='IncohInt', optype='external')
835 1004 # opObj21.addParameter(name='n', value='2', format='int')
836 1005 #
837 1006 # opObj11 = procUnitConfObj2.addOperation(name='SpectraPlot', optype='external')
838 1007 # opObj11.addParameter(name='idfigure', value='4', format='int')
839 1008 # opObj11.addParameter(name='wintitle', value='SpectraPlot OBJ 2', format='str')
840 1009 # opObj11.addParameter(name='zmin', value='70', format='int')
841 1010 # opObj11.addParameter(name='zmax', value='90', format='int')
842 1011
843 1012 print "Escribiendo el archivo XML"
844 1013
845 1014 controllerObj.writeXml(filename)
846 1015
847 1016 print "Leyendo el archivo XML"
848 1017 controllerObj.readXml(filename)
849 1018 #controllerObj.printattr()
850 1019
851 1020 controllerObj.createObjects()
852 1021 controllerObj.connectObjects()
853 1022 controllerObj.run()
854 1023
855 1024 No newline at end of file
@@ -1,1 +0,0
1 from figure import * No newline at end of file
@@ -1,30 +1,29
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-'
1
3 2 import sys
4 3 from PyQt4 import QtCore, QtGui
5 4 from PyQt4.QtGui import QApplication
6 5 #from PyQt4.QtCore import pyqtSignature
7 6
8 7 from viewcontroller.initwindow import InitWindow
9 8 from viewcontroller.basicwindow import BasicWindow
10 9 from viewcontroller.workspace import Workspace
11 10
12 11 def main():
13 12 import sys
14 13 app = QtGui.QApplication(sys.argv)
15 14
16 15 Welcome=InitWindow()
17 16 if not Welcome.exec_():
18 17 sys.exit(-1)
19 18
20 19 WorkPathspace=Workspace()
21 20 if not WorkPathspace.exec_():
22 21 sys.exit(-1)
23 22
24 23 MainGUI=BasicWindow()
25 24 MainGUI.setWorkSpaceGUI(WorkPathspace.dirComBox.currentText())
26 25 MainGUI.show()
27 26 sys.exit(app.exec_())
28 27
29 28 if __name__ == "__main__":
30 29 main() No newline at end of file
@@ -1,1 +0,0
1 from viewcontroller import * No newline at end of file
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
@@ -1,42 +1,42
1 1 # -*- coding: utf-8 -*-
2 2
3 3 """
4 4 Module implementing InitWindow.
5 5 """
6 6
7 7 from PyQt4.QtGui import QDialog
8 8 from PyQt4.QtCore import pyqtSignature
9 9 from PyQt4 import QtCore
10 10 from PyQt4 import QtGui
11 11
12 from viewer.ui_initwindow import Ui_InitWindow
12 from schainpy.gui.viewer.ui_initwindow import Ui_InitWindow
13 13
14 14 class InitWindow(QDialog, Ui_InitWindow):
15 15 """
16 16 Class documentation goes here.
17 17 """
18 18 def __init__(self, parent = None):
19 19 """
20 20 Constructor
21 21 """
22 22 QDialog.__init__(self, parent)
23 23 self.setupUi(self)
24 24 self.setWindowTitle("ROJ-Signal Chain")
25 self.setWindowIcon(QtGui.QIcon("figure/adn.jpg"))
25 self.setWindowIcon(QtGui.QIcon("schainpy/gui/figure/adn.jpg"))
26 26
27 27 @pyqtSignature("")
28 28 def on_ExitBtn_clicked(self):
29 29 """
30 30 Exit cierra la ventana de Bienvenida
31 31 """
32 32 self.close()
33 33
34 34 @pyqtSignature("")
35 35 def on_ContinueBtn_clicked(self):
36 36 """
37 37 Continue cierra la ventana de Bienvenida, a este evento se le complementa con la accion
38 38 conectar con la ventana de configuracion de Workspace
39 39 """
40 40 # TODO: not implemented yet
41 41 #raise NotImplementedError
42 42 self.accept()
@@ -1,633 +1,632
1 1 # -*- coding: utf-8 -*-
2 2 """
3 3 Module implementing MainWindow.
4 4 #+++++++++++++++++++++INTERFAZ DE USUARIO V1.1++++++++++++++++++++++++#
5 5 """
6 6 from PyQt4.QtGui import QMainWindow
7 7 from PyQt4.QtCore import pyqtSignature
8 8 from PyQt4.QtCore import pyqtSignal
9 9 from PyQt4 import QtCore
10 10 from PyQt4 import QtGui
11 11 from timeconversions import Doy2Date
12 12 from modelProperties import treeModel
13 13
14 from viewer.ui_unitprocess import Ui_UnitProcess
15 from viewer.ui_window import Ui_window
16 from viewer.ui_mainwindow import Ui_MainWindow
14 from schainpy.gui.viewer.ui_unitprocess import Ui_UnitProcess
15 from schainpy.gui.viewer.ui_window import Ui_window
16 from schainpy.gui.viewer.ui_mainwindow import Ui_MainWindow
17 17
18
19 from controller import Project,ReadUnitConf,ProcUnitConf,OperationConf,ParameterConf
18 from schainpy.controller import Project,ReadUnitConf,ProcUnitConf,OperationConf,ParameterConf
20 19 import os
21 20
22 21
23 22 class BodyMainWindow(QMainWindow, Ui_MainWindow):
24 23 __projObjDict = {}
25 24 __arbolDict = {}
26 25 __upObjDict = {}
27 26
28 27 """
29 28 Class documentation goes here.
30 29 #*##################VENTANA CUERPO DEL PROGRAMA####################
31 30 """
32 31 def __init__(self, parent = None):
33 32 """
34 33 Constructor
35 34 """
36 35 print "Inicio de Programa Interfaz Gráfica"
37 36 QMainWindow.__init__(self, parent)
38 37 self.setupUi(self)
39 38
40 39 self.indexclick=None
41 40
42 41 self.online=0
43 42 self.datatype=0
44 43 self.variableList=[]
45 44
46 45 self.proObjList=[]
47 46 self.idp=0
48 47 self.namep=0
49 48 self.description=0
50 49 self.namepTree=0
51 50 self.valuep=0
52 51
53 52 self.upObjList= []
54 53 self.upn=0
55 54 self.upName=0
56 55 self.upType=0
57 56 self.uporProObjRecover=0
58 57
59 58 self.readUnitConfObjList=[]
60 59
61 60 self.upObjVolList=[]
62 61 self.upobjSpecList=[]
63 62
64 63 self.operObjList=[]
65 64
66 65 self.configProject=None
67 66 self.configUP=None
68 67
69 68 self.readUnitConfObj=None
70 69 self.procUnitConfObj0=None
71 70 self.opObj10=None
72 71 self.opObj12=None
73 72
74 73 self.setParam()
75 74
76 75 #-----------------------------------NEW PROPERTIES------------------------------------------------#
77 76 QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10))
78 77 self.addprojectBtn.setToolTip('Add_New_Project')
79 78 self.addUnitProces.setToolTip('Add_New_Processing_Unit')
80 79
81 80 #-----------------------------------NEW PROPERTIES------------------------------------------------#
82 81 self.model = QtGui.QStandardItemModel()
83 82 self.treeView.setModel(self.model)
84 83 self.treeView.clicked.connect(self.clickFunctiontree)
85 84 self.treeView.expandAll()
86 85 #self.treeView.clicked.connect(self.treefunction1)
87 86
88 87 #-----------------------------------BARRA DE MENU-------------------------------------------------#
89 88
90 89 #----------------------------------- MENU_PROJECT--------------------------------------------------#
91 90
92 91 @pyqtSignature("")
93 92 def on_menuFileAbrirObj_triggered(self):
94 93 """
95 94 Abre un archivo de configuracion seleccionado, lee los parametros y
96 95 actualiza los atributos de esta clase; creando los objetos necesarios
97 96 con los parametros leidos desde el archivo.
98 97 """
99 98 print "Leer un archivo xml y extraer sus atributos Not implemented yet"
100 99
101 100 @pyqtSignature("")
102 101 def on_menuFileCrearObj_triggered(self):
103 102 """
104 103 Crea un proyecto nuevo y lo anade a mi diccionario de proyectos
105 104 y habilita la ventana de configuracion del proyecto.
106 105
107 106 """
108 107 self.addProject()
109 108
110 109 @pyqtSignature("")
111 110 def on_menuFileGuardarObj_triggered(self):
112 111 """
113 112 METODO EJECUTADO CUANDO OCURRE EL EVENTO GUARDAR PROJECTO
114 113
115 114 Llama al metodo saveProject.
116 115 """
117 116 # my_id = arbol_selected()
118 117 # filename = savefindow.show()
119 118 # self.saveProject(id, filename)
120 119 print "probsave"
121 120 self.saveProject()
122 121
123 122 @pyqtSignature("")
124 123 def on_menuFileCerrarObj_triggered(self):
125 124 """
126 125 METODO EJECUTADO CUANDO OCURRE EL EVENTO CERRAR
127 126 Llama al metodo close.
128 127 """
129 128 self.close()
130 129
131 130 #-----------------------------------MENU_RUN----------------------------------------------------#
132 131
133 132 @pyqtSignature("")
134 133 def on_menuRUNStartObj_clicked(self):
135 134 """
136 135 METODO EJECUTADO CUANDO OCURRE EL EVENTO RUN
137 136 Llama al metodo RUN.
138 137 """
139 138 print "Not implemented yet"
140 139
141 140 @pyqtSignature("")
142 141 def on_menuRUNPausaObj_clicked(self):
143 142 """
144 143 METODO EJECUTADO CUANDO OCURRE EL EVENTO PAUSA
145 144 Llama al metodo PAUSA.
146 145 """
147 146 print "Not implemented yet"
148 147
149 148 #-----------------------------------MENU_OPTION-------------------------------------------------#
150 149
151 150 @pyqtSignature("")
152 151 def on_menuOptConfigLogfileObj_clicked(self):
153 152 """
154 153 METODO EJECUTADO CUANDO OCURRE EL EVENTO ConfigLog
155 154 Llama al metodo close.
156 155 """
157 156 print "Not implemented yet"
158 157
159 158 @pyqtSignature("")
160 159 def on_menuOptConfigserverObj_clicked(self):
161 160 """
162 161 METODO EJECUTADO CUANDO OCURRE EL EVENTO Config Server
163 162 Llama al metodo close.
164 163 """
165 164 print "Not implemented yet"
166 165 #-----------------------------------MENU_HELP-------------------------------------------------------#
167 166
168 167 @pyqtSignature("")
169 168 def on_menuHELPAboutObj_clicked(self):
170 169 """
171 170 METODO EJECUTADO CUANDO OCURRE EL EVENTO HELP
172 171 Llama al metodo close.
173 172 """
174 173 print "Not implemented yet"
175 174
176 175 @pyqtSignature("")
177 176 def on_menuHELPPrfObj_clicked(self):
178 177 """
179 178 METODO EJECUTADO CUANDO OCURRE EL EVENTO HElp
180 179 Llama al metodo close.
181 180 """
182 181 print "Not implemented yet"
183 182
184 183 #-----------------------------------BARRA DE HERRAMIENTAS----------------------------------------#
185 184
186 185 @pyqtSignature("")
187 186 def on_actOpenObj_triggered(self):
188 187 """
189 188 METODO CARGA UN ARCHIVO DE CONFIGURACION ANTERIOR
190 189 """
191 190 print "Leer un archivo xml y extraer sus atributos Not implemented yet"
192 191
193 192 @pyqtSignature("")
194 193 def on_actCreateObj_triggered(self):
195 194 """
196 195 CREAR PROJECT ,ANADE UN NUEVO PROYECTO, LLAMA AL MÉTODO QUE CONTIENE LAS OPERACION DE CREACION DE PROYECTOS
197 196 Llama al metodo addProject.
198 197 """
199 198 self.addProject()
200 199
201 200 @pyqtSignature("")
202 201 def on_actStopObj_triggered(self):
203 202 """
204 203 METODO EJECUTADO CUANDO OCURRE EL EVENTO PAUSA
205 204 Llama al metodo PAUSA.
206 205 """
207 206 print "Not implemented yet"
208 207
209 208 @pyqtSignature("")
210 209 def on_actPlayObj_triggered(self):
211 210 """
212 211 METODO EJECUTADO CUANDO OCURRE EL EVENTO PAUSA
213 212 Llama al metodo PAUSA.
214 213 """
215 214 print "Not implemented yet"
216 215
217 216 @pyqtSignature("")
218 217 def on_actSaveObj_triggered(self):
219 218 """
220 219 METODO EJECUTADO CUANDO OCURRE EL EVENTO SAVE
221 220 Llama al metodo SAVE.
222 221 """
223 222 self.saveProject()
224 223
225 224 #-----------------------------------PUSHBUTTON_CREATE PROJECT----------------------------------#
226 225
227 226 @pyqtSignature("")
228 227 def on_addprojectBtn_clicked(self):
229 228 """
230 229 CREAR PROJECT ,ANADE UN NUEVO PROYECTO, LLAMA AL MÉTODO QUE CONTIENE LAS OPERACION DE CREACION DE PROYECTOS
231 230 Llama al metodo addProject.
232 231 """
233 232 self.addProject()
234 233
235 234 #------------------------------------VENTANA CONFIGURACION PROJECT----------------------------#
236 235
237 236 @pyqtSignature("int")
238 237 def on_dataTypeCmbBox_activated(self,index):
239 238 """
240 239 Metodo que identifica que tipo de dato se va a trabajar VOLTAGE O ESPECTRA
241 240 """
242 241 self.dataFormatTxt.setReadOnly(True)
243 242 if index==0:
244 243 self.datatype='Voltage'
245 244 elif index==1:
246 245 self.datatype='Spectra'
247 246 else :
248 247 self.datatype=''
249 248 self.dataFormatTxt.setReadOnly(False)
250 249 self.dataFormatTxt.setText(self.datatype)
251 250
252 251 @pyqtSignature("")
253 252 def on_dataPathBrowse_clicked(self):
254 253 """
255 254 OBTENCION DE LA RUTA DE DATOS
256 255 """
257 256 self.dataPath = str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly))
258 257 self.dataPathTxt.setText(self.dataPath)
259 258 self.statusDpath=self.existDir(self.dataPath)
260 259 self.loadDays()
261 260
262 261 @pyqtSignature("int")
263 262 def on_starDateCmbBox_activated(self, index):
264 263 """
265 264 SELECCION DEL RANGO DE FECHAS -START DATE
266 265 """
267 266 var_StopDay_index=self.endDateCmbBox.count() - self.endDateCmbBox.currentIndex()
268 267 self.endDateCmbBox.clear()
269 268 for i in self.variableList[index:]:
270 269 self.endDateCmbBox.addItem(i)
271 270 self.endDateCmbBox.setCurrentIndex(self.endDateCmbBox.count() - var_StopDay_index)
272 271 self.getsubList()
273 272
274 273 @pyqtSignature("int")
275 274 def on_endDateCmbBox_activated(self, index):
276 275 """
277 276 SELECCION DEL RANGO DE FECHAS-END DATE
278 277 """
279 278 var_StartDay_index=self.starDateCmbBox.currentIndex()
280 279 var_end_index = self.endDateCmbBox.count() - index
281 280 self.starDateCmbBox.clear()
282 281 for i in self.variableList[:len(self.variableList) - var_end_index + 1]:
283 282 self.starDateCmbBox.addItem(i)
284 283 self.starDateCmbBox.setCurrentIndex(var_StartDay_index)
285 284 self.getsubList() #Se carga var_sublist[] con el rango de las fechas seleccionadas
286 285
287 286 @pyqtSignature("int")
288 287 def on_readModeCmBox_activated(self, p0):
289 288 """
290 289 SELECCION DEL MODO DE LECTURA ON=1, OFF=0
291 290 """
292 291 if p0==0:
293 292 self.online=0
294 293 elif p0==1:
295 294 self.online=1
296 295
297 296 #---------------PUSHBUTTON_DATA " OKBUTTON "_CONFIGURATION PROJECT--------------------------#
298 297
299 298 @pyqtSignature("")
300 299 def on_dataOkBtn_clicked(self):
301 300 """
302 301 Añade al Obj XML de Projecto, name,datatype,date,time,readmode,wait,etc, crea el readUnitProcess del archivo xml.
303 302 Prepara la configuración del diágrama del Arbol del treeView numero 2
304 303 """
305 304 print "En este nivel se pasa el tipo de dato con el que se trabaja,path,startDate,endDate,startTime,endTime,online"
306 305
307 306 for i in self.__arbolDict:
308 307 if self.__arbolDict[i]==self.indexclick:
309 308 self.projectObj=self.__projObjDict[int(i)]
310 309 # print self.projectObj
311 310 # print i
312 311 # print "get",self.__arbolDict.items()
313 312 # print "keys",self.__arbolDict.keys()
314 313 self.description="Think"
315 314 id=i
316 315 name=str(self.nameProjectTxt.text())
317 316 desc=str(self.description)
318 317
319 318 self.projectObj.setup(id = id, name=name, description=desc)
320 319 print self.projectObj.id
321 320 # print self.projectObj.name
322 321 # print self.projectObj.description
323 322
324 323 datatype=str(self.dataTypeCmbBox.currentText())
325 324 path=str(self.dataPathTxt.text())
326 325 online=int(self.online)
327 326 starDate=str(self.starDateCmbBox.currentText())
328 327 endDate=str(self.endDateCmbBox.currentText())
329 328
330 329
331 330 self.readUnitConfObj = self.projectObj.addReadUnit(datatype=datatype,
332 331 path=path,
333 332 startDate=starDate,
334 333 endDate=endDate,
335 334 startTime='06:10:00',
336 335 endTime='23:59:59',
337 336 online=online)
338 337
339 338 self.readUnitConfObjList.append(self.readUnitConfObj)
340 339 print "self.readUnitConfObj.getId",self.readUnitConfObj.getId(),datatype,path,starDate,endDate,online
341 340
342 341 self.model_2=treeModel()
343 342 self.model_2.setParams(name=self.projectObj.name+str(self.projectObj.id),
344 343 directorio=path,
345 344 workspace="C:\\WorkspaceGUI",
346 345 remode=str(self.readModeCmBox.currentText()),
347 346 dataformat=datatype,
348 347 date=str(starDate)+"-"+str(endDate),
349 348 initTime='06:10:00',
350 349 endTime='23:59:59',
351 350 timezone="Local" ,
352 351 Summary="test de prueba")
353 352 self.model_2.arbol()
354 353 self.treeView_2.setModel(self.model_2)
355 354 self.treeView_2.expandAll()
356 355
357 356 #
358 357 #-----------------PUSHBUTTON_ADD_PROCESSING UNIT PROJECT------------------#
359 358 @pyqtSignature("")
360 359 def on_addUnitProces_clicked(self):
361 360 """
362 361 CREAR PROCESSING UNI ,ANADE UNA UNIDAD DE PROCESAMIENTO, LLAMA AL MÉTODO addUP QUE CONTIENE LAS OPERACION DE CREACION DE UNIDADES DE PROCESAMIENTO
363 362 Llama al metodo addUP.
364 363 """
365 364 # print "En este nivel se adiciona una rama de procesamiento, y se le concatena con el id"
366 365 self.addUP()
367 366
368 367 #----------------------------BASICO-----------------------------------#
369 368
370 369 def getNumberofProject(self):
371 370 # for i in self.proObjList:
372 371 # print i
373 372 return self.proObjList
374 373 # for i in self.proObjList:
375 374 # print i
376 375
377 376 def setParam(self):
378 377
379 378 self.tabWidgetProject.setEnabled(False)
380 379 self.dataPathTxt.setText('C:\data')
381 380 self.nameProjectTxt.setText("Test")
382 381 self.numberChannelopVol.setEnabled(False)
383 382 self.lineHeighProfileTxtopVol.setEnabled(False)
384 383 self.numberIntegration.setEnabled(False)
385 384 self.valuenFFTPointOpSpec.setEnabled(False)
386 385 self.lineProfileSelecopVolCEB.setEnabled(False)
387 386
388 387 def clickFunctiontree(self,index):
389 388 self.indexclick= index.model().itemFromIndex(index)
390 389 print self.indexclick
391 390 return self.indexclick
392 391 # self.indexclick= index.model().itemFromIndex(index).text()
393 392 # return self.indexclick
394 393 # print self.indexclick()
395 394 # print index.model().itemFromIndex(index)
396 395 # print self.indexclick
397 396 # NumofPro=self.indexclick[8:10]
398 397 # self.valuep=NumofPro
399 398 # #print self.valuep
400 399 # NameofPro=self.indexclick[0:7]
401 400 # self.namepTree=NameofPro
402 401 # print self.namepTree
403 402
404 403 def addProject(self):
405 404 self.tabWidgetProject.setEnabled(True)
406 405 print "En este nivel se debe crear el proyecto,id,nombre,desc"
407 406 #+++++++++++++++++++Creacion del Objeto Controller-XML+++++++++++++#
408 407
409 408 self.idp += 1
410 409 self.projectObj = Project()
411 410 print self.projectObj
412 411 self.__projObjDict[self.idp] = self.projectObj
413 412
414 413 #++++++++++++++++++Creación del Arbol++++++++++++++++++++#
415 414 self.parentItem = self.model.invisibleRootItem()
416 415 name=str(self.nameProjectTxt.text())
417 416 self.__arbolDict[self.idp] = QtGui.QStandardItem(QtCore.QString(name+" %0").arg(self.idp))
418 417 print self.__arbolDict[self.idp]
419 418 self.parentItem.appendRow(self.__arbolDict[self.idp])
420 419 self.parentItem=self.__arbolDict[self.idp]
421 420
422 421 print "Porfavor ingrese los parámetros de configuracion del Proyecto"
423 422
424 423 def existDir(self, var_dir):
425 424 """
426 425 METODO PARA VERIFICAR SI LA RUTA EXISTE-VAR_DIR
427 426 VARIABLE DIRECCION
428 427 """
429 428 if os.path.isdir(var_dir):
430 429 return True
431 430 else:
432 431 self.textEdit.append("Incorrect path:" + str(var_dir))
433 432 return False
434 433
435 434 def loadDays(self):
436 435 """
437 436 METODO PARA CARGAR LOS DIAS
438 437 """
439 438 self.variableList=[]
440 439 self.starDateCmbBox.clear()
441 440 self.endDateCmbBox.clear()
442 441
443 442 Dirlist = os.listdir(self.dataPath)
444 443 Dirlist.sort()
445 444
446 445 for a in range(0, len(Dirlist)):
447 446 fname= Dirlist[a]
448 447 Doy=fname[5:8]
449 448 fname = fname[1:5]
450 449 print fname
451 450 fecha=Doy2Date(int(fname),int(Doy))
452 451 fechaList=fecha.change2date()
453 452 #print fechaList[0]
454 453 Dirlist[a]=fname+"/"+str(fechaList[0])+"/"+str(fechaList[1])
455 454 #+"-"+ fechaList[0]+"-"+fechaList[1]
456 455
457 456 #---------------AQUI TIENE QUE SER MODIFICADO--------#
458 457
459 458 #Se cargan las listas para seleccionar StartDay y StopDay (QComboBox)
460 459 for i in range(0, (len(Dirlist))):
461 460 self.variableList.append(Dirlist[i])
462 461
463 462 for i in self.variableList:
464 463 self.starDateCmbBox.addItem(i)
465 464 self.endDateCmbBox.addItem(i)
466 465 self.endDateCmbBox.setCurrentIndex(self.starDateCmbBox.count()-1)
467 466
468 467 self.getsubList()
469 468 self.dataOkBtn.setEnabled(True)
470 469
471 470 def getsubList(self):
472 471 """
473 472 OBTIENE EL RANDO DE LAS FECHAS SELECCIONADAS
474 473 """
475 474 self.subList=[]
476 475 for i in self.variableList[self.starDateCmbBox.currentIndex():self.starDateCmbBox.currentIndex() + self.endDateCmbBox.currentIndex()+1]:
477 476 self.subList.append(i)
478 477
479 478 def addUP(self):
480 479
481 480 self.configUP=UnitProcess(self)
482 481 for i in self.__arbolDict:
483 482 if self.__arbolDict[i]==self.indexclick:
484 483 if self.__projObjDict.has_key(i)==True:
485 484 self.projectObj=self.__projObjDict[int(i)]
486 485 print self.projectObj.id
487 486 self.configUP.getfromWindowList.append(self.projectObj)
488 487
489 488
490 489 for i in self.projectObj.procUnitConfObjDict:
491 490 if self.projectObj.procUnitConfObjDict[i].getElementName()=='ProcUnit':
492 491 self.upObj=self.projectObj.procUnitConfObjDict[i]
493 492 self.configUP.getfromWindowList.append(self.upObj)
494 493
495 494
496 495
497 496 self.configUP.loadTotalList()
498 497 self.configUP.show()
499 498 #self.configUP.unitPsavebut.clicked.connect(self.reciveUPparameters)
500 499 self.configUP.closed.connect(self.createUP)
501 500
502 501
503 502
504 503 def createUP(self):
505 504
506 505 print "En este nivel se adiciona una rama de procesamiento, y se le concatena con el id"
507 506
508 507 if not self.configUP.create:
509 508 return
510 509
511 510 self.uporProObjRecover=self.configUP.getFromWindow
512 511
513 512 self.upType = self.configUP.typeofUP
514 513 for i in self.__arbolDict:
515 514 if self.__arbolDict[i]==self.indexclick:
516 515 self.projectObj=self.__projObjDict[int(i)]
517 516
518 517 datatype=str(self.upType)
519 518 uporprojectObj=self.uporProObjRecover
520 519
521 520 if uporprojectObj.getElementName()=='ProcUnit':
522 521 inputId=uporprojectObj.getId()
523 522 else:
524 523 inputId=self.readUnitConfObjList[uporprojectObj.id-1].getId()
525 524
526 525 print 'uporprojectObj.id','inputId', uporprojectObj.id,inputId
527 526 self.procUnitConfObj1 = self.projectObj.addProcUnit(datatype=datatype, inputId=inputId)
528 527 self.__upObjDict[inputId]= self.procUnitConfObj1
529 528
530 529 self.parentItem=self.__arbolDict[uporprojectObj.id]
531 530 #print "i","self.__arbolDict[i]",i ,self.__arbolDict[i]
532 531 self.numbertree=int(self.procUnitConfObj1.getId())-1
533 532 self.__arbolDict[self.procUnitConfObj1.id]=QtGui.QStandardItem(QtCore.QString(datatype +"%1 ").arg(self.numbertree))
534 533 self.parentItem.appendRow(self.__arbolDict[self.procUnitConfObj1.id])
535 534 self.parentItem=self.__arbolDict[self.procUnitConfObj1.id]
536 535 # self.loadUp()
537 536 self.treeView.expandAll()
538 537
539 538 def resetopVolt(self):
540 539 self.selecChannelopVolCEB.setChecked(False)
541 540 self.selecHeighopVolCEB.setChecked(False)
542 541 self.coherentIntegrationCEB.setChecked(False)
543 542 self.profileSelecopVolCEB.setChecked(False)
544 543 #self.selecChannelopVolCEB.setEnabled(False)
545 544 self.lineHeighProfileTxtopVol.clear()
546 545 self.lineProfileSelecopVolCEB.clear()
547 546 self.numberChannelopVol.clear()
548 547 self.numberIntegration.clear()
549 548
550 549
551 550 def resetopSpec(self):
552 551 self.nFFTPointOpSpecCEB.setChecked(False)
553 552
554 553 self.valuenFFTPointOpSpec.clear()
555 554
556 555 def resetgraphSpec(self):
557 556 self.SpectraPlotGraphCEB.setChecked(False)
558 557 self.CrossSpectraPlotGraphceb.setChecked(False)
559 558 self.RTIPlotGraphCEB.setChecked(False)
560 559
561 560
562 561 def saveProject(self):
563 562 print "entro"
564 563 #filename="C:\WorkspaceGUI\config1.xml"
565 564 for i in self.__arbolDict:
566 565 if self.__arbolDict[i]==self.indexclick:
567 566 self.projectObj=self.__projObjDict[int(i)]
568 567 print "Encontre project"
569 568 filename="C:\WorkspaceGUI\config"+str(self.projectObj.id)+".xml"
570 569 print "Escribo Project"
571 570 self.projectObj.writeXml(filename)
572 571
573 572
574 573 class UnitProcess(QMainWindow, Ui_UnitProcess):
575 574 """
576 575 Class documentation goes here.
577 576 """
578 577 closed=pyqtSignal()
579 578 create= False
580 579 def __init__(self, parent = None):
581 580 """
582 581 Constructor
583 582 """
584 583 QMainWindow.__init__(self, parent)
585 584 self.setupUi(self)
586 585 self.getFromWindow=None
587 586 self.getfromWindowList=[]
588 587
589 588 self.listUP=None
590 589
591 590 @pyqtSignature("")
592 591 def on_unitPokbut_clicked(self):
593 592 """
594 593 Slot documentation goes here.
595 594 """
596 595 self.create =True
597 596 self.getFromWindow=self.getfromWindowList[int(self.comboInputBox.currentIndex())]
598 597 #self.nameofUP= str(self.nameUptxt.text())
599 598 self.typeofUP= str(self.comboTypeBox.currentText())
600 599 self.close()
601 600
602 601
603 602 @pyqtSignature("")
604 603 def on_unitPcancelbut_clicked(self):
605 604 """
606 605 Slot documentation goes here.
607 606 """
608 607 # TODO: not implemented yet
609 608 #raise NotImplementedError
610 609 self.create=False
611 610 self.close()
612 611
613 612 def loadTotalList(self):
614 613 self.comboInputBox.clear()
615 614 for i in self.getfromWindowList:
616 615
617 616 name=i.getElementName()
618 617 if name=='Project':
619 618 id= i.id
620 619 if name=='ProcUnit':
621 620 id=int(i.id)-1
622 621 self.comboInputBox.addItem(str(name)+str(id))
623 622
624 623 def closeEvent(self, event):
625 624 self.closed.emit()
626 625 event.accept()
627 626
628 627
629 628
630 629
631 630
632 631
633 632 No newline at end of file
@@ -1,277 +1,303
1 # -*- coding: utf-8 -*-
1 2 from PyQt4 import QtCore
3 import itertools
2 4
3 5 HORIZONTAL_HEADERS = ("Property","Value " )
4 6
5 7 HORIZONTAL = ("RAMA :",)
6 8
7 9 class treeModel(QtCore.QAbstractItemModel):
8 10 '''
9 11 a model to display a few names, ordered by encabezado
12
10 13 '''
14 def __init__(self ,parent=None):
15 super(treeModel, self).__init__(parent)
16 self.people = []
17 self.initProjectProperties()
18 self.initPUVoltageProperties()
19 self.initPUSpectraProperties()
20 self.initPUSpectraHeisProperties()
21
22 def initProjectProperties(self):
23
11 24 name=None
12 25 directorio=None
13 26 workspace=None
14 27 remode=None
15 28 dataformat=None
16 date=None
17 initTime=None
29 startDate=None
30 endDate=None
31 startTime=None
18 32 endTime=None
33 delay=None
34 set= None
35 walk=None
19 36 timezone=None
20 37 Summary=None
21
22 38 description=None
23 39
24 def __init__(self ,parent=None):
25 super(treeModel, self).__init__(parent)
26 self.people = []
40 def initPUVoltageProperties(self):
41 type=None
42 channel=None
43 heights=None
44 filter=None
45 profile=None
46 code=None
47 mode=None
48 coherentintegration=None
49
50 def initPUSpectraProperties(self):
51 type =None
52 nFFTpoints =None
53 ippFactor = None
54 pairsList =None
55 channel =None
56 heights =None
57 incoherentintegration =None
58 removeDC = None
59 removeInterference =None
60 getNoise = None
61 operationSpecPlot=None
62 operationCrossSpecPlot = None
63 operationRTIPlot = None
64 operationCohermap = None
65 operationPowProfilePlot = None
66
67 def initPUSpectraHeisProperties(self):
68 type =None
69 incoherentintegration =None
70 operationSpecHeisPlot=None
71 operationRTIHeisPlot = None
72
73 def initProjectView(self):
74 """
75 Reemplazo del método showtree
76 """
77 HORIZONTAL_HEADERS = ("Property","Value " )
78 HORIZONTAL = ("RAMA :",)
79 self.rootItem = TreeItem(None, "ALL", None)
80 self.parents = {0 : self.rootItem}
81 self.setupModelData()
27 82
83 def initPUVoltageView(self):
84 HORIZONTAL_HEADERS = ("Operation"," Parameter Value " )
85 HORIZONTAL = ("RAMA :",)
86 self.rootItem = TreeItem(None, "ALL", None)
87 self.parents = {0 : self.rootItem}
88 self.setupModelData()
28 89
29 def properties_projecto(self,description):
30 self.caracteristica="Project_Properties"
31 self.principal ="Name"
32 self.description =description
33 exam_project=person_class(self.caracteristica,self.principal,self.description)
34 return exam_project
35
36
37
38 def arbol(self):
39 for caracteristica,principal, descripcion in (("Properties","Name",self.name),
40 ("Properties","Data Path",self.directorio),
41 ("Properties","Workspace",self.workspace),
42 ("Parameters", "Read Mode ",self.remode),
43 ("Parameters", "DataType ",self.dataformat),
44 ("Parameters", "Date ",self.date),
45 ("Parameters", "Init Time ",self.initTime),
46 ("Parameters", "Final Time ",self.endTime),
47 ("Parameters", " Time zone ",self.timezone),
48 ("Parameters", "Profiles ","1"),
49 ("Description", "Summary ", self.Summary),
50 ):
90 def showProjectParms(self,caracteristicaList,principalList,descripcionList):
91 """
92 set2Obje
93 """
94 for caracteristica,principal, descripcion in itertools.izip(caracteristicaList,principalList,descripcionList):
51 95 person = person_class(caracteristica, principal, descripcion)
52 96 self.people.append(person)
53 def addProjectproperties(self,person):
97 self.rootItem = TreeItem(None, "ALL", None)
98 self.parents = {0 : self.rootItem}
99 self.setupModelData()
100
101 def showPUVoltageParms(self,caracteristicaList,principalList,descripcionList):
102
103 for caracteristica,principal, descripcion in itertools.izip(caracteristicaList,principalList,descripcionList):
104 person = person_class(caracteristica, principal, descripcion)
54 105 self.people.append(person)
106 self.rootItem = TreeItem(None, "ALL", None)
107 self.parents = {0 : self.rootItem}
108 self.setupModelData()
55 109
56 110
57 #def veamos(self):
58 # self.update= MainWindow(self)
59 # self.update.dataProyectTxt.text()
60 # return self.update.dataProyectTxt.text()
111 def showPUSpectraParms(self,caracteristicaList,principalList,descripcionList):
61 112
62 def showtree(self):
113 for caracteristica,principal, descripcion in itertools.izip(caracteristicaList,principalList,descripcionList):
114 person = person_class(caracteristica, principal, descripcion)
115 self.people.append(person)
63 116 self.rootItem = TreeItem(None, "ALL", None)
64 117 self.parents = {0 : self.rootItem}
65 118 self.setupModelData()
66 119
67 def setParams(self,name,directorio,workspace,remode,dataformat,date,initTime,endTime,timezone,Summary):
68 self.name=name
69 self.workspace=workspace
70 self.directorio= directorio
71 self.remode=remode
72 self.dataformat=dataformat
73 self.date=date
74 self.initTime=initTime
75 self.endTime=endTime
76 self.timezone=timezone
77 self.Summary=Summary
78
79
80 for caracteristica,principal, descripcion in (("Properties","Name",self.name),
81 ("Properties","Data Path",self.directorio),
82 ("Properties","Workspace",self.workspace),
83 ("Parameters", "Read Mode ",self.remode),
84 ("Parameters", "DataType ",self.dataformat),
85 ("Parameters", "Date ",self.date),
86 ("Parameters", "Init Time ",self.initTime),
87 ("Parameters", "Final Time ",self.endTime),
88 ("Parameters", " Time zone ",self.timezone),
89 ("Parameters", "Profiles ","1"),
90 ("Description", "Summary ", self.Summary),
91 ):
120 def showPUSpectraHeisParms(self,caracteristicaList,principalList,descripcionList):
121
122 for caracteristica,principal, descripcion in itertools.izip(caracteristicaList,principalList,descripcionList):
92 123 person = person_class(caracteristica, principal, descripcion)
93 124 self.people.append(person)
94 125 self.rootItem = TreeItem(None, "ALL", None)
95 126 self.parents = {0 : self.rootItem}
96 127 self.setupModelData()
97 128
98 129
99 130 def columnCount(self, parent=None):
100 131 if parent and parent.isValid():
101 132 return parent.internalPointer().columnCount()
102 133 else:
103 134 return len(HORIZONTAL_HEADERS)
104 135
105 136 def data(self, index, role):
106 137 if not index.isValid():
107 138 return QtCore.QVariant()
108 139
109 140 item = index.internalPointer()
110 141 if role == QtCore.Qt.DisplayRole:
111 142 return item.data(index.column())
112 143 if role == QtCore.Qt.UserRole:
113 144 if item:
114 145 return item.person
115 146
116 147 return QtCore.QVariant()
117 148
118 149 def headerData(self, column, orientation, role):
119 150 if (orientation == QtCore.Qt.Horizontal and
120 151 role == QtCore.Qt.DisplayRole):
121 152 try:
122 153 return QtCore.QVariant(HORIZONTAL_HEADERS[column])
123 154 except IndexError:
124 155 pass
125 156
126 157 return QtCore.QVariant()
127 158
128 159 def index(self, row, column, parent):
129 160 if not self.hasIndex(row, column, parent):
130 161 return QtCore.QModelIndex()
131 162
132 163 if not parent.isValid():
133 164 parentItem = self.rootItem
134 165 else:
135 166 parentItem = parent.internalPointer()
136 167
137 168 childItem = parentItem.child(row)
138 169 if childItem:
139 170 return self.createIndex(row, column, childItem)
140 171 else:
141 172 return QtCore.QModelIndex()
142 173
143 174 def parent(self, index):
144 175 if not index.isValid():
145 176 return QtCore.QModelIndex()
146 177
147 178 childItem = index.internalPointer()
148 179 if not childItem:
149 180 return QtCore.QModelIndex()
150 181
151 182 parentItem = childItem.parent()
152 183
153 184 if parentItem == self.rootItem:
154 185 return QtCore.QModelIndex()
155 186
156 187 return self.createIndex(parentItem.row(), 0, parentItem)
157 188
158 189 def rowCount(self, parent=QtCore.QModelIndex()):
159 190 if parent.column() > 0:
160 191 return 0
161 192 if not parent.isValid():
162 193 p_Item = self.rootItem
163 194 else:
164 195 p_Item = parent.internalPointer()
165 196 return p_Item.childCount()
166 197
167 198 def setupModelData(self):
168 199 for person in self.people:
169 200 if person.descripcion:
170 201 encabezado = person.caracteristica
171 202
172 203
173 204 if not self.parents.has_key(encabezado):
174 205 newparent = TreeItem(None, encabezado, self.rootItem)
175 206 self.rootItem.appendChild(newparent)
176 207
177 208 self.parents[encabezado] = newparent
178 209
179 210 parentItem = self.parents[encabezado]
180 211 newItem = TreeItem(person, "", parentItem)
181 212 parentItem.appendChild(newItem)
182 213
183 214 def searchModel(self, person):
184 215 '''
185 216 get the modelIndex for a given appointment
186 217 '''
187 218 def searchNode(node):
188 219 '''
189 220 a function called recursively, looking at all nodes beneath node
190 221 '''
191 222 for child in node.childItems:
192 223 if person == child.person:
193 224 index = self.createIndex(child.row(), 0, child)
194 225 return index
195 226
196 227 if child.childCount() > 0:
197 228 result = searchNode(child)
198 229 if result:
199 230 return result
200 231
201 232 retarg = searchNode(self.parents[0])
202 233 #print retarg
203 234 return retarg
204 235
205 236 def find_GivenName(self, principal):
206 237 app = None
207 238 for person in self.people:
208 239 if person.principal == principal:
209 240 app = person
210 241 break
211 242 if app != None:
212 243 index = self.searchModel(app)
213 244 return (True, index)
214 245 return (False, None)
215 246
216 247
217
218
219
220
221
222 248 class person_class(object):
223 249 '''
224 250 a trivial custom data object
225 251 '''
226 252 def __init__(self, caracteristica, principal, descripcion):
227 253 self.caracteristica = caracteristica
228 254 self.principal = principal
229 255 self.descripcion = descripcion
230 256
231 257 def __repr__(self):
232 258 return "PERSON - %s %s"% (self.principal, self.caracteristica)
233 259
234 260 class TreeItem(object):
235 261 '''
236 262 a python object used to return row/column data, and keep note of
237 263 it's parents and/or children
238 264 '''
239 265 def __init__(self, person, header, parentItem):
240 266 self.person = person
241 267 self.parentItem = parentItem
242 268 self.header = header
243 269 self.childItems = []
244 270
245 271 def appendChild(self, item):
246 272 self.childItems.append(item)
247 273
248 274 def child(self, row):
249 275 return self.childItems[row]
250 276
251 277 def childCount(self):
252 278 return len(self.childItems)
253 279
254 280 def columnCount(self):
255 281 return 2
256 282
257 283 def data(self, column):
258 284 if self.person == None:
259 285 if column == 0:
260 286 return QtCore.QVariant(self.header)
261 287 if column == 1:
262 288 return QtCore.QVariant("")
263 289 else:
264 290 if column == 0:
265 291 return QtCore.QVariant(self.person.principal)
266 292 if column == 1:
267 293 return QtCore.QVariant(self.person.descripcion)
268 294 return QtCore.QVariant()
269 295
270 296 def parent(self):
271 297 return self.parentItem
272 298
273 299 def row(self):
274 300 if self.parentItem:
275 301 return self.parentItem.childItems.index(self)
276 302 return 0
277 303 No newline at end of file
@@ -1,41 +1,38
1 1 import os, sys
2 2 import getopt
3 path = os.path.split(os.getcwd())[0]
4 #path="C://Users//alex//workspace//gui_14_03_13"
5 sys.path.append(path)
6 3
7 from controller import *
4 from schainpy.controller import Project
8 5
9 6 class scProcessController():
10 7 def __init__(self):
11 8 print "ESTOY EJECUTANDO EL NUEVO PROCESO PERO APARENTEMENTE NO QUIERE"
12 9 self.setfilename()
13 10 self.operation()
14 11
15 12 def setfilename(self):
16 13 arglist= ''
17 14 longarglist=['filename=']
18 15 optlist,args=getopt.getopt(sys.argv[1:],arglist,longarglist)
19 16 for opt in optlist:
20 17 if opt[0]== '--filename':
21 18 self.filename = opt[1]
22 19
23 20 def operation(self):
24 21 print 'inicia operation'
25 22 controllerObj = Project()
26 23 print "Leyendo el archivo XML"
27 24 #self.filename="C://Users//alex//schain_workspace//Alexander1.xml"
28 25 controllerObj.readXml(self.filename)
29 26 #controllerObj.printattr()
30 27
31 28 controllerObj.createObjects()
32 29 controllerObj.connectObjects()
33 30 controllerObj.run()
34 31
35 32
36 33 def main():
37 34 a=scProcessController()
38 35
39 36
40 37 if __name__ == "__main__":
41 38 main() No newline at end of file
@@ -1,58 +1,58
1 1 # -*- coding: utf-8 -*-
2 2
3 3 """
4 4 Module implementing MainWindow.
5 5 """
6 6
7 7 from PyQt4.QtGui import QMainWindow
8 8 from PyQt4.QtCore import pyqtSignature
9 9
10 from viewer.ui_unitprocess import Ui_UnitProcess
10 from schainpy.gui.viewer.ui_unitprocess import Ui_UnitProcess
11 11
12 12 class UnitProcess(QMainWindow, Ui_UnitProcess):
13 13 """
14 14 Class documentation goes here.
15 15 """
16 16
17 17 def __init__(self, parent = None):
18 18 """
19 19 Constructor
20 20 """
21 21 QMainWindow.__init__(self, parent)
22 22 self.setupUi(self)
23 23
24 24
25 25 @pyqtSignature("QString")
26 26 def on_comboInputBox_activated(self, p0):
27 27 """
28 28 Slot documentation goes here.
29 29 """
30 30 # TODO: not implemented yet
31 31 raise NotImplementedError
32 32
33 33 @pyqtSignature("QString")
34 34 def on_comboTypeBox_activated(self, p0):
35 35 """
36 36 Slot documentation goes here.
37 37 """
38 38 # TODO: not implemented yet
39 39 raise NotImplementedError
40 40
41 41
42 42 @pyqtSignature("")
43 43 def on_unitPokbut_clicked(self):
44 44 """
45 45 Slot documentation goes here.
46 46 """
47 47 # TODO: not implemented yet
48 48 #raise NotImplementedError
49 49 print "this is suspiscious"
50 50 print "njdasjdajj"
51 51
52 52 @pyqtSignature("")
53 53 def on_unitPcancelbut_clicked(self):
54 54 """
55 55 Slot documentation goes here.
56 56 """
57 57 # TODO: not implemented yet
58 58 raise NotImplementedError
@@ -1,807 +1,807
1 1 # -*- coding: utf-8 -*-
2 2 """
3 3 Module implementing MainWindow.
4 4 #+++++++++++++++++++++INTERFAZ DE USUARIO V1.1++++++++++++++++++++++++#
5 5 """
6 6 from PyQt4.QtGui import QMainWindow
7 7 from PyQt4.QtCore import pyqtSignature
8 8 from PyQt4.QtCore import pyqtSignal
9 9 from PyQt4 import QtCore
10 10 from PyQt4 import QtGui
11 11 from timeconversions import Doy2Date
12 12 from modelProperties import treeModel
13 from viewer.ui_unitprocess import Ui_UnitProcess
14 from viewer.ui_window import Ui_window
15 from viewer.ui_mainwindow import Ui_MainWindow
16 from viewer.ui_workspace import Ui_Workspace
17 from viewer.ui_initwindow import Ui_InitWindow
13 from schainpy.gui.viewer.ui_unitprocess import Ui_UnitProcess
14 from schainpy.gui.viewer.ui_window import Ui_window
15 from schainpy.gui.viewer.ui_mainwindow import Ui_MainWindow
16 from schainpy.gui.viewer.ui_workspace import Ui_Workspace
17 from schainpy.gui.viewer.ui_initwindow import Ui_InitWindow
18 18
19 from controller import Project,ReadUnitConf,ProcUnitConf,OperationConf,ParameterConf
19 from schainpy.controller import Project,ReadUnitConf,ProcUnitConf,OperationConf,ParameterConf
20 20 import os
21 21
22 22 HORIZONTAL_HEADERS = ("ITEM :"," DATOS : " )
23 23
24 24 HORIZONTAL = ("RAMA :",)
25 25
26 26 class MainWindow(QMainWindow, Ui_MainWindow):
27 27
28 28 nop=None
29 29
30 30 __projObjDict = {}
31 31 __arbolDict = {}
32 32
33 33 """
34 34 Class documentation goes here.
35 35 #*##################VENTANA CUERPO DEL PROGRAMA####################
36 36 """
37 37 def __init__(self, parent = None):
38 38 """
39 39 Constructor
40 40 """
41 41 print "Inicio de Programa Interfaz Gráfica"
42 42 QMainWindow.__init__(self, parent)
43 43 self.setupUi(self)
44 44
45 45 self.online=0
46 46 self.datatype=0
47 47 self.variableList=[]
48 48
49 49 self.proObjList=[]
50 50 self.idp=0
51 51 self.projectName=0
52 52 self.description=0
53 53 self.namepTree=0
54 54 self.valuep=0
55 55
56 56 self.upObjList= []
57 57 self.upn=0
58 58 self.upName=0
59 59 self.upType=0
60 60 self.uporProObjRecover=0
61 61
62 62
63 63 self.readUnitConfObjList=[]
64 64
65 65 self.upObjVolList=[]
66 66 self.upobjSpecList=[]
67 67
68 68
69 69 self.operObjList=[]
70 70
71 71 self.projectWindow=None
72 72 self.configUP=None
73 73
74 74 self.projectObj=None
75 75 self.readUnitConfObj=None
76 76 self.procUnitConfObj0=None
77 77 self.opObj10=None
78 78 self.opObj12=None
79 79
80 80
81 81 self.setParam()
82 82
83 83 #++++++++++++++++++NEW PROPERTIES+++++++++++++++++#
84 84 QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10))
85 85 self.addpBtn.setToolTip('Add_New_Project')
86 86 self.addUnitProces.setToolTip('Add_New_Processing_Unit')
87 87
88 88 #++++++++++++++++++NEW PROPERTIES+++++++++++++++++#
89 89 self.model = QtGui.QStandardItemModel()
90 90 self.treeView.setModel(self.model)
91 91 self.treeView.clicked.connect(self.clickFunctiontree)
92 92 self.treeView.expandAll()
93 93 #self.treeView.clicked.connect(self.treefunction1)
94 94
95 95 def getNumberofProject(self):
96 96 # for i in self.proObjList:
97 97 # print i
98 98 return self.proObjList
99 99 # for i in self.proObjList:
100 100 # print i
101 101
102 102 def setParam(self):
103 103 self.dataPathTxt.setText('C:\data')
104 104 self.numberChannelopVol.setEnabled(False)
105 105 self.lineHeighProfileTxtopVol.setEnabled(False)
106 106 self.numberIntegration.setEnabled(False)
107 107 self.valuenFFTPointOpSpec.setEnabled(False)
108 108 self.lineProfileSelecopVolCEB.setEnabled(False)
109 109
110 110
111 111 def clickFunctiontree(self,index):
112 112 indexclick= index.model().itemFromIndex(index).text()
113 113 #print indexclick
114 114 NumofPro=indexclick[8:10]
115 115 self.valuep=NumofPro
116 116 #print self.valuep
117 117 NameofPro=indexclick[0:7]
118 118 self.namepTree=NameofPro
119 119 #print self.namepTree
120 120
121 121
122 122 @pyqtSignature("")
123 123 def on_addprojectBtn_clicked(self):
124 124 """
125 125 Llama al metodo addProject.
126 126 """
127 127 print "En este nivel se abre el window"
128 128
129 129
130 130 self.addProject()
131 131
132 132 def addProject(self):
133 133 """
134 134 Muestra una
135 135 """
136 136
137 137 self.projectWindow = ProjectWindow(self)
138 138 self.projectWindow.show()
139 139
140 140 #Al cerrar la venta de proyecto se ejecutara el metodo createProject
141 141 self.projectWindow.closed.connect(self.createProject)
142 142
143 143 def createProject(self):
144 144 """
145 145 Crea un nuevo proyecto del tipo Controller.Project() y lo adiciona al diccionario
146 146 self.__projectDict.
147 147 """
148 148
149 149 if not self.projectWindow.create:
150 150 return
151 151
152 152 self.projectName = self.projectWindow.name
153 153 self.description = self.projectWindow.description
154 154
155 155 print "En este nivel se debe crear el proyecto,id,nombre,desc"
156 156 #+++++Creacion del Objeto Controller-XML++++++++++#
157 157 self.idp += 1
158 158 self.projectObj = Project()
159 159
160 160 id=int(self.idp)
161 161 name=str(self.projectName)
162 162 desc=str(self.description)
163 163
164 164 self.projectObj.setup(id = id, name=name, description=desc)
165 165 self.__projObjDict[id] = self.projectObj
166 166 self.proObjList.append(self.projectObj)
167 167
168 168 self.parentItem = self.model.invisibleRootItem()
169 169 self.__arbolDict[id] = QtGui.QStandardItem(QtCore.QString("Project %0").arg(self.idp))
170 170
171 171 self.parentItem.appendRow(self.__arbolDict[projectObj.id])
172 172
173 173 #+++++++++++++++++++LISTA DE PROYECTO++++++++++++++++++++++++++++#
174 174
175 175
176 176 # self.parentItem=self.projectObj.arbol
177 177 # self.loadProjects()
178 178
179 179 print "Porfavor ingrese los parámetros de configuracion del Proyecto"
180 180
181 181 def loadProjects(self):
182 182 self.proConfCmbBox.clear()
183 183 for i in self.__projObjDict.values():
184 184 self.proConfCmbBox.addItem("Project"+str(i.id))
185 185
186 186 @pyqtSignature("int")
187 187 def on_dataTypeCmbBox_activated(self,index):
188 188 self.dataFormatTxt.setReadOnly(True)
189 189 if index==0:
190 190 self.datatype='Voltage'
191 191 elif index==1:
192 192 self.datatype='Spectra'
193 193 else :
194 194 self.datatype=''
195 195 self.dataFormatTxt.setReadOnly(False)
196 196 self.dataFormatTxt.setText(self.datatype)
197 197
198 198 def existDir(self, var_dir):
199 199 """
200 200 METODO PARA VERIFICAR SI LA RUTA EXISTE-VAR_DIR
201 201 VARIABLE DIRECCION
202 202 """
203 203 if os.path.isdir(var_dir):
204 204 return True
205 205 else:
206 206 self.textEdit.append("Incorrect path:" + str(var_dir))
207 207 return False
208 208
209 209 def loadDays(self):
210 210 """
211 211 METODO PARA CARGAR LOS DIAS
212 212 """
213 213 self.variableList=[]
214 214 self.starDateCmbBox.clear()
215 215 self.endDateCmbBox.clear()
216 216
217 217 Dirlist = os.listdir(self.dataPath)
218 218 Dirlist.sort()
219 219
220 220 for a in range(0, len(Dirlist)):
221 221 fname= Dirlist[a]
222 222 Doy=fname[5:8]
223 223 fname = fname[1:5]
224 224 print fname
225 225 fecha=Doy2Date(int(fname),int(Doy))
226 226 fechaList=fecha.change2date()
227 227 #print fechaList[0]
228 228 Dirlist[a]=fname+"/"+str(fechaList[0])+"/"+str(fechaList[1])
229 229 #+"-"+ fechaList[0]+"-"+fechaList[1]
230 230
231 231 #---------------AQUI TIENE QUE SER MODIFICADO--------#
232 232
233 233 #Se cargan las listas para seleccionar StartDay y StopDay (QComboBox)
234 234 for i in range(0, (len(Dirlist))):
235 235 self.variableList.append(Dirlist[i])
236 236
237 237 for i in self.variableList:
238 238 self.starDateCmbBox.addItem(i)
239 239 self.endDateCmbBox.addItem(i)
240 240 self.endDateCmbBox.setCurrentIndex(self.starDateCmbBox.count()-1)
241 241
242 242 self.getsubList()
243 243 self.dataOkBtn.setEnabled(True)
244 244
245 245 def getsubList(self):
246 246 """
247 247 OBTIENE EL RANDO DE LAS FECHAS SELECCIONADAS
248 248 """
249 249 self.subList=[]
250 250 for i in self.variableList[self.starDateCmbBox.currentIndex():self.starDateCmbBox.currentIndex() + self.endDateCmbBox.currentIndex()+1]:
251 251 self.subList.append(i)
252 252
253 253 @pyqtSignature("")
254 254 def on_dataPathBrowse_clicked(self):
255 255 """
256 256 OBTENCION DE LA RUTA DE DATOS
257 257 """
258 258 self.dataPath = str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly))
259 259 self.dataPathTxt.setText(self.dataPath)
260 260 self.statusDpath=self.existDir(self.dataPath)
261 261 self.loadDays()
262 262
263 263 @pyqtSignature("int")
264 264 def on_starDateCmbBox_activated(self, index):
265 265 """
266 266 SELECCION DEL RANGO DE FECHAS -STAR DATE
267 267 """
268 268 var_StopDay_index=self.endDateCmbBox.count() - self.endDateCmbBox.currentIndex()
269 269 self.endDateCmbBox.clear()
270 270 for i in self.variableList[index:]:
271 271 self.endDateCmbBox.addItem(i)
272 272 self.endDateCmbBox.setCurrentIndex(self.endDateCmbBox.count() - var_StopDay_index)
273 273 self.getsubList()
274 274
275 275 @pyqtSignature("int")
276 276 def on_endDateCmbBox_activated(self, index):
277 277 """
278 278 SELECCION DEL RANGO DE FECHAS-END DATE
279 279 """
280 280 var_StartDay_index=self.starDateCmbBox.currentIndex()
281 281 var_end_index = self.endDateCmbBox.count() - index
282 282 self.starDateCmbBox.clear()
283 283 for i in self.variableList[:len(self.variableList) - var_end_index + 1]:
284 284 self.starDateCmbBox.addItem(i)
285 285 self.starDateCmbBox.setCurrentIndex(var_StartDay_index)
286 286 self.getsubList() #Se carga var_sublist[] con el rango de las fechas seleccionadas
287 287
288 288 @pyqtSignature("int")
289 289 def on_readModeCmBox_activated(self, p0):
290 290 """
291 291 Slot documentation goes here.
292 292 """
293 293 if p0==0:
294 294 self.online=0
295 295 elif p0==1:
296 296 self.online=1
297 297
298 298 @pyqtSignature("")
299 299 def on_dataOkBtn_clicked(self):
300 300 """
301 301 Slot documentation goes here.
302 302 """
303 303 print "En este nivel se pasa el tipo de dato con el que se trabaja,path,startDate,endDate,startTime,endTime,online"
304 304
305 305 projectObj=self.proObjList[int(self.proConfCmbBox.currentIndex())]
306 306 datatype=str(self.dataTypeCmbBox.currentText())
307 307 path=str(self.dataPathTxt.text())
308 308 online=int(self.online)
309 309 starDate=str(self.starDateCmbBox.currentText())
310 310 endDate=str(self.endDateCmbBox.currentText())
311 311
312 312
313 313 self.readUnitConfObj = projectObj.addReadUnit(datatype=datatype,
314 314 path=path,
315 315 startDate=starDate,
316 316 endDate=endDate,
317 317 startTime='06:10:00',
318 318 endTime='23:59:59',
319 319 online=online)
320 320
321 321 self.readUnitConfObjList.append(self.readUnitConfObj)
322 322
323 323 print "self.readUnitConfObj.getId",self.readUnitConfObj.getId(),datatype,path,starDate,endDate,online
324 324
325 325
326 326 self.model_2=treeModel()
327 327
328 328 self.model_2.setParams(name=projectObj.name+str(projectObj.id),
329 329 directorio=path,
330 330 workspace="C:\\WorkspaceGUI",
331 331 remode=str(self.readModeCmBox.currentText()),
332 332 dataformat=datatype,
333 333 date=str(starDate)+"-"+str(endDate),
334 334 initTime='06:10:00',
335 335 endTime='23:59:59',
336 336 timezone="Local" ,
337 337 Summary="test de prueba")
338 338 self.model_2.arbol()
339 339 self.treeView_2.setModel(self.model_2)
340 340 self.treeView_2.expandAll()
341 341
342 342
343 343 @pyqtSignature("")
344 344 def on_addUnitProces_clicked(self):
345 345 """
346 346 Slot documentation goes here.
347 347 """
348 348 # print "En este nivel se adiciona una rama de procesamiento, y se le concatena con el id"
349 349 # self.procUnitConfObj0 = self.projectObj.addProcUnit(datatype='Voltage', inputId=self.readUnitConfObj.getId())
350 350 self.showUp()
351 351
352 352 def showUp(self):
353 353
354 354 self.configUP=UnitProcess(self)
355 355 for i in self.proObjList:
356 356 self.configUP.getfromWindowList.append(i)
357 357 #print i
358 358 for i in self.upObjList:
359 359 self.configUP.getfromWindowList.append(i)
360 360 self.configUP.loadTotalList()
361 361 self.configUP.show()
362 362 self.configUP.unitPsavebut.clicked.connect(self.reciveUPparameters)
363 363 self.configUP.closed.connect(self.createUP)
364 364
365 365 def reciveUPparameters(self):
366 366
367 367 self.uporProObjRecover,self.upType=self.configUP.almacena()
368 368
369 369
370 370 def createUP(self):
371 371 print "En este nivel se adiciona una rama de procesamiento, y se le concatena con el id"
372 372 projectObj=self.proObjList[int(self.proConfCmbBox.currentIndex())]
373 373
374 374 datatype=str(self.upType)
375 375 uporprojectObj=self.uporProObjRecover
376 376 #+++++++++++LET FLY+++++++++++#
377 377 if uporprojectObj.getElementName()=='ProcUnit':
378 378 inputId=uporprojectObj.getId()
379 379 elif uporprojectObj.getElementName()=='Project':
380 380 inputId=self.readUnitConfObjList[uporprojectObj.id-1].getId()
381 381
382 382
383 383 self.procUnitConfObj1 = projectObj.addProcUnit(datatype=datatype, inputId=inputId)
384 384 self.upObjList.append(self.procUnitConfObj1)
385 385 print inputId
386 386 print self.procUnitConfObj1.getId()
387 387 self.parentItem=uporprojectObj.arbol
388 388 self.numbertree=int(self.procUnitConfObj1.getId())-1
389 389 self.procUnitConfObj1.arbol=QtGui.QStandardItem(QtCore.QString(datatype +"%1 ").arg(self.numbertree))
390 390 self.parentItem.appendRow(self.procUnitConfObj1.arbol)
391 391 self.parentItem=self.procUnitConfObj1.arbol
392 392 self.loadUp()
393 393 self.treeView.expandAll()
394 394
395 395 def loadUp(self):
396 396 self.addOpUpselec.clear()
397 397 self.addOpSpecUpselec.clear()
398 398 for i in self.upObjList:
399 399 if i.datatype=='Voltage':
400 400 self.upObjVolList.append(i)
401 401 name=i.getElementName()
402 402 id=int(i.id)-1
403 403 self.addOpUpselec.addItem(name+str(id))
404 404 if i.datatype=='Spectra':
405 405 self.upobjSpecList.append(i)
406 406 name=i.getElementName()
407 407 id=int(i.id)-1
408 408 self.addOpSpecUpselec.addItem(name+str(id))
409 409
410 410 self.resetopVolt()
411 411 self.resetopSpec()
412 412
413 413
414 414 @pyqtSignature("int")
415 415 def on_selecChannelopVolCEB_stateChanged(self, p0):
416 416 """
417 417 Slot documentation goes here.
418 418 """
419 419 if p0==2:
420 420 self.numberChannelopVol.setEnabled(True)
421 421 upProcessSelect=self.upObjVolList[int(self.addOpUpselec.currentIndex())]
422 422 opObj10=upProcessSelect.addOperation(name='selectChannels')
423 423 print opObj10.id
424 424 self.operObjList.append(opObj10)
425 425 print " Ingresa seleccion de Canales"
426 426 if p0==0:
427 427 print " deshabilitado"
428 428
429 429 @pyqtSignature("int")
430 430 def on_selecHeighopVolCEB_stateChanged(self, p0):
431 431 """
432 432 Slot documentation goes here.
433 433 """
434 434 if p0==2:
435 435 self.lineHeighProfileTxtopVol.setEnabled(True)
436 436 upProcessSelect=self.upObjVolList[int(self.addOpUpselec.currentIndex())]
437 437 opObj10=upProcessSelect.addOperation(name='selectHeights')
438 438 print opObj10.id
439 439 self.operObjList.append(opObj10)
440 440 print " Select Type of Profile"
441 441 if p0==0:
442 442 print " deshabilitado"
443 443
444 444
445 445 @pyqtSignature("int")
446 446 def on_profileSelecopVolCEB_stateChanged(self, p0):
447 447 """
448 448 Slot documentation goes here.
449 449 """
450 450 if p0==2:
451 451 self.lineProfileSelecopVolCEB.setEnabled(True)
452 452 upProcessSelect=self.upObjVolList[int(self.addOpUpselec.currentIndex())]
453 453 opObj10=upProcessSelect.addOperation(name='ProfileSelector', optype='other')
454 454 print opObj10.id
455 455 self.operObjList.append(opObj10)
456 456 print " Select Type of Profile"
457 457 if p0==0:
458 458 print " deshabilitado"
459 459
460 460
461 461 @pyqtSignature("int")
462 462 def on_coherentIntegrationCEB_stateChanged(self, p0):
463 463 """
464 464 Slot documentation goes here.
465 465 """
466 466 if p0==2:
467 467 self.numberIntegration.setEnabled(True)
468 468 upProcessSelect=self.upObjVolList[int(self.addOpUpselec.currentIndex())]
469 469 opObj10=upProcessSelect.addOperation(name='CohInt', optype='other')
470 470 print opObj10.id
471 471 self.operObjList.append(opObj10)
472 472 print "Choose number of Cohint"
473 473 if p0==0:
474 474 print " deshabilitado"
475 475 self.numberChannelopVol.setEnabled(False)
476 476
477 477 def resetopVolt(self):
478 478 self.selecChannelopVolCEB.setChecked(False)
479 479 self.selecHeighopVolCEB.setChecked(False)
480 480 self.coherentIntegrationCEB.setChecked(False)
481 481 self.profileSelecopVolCEB.setChecked(False)
482 482 #self.selecChannelopVolCEB.setEnabled(False)
483 483 self.lineHeighProfileTxtopVol.clear()
484 484 self.lineProfileSelecopVolCEB.clear()
485 485 self.numberChannelopVol.clear()
486 486 self.numberIntegration.clear()
487 487
488 488
489 489 @pyqtSignature("")
490 490 def on_dataopVolOkBtn_clicked(self):
491 491 """
492 492 Slot documentation goes here.
493 493 """
494 494 if self.selecChannelopVolCEB.isChecked():
495 495 for i in self.operObjList:
496 496 if i.name=='selectChannels':
497 497 value=self.numberChannelopVol.text()
498 498 i.addParameter(name='channelList', value=value, format='intlist')
499 499
500 500
501 501 print "channel"
502 502
503 503 if self.selecHeighopVolCEB.isChecked():
504 504 for i in self.operObjList:
505 505 if i.name=='selectHeights' :
506 506 value=self.lineHeighProfileTxtopVol.text()
507 507 valueList=value.split(',')
508 508 i.addParameter(name='minHei', value=valueList[0], format='float')
509 509 i.addParameter(name='maxHei', value=valueList[1], format='float')
510 510
511 511 print "height"
512 512
513 513
514 514 if self.selecHeighopVolCEB.isChecked():
515 515 for i in self.operObjList:
516 516 if i.name=='ProfileSelector' :
517 517 value=self.lineProfileSelecopVolCEB.text()
518 518 i.addParameter(name='ProfileSelector', value=value, format='intlist')
519 519
520 520
521 521
522 522 if self.coherentIntegrationCEB.isChecked():
523 523 for i in self.operObjList:
524 524 if i.name=='CohInt':
525 525 value=self.numberIntegration.text()
526 526 i.addParameter(name='n', value=value, format='int')
527 527
528 528
529 529 @pyqtSignature("int")
530 530 def on_nFFTPointOpSpecCEB_stateChanged(self, p0):
531 531 """
532 532 Slot documentation goes here.
533 533 """
534 534 if p0==2:
535 535 self.valuenFFTPointOpSpec.setEnabled(True)
536 536 print " nFFTPoint"
537 537 if p0==0:
538 538 print " deshabilitado"
539 539
540 540
541 541 def resetopSpec(self):
542 542 self.nFFTPointOpSpecCEB.setChecked(False)
543 543
544 544 self.valuenFFTPointOpSpec.clear()
545 545
546 546
547 547 @pyqtSignature("")
548 548 def on_dataopSpecOkBtn_clicked(self):
549 549 """
550 550 Slot documentation goes here.
551 551 """
552 552 print "Añadimos operaciones Spectra,nchannels,value,format"
553 553 if self.nFFTPointOpSpecCEB.isChecked():
554 554 upProcessSelect=self.upobjSpecList[int(self.addOpSpecUpselec.currentIndex())]
555 555 value=self.valuenFFTPointOpSpec.text()
556 556 upProcessSelect.addParameter(name='nFFTPoints',value=value,format='int')
557 557
558 558 @pyqtSignature("int")
559 559 def on_SpectraPlotGraphCEB_stateChanged(self, p0):
560 560 """
561 561 Slot documentation goes here.
562 562 """
563 563 if p0==2:
564 564 upProcessSelect=self.upobjSpecList[int(self.addOpSpecUpselec.currentIndex())]
565 565 opObj10=upProcessSelect.addOperation(name='SpectraPlot',optype='other')
566 566 print opObj10.id
567 567 self.operObjList.append(opObj10)
568 568
569 569 if p0==0:
570 570 print " deshabilitado"
571 571
572 572 @pyqtSignature("int")
573 573 def on_CrossSpectraPlotGraphceb_stateChanged(self, p0):
574 574 """
575 575 Slot documentation goes here.
576 576 """
577 577 if p0==2:
578 578 upProcessSelect=self.upobjSpecList[int(self.addOpSpecUpselec.currentIndex())]
579 579 opObj10=upProcessSelect.addOperation(name='CrossSpectraPlot',optype='other')
580 580 print opObj10.id
581 581 self.operObjList.append(opObj10)
582 582 if p0==0:
583 583 print " deshabilitado"
584 584
585 585 @pyqtSignature("int")
586 586 def on_RTIPlotGraphCEB_stateChanged(self, p0):
587 587 """
588 588 Slot documentation goes here.
589 589 """
590 590 if p0==2:
591 591 upProcessSelect=self.upobjSpecList[int(self.addOpSpecUpselec.currentIndex())]
592 592 opObj10=upProcessSelect.addOperation(name='RTIPlot',optype='other')
593 593 print opObj10.id
594 594 self.operObjList.append(opObj10)
595 595 if p0==0:
596 596 print " deshabilitado"
597 597
598 598
599 599 def resetgraphSpec(self):
600 600 self.SpectraPlotGraphCEB.setChecked(False)
601 601 self.CrossSpectraPlotGraphceb.setChecked(False)
602 602 self.RTIPlotGraphCEB.setChecked(False)
603 603
604 604 @pyqtSignature("")
605 605 def on_dataGraphSpecOkBtn_clicked(self):
606 606 """
607 607 Slot documentation goes here.
608 608 """
609 609 print "Graficar Spec op"
610 610 if self.SpectraPlotGraphCEB.isChecked():
611 611 for i in self.operObjList:
612 612 if i.name=='SpectraPlot':
613 613 i.addParameter(name='idfigure', value='1', format='int')
614 614 i.addParameter(name='wintitle', value='SpectraPlot0', format='str')
615 615 i.addParameter(name='zmin', value='40', format='int')
616 616 i.addParameter(name='zmax', value='90', format='int')
617 617 i.addParameter(name='showprofile', value='1', format='int')
618 618
619 619 if self.CrossSpectraPlotGraphceb.isChecked():
620 620 for i in self.operObjList:
621 621 if i.name=='CrossSpectraPlot' :
622 622 i.addParameter(name='idfigure', value='2', format='int')
623 623 i.addParameter(name='wintitle', value='CrossSpectraPlot', format='str')
624 624 i.addParameter(name='zmin', value='40', format='int')
625 625 i.addParameter(name='zmax', value='90', format='int')
626 626
627 627 if self.RTIPlotGraphCEB.isChecked():
628 628 for i in self.operObjList:
629 629 if i.name=='RTIPlot':
630 630 i.addParameter(name='n', value='2', format='int')
631 631 i.addParameter(name='overlapping', value='1', format='int')
632 632
633 633 @pyqtSignature("")
634 634 def on_actionguardarObj_triggered(self):
635 635 """
636 636 GUARDAR EL ARCHIVO DE CONFIGURACION XML
637 637 """
638 638 if self.idp==1:
639 639 self.valuep=1
640 640
641 641 print "Escribiendo el archivo XML"
642 642 filename="C:\\WorkspaceGUI\\CONFIG"+str(self.valuep)+".xml"
643 643 self.projectObj=self.proObjList[int(self.valuep)-1]
644 644 self.projectObj.writeXml(filename)
645 645
646 646
647 647 class BasicWindow(MainWindow):
648 648
649 649 def __init__(self):
650 650 pass
651 651
652 652 class AdvancedWindow(MainWindow):
653 653
654 654 def __init__(self):
655 655 pass
656 656
657 657
658 658
659 659 class ProjectWindow(QMainWindow, Ui_window):
660 660 """
661 661 Class documentation goes here.
662 662 """
663 663 closed = pyqtSignal()
664 664
665 665 create = False
666 666 name = None
667 667 description = None
668 668
669 669
670 670
671 671 def __init__(self, parent = None):
672 672 """
673 673 Constructor
674 674 """
675 675 QMainWindow.__init__(self, parent)
676 676 self.setupUi(self)
677 677 self.name=None
678 678
679 679 self.proyectNameLine.setText('My_name_is...')
680 680 self.descriptionTextEdit.setText('Write a description...')
681 681
682 682
683 683 @pyqtSignature("")
684 684 def on_cancelButton_clicked(self):
685 685 """
686 686 Slot documentation goes here.
687 687 """
688 688 # TODO: not implemented yet
689 689 #raise NotImplementedError
690 690 self.create = False
691 691 self.close()
692 692
693 693 @pyqtSignature("")
694 694 def on_okButton_clicked(self):
695 695 """
696 696 Slot documentation goes here.
697 697 """
698 698 #self.almacena()
699 699 self.create = True
700 700 self.name = str(self.proyectNameLine.text())
701 701 self.description = str(self.descriptionTextEdit.toPlainText())
702 702
703 703 self.close()
704 704
705 705 # @pyqtSignature("")
706 706 # def on_saveButton_clicked(self):
707 707 # """
708 708 # Slot documentation goes here.
709 709 # """
710 710 # self.almacena()
711 711 ## self.close()
712 712 #
713 713 # def almacena(self):
714 714 # #print str(self.proyectNameLine.text())
715 715 # self.nameproject=str(self.proyectNameLine.text())
716 716 # self.description=str(self.descriptionTextEdit.toPlainText())
717 717 # return self.nameproject,self.description
718 718 #
719 719 def closeEvent(self, event):
720 720 self.closed.emit()
721 721 event.accept()
722 722
723 723
724 724 class UnitProcess(QMainWindow, Ui_UnitProcess):
725 725 """
726 726 Class documentation goes here.
727 727 """
728 728 closed=pyqtSignal()
729 729 def __init__(self, parent = None):
730 730 """
731 731 Constructor
732 732 """
733 733 QMainWindow.__init__(self, parent)
734 734 self.setupUi(self)
735 735 self.getFromWindow=None
736 736 self.getfromWindowList=[]
737 737
738 738 self.listUP=None
739 739
740 740 def loadTotalList(self):
741 741 self.comboInputBox.clear()
742 742 for i in self.getfromWindowList:
743 743 name=i.getElementName()
744 744 id= i.id
745 745 if i.getElementName()=='ProcUnit':
746 746 id=int(i.id)-1
747 747 self.comboInputBox.addItem(str(name)+str(id))
748 748
749 749 @pyqtSignature("QString")
750 750 def on_comboInputBox_activated(self, p0):
751 751 """
752 752 Slot documentation goes here.
753 753 """
754 754
755 755 # TODO: not implemented yet
756 756 #raise NotImplementedError
757 757
758 758 @pyqtSignature("QString")
759 759 def on_comboTypeBox_activated(self, p0):
760 760 """
761 761 Slot documentation goes here.
762 762 """
763 763 # TODO: not implemented yet
764 764 #raise NotImplementedError
765 765
766 766 @pyqtSignature("")
767 767 def on_unitPokbut_clicked(self):
768 768 """
769 769 Slot documentation goes here.
770 770 """
771 771 self.close()
772 772
773 773 @pyqtSignature("")
774 774 def on_unitPsavebut_clicked(self):
775 775 """
776 776 Slot documentation goes here.
777 777 """
778 778
779 779 print "alex"
780 780 self.almacena()
781 781
782 782 @pyqtSignature("")
783 783 def on_unitPcancelbut_clicked(self):
784 784 """
785 785 Slot documentation goes here.
786 786 """
787 787 # TODO: not implemented yet
788 788 #raise NotImplementedError
789 789 self.hide()
790 790
791 791 def almacena(self):
792 792 self.getFromWindow=self.getfromWindowList[int(self.comboInputBox.currentIndex())]
793 793 #self.nameofUP= str(self.nameUptxt.text())
794 794 self.typeofUP= str(self.comboTypeBox.currentText())
795 795 return self.getFromWindow,self.typeofUP
796 796
797 797 def closeEvent(self, event):
798 798 self.closed.emit()
799 799 event.accept()
800 800
801 801
802 802
803 803
804 804
805 805
806 806
807 807 No newline at end of file
@@ -1,65 +1,67
1 1 # -*- coding: utf-8 -*-
2 2 import os
3 from os.path import expanduser
4
3 5 from PyQt4.QtGui import QDialog
4 6 from PyQt4.QtCore import pyqtSignature
5 7 from PyQt4.QtCore import pyqtSignal
6 8 from PyQt4 import QtGui, QtCore
7 from viewer.ui_workspace import Ui_Workspace
8 from os.path import expanduser
9
10 from schainpy.gui.viewer.ui_workspace import Ui_Workspace
9 11
10 12 class Workspace(QDialog, Ui_Workspace):
11 13 """
12 14 Class documentation goes here.
13 15 """
14 16
15 17 def __init__(self, parent = None):
16 18 """
17 19 Constructor
18 20 """
19 21 QDialog.__init__(self, parent)
20 22 self.dirList=[]
21 23 self.setupUi(self)
22 24 self.setWindowTitle("ROJ-Signal Chain")
23 self.setWindowIcon(QtGui.QIcon("figure/adn.jpg"))
25 self.setWindowIcon(QtGui.QIcon("schainpy/gui/figure/adn.jpg"))
24 26 #*####### DIRECTORIO DE TRABAJO #########*#
25 27 #self.dirCmbBox.setItemText(0, QtGui.QApplication.translate("MainWindow", "C:\WorkSpaceGui", None, QtGui.QApplication.UnicodeUTF8))
26 28 home=expanduser("~")
27 29 self.dir=os.path.join(home,'schain_workspace')
28 30 if not os.path.exists(self.dir):
29 31 os.makedirs(self.dir)
30 32 self.dirComBox.addItem(self.dir)
31 33 self.i=0
32 34
33 35
34 36 @pyqtSignature("")
35 37 def on_dirToolPath_clicked(self):
36 38 """
37 39 Slot documentation goes here.
38 40 """
39 41 self.i +=1
40 42 self.dirBrowse = str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly))
41 43 self.dirComBox.addItem(self.dirBrowse)
42 44 self.dirComBox.setCurrentIndex(self.i)
43 45
44 46
45 47
46 48 @pyqtSignature("")
47 49 def on_dirOkBtn_clicked(self):
48 50 """
49 51 VISTA DE INTERFAZ GRÁFICA
50 52 """
51 53 self.accept()
52 54 # self.close()
53 55 #
54 56 @pyqtSignature("")
55 57 def on_dirCancelBtn_clicked(self):
56 58 """
57 59 Cerrar
58 60 """
59 61 self.close()
60 62
61 63
62 64
63 65
64 66
65 67 No newline at end of file
@@ -1,4 +1,5
1 1 import ui_initwindow
2 2 import ui_workspace
3 3 import ui_mainwindow
4 4 import ui_window
5 import ui_ftp No newline at end of file
@@ -1,88 +1,88
1 1 # -*- coding: utf-8 -*-
2 2
3 3 # Form implementation generated from reading ui file '/home/roj-idl71/SignalChain/initwindowv2.ui'
4 4 #
5 5 # Created: Wed Mar 6 15:32:39 2013
6 6 # by: PyQt4 UI code generator 4.8.6
7 7 #
8 8 # WARNING! All changes made in this file will be lost!
9 9
10 10 from PyQt4 import QtCore, QtGui
11 11
12 12 try:
13 13 _fromUtf8 = QtCore.QString.fromUtf8
14 14 except AttributeError:
15 15 _fromUtf8 = lambda s: s
16 16
17 17 class Ui_InitWindow(object):
18 18 def setupUi(self, Dialog):
19 19 Dialog.setObjectName(_fromUtf8("Dialog"))
20 20 Dialog.resize(652, 496)
21 21 Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
22 22 self.gridLayout = QtGui.QGridLayout(Dialog)
23 23 self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
24 24 self.verticalLayout_3 = QtGui.QVBoxLayout()
25 25 self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3"))
26 26 self.verticalLayout_4 = QtGui.QVBoxLayout()
27 27 self.verticalLayout_4.setObjectName(_fromUtf8("verticalLayout_4"))
28 28 self.label_3 = QtGui.QLabel(Dialog)
29 29 font = QtGui.QFont()
30 30 font.setFamily(_fromUtf8("Cambria"))
31 31 font.setPointSize(22)
32 32 font.setBold(False)
33 33 font.setWeight(50)
34 34 self.label_3.setFont(font)
35 35 self.label_3.setText(QtGui.QApplication.translate("Dialog", "Signal Chain - Ver. 1.0", None, QtGui.QApplication.UnicodeUTF8))
36 36 self.label_3.setObjectName(_fromUtf8("label_3"))
37 37 self.verticalLayout_4.addWidget(self.label_3)
38 38 self.line_2 = QtGui.QFrame(Dialog)
39 39 self.line_2.setFrameShape(QtGui.QFrame.HLine)
40 40 self.line_2.setFrameShadow(QtGui.QFrame.Sunken)
41 41 self.line_2.setObjectName(_fromUtf8("line_2"))
42 42 self.verticalLayout_4.addWidget(self.line_2)
43 43 self.label_4 = QtGui.QLabel(Dialog)
44 44 self.label_4.setText(_fromUtf8(""))
45 self.label_4.setPixmap(QtGui.QPixmap(_fromUtf8("figure/w.jpg")))
45 self.label_4.setPixmap(QtGui.QPixmap(_fromUtf8("schainpy/gui/figure/w.jpg")))
46 46 self.label_4.setScaledContents(True)
47 47 self.label_4.setObjectName(_fromUtf8("label_4"))
48 48 self.verticalLayout_4.addWidget(self.label_4)
49 49 self.verticalLayout_3.addLayout(self.verticalLayout_4)
50 50 self.horizontalLayout_3 = QtGui.QHBoxLayout()
51 51 self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3"))
52 52 self.horizontalLayout_4 = QtGui.QHBoxLayout()
53 53 self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4"))
54 54 spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
55 55 self.horizontalLayout_4.addItem(spacerItem)
56 56 self.ExitBtn = QtGui.QPushButton(Dialog)
57 57 self.ExitBtn.setText(QtGui.QApplication.translate("Dialog", "Exit", None, QtGui.QApplication.UnicodeUTF8))
58 58 self.ExitBtn.setObjectName(_fromUtf8("ExitBtn"))
59 59 self.horizontalLayout_4.addWidget(self.ExitBtn)
60 60 self.ContinueBtn = QtGui.QPushButton(Dialog)
61 61 self.ContinueBtn.setText(QtGui.QApplication.translate("Dialog", "Continue", None, QtGui.QApplication.UnicodeUTF8))
62 62 self.ContinueBtn.setObjectName(_fromUtf8("ContinueBtn"))
63 63 self.horizontalLayout_4.addWidget(self.ContinueBtn)
64 64 spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
65 65 self.horizontalLayout_4.addItem(spacerItem1)
66 66 self.horizontalLayout_3.addLayout(self.horizontalLayout_4)
67 67 self.verticalLayout_3.addLayout(self.horizontalLayout_3)
68 68 self.gridLayout.addLayout(self.verticalLayout_3, 0, 0, 1, 1)
69 69
70 70 self.retranslateUi(Dialog)
71 71 QtCore.QMetaObject.connectSlotsByName(Dialog)
72 72
73 73 def retranslateUi(self, Dialog):
74 74 pass
75 75
76 76
77 77 if __name__ == "__main__":
78 78 import sys
79 79 app = QtGui.QApplication(sys.argv)
80 80 Dialog = QtGui.QDialog()
81 81 ui = Ui_InitWindow()
82 82 ui.setupUi(Dialog)
83 83 Dialog.show()
84 84 sys.exit(app.exec_())
85 85
86 86
87 87
88 88
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
General Comments 0
You need to be logged in to leave comments. Login now