Commit 28d55da4 authored by Alisson Claudino's avatar Alisson Claudino

Padronização das interfaces e gráficos genéricos com n eixos

parent b4282bcb
This diff is collapsed.
This diff is collapsed.
...@@ -5,60 +5,72 @@ import time ...@@ -5,60 +5,72 @@ import time
class Graph(PlotItem): class Graph(PlotItem):
index = 0 index = 0
def __init__(self,x_sampling, x_range, y1_min, y1_max, y2_min, y2_max, x_size, y_size, color1, color2, name1, name2): def __init__(self,x_sampling, x_range, n_axis, y_min, y_max, x_size, y_size, color, name,unit):
super(Graph, self).__init__() super(Graph, self).__init__()
self.x_sampling=1 self.x_sampling=1
self.x_range = x_range/x_sampling self.x_range = x_range/x_sampling
self.y1_min = y1_min
self.y1_max = y1_max self.curve = []
self.y2_min = y2_min self.axis = []
self.y2_max = y2_max self.y=[]
self.x_size = x_size
self.y_size = y_size self.curve.append(self.plot(pen=color[0], name=name[0]))
self.color1 = color1 self.axis.append(AxisItem("left",color[0]))
self.color2 = color2 self.axis[0].setLabel(name[0], unit[0])
self.name1 = name1 self.axis[0].setRange(y_min[0], y_max[0])
self.name2 = name2
self.curve1 = self.plot(pen=color1, name=self.name1) y_axis = [0]
self.curve2 = self.plot(pen=color2, name=self.name2) self.y.append(y_axis)
try:
for n in range(1,n_axis):
self.curve.append(self.plot(pen=color[n], name=name[n]))
self.axis.append(AxisItem("right",color[n]))
self.axis[n].setLabel(name[n],unit[n])
self.axis[n].setRange(y_min[n],y_max[n])
self.y.append(y_axis)
print(y_axis)
except Exception as e:
print(e)
self.axisTime = AxisItem("bottom", 'w') self.axisTime = AxisItem("bottom", 'w')
self.axis2 = AxisItem("right", color2)
self.axis1 = AxisItem("left", color1)
self.axis1.setLabel(self.name1,'Tonf')
self.axis2.setLabel(self.name2,'mV')
self.axisTime.setLabel("Tempo", 's') self.axisTime.setLabel("Tempo", 's')
self.axisTime.setRange(0, x_range)
self.x=[]
self.x.append(0)
self.showAxis("left", False)
self.showAxis("bottom", False)
self.axisTime.setRange(0,x_range) self.setMinimumSize(x_size, y_size)
self.axis1.setRange(y1_min,y1_max)
self.axis2.setRange(y2_min,y2_max)
self.showAxis("left",False)
self.showAxis("bottom",False)
self.setMinimumSize(x_size,y_size)
self.setXRange(0, self.x_range, padding=0) self.setXRange(0, self.x_range, padding=0)
self.setYRange(min(self.y1_min,self.y2_min), max(self.y1_max,self.y2_max), padding=0) self.setYRange(min(y_min), max(y_max), padding=0)
self.x1 = []
self.y1 = []
self.y2 = []
self.timeant = time.time()
self.timeant = time.time()
def updateGraph(self, y1, y2): def updateGraph(self, y):
# print(time.time()-self.timeant) # print(time.time()-self.timeant)
self.y1.append(y1)
self.y2.append(y2)
if len(self.y1) > self.x_range + 1: for n in range(0,len(y)):
self.y1.pop(0) print(y[n])
self.y2.pop(0) print(self.y[n])
self.y[n].append(y[n])
if len(self.y[0]) > self.x_range+1 :
for n in range(0,len(y)):
self.y[n].pop(0)
self.index = self.x_range self.index = self.x_range
else: else:
self.x1.append(self.index) self.x.append(self.index)
self.index = self.index + 1 self.index = self.index + 1
self.curve1.setData(self.x1, self.y1)
self.curve2.setData(self.x1, self.y2) for n in range(0,len(y)):
#self.timeant = time.time() self.curve[0].setData(self.x, self.y[0])
self.timeant = time.time()
from datetime import datetime from datetime import datetime
from PyQt5 import QtWidgets,QtCore from PyQt5 import QtWidgets,QtCore,QtGui
class InterfaceTimer(object): class InterfaceTimer(object):
def __init__(self): def __init__(self):
self.startTimerButton = QtWidgets.QPushButton() self.startTimerButton = QtWidgets.QPushButton()
self.pauseTimerButton = QtWidgets.QPushButton()
self.stopTimerButton = QtWidgets.QPushButton() self.stopTimerButton = QtWidgets.QPushButton()
self.startRegTimerButton = QtWidgets.QPushButton() self.startRegTimerButton = QtWidgets.QPushButton()
self.stopRegTimerButton = QtWidgets.QPushButton() self.stopRegTimerButton = QtWidgets.QPushButton()
self.regTimerLabel=QtWidgets.QLabel() self.regTimerLabel=QtWidgets.QLabel()
self.screenTimerLabel = QtWidgets.QLabel() self.timerLabel = QtWidgets.QLabel()
self.currentTimeLabel = QtWidgets.QLabel() self.currentTimeLabel = QtWidgets.QLabel()
self.currentTimer = QtCore.QTimer() self.currentTimer = QtCore.QTimer()
self.regTimer=QtCore.QTimer()
self.MainWindow=QtWidgets.QDialog()
self.regTimerLabel.setText("0.0 s")
self.regTimerLabel.setText("0 s") self.timerLabel.setText("0.0 s")
self.timeValue=0 self.timeValue=0
self.regTimerValue=0 self.regTimerValue=1000
def linkActions(self): def linkActions(self):
self.startTimerButton.pressed.connect(self.startScreenTimer) self.startTimerButton.pressed.connect(self.startScreenTimer)
self.pauseTimerButton.pressed.connect(self.playPauseScreenTimer)
self.stopTimerButton.pressed.connect(self.stopScreenTimer) self.stopTimerButton.pressed.connect(self.stopScreenTimer)
self.currentTimer.timeout.connect(self.updateCurrentTime) self.currentTimer.timeout.connect(self.updateCurrentTime)
self.startRegTimerButton.pressed.connect(self.startRegressiveTimer) self.startRegTimerButton.pressed.connect(self.startRegressiveTimer)
self.stopRegTimerButton.pressed.connect(self.startRegressiveTimer) self.stopRegTimerButton.pressed.connect(self.stopRegressiveTimer)
self.currentTimer.start(500) self.currentTimer.start(500)
self.screenTimerFlag = False self.screenTimerFlag = False
def startRegressiveTimer(self): def startRegressiveTimer(self):
try: try:
if(self.regTimerLabel.text().split(" ",3)[1]=="s"):
self.regTimerValue=self.regTimerLabel.text().split(" ",3)[0]
else:
self.regTimerValue=self.regTimerLabel.text()
print(self.regTimerValue)
self.regTimerValue=float(self.regTimerValue)
except(IndexError):
self.regTimerValue=self.regTimerLabel.text() self.regTimerValue=self.regTimerLabel.text()
self.regTimerValue.split(" ", 3)
self.regTimerValue=float(self.regTimerValue[0]) except(ValueError,TypeError):
except(ValueError): error=QtWidgets.QMessageBox(self.MainWindow)
print(self.regTimerLabel.text) error.setText("Valor Inválido! Definindo valor padrão de 1000 segundos")
error.setWindowTitle("ERRO!")
error.exec()
self.regTimerValue = 1000
print(self.regTimerValue)
self.regTimerValue = float(self.regTimerValue)
self.regTimer=QtCore.QTimer() self.regTimer=QtCore.QTimer()
self.regTimer.timeout.connect(self.updateRegTimer) self.regTimer.timeout.connect(self.updateRegTimer)
...@@ -55,53 +71,39 @@ class InterfaceTimer(object): ...@@ -55,53 +71,39 @@ class InterfaceTimer(object):
self.regTimer.stop() self.regTimer.stop()
self.startRegTimerButton.setText("Iniciar") self.startRegTimerButton.setText("Iniciar")
self.startRegTimerButton.pressed.disconnect() self.startRegTimerButton.pressed.disconnect()
self.startRegTimerButton.pressed.connect(startRegressiveTimer) self.startRegTimerButton.pressed.connect(self.startRegressiveTimer)
self.regTimerLabel.setText("0.00 s") self.regTimerLabel.setText("0.00 s")
def updateRegTimer(self): def updateRegTimer(self):
while(self.regTimerValue!=0): if(self.regTimerValue>=0.1):
self.regTimerValue -= 0.1 self.regTimerValue -= 0.1
self.regTimerLabel.setText("%.1f seg"%self.regTimerValue) self.regTimerLabel.setText("%.1f s"%self.regTimerValue)
def startScreenTimer(self): def startScreenTimer(self):
self.timeValue = 0
self.screenTimer = QtCore.QTimer() self.screenTimer = QtCore.QTimer()
self.screenTimer.timeout.connect(self.updateScreenTimer) self.screenTimer.timeout.connect(self.updateScreenTimer)
self.screenTimer.start(100) self.screenTimer.start(100)
self.startTimerButton.setText("Reiniciar") self.startTimerButton.pressed.disconnect()
self.pauseTimerButton.setText("Pausar") self.startTimerButton.pressed.connect(self.pauseScreenTimer)
self.screenTimerFlag = True self.startTimerButton.setText("Pausar")
def playPauseScreenTimer(self): def pauseScreenTimer(self):
self.startTimerButton.setText("Reiniciar") self.screenTimer.stop()
if (self.pauseTimerButton == "Iniciar"): self.startTimerButton.setText("Continuar")
self.startScreenTimer() self.startTimerButton.pressed.disconnect()
if (self.screenTimerFlag == True): self.startTimerButton.pressed.connect(self.startScreenTimer)
self.screenTimer.stop()
self.screenTimerFlag = False
self.pauseTimerButton.setText("Continuar")
else:
try:
self.screenTimer.start(100)
self.screenTimerFlag = True
self.pauseTimerButton.setText("Pausar")
except:
self.startScreenTimer()
def stopScreenTimer(self): def stopScreenTimer(self):
self.screenTimer.stop() self.screenTimer.stop()
self.screenTimerLabel.setText("0.00 seg") self.timerLabel.setText("0.00 s")
self.timeValue = 0 self.timeValue = 0
self.screenTimerFlag = False self.screenTimerFlag = False
self.startTimerButton.setText("Iniciar") self.startTimerButton.setText("Iniciar")
self.pauseTimerButton.setText("Iniciar")
def updateScreenTimer(self): def updateScreenTimer(self):
self.timeValue += 0.1 self.timeValue += 0.1
self.screenTimerLabel.setText("%.1f seg" % self.timeValue) self.timerLabel.setText("%.1f s" % self.timeValue)
def updateCurrentTime(self): def updateCurrentTime(self):
self.currentTime = (str(datetime.now().time())) self.currentTime = (str(datetime.now().time()))
......
This diff is collapsed.
...@@ -473,29 +473,12 @@ border:1px solid rgb(123, 0, 129);</string> ...@@ -473,29 +473,12 @@ border:1px solid rgb(123, 0, 129);</string>
<property name="title"> <property name="title">
<string>Timer</string> <string>Timer</string>
</property> </property>
<widget class="QPushButton" name="startTimerButton">
<property name="geometry">
<rect>
<x>170</x>
<y>30</y>
<width>51</width>
<height>31</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color:rgb(53, 53, 53);
border: 1px solid rgb(44, 0, 47);</string>
</property>
<property name="text">
<string>Iniciar</string>
</property>
</widget>
<widget class="QGroupBox" name="timerGBox"> <widget class="QGroupBox" name="timerGBox">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>30</y> <y>30</y>
<width>141</width> <width>211</width>
<height>71</height> <height>71</height>
</rect> </rect>
</property> </property>
...@@ -521,14 +504,45 @@ border: 1px solid rgb(44, 0, 47); ...@@ -521,14 +504,45 @@ border: 1px solid rgb(44, 0, 47);
font: 75 12pt &quot;Noto Serif&quot;;</string> font: 75 12pt &quot;Noto Serif&quot;;</string>
</property> </property>
<property name="text"> <property name="text">
<string>10.2674 s</string> <string>0.00 s</string>
</property>
</widget>
<widget class="QPushButton" name="startTimerButton">
<property name="geometry">
<rect>
<x>130</x>
<y>10</y>
<width>51</width>
<height>21</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color:rgb(53, 53, 53);
border: 1px solid rgb(44, 0, 47);</string>
</property>
<property name="text">
<string>Iniciar</string>
</property>
</widget>
<widget class="QPushButton" name="stopTimerButton">
<property name="geometry">
<rect>
<x>130</x>
<y>40</y>
<width>51</width>
<height>21</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color:rgb(53, 53, 53);
border: 1px solid rgb(44, 0, 47);</string>
</property>
<property name="text">
<string>Parar</string>
</property> </property>
</widget> </widget>
<zorder>timerLabel</zorder>
<zorder>startTimerButton</zorder>
<zorder>stopTimerButton</zorder>
</widget> </widget>
<widget class="QGroupBox" name="currentTimeGBox"> <widget class="QGroupBox" name="startTimeGBox">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>240</x> <x>240</x>
...@@ -543,7 +557,7 @@ font: 75 12pt &quot;Noto Serif&quot;;</string> ...@@ -543,7 +557,7 @@ font: 75 12pt &quot;Noto Serif&quot;;</string>
<property name="title"> <property name="title">
<string>Horário de Início</string> <string>Horário de Início</string>
</property> </property>
<widget class="QLabel" name="currentTimeLabel"> <widget class="QLabel" name="startTimeLabel">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>30</x> <x>30</x>
...@@ -562,7 +576,7 @@ font: 14pt &quot;Noto Serif&quot;;</string> ...@@ -562,7 +576,7 @@ font: 14pt &quot;Noto Serif&quot;;</string>
</property> </property>
</widget> </widget>
</widget> </widget>
<widget class="QGroupBox" name="horaAtualGBox"> <widget class="QGroupBox" name="currentTimeGBox">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>240</x> <x>240</x>
...@@ -577,7 +591,7 @@ font: 14pt &quot;Noto Serif&quot;;</string> ...@@ -577,7 +591,7 @@ font: 14pt &quot;Noto Serif&quot;;</string>
<property name="title"> <property name="title">
<string>Horário Atual</string> <string>Horário Atual</string>
</property> </property>
<widget class="QLabel" name="horaAtualLabel"> <widget class="QLabel" name="currentTimeLabel">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>30</x> <x>30</x>
...@@ -596,29 +610,12 @@ font: 14pt &quot;Noto Serif&quot;;</string> ...@@ -596,29 +610,12 @@ font: 14pt &quot;Noto Serif&quot;;</string>
</property> </property>
</widget> </widget>
</widget> </widget>
<widget class="QPushButton" name="stopTimerButton">
<property name="geometry">
<rect>
<x>170</x>
<y>70</y>
<width>51</width>
<height>31</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color:rgb(53, 53, 53);
border: 1px solid rgb(44, 0, 47);</string>
</property>
<property name="text">
<string>Parar</string>
</property>
</widget>
<widget class="QGroupBox" name="regTimerGBox"> <widget class="QGroupBox" name="regTimerGBox">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>120</y> <y>120</y>
<width>141</width> <width>211</width>
<height>71</height> <height>71</height>
</rect> </rect>
</property> </property>
...@@ -628,7 +625,24 @@ border: 1px solid rgb(44, 0, 47);</string> ...@@ -628,7 +625,24 @@ border: 1px solid rgb(44, 0, 47);</string>
<property name="title"> <property name="title">
<string>Cont. Regressivo</string> <string>Cont. Regressivo</string>
</property> </property>
<widget class="QLabel" name="regTimerLabel"> <widget class="QPushButton" name="startRegTimerButton">
<property name="geometry">
<rect>
<x>130</x>
<y>10</y>
<width>51</width>
<height>21</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border: 1px solid rgb(255,255,255);
background-color:rgb(53, 53, 53)</string>
</property>
<property name="text">
<string>Iniciar</string>
</property>
</widget>
<widget class="QLineEdit" name="regTimerLabel">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>20</x> <x>20</x>
...@@ -643,35 +657,15 @@ border: 1px solid rgb(255,255,255); ...@@ -643,35 +657,15 @@ border: 1px solid rgb(255,255,255);
color:rgb(255,255,255); color:rgb(255,255,255);
font: 75 12pt &quot;Noto Serif&quot;;</string> font: 75 12pt &quot;Noto Serif&quot;;</string>
</property> </property>
<property name="text">
<string>10.2674 s</string>
</property>
</widget> </widget>
</widget> </widget>
<widget class="QPushButton" name="startRegTimerButton">
<property name="geometry">
<rect>
<x>170</x>
<y>120</y>
<width>51</width>
<height>31</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border: 1px solid rgb(255,255,255);
background-color:rgb(53, 53, 53)</string>
</property>
<property name="text">
<string>Iniciar</string>
</property>
</widget>
<widget class="QPushButton" name="stopRegTimerButton"> <widget class="QPushButton" name="stopRegTimerButton">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>170</x> <x>140</x>
<y>160</y> <y>160</y>
<width>51</width> <width>51</width>
<height>31</height> <height>21</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
...@@ -742,7 +736,7 @@ background-color:rgb(53, 53, 53)</string> ...@@ -742,7 +736,7 @@ background-color:rgb(53, 53, 53)</string>
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>/home/LAPMA/Pressao/1025565.pre</string> <string>/home/LAPMA/Pressao/1025565.temp</string>
</property> </property>
</widget> </widget>
<widget class="QGroupBox" name="ambientTempGBox"> <widget class="QGroupBox" name="ambientTempGBox">
...@@ -900,16 +894,6 @@ font: 14pt &quot;Noto Serif&quot;;</string> ...@@ -900,16 +894,6 @@ font: 14pt &quot;Noto Serif&quot;;</string>
</widget> </widget>
</widget> </widget>
</widget> </widget>
<zorder>CentralGraph</zorder>
<zorder>scaleBox</zorder>
<zorder>samplingBox</zorder>
<zorder>cronometroBox</zorder>
<zorder>prensaNameGBox</zorder>
<zorder>arquivoSalvoLabel</zorder>
<zorder>arqSalvoLabel</zorder>
<zorder>ambientTempGBox</zorder>
<zorder>amostragemBox_2</zorder>
<zorder>absolValGBox</zorder>
</widget> </widget>
<widget class="QStatusBar" name="menuStatusBar"/> <widget class="QStatusBar" name="menuStatusBar"/>
<widget class="QMenuBar" name="menuBar"> <widget class="QMenuBar" name="menuBar">
...@@ -921,15 +905,15 @@ font: 14pt &quot;Noto Serif&quot;;</string> ...@@ -921,15 +905,15 @@ font: 14pt &quot;Noto Serif&quot;;</string>
<height>23</height> <height>23</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuArquivo"> <widget class="QMenu" name="fileMenu">
<property name="title"> <property name="title">
<string>Arquivo</string> <string>Arquivo</string>
</property> </property>
<addaction name="botaoAbrir"/> <addaction name="openButton"/>
<addaction name="botaoSalvar"/> <addaction name="saveButton"/>
<addaction name="botaoSalvarComo"/> <addaction name="saveAsButton"/>
</widget> </widget>
<widget class="QMenu" name="menuEtapa"> <widget class="QMenu" name="stageMenu">
<property name="title"> <property name="title">
<string>Etapa</string> <string>Etapa</string>
</property> </property>
...@@ -937,32 +921,32 @@ font: 14pt &quot;Noto Serif&quot;;</string> ...@@ -937,32 +921,32 @@ font: 14pt &quot;Noto Serif&quot;;</string>
<addaction name="alternaCalibraT"/> <addaction name="alternaCalibraT"/>
<addaction name="alternaProc"/> <addaction name="alternaProc"/>
</widget> </widget>
<widget class="QMenu" name="menuPorta"> <widget class="QMenu" name="serialMenu">
<property name="title"> <property name="title">
<string>Porta</string> <string>Porta</string>
</property> </property>
</widget> </widget>
<widget class="QMenu" name="menuPlay_Pause"> <widget class="QMenu" name="playPauseButton">
<property name="title"> <property name="title">
<string>Iniciar/Pausar</string> <string>Iniciar/Pausar</string>
</property> </property>
</widget> </widget>
<widget class="QMenu" name="menuTermopar"> <widget class="QMenu" name="ThermocoupleMenu">
<property name="title"> <property name="title">
<string>Termopar</string> <string>Termopar</string>
</property> </property>
</widget> </widget>
<widget class="QMenu" name="menuFinalizar"> <widget class="QMenu" name="finalizeButton">
<property name="title"> <property name="title">
<string>Finalizar</string> <string>Finalizar</string>
</property> </property>
</widget> </widget>
<addaction name="menuArquivo"/> <addaction name="fileMenu"/>
<addaction name="menuEtapa"/> <addaction name="stageMenu"/>
<addaction name="menuPorta"/> <addaction name="serialMenu"/>
<addaction name="menuTermopar"/> <addaction name="ThermocoupleMenu"/>
<addaction name="menuPlay_Pause"/> <addaction name="playPauseButton"/>
<addaction name="menuFinalizar"/> <addaction name="finalizeButton"/>
</widget> </widget>
<action name="alternaCalibraP"> <action name="alternaCalibraP">
<property name="text"> <property name="text">
...@@ -979,7 +963,7 @@ font: 14pt &quot;Noto Serif&quot;;</string> ...@@ -979,7 +963,7 @@ font: 14pt &quot;Noto Serif&quot;;</string>
<string>Processamento</string> <string>Processamento</string>
</property> </property>
</action> </action>
<action name="botaoAbrir"> <action name="openButton">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
...@@ -1000,12 +984,12 @@ font: 14pt &quot;Noto Serif&quot;;</string> ...@@ -1000,12 +984,12 @@ font: 14pt &quot;Noto Serif&quot;;</string>
<string>Salvar Como</string> <string>Salvar Como</string>
</property> </property>
</action> </action>
<action name="botaoSalvar"> <action name="saveButton">
<property name="text"> <property name="text">
<string>Salvar</string> <string>Salvar</string>
</property> </property>
</action> </action>
<action name="botaoSalvarComo"> <action name="saveAsButton">
<property name="text"> <property name="text">
<string>Salvar Como</string> <string>Salvar Como</string>
</property> </property>
......
import serial import serial
import serial.tools.list_ports import serial.tools.list_ports
import time import time
from PyQt5 import QtWidgets
class SerialManager(object): class SerialManager(object):
...@@ -21,4 +22,12 @@ class SerialManager(object): ...@@ -21,4 +22,12 @@ class SerialManager(object):
if(self.ser.inWaiting()==0): if(self.ser.inWaiting()==0):
pass