Graph mockup
This commit is contained in:
parent
714bf2892d
commit
f769eca8f9
File diff suppressed because it is too large
Load Diff
132
src/um24clab.py
132
src/um24clab.py
|
@ -1,115 +1,49 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import sys
|
import sys
|
||||||
from PyQt5.QtWidgets import (
|
from PySide2.QtWidgets import (
|
||||||
QApplication, QWidget, QMainWindow, QLabel, QFrame, QComboBox, QPushButton,
|
QApplication, QMainWindow
|
||||||
QButtonGroup, QRadioButton
|
|
||||||
)
|
)
|
||||||
import PyQt5.QtGui as QtGui
|
from PySide2.QtCharts import (
|
||||||
import pyqtgraph as pg
|
QtCharts
|
||||||
|
)
|
||||||
|
from UM24CUI import Ui_MainWindow
|
||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
class UM24Lab(QMainWindow):
|
class UM24Lab(QMainWindow):
|
||||||
|
|
||||||
def __init__(self, screen_width=1280, screen_height=1024):
|
def __init__(self):
|
||||||
super().__init__()
|
super(UM24Lab, self).__init__()
|
||||||
self.title = 'UM24C USB Meter Lab'
|
self.ui = Ui_MainWindow()
|
||||||
self.width = 800
|
self.ui.setupUi(self)
|
||||||
self.height = 600
|
|
||||||
self.left = screen_width // 2 - self.width // 2
|
|
||||||
self.top = screen_height // 2 - self.height // 2
|
|
||||||
self.init_ui()
|
|
||||||
|
|
||||||
def init_ui(self):
|
self.ui.plotVoltage = QtCharts.QChart()
|
||||||
"""
|
self.ui.widgetVoltage.setChart(self.ui.plotVoltage)
|
||||||
Window Layout
|
|
||||||
+---------+-----------------------+
|
|
||||||
|(1) |(3) |
|
|
||||||
| (1.1) | |
|
|
||||||
| (1.2) | PLOTS |
|
|
||||||
| | |
|
|
||||||
+---------+ |
|
|
||||||
|(2) +------+------+---------+
|
|
||||||
| |(4) | | |
|
|
||||||
| | (4.1)| (4.2)|(4.3) |
|
|
||||||
| | | | |
|
|
||||||
| | | |---------|
|
|
||||||
| | | |(4.4) |
|
|
||||||
| | | | |
|
|
||||||
+---------+------+------+---------+
|
|
||||||
|
|
||||||
"""
|
self.ui.plotCurrent = QtCharts.QChart()
|
||||||
self.setWindowTitle(self.title)
|
self.ui.widgetCurrent.setChart(self.ui.plotCurrent)
|
||||||
self.setGeometry(self.left, self.top, self.width, self.height)
|
|
||||||
self.statusBar().showMessage('Idle')
|
|
||||||
|
|
||||||
centralWidget = QWidget()
|
voltage = self.ui.plotVoltage
|
||||||
centralLayout = QtGui.QHBoxLayout()
|
series = QtCharts.QLineSeries()
|
||||||
centralWidget.setLayout(centralLayout)
|
series.setName('Voltage')
|
||||||
|
for x in range(100):
|
||||||
|
y = random.randint(0, 10)
|
||||||
|
series.append(x, y)
|
||||||
|
voltage.addSeries(series)
|
||||||
|
|
||||||
# (1) Device Control
|
current = self.ui.plotCurrent
|
||||||
# (1.1) Device Management
|
series = QtCharts.QLineSeries()
|
||||||
deviceWidget = QWidget()
|
series.setName('Current')
|
||||||
layout = QtGui.QHBoxLayout()
|
for x in range(100):
|
||||||
deviceWidget.setLayout(layout)
|
y = random.randint(0, 10)
|
||||||
self.deviceSelect = QComboBox()
|
series.append(x, y)
|
||||||
layout.addWidget(self.deviceSelect)
|
current.addSeries(series)
|
||||||
# TODO: Populate deviceSelect
|
|
||||||
self.btnDeviceConnect = QPushButton('Connect')
|
|
||||||
layout.addWidget(self.btnDeviceConnect)
|
|
||||||
centralLayout.addWidget(deviceWidget)
|
|
||||||
|
|
||||||
# (1.2) Screen Control
|
|
||||||
screenWidget = QWidget()
|
|
||||||
layout = QtGui.QGridLayout()
|
|
||||||
screenWidget.setLayout(layout)
|
|
||||||
self.screenIndicator = QWidget()
|
|
||||||
screenManagementButtons = QButtonGroup()
|
|
||||||
group = QWidget()
|
|
||||||
groupLayout = QtGui.QHBoxLayout()
|
|
||||||
group.setLayout(groupLayout)
|
|
||||||
for i in range(7):
|
|
||||||
btn = QRadioButton()
|
|
||||||
screenManagementButtons.addButton(btn)
|
|
||||||
groupLayout.addWidget(btn)
|
|
||||||
layout.addWidget(group, 0, 0, 0, 1)
|
|
||||||
# TODO: Select initial screen
|
|
||||||
self.btnRotateScreen = QPushButton('Rotate')
|
|
||||||
layout.addWidget(self.btnRotateScreen, 1, 0)
|
|
||||||
self.btnNextPage = QPushButton('Next')
|
|
||||||
layout.addWidget(self.btnNextPage, 1, 1,)
|
|
||||||
centralLayout.addWidget(screenWidget)
|
|
||||||
|
|
||||||
# TODO: Screen Timeout
|
|
||||||
|
|
||||||
# (2) Group Memory
|
|
||||||
# TODO: List groups: Capacity (mAh) and Energy (mWh)
|
|
||||||
|
|
||||||
# (3) Plots
|
|
||||||
plotWidget = QWidget()
|
|
||||||
layout = QtGui.QHBoxLayout()
|
|
||||||
plotWidget.setLayout(layout)
|
|
||||||
self.plotVoltage = pg.PlotWidget()
|
|
||||||
self.plotCurrent = pg.PlotWidget()
|
|
||||||
layout.addWidget(self.plotCurrent)
|
|
||||||
layout.addWidget(self.plotVoltage)
|
|
||||||
centralLayout.addWidget(plotWidget)
|
|
||||||
|
|
||||||
# (4) Current Measurement
|
|
||||||
# TODO: (4.1) Voltage, Current, Power, Impedance
|
|
||||||
# TODO: (4.2) Recorder
|
|
||||||
# TODO: (4.3) USB D+/D-, Mode
|
|
||||||
# TODO: (4.4) Temperature (°C, °F)
|
|
||||||
|
|
||||||
self.setCentralWidget(centralWidget)
|
|
||||||
self.show()
|
|
||||||
|
|
||||||
def slot_connect_device(self):
|
|
||||||
self.statusBar().showMessage('Connecting...')
|
|
||||||
# TODO: connect to UM24C
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
screen_resolution = app.desktop().screenGeometry()
|
|
||||||
labview = UM24Lab(screen_resolution.width(), screen_resolution.height())
|
labview = UM24Lab()
|
||||||
|
labview.show()
|
||||||
|
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
|
Loading…
Reference in New Issue