Commit b4447145 authored by Pedro Henrique Kopper's avatar Pedro Henrique Kopper

Initial commit 2

parent e1f9c06c
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
pyqtgraph = "*"
numpy = "*"
pyserial = "*"
pyqt5 = "*"
[requires]
python_version = "3.5"
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Classe Main (Principal) #
# Autor: Alisson Claudino (alisson.claudino@ufrgs.br) -> https://lief.if.ufrgs.br/~itsalissom #
# Autores: Pedro Henrique Kopper (pedro.kopper@ufrgs.br) -> https://lief.if.ufrgs.br/~phckopper #
# Alisson Claudino (alisson.claudino@ufrgs.br) -> https://lief.if.ufrgs.br/~itsalissom
# Licença: GNU GPLv2 #
# Propósito: Inicializar o programa #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
import sys
from MainWindow import Ui_MainWindow
from ui.MainWindow import Ui_MainWindow
if __name__ == '__main__':
mainWindow = Ui_MainWindow()
#engine=SystemEngine()
sys.exit(mainWindow.app.exec_())
from random import random
class Interface(object):
def read(self):
return random() * 20
\ No newline at end of file
......@@ -48,7 +48,7 @@ QGroupBox QLineEdit {
font: bold 13px "FreeMono";
}</string>
</property>
<widget class="QGraphicsView" name="CentralGraph">
<widget class="PlotWidget" name="mainGraph">
<property name="geometry">
<rect>
<x>430</x>
......@@ -198,8 +198,7 @@ color:rgb(255,255,255);</string>
</rect>
</property>
<property name="styleSheet">
<string notr="true">
</string>
<string notr="true"/>
</property>
<property name="title">
<string>Tensão no Calibrante</string>
......@@ -516,24 +515,6 @@ font: 14pt &quot;Noto Serif&quot;;</string>
</widget>
</widget>
</widget>
<widget class="QLabel" name="arqSalvoLabel">
<property name="geometry">
<rect>
<x>430</x>
<y>560</y>
<width>921</width>
<height>111</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">padding: 2px;
border: 2px solid rgb(5, 5, 5);
font: normal 10pt &quot;FreeMono&quot;;</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QGroupBox" name="cronometroBox">
<property name="geometry">
<rect>
......@@ -559,8 +540,7 @@ font: normal 10pt &quot;FreeMono&quot;;</string>
</rect>
</property>
<property name="styleSheet">
<string notr="true">
</string>
<string notr="true"/>
</property>
<property name="title">
<string>Cronômetro</string>
......@@ -757,6 +737,80 @@ border: 1px solid rgb(255,255,255);</string>
</property>
</widget>
</widget>
<widget class="QScrollArea" name="scrollArea">
<property name="geometry">
<rect>
<x>430</x>
<y>560</y>
<width>921</width>
<height>111</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>false</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>904</width>
<height>109</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QLabel" name="consoleView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>921</width>
<height>800</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="styleSheet">
<string notr="true">padding: 2px;
border: 2px solid rgb(5, 5, 5);
font: 10pt &quot;Liberation Mono&quot;;</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</widget>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
......@@ -855,6 +909,13 @@ border: 1px solid rgb(255,255,255);</string>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>PlotWidget</class>
<extends>QGraphicsView</extends>
<header>pyqtgraph</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
from time import sleep
from PyQt5.QtCore import QThread, QTimer
from interfaces.Mock import Interface
class MainThread(QThread):
def __init__(self, ui, parent=None):
super(MainThread, self).__init__(parent)
self.ui = ui
self.interface = Interface()
self.data = []
def run(self):
self.timer = QTimer()
self.timer.timeout.connect(self._updateGraph)
self.timer.start(100)
thread_instance = QThread()
thread_instance.start()
thread_instance.exec_()
def _updateGraph(self):
self._log("DEBUG", "Loop")
self.ui.mainGraph.clear()
self.data.append(self.interface.read())
self.ui.mainGraph.plot(self.data)
def _log(self, level, msg):
self.ui.consoleView.setText("{} {}\n{}".format(level, msg, self.ui.consoleView.text()))
print(self.ui.consoleView.size())
\ No newline at end of file
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'Resources/UI/CalibracaoPressaoW.ui'
# Form implementation generated from reading ui file 'resources/UI/CalibracaoPressaoW.ui'
#
# Created by: PyQt5 UI code generator 5.12.1
#
......@@ -38,17 +38,17 @@ class Ui_CalibracaoPressaoW(object):
" font: bold 13px \"FreeMono\";\n"
"}")
self.centralWidget.setObjectName("centralWidget")
self.CentralGraph = QtWidgets.QGraphicsView(self.centralWidget)
self.CentralGraph.setGeometry(QtCore.QRect(430, 10, 921, 531))
self.mainGraph = PlotWidget(self.centralWidget)
self.mainGraph.setGeometry(QtCore.QRect(430, 10, 921, 531))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.CentralGraph.sizePolicy().hasHeightForWidth())
self.CentralGraph.setSizePolicy(sizePolicy)
self.CentralGraph.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.CentralGraph.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.CentralGraph.setAlignment(QtCore.Qt.AlignBottom|QtCore.Qt.AlignJustify)
self.CentralGraph.setObjectName("CentralGraph")
sizePolicy.setHeightForWidth(self.mainGraph.sizePolicy().hasHeightForWidth())
self.mainGraph.setSizePolicy(sizePolicy)
self.mainGraph.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.mainGraph.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.mainGraph.setAlignment(QtCore.Qt.AlignBottom|QtCore.Qt.AlignJustify)
self.mainGraph.setObjectName("mainGraph")
self.scaleBox = QtWidgets.QGroupBox(self.centralWidget)
self.scaleBox.setGeometry(QtCore.QRect(20, 10, 401, 221))
self.scaleBox.setToolTip("")
......@@ -83,8 +83,7 @@ class Ui_CalibracaoPressaoW(object):
self.f_min.setObjectName("f_min")
self.pressureBox = QtWidgets.QGroupBox(self.scaleBox)
self.pressureBox.setGeometry(QtCore.QRect(210, 30, 181, 101))
self.pressureBox.setStyleSheet("\n"
"")
self.pressureBox.setStyleSheet("")
self.pressureBox.setObjectName("pressureBox")
self.p_max = QtWidgets.QLineEdit(self.pressureBox)
self.p_max.setGeometry(QtCore.QRect(80, 30, 61, 21))
......@@ -171,21 +170,13 @@ class Ui_CalibracaoPressaoW(object):
"color:rgb(255,255,255);\n"
"font: 14pt \"Noto Serif\";")
self.calibratorLabel.setObjectName("calibratorLabel")
self.arqSalvoLabel = QtWidgets.QLabel(self.centralWidget)
self.arqSalvoLabel.setGeometry(QtCore.QRect(430, 560, 921, 111))
self.arqSalvoLabel.setStyleSheet("padding: 2px;\n"
"border: 2px solid rgb(5, 5, 5);\n"
"font: normal 10pt \"FreeMono\";")
self.arqSalvoLabel.setText("")
self.arqSalvoLabel.setObjectName("arqSalvoLabel")
self.cronometroBox = QtWidgets.QGroupBox(self.centralWidget)
self.cronometroBox.setGeometry(QtCore.QRect(20, 340, 401, 201))
self.cronometroBox.setStyleSheet("border: 2px solid rgb(123, 0, 129);")
self.cronometroBox.setObjectName("cronometroBox")
self.timerGBox = QtWidgets.QGroupBox(self.cronometroBox)
self.timerGBox.setGeometry(QtCore.QRect(10, 30, 211, 71))
self.timerGBox.setStyleSheet("\n"
"")
self.timerGBox.setStyleSheet("")
self.timerGBox.setObjectName("timerGBox")
self.timerLabel = QtWidgets.QLabel(self.timerGBox)
self.timerLabel.setGeometry(QtCore.QRect(20, 30, 81, 31))
......@@ -245,6 +236,41 @@ class Ui_CalibracaoPressaoW(object):
self.stopRegTimerButton.setStyleSheet("background-color: rgb(80,80,80);\n"
"border: 1px solid rgb(255,255,255);")
self.stopRegTimerButton.setObjectName("stopRegTimerButton")
self.scrollArea = QtWidgets.QScrollArea(self.centralWidget)
self.scrollArea.setGeometry(QtCore.QRect(430, 560, 921, 111))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.scrollArea.sizePolicy().hasHeightForWidth())
self.scrollArea.setSizePolicy(sizePolicy)
self.scrollArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
self.scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.scrollArea.setWidgetResizable(False)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 904, 109))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.scrollAreaWidgetContents.sizePolicy().hasHeightForWidth())
self.scrollAreaWidgetContents.setSizePolicy(sizePolicy)
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.consoleView = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.consoleView.setGeometry(QtCore.QRect(0, 0, 921, 800))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.MinimumExpanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.consoleView.sizePolicy().hasHeightForWidth())
self.consoleView.setSizePolicy(sizePolicy)
self.consoleView.setCursor(QtGui.QCursor(QtCore.Qt.IBeamCursor))
self.consoleView.setStyleSheet("padding: 2px;\n"
"border: 2px solid rgb(5, 5, 5);\n"
"font: 10pt \"Liberation Mono\";")
self.consoleView.setText("")
self.consoleView.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
self.consoleView.setWordWrap(True)
self.consoleView.setObjectName("consoleView")
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
CalibracaoPressaoW.setCentralWidget(self.centralWidget)
self.menuBar = QtWidgets.QMenuBar(CalibracaoPressaoW)
self.menuBar.setGeometry(QtCore.QRect(0, 0, 1366, 24))
......@@ -360,3 +386,4 @@ class Ui_CalibracaoPressaoW(object):
self.selectPortaUSB.setText(_translate("CalibracaoPressaoW", "Selecionar porta USB"))
from pyqtgraph import PlotWidget
import sys
from PyQt5 import QtWidgets
from CalibracaoPressaoW import Ui_CalibracaoPressaoW
from ui.CalibracaoPressaoW import Ui_CalibracaoPressaoW
from threads.MainThread import MainThread
class Ui_MainWindow(object):
......@@ -12,4 +13,8 @@ class Ui_MainWindow(object):
self.ui = Ui_CalibracaoPressaoW()
self.ui.setupUi(self.dialog)
main_thread = MainThread(self.ui)
main_thread.finished.connect(self.app.exit)
main_thread.start()
self.dialog.showMaximized()
\ No newline at end of file
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