Commit 31aa3998 authored by Alisson Claudino's avatar Alisson Claudino

Implementados os timers e Eixos Y independentes

parent ae7fec10
This diff is collapsed.
from pyqtgraph import PlotItem
from pyqtgraph import PlotItem,AxisItem,GridItem
import time
class Graph(PlotItem):
index = 0
def __init__(self, x_range, y_min, y_max, x_size, y_size, color1, color2, name1, name2):
super(Graph, self).__init__(title="Curvas de Força e Calibrante")
def __init__(self, x_range, y1_min, y1_max, y2_min, y2_max, x_size, y_size, color1, color2, name1, name2):
super(Graph, self).__init__()
self.x_range = x_range
self.y_min = y_min
self.y_max = y_max
self.y1_min = y1_min
self.y1_max = y1_max
self.y2_min = y2_min
self.y2_max = y2_max
self.x_size = x_size
self.y_size = y_size
self.color1 = color1
self.color2 = color2
self.name1 = name1
self.name2 = name2
self.addLegend()
self.curve1 = self.plot(pen=color1, name=self.name1)
self.curve2 = self.plot(pen=color2, name=self.name2)
self.showGrid(True, True)
self.setPreferredSize(self.x_size, self.y_size)
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.setRange(0,x_range)
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.setYRange(self.y_min, self.y_max, padding=0)
self.setYRange(min(self.y1_min,self.y2_min), max(self.y1_max,self.y2_max), padding=0)
self.x1 = []
self.y1 = []
self.y2 = []
......
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="styleSheet">
<string notr="true">background-color:rgb(53, 53, 53);
color: rgb(255,255,255);</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>30</x>
<y>130</y>
<width>741</width>
<height>71</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color:rgb(53, 53, 53);
font: 15pt &quot;Noto Serif&quot;;</string>
</property>
<property name="text">
<string> Sistema de Aquisição de Dados para Análise de Materiais em Altas Pressões</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>310</x>
<y>30</y>
<width>141</width>
<height>81</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color:rgb(53, 53, 53);
font: 22pt &quot;Noto Serif&quot;;</string>
</property>
<property name="text">
<string>SADAMAP</string>
</property>
</widget>
<widget class="QToolButton" name="pressButton">
<property name="geometry">
<rect>
<x>40</x>
<y>340</y>
<width>171</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string>Calibração de Pressão</string>
</property>
</widget>
<widget class="QToolButton" name="tempButton">
<property name="geometry">
<rect>
<x>310</x>
<y>340</y>
<width>181</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string>Calibração de Temperatura</string>
</property>
</widget>
<widget class="QToolButton" name="procButton">
<property name="geometry">
<rect>
<x>580</x>
<y>340</y>
<width>181</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string>Processamento</string>
</property>
</widget>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
import serial
import serial.tools.list_ports
import time
class SerialManager(object):
def __init__(self):
......
from PyQt5 import QtCore,QtGui,QtWidgets # importação de classes
import pyqtgraph
# importação de classes
import time
import sys
from PyQt5 import QtCore,QtGui,QtWidgets
from pyqtgraph import GraphicsLayout
from SerialManager import SerialManager
from CalibracaoP import Ui_MainWindow
from Graph import Graph
class SystemEngine(object):
def __init__(self):
......@@ -18,15 +20,27 @@ class SystemEngine(object):
self.uiCalibra1.setupUi(self.dialog)
self.uiCalibra1.serialListPanel(self.ser1.portList)
self.layout=pyqtgraph.GraphicsLayout()
self.graph = Graph(100,0, 30000, 900, 600, 'r','g',"Força","Tensão no Calibrante")
self.layout.addItem(self.graph)
self.prev_x_scale=100
self.x_scale=100
self.y1_min=0
self.y1_max=32700
self.y2_min=0
self.y2_max=10000
self.layout=GraphicsLayout()
self.graph = self.graph = Graph(self.x_scale, self.y1_min, self.y1_max, self.y2_min, self.y2_max, 770, 550, 'r', 'g', "Força", "Tensão no Calibrante")
self.layout.addItem(self.graph.axis2,row=1,col=3,rowspan=1,colspan=1)
self.layout.addItem(self.graph.axis1,row=1,col=1,rowspan=1,colspan=1)
self.layout.addItem(self.graph.axisTime,row=2,col=2,rowspan=1,colspan=1)
self.layout.addItem(self.graph,row=1,col=2,rowspan=1,colspan=1)
self.scene = QtGui.QGraphicsScene()
self.scene.addItem(self.layout)
self.layout.setMaximumSize(770,550)
self.scene.focusItem()
self.uiCalibra1.sceneSelector(self.scene)
self.dialog.showMaximized()
self.prev_x_scale=100
self.x_scale=100
self.uiCalibra1.t_max.returnPressed.connect(self.updateScale)
self.uiCalibra1.f_max.returnPressed.connect(self.updateScale)
......@@ -34,7 +48,7 @@ class SystemEngine(object):
self.uiCalibra1.p_max.returnPressed.connect(self.updateScale)
self.uiCalibra1.p_min.returnPressed.connect(self.updateScale)
self.uiCalibra1.amostragemCBox.currentIndexChanged.connect(self.updateTimer)
self.uiCalibra1.samplingCBox.currentIndexChanged.connect(self.updateTimer)
self.timeant=time.time()
self.timer.timeout.connect(self.updateData)
self.timer.start(100)
......@@ -47,8 +61,8 @@ class SystemEngine(object):
readData = readData.decode('utf8')
dado = readData.split(' ', 3)
try:
self.uiCalibra1.forcaLabel.setText(str(dado[0])+" Tonf")
self.uiCalibra1.calibranteLabel.setText(str(dado[1].split()[0])+" mV")
self.uiCalibra1.forceLabel.setText(str(dado[0])+" Tonf")
self.uiCalibra1.calibratorLabel.setText(str(dado[1].split()[0])+" mV")
except IndexError:
print("Erro no Indice do Array Enviado pela Serial")
......@@ -56,6 +70,9 @@ class SystemEngine(object):
self.graph.updateGraph(float(dado[0]),float(dado[1]))
except ValueError:
print("Erro nos Valores do Array Enviado pela Serial")
except IndexError:
print("Erro: Array inválido")
print(dado)
else:
pass
......@@ -64,24 +81,31 @@ class SystemEngine(object):
def updateScale(self):
try:
self.x_scale = int(self.uiCalibra1.t_max.text())
self.y_min = int(self.uiCalibra1.f_min.text())
self.y_max = int(self.uiCalibra1.f_max.text())
self.y1_min = int(self.uiCalibra1.f_min.text())
self.y1_max = int(self.uiCalibra1.f_max.text())
self.y2_min = int(self.uiCalibra1.p_min.text())
self.y2_max = int(self.uiCalibra1.p_max.text())
except ValueError:
self.x_scale = 100
self.y_min = 0
self.y_max = 32700
self.y1_min = 0
self.y1_max = 32700
self.y2_min = 0
self.y2_max = 10000
print("Erro!: Campos de Escala Vazios")
if(self.x_scale=="0"):
self.x_scale="1"
self.layout.clear()
self.graph = self.graph = Graph(self.x_scale, self.y_min , self.y_max, 900, 600, 'r', 'g', "Força", "Tensão no Calibrante")
self.layout.addItem(self.graph)
self.graph = Graph(self.x_scale, self.y1_min, self.y1_max, self.y2_min, self.y2_max, 770, 550, 'r', 'g', "Força", "Tensão no Calibrante")
self.layout.addItem(self.graph.axis2,row=1,col=3,rowspan=1,colspan=1)
self.layout.addItem(self.graph.axis1,row=1,col=1,rowspan=1,colspan=1)
self.layout.addItem(self.graph.axisTime,row=2,col=2,rowspan=1,colspan=1)
self.layout.addItem(self.graph,row=1,col=2,rowspan=1,colspan=1)
self.scene.focusItem()
def updateTimer(self):
self.time=self.uiCalibra1.amostragemCBox.currentText().split(" ")
self.time=self.uiCalibra1.samplingCBox.currentText().split(" ")
self.time[0]=int(self.time[0])
print(self.time[0])
if(self.time[0]<100):
......
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