forked from Barracuda09/PyPSADiag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPyPSADiagGUI.py
209 lines (181 loc) · 10.2 KB
/
PyPSADiagGUI.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
"""
PyPSADiagGUI.py
Copyright (C) 2024 - 2025 Marc Postema (mpostema09 -at- gmail.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Or, point your browser to http://www.gnu.org/copyleft/gpl.html
"""
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
QMetaObject, QObject, QPoint, QRect,
QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
QFont, QFontDatabase, QGradient, QIcon,
QImage, QKeySequence, QLinearGradient, QPainter,
QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QCheckBox, QComboBox, QFrame,
QHBoxLayout, QLineEdit, QMainWindow, QPushButton,
QSizePolicy, QSpacerItem, QSplitter, QStatusBar,
QTextEdit, QVBoxLayout, QWidget)
from EcuZoneTreeView import EcuZoneTreeView
class PyPSADiagGUI(object):
def setupGUi(self, MainWindow, scan: bool()):
if not MainWindow.objectName():
MainWindow.setObjectName(u"MainWindow")
MainWindow.resize(1100, 700)
MainWindow.setSizeIncrement(QSize(1, 1))
MainWindow.setWindowTitle("PyPSADiag")
self.centralwidget = QWidget(MainWindow)
sizePolicy = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Preferred)
sizePolicy.setHorizontalStretch(1)
sizePolicy.setVerticalStretch(1)
sizePolicy.setHeightForWidth(self.centralwidget.sizePolicy().hasHeightForWidth())
self.centralwidget.setSizePolicy(sizePolicy)
self.command = QLineEdit()
self.output = QTextEdit()
self.output.setReadOnly(True)
self.sendCommand = QPushButton()
self.sendCommand.setText(QCoreApplication.translate("MainWindow", u"Send Command", None))
self.openCSVFile = QPushButton()
self.openCSVFile.setText(QCoreApplication.translate("MainWindow", u"Open CSV File", None))
self.saveCSVFile = QPushButton()
self.saveCSVFile.setText(QCoreApplication.translate("MainWindow", u"Write CSV File", None))
self.portNameComboBox = QComboBox()
self.ConnectPort = QPushButton()
self.ConnectPort.setText(QCoreApplication.translate("MainWindow", u"Connect", None))
self.SearchConnectPort = QPushButton()
self.SearchConnectPort.setText(QCoreApplication.translate("MainWindow", u"Search", None))
self.DisconnectPort = QPushButton()
self.DisconnectPort.setText(QCoreApplication.translate("MainWindow", u"Disconnect", None))
self.openZoneFile = QPushButton()
self.openZoneFile.setText(QCoreApplication.translate("MainWindow", u"Open Zone File", None))
self.ecuComboBox = QComboBox()
self.ecuKeyComboBox = QComboBox()
self.readZone = QPushButton()
self.readZone.setText(QCoreApplication.translate("MainWindow", u"Read", None))
self.writeZone = QPushButton()
self.writeZone.setText(QCoreApplication.translate("MainWindow", u"Write", None))
self.rebootEcu = QPushButton()
self.rebootEcu.setText(QCoreApplication.translate("MainWindow", u"Reboot ECU", None))
self.readEcuFaults = QPushButton()
self.readEcuFaults.setText(QCoreApplication.translate("MainWindow", u"Read ECU Faults", None))
self.writeSecureTraceability = QCheckBox()
self.writeSecureTraceability.setText(QCoreApplication.translate("MainWindow", u"Write Secure Traceability", None))
self.virginWriteZone = QCheckBox()
self.virginWriteZone.setText(QCoreApplication.translate("MainWindow", u"Virgin Write", None))
self.hideNoResponseZone = QCheckBox()
self.hideNoResponseZone.setText(QCoreApplication.translate("MainWindow", u"Hide 'No Response' Zones", None))
# self.useSketchSeedGenerator = QCheckBox()
# self.useSketchSeedGenerator.setText(QCoreApplication.translate("MainWindow", u"Use Sketch Seed Generator", None))
self.treeView = EcuZoneTreeView(None)
if scan:
self.scanTreeView = EcuZoneTreeView(None)
###################################################
# Setup Top Left Layout
self.topLeftLayout = QVBoxLayout()
self.topLeftLayout.addWidget(self.command)
self.topLeftLayout.addWidget(self.output)
###################################################
###################################################
# Setup Top Right Layout
self.topRightLayout = QVBoxLayout()
self.topRightLayout.addWidget(self.sendCommand)
self.topRightLayout.addItem(QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding))
self.topRightLayout.addWidget(self.openCSVFile)
self.topRightLayout.addWidget(self.saveCSVFile)
self.topRightLayout.addItem(QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding))
self.topRightLayout.addWidget(self.portNameComboBox)
self.topRightLayout.addWidget(self.SearchConnectPort)
self.topRightLayout.addWidget(self.ConnectPort)
self.topRightLayout.addWidget(self.DisconnectPort)
self.topRightLayout.addItem(QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding))
###################################################
###################################################
# Setup Bottom Left Layout (TreeView)
self.bottomLeftLayout = QVBoxLayout()
self.bottomLeftLayout.addWidget(self.treeView)
###################################################
###################################################
# Setup Bottom Right Layout (Buttons)
self.bottomRightLayout = QVBoxLayout()
self.bottomRightLayout.addWidget(self.openZoneFile)
self.bottomRightLayout.addWidget(self.ecuComboBox)
self.bottomRightLayout.addWidget(self.ecuKeyComboBox)
self.bottomRightLayout.addWidget(self.readZone)
self.bottomRightLayout.addWidget(self.writeZone)
self.bottomRightLayout.addWidget(self.readEcuFaults)
self.bottomRightLayout.addWidget(self.rebootEcu)
self.bottomRightLayout.addWidget(self.virginWriteZone)
self.bottomRightLayout.addWidget(self.writeSecureTraceability)
self.bottomRightLayout.addWidget(self.hideNoResponseZone)
# self.bottomRightLayout.addWidget(self.useSketchSeedGenerator)
self.bottomRightLayout.addItem(QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding))
###################################################
###################################################
# Add Top Left, Right Layout -> Main Top Layout
self.topLayout = QHBoxLayout()
self.topLayout.addLayout(self.topLeftLayout)
self.topLayout.addLayout(self.topRightLayout)
###################################################
###################################################
# Add Bottom Left, Right Layout -> Main Bottom Layout
self.bottomLayout = QHBoxLayout()
self.bottomLayout.addLayout(self.bottomLeftLayout)
self.bottomLayout.addLayout(self.bottomRightLayout)
###################################################
###################################################
# Setup splitter Vertical (Top-Bottom)
self.splitterTopBottom = QSplitter()
self.splitterTopBottom.setStyleSheet("QSplitter::handle {background: gray;}")
self.splitterTopBottom.setOrientation(Qt.Orientation.Vertical)
self.topWidget = QWidget()
self.topWidget.setLayout(self.topLayout)
self.splitterTopBottom.addWidget(self.topWidget)
self.bottomWidget = QWidget()
self.bottomWidget.setLayout(self.bottomLayout)
self.splitterTopBottom.addWidget(self.bottomWidget)
###################################################
if scan:
###################################################
# Setup Main Left Layout
self.mainLeftLayout = QHBoxLayout()
self.mainLeftLayout.addWidget(self.scanTreeView)
###################################################
###################################################
# Setup Main Right Layout
self.mainRightLayout = QHBoxLayout()
self.mainRightLayout.addWidget(self.splitterTopBottom)
###################################################
###################################################
# Setup splitter Horizontal (Left-Right)
self.splitterLeftRight = QSplitter()
self.splitterLeftRight.setOrientation(Qt.Orientation.Horizontal)
self.mainLeftWidget = QWidget()
self.mainLeftWidget.setLayout(self.mainLeftLayout)
self.splitterLeftRight.addWidget(self.mainLeftWidget)
self.mainRightWidget = QWidget()
self.mainRightWidget.setLayout(self.mainRightLayout)
self.splitterLeftRight.addWidget(self.mainRightWidget)
###################################################
self.frame = QFrame(self.centralwidget)
self.frame.setFrameShape(QFrame.Shape.StyledPanel)
self.frame.setFrameShadow(QFrame.Shadow.Raised)
self.frameLayout = QHBoxLayout()
if scan:
self.frameLayout.addWidget(self.splitterLeftRight)
else:
self.frameLayout.addWidget(self.splitterTopBottom)
self.frame.setLayout(self.frameLayout)
# Setup Main Frame
self.mainLayout = QHBoxLayout()
self.mainLayout.addWidget(self.frame)
self.centralwidget.setLayout(self.mainLayout)
MainWindow.setCentralWidget(self.centralwidget)