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 |
|
NO CONTENT: new file 100644, binary diff hidden |
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
1 | NO CONTENT: new file 100644, binary diff hidden |
|
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 |
|
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 |
1 | NO CONTENT: new file 100644 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 | Created on September , 2012 |
|
2 | Created on September , 2012 | |
3 | @author: |
|
3 | @author: | |
4 | ''' |
|
4 | ''' | |
5 | from xml.etree.ElementTree import Element, SubElement |
|
5 | from xml.etree.ElementTree import Element, SubElement | |
6 | from xml.etree import ElementTree as ET |
|
6 | from xml.etree import ElementTree as ET | |
7 | from xml.dom import minidom |
|
7 | from xml.dom import minidom | |
8 |
|
8 | |||
9 | #import datetime |
|
9 | #import datetime | |
10 | from model import * |
|
10 | from model import * | |
11 |
|
11 | |||
12 | import ast |
|
12 | import ast | |
13 |
|
13 | |||
14 | def prettify(elem): |
|
14 | def prettify(elem): | |
15 | """Return a pretty-printed XML string for the Element. |
|
15 | """Return a pretty-printed XML string for the Element. | |
16 | """ |
|
16 | """ | |
17 | rough_string = ET.tostring(elem, 'utf-8') |
|
17 | rough_string = ET.tostring(elem, 'utf-8') | |
18 | reparsed = minidom.parseString(rough_string) |
|
18 | reparsed = minidom.parseString(rough_string) | |
19 | return reparsed.toprettyxml(indent=" ") |
|
19 | return reparsed.toprettyxml(indent=" ") | |
20 |
|
20 | |||
21 | class ParameterConf(): |
|
21 | class ParameterConf(): | |
22 |
|
22 | |||
23 | id = None |
|
23 | id = None | |
24 | name = None |
|
24 | name = None | |
25 | value = None |
|
25 | value = None | |
26 | format = None |
|
26 | format = None | |
27 |
|
27 | |||
28 | __formated_value = None |
|
28 | __formated_value = None | |
29 |
|
29 | |||
30 | ELEMENTNAME = 'Parameter' |
|
30 | ELEMENTNAME = 'Parameter' | |
31 |
|
31 | |||
32 | def __init__(self): |
|
32 | def __init__(self): | |
33 |
|
33 | |||
34 | self.format = 'str' |
|
34 | self.format = 'str' | |
35 |
|
35 | |||
36 | def getElementName(self): |
|
36 | def getElementName(self): | |
37 |
|
37 | |||
38 | return self.ELEMENTNAME |
|
38 | return self.ELEMENTNAME | |
39 |
|
39 | |||
40 | def getValue(self): |
|
40 | def getValue(self): | |
41 |
|
41 | |||
42 | if self.__formated_value != None: |
|
42 | if self.__formated_value != None: | |
43 |
|
43 | |||
44 | return self.__formated_value |
|
44 | return self.__formated_value | |
45 |
|
45 | |||
46 | value = self.value |
|
46 | value = self.value | |
47 |
|
47 | |||
48 | if self.format == 'bool': |
|
48 | if self.format == 'bool': | |
49 | value = int(value) |
|
49 | value = int(value) | |
50 |
|
50 | |||
51 | if self.format == 'list': |
|
51 | if self.format == 'list': | |
52 | strList = value.split(',') |
|
52 | strList = value.split(',') | |
53 |
|
53 | |||
54 | self.__formated_value = strList |
|
54 | self.__formated_value = strList | |
55 |
|
55 | |||
56 | return self.__formated_value |
|
56 | return self.__formated_value | |
57 |
|
57 | |||
58 | if self.format == 'intlist': |
|
58 | if self.format == 'intlist': | |
59 | """ |
|
59 | """ | |
60 | Example: |
|
60 | Example: | |
61 | value = (0,1,2) |
|
61 | value = (0,1,2) | |
62 | """ |
|
62 | """ | |
63 | strList = value.split(',') |
|
63 | strList = value.split(',') | |
64 | intList = [int(x) for x in strList] |
|
64 | intList = [int(x) for x in strList] | |
65 |
|
65 | |||
66 | self.__formated_value = intList |
|
66 | self.__formated_value = intList | |
67 |
|
67 | |||
68 | return self.__formated_value |
|
68 | return self.__formated_value | |
69 |
|
69 | |||
70 | if self.format == 'floatlist': |
|
70 | if self.format == 'floatlist': | |
71 | """ |
|
71 | """ | |
72 | Example: |
|
72 | Example: | |
73 | value = (0.5, 1.4, 2.7) |
|
73 | value = (0.5, 1.4, 2.7) | |
74 | """ |
|
74 | """ | |
75 | strList = value.split(',') |
|
75 | strList = value.split(',') | |
76 | floatList = [float(x) for x in strList] |
|
76 | floatList = [float(x) for x in strList] | |
77 |
|
77 | |||
78 | self.__formated_value = floatList |
|
78 | self.__formated_value = floatList | |
79 |
|
79 | |||
80 | return self.__formated_value |
|
80 | return self.__formated_value | |
81 |
|
81 | |||
82 | if self.format == 'date': |
|
82 | if self.format == 'date': | |
83 | strList = value.split('/') |
|
83 | strList = value.split('/') | |
84 | intList = [int(x) for x in strList] |
|
84 | intList = [int(x) for x in strList] | |
85 | date = datetime.date(intList[0], intList[1], intList[2]) |
|
85 | date = datetime.date(intList[0], intList[1], intList[2]) | |
86 |
|
86 | |||
87 | self.__formated_value = date |
|
87 | self.__formated_value = date | |
88 |
|
88 | |||
89 | return self.__formated_value |
|
89 | return self.__formated_value | |
90 |
|
90 | |||
91 | if self.format == 'time': |
|
91 | if self.format == 'time': | |
92 | strList = value.split(':') |
|
92 | strList = value.split(':') | |
93 | intList = [int(x) for x in strList] |
|
93 | intList = [int(x) for x in strList] | |
94 | time = datetime.time(intList[0], intList[1], intList[2]) |
|
94 | time = datetime.time(intList[0], intList[1], intList[2]) | |
95 |
|
95 | |||
96 | self.__formated_value = time |
|
96 | self.__formated_value = time | |
97 |
|
97 | |||
98 | return self.__formated_value |
|
98 | return self.__formated_value | |
99 |
|
99 | |||
100 | if self.format == 'pairslist': |
|
100 | if self.format == 'pairslist': | |
101 | """ |
|
101 | """ | |
102 | Example: |
|
102 | Example: | |
103 | value = (0,1),(1,2) |
|
103 | value = (0,1),(1,2) | |
104 | """ |
|
104 | """ | |
105 |
|
105 | |||
106 | value = value.replace('(', '') |
|
106 | value = value.replace('(', '') | |
107 | value = value.replace(')', '') |
|
107 | value = value.replace(')', '') | |
108 |
|
108 | |||
109 | strList = value.split(',') |
|
109 | strList = value.split(',') | |
110 | intList = [int(item) for item in strList] |
|
110 | intList = [int(item) for item in strList] | |
111 | pairList = [] |
|
111 | pairList = [] | |
112 | for i in range(len(intList)/2): |
|
112 | for i in range(len(intList)/2): | |
113 | pairList.append((intList[i*2], intList[i*2 + 1])) |
|
113 | pairList.append((intList[i*2], intList[i*2 + 1])) | |
114 |
|
114 | |||
115 | self.__formated_value = pairList |
|
115 | self.__formated_value = pairList | |
116 |
|
116 | |||
117 | return self.__formated_value |
|
117 | return self.__formated_value | |
118 |
|
118 | |||
119 | if self.format == 'multilist': |
|
119 | if self.format == 'multilist': | |
120 | """ |
|
120 | """ | |
121 | Example: |
|
121 | Example: | |
122 | value = (0,1,2),(3,4,5) |
|
122 | value = (0,1,2),(3,4,5) | |
123 | """ |
|
123 | """ | |
124 | multiList = ast.literal_eval(value) |
|
124 | multiList = ast.literal_eval(value) | |
125 |
|
125 | |||
126 | self.__formated_value = multiList |
|
126 | self.__formated_value = multiList | |
127 |
|
127 | |||
128 | return self.__formated_value |
|
128 | return self.__formated_value | |
129 |
|
129 | |||
130 | format_func = eval(self.format) |
|
130 | format_func = eval(self.format) | |
131 |
|
131 | |||
132 | self.__formated_value = format_func(value) |
|
132 | self.__formated_value = format_func(value) | |
133 |
|
133 | |||
134 | return self.__formated_value |
|
134 | return self.__formated_value | |
135 |
|
135 | |||
136 | def setup(self, id, name, value, format='str'): |
|
136 | def setup(self, id, name, value, format='str'): | |
137 |
|
137 | |||
138 | self.id = id |
|
138 | self.id = id | |
139 | self.name = name |
|
139 | self.name = name | |
140 | self.value = str(value) |
|
140 | self.value = str(value) | |
141 | self.format = str.lower(format) |
|
141 | self.format = str.lower(format) | |
|
142 | ||||
|
143 | def update(self, name, value, format='str'): | |||
|
144 | ||||
|
145 | self.name = name | |||
|
146 | self.value = str(value) | |||
|
147 | self.format = format | |||
142 |
|
148 | |||
143 | def makeXml(self, opElement): |
|
149 | def makeXml(self, opElement): | |
144 |
|
150 | |||
145 | parmElement = SubElement(opElement, self.ELEMENTNAME) |
|
151 | parmElement = SubElement(opElement, self.ELEMENTNAME) | |
146 | parmElement.set('id', str(self.id)) |
|
152 | parmElement.set('id', str(self.id)) | |
147 | parmElement.set('name', self.name) |
|
153 | parmElement.set('name', self.name) | |
148 | parmElement.set('value', self.value) |
|
154 | parmElement.set('value', self.value) | |
149 | parmElement.set('format', self.format) |
|
155 | parmElement.set('format', self.format) | |
150 |
|
156 | |||
151 | def readXml(self, parmElement): |
|
157 | def readXml(self, parmElement): | |
152 |
|
158 | |||
153 | self.id = parmElement.get('id') |
|
159 | self.id = parmElement.get('id') | |
154 | self.name = parmElement.get('name') |
|
160 | self.name = parmElement.get('name') | |
155 | self.value = parmElement.get('value') |
|
161 | self.value = parmElement.get('value') | |
156 | self.format = str.lower(parmElement.get('format')) |
|
162 | self.format = str.lower(parmElement.get('format')) | |
157 |
|
163 | |||
158 | #Compatible with old signal chain version |
|
164 | #Compatible with old signal chain version | |
159 | if self.format == 'int' and self.name == 'idfigure': |
|
165 | if self.format == 'int' and self.name == 'idfigure': | |
160 | self.name = 'id' |
|
166 | self.name = 'id' | |
161 |
|
167 | |||
162 | def printattr(self): |
|
168 | def printattr(self): | |
163 |
|
169 | |||
164 | print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format) |
|
170 | print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format) | |
165 |
|
171 | |||
166 | class OperationConf(): |
|
172 | class OperationConf(): | |
167 |
|
173 | |||
168 | id = None |
|
174 | id = None | |
169 | name = None |
|
175 | name = None | |
170 | priority = None |
|
176 | priority = None | |
171 | type = None |
|
177 | type = None | |
172 |
|
178 | |||
173 | parmConfObjList = [] |
|
179 | parmConfObjList = [] | |
174 |
|
180 | |||
175 | ELEMENTNAME = 'Operation' |
|
181 | ELEMENTNAME = 'Operation' | |
176 |
|
182 | |||
177 | def __init__(self): |
|
183 | def __init__(self): | |
178 |
|
184 | |||
179 | self.id = 0 |
|
185 | self.id = 0 | |
180 | self.name = None |
|
186 | self.name = None | |
181 | self.priority = None |
|
187 | self.priority = None | |
182 | self.type = 'self' |
|
188 | self.type = 'self' | |
183 |
|
189 | |||
184 |
|
190 | |||
185 | def __getNewId(self): |
|
191 | def __getNewId(self): | |
186 |
|
192 | |||
187 | return int(self.id)*10 + len(self.parmConfObjList) + 1 |
|
193 | return int(self.id)*10 + len(self.parmConfObjList) + 1 | |
188 |
|
194 | |||
189 | def getElementName(self): |
|
195 | def getElementName(self): | |
190 |
|
196 | |||
191 | return self.ELEMENTNAME |
|
197 | return self.ELEMENTNAME | |
192 |
|
198 | |||
193 | def getParameterObjList(self): |
|
199 | def getParameterObjList(self): | |
194 |
|
200 | |||
195 | return self.parmConfObjList |
|
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 | def setup(self, id, name, priority, type): |
|
231 | def setup(self, id, name, priority, type): | |
198 |
|
232 | |||
199 | self.id = id |
|
233 | self.id = id | |
200 | self.name = name |
|
234 | self.name = name | |
201 | self.type = type |
|
235 | self.type = type | |
202 | self.priority = priority |
|
236 | self.priority = priority | |
203 |
|
237 | |||
204 | self.parmConfObjList = [] |
|
238 | self.parmConfObjList = [] | |
|
239 | ||||
|
240 | def removeParameters(self): | |||
|
241 | ||||
|
242 | for obj in self.parmConfObjList: | |||
|
243 | del obj | |||
|
244 | ||||
|
245 | self.parmConfObjList = [] | |||
205 |
|
246 | |||
206 | def addParameter(self, name, value, format='str'): |
|
247 | def addParameter(self, name, value, format='str'): | |
207 |
|
248 | |||
208 | id = self.__getNewId() |
|
249 | id = self.__getNewId() | |
209 |
|
250 | |||
210 | parmConfObj = ParameterConf() |
|
251 | parmConfObj = ParameterConf() | |
211 | parmConfObj.setup(id, name, value, format) |
|
252 | parmConfObj.setup(id, name, value, format) | |
212 |
|
253 | |||
213 | self.parmConfObjList.append(parmConfObj) |
|
254 | self.parmConfObjList.append(parmConfObj) | |
214 |
|
255 | |||
215 | return parmConfObj |
|
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 | def makeXml(self, upElement): |
|
265 | def makeXml(self, upElement): | |
218 |
|
266 | |||
219 | opElement = SubElement(upElement, self.ELEMENTNAME) |
|
267 | opElement = SubElement(upElement, self.ELEMENTNAME) | |
220 | opElement.set('id', str(self.id)) |
|
268 | opElement.set('id', str(self.id)) | |
221 | opElement.set('name', self.name) |
|
269 | opElement.set('name', self.name) | |
222 | opElement.set('type', self.type) |
|
270 | opElement.set('type', self.type) | |
223 | opElement.set('priority', str(self.priority)) |
|
271 | opElement.set('priority', str(self.priority)) | |
224 |
|
272 | |||
225 | for parmConfObj in self.parmConfObjList: |
|
273 | for parmConfObj in self.parmConfObjList: | |
226 | parmConfObj.makeXml(opElement) |
|
274 | parmConfObj.makeXml(opElement) | |
227 |
|
275 | |||
228 | def readXml(self, opElement): |
|
276 | def readXml(self, opElement): | |
229 |
|
277 | |||
230 | self.id = opElement.get('id') |
|
278 | self.id = opElement.get('id') | |
231 | self.name = opElement.get('name') |
|
279 | self.name = opElement.get('name') | |
232 | self.type = opElement.get('type') |
|
280 | self.type = opElement.get('type') | |
233 | self.priority = opElement.get('priority') |
|
281 | self.priority = opElement.get('priority') | |
234 |
|
282 | |||
235 | #Compatible with old signal chain version |
|
283 | #Compatible with old signal chain version | |
236 | #Use of 'run' method instead 'init' |
|
284 | #Use of 'run' method instead 'init' | |
237 | if self.type == 'self' and self.name == 'init': |
|
285 | if self.type == 'self' and self.name == 'init': | |
238 | self.name = 'run' |
|
286 | self.name = 'run' | |
239 |
|
287 | |||
240 | self.parmConfObjList = [] |
|
288 | self.parmConfObjList = [] | |
241 |
|
289 | |||
242 | parmElementList = opElement.getiterator(ParameterConf().getElementName()) |
|
290 | parmElementList = opElement.getiterator(ParameterConf().getElementName()) | |
243 |
|
291 | |||
244 | for parmElement in parmElementList: |
|
292 | for parmElement in parmElementList: | |
245 | parmConfObj = ParameterConf() |
|
293 | parmConfObj = ParameterConf() | |
246 | parmConfObj.readXml(parmElement) |
|
294 | parmConfObj.readXml(parmElement) | |
247 |
|
295 | |||
248 | #Compatible with old signal chain version |
|
296 | #Compatible with old signal chain version | |
249 | #If an 'plot' OPERATION is found, changes name operation by the value of its type PARAMETER |
|
297 | #If an 'plot' OPERATION is found, changes name operation by the value of its type PARAMETER | |
250 | if self.type != 'self' and self.name == 'Plot': |
|
298 | if self.type != 'self' and self.name == 'Plot': | |
251 | if parmConfObj.format == 'str' and parmConfObj.name == 'type': |
|
299 | if parmConfObj.format == 'str' and parmConfObj.name == 'type': | |
252 | self.name = parmConfObj.value |
|
300 | self.name = parmConfObj.value | |
253 | continue |
|
301 | continue | |
254 |
|
302 | |||
255 | self.parmConfObjList.append(parmConfObj) |
|
303 | self.parmConfObjList.append(parmConfObj) | |
256 |
|
304 | |||
257 | def printattr(self): |
|
305 | def printattr(self): | |
258 |
|
306 | |||
259 | print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME, |
|
307 | print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME, | |
260 | self.id, |
|
308 | self.id, | |
261 | self.name, |
|
309 | self.name, | |
262 | self.type, |
|
310 | self.type, | |
263 | self.priority) |
|
311 | self.priority) | |
264 |
|
312 | |||
265 | for parmConfObj in self.parmConfObjList: |
|
313 | for parmConfObj in self.parmConfObjList: | |
266 | parmConfObj.printattr() |
|
314 | parmConfObj.printattr() | |
267 |
|
315 | |||
268 | def createObject(self): |
|
316 | def createObject(self): | |
269 |
|
317 | |||
270 | if self.type == 'self': |
|
318 | if self.type == 'self': | |
271 | raise ValueError, "This operation type cannot be created" |
|
319 | raise ValueError, "This operation type cannot be created" | |
272 |
|
320 | |||
273 | if self.type == 'external' or self.type == 'other': |
|
321 | if self.type == 'external' or self.type == 'other': | |
274 | className = eval(self.name) |
|
322 | className = eval(self.name) | |
275 | opObj = className() |
|
323 | opObj = className() | |
276 |
|
324 | |||
277 | return opObj |
|
325 | return opObj | |
278 |
|
326 | |||
279 | class ProcUnitConf(): |
|
327 | class ProcUnitConf(): | |
280 |
|
328 | |||
281 | id = None |
|
329 | id = None | |
282 | name = None |
|
330 | name = None | |
283 | datatype = None |
|
331 | datatype = None | |
284 | inputId = None |
|
332 | inputId = None | |
|
333 | parentId = None | |||
285 |
|
334 | |||
286 | opConfObjList = [] |
|
335 | opConfObjList = [] | |
287 |
|
336 | |||
288 | procUnitObj = None |
|
337 | procUnitObj = None | |
289 | opObjList = [] |
|
338 | opObjList = [] | |
290 |
|
339 | |||
291 | ELEMENTNAME = 'ProcUnit' |
|
340 | ELEMENTNAME = 'ProcUnit' | |
292 |
|
341 | |||
293 | def __init__(self): |
|
342 | def __init__(self): | |
294 |
|
343 | |||
295 | self.id = None |
|
344 | self.id = None | |
296 | self.datatype = None |
|
345 | self.datatype = None | |
297 | self.name = None |
|
346 | self.name = None | |
298 | self.inputId = None |
|
347 | self.inputId = None | |
299 |
|
348 | |||
300 | self.opConfObjList = [] |
|
349 | self.opConfObjList = [] | |
301 |
|
350 | |||
302 | self.procUnitObj = None |
|
351 | self.procUnitObj = None | |
303 | self.opObjDict = {} |
|
352 | self.opObjDict = {} | |
304 |
|
353 | |||
305 | def __getPriority(self): |
|
354 | def __getPriority(self): | |
306 |
|
355 | |||
307 | return len(self.opConfObjList)+1 |
|
356 | return len(self.opConfObjList)+1 | |
308 |
|
357 | |||
309 | def __getNewId(self): |
|
358 | def __getNewId(self): | |
310 |
|
359 | |||
311 | return int(self.id)*10 + len(self.opConfObjList) + 1 |
|
360 | return int(self.id)*10 + len(self.opConfObjList) + 1 | |
312 |
|
361 | |||
313 | def getElementName(self): |
|
362 | def getElementName(self): | |
314 |
|
363 | |||
315 | return self.ELEMENTNAME |
|
364 | return self.ELEMENTNAME | |
316 |
|
365 | |||
317 | def getId(self): |
|
366 | def getId(self): | |
318 |
|
367 | |||
319 | return str(self.id) |
|
368 | return str(self.id) | |
320 |
|
369 | |||
321 | def getInputId(self): |
|
370 | def getInputId(self): | |
322 |
|
371 | |||
323 | return str(self.inputId) |
|
372 | return str(self.inputId) | |
324 |
|
373 | |||
325 | def getOperationObjList(self): |
|
374 | def getOperationObjList(self): | |
326 |
|
375 | |||
327 | return self.opConfObjList |
|
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 | def getProcUnitObj(self): |
|
397 | def getProcUnitObj(self): | |
330 |
|
398 | |||
331 | return self.procUnitObj |
|
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 | self.id = id |
|
403 | self.id = id | |
336 | self.name = name |
|
404 | self.name = name | |
337 | self.datatype = datatype |
|
405 | self.datatype = datatype | |
338 | self.inputId = inputId |
|
406 | self.inputId = inputId | |
|
407 | self.parentId = parentId | |||
339 |
|
408 | |||
340 | self.opConfObjList = [] |
|
409 | self.opConfObjList = [] | |
341 |
|
410 | |||
342 | self.addOperation(name='run', optype='self') |
|
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 | def addParameter(self, **kwargs): |
|
421 | def addParameter(self, **kwargs): | |
345 |
|
422 | |||
346 | opObj = self.opConfObjList[0] |
|
423 | opObj = self.opConfObjList[0] | |
347 |
|
424 | |||
348 | opObj.addParameter(**kwargs) |
|
425 | opObj.addParameter(**kwargs) | |
349 |
|
426 | |||
350 | return opObj |
|
427 | return opObj | |
351 |
|
428 | |||
352 | def addOperation(self, name, optype='self'): |
|
429 | def addOperation(self, name, optype='self'): | |
353 |
|
430 | |||
354 | id = self.__getNewId() |
|
431 | id = self.__getNewId() | |
355 | priority = self.__getPriority() |
|
432 | priority = self.__getPriority() | |
356 |
|
433 | |||
357 | opConfObj = OperationConf() |
|
434 | opConfObj = OperationConf() | |
358 | opConfObj.setup(id, name=name, priority=priority, type=optype) |
|
435 | opConfObj.setup(id, name=name, priority=priority, type=optype) | |
359 |
|
436 | |||
360 | self.opConfObjList.append(opConfObj) |
|
437 | self.opConfObjList.append(opConfObj) | |
361 |
|
438 | |||
362 | return opConfObj |
|
439 | return opConfObj | |
363 |
|
440 | |||
364 | def makeXml(self, procUnitElement): |
|
441 | def makeXml(self, procUnitElement): | |
365 |
|
442 | |||
366 | upElement = SubElement(procUnitElement, self.ELEMENTNAME) |
|
443 | upElement = SubElement(procUnitElement, self.ELEMENTNAME) | |
367 | upElement.set('id', str(self.id)) |
|
444 | upElement.set('id', str(self.id)) | |
368 | upElement.set('name', self.name) |
|
445 | upElement.set('name', self.name) | |
369 | upElement.set('datatype', self.datatype) |
|
446 | upElement.set('datatype', self.datatype) | |
370 | upElement.set('inputId', str(self.inputId)) |
|
447 | upElement.set('inputId', str(self.inputId)) | |
371 |
|
448 | |||
372 | for opConfObj in self.opConfObjList: |
|
449 | for opConfObj in self.opConfObjList: | |
373 | opConfObj.makeXml(upElement) |
|
450 | opConfObj.makeXml(upElement) | |
374 |
|
451 | |||
375 | def readXml(self, upElement): |
|
452 | def readXml(self, upElement): | |
376 |
|
453 | |||
377 | self.id = upElement.get('id') |
|
454 | self.id = upElement.get('id') | |
378 | self.name = upElement.get('name') |
|
455 | self.name = upElement.get('name') | |
379 | self.datatype = upElement.get('datatype') |
|
456 | self.datatype = upElement.get('datatype') | |
380 | self.inputId = upElement.get('inputId') |
|
457 | self.inputId = upElement.get('inputId') | |
381 |
|
458 | |||
382 | self.opConfObjList = [] |
|
459 | self.opConfObjList = [] | |
383 |
|
460 | |||
384 | opElementList = upElement.getiterator(OperationConf().getElementName()) |
|
461 | opElementList = upElement.getiterator(OperationConf().getElementName()) | |
385 |
|
462 | |||
386 | for opElement in opElementList: |
|
463 | for opElement in opElementList: | |
387 | opConfObj = OperationConf() |
|
464 | opConfObj = OperationConf() | |
388 | opConfObj.readXml(opElement) |
|
465 | opConfObj.readXml(opElement) | |
389 | self.opConfObjList.append(opConfObj) |
|
466 | self.opConfObjList.append(opConfObj) | |
390 |
|
467 | |||
391 | def printattr(self): |
|
468 | def printattr(self): | |
392 |
|
469 | |||
393 | print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME, |
|
470 | print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME, | |
394 | self.id, |
|
471 | self.id, | |
395 | self.name, |
|
472 | self.name, | |
396 | self.datatype, |
|
473 | self.datatype, | |
397 | self.inputId) |
|
474 | self.inputId) | |
398 |
|
475 | |||
399 | for opConfObj in self.opConfObjList: |
|
476 | for opConfObj in self.opConfObjList: | |
400 | opConfObj.printattr() |
|
477 | opConfObj.printattr() | |
401 |
|
478 | |||
402 | def createObjects(self): |
|
479 | def createObjects(self): | |
403 |
|
480 | |||
404 | className = eval(self.name) |
|
481 | className = eval(self.name) | |
405 | procUnitObj = className() |
|
482 | procUnitObj = className() | |
406 |
|
483 | |||
407 | for opConfObj in self.opConfObjList: |
|
484 | for opConfObj in self.opConfObjList: | |
408 |
|
485 | |||
409 | if opConfObj.type == 'self': |
|
486 | if opConfObj.type == 'self': | |
410 | continue |
|
487 | continue | |
411 |
|
488 | |||
412 | opObj = opConfObj.createObject() |
|
489 | opObj = opConfObj.createObject() | |
413 |
|
490 | |||
414 | self.opObjDict[opConfObj.id] = opObj |
|
491 | self.opObjDict[opConfObj.id] = opObj | |
415 | procUnitObj.addOperation(opObj, opConfObj.id) |
|
492 | procUnitObj.addOperation(opObj, opConfObj.id) | |
416 |
|
493 | |||
417 | self.procUnitObj = procUnitObj |
|
494 | self.procUnitObj = procUnitObj | |
418 |
|
495 | |||
419 | return procUnitObj |
|
496 | return procUnitObj | |
420 |
|
497 | |||
421 | def run(self): |
|
498 | def run(self): | |
422 |
|
499 | |||
423 | finalSts = False |
|
500 | finalSts = False | |
424 |
|
501 | |||
425 | for opConfObj in self.opConfObjList: |
|
502 | for opConfObj in self.opConfObjList: | |
426 |
|
503 | |||
427 | kwargs = {} |
|
504 | kwargs = {} | |
428 | for parmConfObj in opConfObj.getParameterObjList(): |
|
505 | for parmConfObj in opConfObj.getParameterObjList(): | |
|
506 | if opConfObj.name == 'run' and parmConfObj.name == 'datatype': | |||
|
507 | continue | |||
|
508 | ||||
429 | kwargs[parmConfObj.name] = parmConfObj.getValue() |
|
509 | kwargs[parmConfObj.name] = parmConfObj.getValue() | |
430 |
|
510 | |||
431 | #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id) |
|
511 | #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id) | |
432 | sts = self.procUnitObj.call(opType = opConfObj.type, |
|
512 | sts = self.procUnitObj.call(opType = opConfObj.type, | |
433 | opName = opConfObj.name, |
|
513 | opName = opConfObj.name, | |
434 | opId = opConfObj.id, |
|
514 | opId = opConfObj.id, | |
435 | **kwargs) |
|
515 | **kwargs) | |
436 | finalSts = finalSts or sts |
|
516 | finalSts = finalSts or sts | |
437 |
|
517 | |||
438 | return finalSts |
|
518 | return finalSts | |
439 |
|
519 | |||
440 | def close(self): |
|
520 | def close(self): | |
441 |
|
521 | |||
442 | self.procUnitObj.close() |
|
522 | for opConfObj in self.opConfObjList: | |
|
523 | if opConfObj.type == 'self': | |||
|
524 | continue | |||
|
525 | ||||
|
526 | opObj = self.procUnitObj.getOperationObj(opConfObj.id) | |||
|
527 | opObj.close() | |||
443 |
|
528 | |||
|
529 | self.procUnitObj.close() | |||
|
530 | ||||
444 | return |
|
531 | return | |
445 |
|
532 | |||
446 | class ReadUnitConf(ProcUnitConf): |
|
533 | class ReadUnitConf(ProcUnitConf): | |
447 |
|
534 | |||
448 | path = None |
|
535 | path = None | |
449 | startDate = None |
|
536 | startDate = None | |
450 | endDate = None |
|
537 | endDate = None | |
451 | startTime = None |
|
538 | startTime = None | |
452 | endTime = None |
|
539 | endTime = None | |
453 |
|
540 | |||
454 | ELEMENTNAME = 'ReadUnit' |
|
541 | ELEMENTNAME = 'ReadUnit' | |
455 |
|
542 | |||
456 | def __init__(self): |
|
543 | def __init__(self): | |
457 |
|
544 | |||
458 | self.id = None |
|
545 | self.id = None | |
459 | self.datatype = None |
|
546 | self.datatype = None | |
460 | self.name = None |
|
547 | self.name = None | |
461 | self.inputId = 0 |
|
548 | self.inputId = 0 | |
462 |
|
549 | |||
463 | self.opConfObjList = [] |
|
550 | self.opConfObjList = [] | |
464 | self.opObjList = [] |
|
551 | self.opObjList = [] | |
465 |
|
552 | |||
466 | def getElementName(self): |
|
553 | def getElementName(self): | |
467 |
|
554 | |||
468 | return self.ELEMENTNAME |
|
555 | return self.ELEMENTNAME | |
469 |
|
556 | |||
470 |
def setup(self, id, name, datatype, path |
|
557 | def setup(self, id, name, datatype, path, startDate="", endDate="", startTime="", endTime="", parentId=None, **kwargs): | |
471 |
|
558 | |||
472 | self.id = id |
|
559 | self.id = id | |
473 | self.name = name |
|
560 | self.name = name | |
474 | self.datatype = datatype |
|
561 | self.datatype = datatype | |
475 |
|
562 | |||
476 | self.path = path |
|
563 | self.path = path | |
477 | self.startDate = startDate |
|
564 | self.startDate = startDate | |
478 | self.endDate = endDate |
|
565 | self.endDate = endDate | |
479 | self.startTime = startTime |
|
566 | self.startTime = startTime | |
480 | self.endTime = endTime |
|
567 | self.endTime = endTime | |
481 |
|
568 | |||
482 | self.addRunOperation(**kwargs) |
|
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 | def addRunOperation(self, **kwargs): |
|
582 | def addRunOperation(self, **kwargs): | |
485 |
|
583 | |||
486 | opObj = self.addOperation(name = 'run', optype = 'self') |
|
584 | opObj = self.addOperation(name = 'run', optype = 'self') | |
487 |
|
585 | |||
|
586 | opObj.addParameter(name='datatype' , value=self.datatype, format='str') | |||
488 | opObj.addParameter(name='path' , value=self.path, format='str') |
|
587 | opObj.addParameter(name='path' , value=self.path, format='str') | |
489 | opObj.addParameter(name='startDate' , value=self.startDate, format='date') |
|
588 | opObj.addParameter(name='startDate' , value=self.startDate, format='date') | |
490 | opObj.addParameter(name='endDate' , value=self.endDate, format='date') |
|
589 | opObj.addParameter(name='endDate' , value=self.endDate, format='date') | |
491 | opObj.addParameter(name='startTime' , value=self.startTime, format='time') |
|
590 | opObj.addParameter(name='startTime' , value=self.startTime, format='time') | |
492 | opObj.addParameter(name='endTime' , value=self.endTime, format='time') |
|
591 | opObj.addParameter(name='endTime' , value=self.endTime, format='time') | |
493 |
|
592 | |||
494 | for key, value in kwargs.items(): |
|
593 | for key, value in kwargs.items(): | |
495 | opObj.addParameter(name=key, value=value, format=type(value).__name__) |
|
594 | opObj.addParameter(name=key, value=value, format=type(value).__name__) | |
496 |
|
595 | |||
497 | return opObj |
|
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 | class Project(): |
|
615 | class Project(): | |
501 |
|
616 | |||
502 | id = None |
|
617 | id = None | |
503 | name = None |
|
618 | name = None | |
504 | description = None |
|
619 | description = None | |
505 | # readUnitConfObjList = None |
|
620 | # readUnitConfObjList = None | |
506 | procUnitConfObjDict = None |
|
621 | procUnitConfObjDict = None | |
507 |
|
622 | |||
508 | ELEMENTNAME = 'Project' |
|
623 | ELEMENTNAME = 'Project' | |
509 |
|
624 | |||
510 | def __init__(self): |
|
625 | def __init__(self, control=None, dataq=None): | |
511 |
|
626 | |||
512 | self.id = None |
|
627 | self.id = None | |
513 | self.name = None |
|
628 | self.name = None | |
514 | self.description = None |
|
629 | self.description = None | |
515 |
|
630 | |||
516 | # self.readUnitConfObjList = [] |
|
|||
517 | self.procUnitConfObjDict = {} |
|
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 | def __getNewId(self): |
|
643 | def __getNewId(self): | |
520 |
|
644 | |||
521 | id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1 |
|
645 | id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1 | |
522 |
|
646 | |||
523 | return str(id) |
|
647 | return str(id) | |
524 |
|
648 | |||
525 | def getElementName(self): |
|
649 | def getElementName(self): | |
526 |
|
650 | |||
527 | return self.ELEMENTNAME |
|
651 | return self.ELEMENTNAME | |
|
652 | ||||
|
653 | def getId(self): | |||
|
654 | ||||
|
655 | return self.id | |||
528 |
|
656 | |||
529 | def setup(self, id, name, description): |
|
657 | def setup(self, id, name, description): | |
530 |
|
658 | |||
531 | self.id = id |
|
659 | self.id = id | |
532 | self.name = name |
|
660 | self.name = name | |
533 | self.description = description |
|
661 | self.description = description | |
534 |
|
662 | |||
|
663 | def update(self, name, description): | |||
|
664 | ||||
|
665 | self.name = name | |||
|
666 | self.description = description | |||
|
667 | ||||
535 | def addReadUnit(self, datatype=None, name=None, **kwargs): |
|
668 | def addReadUnit(self, datatype=None, name=None, **kwargs): | |
536 |
|
669 | |||
537 | #Compatible with old signal chain version |
|
670 | #Compatible with old signal chain version | |
538 | if datatype==None and name==None: |
|
671 | if datatype==None and name==None: | |
539 | raise ValueError, "datatype or name should be defined" |
|
672 | raise ValueError, "datatype or name should be defined" | |
540 |
|
673 | |||
541 | if name==None: |
|
674 | if name==None: | |
542 | if 'Reader' in datatype: |
|
675 | if 'Reader' in datatype: | |
543 | name = datatype |
|
676 | name = datatype | |
544 | else: |
|
677 | else: | |
545 | name = '%sReader' %(datatype) |
|
678 | name = '%sReader' %(datatype) | |
546 |
|
679 | |||
547 | if datatype==None: |
|
680 | if datatype==None: | |
548 | datatype = name.replace('Reader','') |
|
681 | datatype = name.replace('Reader','') | |
549 |
|
682 | |||
550 | id = self.__getNewId() |
|
683 | id = self.__getNewId() | |
551 |
|
684 | |||
552 | readUnitConfObj = ReadUnitConf() |
|
685 | readUnitConfObj = ReadUnitConf() | |
553 | readUnitConfObj.setup(id, name, datatype, **kwargs) |
|
686 | readUnitConfObj.setup(id, name, datatype, parentId=self.id, **kwargs) | |
554 |
|
687 | |||
555 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj |
|
688 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj | |
556 |
|
689 | |||
557 | return readUnitConfObj |
|
690 | return readUnitConfObj | |
558 |
|
691 | |||
559 | def addProcUnit(self, inputId=0, datatype=None, name=None): |
|
692 | def addProcUnit(self, inputId=0, datatype=None, name=None): | |
560 |
|
693 | |||
561 | #Compatible with old signal chain version |
|
694 | #Compatible with old signal chain version | |
562 | if datatype==None and name==None: |
|
695 | if datatype==None and name==None: | |
563 | raise ValueError, "datatype or name should be defined" |
|
696 | raise ValueError, "datatype or name should be defined" | |
564 |
|
697 | |||
565 | if name==None: |
|
698 | if name==None: | |
566 | if 'Proc' in datatype: |
|
699 | if 'Proc' in datatype: | |
567 | name = datatype |
|
700 | name = datatype | |
568 | else: |
|
701 | else: | |
569 | name = '%sProc' %(datatype) |
|
702 | name = '%sProc' %(datatype) | |
570 |
|
703 | |||
571 | if datatype==None: |
|
704 | if datatype==None: | |
572 | datatype = name.replace('Proc','') |
|
705 | datatype = name.replace('Proc','') | |
573 |
|
706 | |||
574 | id = self.__getNewId() |
|
707 | id = self.__getNewId() | |
575 |
|
708 | |||
576 | procUnitConfObj = ProcUnitConf() |
|
709 | procUnitConfObj = ProcUnitConf() | |
577 | procUnitConfObj.setup(id, name, datatype, inputId) |
|
710 | procUnitConfObj.setup(id, name, datatype, inputId, parentId=self.id) | |
578 |
|
711 | |||
579 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj |
|
712 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj | |
580 |
|
713 | |||
581 | return procUnitConfObj |
|
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 | def makeXml(self): |
|
734 | def makeXml(self): | |
584 |
|
735 | |||
585 | projectElement = Element('Project') |
|
736 | projectElement = Element('Project') | |
586 | projectElement.set('id', str(self.id)) |
|
737 | projectElement.set('id', str(self.id)) | |
587 | projectElement.set('name', self.name) |
|
738 | projectElement.set('name', self.name) | |
588 | projectElement.set('description', self.description) |
|
739 | projectElement.set('description', self.description) | |
589 |
|
740 | |||
590 | # for readUnitConfObj in self.readUnitConfObjList: |
|
741 | # for readUnitConfObj in self.readUnitConfObjList: | |
591 | # readUnitConfObj.makeXml(projectElement) |
|
742 | # readUnitConfObj.makeXml(projectElement) | |
592 |
|
743 | |||
593 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
744 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
594 | procUnitConfObj.makeXml(projectElement) |
|
745 | procUnitConfObj.makeXml(projectElement) | |
595 |
|
746 | |||
596 | self.projectElement = projectElement |
|
747 | self.projectElement = projectElement | |
597 |
|
748 | |||
598 | def writeXml(self, filename): |
|
749 | def writeXml(self, filename): | |
599 |
|
750 | |||
600 | self.makeXml() |
|
751 | self.makeXml() | |
601 |
|
752 | |||
602 | #print prettify(self.projectElement) |
|
753 | #print prettify(self.projectElement) | |
603 |
|
754 | |||
604 | ElementTree(self.projectElement).write(filename, method='xml') |
|
755 | ElementTree(self.projectElement).write(filename, method='xml') | |
605 |
|
756 | |||
606 | def readXml(self, filename): |
|
757 | def readXml(self, filename): | |
607 |
|
758 | |||
608 | #tree = ET.parse(filename) |
|
759 | #tree = ET.parse(filename) | |
609 | self.projectElement = None |
|
760 | self.projectElement = None | |
610 | # self.readUnitConfObjList = [] |
|
761 | # self.readUnitConfObjList = [] | |
611 | self.procUnitConfObjDict = {} |
|
762 | self.procUnitConfObjDict = {} | |
612 |
|
763 | |||
613 | self.projectElement = ElementTree().parse(filename) |
|
764 | self.projectElement = ElementTree().parse(filename) | |
614 |
|
765 | |||
615 | self.project = self.projectElement.tag |
|
766 | self.project = self.projectElement.tag | |
616 |
|
767 | |||
617 | self.id = self.projectElement.get('id') |
|
768 | self.id = self.projectElement.get('id') | |
618 | self.name = self.projectElement.get('name') |
|
769 | self.name = self.projectElement.get('name') | |
619 | self.description = self.projectElement.get('description') |
|
770 | self.description = self.projectElement.get('description') | |
620 |
|
771 | |||
621 | readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName()) |
|
772 | readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName()) | |
622 |
|
773 | |||
623 | for readUnitElement in readUnitElementList: |
|
774 | for readUnitElement in readUnitElementList: | |
624 | readUnitConfObj = ReadUnitConf() |
|
775 | readUnitConfObj = ReadUnitConf() | |
625 | readUnitConfObj.readXml(readUnitElement) |
|
776 | readUnitConfObj.readXml(readUnitElement) | |
626 |
|
777 | |||
627 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj |
|
778 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj | |
628 |
|
779 | |||
629 | procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName()) |
|
780 | procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName()) | |
630 |
|
781 | |||
631 | for procUnitElement in procUnitElementList: |
|
782 | for procUnitElement in procUnitElementList: | |
632 | procUnitConfObj = ProcUnitConf() |
|
783 | procUnitConfObj = ProcUnitConf() | |
633 | procUnitConfObj.readXml(procUnitElement) |
|
784 | procUnitConfObj.readXml(procUnitElement) | |
634 |
|
785 | |||
635 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj |
|
786 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj | |
636 |
|
787 | |||
637 | def printattr(self): |
|
788 | def printattr(self): | |
638 |
|
789 | |||
639 | print "Project[%s]: name = %s, description = %s" %(self.id, |
|
790 | print "Project[%s]: name = %s, description = %s" %(self.id, | |
640 | self.name, |
|
791 | self.name, | |
641 | self.description) |
|
792 | self.description) | |
642 |
|
793 | |||
643 | # for readUnitConfObj in self.readUnitConfObjList: |
|
794 | # for readUnitConfObj in self.readUnitConfObjList: | |
644 | # readUnitConfObj.printattr() |
|
795 | # readUnitConfObj.printattr() | |
645 |
|
796 | |||
646 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
797 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
647 | procUnitConfObj.printattr() |
|
798 | procUnitConfObj.printattr() | |
648 |
|
799 | |||
649 | def createObjects(self): |
|
800 | def createObjects(self): | |
650 |
|
801 | |||
651 | # for readUnitConfObj in self.readUnitConfObjList: |
|
802 | # for readUnitConfObj in self.readUnitConfObjList: | |
652 | # readUnitConfObj.createObjects() |
|
803 | # readUnitConfObj.createObjects() | |
653 |
|
804 | |||
654 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
805 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
655 | procUnitConfObj.createObjects() |
|
806 | procUnitConfObj.createObjects() | |
656 |
|
807 | |||
657 | def __connect(self, objIN, thisObj): |
|
808 | def __connect(self, objIN, thisObj): | |
658 |
|
809 | |||
659 | thisObj.setInput(objIN.getOutputObj()) |
|
810 | thisObj.setInput(objIN.getOutputObj()) | |
660 |
|
811 | |||
661 | def connectObjects(self): |
|
812 | def connectObjects(self): | |
662 |
|
813 | |||
663 | for thisPUConfObj in self.procUnitConfObjDict.values(): |
|
814 | for thisPUConfObj in self.procUnitConfObjDict.values(): | |
664 |
|
815 | |||
665 | inputId = thisPUConfObj.getInputId() |
|
816 | inputId = thisPUConfObj.getInputId() | |
666 |
|
817 | |||
667 | if int(inputId) == 0: |
|
818 | if int(inputId) == 0: | |
668 | continue |
|
819 | continue | |
669 |
|
820 | |||
670 | #Get input object |
|
821 | #Get input object | |
671 | puConfINObj = self.procUnitConfObjDict[inputId] |
|
822 | puConfINObj = self.procUnitConfObjDict[inputId] | |
672 | puObjIN = puConfINObj.getProcUnitObj() |
|
823 | puObjIN = puConfINObj.getProcUnitObj() | |
673 |
|
824 | |||
674 | #Get current object |
|
825 | #Get current object | |
675 | thisPUObj = thisPUConfObj.getProcUnitObj() |
|
826 | thisPUObj = thisPUConfObj.getProcUnitObj() | |
676 |
|
827 | |||
677 | self.__connect(puObjIN, thisPUObj) |
|
828 | self.__connect(puObjIN, thisPUObj) | |
678 |
|
829 | |||
679 | def run(self): |
|
830 | def run(self): | |
680 |
|
831 | |||
681 | # for readUnitConfObj in self.readUnitConfObjList: |
|
832 | # for readUnitConfObj in self.readUnitConfObjList: | |
682 | # readUnitConfObj.run() |
|
833 | # readUnitConfObj.run() | |
683 |
|
834 | |||
684 | print "*"*40 |
|
835 | print "*"*40 | |
685 | print " Starting SIGNAL CHAIN PROCESSING " |
|
836 | print " Starting SIGNAL CHAIN PROCESSING " | |
686 | print "*"*40 |
|
837 | print "*"*40 | |
687 |
|
838 | |||
688 |
|
839 | |||
689 | keyList = self.procUnitConfObjDict.keys() |
|
840 | keyList = self.procUnitConfObjDict.keys() | |
690 | keyList.sort() |
|
841 | keyList.sort() | |
691 |
|
842 | |||
692 | while(True): |
|
843 | while(True): | |
693 |
|
844 | |||
694 | finalSts = False |
|
845 | finalSts = False | |
695 |
|
846 | |||
696 | for procKey in keyList: |
|
847 | for procKey in keyList: | |
697 | # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id) |
|
848 | # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id) | |
698 |
|
849 | |||
699 | procUnitConfObj = self.procUnitConfObjDict[procKey] |
|
850 | procUnitConfObj = self.procUnitConfObjDict[procKey] | |
700 | sts = procUnitConfObj.run() |
|
851 | sts = procUnitConfObj.run() | |
701 | finalSts = finalSts or sts |
|
852 | finalSts = finalSts or sts | |
702 |
|
853 | |||
703 | #If every process unit finished so end process |
|
854 | #If every process unit finished so end process | |
704 | if not(finalSts): |
|
855 | if not(finalSts): | |
705 | print "Every process unit have finished" |
|
856 | print "Every process unit have finished" | |
706 | break |
|
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 | #Closing every process |
|
875 | #Closing every process | |
709 | for procKey in keyList: |
|
876 | for procKey in keyList: | |
710 | procUnitConfObj = self.procUnitConfObjDict[procKey] |
|
877 | procUnitConfObj = self.procUnitConfObjDict[procKey] | |
711 | procUnitConfObj.close() |
|
878 | procUnitConfObj.close() | |
|
879 | ||||
|
880 | print "Process stopped" | |||
712 |
|
881 | |||
713 | def start(self, filename): |
|
882 | def start(self, filename): | |
714 |
|
883 | |||
715 | self.writeXml(filename) |
|
884 | self.writeXml(filename) | |
716 | self.readXml(filename) |
|
885 | self.readXml(filename) | |
717 |
|
886 | |||
718 | self.createObjects() |
|
887 | self.createObjects() | |
719 | self.connectObjects() |
|
888 | self.connectObjects() | |
720 | self.run() |
|
889 | self.run() | |
721 |
|
890 | |||
722 | if __name__ == '__main__': |
|
891 | if __name__ == '__main__': | |
723 |
|
892 | |||
724 | desc = "Segundo Test" |
|
893 | desc = "Segundo Test" | |
725 | filename = "schain.xml" |
|
894 | filename = "schain.xml" | |
726 |
|
895 | |||
727 | controllerObj = Project() |
|
896 | controllerObj = Project() | |
728 |
|
897 | |||
729 | controllerObj.setup(id = '191', name='test01', description=desc) |
|
898 | controllerObj.setup(id = '191', name='test01', description=desc) | |
730 |
|
899 | |||
731 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', |
|
900 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', | |
732 | path='data/rawdata/', |
|
901 | path='data/rawdata/', | |
733 | startDate='2011/01/01', |
|
902 | startDate='2011/01/01', | |
734 | endDate='2012/12/31', |
|
903 | endDate='2012/12/31', | |
735 | startTime='00:00:00', |
|
904 | startTime='00:00:00', | |
736 | endTime='23:59:59', |
|
905 | endTime='23:59:59', | |
737 | online=1, |
|
906 | online=1, | |
738 | walk=1) |
|
907 | walk=1) | |
739 |
|
908 | |||
740 | # opObj00 = readUnitConfObj.addOperation(name='printInfo') |
|
909 | # opObj00 = readUnitConfObj.addOperation(name='printInfo') | |
741 |
|
910 | |||
742 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) |
|
911 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |
743 |
|
912 | |||
744 | opObj10 = procUnitConfObj0.addOperation(name='selectChannels') |
|
913 | opObj10 = procUnitConfObj0.addOperation(name='selectChannels') | |
745 | opObj10.addParameter(name='channelList', value='3,4,5', format='intlist') |
|
914 | opObj10.addParameter(name='channelList', value='3,4,5', format='intlist') | |
746 |
|
915 | |||
747 | opObj10 = procUnitConfObj0.addOperation(name='selectHeights') |
|
916 | opObj10 = procUnitConfObj0.addOperation(name='selectHeights') | |
748 | opObj10.addParameter(name='minHei', value='90', format='float') |
|
917 | opObj10.addParameter(name='minHei', value='90', format='float') | |
749 | opObj10.addParameter(name='maxHei', value='180', format='float') |
|
918 | opObj10.addParameter(name='maxHei', value='180', format='float') | |
750 |
|
919 | |||
751 | opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='external') |
|
920 | opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='external') | |
752 | opObj12.addParameter(name='n', value='10', format='int') |
|
921 | opObj12.addParameter(name='n', value='10', format='int') | |
753 |
|
922 | |||
754 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) |
|
923 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) | |
755 | procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int') |
|
924 | procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int') | |
756 | # procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='') |
|
925 | # procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='') | |
757 |
|
926 | |||
758 |
|
927 | |||
759 | opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') |
|
928 | opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') | |
760 | opObj11.addParameter(name='idfigure', value='1', format='int') |
|
929 | opObj11.addParameter(name='idfigure', value='1', format='int') | |
761 | opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str') |
|
930 | opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str') | |
762 | opObj11.addParameter(name='zmin', value='40', format='int') |
|
931 | opObj11.addParameter(name='zmin', value='40', format='int') | |
763 | opObj11.addParameter(name='zmax', value='90', format='int') |
|
932 | opObj11.addParameter(name='zmax', value='90', format='int') | |
764 | opObj11.addParameter(name='showprofile', value='1', format='int') |
|
933 | opObj11.addParameter(name='showprofile', value='1', format='int') | |
765 |
|
934 | |||
766 | # opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='external') |
|
935 | # opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='external') | |
767 | # opObj11.addParameter(name='idfigure', value='2', format='int') |
|
936 | # opObj11.addParameter(name='idfigure', value='2', format='int') | |
768 | # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str') |
|
937 | # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str') | |
769 | # opObj11.addParameter(name='zmin', value='40', format='int') |
|
938 | # opObj11.addParameter(name='zmin', value='40', format='int') | |
770 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
939 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
771 |
|
940 | |||
772 |
|
941 | |||
773 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Voltage', inputId=procUnitConfObj0.getId()) |
|
942 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Voltage', inputId=procUnitConfObj0.getId()) | |
774 | # |
|
943 | # | |
775 | # opObj12 = procUnitConfObj2.addOperation(name='CohInt', optype='external') |
|
944 | # opObj12 = procUnitConfObj2.addOperation(name='CohInt', optype='external') | |
776 | # opObj12.addParameter(name='n', value='2', format='int') |
|
945 | # opObj12.addParameter(name='n', value='2', format='int') | |
777 | # opObj12.addParameter(name='overlapping', value='1', format='int') |
|
946 | # opObj12.addParameter(name='overlapping', value='1', format='int') | |
778 | # |
|
947 | # | |
779 | # procUnitConfObj3 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj2.getId()) |
|
948 | # procUnitConfObj3 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj2.getId()) | |
780 | # procUnitConfObj3.addParameter(name='nFFTPoints', value='32', format='int') |
|
949 | # procUnitConfObj3.addParameter(name='nFFTPoints', value='32', format='int') | |
781 | # |
|
950 | # | |
782 | # opObj11 = procUnitConfObj3.addOperation(name='SpectraPlot', optype='external') |
|
951 | # opObj11 = procUnitConfObj3.addOperation(name='SpectraPlot', optype='external') | |
783 | # opObj11.addParameter(name='idfigure', value='2', format='int') |
|
952 | # opObj11.addParameter(name='idfigure', value='2', format='int') | |
784 | # opObj11.addParameter(name='wintitle', value='SpectraPlot1', format='str') |
|
953 | # opObj11.addParameter(name='wintitle', value='SpectraPlot1', format='str') | |
785 | # opObj11.addParameter(name='zmin', value='40', format='int') |
|
954 | # opObj11.addParameter(name='zmin', value='40', format='int') | |
786 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
955 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
787 | # opObj11.addParameter(name='showprofile', value='1', format='int') |
|
956 | # opObj11.addParameter(name='showprofile', value='1', format='int') | |
788 |
|
957 | |||
789 | # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='external') |
|
958 | # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='external') | |
790 | # opObj11.addParameter(name='idfigure', value='10', format='int') |
|
959 | # opObj11.addParameter(name='idfigure', value='10', format='int') | |
791 | # opObj11.addParameter(name='wintitle', value='RTI', format='str') |
|
960 | # opObj11.addParameter(name='wintitle', value='RTI', format='str') | |
792 | ## opObj11.addParameter(name='xmin', value='21', format='float') |
|
961 | ## opObj11.addParameter(name='xmin', value='21', format='float') | |
793 | ## opObj11.addParameter(name='xmax', value='22', format='float') |
|
962 | ## opObj11.addParameter(name='xmax', value='22', format='float') | |
794 | # opObj11.addParameter(name='zmin', value='40', format='int') |
|
963 | # opObj11.addParameter(name='zmin', value='40', format='int') | |
795 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
964 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
796 | # opObj11.addParameter(name='showprofile', value='1', format='int') |
|
965 | # opObj11.addParameter(name='showprofile', value='1', format='int') | |
797 | # opObj11.addParameter(name='timerange', value=str(60), format='int') |
|
966 | # opObj11.addParameter(name='timerange', value=str(60), format='int') | |
798 |
|
967 | |||
799 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') |
|
968 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') | |
800 | # opObj10.addParameter(name='channelList', value='0,2,4,6', format='intlist') |
|
969 | # opObj10.addParameter(name='channelList', value='0,2,4,6', format='intlist') | |
801 | # |
|
970 | # | |
802 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='external') |
|
971 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='external') | |
803 | # opObj12.addParameter(name='n', value='2', format='int') |
|
972 | # opObj12.addParameter(name='n', value='2', format='int') | |
804 | # |
|
973 | # | |
805 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') |
|
974 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') | |
806 | # opObj11.addParameter(name='idfigure', value='2', format='int') |
|
975 | # opObj11.addParameter(name='idfigure', value='2', format='int') | |
807 | # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') |
|
976 | # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') | |
808 | # opObj11.addParameter(name='zmin', value='70', format='int') |
|
977 | # opObj11.addParameter(name='zmin', value='70', format='int') | |
809 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
978 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
810 | # |
|
979 | # | |
811 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') |
|
980 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') | |
812 | # opObj10.addParameter(name='channelList', value='2,6', format='intlist') |
|
981 | # opObj10.addParameter(name='channelList', value='2,6', format='intlist') | |
813 | # |
|
982 | # | |
814 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='external') |
|
983 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='external') | |
815 | # opObj12.addParameter(name='n', value='2', format='int') |
|
984 | # opObj12.addParameter(name='n', value='2', format='int') | |
816 | # |
|
985 | # | |
817 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') |
|
986 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') | |
818 | # opObj11.addParameter(name='idfigure', value='3', format='int') |
|
987 | # opObj11.addParameter(name='idfigure', value='3', format='int') | |
819 | # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') |
|
988 | # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') | |
820 | # opObj11.addParameter(name='zmin', value='70', format='int') |
|
989 | # opObj11.addParameter(name='zmin', value='70', format='int') | |
821 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
990 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
822 |
|
991 | |||
823 |
|
992 | |||
824 | # opObj12 = procUnitConfObj1.addOperation(name='decoder') |
|
993 | # opObj12 = procUnitConfObj1.addOperation(name='decoder') | |
825 | # opObj12.addParameter(name='ncode', value='2', format='int') |
|
994 | # opObj12.addParameter(name='ncode', value='2', format='int') | |
826 | # opObj12.addParameter(name='nbauds', value='8', format='int') |
|
995 | # opObj12.addParameter(name='nbauds', value='8', format='int') | |
827 | # opObj12.addParameter(name='code0', value='001110011', format='int') |
|
996 | # opObj12.addParameter(name='code0', value='001110011', format='int') | |
828 | # opObj12.addParameter(name='code1', value='001110011', format='int') |
|
997 | # opObj12.addParameter(name='code1', value='001110011', format='int') | |
829 |
|
998 | |||
830 |
|
999 | |||
831 |
|
1000 | |||
832 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj1.getId()) |
|
1001 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj1.getId()) | |
833 | # |
|
1002 | # | |
834 | # opObj21 = procUnitConfObj2.addOperation(name='IncohInt', optype='external') |
|
1003 | # opObj21 = procUnitConfObj2.addOperation(name='IncohInt', optype='external') | |
835 | # opObj21.addParameter(name='n', value='2', format='int') |
|
1004 | # opObj21.addParameter(name='n', value='2', format='int') | |
836 | # |
|
1005 | # | |
837 | # opObj11 = procUnitConfObj2.addOperation(name='SpectraPlot', optype='external') |
|
1006 | # opObj11 = procUnitConfObj2.addOperation(name='SpectraPlot', optype='external') | |
838 | # opObj11.addParameter(name='idfigure', value='4', format='int') |
|
1007 | # opObj11.addParameter(name='idfigure', value='4', format='int') | |
839 | # opObj11.addParameter(name='wintitle', value='SpectraPlot OBJ 2', format='str') |
|
1008 | # opObj11.addParameter(name='wintitle', value='SpectraPlot OBJ 2', format='str') | |
840 | # opObj11.addParameter(name='zmin', value='70', format='int') |
|
1009 | # opObj11.addParameter(name='zmin', value='70', format='int') | |
841 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
1010 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
842 |
|
1011 | |||
843 | print "Escribiendo el archivo XML" |
|
1012 | print "Escribiendo el archivo XML" | |
844 |
|
1013 | |||
845 | controllerObj.writeXml(filename) |
|
1014 | controllerObj.writeXml(filename) | |
846 |
|
1015 | |||
847 | print "Leyendo el archivo XML" |
|
1016 | print "Leyendo el archivo XML" | |
848 | controllerObj.readXml(filename) |
|
1017 | controllerObj.readXml(filename) | |
849 | #controllerObj.printattr() |
|
1018 | #controllerObj.printattr() | |
850 |
|
1019 | |||
851 | controllerObj.createObjects() |
|
1020 | controllerObj.createObjects() | |
852 | controllerObj.connectObjects() |
|
1021 | controllerObj.connectObjects() | |
853 | controllerObj.run() |
|
1022 | controllerObj.run() | |
854 |
|
1023 | |||
855 | No newline at end of file |
|
1024 |
@@ -1,1 +0,0 | |||||
1 | from figure import * No newline at end of file |
|
@@ -1,30 +1,29 | |||||
1 | #!/usr/bin/python |
|
1 | ||
2 | # -*- coding: utf-8 -*-' |
|
|||
3 | import sys |
|
2 | import sys | |
4 | from PyQt4 import QtCore, QtGui |
|
3 | from PyQt4 import QtCore, QtGui | |
5 | from PyQt4.QtGui import QApplication |
|
4 | from PyQt4.QtGui import QApplication | |
6 | #from PyQt4.QtCore import pyqtSignature |
|
5 | #from PyQt4.QtCore import pyqtSignature | |
7 |
|
6 | |||
8 | from viewcontroller.initwindow import InitWindow |
|
7 | from viewcontroller.initwindow import InitWindow | |
9 | from viewcontroller.basicwindow import BasicWindow |
|
8 | from viewcontroller.basicwindow import BasicWindow | |
10 | from viewcontroller.workspace import Workspace |
|
9 | from viewcontroller.workspace import Workspace | |
11 |
|
10 | |||
12 | def main(): |
|
11 | def main(): | |
13 | import sys |
|
12 | import sys | |
14 | app = QtGui.QApplication(sys.argv) |
|
13 | app = QtGui.QApplication(sys.argv) | |
15 |
|
14 | |||
16 | Welcome=InitWindow() |
|
15 | Welcome=InitWindow() | |
17 | if not Welcome.exec_(): |
|
16 | if not Welcome.exec_(): | |
18 | sys.exit(-1) |
|
17 | sys.exit(-1) | |
19 |
|
18 | |||
20 | WorkPathspace=Workspace() |
|
19 | WorkPathspace=Workspace() | |
21 | if not WorkPathspace.exec_(): |
|
20 | if not WorkPathspace.exec_(): | |
22 | sys.exit(-1) |
|
21 | sys.exit(-1) | |
23 |
|
22 | |||
24 | MainGUI=BasicWindow() |
|
23 | MainGUI=BasicWindow() | |
25 | MainGUI.setWorkSpaceGUI(WorkPathspace.dirComBox.currentText()) |
|
24 | MainGUI.setWorkSpaceGUI(WorkPathspace.dirComBox.currentText()) | |
26 | MainGUI.show() |
|
25 | MainGUI.show() | |
27 | sys.exit(app.exec_()) |
|
26 | sys.exit(app.exec_()) | |
28 |
|
27 | |||
29 | if __name__ == "__main__": |
|
28 | if __name__ == "__main__": | |
30 | main() No newline at end of file |
|
29 | main() |
@@ -1,1 +0,0 | |||||
1 | from viewcontroller import * No newline at end of file |
|
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
@@ -1,42 +1,42 | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | """ |
|
3 | """ | |
4 | Module implementing InitWindow. |
|
4 | Module implementing InitWindow. | |
5 | """ |
|
5 | """ | |
6 |
|
6 | |||
7 | from PyQt4.QtGui import QDialog |
|
7 | from PyQt4.QtGui import QDialog | |
8 | from PyQt4.QtCore import pyqtSignature |
|
8 | from PyQt4.QtCore import pyqtSignature | |
9 | from PyQt4 import QtCore |
|
9 | from PyQt4 import QtCore | |
10 | from PyQt4 import QtGui |
|
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 | class InitWindow(QDialog, Ui_InitWindow): |
|
14 | class InitWindow(QDialog, Ui_InitWindow): | |
15 | """ |
|
15 | """ | |
16 | Class documentation goes here. |
|
16 | Class documentation goes here. | |
17 | """ |
|
17 | """ | |
18 | def __init__(self, parent = None): |
|
18 | def __init__(self, parent = None): | |
19 | """ |
|
19 | """ | |
20 | Constructor |
|
20 | Constructor | |
21 | """ |
|
21 | """ | |
22 | QDialog.__init__(self, parent) |
|
22 | QDialog.__init__(self, parent) | |
23 | self.setupUi(self) |
|
23 | self.setupUi(self) | |
24 | self.setWindowTitle("ROJ-Signal Chain") |
|
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 | @pyqtSignature("") |
|
27 | @pyqtSignature("") | |
28 | def on_ExitBtn_clicked(self): |
|
28 | def on_ExitBtn_clicked(self): | |
29 | """ |
|
29 | """ | |
30 | Exit cierra la ventana de Bienvenida |
|
30 | Exit cierra la ventana de Bienvenida | |
31 | """ |
|
31 | """ | |
32 | self.close() |
|
32 | self.close() | |
33 |
|
33 | |||
34 | @pyqtSignature("") |
|
34 | @pyqtSignature("") | |
35 | def on_ContinueBtn_clicked(self): |
|
35 | def on_ContinueBtn_clicked(self): | |
36 | """ |
|
36 | """ | |
37 | Continue cierra la ventana de Bienvenida, a este evento se le complementa con la accion |
|
37 | Continue cierra la ventana de Bienvenida, a este evento se le complementa con la accion | |
38 | conectar con la ventana de configuracion de Workspace |
|
38 | conectar con la ventana de configuracion de Workspace | |
39 | """ |
|
39 | """ | |
40 | # TODO: not implemented yet |
|
40 | # TODO: not implemented yet | |
41 | #raise NotImplementedError |
|
41 | #raise NotImplementedError | |
42 | self.accept() |
|
42 | self.accept() |
@@ -1,633 +1,632 | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ |
|
2 | """ | |
3 | Module implementing MainWindow. |
|
3 | Module implementing MainWindow. | |
4 | #+++++++++++++++++++++INTERFAZ DE USUARIO V1.1++++++++++++++++++++++++# |
|
4 | #+++++++++++++++++++++INTERFAZ DE USUARIO V1.1++++++++++++++++++++++++# | |
5 | """ |
|
5 | """ | |
6 | from PyQt4.QtGui import QMainWindow |
|
6 | from PyQt4.QtGui import QMainWindow | |
7 | from PyQt4.QtCore import pyqtSignature |
|
7 | from PyQt4.QtCore import pyqtSignature | |
8 | from PyQt4.QtCore import pyqtSignal |
|
8 | from PyQt4.QtCore import pyqtSignal | |
9 | from PyQt4 import QtCore |
|
9 | from PyQt4 import QtCore | |
10 | from PyQt4 import QtGui |
|
10 | from PyQt4 import QtGui | |
11 | from timeconversions import Doy2Date |
|
11 | from timeconversions import Doy2Date | |
12 | from modelProperties import treeModel |
|
12 | from modelProperties import treeModel | |
13 |
|
13 | |||
14 | from viewer.ui_unitprocess import Ui_UnitProcess |
|
14 | from schainpy.gui.viewer.ui_unitprocess import Ui_UnitProcess | |
15 | from viewer.ui_window import Ui_window |
|
15 | from schainpy.gui.viewer.ui_window import Ui_window | |
16 | from viewer.ui_mainwindow import Ui_MainWindow |
|
16 | from schainpy.gui.viewer.ui_mainwindow import Ui_MainWindow | |
17 |
|
17 | |||
18 |
|
18 | from schainpy.controller import Project,ReadUnitConf,ProcUnitConf,OperationConf,ParameterConf | ||
19 | from controller import Project,ReadUnitConf,ProcUnitConf,OperationConf,ParameterConf |
|
|||
20 | import os |
|
19 | import os | |
21 |
|
20 | |||
22 |
|
21 | |||
23 | class BodyMainWindow(QMainWindow, Ui_MainWindow): |
|
22 | class BodyMainWindow(QMainWindow, Ui_MainWindow): | |
24 | __projObjDict = {} |
|
23 | __projObjDict = {} | |
25 | __arbolDict = {} |
|
24 | __arbolDict = {} | |
26 | __upObjDict = {} |
|
25 | __upObjDict = {} | |
27 |
|
26 | |||
28 | """ |
|
27 | """ | |
29 | Class documentation goes here. |
|
28 | Class documentation goes here. | |
30 | #*##################VENTANA CUERPO DEL PROGRAMA#################### |
|
29 | #*##################VENTANA CUERPO DEL PROGRAMA#################### | |
31 | """ |
|
30 | """ | |
32 | def __init__(self, parent = None): |
|
31 | def __init__(self, parent = None): | |
33 | """ |
|
32 | """ | |
34 | Constructor |
|
33 | Constructor | |
35 | """ |
|
34 | """ | |
36 | print "Inicio de Programa Interfaz Gráfica" |
|
35 | print "Inicio de Programa Interfaz Gráfica" | |
37 | QMainWindow.__init__(self, parent) |
|
36 | QMainWindow.__init__(self, parent) | |
38 | self.setupUi(self) |
|
37 | self.setupUi(self) | |
39 |
|
38 | |||
40 | self.indexclick=None |
|
39 | self.indexclick=None | |
41 |
|
40 | |||
42 | self.online=0 |
|
41 | self.online=0 | |
43 | self.datatype=0 |
|
42 | self.datatype=0 | |
44 | self.variableList=[] |
|
43 | self.variableList=[] | |
45 |
|
44 | |||
46 | self.proObjList=[] |
|
45 | self.proObjList=[] | |
47 | self.idp=0 |
|
46 | self.idp=0 | |
48 | self.namep=0 |
|
47 | self.namep=0 | |
49 | self.description=0 |
|
48 | self.description=0 | |
50 | self.namepTree=0 |
|
49 | self.namepTree=0 | |
51 | self.valuep=0 |
|
50 | self.valuep=0 | |
52 |
|
51 | |||
53 | self.upObjList= [] |
|
52 | self.upObjList= [] | |
54 | self.upn=0 |
|
53 | self.upn=0 | |
55 | self.upName=0 |
|
54 | self.upName=0 | |
56 | self.upType=0 |
|
55 | self.upType=0 | |
57 | self.uporProObjRecover=0 |
|
56 | self.uporProObjRecover=0 | |
58 |
|
57 | |||
59 | self.readUnitConfObjList=[] |
|
58 | self.readUnitConfObjList=[] | |
60 |
|
59 | |||
61 | self.upObjVolList=[] |
|
60 | self.upObjVolList=[] | |
62 | self.upobjSpecList=[] |
|
61 | self.upobjSpecList=[] | |
63 |
|
62 | |||
64 | self.operObjList=[] |
|
63 | self.operObjList=[] | |
65 |
|
64 | |||
66 | self.configProject=None |
|
65 | self.configProject=None | |
67 | self.configUP=None |
|
66 | self.configUP=None | |
68 |
|
67 | |||
69 | self.readUnitConfObj=None |
|
68 | self.readUnitConfObj=None | |
70 | self.procUnitConfObj0=None |
|
69 | self.procUnitConfObj0=None | |
71 | self.opObj10=None |
|
70 | self.opObj10=None | |
72 | self.opObj12=None |
|
71 | self.opObj12=None | |
73 |
|
72 | |||
74 | self.setParam() |
|
73 | self.setParam() | |
75 |
|
74 | |||
76 | #-----------------------------------NEW PROPERTIES------------------------------------------------# |
|
75 | #-----------------------------------NEW PROPERTIES------------------------------------------------# | |
77 | QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10)) |
|
76 | QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10)) | |
78 | self.addprojectBtn.setToolTip('Add_New_Project') |
|
77 | self.addprojectBtn.setToolTip('Add_New_Project') | |
79 | self.addUnitProces.setToolTip('Add_New_Processing_Unit') |
|
78 | self.addUnitProces.setToolTip('Add_New_Processing_Unit') | |
80 |
|
79 | |||
81 | #-----------------------------------NEW PROPERTIES------------------------------------------------# |
|
80 | #-----------------------------------NEW PROPERTIES------------------------------------------------# | |
82 | self.model = QtGui.QStandardItemModel() |
|
81 | self.model = QtGui.QStandardItemModel() | |
83 | self.treeView.setModel(self.model) |
|
82 | self.treeView.setModel(self.model) | |
84 | self.treeView.clicked.connect(self.clickFunctiontree) |
|
83 | self.treeView.clicked.connect(self.clickFunctiontree) | |
85 | self.treeView.expandAll() |
|
84 | self.treeView.expandAll() | |
86 | #self.treeView.clicked.connect(self.treefunction1) |
|
85 | #self.treeView.clicked.connect(self.treefunction1) | |
87 |
|
86 | |||
88 | #-----------------------------------BARRA DE MENU-------------------------------------------------# |
|
87 | #-----------------------------------BARRA DE MENU-------------------------------------------------# | |
89 |
|
88 | |||
90 | #----------------------------------- MENU_PROJECT--------------------------------------------------# |
|
89 | #----------------------------------- MENU_PROJECT--------------------------------------------------# | |
91 |
|
90 | |||
92 | @pyqtSignature("") |
|
91 | @pyqtSignature("") | |
93 | def on_menuFileAbrirObj_triggered(self): |
|
92 | def on_menuFileAbrirObj_triggered(self): | |
94 | """ |
|
93 | """ | |
95 | Abre un archivo de configuracion seleccionado, lee los parametros y |
|
94 | Abre un archivo de configuracion seleccionado, lee los parametros y | |
96 | actualiza los atributos de esta clase; creando los objetos necesarios |
|
95 | actualiza los atributos de esta clase; creando los objetos necesarios | |
97 | con los parametros leidos desde el archivo. |
|
96 | con los parametros leidos desde el archivo. | |
98 | """ |
|
97 | """ | |
99 | print "Leer un archivo xml y extraer sus atributos Not implemented yet" |
|
98 | print "Leer un archivo xml y extraer sus atributos Not implemented yet" | |
100 |
|
99 | |||
101 | @pyqtSignature("") |
|
100 | @pyqtSignature("") | |
102 | def on_menuFileCrearObj_triggered(self): |
|
101 | def on_menuFileCrearObj_triggered(self): | |
103 | """ |
|
102 | """ | |
104 | Crea un proyecto nuevo y lo anade a mi diccionario de proyectos |
|
103 | Crea un proyecto nuevo y lo anade a mi diccionario de proyectos | |
105 | y habilita la ventana de configuracion del proyecto. |
|
104 | y habilita la ventana de configuracion del proyecto. | |
106 |
|
105 | |||
107 | """ |
|
106 | """ | |
108 | self.addProject() |
|
107 | self.addProject() | |
109 |
|
108 | |||
110 | @pyqtSignature("") |
|
109 | @pyqtSignature("") | |
111 | def on_menuFileGuardarObj_triggered(self): |
|
110 | def on_menuFileGuardarObj_triggered(self): | |
112 | """ |
|
111 | """ | |
113 | METODO EJECUTADO CUANDO OCURRE EL EVENTO GUARDAR PROJECTO |
|
112 | METODO EJECUTADO CUANDO OCURRE EL EVENTO GUARDAR PROJECTO | |
114 |
|
113 | |||
115 | Llama al metodo saveProject. |
|
114 | Llama al metodo saveProject. | |
116 | """ |
|
115 | """ | |
117 | # my_id = arbol_selected() |
|
116 | # my_id = arbol_selected() | |
118 | # filename = savefindow.show() |
|
117 | # filename = savefindow.show() | |
119 | # self.saveProject(id, filename) |
|
118 | # self.saveProject(id, filename) | |
120 | print "probsave" |
|
119 | print "probsave" | |
121 | self.saveProject() |
|
120 | self.saveProject() | |
122 |
|
121 | |||
123 | @pyqtSignature("") |
|
122 | @pyqtSignature("") | |
124 | def on_menuFileCerrarObj_triggered(self): |
|
123 | def on_menuFileCerrarObj_triggered(self): | |
125 | """ |
|
124 | """ | |
126 | METODO EJECUTADO CUANDO OCURRE EL EVENTO CERRAR |
|
125 | METODO EJECUTADO CUANDO OCURRE EL EVENTO CERRAR | |
127 | Llama al metodo close. |
|
126 | Llama al metodo close. | |
128 | """ |
|
127 | """ | |
129 | self.close() |
|
128 | self.close() | |
130 |
|
129 | |||
131 | #-----------------------------------MENU_RUN----------------------------------------------------# |
|
130 | #-----------------------------------MENU_RUN----------------------------------------------------# | |
132 |
|
131 | |||
133 | @pyqtSignature("") |
|
132 | @pyqtSignature("") | |
134 | def on_menuRUNStartObj_clicked(self): |
|
133 | def on_menuRUNStartObj_clicked(self): | |
135 | """ |
|
134 | """ | |
136 | METODO EJECUTADO CUANDO OCURRE EL EVENTO RUN |
|
135 | METODO EJECUTADO CUANDO OCURRE EL EVENTO RUN | |
137 | Llama al metodo RUN. |
|
136 | Llama al metodo RUN. | |
138 | """ |
|
137 | """ | |
139 | print "Not implemented yet" |
|
138 | print "Not implemented yet" | |
140 |
|
139 | |||
141 | @pyqtSignature("") |
|
140 | @pyqtSignature("") | |
142 | def on_menuRUNPausaObj_clicked(self): |
|
141 | def on_menuRUNPausaObj_clicked(self): | |
143 | """ |
|
142 | """ | |
144 | METODO EJECUTADO CUANDO OCURRE EL EVENTO PAUSA |
|
143 | METODO EJECUTADO CUANDO OCURRE EL EVENTO PAUSA | |
145 | Llama al metodo PAUSA. |
|
144 | Llama al metodo PAUSA. | |
146 | """ |
|
145 | """ | |
147 | print "Not implemented yet" |
|
146 | print "Not implemented yet" | |
148 |
|
147 | |||
149 | #-----------------------------------MENU_OPTION-------------------------------------------------# |
|
148 | #-----------------------------------MENU_OPTION-------------------------------------------------# | |
150 |
|
149 | |||
151 | @pyqtSignature("") |
|
150 | @pyqtSignature("") | |
152 | def on_menuOptConfigLogfileObj_clicked(self): |
|
151 | def on_menuOptConfigLogfileObj_clicked(self): | |
153 | """ |
|
152 | """ | |
154 | METODO EJECUTADO CUANDO OCURRE EL EVENTO ConfigLog |
|
153 | METODO EJECUTADO CUANDO OCURRE EL EVENTO ConfigLog | |
155 | Llama al metodo close. |
|
154 | Llama al metodo close. | |
156 | """ |
|
155 | """ | |
157 | print "Not implemented yet" |
|
156 | print "Not implemented yet" | |
158 |
|
157 | |||
159 | @pyqtSignature("") |
|
158 | @pyqtSignature("") | |
160 | def on_menuOptConfigserverObj_clicked(self): |
|
159 | def on_menuOptConfigserverObj_clicked(self): | |
161 | """ |
|
160 | """ | |
162 | METODO EJECUTADO CUANDO OCURRE EL EVENTO Config Server |
|
161 | METODO EJECUTADO CUANDO OCURRE EL EVENTO Config Server | |
163 | Llama al metodo close. |
|
162 | Llama al metodo close. | |
164 | """ |
|
163 | """ | |
165 | print "Not implemented yet" |
|
164 | print "Not implemented yet" | |
166 | #-----------------------------------MENU_HELP-------------------------------------------------------# |
|
165 | #-----------------------------------MENU_HELP-------------------------------------------------------# | |
167 |
|
166 | |||
168 | @pyqtSignature("") |
|
167 | @pyqtSignature("") | |
169 | def on_menuHELPAboutObj_clicked(self): |
|
168 | def on_menuHELPAboutObj_clicked(self): | |
170 | """ |
|
169 | """ | |
171 | METODO EJECUTADO CUANDO OCURRE EL EVENTO HELP |
|
170 | METODO EJECUTADO CUANDO OCURRE EL EVENTO HELP | |
172 | Llama al metodo close. |
|
171 | Llama al metodo close. | |
173 | """ |
|
172 | """ | |
174 | print "Not implemented yet" |
|
173 | print "Not implemented yet" | |
175 |
|
174 | |||
176 | @pyqtSignature("") |
|
175 | @pyqtSignature("") | |
177 | def on_menuHELPPrfObj_clicked(self): |
|
176 | def on_menuHELPPrfObj_clicked(self): | |
178 | """ |
|
177 | """ | |
179 | METODO EJECUTADO CUANDO OCURRE EL EVENTO HElp |
|
178 | METODO EJECUTADO CUANDO OCURRE EL EVENTO HElp | |
180 | Llama al metodo close. |
|
179 | Llama al metodo close. | |
181 | """ |
|
180 | """ | |
182 | print "Not implemented yet" |
|
181 | print "Not implemented yet" | |
183 |
|
182 | |||
184 | #-----------------------------------BARRA DE HERRAMIENTAS----------------------------------------# |
|
183 | #-----------------------------------BARRA DE HERRAMIENTAS----------------------------------------# | |
185 |
|
184 | |||
186 | @pyqtSignature("") |
|
185 | @pyqtSignature("") | |
187 | def on_actOpenObj_triggered(self): |
|
186 | def on_actOpenObj_triggered(self): | |
188 | """ |
|
187 | """ | |
189 | METODO CARGA UN ARCHIVO DE CONFIGURACION ANTERIOR |
|
188 | METODO CARGA UN ARCHIVO DE CONFIGURACION ANTERIOR | |
190 | """ |
|
189 | """ | |
191 | print "Leer un archivo xml y extraer sus atributos Not implemented yet" |
|
190 | print "Leer un archivo xml y extraer sus atributos Not implemented yet" | |
192 |
|
191 | |||
193 | @pyqtSignature("") |
|
192 | @pyqtSignature("") | |
194 | def on_actCreateObj_triggered(self): |
|
193 | def on_actCreateObj_triggered(self): | |
195 | """ |
|
194 | """ | |
196 | CREAR PROJECT ,ANADE UN NUEVO PROYECTO, LLAMA AL MÉTODO QUE CONTIENE LAS OPERACION DE CREACION DE PROYECTOS |
|
195 | CREAR PROJECT ,ANADE UN NUEVO PROYECTO, LLAMA AL MÉTODO QUE CONTIENE LAS OPERACION DE CREACION DE PROYECTOS | |
197 | Llama al metodo addProject. |
|
196 | Llama al metodo addProject. | |
198 | """ |
|
197 | """ | |
199 | self.addProject() |
|
198 | self.addProject() | |
200 |
|
199 | |||
201 | @pyqtSignature("") |
|
200 | @pyqtSignature("") | |
202 | def on_actStopObj_triggered(self): |
|
201 | def on_actStopObj_triggered(self): | |
203 | """ |
|
202 | """ | |
204 | METODO EJECUTADO CUANDO OCURRE EL EVENTO PAUSA |
|
203 | METODO EJECUTADO CUANDO OCURRE EL EVENTO PAUSA | |
205 | Llama al metodo PAUSA. |
|
204 | Llama al metodo PAUSA. | |
206 | """ |
|
205 | """ | |
207 | print "Not implemented yet" |
|
206 | print "Not implemented yet" | |
208 |
|
207 | |||
209 | @pyqtSignature("") |
|
208 | @pyqtSignature("") | |
210 | def on_actPlayObj_triggered(self): |
|
209 | def on_actPlayObj_triggered(self): | |
211 | """ |
|
210 | """ | |
212 | METODO EJECUTADO CUANDO OCURRE EL EVENTO PAUSA |
|
211 | METODO EJECUTADO CUANDO OCURRE EL EVENTO PAUSA | |
213 | Llama al metodo PAUSA. |
|
212 | Llama al metodo PAUSA. | |
214 | """ |
|
213 | """ | |
215 | print "Not implemented yet" |
|
214 | print "Not implemented yet" | |
216 |
|
215 | |||
217 | @pyqtSignature("") |
|
216 | @pyqtSignature("") | |
218 | def on_actSaveObj_triggered(self): |
|
217 | def on_actSaveObj_triggered(self): | |
219 | """ |
|
218 | """ | |
220 | METODO EJECUTADO CUANDO OCURRE EL EVENTO SAVE |
|
219 | METODO EJECUTADO CUANDO OCURRE EL EVENTO SAVE | |
221 | Llama al metodo SAVE. |
|
220 | Llama al metodo SAVE. | |
222 | """ |
|
221 | """ | |
223 | self.saveProject() |
|
222 | self.saveProject() | |
224 |
|
223 | |||
225 | #-----------------------------------PUSHBUTTON_CREATE PROJECT----------------------------------# |
|
224 | #-----------------------------------PUSHBUTTON_CREATE PROJECT----------------------------------# | |
226 |
|
225 | |||
227 | @pyqtSignature("") |
|
226 | @pyqtSignature("") | |
228 | def on_addprojectBtn_clicked(self): |
|
227 | def on_addprojectBtn_clicked(self): | |
229 | """ |
|
228 | """ | |
230 | CREAR PROJECT ,ANADE UN NUEVO PROYECTO, LLAMA AL MÉTODO QUE CONTIENE LAS OPERACION DE CREACION DE PROYECTOS |
|
229 | CREAR PROJECT ,ANADE UN NUEVO PROYECTO, LLAMA AL MÉTODO QUE CONTIENE LAS OPERACION DE CREACION DE PROYECTOS | |
231 | Llama al metodo addProject. |
|
230 | Llama al metodo addProject. | |
232 | """ |
|
231 | """ | |
233 | self.addProject() |
|
232 | self.addProject() | |
234 |
|
233 | |||
235 | #------------------------------------VENTANA CONFIGURACION PROJECT----------------------------# |
|
234 | #------------------------------------VENTANA CONFIGURACION PROJECT----------------------------# | |
236 |
|
235 | |||
237 | @pyqtSignature("int") |
|
236 | @pyqtSignature("int") | |
238 | def on_dataTypeCmbBox_activated(self,index): |
|
237 | def on_dataTypeCmbBox_activated(self,index): | |
239 | """ |
|
238 | """ | |
240 | Metodo que identifica que tipo de dato se va a trabajar VOLTAGE O ESPECTRA |
|
239 | Metodo que identifica que tipo de dato se va a trabajar VOLTAGE O ESPECTRA | |
241 | """ |
|
240 | """ | |
242 | self.dataFormatTxt.setReadOnly(True) |
|
241 | self.dataFormatTxt.setReadOnly(True) | |
243 | if index==0: |
|
242 | if index==0: | |
244 | self.datatype='Voltage' |
|
243 | self.datatype='Voltage' | |
245 | elif index==1: |
|
244 | elif index==1: | |
246 | self.datatype='Spectra' |
|
245 | self.datatype='Spectra' | |
247 | else : |
|
246 | else : | |
248 | self.datatype='' |
|
247 | self.datatype='' | |
249 | self.dataFormatTxt.setReadOnly(False) |
|
248 | self.dataFormatTxt.setReadOnly(False) | |
250 | self.dataFormatTxt.setText(self.datatype) |
|
249 | self.dataFormatTxt.setText(self.datatype) | |
251 |
|
250 | |||
252 | @pyqtSignature("") |
|
251 | @pyqtSignature("") | |
253 | def on_dataPathBrowse_clicked(self): |
|
252 | def on_dataPathBrowse_clicked(self): | |
254 | """ |
|
253 | """ | |
255 | OBTENCION DE LA RUTA DE DATOS |
|
254 | OBTENCION DE LA RUTA DE DATOS | |
256 | """ |
|
255 | """ | |
257 | self.dataPath = str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)) |
|
256 | self.dataPath = str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)) | |
258 | self.dataPathTxt.setText(self.dataPath) |
|
257 | self.dataPathTxt.setText(self.dataPath) | |
259 | self.statusDpath=self.existDir(self.dataPath) |
|
258 | self.statusDpath=self.existDir(self.dataPath) | |
260 | self.loadDays() |
|
259 | self.loadDays() | |
261 |
|
260 | |||
262 | @pyqtSignature("int") |
|
261 | @pyqtSignature("int") | |
263 | def on_starDateCmbBox_activated(self, index): |
|
262 | def on_starDateCmbBox_activated(self, index): | |
264 | """ |
|
263 | """ | |
265 | SELECCION DEL RANGO DE FECHAS -START DATE |
|
264 | SELECCION DEL RANGO DE FECHAS -START DATE | |
266 | """ |
|
265 | """ | |
267 | var_StopDay_index=self.endDateCmbBox.count() - self.endDateCmbBox.currentIndex() |
|
266 | var_StopDay_index=self.endDateCmbBox.count() - self.endDateCmbBox.currentIndex() | |
268 | self.endDateCmbBox.clear() |
|
267 | self.endDateCmbBox.clear() | |
269 | for i in self.variableList[index:]: |
|
268 | for i in self.variableList[index:]: | |
270 | self.endDateCmbBox.addItem(i) |
|
269 | self.endDateCmbBox.addItem(i) | |
271 | self.endDateCmbBox.setCurrentIndex(self.endDateCmbBox.count() - var_StopDay_index) |
|
270 | self.endDateCmbBox.setCurrentIndex(self.endDateCmbBox.count() - var_StopDay_index) | |
272 | self.getsubList() |
|
271 | self.getsubList() | |
273 |
|
272 | |||
274 | @pyqtSignature("int") |
|
273 | @pyqtSignature("int") | |
275 | def on_endDateCmbBox_activated(self, index): |
|
274 | def on_endDateCmbBox_activated(self, index): | |
276 | """ |
|
275 | """ | |
277 | SELECCION DEL RANGO DE FECHAS-END DATE |
|
276 | SELECCION DEL RANGO DE FECHAS-END DATE | |
278 | """ |
|
277 | """ | |
279 | var_StartDay_index=self.starDateCmbBox.currentIndex() |
|
278 | var_StartDay_index=self.starDateCmbBox.currentIndex() | |
280 | var_end_index = self.endDateCmbBox.count() - index |
|
279 | var_end_index = self.endDateCmbBox.count() - index | |
281 | self.starDateCmbBox.clear() |
|
280 | self.starDateCmbBox.clear() | |
282 | for i in self.variableList[:len(self.variableList) - var_end_index + 1]: |
|
281 | for i in self.variableList[:len(self.variableList) - var_end_index + 1]: | |
283 | self.starDateCmbBox.addItem(i) |
|
282 | self.starDateCmbBox.addItem(i) | |
284 | self.starDateCmbBox.setCurrentIndex(var_StartDay_index) |
|
283 | self.starDateCmbBox.setCurrentIndex(var_StartDay_index) | |
285 | self.getsubList() #Se carga var_sublist[] con el rango de las fechas seleccionadas |
|
284 | self.getsubList() #Se carga var_sublist[] con el rango de las fechas seleccionadas | |
286 |
|
285 | |||
287 | @pyqtSignature("int") |
|
286 | @pyqtSignature("int") | |
288 | def on_readModeCmBox_activated(self, p0): |
|
287 | def on_readModeCmBox_activated(self, p0): | |
289 | """ |
|
288 | """ | |
290 | SELECCION DEL MODO DE LECTURA ON=1, OFF=0 |
|
289 | SELECCION DEL MODO DE LECTURA ON=1, OFF=0 | |
291 | """ |
|
290 | """ | |
292 | if p0==0: |
|
291 | if p0==0: | |
293 | self.online=0 |
|
292 | self.online=0 | |
294 | elif p0==1: |
|
293 | elif p0==1: | |
295 | self.online=1 |
|
294 | self.online=1 | |
296 |
|
295 | |||
297 | #---------------PUSHBUTTON_DATA " OKBUTTON "_CONFIGURATION PROJECT--------------------------# |
|
296 | #---------------PUSHBUTTON_DATA " OKBUTTON "_CONFIGURATION PROJECT--------------------------# | |
298 |
|
297 | |||
299 | @pyqtSignature("") |
|
298 | @pyqtSignature("") | |
300 | def on_dataOkBtn_clicked(self): |
|
299 | def on_dataOkBtn_clicked(self): | |
301 | """ |
|
300 | """ | |
302 | Añade al Obj XML de Projecto, name,datatype,date,time,readmode,wait,etc, crea el readUnitProcess del archivo xml. |
|
301 | Añade al Obj XML de Projecto, name,datatype,date,time,readmode,wait,etc, crea el readUnitProcess del archivo xml. | |
303 | Prepara la configuración del diágrama del Arbol del treeView numero 2 |
|
302 | Prepara la configuración del diágrama del Arbol del treeView numero 2 | |
304 | """ |
|
303 | """ | |
305 | print "En este nivel se pasa el tipo de dato con el que se trabaja,path,startDate,endDate,startTime,endTime,online" |
|
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 | for i in self.__arbolDict: |
|
306 | for i in self.__arbolDict: | |
308 | if self.__arbolDict[i]==self.indexclick: |
|
307 | if self.__arbolDict[i]==self.indexclick: | |
309 | self.projectObj=self.__projObjDict[int(i)] |
|
308 | self.projectObj=self.__projObjDict[int(i)] | |
310 | # print self.projectObj |
|
309 | # print self.projectObj | |
311 | # print i |
|
310 | # print i | |
312 | # print "get",self.__arbolDict.items() |
|
311 | # print "get",self.__arbolDict.items() | |
313 | # print "keys",self.__arbolDict.keys() |
|
312 | # print "keys",self.__arbolDict.keys() | |
314 | self.description="Think" |
|
313 | self.description="Think" | |
315 | id=i |
|
314 | id=i | |
316 | name=str(self.nameProjectTxt.text()) |
|
315 | name=str(self.nameProjectTxt.text()) | |
317 | desc=str(self.description) |
|
316 | desc=str(self.description) | |
318 |
|
317 | |||
319 | self.projectObj.setup(id = id, name=name, description=desc) |
|
318 | self.projectObj.setup(id = id, name=name, description=desc) | |
320 | print self.projectObj.id |
|
319 | print self.projectObj.id | |
321 | # print self.projectObj.name |
|
320 | # print self.projectObj.name | |
322 | # print self.projectObj.description |
|
321 | # print self.projectObj.description | |
323 |
|
322 | |||
324 | datatype=str(self.dataTypeCmbBox.currentText()) |
|
323 | datatype=str(self.dataTypeCmbBox.currentText()) | |
325 | path=str(self.dataPathTxt.text()) |
|
324 | path=str(self.dataPathTxt.text()) | |
326 | online=int(self.online) |
|
325 | online=int(self.online) | |
327 | starDate=str(self.starDateCmbBox.currentText()) |
|
326 | starDate=str(self.starDateCmbBox.currentText()) | |
328 | endDate=str(self.endDateCmbBox.currentText()) |
|
327 | endDate=str(self.endDateCmbBox.currentText()) | |
329 |
|
328 | |||
330 |
|
329 | |||
331 | self.readUnitConfObj = self.projectObj.addReadUnit(datatype=datatype, |
|
330 | self.readUnitConfObj = self.projectObj.addReadUnit(datatype=datatype, | |
332 | path=path, |
|
331 | path=path, | |
333 | startDate=starDate, |
|
332 | startDate=starDate, | |
334 | endDate=endDate, |
|
333 | endDate=endDate, | |
335 | startTime='06:10:00', |
|
334 | startTime='06:10:00', | |
336 | endTime='23:59:59', |
|
335 | endTime='23:59:59', | |
337 | online=online) |
|
336 | online=online) | |
338 |
|
337 | |||
339 | self.readUnitConfObjList.append(self.readUnitConfObj) |
|
338 | self.readUnitConfObjList.append(self.readUnitConfObj) | |
340 | print "self.readUnitConfObj.getId",self.readUnitConfObj.getId(),datatype,path,starDate,endDate,online |
|
339 | print "self.readUnitConfObj.getId",self.readUnitConfObj.getId(),datatype,path,starDate,endDate,online | |
341 |
|
340 | |||
342 | self.model_2=treeModel() |
|
341 | self.model_2=treeModel() | |
343 | self.model_2.setParams(name=self.projectObj.name+str(self.projectObj.id), |
|
342 | self.model_2.setParams(name=self.projectObj.name+str(self.projectObj.id), | |
344 | directorio=path, |
|
343 | directorio=path, | |
345 | workspace="C:\\WorkspaceGUI", |
|
344 | workspace="C:\\WorkspaceGUI", | |
346 | remode=str(self.readModeCmBox.currentText()), |
|
345 | remode=str(self.readModeCmBox.currentText()), | |
347 | dataformat=datatype, |
|
346 | dataformat=datatype, | |
348 | date=str(starDate)+"-"+str(endDate), |
|
347 | date=str(starDate)+"-"+str(endDate), | |
349 | initTime='06:10:00', |
|
348 | initTime='06:10:00', | |
350 | endTime='23:59:59', |
|
349 | endTime='23:59:59', | |
351 | timezone="Local" , |
|
350 | timezone="Local" , | |
352 | Summary="test de prueba") |
|
351 | Summary="test de prueba") | |
353 | self.model_2.arbol() |
|
352 | self.model_2.arbol() | |
354 | self.treeView_2.setModel(self.model_2) |
|
353 | self.treeView_2.setModel(self.model_2) | |
355 | self.treeView_2.expandAll() |
|
354 | self.treeView_2.expandAll() | |
356 |
|
355 | |||
357 | # |
|
356 | # | |
358 | #-----------------PUSHBUTTON_ADD_PROCESSING UNIT PROJECT------------------# |
|
357 | #-----------------PUSHBUTTON_ADD_PROCESSING UNIT PROJECT------------------# | |
359 | @pyqtSignature("") |
|
358 | @pyqtSignature("") | |
360 | def on_addUnitProces_clicked(self): |
|
359 | def on_addUnitProces_clicked(self): | |
361 | """ |
|
360 | """ | |
362 | CREAR PROCESSING UNI ,ANADE UNA UNIDAD DE PROCESAMIENTO, LLAMA AL MÉTODO addUP QUE CONTIENE LAS OPERACION DE CREACION DE UNIDADES DE PROCESAMIENTO |
|
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 | Llama al metodo addUP. |
|
362 | Llama al metodo addUP. | |
364 | """ |
|
363 | """ | |
365 | # print "En este nivel se adiciona una rama de procesamiento, y se le concatena con el id" |
|
364 | # print "En este nivel se adiciona una rama de procesamiento, y se le concatena con el id" | |
366 | self.addUP() |
|
365 | self.addUP() | |
367 |
|
366 | |||
368 | #----------------------------BASICO-----------------------------------# |
|
367 | #----------------------------BASICO-----------------------------------# | |
369 |
|
368 | |||
370 | def getNumberofProject(self): |
|
369 | def getNumberofProject(self): | |
371 | # for i in self.proObjList: |
|
370 | # for i in self.proObjList: | |
372 | # print i |
|
371 | # print i | |
373 | return self.proObjList |
|
372 | return self.proObjList | |
374 | # for i in self.proObjList: |
|
373 | # for i in self.proObjList: | |
375 | # print i |
|
374 | # print i | |
376 |
|
375 | |||
377 | def setParam(self): |
|
376 | def setParam(self): | |
378 |
|
377 | |||
379 | self.tabWidgetProject.setEnabled(False) |
|
378 | self.tabWidgetProject.setEnabled(False) | |
380 | self.dataPathTxt.setText('C:\data') |
|
379 | self.dataPathTxt.setText('C:\data') | |
381 | self.nameProjectTxt.setText("Test") |
|
380 | self.nameProjectTxt.setText("Test") | |
382 | self.numberChannelopVol.setEnabled(False) |
|
381 | self.numberChannelopVol.setEnabled(False) | |
383 | self.lineHeighProfileTxtopVol.setEnabled(False) |
|
382 | self.lineHeighProfileTxtopVol.setEnabled(False) | |
384 | self.numberIntegration.setEnabled(False) |
|
383 | self.numberIntegration.setEnabled(False) | |
385 | self.valuenFFTPointOpSpec.setEnabled(False) |
|
384 | self.valuenFFTPointOpSpec.setEnabled(False) | |
386 | self.lineProfileSelecopVolCEB.setEnabled(False) |
|
385 | self.lineProfileSelecopVolCEB.setEnabled(False) | |
387 |
|
386 | |||
388 | def clickFunctiontree(self,index): |
|
387 | def clickFunctiontree(self,index): | |
389 | self.indexclick= index.model().itemFromIndex(index) |
|
388 | self.indexclick= index.model().itemFromIndex(index) | |
390 | print self.indexclick |
|
389 | print self.indexclick | |
391 | return self.indexclick |
|
390 | return self.indexclick | |
392 | # self.indexclick= index.model().itemFromIndex(index).text() |
|
391 | # self.indexclick= index.model().itemFromIndex(index).text() | |
393 | # return self.indexclick |
|
392 | # return self.indexclick | |
394 | # print self.indexclick() |
|
393 | # print self.indexclick() | |
395 | # print index.model().itemFromIndex(index) |
|
394 | # print index.model().itemFromIndex(index) | |
396 | # print self.indexclick |
|
395 | # print self.indexclick | |
397 | # NumofPro=self.indexclick[8:10] |
|
396 | # NumofPro=self.indexclick[8:10] | |
398 | # self.valuep=NumofPro |
|
397 | # self.valuep=NumofPro | |
399 | # #print self.valuep |
|
398 | # #print self.valuep | |
400 | # NameofPro=self.indexclick[0:7] |
|
399 | # NameofPro=self.indexclick[0:7] | |
401 | # self.namepTree=NameofPro |
|
400 | # self.namepTree=NameofPro | |
402 | # print self.namepTree |
|
401 | # print self.namepTree | |
403 |
|
402 | |||
404 | def addProject(self): |
|
403 | def addProject(self): | |
405 | self.tabWidgetProject.setEnabled(True) |
|
404 | self.tabWidgetProject.setEnabled(True) | |
406 | print "En este nivel se debe crear el proyecto,id,nombre,desc" |
|
405 | print "En este nivel se debe crear el proyecto,id,nombre,desc" | |
407 | #+++++++++++++++++++Creacion del Objeto Controller-XML+++++++++++++# |
|
406 | #+++++++++++++++++++Creacion del Objeto Controller-XML+++++++++++++# | |
408 |
|
407 | |||
409 | self.idp += 1 |
|
408 | self.idp += 1 | |
410 | self.projectObj = Project() |
|
409 | self.projectObj = Project() | |
411 | print self.projectObj |
|
410 | print self.projectObj | |
412 | self.__projObjDict[self.idp] = self.projectObj |
|
411 | self.__projObjDict[self.idp] = self.projectObj | |
413 |
|
412 | |||
414 | #++++++++++++++++++Creación del Arbol++++++++++++++++++++# |
|
413 | #++++++++++++++++++Creación del Arbol++++++++++++++++++++# | |
415 | self.parentItem = self.model.invisibleRootItem() |
|
414 | self.parentItem = self.model.invisibleRootItem() | |
416 | name=str(self.nameProjectTxt.text()) |
|
415 | name=str(self.nameProjectTxt.text()) | |
417 | self.__arbolDict[self.idp] = QtGui.QStandardItem(QtCore.QString(name+" %0").arg(self.idp)) |
|
416 | self.__arbolDict[self.idp] = QtGui.QStandardItem(QtCore.QString(name+" %0").arg(self.idp)) | |
418 | print self.__arbolDict[self.idp] |
|
417 | print self.__arbolDict[self.idp] | |
419 | self.parentItem.appendRow(self.__arbolDict[self.idp]) |
|
418 | self.parentItem.appendRow(self.__arbolDict[self.idp]) | |
420 | self.parentItem=self.__arbolDict[self.idp] |
|
419 | self.parentItem=self.__arbolDict[self.idp] | |
421 |
|
420 | |||
422 | print "Porfavor ingrese los parámetros de configuracion del Proyecto" |
|
421 | print "Porfavor ingrese los parámetros de configuracion del Proyecto" | |
423 |
|
422 | |||
424 | def existDir(self, var_dir): |
|
423 | def existDir(self, var_dir): | |
425 | """ |
|
424 | """ | |
426 | METODO PARA VERIFICAR SI LA RUTA EXISTE-VAR_DIR |
|
425 | METODO PARA VERIFICAR SI LA RUTA EXISTE-VAR_DIR | |
427 | VARIABLE DIRECCION |
|
426 | VARIABLE DIRECCION | |
428 | """ |
|
427 | """ | |
429 | if os.path.isdir(var_dir): |
|
428 | if os.path.isdir(var_dir): | |
430 | return True |
|
429 | return True | |
431 | else: |
|
430 | else: | |
432 | self.textEdit.append("Incorrect path:" + str(var_dir)) |
|
431 | self.textEdit.append("Incorrect path:" + str(var_dir)) | |
433 | return False |
|
432 | return False | |
434 |
|
433 | |||
435 | def loadDays(self): |
|
434 | def loadDays(self): | |
436 | """ |
|
435 | """ | |
437 | METODO PARA CARGAR LOS DIAS |
|
436 | METODO PARA CARGAR LOS DIAS | |
438 | """ |
|
437 | """ | |
439 | self.variableList=[] |
|
438 | self.variableList=[] | |
440 | self.starDateCmbBox.clear() |
|
439 | self.starDateCmbBox.clear() | |
441 | self.endDateCmbBox.clear() |
|
440 | self.endDateCmbBox.clear() | |
442 |
|
441 | |||
443 | Dirlist = os.listdir(self.dataPath) |
|
442 | Dirlist = os.listdir(self.dataPath) | |
444 | Dirlist.sort() |
|
443 | Dirlist.sort() | |
445 |
|
444 | |||
446 | for a in range(0, len(Dirlist)): |
|
445 | for a in range(0, len(Dirlist)): | |
447 | fname= Dirlist[a] |
|
446 | fname= Dirlist[a] | |
448 | Doy=fname[5:8] |
|
447 | Doy=fname[5:8] | |
449 | fname = fname[1:5] |
|
448 | fname = fname[1:5] | |
450 | print fname |
|
449 | print fname | |
451 | fecha=Doy2Date(int(fname),int(Doy)) |
|
450 | fecha=Doy2Date(int(fname),int(Doy)) | |
452 | fechaList=fecha.change2date() |
|
451 | fechaList=fecha.change2date() | |
453 | #print fechaList[0] |
|
452 | #print fechaList[0] | |
454 | Dirlist[a]=fname+"/"+str(fechaList[0])+"/"+str(fechaList[1]) |
|
453 | Dirlist[a]=fname+"/"+str(fechaList[0])+"/"+str(fechaList[1]) | |
455 | #+"-"+ fechaList[0]+"-"+fechaList[1] |
|
454 | #+"-"+ fechaList[0]+"-"+fechaList[1] | |
456 |
|
455 | |||
457 | #---------------AQUI TIENE QUE SER MODIFICADO--------# |
|
456 | #---------------AQUI TIENE QUE SER MODIFICADO--------# | |
458 |
|
457 | |||
459 | #Se cargan las listas para seleccionar StartDay y StopDay (QComboBox) |
|
458 | #Se cargan las listas para seleccionar StartDay y StopDay (QComboBox) | |
460 | for i in range(0, (len(Dirlist))): |
|
459 | for i in range(0, (len(Dirlist))): | |
461 | self.variableList.append(Dirlist[i]) |
|
460 | self.variableList.append(Dirlist[i]) | |
462 |
|
461 | |||
463 | for i in self.variableList: |
|
462 | for i in self.variableList: | |
464 | self.starDateCmbBox.addItem(i) |
|
463 | self.starDateCmbBox.addItem(i) | |
465 | self.endDateCmbBox.addItem(i) |
|
464 | self.endDateCmbBox.addItem(i) | |
466 | self.endDateCmbBox.setCurrentIndex(self.starDateCmbBox.count()-1) |
|
465 | self.endDateCmbBox.setCurrentIndex(self.starDateCmbBox.count()-1) | |
467 |
|
466 | |||
468 | self.getsubList() |
|
467 | self.getsubList() | |
469 | self.dataOkBtn.setEnabled(True) |
|
468 | self.dataOkBtn.setEnabled(True) | |
470 |
|
469 | |||
471 | def getsubList(self): |
|
470 | def getsubList(self): | |
472 | """ |
|
471 | """ | |
473 | OBTIENE EL RANDO DE LAS FECHAS SELECCIONADAS |
|
472 | OBTIENE EL RANDO DE LAS FECHAS SELECCIONADAS | |
474 | """ |
|
473 | """ | |
475 | self.subList=[] |
|
474 | self.subList=[] | |
476 | for i in self.variableList[self.starDateCmbBox.currentIndex():self.starDateCmbBox.currentIndex() + self.endDateCmbBox.currentIndex()+1]: |
|
475 | for i in self.variableList[self.starDateCmbBox.currentIndex():self.starDateCmbBox.currentIndex() + self.endDateCmbBox.currentIndex()+1]: | |
477 | self.subList.append(i) |
|
476 | self.subList.append(i) | |
478 |
|
477 | |||
479 | def addUP(self): |
|
478 | def addUP(self): | |
480 |
|
479 | |||
481 | self.configUP=UnitProcess(self) |
|
480 | self.configUP=UnitProcess(self) | |
482 | for i in self.__arbolDict: |
|
481 | for i in self.__arbolDict: | |
483 | if self.__arbolDict[i]==self.indexclick: |
|
482 | if self.__arbolDict[i]==self.indexclick: | |
484 | if self.__projObjDict.has_key(i)==True: |
|
483 | if self.__projObjDict.has_key(i)==True: | |
485 | self.projectObj=self.__projObjDict[int(i)] |
|
484 | self.projectObj=self.__projObjDict[int(i)] | |
486 | print self.projectObj.id |
|
485 | print self.projectObj.id | |
487 | self.configUP.getfromWindowList.append(self.projectObj) |
|
486 | self.configUP.getfromWindowList.append(self.projectObj) | |
488 |
|
487 | |||
489 |
|
488 | |||
490 | for i in self.projectObj.procUnitConfObjDict: |
|
489 | for i in self.projectObj.procUnitConfObjDict: | |
491 | if self.projectObj.procUnitConfObjDict[i].getElementName()=='ProcUnit': |
|
490 | if self.projectObj.procUnitConfObjDict[i].getElementName()=='ProcUnit': | |
492 | self.upObj=self.projectObj.procUnitConfObjDict[i] |
|
491 | self.upObj=self.projectObj.procUnitConfObjDict[i] | |
493 | self.configUP.getfromWindowList.append(self.upObj) |
|
492 | self.configUP.getfromWindowList.append(self.upObj) | |
494 |
|
493 | |||
495 |
|
494 | |||
496 |
|
495 | |||
497 | self.configUP.loadTotalList() |
|
496 | self.configUP.loadTotalList() | |
498 | self.configUP.show() |
|
497 | self.configUP.show() | |
499 | #self.configUP.unitPsavebut.clicked.connect(self.reciveUPparameters) |
|
498 | #self.configUP.unitPsavebut.clicked.connect(self.reciveUPparameters) | |
500 | self.configUP.closed.connect(self.createUP) |
|
499 | self.configUP.closed.connect(self.createUP) | |
501 |
|
500 | |||
502 |
|
501 | |||
503 |
|
502 | |||
504 | def createUP(self): |
|
503 | def createUP(self): | |
505 |
|
504 | |||
506 | print "En este nivel se adiciona una rama de procesamiento, y se le concatena con el id" |
|
505 | print "En este nivel se adiciona una rama de procesamiento, y se le concatena con el id" | |
507 |
|
506 | |||
508 | if not self.configUP.create: |
|
507 | if not self.configUP.create: | |
509 | return |
|
508 | return | |
510 |
|
509 | |||
511 | self.uporProObjRecover=self.configUP.getFromWindow |
|
510 | self.uporProObjRecover=self.configUP.getFromWindow | |
512 |
|
511 | |||
513 | self.upType = self.configUP.typeofUP |
|
512 | self.upType = self.configUP.typeofUP | |
514 | for i in self.__arbolDict: |
|
513 | for i in self.__arbolDict: | |
515 | if self.__arbolDict[i]==self.indexclick: |
|
514 | if self.__arbolDict[i]==self.indexclick: | |
516 | self.projectObj=self.__projObjDict[int(i)] |
|
515 | self.projectObj=self.__projObjDict[int(i)] | |
517 |
|
516 | |||
518 | datatype=str(self.upType) |
|
517 | datatype=str(self.upType) | |
519 | uporprojectObj=self.uporProObjRecover |
|
518 | uporprojectObj=self.uporProObjRecover | |
520 |
|
519 | |||
521 | if uporprojectObj.getElementName()=='ProcUnit': |
|
520 | if uporprojectObj.getElementName()=='ProcUnit': | |
522 | inputId=uporprojectObj.getId() |
|
521 | inputId=uporprojectObj.getId() | |
523 | else: |
|
522 | else: | |
524 | inputId=self.readUnitConfObjList[uporprojectObj.id-1].getId() |
|
523 | inputId=self.readUnitConfObjList[uporprojectObj.id-1].getId() | |
525 |
|
524 | |||
526 | print 'uporprojectObj.id','inputId', uporprojectObj.id,inputId |
|
525 | print 'uporprojectObj.id','inputId', uporprojectObj.id,inputId | |
527 | self.procUnitConfObj1 = self.projectObj.addProcUnit(datatype=datatype, inputId=inputId) |
|
526 | self.procUnitConfObj1 = self.projectObj.addProcUnit(datatype=datatype, inputId=inputId) | |
528 | self.__upObjDict[inputId]= self.procUnitConfObj1 |
|
527 | self.__upObjDict[inputId]= self.procUnitConfObj1 | |
529 |
|
528 | |||
530 | self.parentItem=self.__arbolDict[uporprojectObj.id] |
|
529 | self.parentItem=self.__arbolDict[uporprojectObj.id] | |
531 | #print "i","self.__arbolDict[i]",i ,self.__arbolDict[i] |
|
530 | #print "i","self.__arbolDict[i]",i ,self.__arbolDict[i] | |
532 | self.numbertree=int(self.procUnitConfObj1.getId())-1 |
|
531 | self.numbertree=int(self.procUnitConfObj1.getId())-1 | |
533 | self.__arbolDict[self.procUnitConfObj1.id]=QtGui.QStandardItem(QtCore.QString(datatype +"%1 ").arg(self.numbertree)) |
|
532 | self.__arbolDict[self.procUnitConfObj1.id]=QtGui.QStandardItem(QtCore.QString(datatype +"%1 ").arg(self.numbertree)) | |
534 | self.parentItem.appendRow(self.__arbolDict[self.procUnitConfObj1.id]) |
|
533 | self.parentItem.appendRow(self.__arbolDict[self.procUnitConfObj1.id]) | |
535 | self.parentItem=self.__arbolDict[self.procUnitConfObj1.id] |
|
534 | self.parentItem=self.__arbolDict[self.procUnitConfObj1.id] | |
536 | # self.loadUp() |
|
535 | # self.loadUp() | |
537 | self.treeView.expandAll() |
|
536 | self.treeView.expandAll() | |
538 |
|
537 | |||
539 | def resetopVolt(self): |
|
538 | def resetopVolt(self): | |
540 | self.selecChannelopVolCEB.setChecked(False) |
|
539 | self.selecChannelopVolCEB.setChecked(False) | |
541 | self.selecHeighopVolCEB.setChecked(False) |
|
540 | self.selecHeighopVolCEB.setChecked(False) | |
542 | self.coherentIntegrationCEB.setChecked(False) |
|
541 | self.coherentIntegrationCEB.setChecked(False) | |
543 | self.profileSelecopVolCEB.setChecked(False) |
|
542 | self.profileSelecopVolCEB.setChecked(False) | |
544 | #self.selecChannelopVolCEB.setEnabled(False) |
|
543 | #self.selecChannelopVolCEB.setEnabled(False) | |
545 | self.lineHeighProfileTxtopVol.clear() |
|
544 | self.lineHeighProfileTxtopVol.clear() | |
546 | self.lineProfileSelecopVolCEB.clear() |
|
545 | self.lineProfileSelecopVolCEB.clear() | |
547 | self.numberChannelopVol.clear() |
|
546 | self.numberChannelopVol.clear() | |
548 | self.numberIntegration.clear() |
|
547 | self.numberIntegration.clear() | |
549 |
|
548 | |||
550 |
|
549 | |||
551 | def resetopSpec(self): |
|
550 | def resetopSpec(self): | |
552 | self.nFFTPointOpSpecCEB.setChecked(False) |
|
551 | self.nFFTPointOpSpecCEB.setChecked(False) | |
553 |
|
552 | |||
554 | self.valuenFFTPointOpSpec.clear() |
|
553 | self.valuenFFTPointOpSpec.clear() | |
555 |
|
554 | |||
556 | def resetgraphSpec(self): |
|
555 | def resetgraphSpec(self): | |
557 | self.SpectraPlotGraphCEB.setChecked(False) |
|
556 | self.SpectraPlotGraphCEB.setChecked(False) | |
558 | self.CrossSpectraPlotGraphceb.setChecked(False) |
|
557 | self.CrossSpectraPlotGraphceb.setChecked(False) | |
559 | self.RTIPlotGraphCEB.setChecked(False) |
|
558 | self.RTIPlotGraphCEB.setChecked(False) | |
560 |
|
559 | |||
561 |
|
560 | |||
562 | def saveProject(self): |
|
561 | def saveProject(self): | |
563 | print "entro" |
|
562 | print "entro" | |
564 | #filename="C:\WorkspaceGUI\config1.xml" |
|
563 | #filename="C:\WorkspaceGUI\config1.xml" | |
565 | for i in self.__arbolDict: |
|
564 | for i in self.__arbolDict: | |
566 | if self.__arbolDict[i]==self.indexclick: |
|
565 | if self.__arbolDict[i]==self.indexclick: | |
567 | self.projectObj=self.__projObjDict[int(i)] |
|
566 | self.projectObj=self.__projObjDict[int(i)] | |
568 | print "Encontre project" |
|
567 | print "Encontre project" | |
569 | filename="C:\WorkspaceGUI\config"+str(self.projectObj.id)+".xml" |
|
568 | filename="C:\WorkspaceGUI\config"+str(self.projectObj.id)+".xml" | |
570 | print "Escribo Project" |
|
569 | print "Escribo Project" | |
571 | self.projectObj.writeXml(filename) |
|
570 | self.projectObj.writeXml(filename) | |
572 |
|
571 | |||
573 |
|
572 | |||
574 | class UnitProcess(QMainWindow, Ui_UnitProcess): |
|
573 | class UnitProcess(QMainWindow, Ui_UnitProcess): | |
575 | """ |
|
574 | """ | |
576 | Class documentation goes here. |
|
575 | Class documentation goes here. | |
577 | """ |
|
576 | """ | |
578 | closed=pyqtSignal() |
|
577 | closed=pyqtSignal() | |
579 | create= False |
|
578 | create= False | |
580 | def __init__(self, parent = None): |
|
579 | def __init__(self, parent = None): | |
581 | """ |
|
580 | """ | |
582 | Constructor |
|
581 | Constructor | |
583 | """ |
|
582 | """ | |
584 | QMainWindow.__init__(self, parent) |
|
583 | QMainWindow.__init__(self, parent) | |
585 | self.setupUi(self) |
|
584 | self.setupUi(self) | |
586 | self.getFromWindow=None |
|
585 | self.getFromWindow=None | |
587 | self.getfromWindowList=[] |
|
586 | self.getfromWindowList=[] | |
588 |
|
587 | |||
589 | self.listUP=None |
|
588 | self.listUP=None | |
590 |
|
589 | |||
591 | @pyqtSignature("") |
|
590 | @pyqtSignature("") | |
592 | def on_unitPokbut_clicked(self): |
|
591 | def on_unitPokbut_clicked(self): | |
593 | """ |
|
592 | """ | |
594 | Slot documentation goes here. |
|
593 | Slot documentation goes here. | |
595 | """ |
|
594 | """ | |
596 | self.create =True |
|
595 | self.create =True | |
597 | self.getFromWindow=self.getfromWindowList[int(self.comboInputBox.currentIndex())] |
|
596 | self.getFromWindow=self.getfromWindowList[int(self.comboInputBox.currentIndex())] | |
598 | #self.nameofUP= str(self.nameUptxt.text()) |
|
597 | #self.nameofUP= str(self.nameUptxt.text()) | |
599 | self.typeofUP= str(self.comboTypeBox.currentText()) |
|
598 | self.typeofUP= str(self.comboTypeBox.currentText()) | |
600 | self.close() |
|
599 | self.close() | |
601 |
|
600 | |||
602 |
|
601 | |||
603 | @pyqtSignature("") |
|
602 | @pyqtSignature("") | |
604 | def on_unitPcancelbut_clicked(self): |
|
603 | def on_unitPcancelbut_clicked(self): | |
605 | """ |
|
604 | """ | |
606 | Slot documentation goes here. |
|
605 | Slot documentation goes here. | |
607 | """ |
|
606 | """ | |
608 | # TODO: not implemented yet |
|
607 | # TODO: not implemented yet | |
609 | #raise NotImplementedError |
|
608 | #raise NotImplementedError | |
610 | self.create=False |
|
609 | self.create=False | |
611 | self.close() |
|
610 | self.close() | |
612 |
|
611 | |||
613 | def loadTotalList(self): |
|
612 | def loadTotalList(self): | |
614 | self.comboInputBox.clear() |
|
613 | self.comboInputBox.clear() | |
615 | for i in self.getfromWindowList: |
|
614 | for i in self.getfromWindowList: | |
616 |
|
615 | |||
617 | name=i.getElementName() |
|
616 | name=i.getElementName() | |
618 | if name=='Project': |
|
617 | if name=='Project': | |
619 | id= i.id |
|
618 | id= i.id | |
620 | if name=='ProcUnit': |
|
619 | if name=='ProcUnit': | |
621 | id=int(i.id)-1 |
|
620 | id=int(i.id)-1 | |
622 | self.comboInputBox.addItem(str(name)+str(id)) |
|
621 | self.comboInputBox.addItem(str(name)+str(id)) | |
623 |
|
622 | |||
624 | def closeEvent(self, event): |
|
623 | def closeEvent(self, event): | |
625 | self.closed.emit() |
|
624 | self.closed.emit() | |
626 | event.accept() |
|
625 | event.accept() | |
627 |
|
626 | |||
628 |
|
627 | |||
629 |
|
628 | |||
630 |
|
629 | |||
631 |
|
630 | |||
632 |
|
631 | |||
633 | No newline at end of file |
|
632 |
This diff has been collapsed as it changes many lines, (578 lines changed) Show them Hide them | |||||
@@ -1,277 +1,303 | |||||
1 | from PyQt4 import QtCore |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | from PyQt4 import QtCore | ||
3 | HORIZONTAL_HEADERS = ("Property","Value " ) |
|
3 | import itertools | |
4 |
|
4 | |||
5 | HORIZONTAL = ("RAMA :",) |
|
5 | HORIZONTAL_HEADERS = ("Property","Value " ) | |
6 |
|
6 | |||
7 | class treeModel(QtCore.QAbstractItemModel): |
|
7 | HORIZONTAL = ("RAMA :",) | |
8 |
|
|
8 | ||
9 | a model to display a few names, ordered by encabezado |
|
9 | class treeModel(QtCore.QAbstractItemModel): | |
10 |
|
|
10 | ''' | |
11 | name=None |
|
11 | a model to display a few names, ordered by encabezado | |
12 | directorio=None |
|
12 | ||
13 | workspace=None |
|
13 | ''' | |
14 | remode=None |
|
14 | def __init__(self ,parent=None): | |
15 | dataformat=None |
|
15 | super(treeModel, self).__init__(parent) | |
16 | date=None |
|
16 | self.people = [] | |
17 | initTime=None |
|
17 | self.initProjectProperties() | |
18 | endTime=None |
|
18 | self.initPUVoltageProperties() | |
19 | timezone=None |
|
19 | self.initPUSpectraProperties() | |
20 | Summary=None |
|
20 | self.initPUSpectraHeisProperties() | |
21 |
|
21 | |||
22 | description=None |
|
22 | def initProjectProperties(self): | |
23 |
|
23 | |||
24 | def __init__(self ,parent=None): |
|
24 | name=None | |
25 | super(treeModel, self).__init__(parent) |
|
25 | directorio=None | |
26 | self.people = [] |
|
26 | workspace=None | |
27 |
|
27 | remode=None | ||
28 |
|
28 | dataformat=None | ||
29 | def properties_projecto(self,description): |
|
29 | startDate=None | |
30 | self.caracteristica="Project_Properties" |
|
30 | endDate=None | |
31 | self.principal ="Name" |
|
31 | startTime=None | |
32 | self.description =description |
|
32 | endTime=None | |
33 | exam_project=person_class(self.caracteristica,self.principal,self.description) |
|
33 | delay=None | |
34 | return exam_project |
|
34 | set= None | |
35 |
|
35 | walk=None | ||
36 |
|
36 | timezone=None | ||
37 |
|
37 | Summary=None | ||
38 | def arbol(self): |
|
38 | description=None | |
39 | for caracteristica,principal, descripcion in (("Properties","Name",self.name), |
|
39 | ||
40 | ("Properties","Data Path",self.directorio), |
|
40 | def initPUVoltageProperties(self): | |
41 | ("Properties","Workspace",self.workspace), |
|
41 | type=None | |
42 | ("Parameters", "Read Mode ",self.remode), |
|
42 | channel=None | |
43 | ("Parameters", "DataType ",self.dataformat), |
|
43 | heights=None | |
44 | ("Parameters", "Date ",self.date), |
|
44 | filter=None | |
45 | ("Parameters", "Init Time ",self.initTime), |
|
45 | profile=None | |
46 | ("Parameters", "Final Time ",self.endTime), |
|
46 | code=None | |
47 | ("Parameters", " Time zone ",self.timezone), |
|
47 | mode=None | |
48 | ("Parameters", "Profiles ","1"), |
|
48 | coherentintegration=None | |
49 | ("Description", "Summary ", self.Summary), |
|
49 | ||
50 | ): |
|
50 | def initPUSpectraProperties(self): | |
51 | person = person_class(caracteristica, principal, descripcion) |
|
51 | type =None | |
52 | self.people.append(person) |
|
52 | nFFTpoints =None | |
53 | def addProjectproperties(self,person): |
|
53 | ippFactor = None | |
54 | self.people.append(person) |
|
54 | pairsList =None | |
55 |
|
55 | channel =None | ||
56 |
|
56 | heights =None | ||
57 | #def veamos(self): |
|
57 | incoherentintegration =None | |
58 | # self.update= MainWindow(self) |
|
58 | removeDC = None | |
59 | # self.update.dataProyectTxt.text() |
|
59 | removeInterference =None | |
60 | # return self.update.dataProyectTxt.text() |
|
60 | getNoise = None | |
61 |
|
61 | operationSpecPlot=None | ||
62 | def showtree(self): |
|
62 | operationCrossSpecPlot = None | |
63 | self.rootItem = TreeItem(None, "ALL", None) |
|
63 | operationRTIPlot = None | |
64 | self.parents = {0 : self.rootItem} |
|
64 | operationCohermap = None | |
65 | self.setupModelData() |
|
65 | operationPowProfilePlot = None | |
66 |
|
66 | |||
67 | def setParams(self,name,directorio,workspace,remode,dataformat,date,initTime,endTime,timezone,Summary): |
|
67 | def initPUSpectraHeisProperties(self): | |
68 | self.name=name |
|
68 | type =None | |
69 | self.workspace=workspace |
|
69 | incoherentintegration =None | |
70 | self.directorio= directorio |
|
70 | operationSpecHeisPlot=None | |
71 | self.remode=remode |
|
71 | operationRTIHeisPlot = None | |
72 | self.dataformat=dataformat |
|
72 | ||
73 | self.date=date |
|
73 | def initProjectView(self): | |
74 | self.initTime=initTime |
|
74 | """ | |
75 | self.endTime=endTime |
|
75 | Reemplazo del método showtree | |
76 | self.timezone=timezone |
|
76 | """ | |
77 | self.Summary=Summary |
|
77 | HORIZONTAL_HEADERS = ("Property","Value " ) | |
78 |
|
78 | HORIZONTAL = ("RAMA :",) | ||
79 |
|
79 | self.rootItem = TreeItem(None, "ALL", None) | ||
80 | for caracteristica,principal, descripcion in (("Properties","Name",self.name), |
|
80 | self.parents = {0 : self.rootItem} | |
81 | ("Properties","Data Path",self.directorio), |
|
81 | self.setupModelData() | |
82 | ("Properties","Workspace",self.workspace), |
|
82 | ||
83 | ("Parameters", "Read Mode ",self.remode), |
|
83 | def initPUVoltageView(self): | |
84 | ("Parameters", "DataType ",self.dataformat), |
|
84 | HORIZONTAL_HEADERS = ("Operation"," Parameter Value " ) | |
85 | ("Parameters", "Date ",self.date), |
|
85 | HORIZONTAL = ("RAMA :",) | |
86 | ("Parameters", "Init Time ",self.initTime), |
|
86 | self.rootItem = TreeItem(None, "ALL", None) | |
87 | ("Parameters", "Final Time ",self.endTime), |
|
87 | self.parents = {0 : self.rootItem} | |
88 | ("Parameters", " Time zone ",self.timezone), |
|
88 | self.setupModelData() | |
89 | ("Parameters", "Profiles ","1"), |
|
89 | ||
90 | ("Description", "Summary ", self.Summary), |
|
90 | def showProjectParms(self,caracteristicaList,principalList,descripcionList): | |
91 | ): |
|
91 | """ | |
92 | person = person_class(caracteristica, principal, descripcion) |
|
92 | set2Obje | |
93 | self.people.append(person) |
|
93 | """ | |
94 | self.rootItem = TreeItem(None, "ALL", None) |
|
94 | for caracteristica,principal, descripcion in itertools.izip(caracteristicaList,principalList,descripcionList): | |
95 | self.parents = {0 : self.rootItem} |
|
95 | person = person_class(caracteristica, principal, descripcion) | |
96 | self.setupModelData() |
|
96 | self.people.append(person) | |
97 |
|
97 | self.rootItem = TreeItem(None, "ALL", None) | ||
98 |
|
98 | self.parents = {0 : self.rootItem} | ||
99 | def columnCount(self, parent=None): |
|
99 | self.setupModelData() | |
100 | if parent and parent.isValid(): |
|
100 | ||
101 | return parent.internalPointer().columnCount() |
|
101 | def showPUVoltageParms(self,caracteristicaList,principalList,descripcionList): | |
102 | else: |
|
102 | ||
103 | return len(HORIZONTAL_HEADERS) |
|
103 | for caracteristica,principal, descripcion in itertools.izip(caracteristicaList,principalList,descripcionList): | |
104 |
|
104 | person = person_class(caracteristica, principal, descripcion) | ||
105 | def data(self, index, role): |
|
105 | self.people.append(person) | |
106 | if not index.isValid(): |
|
106 | self.rootItem = TreeItem(None, "ALL", None) | |
107 | return QtCore.QVariant() |
|
107 | self.parents = {0 : self.rootItem} | |
108 |
|
108 | self.setupModelData() | ||
109 | item = index.internalPointer() |
|
109 | ||
110 | if role == QtCore.Qt.DisplayRole: |
|
110 | ||
111 | return item.data(index.column()) |
|
111 | def showPUSpectraParms(self,caracteristicaList,principalList,descripcionList): | |
112 | if role == QtCore.Qt.UserRole: |
|
112 | ||
113 | if item: |
|
113 | for caracteristica,principal, descripcion in itertools.izip(caracteristicaList,principalList,descripcionList): | |
114 | return item.person |
|
114 | person = person_class(caracteristica, principal, descripcion) | |
115 |
|
115 | self.people.append(person) | ||
116 | return QtCore.QVariant() |
|
116 | self.rootItem = TreeItem(None, "ALL", None) | |
117 |
|
117 | self.parents = {0 : self.rootItem} | ||
118 | def headerData(self, column, orientation, role): |
|
118 | self.setupModelData() | |
119 | if (orientation == QtCore.Qt.Horizontal and |
|
119 | ||
120 | role == QtCore.Qt.DisplayRole): |
|
120 | def showPUSpectraHeisParms(self,caracteristicaList,principalList,descripcionList): | |
121 | try: |
|
121 | ||
122 | return QtCore.QVariant(HORIZONTAL_HEADERS[column]) |
|
122 | for caracteristica,principal, descripcion in itertools.izip(caracteristicaList,principalList,descripcionList): | |
123 | except IndexError: |
|
123 | person = person_class(caracteristica, principal, descripcion) | |
124 | pass |
|
124 | self.people.append(person) | |
125 |
|
125 | self.rootItem = TreeItem(None, "ALL", None) | ||
126 | return QtCore.QVariant() |
|
126 | self.parents = {0 : self.rootItem} | |
127 |
|
127 | self.setupModelData() | ||
128 | def index(self, row, column, parent): |
|
128 | ||
129 | if not self.hasIndex(row, column, parent): |
|
129 | ||
130 | return QtCore.QModelIndex() |
|
130 | def columnCount(self, parent=None): | |
131 |
|
131 | if parent and parent.isValid(): | ||
132 | if not parent.isValid(): |
|
132 | return parent.internalPointer().columnCount() | |
133 | parentItem = self.rootItem |
|
133 | else: | |
134 | else: |
|
134 | return len(HORIZONTAL_HEADERS) | |
135 | parentItem = parent.internalPointer() |
|
135 | ||
136 |
|
136 | def data(self, index, role): | ||
137 | childItem = parentItem.child(row) |
|
137 | if not index.isValid(): | |
138 | if childItem: |
|
138 | return QtCore.QVariant() | |
139 | return self.createIndex(row, column, childItem) |
|
139 | ||
140 | else: |
|
140 | item = index.internalPointer() | |
141 | return QtCore.QModelIndex() |
|
141 | if role == QtCore.Qt.DisplayRole: | |
142 |
|
142 | return item.data(index.column()) | ||
143 | def parent(self, index): |
|
143 | if role == QtCore.Qt.UserRole: | |
144 | if not index.isValid(): |
|
144 | if item: | |
145 |
return |
|
145 | return item.person | |
146 |
|
146 | |||
147 | childItem = index.internalPointer() |
|
147 | return QtCore.QVariant() | |
148 | if not childItem: |
|
148 | ||
149 | return QtCore.QModelIndex() |
|
149 | def headerData(self, column, orientation, role): | |
150 |
|
150 | if (orientation == QtCore.Qt.Horizontal and | ||
151 | parentItem = childItem.parent() |
|
151 | role == QtCore.Qt.DisplayRole): | |
152 |
|
152 | try: | ||
153 | if parentItem == self.rootItem: |
|
153 | return QtCore.QVariant(HORIZONTAL_HEADERS[column]) | |
154 | return QtCore.QModelIndex() |
|
154 | except IndexError: | |
155 |
|
155 | pass | ||
156 | return self.createIndex(parentItem.row(), 0, parentItem) |
|
156 | ||
157 |
|
157 | return QtCore.QVariant() | ||
158 | def rowCount(self, parent=QtCore.QModelIndex()): |
|
158 | ||
159 | if parent.column() > 0: |
|
159 | def index(self, row, column, parent): | |
160 | return 0 |
|
160 | if not self.hasIndex(row, column, parent): | |
161 | if not parent.isValid(): |
|
161 | return QtCore.QModelIndex() | |
162 | p_Item = self.rootItem |
|
162 | ||
163 | else: |
|
163 | if not parent.isValid(): | |
164 | p_Item = parent.internalPointer() |
|
164 | parentItem = self.rootItem | |
165 | return p_Item.childCount() |
|
165 | else: | |
166 |
|
166 | parentItem = parent.internalPointer() | ||
167 | def setupModelData(self): |
|
167 | ||
168 | for person in self.people: |
|
168 | childItem = parentItem.child(row) | |
169 | if person.descripcion: |
|
169 | if childItem: | |
170 | encabezado = person.caracteristica |
|
170 | return self.createIndex(row, column, childItem) | |
171 |
|
171 | else: | ||
172 |
|
172 | return QtCore.QModelIndex() | ||
173 | if not self.parents.has_key(encabezado): |
|
173 | ||
174 | newparent = TreeItem(None, encabezado, self.rootItem) |
|
174 | def parent(self, index): | |
175 | self.rootItem.appendChild(newparent) |
|
175 | if not index.isValid(): | |
176 |
|
176 | return QtCore.QModelIndex() | ||
177 | self.parents[encabezado] = newparent |
|
177 | ||
178 |
|
178 | childItem = index.internalPointer() | ||
179 | parentItem = self.parents[encabezado] |
|
179 | if not childItem: | |
180 | newItem = TreeItem(person, "", parentItem) |
|
180 | return QtCore.QModelIndex() | |
181 | parentItem.appendChild(newItem) |
|
181 | ||
182 |
|
182 | parentItem = childItem.parent() | ||
183 | def searchModel(self, person): |
|
183 | ||
184 | ''' |
|
184 | if parentItem == self.rootItem: | |
185 | get the modelIndex for a given appointment |
|
185 | return QtCore.QModelIndex() | |
186 | ''' |
|
186 | ||
187 | def searchNode(node): |
|
187 | return self.createIndex(parentItem.row(), 0, parentItem) | |
188 | ''' |
|
188 | ||
189 | a function called recursively, looking at all nodes beneath node |
|
189 | def rowCount(self, parent=QtCore.QModelIndex()): | |
190 | ''' |
|
190 | if parent.column() > 0: | |
191 | for child in node.childItems: |
|
191 | return 0 | |
192 | if person == child.person: |
|
192 | if not parent.isValid(): | |
193 | index = self.createIndex(child.row(), 0, child) |
|
193 | p_Item = self.rootItem | |
194 | return index |
|
194 | else: | |
195 |
|
195 | p_Item = parent.internalPointer() | ||
196 | if child.childCount() > 0: |
|
196 | return p_Item.childCount() | |
197 | result = searchNode(child) |
|
197 | ||
198 | if result: |
|
198 | def setupModelData(self): | |
199 | return result |
|
199 | for person in self.people: | |
200 |
|
200 | if person.descripcion: | ||
201 | retarg = searchNode(self.parents[0]) |
|
201 | encabezado = person.caracteristica | |
202 | #print retarg |
|
202 | ||
203 | return retarg |
|
203 | ||
204 |
|
204 | if not self.parents.has_key(encabezado): | ||
205 | def find_GivenName(self, principal): |
|
205 | newparent = TreeItem(None, encabezado, self.rootItem) | |
206 | app = None |
|
206 | self.rootItem.appendChild(newparent) | |
207 | for person in self.people: |
|
207 | ||
208 | if person.principal == principal: |
|
208 | self.parents[encabezado] = newparent | |
209 | app = person |
|
209 | ||
210 | break |
|
210 | parentItem = self.parents[encabezado] | |
211 | if app != None: |
|
211 | newItem = TreeItem(person, "", parentItem) | |
212 | index = self.searchModel(app) |
|
212 | parentItem.appendChild(newItem) | |
213 | return (True, index) |
|
213 | ||
214 | return (False, None) |
|
214 | def searchModel(self, person): | |
215 |
|
215 | ''' | ||
216 |
|
216 | get the modelIndex for a given appointment | ||
217 |
|
217 | ''' | ||
218 |
|
218 | def searchNode(node): | ||
219 |
|
219 | ''' | ||
220 |
|
220 | a function called recursively, looking at all nodes beneath node | ||
221 |
|
221 | ''' | ||
222 | class person_class(object): |
|
222 | for child in node.childItems: | |
223 | ''' |
|
223 | if person == child.person: | |
224 | a trivial custom data object |
|
224 | index = self.createIndex(child.row(), 0, child) | |
225 | ''' |
|
225 | return index | |
226 | def __init__(self, caracteristica, principal, descripcion): |
|
226 | ||
227 | self.caracteristica = caracteristica |
|
227 | if child.childCount() > 0: | |
228 | self.principal = principal |
|
228 | result = searchNode(child) | |
229 | self.descripcion = descripcion |
|
229 | if result: | |
230 |
|
230 | return result | ||
231 | def __repr__(self): |
|
231 | ||
232 | return "PERSON - %s %s"% (self.principal, self.caracteristica) |
|
232 | retarg = searchNode(self.parents[0]) | |
233 |
|
233 | #print retarg | ||
234 | class TreeItem(object): |
|
234 | return retarg | |
235 | ''' |
|
235 | ||
236 | a python object used to return row/column data, and keep note of |
|
236 | def find_GivenName(self, principal): | |
237 | it's parents and/or children |
|
237 | app = None | |
238 | ''' |
|
238 | for person in self.people: | |
239 | def __init__(self, person, header, parentItem): |
|
239 | if person.principal == principal: | |
240 |
|
|
240 | app = person | |
241 | self.parentItem = parentItem |
|
241 | break | |
242 | self.header = header |
|
242 | if app != None: | |
243 | self.childItems = [] |
|
243 | index = self.searchModel(app) | |
244 |
|
244 | return (True, index) | ||
245 | def appendChild(self, item): |
|
245 | return (False, None) | |
246 | self.childItems.append(item) |
|
246 | ||
247 |
|
247 | |||
248 | def child(self, row): |
|
248 | class person_class(object): | |
249 | return self.childItems[row] |
|
249 | ''' | |
250 |
|
250 | a trivial custom data object | ||
251 | def childCount(self): |
|
251 | ''' | |
252 | return len(self.childItems) |
|
252 | def __init__(self, caracteristica, principal, descripcion): | |
253 |
|
253 | self.caracteristica = caracteristica | ||
254 | def columnCount(self): |
|
254 | self.principal = principal | |
255 | return 2 |
|
255 | self.descripcion = descripcion | |
256 |
|
256 | |||
257 |
def |
|
257 | def __repr__(self): | |
258 | if self.person == None: |
|
258 | return "PERSON - %s %s"% (self.principal, self.caracteristica) | |
259 | if column == 0: |
|
259 | ||
260 | return QtCore.QVariant(self.header) |
|
260 | class TreeItem(object): | |
261 | if column == 1: |
|
261 | ''' | |
262 | return QtCore.QVariant("") |
|
262 | a python object used to return row/column data, and keep note of | |
263 | else: |
|
263 | it's parents and/or children | |
264 | if column == 0: |
|
264 | ''' | |
265 | return QtCore.QVariant(self.person.principal) |
|
265 | def __init__(self, person, header, parentItem): | |
266 | if column == 1: |
|
266 | self.person = person | |
267 | return QtCore.QVariant(self.person.descripcion) |
|
267 | self.parentItem = parentItem | |
268 | return QtCore.QVariant() |
|
268 | self.header = header | |
269 |
|
269 | self.childItems = [] | ||
270 | def parent(self): |
|
270 | ||
271 | return self.parentItem |
|
271 | def appendChild(self, item): | |
272 |
|
272 | self.childItems.append(item) | ||
273 | def row(self): |
|
273 | ||
274 | if self.parentItem: |
|
274 | def child(self, row): | |
275 |
|
|
275 | return self.childItems[row] | |
276 | return 0 |
|
276 | ||
|
277 | def childCount(self): | |||
|
278 | return len(self.childItems) | |||
|
279 | ||||
|
280 | def columnCount(self): | |||
|
281 | return 2 | |||
|
282 | ||||
|
283 | def data(self, column): | |||
|
284 | if self.person == None: | |||
|
285 | if column == 0: | |||
|
286 | return QtCore.QVariant(self.header) | |||
|
287 | if column == 1: | |||
|
288 | return QtCore.QVariant("") | |||
|
289 | else: | |||
|
290 | if column == 0: | |||
|
291 | return QtCore.QVariant(self.person.principal) | |||
|
292 | if column == 1: | |||
|
293 | return QtCore.QVariant(self.person.descripcion) | |||
|
294 | return QtCore.QVariant() | |||
|
295 | ||||
|
296 | def parent(self): | |||
|
297 | return self.parentItem | |||
|
298 | ||||
|
299 | def row(self): | |||
|
300 | if self.parentItem: | |||
|
301 | return self.parentItem.childItems.index(self) | |||
|
302 | return 0 | |||
277 | No newline at end of file |
|
303 |
@@ -1,41 +1,38 | |||||
1 | import os, sys |
|
1 | import os, sys | |
2 | import getopt |
|
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 | class scProcessController(): |
|
6 | class scProcessController(): | |
10 | def __init__(self): |
|
7 | def __init__(self): | |
11 | print "ESTOY EJECUTANDO EL NUEVO PROCESO PERO APARENTEMENTE NO QUIERE" |
|
8 | print "ESTOY EJECUTANDO EL NUEVO PROCESO PERO APARENTEMENTE NO QUIERE" | |
12 | self.setfilename() |
|
9 | self.setfilename() | |
13 | self.operation() |
|
10 | self.operation() | |
14 |
|
11 | |||
15 | def setfilename(self): |
|
12 | def setfilename(self): | |
16 | arglist= '' |
|
13 | arglist= '' | |
17 | longarglist=['filename='] |
|
14 | longarglist=['filename='] | |
18 | optlist,args=getopt.getopt(sys.argv[1:],arglist,longarglist) |
|
15 | optlist,args=getopt.getopt(sys.argv[1:],arglist,longarglist) | |
19 | for opt in optlist: |
|
16 | for opt in optlist: | |
20 | if opt[0]== '--filename': |
|
17 | if opt[0]== '--filename': | |
21 | self.filename = opt[1] |
|
18 | self.filename = opt[1] | |
22 |
|
19 | |||
23 | def operation(self): |
|
20 | def operation(self): | |
24 | print 'inicia operation' |
|
21 | print 'inicia operation' | |
25 | controllerObj = Project() |
|
22 | controllerObj = Project() | |
26 | print "Leyendo el archivo XML" |
|
23 | print "Leyendo el archivo XML" | |
27 | #self.filename="C://Users//alex//schain_workspace//Alexander1.xml" |
|
24 | #self.filename="C://Users//alex//schain_workspace//Alexander1.xml" | |
28 | controllerObj.readXml(self.filename) |
|
25 | controllerObj.readXml(self.filename) | |
29 | #controllerObj.printattr() |
|
26 | #controllerObj.printattr() | |
30 |
|
27 | |||
31 | controllerObj.createObjects() |
|
28 | controllerObj.createObjects() | |
32 | controllerObj.connectObjects() |
|
29 | controllerObj.connectObjects() | |
33 | controllerObj.run() |
|
30 | controllerObj.run() | |
34 |
|
31 | |||
35 |
|
32 | |||
36 | def main(): |
|
33 | def main(): | |
37 | a=scProcessController() |
|
34 | a=scProcessController() | |
38 |
|
35 | |||
39 |
|
36 | |||
40 | if __name__ == "__main__": |
|
37 | if __name__ == "__main__": | |
41 | main() No newline at end of file |
|
38 | main() |
@@ -1,58 +1,58 | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | """ |
|
3 | """ | |
4 | Module implementing MainWindow. |
|
4 | Module implementing MainWindow. | |
5 | """ |
|
5 | """ | |
6 |
|
6 | |||
7 | from PyQt4.QtGui import QMainWindow |
|
7 | from PyQt4.QtGui import QMainWindow | |
8 | from PyQt4.QtCore import pyqtSignature |
|
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 | class UnitProcess(QMainWindow, Ui_UnitProcess): |
|
12 | class UnitProcess(QMainWindow, Ui_UnitProcess): | |
13 | """ |
|
13 | """ | |
14 | Class documentation goes here. |
|
14 | Class documentation goes here. | |
15 | """ |
|
15 | """ | |
16 |
|
16 | |||
17 | def __init__(self, parent = None): |
|
17 | def __init__(self, parent = None): | |
18 | """ |
|
18 | """ | |
19 | Constructor |
|
19 | Constructor | |
20 | """ |
|
20 | """ | |
21 | QMainWindow.__init__(self, parent) |
|
21 | QMainWindow.__init__(self, parent) | |
22 | self.setupUi(self) |
|
22 | self.setupUi(self) | |
23 |
|
23 | |||
24 |
|
24 | |||
25 | @pyqtSignature("QString") |
|
25 | @pyqtSignature("QString") | |
26 | def on_comboInputBox_activated(self, p0): |
|
26 | def on_comboInputBox_activated(self, p0): | |
27 | """ |
|
27 | """ | |
28 | Slot documentation goes here. |
|
28 | Slot documentation goes here. | |
29 | """ |
|
29 | """ | |
30 | # TODO: not implemented yet |
|
30 | # TODO: not implemented yet | |
31 | raise NotImplementedError |
|
31 | raise NotImplementedError | |
32 |
|
32 | |||
33 | @pyqtSignature("QString") |
|
33 | @pyqtSignature("QString") | |
34 | def on_comboTypeBox_activated(self, p0): |
|
34 | def on_comboTypeBox_activated(self, p0): | |
35 | """ |
|
35 | """ | |
36 | Slot documentation goes here. |
|
36 | Slot documentation goes here. | |
37 | """ |
|
37 | """ | |
38 | # TODO: not implemented yet |
|
38 | # TODO: not implemented yet | |
39 | raise NotImplementedError |
|
39 | raise NotImplementedError | |
40 |
|
40 | |||
41 |
|
41 | |||
42 | @pyqtSignature("") |
|
42 | @pyqtSignature("") | |
43 | def on_unitPokbut_clicked(self): |
|
43 | def on_unitPokbut_clicked(self): | |
44 | """ |
|
44 | """ | |
45 | Slot documentation goes here. |
|
45 | Slot documentation goes here. | |
46 | """ |
|
46 | """ | |
47 | # TODO: not implemented yet |
|
47 | # TODO: not implemented yet | |
48 | #raise NotImplementedError |
|
48 | #raise NotImplementedError | |
49 | print "this is suspiscious" |
|
49 | print "this is suspiscious" | |
50 | print "njdasjdajj" |
|
50 | print "njdasjdajj" | |
51 |
|
51 | |||
52 | @pyqtSignature("") |
|
52 | @pyqtSignature("") | |
53 | def on_unitPcancelbut_clicked(self): |
|
53 | def on_unitPcancelbut_clicked(self): | |
54 | """ |
|
54 | """ | |
55 | Slot documentation goes here. |
|
55 | Slot documentation goes here. | |
56 | """ |
|
56 | """ | |
57 | # TODO: not implemented yet |
|
57 | # TODO: not implemented yet | |
58 | raise NotImplementedError |
|
58 | raise NotImplementedError |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: modified file |
|
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 |
|
NO CONTENT: file was removed, binary diff hidden |
1 | NO CONTENT: file was removed, binary diff hidden |
|
NO CONTENT: file was removed, binary diff hidden |
1 | NO CONTENT: file was removed, binary diff hidden |
|
NO CONTENT: file was removed, binary diff hidden |
General Comments 0
You need to be logged in to leave comments.
Login now