Commit ffbf973f authored by Alisson Claudino's avatar Alisson Claudino
Browse files

Funcionando o código separado em classes, nomeação de componentes gráficos e...

Funcionando o código separado em classes, nomeação de componentes gráficos e alteração dinâmica de escala de gráficos
parent 337b1781
......@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'Resources/CalibracaoP.ui'
#
# Created: Wed Nov 1 20:05:10 2017
# Created: Fri Nov 10 15:32:01 2017
# by: PyQt5 UI code generator 5.2.1
#
# WARNING! All changes made in this file will be lost!
......@@ -107,103 +107,103 @@ class Ui_MainWindow(object):
self.cronometroBox.setGeometry(QtCore.QRect(20, 330, 381, 171))
self.cronometroBox.setStyleSheet("border:1px solid rgb(123, 0, 129);")
self.cronometroBox.setObjectName("cronometroBox")
self.timerButton = QtWidgets.QPushButton(self.cronometroBox)
self.timerButton.setGeometry(QtCore.QRect(140, 130, 61, 31))
self.timerButton.setObjectName("timerButton")
self.stopTimerButton = QtWidgets.QPushButton(self.cronometroBox)
self.stopTimerButton.setGeometry(QtCore.QRect(140, 30, 61, 31))
self.stopTimerButton.setObjectName("stopTimerButton")
self.groupBox_2 = QtWidgets.QGroupBox(self.cronometroBox)
self.groupBox_2.setGeometry(QtCore.QRect(10, 30, 120, 131))
self.groupBox_2.setObjectName("groupBox_2")
self.cronometroLabel = QtWidgets.QLabel(self.groupBox_2)
self.timerOptionButton = QtWidgets.QPushButton(self.cronometroBox)
self.timerOptionButton.setGeometry(QtCore.QRect(140, 130, 61, 31))
self.timerOptionButton.setObjectName("timerOptionButton")
self.initTimerButton = QtWidgets.QPushButton(self.cronometroBox)
self.initTimerButton.setGeometry(QtCore.QRect(140, 30, 61, 31))
self.initTimerButton.setObjectName("initTimerButton")
self.cronometroGBox = QtWidgets.QGroupBox(self.cronometroBox)
self.cronometroGBox.setGeometry(QtCore.QRect(10, 30, 120, 131))
self.cronometroGBox.setObjectName("cronometroGBox")
self.cronometroLabel = QtWidgets.QLabel(self.cronometroGBox)
self.cronometroLabel.setGeometry(QtCore.QRect(20, 60, 81, 31))
self.cronometroLabel.setObjectName("cronometroLabel")
self.groupBox_3 = QtWidgets.QGroupBox(self.cronometroBox)
self.groupBox_3.setGeometry(QtCore.QRect(220, 10, 151, 71))
self.groupBox_3.setObjectName("groupBox_3")
self.label = QtWidgets.QLabel(self.groupBox_3)
self.label.setGeometry(QtCore.QRect(30, 30, 91, 31))
self.label.setStyleSheet("font: 14pt \"Noto Serif\";")
self.label.setObjectName("label")
self.groupBox_4 = QtWidgets.QGroupBox(self.cronometroBox)
self.groupBox_4.setGeometry(QtCore.QRect(220, 90, 151, 71))
self.groupBox_4.setObjectName("groupBox_4")
self.label_2 = QtWidgets.QLabel(self.groupBox_4)
self.label_2.setGeometry(QtCore.QRect(30, 30, 91, 31))
self.label_2.setStyleSheet("font: 14pt \"Noto Serif\";")
self.label_2.setObjectName("label_2")
self.stopTimerButton_2 = QtWidgets.QPushButton(self.cronometroBox)
self.stopTimerButton_2.setGeometry(QtCore.QRect(140, 80, 61, 31))
self.stopTimerButton_2.setObjectName("stopTimerButton_2")
self.groupBox = QtWidgets.QGroupBox(self.centralWidget)
self.groupBox.setGeometry(QtCore.QRect(210, 250, 191, 71))
self.groupBox.setStyleSheet("border: 1px solid rgb(27, 144, 0);")
self.groupBox.setObjectName("groupBox")
self.lineEdit = QtWidgets.QLineEdit(self.groupBox)
self.lineEdit.setGeometry(QtCore.QRect(50, 20, 111, 31))
self.lineEdit.setStyleSheet("font: 12pt \"Noto Serif\";")
self.lineEdit.setObjectName("lineEdit")
self.groupBox_5 = QtWidgets.QGroupBox(self.centralWidget)
self.groupBox_5.setGeometry(QtCore.QRect(20, 510, 381, 111))
self.groupBox_5.setStyleSheet("border: 1px solid rgb(26, 149, 172)")
self.groupBox_5.setObjectName("groupBox_5")
self.groupBox_6 = QtWidgets.QGroupBox(self.groupBox_5)
self.groupBox_6.setGeometry(QtCore.QRect(20, 30, 161, 71))
self.groupBox_6.setObjectName("groupBox_6")
self.forcaLabel = QtWidgets.QLabel(self.groupBox_6)
self.horaInicGBox = QtWidgets.QGroupBox(self.cronometroBox)
self.horaInicGBox.setGeometry(QtCore.QRect(220, 10, 151, 71))
self.horaInicGBox.setObjectName("horaInicGBox")
self.horaInicLabel = QtWidgets.QLabel(self.horaInicGBox)
self.horaInicLabel.setGeometry(QtCore.QRect(30, 30, 91, 31))
self.horaInicLabel.setStyleSheet("font: 14pt \"Noto Serif\";")
self.horaInicLabel.setObjectName("horaInicLabel")
self.horaAtualGBox = QtWidgets.QGroupBox(self.cronometroBox)
self.horaAtualGBox.setGeometry(QtCore.QRect(220, 90, 151, 71))
self.horaAtualGBox.setObjectName("horaAtualGBox")
self.horaAtualLabel = QtWidgets.QLabel(self.horaAtualGBox)
self.horaAtualLabel.setGeometry(QtCore.QRect(30, 30, 91, 31))
self.horaAtualLabel.setStyleSheet("font: 14pt \"Noto Serif\";")
self.horaAtualLabel.setObjectName("horaAtualLabel")
self.stopTimerButton = QtWidgets.QPushButton(self.cronometroBox)
self.stopTimerButton.setGeometry(QtCore.QRect(140, 80, 61, 31))
self.stopTimerButton.setObjectName("stopTimerButton")
self.prensaNameGBox = QtWidgets.QGroupBox(self.centralWidget)
self.prensaNameGBox.setGeometry(QtCore.QRect(210, 250, 191, 71))
self.prensaNameGBox.setStyleSheet("border: 1px solid rgb(27, 144, 0);")
self.prensaNameGBox.setObjectName("prensaNameGBox")
self.prensaName = QtWidgets.QLineEdit(self.prensaNameGBox)
self.prensaName.setGeometry(QtCore.QRect(50, 20, 111, 31))
self.prensaName.setStyleSheet("font: 12pt \"Noto Serif\";")
self.prensaName.setObjectName("prensaName")
self.valAbsolGBox = QtWidgets.QGroupBox(self.centralWidget)
self.valAbsolGBox.setGeometry(QtCore.QRect(20, 510, 381, 111))
self.valAbsolGBox.setStyleSheet("border: 1px solid rgb(26, 149, 172)")
self.valAbsolGBox.setObjectName("valAbsolGBox")
self.forcaGBox = QtWidgets.QGroupBox(self.valAbsolGBox)
self.forcaGBox.setGeometry(QtCore.QRect(20, 30, 161, 71))
self.forcaGBox.setObjectName("forcaGBox")
self.forcaLabel = QtWidgets.QLabel(self.forcaGBox)
self.forcaLabel.setGeometry(QtCore.QRect(20, 30, 121, 31))
self.forcaLabel.setStyleSheet("font: 14pt \"Noto Serif\";")
self.forcaLabel.setObjectName("forcaLabel")
self.groupBox_7 = QtWidgets.QGroupBox(self.groupBox_5)
self.groupBox_7.setGeometry(QtCore.QRect(200, 30, 161, 71))
self.groupBox_7.setObjectName("groupBox_7")
self.calibranteLabel = QtWidgets.QLabel(self.groupBox_7)
self.calibranteGBox = QtWidgets.QGroupBox(self.valAbsolGBox)
self.calibranteGBox.setGeometry(QtCore.QRect(200, 30, 161, 71))
self.calibranteGBox.setObjectName("calibranteGBox")
self.calibranteLabel = QtWidgets.QLabel(self.calibranteGBox)
self.calibranteLabel.setGeometry(QtCore.QRect(20, 30, 131, 31))
self.calibranteLabel.setStyleSheet("font: 14pt \"Noto Serif\";")
self.calibranteLabel.setObjectName("calibranteLabel")
self.label_5 = QtWidgets.QLabel(self.centralWidget)
self.label_5.setGeometry(QtCore.QRect(20, 630, 111, 16))
self.label_5.setObjectName("label_5")
self.label_6 = QtWidgets.QLabel(self.centralWidget)
self.label_6.setGeometry(QtCore.QRect(140, 630, 241, 16))
self.label_6.setObjectName("label_6")
self.arquivoSalvoLabel = QtWidgets.QLabel(self.centralWidget)
self.arquivoSalvoLabel.setGeometry(QtCore.QRect(20, 630, 111, 16))
self.arquivoSalvoLabel.setObjectName("arquivoSalvoLabel")
self.arqSalvoLabel = QtWidgets.QLabel(self.centralWidget)
self.arqSalvoLabel.setGeometry(QtCore.QRect(140, 630, 241, 16))
self.arqSalvoLabel.setObjectName("arqSalvoLabel")
MainWindow.setCentralWidget(self.centralWidget)
self.menuBar = QtWidgets.QMenuBar(MainWindow)
self.menuBar.setGeometry(QtCore.QRect(0, 0, 1366, 25))
self.menuBar.setGeometry(QtCore.QRect(0, 0, 1366, 23))
self.menuBar.setObjectName("menuBar")
self.Menuzinho = QtWidgets.QMenu(self.menuBar)
self.Menuzinho.setObjectName("Menuzinho")
self.menuArquivo = QtWidgets.QMenu(self.menuBar)
self.menuArquivo.setObjectName("menuArquivo")
self.menuEtapa = QtWidgets.QMenu(self.menuBar)
self.menuEtapa.setObjectName("menuEtapa")
MainWindow.setMenuBar(self.menuBar)
self.statusBar = QtWidgets.QStatusBar(MainWindow)
self.statusBar.setObjectName("statusBar")
MainWindow.setStatusBar(self.statusBar)
self.actionCalibra_o_P = QtWidgets.QAction(MainWindow)
self.actionCalibra_o_P.setObjectName("actionCalibra_o_P")
self.actionCalibra_o_T = QtWidgets.QAction(MainWindow)
self.actionCalibra_o_T.setObjectName("actionCalibra_o_T")
self.actionProcessamento = QtWidgets.QAction(MainWindow)
self.actionProcessamento.setObjectName("actionProcessamento")
self.actionAbrir = QtWidgets.QAction(MainWindow)
self.actionAbrir.setIconVisibleInMenu(True)
self.actionAbrir.setObjectName("actionAbrir")
self.menuStatusBar = QtWidgets.QStatusBar(MainWindow)
self.menuStatusBar.setObjectName("menuStatusBar")
MainWindow.setStatusBar(self.menuStatusBar)
self.alternaCalibraP = QtWidgets.QAction(MainWindow)
self.alternaCalibraP.setObjectName("alternaCalibraP")
self.alternaCalibraT = QtWidgets.QAction(MainWindow)
self.alternaCalibraT.setObjectName("alternaCalibraT")
self.alternaProc = QtWidgets.QAction(MainWindow)
self.alternaProc.setObjectName("alternaProc")
self.botaoAbrir = QtWidgets.QAction(MainWindow)
self.botaoAbrir.setIconVisibleInMenu(True)
self.botaoAbrir.setObjectName("botaoAbrir")
self.actionSalvar = QtWidgets.QAction(MainWindow)
self.actionSalvar.setObjectName("actionSalvar")
self.actionSalvar_Como = QtWidgets.QAction(MainWindow)
self.actionSalvar_Como.setObjectName("actionSalvar_Como")
self.actionSalvar_2 = QtWidgets.QAction(MainWindow)
self.actionSalvar_2.setObjectName("actionSalvar_2")
self.actionSalvar_Como_2 = QtWidgets.QAction(MainWindow)
self.actionSalvar_Como_2.setObjectName("actionSalvar_Como_2")
self.Menuzinho.addAction(self.actionAbrir)
self.Menuzinho.addAction(self.actionSalvar_2)
self.Menuzinho.addAction(self.actionSalvar_Como_2)
self.menuEtapa.addAction(self.actionCalibra_o_P)
self.menuEtapa.addAction(self.actionCalibra_o_T)
self.menuEtapa.addAction(self.actionProcessamento)
self.menuBar.addAction(self.Menuzinho.menuAction())
self.botaoSalvar = QtWidgets.QAction(MainWindow)
self.botaoSalvar.setObjectName("botaoSalvar")
self.botaoSalvarComo = QtWidgets.QAction(MainWindow)
self.botaoSalvarComo.setObjectName("botaoSalvarComo")
self.menuArquivo.addAction(self.botaoAbrir)
self.menuArquivo.addAction(self.botaoSalvar)
self.menuArquivo.addAction(self.botaoSalvarComo)
self.menuEtapa.addAction(self.alternaCalibraP)
self.menuEtapa.addAction(self.alternaCalibraT)
self.menuEtapa.addAction(self.alternaProc)
self.menuBar.addAction(self.menuArquivo.menuAction())
self.menuBar.addAction(self.menuEtapa.menuAction())
self.retranslateUi(MainWindow)
......@@ -214,6 +214,7 @@ class Ui_MainWindow(object):
MainWindow.setWindowTitle(_translate("MainWindow", "SADAMAP - Análise de Dados: Etapa 1 - Calibração de Pressão"))
self.escalaBox.setTitle(_translate("MainWindow", "Escalas de Visualização (Range)"))
self.forcaBox.setTitle(_translate("MainWindow", "Força"))
self.f_max.setText(_translate("MainWindow", "100"))
self.f_max_label.setText(_translate("MainWindow", "Máximo:"))
self.f_min_label.setText(_translate("MainWindow", "Mínimo:"))
self.pressaoBox.setTitle(_translate("MainWindow", "Tensão no Calibrante"))
......@@ -232,35 +233,35 @@ class Ui_MainWindow(object):
self.amostragemCBox.setItemText(7, _translate("MainWindow", "5 seg"))
self.amostragemCBox.setItemText(8, _translate("MainWindow", "10 seg"))
self.cronometroBox.setTitle(_translate("MainWindow", "Timer"))
self.timerButton.setText(_translate("MainWindow", "Opções"))
self.stopTimerButton.setText(_translate("MainWindow", "Iniciar"))
self.groupBox_2.setTitle(_translate("MainWindow", "Cronômetro"))
self.timerOptionButton.setText(_translate("MainWindow", "Opções"))
self.initTimerButton.setText(_translate("MainWindow", "Iniciar"))
self.cronometroGBox.setTitle(_translate("MainWindow", "Cronômetro"))
self.cronometroLabel.setText(_translate("MainWindow", "10.2674 s"))
self.groupBox_3.setTitle(_translate("MainWindow", "Horário de Início"))
self.label.setText(_translate("MainWindow", "16:30:15"))
self.groupBox_4.setTitle(_translate("MainWindow", "Horário Atual"))
self.label_2.setText(_translate("MainWindow", "17:05:56"))
self.stopTimerButton_2.setText(_translate("MainWindow", "Parar"))
self.groupBox.setTitle(_translate("MainWindow", "Prensa"))
self.lineEdit.setText(_translate("MainWindow", "Pr 400 Tonf"))
self.groupBox_5.setTitle(_translate("MainWindow", "Valores Absolutos"))
self.groupBox_6.setTitle(_translate("MainWindow", "Força"))
self.horaInicGBox.setTitle(_translate("MainWindow", "Horário de Início"))
self.horaInicLabel.setText(_translate("MainWindow", "16:30:15"))
self.horaAtualGBox.setTitle(_translate("MainWindow", "Horário Atual"))
self.horaAtualLabel.setText(_translate("MainWindow", "17:05:56"))
self.stopTimerButton.setText(_translate("MainWindow", "Parar"))
self.prensaNameGBox.setTitle(_translate("MainWindow", "Prensa"))
self.prensaName.setText(_translate("MainWindow", "Pr 400 Tonf"))
self.valAbsolGBox.setTitle(_translate("MainWindow", "Valores Absolutos"))
self.forcaGBox.setTitle(_translate("MainWindow", "Força"))
self.forcaLabel.setText(_translate("MainWindow", "-42.679 Tonf"))
self.groupBox_7.setTitle(_translate("MainWindow", "Tensão no Calibrante"))
self.calibranteGBox.setTitle(_translate("MainWindow", "Tensão no Calibrante"))
self.calibranteLabel.setText(_translate("MainWindow", "-23.804 mV"))
self.label_5.setText(_translate("MainWindow", "Arquivo Salvo em:"))
self.label_6.setText(_translate("MainWindow", "/home/LAPMA/Pressao/1025565.pre"))
self.Menuzinho.setTitle(_translate("MainWindow", "Arquivo"))
self.arquivoSalvoLabel.setText(_translate("MainWindow", "Arquivo Salvo em:"))
self.arqSalvoLabel.setText(_translate("MainWindow", "/home/LAPMA/Pressao/1025565.pre"))
self.menuArquivo.setTitle(_translate("MainWindow", "Arquivo"))
self.menuEtapa.setTitle(_translate("MainWindow", "Etapa"))
self.actionCalibra_o_P.setText(_translate("MainWindow", "Calibração P"))
self.actionCalibra_o_T.setText(_translate("MainWindow", "Calibração T"))
self.actionProcessamento.setText(_translate("MainWindow", "Processamento"))
self.actionAbrir.setText(_translate("MainWindow", "Abrir"))
self.alternaCalibraP.setText(_translate("MainWindow", "Calibração P"))
self.alternaCalibraT.setText(_translate("MainWindow", "Calibração T"))
self.alternaProc.setText(_translate("MainWindow", "Processamento"))
self.botaoAbrir.setText(_translate("MainWindow", "Abrir"))
self.actionSalvar.setText(_translate("MainWindow", "Salvar"))
self.actionSalvar_Como.setText(_translate("MainWindow", "Salvar Como"))
self.actionSalvar_2.setText(_translate("MainWindow", "Salvar"))
self.actionSalvar_Como_2.setText(_translate("MainWindow", "Salvar Como"))
self.botaoSalvar.setText(_translate("MainWindow", "Salvar"))
self.botaoSalvarComo.setText(_translate("MainWindow", "Salvar Como"))
def sceneSelector(self,scene):
def sceneSelector(self, scene):
self.CentralGraph.setScene(scene)
self.CentralGraph.setBackgroundBrush(QtCore.Qt.black)
\ No newline at end of file
......@@ -3,7 +3,7 @@ import pyqtgraph
import serial
import time
import sys
from mainwindow import Ui_MainWindow
from CalibracaoP import Ui_MainWindow
class SerialManager(object):
def __init__(self):
......@@ -16,57 +16,100 @@ class SerialManager(object):
def read(self):
if(self.ser.inWaiting()==0):
pass
return self.ser.read()
return self.ser.readline()
class Graph(pyqtgraph.GraphicsLayout):
index=0
index=1
def __init__(self,x_range,y_range,x_size,y_size,color):
def __init__(self,x_range,y_range,x_size,y_size,color1,color2):
super(Graph,self).__init__()
self.x_range = x_range
self.y_range = y_range
self.x_size = x_size
self.y_size = y_size
self.color1 = color1
self.color2 = color2
self.p1 = self.addPlot()
self.curve1 = self.p1.plot(pen=color)
self.setPreferredSize(x_size,y_size)
self.p1.setXRange(0,x_range,padding=0)
self.p1.setYRange(0, y_range, padding=0)
self.curve1 = self.p1.plot(pen=color1)
self.curve2 = self.p1.plot(pen=color2)
self.setPreferredSize(self.x_size,self.y_size)
self.p1.setXRange(0,self.x_range,padding=0)
self.p1.setYRange(0, self.y_range, padding=0)
self.x1=[]
self.y1=[]
self.y2=[]
def updateGraph(self,value):
self.y1.append(value)
self.index += 1
if len(self.y1)>self.x_range-1:
#self.p1.enableAutoScale()
def updateGraph(self,y1,y2):
self.y1.append(y1)
self.y2.append(y2)
if len(self.y1)>self.x_range+1:
del self.y1[0]
del self.y2[0]
self.index = self.x_range
else:
self.x1.append(index)
self.x1.append(self.index)
self.index = self.index + 1
self.curve1.setData(self.x1, self.y1)
self.curve2.setData(self.x1,self.y2)
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
dialog = QtWidgets.QMainWindow()
ser1 = SerialManager()
uiCalibra1=Ui_MainWindow()
uiCalibra1.setupUi(dialog)
layout = Graph(0,100,0,1023,'r')
scene = QtGui.QGraphicsScene()
scene.addItem(layout)
uiCalibra1.sceneSelector(scene)
def setGraphScale(self,x_range,y_range):
self.x_range=x_range
self.y_range=y_range
self.x1=[]
self.y1=[]
self.y2=[]
self.index=0
self.clear()
self.p1=self.addPlot()
self.p1.setXRange(0, self.x_range, padding=0)
self.p1.setYRange(0, self.y_range, padding=0)
self.curve1=self.p1.plot(pen=self.color1)
self.curve2=self.p1.plot(pen=self.color2)
class SystemEngine(object):
def __init__(self):
self.app = QtWidgets.QApplication(sys.argv)
self.dialog = QtWidgets.QMainWindow()
self.ser1 = SerialManager()
self.uiCalibra1 = Ui_MainWindow()
self.uiCalibra1.setupUi(self.dialog)
self.layout = Graph(100, 10230, 900, 600, 'r','g')
self.scene = QtGui.QGraphicsScene()
self.scene.addItem(self.layout)
self.uiCalibra1.sceneSelector(self.scene)
self.dialog.showMaximized()
self.prev_x_scale=100
self.x_scale=100
def updateData(self):
readData = self.ser1.read() # Lê o dado da serial
readData = readData.decode('utf8')
dado = readData.split(' ', 3)
self.x_scale=int(self.uiCalibra1.f_max.text())
if(self.x_scale != self.prev_x_scale):
self.layout.setGraphScale(int(self.x_scale),32700)
self.prev_x_scale = self.x_scale
self.layout.updateGraph(float(dado[0]),float(dado[1]))
if __name__ == '__main__':
engine=SystemEngine()
timer = QtCore.QTimer() #
timer.timeout.connect(layout.update(ser1.read())) #
timer.timeout.connect(engine.updateData) #
timer.start(0)
dialog.showMaximized()
sys.exit(app.exec_())
sys.exit(engine.app.exec_())
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment