basicwindow.py
1128 lines
| 44.0 KiB
| text/x-python
|
PythonLexer
|
r286 | # -*- coding: utf-8 -*- | |
""" | |||
Module implementing MainWindow. | |||
|
r322 | #+++++++++++++INTERFAZ DE USUARIO V1.1++++++++++++++# | |
|
r286 | """ | |
|
r322 | import os | |
import datetime | |||
from PyQt4.QtGui import QMainWindow | |||
from PyQt4.QtCore import pyqtSignature | |||
from PyQt4.QtCore import pyqtSignal | |||
from PyQt4 import QtCore | |||
from PyQt4 import QtGui | |||
from timeconversions import Doy2Date | |||
from modelProperties import treeModel | |||
|
r286 | ||
from viewer.ui_unitprocess import Ui_UnitProcess | |||
|
r322 | from viewer.ui_window import Ui_window | |
from viewer.ui_mainwindow import Ui_BasicWindow | |||
from controller import Project,ReadUnitConf,ProcUnitConf,OperationConf,ParameterConf | |||
|
r286 | ||
|
r322 | def isRadarFile(file): | |
|
r286 | ||
|
r322 | try: | |
year = int(file[1:5]) | |||
doy = int(file[5:8]) | |||
set = int(file[8:11]) | |||
except: | |||
return 0 | |||
return 1 | |||
def isRadarPath(path): | |||
try: | |||
year = int(path[1:5]) | |||
doy = int(path[5:8]) | |||
except: | |||
return 0 | |||
return 1 | |||
|
r286 | ||
class BasicWindow(QMainWindow, Ui_BasicWindow): | |||
|
r322 | __projObjDict = None | |
__arbolDict = None | |||
__upObjDict = None | |||
|
r286 | ||
""" | |||
Class documentation goes here. | |||
|
r322 | #*############VENTANA CUERPO DEL PROGRAMA############## | |
|
r286 | """ | |
def __init__(self, parent = None): | |||
""" | |||
Constructor | |||
""" | |||
|
r322 | print "INICIO PROGRAMA " | |
|
r286 | QMainWindow.__init__(self, parent) | |
self.setupUi(self) | |||
|
r322 | self.__projObjDict = {} | |
self.__arbolDict = {} | |||
self.__upObjDict = {} | |||
|
r330 | self.__opObjDict= {} | |
|
r286 | self.indexclick=None | |
self.online=0 | |||
self.datatype=0 | |||
|
r322 | self.dateList=[] | |
|
r286 | ||
self.proObjList=[] | |||
self.idp=0 | |||
self.namep=0 | |||
self.description=0 | |||
self.namepTree=0 | |||
self.valuep=0 | |||
self.upObjList= [] | |||
self.upn=0 | |||
self.upName=0 | |||
self.upType=0 | |||
self.uporProObjRecover=0 | |||
self.readUnitConfObjList=[] | |||
self.upObjVolList=[] | |||
self.upobjSpecList=[] | |||
self.operObjList=[] | |||
self.configProject=None | |||
self.configUP=None | |||
self.readUnitConfObj=None | |||
self.procUnitConfObj0=None | |||
self.opObj10=None | |||
self.opObj12=None | |||
|
r330 | self.setParam() | |
|
r286 | ||
|
r330 | #------------------VistadelNombreCompletousandoelpunteroSobrelosbotones---------------------------# | |
|
r286 | QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10)) | |
self.addprojectBtn.setToolTip('Add_New_Project') | |||
self.addUnitProces.setToolTip('Add_New_Processing_Unit') | |||
|
r330 | #------------------------ManejodeEventosconelmouse------------------------------------------------# | |
|
r286 | self.model = QtGui.QStandardItemModel() | |
self.treeView.setModel(self.model) | |||
self.treeView.clicked.connect(self.clickFunctiontree) | |||
|
r330 | self.treeView.doubleClicked.connect(self.doubleclickFunctiontree) | |
|
r286 | self.treeView.expandAll() | |
|
r330 | ||
#self.treeView.setReadOnly(True) | |||
self.treeView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) | |||
self.treeView.customContextMenuRequested.connect(self.popup) | |||
|
r286 | #self.treeView.clicked.connect(self.treefunction1) | |
|
r322 | ||
|
r286 | #-----------------------------------BARRA DE MENU-------------------------------------------------# | |
|
r330 | def popup(self, pos): | |
# for i in self.treeView.selectionModel().selection().indexes(): | |||
# print i.row(), i.column() | |||
menu = QtGui.QMenu() | |||
#menu.centralWidget.setObjectName(_fromUtf8("centralWidget")) | |||
quitAction0 = menu.addAction("Add Branch") | |||
quitAction1 = menu.addAction("Delete Branch") | |||
quitAction2 = menu.addAction("Exit") | |||
#quitAction2 = menu.addAction("Exit") | |||
print "pos:", pos | |||
action = menu.exec_(self.mapToGlobal(pos)) | |||
if action == quitAction0: | |||
self.addUP() | |||
if action == quitAction1: | |||
for i in self.__arbolDict: | |||
if self.__arbolDict[i]==self.indexclick: | |||
self.arbolItem=self.__arbolDict[i] | |||
print self.arbolItem | |||
self.arbolItem.removeRows(self.arbolItem.row(),1) | |||
if action == quitAction2: | |||
return | |||
|
r286 | #----------------------------------- MENU_PROJECT--------------------------------------------------# | |
@pyqtSignature("") | |||
def on_menuFileAbrirObj_triggered(self): | |||
""" | |||
Abre un archivo de configuracion seleccionado, lee los parametros y | |||
actualiza los atributos de esta clase; creando los objetos necesarios | |||
con los parametros leidos desde el archivo. | |||
""" | |||
print "Leer un archivo xml y extraer sus atributos Not implemented yet" | |||
@pyqtSignature("") | |||
def on_menuFileCrearObj_triggered(self): | |||
""" | |||
Crea un proyecto nuevo y lo anade a mi diccionario de proyectos | |||
y habilita la ventana de configuracion del proyecto. | |||
""" | |||
self.addProject() | |||
@pyqtSignature("") | |||
def on_menuFileGuardarObj_triggered(self): | |||
""" | |||
METODO EJECUTADO CUANDO OCURRE EL EVENTO GUARDAR PROJECTO | |||
Llama al metodo saveProject. | |||
""" | |||
# my_id = arbol_selected() | |||
# filename = savefindow.show() | |||
# self.saveProject(id, filename) | |||
print "probsave" | |||
self.saveProject() | |||
@pyqtSignature("") | |||
def on_menuFileCerrarObj_triggered(self): | |||
""" | |||
METODO EJECUTADO CUANDO OCURRE EL EVENTO CERRAR | |||
Llama al metodo close. | |||
""" | |||
self.close() | |||
#-----------------------------------MENU_RUN----------------------------------------------------# | |||
@pyqtSignature("") | |||
def on_menuRUNStartObj_clicked(self): | |||
""" | |||
METODO EJECUTADO CUANDO OCURRE EL EVENTO RUN | |||
Llama al metodo RUN. | |||
""" | |||
print "Not implemented yet" | |||
@pyqtSignature("") | |||
def on_menuRUNPausaObj_clicked(self): | |||
""" | |||
METODO EJECUTADO CUANDO OCURRE EL EVENTO PAUSA | |||
Llama al metodo PAUSA. | |||
""" | |||
print "Not implemented yet" | |||
#-----------------------------------MENU_OPTION-------------------------------------------------# | |||
@pyqtSignature("") | |||
def on_menuOptConfigLogfileObj_clicked(self): | |||
""" | |||
METODO EJECUTADO CUANDO OCURRE EL EVENTO ConfigLog | |||
Llama al metodo close. | |||
""" | |||
print "Not implemented yet" | |||
@pyqtSignature("") | |||
def on_menuOptConfigserverObj_clicked(self): | |||
""" | |||
METODO EJECUTADO CUANDO OCURRE EL EVENTO Config Server | |||
Llama al metodo close. | |||
""" | |||
print "Not implemented yet" | |||
#-----------------------------------MENU_HELP-------------------------------------------------------# | |||
@pyqtSignature("") | |||
def on_menuHELPAboutObj_clicked(self): | |||
""" | |||
METODO EJECUTADO CUANDO OCURRE EL EVENTO HELP | |||
Llama al metodo close. | |||
""" | |||
print "Not implemented yet" | |||
@pyqtSignature("") | |||
def on_menuHELPPrfObj_clicked(self): | |||
""" | |||
METODO EJECUTADO CUANDO OCURRE EL EVENTO HElp | |||
Llama al metodo close. | |||
""" | |||
print "Not implemented yet" | |||
#-----------------------------------BARRA DE HERRAMIENTAS----------------------------------------# | |||
@pyqtSignature("") | |||
def on_actOpenObj_triggered(self): | |||
""" | |||
METODO CARGA UN ARCHIVO DE CONFIGURACION ANTERIOR | |||
""" | |||
print "Leer un archivo xml y extraer sus atributos Not implemented yet" | |||
@pyqtSignature("") | |||
def on_actCreateObj_triggered(self): | |||
""" | |||
CREAR PROJECT ,ANADE UN NUEVO PROYECTO, LLAMA AL MÉTODO QUE CONTIENE LAS OPERACION DE CREACION DE PROYECTOS | |||
Llama al metodo addProject. | |||
""" | |||
self.addProject() | |||
@pyqtSignature("") | |||
def on_actStopObj_triggered(self): | |||
""" | |||
METODO EJECUTADO CUANDO OCURRE EL EVENTO PAUSA | |||
Llama al metodo PAUSA. | |||
""" | |||
print "Not implemented yet" | |||
@pyqtSignature("") | |||
def on_actPlayObj_triggered(self): | |||
""" | |||
METODO EJECUTADO CUANDO OCURRE EL EVENTO PAUSA | |||
Llama al metodo PAUSA. | |||
""" | |||
print "Not implemented yet" | |||
@pyqtSignature("") | |||
def on_actSaveObj_triggered(self): | |||
""" | |||
METODO EJECUTADO CUANDO OCURRE EL EVENTO SAVE | |||
Llama al metodo SAVE. | |||
""" | |||
self.saveProject() | |||
#-----------------------------------PUSHBUTTON_CREATE PROJECT----------------------------------# | |||
@pyqtSignature("") | |||
def on_addprojectBtn_clicked(self): | |||
""" | |||
CREAR PROJECT ,ANADE UN NUEVO PROYECTO, LLAMA AL MÉTODO QUE CONTIENE LAS OPERACION DE CREACION DE PROYECTOS | |||
Llama al metodo addProject. | |||
""" | |||
self.addProject() | |||
|
r330 | self.setProjectParam() | |
|
r286 | ||
#------------------------------------VENTANA CONFIGURACION PROJECT----------------------------# | |||
@pyqtSignature("int") | |||
def on_dataTypeCmbBox_activated(self,index): | |||
""" | |||
Metodo que identifica que tipo de dato se va a trabajar VOLTAGE O ESPECTRA | |||
""" | |||
self.dataFormatTxt.setReadOnly(True) | |||
if index==0: | |||
|
r322 | self.datatype='.r' | |
|
r286 | elif index==1: | |
|
r322 | self.datatype='.pdata' | |
|
r286 | else : | |
self.datatype='' | |||
self.dataFormatTxt.setReadOnly(False) | |||
|
r322 | self.dataFormatTxt.setText(self.datatype) | |
self.loadDays() | |||
|
r286 | ||
@pyqtSignature("") | |||
def on_dataPathBrowse_clicked(self): | |||
""" | |||
OBTENCION DE LA RUTA DE DATOS | |||
""" | |||
self.dataPath = str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)) | |||
self.dataPathTxt.setText(self.dataPath) | |||
|
r322 | ||
|
r330 | self.starDateCmbBox.clear() | |
|
r322 | self.endDateCmbBox.clear() | |
if not os.path.exists(self.dataPath): | |||
self.dataOkBtn.setEnabled(False) | |||
return | |||
self.loadDays() | |||
|
r286 | ||
@pyqtSignature("int") | |||
def on_starDateCmbBox_activated(self, index): | |||
""" | |||
SELECCION DEL RANGO DE FECHAS -START DATE | |||
""" | |||
|
r322 | stopIndex = self.endDateCmbBox.count() - self.endDateCmbBox.currentIndex() | |
|
r286 | self.endDateCmbBox.clear() | |
|
r322 | ||
for i in self.dateList[index:]: | |||
|
r286 | self.endDateCmbBox.addItem(i) | |
|
r322 | ||
self.endDateCmbBox.setCurrentIndex(self.endDateCmbBox.count() - stopIndex) | |||
|
r286 | ||
@pyqtSignature("int") | |||
def on_endDateCmbBox_activated(self, index): | |||
""" | |||
SELECCION DEL RANGO DE FECHAS-END DATE | |||
""" | |||
|
r322 | startIndex=self.starDateCmbBox.currentIndex() | |
stopIndex = self.endDateCmbBox.count() - index | |||
|
r286 | self.starDateCmbBox.clear() | |
|
r322 | for i in self.dateList[:len(self.dateList) - stopIndex + 1]: | |
|
r286 | self.starDateCmbBox.addItem(i) | |
|
r322 | self.starDateCmbBox.setCurrentIndex(startIndex) | |
|
r286 | ||
@pyqtSignature("int") | |||
def on_readModeCmBox_activated(self, p0): | |||
""" | |||
SELECCION DEL MODO DE LECTURA ON=1, OFF=0 | |||
""" | |||
if p0==0: | |||
self.online=0 | |||
elif p0==1: | |||
self.online=1 | |||
#---------------PUSHBUTTON_DATA " OKBUTTON "_CONFIGURATION PROJECT--------------------------# | |||
@pyqtSignature("") | |||
def on_dataOkBtn_clicked(self): | |||
""" | |||
Añade al Obj XML de Projecto, name,datatype,date,time,readmode,wait,etc, crea el readUnitProcess del archivo xml. | |||
Prepara la configuración del diágrama del Arbol del treeView numero 2 | |||
""" | |||
|
r330 | print "DATOS DEL PROJECT PATH,DATE,TIME" | |
|
r322 | ||
|
r286 | # print self.projectObj | |
# print i | |||
# print "get",self.__arbolDict.items() | |||
# print "keys",self.__arbolDict.keys() | |||
|
r322 | ||
self.idp += 1 | |||
self.projectObj = Project() | |||
self.__projObjDict[self.idp] = self.projectObj | |||
|
r330 | self.description="Think" | |
id = self.idp | |||
name = str(self.nameProjectTxt.text()) | |||
desc = str(self.description) | |||
|
r322 | ||
self.projectObj.setup(id = id, name=name, description=desc) | |||
print "self.projectObj.id",self.projectObj.id | |||
|
r330 | ||
#-------AÑADIENDO PARAMETROS A LA UNIDAD DE LECTURA---------# | |||
|
r322 | ||
|
r330 | datatype = str(self.dataTypeCmbBox.currentText()) | |
path = str(self.dataPathTxt.text()) | |||
online = int(self.online) | |||
starDate = str(self.starDateCmbBox.currentText()) | |||
endDate = str(self.endDateCmbBox.currentText()) | |||
|
r322 | reloj1=self.startTimeEdit.time() | |
|
r330 | ||
|
r322 | reloj2=self.timeEdit_2.time() | |
|
r330 | ||
|
r322 | print reloj1.hour() | |
print reloj1.minute() | |||
print reloj1.second() | |||
|
r330 | self.readUnitConfObj = self.projectObj.addReadUnit(datatype = datatype, | |
path = path, | |||
startDate = starDate, | |||
endDate = endDate, | |||
startTime = str(reloj1.hour()) +":"+str(reloj1.minute())+":"+ str(reloj1.second()), | |||
endTime = str(reloj2.hour()) +":"+str(reloj2.minute())+":"+ str(reloj2.second()), | |||
online = online) | |||
print self.readUnitConfObj.datatype,"self.readUnitConfObj.datatype" | |||
self.readUnitConfObjList.append(self.readUnitConfObj) | |||
#--------VISUALIZACION EN LA VENTANA PROJECT PROPERTIES-----------------# | |||
|
r322 | self.model_2=treeModel() | |
|
r330 | self.model_2.setParams(name = self.projectObj.name, | |
directorio = path, | |||
workspace = "C:\\WorkspaceGUI", | |||
remode = str(self.readModeCmBox.currentText()), | |||
dataformat = datatype, | |||
date = str(starDate)+"-"+str(endDate), | |||
initTime = str(reloj1.hour()) +":"+str(reloj1.minute())+":"+ str(reloj1.second()), | |||
endTime = str(reloj2.hour()) +":"+str(reloj2.minute())+":"+ str(reloj2.second()), | |||
timezone = "Local" , | |||
Summary = "test de prueba") | |||
|
r286 | ||
|
r322 | self.model_2.arbol() | |
self.treeView_2.setModel(self.model_2) | |||
|
r330 | self.treeView_2.expandAll() | |
#--------CREACIÓNDELDIAGRAMADELARBOL------------------------# | |||
|
r322 | self.parentItem = self.model.invisibleRootItem() | |
#self.__arbolDict[self.idp] = QtGui.QStandardItem(QtCore.QString(name).arg(self.idp)) | |||
self.__arbolDict[self.idp] = QtGui.QStandardItem(QtCore.QString(name).arg(self.idp)) | |||
print self.__arbolDict[self.idp] | |||
self.parentItem.appendRow(self.__arbolDict[self.idp]) | |||
self.parentItem=self.__arbolDict[self.idp] | |||
|
r330 | ||
#--------BLOQUEO-------# | |||
|
r322 | self.tabProject.setEnabled(False) | |
|
r286 | #-----------------PUSHBUTTON_ADD_PROCESSING UNIT PROJECT------------------# | |
@pyqtSignature("") | |||
def on_addUnitProces_clicked(self): | |||
""" | |||
|
r330 | CREAR PROCESSING UNIT ,añade unidad de procesamiento, LLAMA AL MÉTODO addUP QUE CONTIENE LAS OPERACION DE CREACION DE UNIDADES DE PROCESAMIENTO | |
|
r286 | Llama al metodo addUP. | |
""" | |||
|
r330 | self.addUP() | |
|
r286 | ||
def setParam(self): | |||
self.tabWidgetProject.setEnabled(False) | |||
|
r322 | self.tabVoltage.setEnabled(False) | |
self.tabSpectra.setEnabled(False) | |||
self.tabCorrelation.setEnabled(False) | |||
|
r286 | self.dataPathTxt.setText('C:\data') | |
self.nameProjectTxt.setText("Test") | |||
self.numberChannelopVol.setEnabled(False) | |||
self.lineHeighProfileTxtopVol.setEnabled(False) | |||
self.numberIntegration.setEnabled(False) | |||
self.valuenFFTPointOpSpec.setEnabled(False) | |||
self.lineProfileSelecopVolCEB.setEnabled(False) | |||
|
r330 | ||
def setProjectParam(self): | |||
self.nameProjectTxt.setText("Test") | |||
self.dataPathTxt.setText('C:\data') | |||
self.dataTypeCmbBox.clear() | |||
self.dataTypeCmbBox.addItem("Voltage") | |||
self.dataTypeCmbBox.addItem("Spectra") | |||
startTime="00:00:00" | |||
endTime="23:59:59" | |||
starlist=startTime.split(":") | |||
endlist=endTime.split(":") | |||
print starlist[0],starlist[1],starlist[2] | |||
print endlist[0],endlist[1],endlist[2] | |||
self.time.setHMS(int(starlist[0]),int(starlist[1]),int(starlist[2])) | |||
self.startTimeEdit.setTime(self.time) | |||
self.time.setHMS(int(endlist[0]),int(endlist[1]),int(endlist[2])) | |||
self.timeEdit_2.setTime(self.time) | |||
|
r286 | def clickFunctiontree(self,index): | |
|
r330 | ||
|
r286 | self.indexclick= index.model().itemFromIndex(index) | |
|
r322 | print "OPCION CLICK" | |
print "ArbolDict",self.indexclick | |||
print "name:",self.indexclick.text() | |||
#print self.tabWidgetProject.currentIndex() | |||
|
r330 | ||
def doubleclickFunctiontree(self): | |||
|
r322 | for i in self.__arbolDict: | |
if self.__arbolDict[i]==self.indexclick: | |||
print "INDEXCLICK=ARBOLDICT",i | |||
if self.__projObjDict.has_key(i)==True: | |||
self.tabWidgetProject.setCurrentWidget(self.tabProject) | |||
|
r330 | self.nameProjectTxt.setText(str(self.__projObjDict[i].name)) | |
self.dataTypeCmbBox.clear() | |||
self.dataTypeCmbBox.addItem(str(self.readUnitConfObjList[i-1].datatype)) | |||
print str(self.readUnitConfObjList[i-1].path) | |||
self.dataPathTxt.setText(str(self.readUnitConfObjList[i-1].path)) | |||
self.starDateCmbBox.clear() | |||
self.endDateCmbBox.clear() | |||
self.starDateCmbBox.addItem(str(self.readUnitConfObjList[i-1].startDate)) | |||
self.endDateCmbBox.addItem(str(self.readUnitConfObjList[i-1].endDate)) | |||
startTime=self.readUnitConfObjList[i-1].startTime | |||
endTime=self.readUnitConfObjList[i-1].endTime | |||
starlist=startTime.split(":") | |||
endlist=endTime.split(":") | |||
print starlist[0],starlist[1],starlist[2] | |||
print endlist[0],endlist[1],endlist[2] | |||
self.time.setHMS(int(starlist[0]),int(starlist[1]),int(starlist[2])) | |||
self.startTimeEdit.setTime(self.time) | |||
self.time.setHMS(int(endlist[0]),int(endlist[1]),int(endlist[2])) | |||
self.timeEdit_2.setTime(self.time) | |||
#--------VISUALIZACION EN LA VENTANA PROJECT PROPERTIES-----------------# | |||
self.model_2=treeModel() | |||
self.model_2.setParams(name = str(self.__projObjDict[i].name), | |||
directorio = str(self.readUnitConfObjList[i-1].path), | |||
workspace = "C:\\WorkspaceGUI", | |||
remode = str(self.readModeCmBox.currentText()), | |||
dataformat = "Voltage", | |||
date = str(self.readUnitConfObjList[i-1].startDate)+"-"+str(self.readUnitConfObjList[i-1].endDate), | |||
initTime = str(starlist[0]) +":"+str(starlist[1])+":"+ str(starlist[2]), | |||
endTime = str(endlist[0]) +":"+str(endlist[1])+":"+ str(endlist[2]), | |||
timezone = "Local" , | |||
Summary = "test de prueba") | |||
self.model_2.arbol() | |||
self.treeView_2.setModel(self.model_2) | |||
self.treeView_2.expandAll() | |||
#self.dataPathTxt.setText(str(self.__projObjDict[i].addReadUnit.path())) | |||
|
r322 | ||
if self.indexclick.text()=='Voltage': | |||
self.tabVoltage.setEnabled(True) | |||
self.tabWidgetProject.setCurrentWidget(self.tabVoltage) | |||
|
r330 | # for i in self.__opObjDict[i] | |
# self.OpObj= | |||
|
r322 | ||
if self.indexclick.text()=='Spectra': | |||
self.tabSpectra.setEnabled(True) | |||
self.tabWidgetProject.setCurrentWidget(self.tabSpectra) | |||
if self.indexclick.text()=='Correlation': | |||
self.tabCorrelation.setEnabled(True) | |||
self.tabWidgetProject.setCurrentWidget(self.tabCorrelation) | |||
|
r330 | ||
|
r286 | def addProject(self): | |
|
r330 | ||
|
r286 | self.tabWidgetProject.setEnabled(True) | |
|
r330 | #---------------KILL-----------------# | |
# self.tabWidgetProject.setTabsClosable(True) | |||
# self.tabWidgetProject.tabCloseRequested.connect(self.tabWidgetProject.removeTab) | |||
#------------------------------------# | |||
|
r322 | self.tabWidgetProject.setCurrentWidget(self.tabProject) | |
self.tabProject.setEnabled(True) | |||
#self.tabVoltage.setEnabled(False) | |||
|
r330 | print "HABILITA WIDGET" | |
|
r286 | ||
def existDir(self, var_dir): | |||
""" | |||
METODO PARA VERIFICAR SI LA RUTA EXISTE-VAR_DIR | |||
VARIABLE DIRECCION | |||
""" | |||
if os.path.isdir(var_dir): | |||
return True | |||
else: | |||
self.textEdit.append("Incorrect path:" + str(var_dir)) | |||
return False | |||
|
r322 | def searchData(self, path, ext, expLabel='', walk=1): | |
dateList = [] | |||
fileList = [] | |||
if walk == 0: | |||
files = os.listdir(path) | |||
for thisFile in files: | |||
if not os.path.isfile(thisFile): | |||
continue | |||
thisExt = os.path.splitext(thisFile)[-1] | |||
if thisExt != ext: | |||
continue | |||
fileList.append(file) | |||
for thisFile in fileList: | |||
if not isRadarFile(thisFile): | |||
continue | |||
year = int(thisFile[1:5]) | |||
doy = int(thisFile[5:8]) | |||
date = datetime.date(year,1,1) + datetime.timedelta(doy-1) | |||
dateformat = date.strftime("%Y/%m/%d") | |||
if dateformat not in dateList: | |||
dateList.append(dateformat) | |||
if walk == 1: | |||
dirList = os.listdir(path) | |||
dirList.sort() | |||
dateList = [] | |||
for thisDir in dirList: | |||
if not isRadarPath(thisDir): | |||
continue | |||
doypath = os.path.join(path, thisDir, expLabel) | |||
files = os.listdir(doypath) | |||
fileList = [] | |||
for thisFile in files: | |||
if os.path.splitext(thisFile)[-1] != ext: | |||
continue | |||
if not isRadarFile(thisFile): | |||
continue | |||
fileList.append(thisFile) | |||
break | |||
if fileList == []: | |||
continue | |||
year = int(thisDir[1:5]) | |||
doy = int(thisDir[5:8]) | |||
date = datetime.date(year,1,1) + datetime.timedelta(doy-1) | |||
dateformat = date.strftime("%Y/%m/%d") | |||
dateList.append(dateformat) | |||
return dateList | |||
|
r286 | def loadDays(self): | |
""" | |||
METODO PARA CARGAR LOS DIAS | |||
""" | |||
|
r322 | ext = self.datatype | |
path = str(self.dataPathTxt.text()) | |||
|
r286 | self.starDateCmbBox.clear() | |
self.endDateCmbBox.clear() | |||
|
r322 | dateList = self.searchData(path, ext=ext) | |
#Se cargan las listas para seleccionar StartDay y StopDay (QComboBox) | |||
self.dateList = dateList | |||
|
r286 | ||
|
r322 | for thisDate in dateList: | |
self.starDateCmbBox.addItem(thisDate) | |||
self.endDateCmbBox.addItem(thisDate) | |||
self.endDateCmbBox.setCurrentIndex(self.starDateCmbBox.count()-1) | |||
self.dataOkBtn.setEnabled(True) | |||
def HourChanged(self): | |||
#self.hour = self.HourScrollBar.value() | |||
self.set_time() | |||
|
r286 | ||
|
r322 | def MinChanged(self): | |
#self.min = self.MinScrollBar.value() | |||
self.set_time() | |||
def SecChanged(self): | |||
#self.sec = self.SecScrollBar.value() | |||
self.set_time() | |||
def set_time(self): | |||
self.time.setHMS(self.hour, self.min, self.sec) | |||
self.startTimeEdit.setTime(self.time) | |||
|
r286 | ||
|
r322 | self.timeEdit_2.setTime(self.time) | |
|
r286 | ||
def addUP(self): | |||
self.configUP=UnitProcess(self) | |||
|
r322 | ||
|
r286 | for i in self.__arbolDict: | |
if self.__arbolDict[i]==self.indexclick: | |||
|
r322 | print "INDEXCLICK=ARBOLDICT",i | |
|
r286 | if self.__projObjDict.has_key(i)==True: | |
self.projectObj=self.__projObjDict[int(i)] | |||
|
r322 | print "self.projectObj.id",self.projectObj.id | |
|
r330 | #-----------Añadiendo Tipo de dato y Projecto a la Clase UnitProcess que abre la ventana de selección----# | |
|
r322 | self.configUP.dataTypeProject=str(self.dataTypeCmbBox.currentText()) | |
|
r286 | self.configUP.getfromWindowList.append(self.projectObj) | |
|
r322 | ||
|
r330 | # for i in self.projectObj.procUnitConfObjDict: | |
# if self.projectObj.procUnitConfObjDict[i].getElementName()=='ProcUnit': | |||
# self.upObj=self.projectObj.procUnitConfObjDict[i] | |||
# self.configUP.getfromWindowList.append(self.upObj) | |||
|
r322 | else: | |
|
r330 | #-----------Añadiendo Unidad de Procesamiento a una Unidad de Procesamiento----# | |
|
r322 | self.upObj=self.__upObjDict[i] | |
print "self.upObj.id",self.upObj.id | |||
self.configUP.getfromWindowList.append(self.upObj) | |||
|
r330 | ||
|
r286 | self.configUP.loadTotalList() | |
self.configUP.show() | |||
self.configUP.closed.connect(self.createUP) | |||
def createUP(self): | |||
|
r322 | print "ADICION DE BRANCH Y ID" | |
|
r286 | ||
if not self.configUP.create: | |||
return | |||
self.uporProObjRecover=self.configUP.getFromWindow | |||
self.upType = self.configUP.typeofUP | |||
for i in self.__arbolDict: | |||
|
r322 | print self.__arbolDict[i],"VALORES DEL DIC" | |
|
r286 | if self.__arbolDict[i]==self.indexclick: | |
|
r322 | if self.__projObjDict.has_key(i)==True: | |
# print "self.__projObjDict[int(i)]" ,__projObjDict[int(i)] | |||
self.projectObj=self.__projObjDict[int(i)] | |||
print self.__projObjDict[int(i)] | |||
if self.__upObjDict.has_key(i)==True: | |||
print "Entro al else" | |||
print self.__upObjDict.items() | |||
self.upObj=self.__upObjDict[i] | |||
getIdProject=self.upObj.id[0] | |||
print getIdProject | |||
self.projectObj=self.__projObjDict[int(getIdProject)] | |||
|
r286 | ||
datatype=str(self.upType) | |||
uporprojectObj=self.uporProObjRecover | |||
if uporprojectObj.getElementName()=='ProcUnit': | |||
inputId=uporprojectObj.getId() | |||
else: | |||
inputId=self.readUnitConfObjList[uporprojectObj.id-1].getId() | |||
|
r322 | print 'uporprojectObj.id:',uporprojectObj.id,'inputId:',inputId | |
|
r286 | self.procUnitConfObj1 = self.projectObj.addProcUnit(datatype=datatype, inputId=inputId) | |
|
r317 | self.__upObjDict[self.procUnitConfObj1.id]= self.procUnitConfObj1 | |
|
r322 | print "PRIMERA UP_VEAMOS",self.__upObjDict.items() | |
|
r286 | self.parentItem=self.__arbolDict[uporprojectObj.id] | |
#print "i","self.__arbolDict[i]",i ,self.__arbolDict[i] | |||
self.numbertree=int(self.procUnitConfObj1.getId())-1 | |||
|
r322 | print self.procUnitConfObj1.id," ID DE LA UNIDAD DE PROCESAMIENTO " | |
#self.__arbolDict[self.procUnitConfObj1.id]=QtGui.QStandardItem(QtCore.QString(datatype+"%1").arg(self.numbertree)) | |||
|
r330 | ||
|
r322 | self.__arbolDict[self.procUnitConfObj1.id]=QtGui.QStandardItem(QtCore.QString(datatype).arg(self.numbertree)) | |
|
r286 | self.parentItem.appendRow(self.__arbolDict[self.procUnitConfObj1.id]) | |
self.parentItem=self.__arbolDict[self.procUnitConfObj1.id] | |||
# self.loadUp() | |||
self.treeView.expandAll() | |||
def resetopVolt(self): | |||
self.selecChannelopVolCEB.setChecked(False) | |||
self.selecHeighopVolCEB.setChecked(False) | |||
self.coherentIntegrationCEB.setChecked(False) | |||
self.profileSelecopVolCEB.setChecked(False) | |||
#self.selecChannelopVolCEB.setEnabled(False) | |||
self.lineHeighProfileTxtopVol.clear() | |||
self.lineProfileSelecopVolCEB.clear() | |||
self.numberChannelopVol.clear() | |||
self.numberIntegration.clear() | |||
def resetopSpec(self): | |||
|
r330 | self.nFFTPointOpSpecCEB.setChecked(False) | |
|
r286 | self.valuenFFTPointOpSpec.clear() | |
def resetgraphSpec(self): | |||
self.SpectraPlotGraphCEB.setChecked(False) | |||
self.CrossSpectraPlotGraphceb.setChecked(False) | |||
self.RTIPlotGraphCEB.setChecked(False) | |||
def saveProject(self): | |||
print "entro" | |||
#filename="C:\WorkspaceGUI\config1.xml" | |||
for i in self.__arbolDict: | |||
if self.__arbolDict[i]==self.indexclick: | |||
|
r330 | self.projectObj=self.__projObjDict[i] | |
|
r286 | print "Encontre project" | |
filename="C:\WorkspaceGUI\config"+str(self.projectObj.id)+".xml" | |||
print "Escribo Project" | |||
self.projectObj.writeXml(filename) | |||
|
r330 | ||
# -----------------VENTANA CONFIGURACION DE VOLTAGE---------------------------# | |||
@pyqtSignature("int") | |||
def on_selecChannelopVolCEB_stateChanged(self, p0): | |||
""" | |||
Check Box habilita operaciones de Selecci�n de Canales | |||
""" | |||
if p0==2: | |||
self.numberChannelopVol.setEnabled(True) | |||
# upProcessSelect=self.upObjVolList[int(self.addOpUpselec.currentIndex())] | |||
# opObj10=upProcessSelect.addOperation(name='selectChannels') | |||
# print opObj10.id | |||
# self.operObjList.append(opObj10) | |||
print " Ingresa seleccion de Canales" | |||
if p0==0: | |||
self.numberChannelopVol.setEnabled(False) | |||
print " deshabilitado" | |||
@pyqtSignature("int") | |||
def on_selecHeighopVolCEB_stateChanged(self, p0): | |||
""" | |||
Check Box habilita operaciones de Selecci�n de Alturas | |||
""" | |||
if p0==2: | |||
self.lineHeighProfileTxtopVol.setEnabled(True) | |||
# upProcessSelect=self.upObjVolList[int(self.addOpUpselec.currentIndex())] | |||
# opObj10=upProcessSelect.addOperation(name='selectHeights') | |||
# print opObj10.id | |||
# self.operObjList.append(opObj10) | |||
print " Select Type of Profile" | |||
if p0==0: | |||
self.lineHeighProfileTxtopVol.setEnabled(False) | |||
print " deshabilitado" | |||
@pyqtSignature("int") | |||
def on_profileSelecopVolCEB_stateChanged(self, p0): | |||
""" | |||
Check Box habilita ingreso del rango de Perfiles | |||
""" | |||
if p0==2: | |||
self.lineProfileSelecopVolCEB.setEnabled(True) | |||
# upProcessSelect=self.upObjVolList[int(self.addOpUpselec.currentIndex())] | |||
# opObj10=upProcessSelect.addOperation(name='ProfileSelector', optype='other') | |||
# print opObj10.id | |||
# self.operObjList.append(opObj10) | |||
print " Select Type of Profile" | |||
if p0==0: | |||
self.lineProfileSelecopVolCEB.setEnabled(False) | |||
print " deshabilitado" | |||
@pyqtSignature("int") | |||
def on_coherentIntegrationCEB_stateChanged(self, p0): | |||
""" | |||
Check Box habilita ingresode del numero de Integraciones a realizar | |||
""" | |||
if p0==2: | |||
self.numberIntegration.setEnabled(True) | |||
# upProcessSelect=self.upObjVolList[int(self.addOpUpselec.currentIndex())] | |||
# opObj10=upProcessSelect.addOperation(name='CohInt', optype='other') | |||
# print opObj10.id | |||
# self.operObjList.append(opObj10) | |||
print "Choose number of Cohint" | |||
if p0==0: | |||
print " deshabilitado" | |||
self.numberIntegration.setEnabled(False) | |||
#-----------------------PUSHBUTTON_ACCEPT_OPERATION----------------------------# | |||
@pyqtSignature("") | |||
def on_dataopVolOkBtn_clicked(self): | |||
""" | |||
BUSCA EN LA LISTA DE OPERACIONES DEL TIPO VOLTAJE Y LES A�ADE EL PARAMETRO ADECUADO ESPERANDO LA ACEPTACION DEL USUARIO | |||
PARA AGREGARLO AL ARCHIVO DE CONFIGURACION XML | |||
""" | |||
for i in self.__arbolDict: | |||
if self.__arbolDict[i]==self.indexclick: | |||
print "INDEXCLICK=ARBOLDICT",i | |||
if self.__upObjDict.has_key(i)==True: | |||
self.upObj=self.__upObjDict[i] | |||
# self.operObjList.append(opObj10) | |||
if self.selecChannelopVolCEB.isChecked(): | |||
opObj10=self.upObj.addOperation(name='selectChannels') | |||
self.operObjList.append(opObj10) | |||
value=self.numberChannelopVol.text() | |||
opObj10.addParameter(name='channelList', value=value, format='intlist') | |||
print "channel" | |||
if self.selecHeighopVolCEB.isChecked(): | |||
opObj10=self.upObj.addOperation(name='selectHeights') | |||
print opObj10.id | |||
self.operObjList.append(opObj10) | |||
value=self.lineHeighProfileTxtopVol.text() | |||
valueList=value.split(',') | |||
opObj10.addParameter(name='minHei', value=valueList[0], format='float') | |||
opObj10.addParameter(name='maxHei', value=valueList[1], format='float') | |||
print "height" | |||
if self.selecHeighopVolCEB.isChecked(): | |||
obj10=self.upObj.addOperation(name='ProfileSelector', optype='other') | |||
print opObj10.id | |||
self.operObjList.append(opObj10) | |||
value=self.lineProfileSelecopVolCEB.text() | |||
obj10.addParameter(name='ProfileSelector', value=value, format='intlist') | |||
# for i in self.operObjList: | |||
# if i.name=='ProfileSelector' : | |||
# value=self.lineProfileSelecopVolCEB.text() | |||
# i.addParameter(name='ProfileSelector', value=value, format='intlist') | |||
if self.coherentIntegrationCEB.isChecked(): | |||
opObj10=self.upObj.addOperation(name='CohInt', optype='other') | |||
print opObj10.id | |||
self.operObjList.append(opObj10) | |||
value=self.numberIntegration.text() | |||
opObj10.addParameter(name='n', value=value, format='int') | |||
# self.__opObjDict[i]==self.operObjList | |||
#-------------------------VENTANA DE CONFIGURACION SPECTRA------------------------# | |||
@pyqtSignature("int") | |||
def on_nFFTPointOpSpecCEB_stateChanged(self, p0): | |||
""" | |||
Habilita la opcion de a�adir el par�metro nFFTPoints a la Unidad de Procesamiento . | |||
""" | |||
if p0==2: | |||
self.valuenFFTPointOpSpec.setEnabled(True) | |||
print " nFFTPoint" | |||
if p0==0: | |||
print " deshabilitado" | |||
self.valuenFFTPointOpSpec.setEnabled(False) | |||
@pyqtSignature("") | |||
def on_dataopSpecOkBtn_clicked(self): | |||
""" | |||
A�ade al archivo de configuraci�n el par�metros nFFTPoints a la UP. | |||
""" | |||
print "A�adimos operaciones Spectra,nchannels,value,format" | |||
for i in self.__arbolDict: | |||
if self.__arbolDict[i]==self.indexclick: | |||
print "INDEXCLICK=ARBOLDICT",i | |||
if self.__upObjDict.has_key(i)==True: | |||
self.upObj=self.__upObjDict[i] | |||
# self.operObjList.append(opObj10) | |||
if self.nFFTPointOpSpecCEB.isChecked(): | |||
value=self.numberChannelopVol.text() | |||
self.upObj.addParameter(name='nFFTPoints',value=value,format='int') | |||
print "nFFTpoints" | |||
#---------------------VENTANA DE CONFIGURACION GRAPH SPECTRA------------------# | |||
@pyqtSignature("int") | |||
def on_SpectraPlotGraphCEB_stateChanged(self, p0): | |||
""" | |||
Habilita la opcion de Ploteo Spectra Plot | |||
""" | |||
if p0==2: | |||
print "Habilitado" | |||
if p0==0: | |||
print " deshabilitado" | |||
@pyqtSignature("int") | |||
def on_CrossSpectraPlotGraphceb_stateChanged(self, p0): | |||
""" | |||
Habilita la opci�n de Ploteo CrossSpectra | |||
""" | |||
if p0==2: | |||
print "Habilitado" | |||
if p0==0: | |||
print " deshabilitado" | |||
@pyqtSignature("int") | |||
def on_RTIPlotGraphCEB_stateChanged(self, p0): | |||
""" | |||
Habilita la opci�n de Plote RTIPlot | |||
""" | |||
if p0==2: | |||
print "Habilitado" | |||
if p0==0: | |||
print " deshabilitado" | |||
#------------------PUSH_BUTTON_SPECTRA_GRAPH_OK-----------------------------# | |||
@pyqtSignature("") | |||
def on_dataGraphSpecOkBtn_clicked(self): | |||
""" | |||
HABILITAR DE ACUERDO A LOS CHECKBOX QUE TIPO DE PLOTEOS SE VAN A REALIZAR MUESTRA Y GRABA LAS IMAGENES. | |||
""" | |||
for i in self.__arbolDict: | |||
if self.__arbolDict[i]==self.indexclick: | |||
print "INDEXCLICK=ARBOLDICT",i | |||
if self.__upObjDict.has_key(i)==True: | |||
self.upObj=self.__upObjDict[i] | |||
print "Graficar Spec op" | |||
if self.SpectraPlotGraphCEB_2.isChecked(): | |||
opObj10=self.upObj.addOperation(name='SpectraPlot',optype='other') | |||
print opObj10.id | |||
self.operObjList.append(opObj10) | |||
for i in self.operObjList: | |||
if i.name=='SpectraPlot': | |||
i.addParameter(name='idfigure', value='1', format='int') | |||
i.addParameter(name='wintitle', value='SpectraPlot0', format='str') | |||
i.addParameter(name='zmin', value='40', format='int') | |||
i.addParameter(name='zmax', value='90', format='int') | |||
i.addParameter(name='showprofile', value='1', format='int') | |||
if self.CrossSpectraPlotGraphceb.isChecked(): | |||
opObj10=self.upObj.addOperation(name='CrossSpectraPlot',optype='other') | |||
print opObj10.id | |||
self.operObjList.append(opObj10) | |||
for i in self.operObjList: | |||
if i.name=='CrossSpectraPlot' : | |||
i.addParameter(name='idfigure', value='2', format='int') | |||
i.addParameter(name='wintitle', value='CrossSpectraPlot', format='str') | |||
i.addParameter(name='zmin', value='40', format='int') | |||
i.addParameter(name='zmax', value='90', format='int') | |||
if self.RTIPlotGraphCEB.isChecked(): | |||
opObj10=self.upObj.addOperation(name='RTIPlot',optype='other') | |||
print opObj10.id | |||
self.operObjList.append(opObj10) | |||
for i in self.operObjList: | |||
if i.name=='RTIPlot': | |||
i.addParameter(name='n', value='2', format='int') | |||
i.addParameter(name='overlapping', value='1', format='int') | |||
|
r286 | class UnitProcess(QMainWindow, Ui_UnitProcess): | |
""" | |||
Class documentation goes here. | |||
""" | |||
closed=pyqtSignal() | |||
create= False | |||
def __init__(self, parent = None): | |||
""" | |||
Constructor | |||
""" | |||
QMainWindow.__init__(self, parent) | |||
self.setupUi(self) | |||
self.getFromWindow=None | |||
self.getfromWindowList=[] | |||
|
r322 | self.dataTypeProject=None | |
|
r286 | ||
self.listUP=None | |||
@pyqtSignature("") | |||
def on_unitPokbut_clicked(self): | |||
""" | |||
Slot documentation goes here. | |||
""" | |||
self.create =True | |||
self.getFromWindow=self.getfromWindowList[int(self.comboInputBox.currentIndex())] | |||
#self.nameofUP= str(self.nameUptxt.text()) | |||
self.typeofUP= str(self.comboTypeBox.currentText()) | |||
self.close() | |||
@pyqtSignature("") | |||
def on_unitPcancelbut_clicked(self): | |||
""" | |||
Slot documentation goes here. | |||
""" | |||
self.create=False | |||
self.close() | |||
def loadTotalList(self): | |||
self.comboInputBox.clear() | |||
for i in self.getfromWindowList: | |||
name=i.getElementName() | |||
|
r330 | print "name",name | |
|
r286 | if name=='Project': | |
id= i.id | |||
name=i.name | |||
|
r330 | print "tipodeproyecto",self.dataTypeProject | |
if self.dataTypeProject=='Voltage': | |||
self.comboTypeBox.clear() | |||
self.comboTypeBox.addItem("Voltage") | |||
self.comboTypeBox.addItem("Spectra") | |||
self.comboTypeBox.addItem("Correlation") | |||
|
r322 | if self.dataTypeProject=='Spectra': | |
self.comboTypeBox.clear() | |||
self.comboTypeBox.addItem("Spectra") | |||
self.comboTypeBox.addItem("Correlation") | |||
|
r286 | if name=='ProcUnit': | |
id=int(i.id)-1 | |||
name=i.datatype | |||
|
r322 | if name == 'Voltage': | |
self.comboTypeBox.clear() | |||
self.comboTypeBox.addItem("Spectra") | |||
self.comboTypeBox.addItem("Correlation") | |||
if name == 'Spectra': | |||
self.comboTypeBox.clear() | |||
self.comboTypeBox.addItem("Spectra") | |||
self.comboTypeBox.addItem("Correlation") | |||
|
r286 | ||
|
r330 | self.comboInputBox.addItem(str(name)) | |
#self.comboInputBox.addItem(str(name)+str(id)) | |||
|
r286 | ||
def closeEvent(self, event): | |||
self.closed.emit() | |||
event.accept() | |||
|
r330 | ||