-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.py
109 lines (87 loc) · 3.47 KB
/
debug.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
############################################################################################################
## Description: Displays debug values for testing in a seperate window
## Values displayed: channels which can display any value based on parameters passed in
## Written for: BOLT Senior Design Team
## Author: Henry Trease
## Written: Fall 2017
## Modified: Fall 2017
## Notes:
############################################################################################################
import sys
from PyQt5.QtWidgets import QWidget, QPushButton, QLCDNumber, QLabel, QAction, QFrame, QApplication, QPushButton
from PyQt5.QtGui import QIcon, QPainter, QColor, QPen
from PyQt5.QtCore import QObject, pyqtSlot, pyqtSignal, Qt
from gpsGauge import Gps
DEBUG_WIDTH = 600
DEBUG_HEIGHT = 380
CHANNEL_WIDTH = 100
CHANNEL_HEIGHT = 100
class Debug(QWidget):
def __init__(self, parent):
super(Debug, self).__init__(parent)
self.setWindowTitle('DEBUG WINDOW')
self.setMinimumWidth(DEBUG_WIDTH)
self.setMinimumHeight(DEBUG_HEIGHT)
self.initDebug()
def initDebug(self):
self.setAutoFillBackground(True)
self.closeButton = QPushButton("Close", self)
self.closeButton.move(540,350)
self.closeButton.resize(50,20)
self.closeButton.clicked.connect(self.debug_close)
self.c1 = Channel(self, "RPM:",0, 20, 0)
self.c2 = Channel(self, "SOC:", 125, 20, 0.0)
self.c3 = Channel(self, "MC Temp:",250,20,0.0)
self.c4 = Channel(self, "Motor Temp:",350,20,0.0)
self.c5 = Channel(self, "High Cell Temp:",0,100,0.0)
self.c6 = Channel(self, "Low Cell Temp:",150,100,0.0)
self.c7 = Channel(self, "High Motor Temp:",450,20,0.0)
self.c8 = Channel(self, "DCL:",300,100,0.0)
p = self.palette()
p.setColor(self.backgroundRole(), Qt.gray)
p.setColor(self.foregroundRole(), Qt.blue)
self.setPalette(p)
self.hide()
@pyqtSlot()
def debug_open(self):
self.show()
@pyqtSlot()
def debug_close(self):
self.close()
# channel to limit code duplication
class Channel(QWidget):
def __init__(self, parent, name, x, y, value):
super(Channel, self).__init__(parent)
self.label = QLabel(name, self)
self.label.resize(CHANNEL_WIDTH,20)
self.label.move(x,y)
self.label.show()
self.gauge = QLCDNumber(self)
self.gauge.display(value)
self.gauge.move(x,y+10)
self.gauge.resize(CHANNEL_WIDTH, CHANNEL_HEIGHT)
self.gauge.setFrameShape(QFrame.NoFrame)
self.gauge.setSegmentStyle(QLCDNumber.Flat)
@pyqtSlot(float)
def channel_update(self, value):
self.gauge.display(value)
self.value = value
self.update()
# channel to display x,y,z data points
class Channel3(QWidget):
def __init__(self, parent, name, x, y, value):
super(Channel3, self).__init__(parent)
self.label = QLabel(name, self)
self.label.resize(CHANNEL_WIDTH,20)
self.label.move(x,y)
self.gauge = QLCDNumber(self)
self.gauge.display(value)
self.gauge.move(x,y+20)
self.gauge.resize(CHANNEL_WIDTH, CHANNEL_HEIGHT)
self.gauge.setFrameShape(QFrame.NoFrame)
self.gauge.setSegmentStyle(QLCDNumber.Flat)
@pyqtSlot(float)
def channel_update(self, value):
self.gauge.display(value)
self.value = value
self.update()