116 lines
3.8 KiB
Python
116 lines
3.8 KiB
Python
#!/usr/bin/env python
|
|
import sys
|
|
from PyQt5.QtWidgets import (
|
|
QApplication, QWidget, QMainWindow, QLabel, QFrame, QComboBox, QPushButton,
|
|
QButtonGroup, QRadioButton
|
|
)
|
|
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) | |
|
|
| (1.2) | 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)
|
|
|
|
# (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__':
|
|
app = QApplication(sys.argv)
|
|
screen_resolution = app.desktop().screenGeometry()
|
|
labview = UM24Lab(screen_resolution.width(), screen_resolution.height())
|
|
sys.exit(app.exec_())
|