um24clab/src/um24clab.py

98 lines
3.1 KiB
Python

#!/usr/bin/env python
import sys
from PyQt5.QtWidgets import (
QApplication, QWidget, QMainWindow, QLabel, QFrame, QComboBox, QPushButton
)
import PyQt5.QtGui as QtGui
import pyqtgraph as pg
class UM24Lab(QMainWindow):
def __init__(self, screen_width=1280, screen_height=1024):
super().__init__()
self.title = 'UM24C USB Meter Lab'
self.width = 800
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):
"""
Window Layout
+---------+-----------------------+
|(1) |(3) |
| (1.1) | |
| | PLOTS |
| | |
+---------+ |
|(2) +------+------+---------+
| |(4) | | |
| | (4.1)| (4.2)|(4.3) |
| | | | |
| | | |---------|
| | | |(4.4) |
| | | | |
+---------+------+------+---------+
"""
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
self.statusBar().showMessage('Idle')
centralWidget = QWidget()
centralLayout = QtGui.QHBoxLayout()
centralWidget.setLayout(centralLayout)
# (1) Device Control
# (1.1) Device Management
deviceWidget = QWidget()
layout = QtGui.QHBoxLayout()
deviceWidget.setLayout(layout)
self.deviceSelect = QComboBox()
layout.addWidget(self.deviceSelect)
# TODO: Populate deviceSelect
self.btnDeviceConnect = QPushButton('Connect')
layout.addWidget(self.btnDeviceConnect)
centralLayout.addWidget(deviceWidget)
# TODO: Status current page
# TODO: Rotate Screen
# TODO: Next Page
# TODO: Screen Brightness
# 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__':
app = QApplication(sys.argv)
screen_resolution = app.desktop().screenGeometry()
labview = UM24Lab(screen_resolution.width(), screen_resolution.height())
sys.exit(app.exec_())