Updates
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
98
main.py
98
main.py
@@ -69,6 +69,10 @@ class MainWindow(QMainWindow):
|
|||||||
self.ui.connButton.setCheckable(True)
|
self.ui.connButton.setCheckable(True)
|
||||||
self.ui.connButton.clicked.connect(self.conn_button_press)
|
self.ui.connButton.clicked.connect(self.conn_button_press)
|
||||||
|
|
||||||
|
# Add global power button action
|
||||||
|
self.ui.powerButton.setCheckable(True)
|
||||||
|
self.ui.powerButton.clicked.connect(self.power_button_press)
|
||||||
|
|
||||||
# Add radio button actions
|
# Add radio button actions
|
||||||
self.ui.radiolocal.toggled.connect(self.handle_all_radios)
|
self.ui.radiolocal.toggled.connect(self.handle_all_radios)
|
||||||
self.ui.radioscript.toggled.connect(self.handle_all_radios)
|
self.ui.radioscript.toggled.connect(self.handle_all_radios)
|
||||||
@@ -87,7 +91,11 @@ class MainWindow(QMainWindow):
|
|||||||
self.ui.setv.setHidden(True)
|
self.ui.setv.setHidden(True)
|
||||||
self.ui.actvLabel.setHidden(True)
|
self.ui.actvLabel.setHidden(True)
|
||||||
self.ui.actv.setHidden(True)
|
self.ui.actv.setHidden(True)
|
||||||
|
self.ui.scriptLabel.setHidden(True)
|
||||||
|
self.ui.script.setHidden(True)
|
||||||
|
self.ui.openButton.setHidden(True)
|
||||||
|
self.ui.runButton.setHidden(True)
|
||||||
|
|
||||||
# Set initial size
|
# Set initial size
|
||||||
initial_width = 1000
|
initial_width = 1000
|
||||||
initial_height = 600
|
initial_height = 600
|
||||||
@@ -101,8 +109,8 @@ class MainWindow(QMainWindow):
|
|||||||
self.setFixedSize(1000, 600)
|
self.setFixedSize(1000, 600)
|
||||||
|
|
||||||
# Setup serial port
|
# Setup serial port
|
||||||
#self.serial = QSerialPort(self)
|
self.serial = QSerialPort(self)
|
||||||
#self.serial.readyRead.connect(self.on_data_received)
|
self.serial.readyRead.connect(self.on_data_received)
|
||||||
|
|
||||||
# Create serial rx flag
|
# Create serial rx flag
|
||||||
self.serial_rx_flag = False
|
self.serial_rx_flag = False
|
||||||
@@ -137,6 +145,10 @@ class MainWindow(QMainWindow):
|
|||||||
self.ui.setv.setHidden(False)
|
self.ui.setv.setHidden(False)
|
||||||
self.ui.actvLabel.setHidden(False)
|
self.ui.actvLabel.setHidden(False)
|
||||||
self.ui.actv.setHidden(False)
|
self.ui.actv.setHidden(False)
|
||||||
|
self.ui.scriptLabel.setHidden(True)
|
||||||
|
self.ui.script.setHidden(True)
|
||||||
|
self.ui.openButton.setHidden(True)
|
||||||
|
self.ui.runButton.setHidden(True)
|
||||||
|
|
||||||
elif button.text() == "SCRIPT CONTROL":
|
elif button.text() == "SCRIPT CONTROL":
|
||||||
self.ui.powerButton.setHidden(True)
|
self.ui.powerButton.setHidden(True)
|
||||||
@@ -144,20 +156,56 @@ class MainWindow(QMainWindow):
|
|||||||
self.ui.setv.setHidden(True)
|
self.ui.setv.setHidden(True)
|
||||||
self.ui.actvLabel.setHidden(True)
|
self.ui.actvLabel.setHidden(True)
|
||||||
self.ui.actv.setHidden(True)
|
self.ui.actv.setHidden(True)
|
||||||
|
self.ui.scriptLabel.setHidden(False)
|
||||||
|
self.ui.script.setHidden(False)
|
||||||
|
self.ui.openButton.setHidden(False)
|
||||||
|
self.ui.runButton.setHidden(False)
|
||||||
|
|
||||||
elif button.text() == "PULSE TRIGGERED":
|
elif button.text() == "PULSE TRIGGERED":
|
||||||
self.ui.powerButton.setHidden(True)
|
self.ui.powerButton.setHidden(True)
|
||||||
self.ui.setvLabel.setHidden(True)
|
self.ui.setvLabel.setHidden(True)
|
||||||
self.ui.setv.setHidden(True)
|
self.ui.setv.setHidden(True)
|
||||||
self.ui.actvLabel.setHidden(True)
|
self.ui.actvLabel.setHidden(True)
|
||||||
self.ui.actv.setHidden(True)
|
self.ui.actv.setHidden(True)
|
||||||
|
self.ui.scriptLabel.setHidden(True)
|
||||||
|
self.ui.script.setHidden(True)
|
||||||
|
self.ui.openButton.setHidden(True)
|
||||||
|
self.ui.runButton.setHidden(True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.ui.powerButton.setHidden(True)
|
self.ui.powerButton.setHidden(True)
|
||||||
self.ui.setvLabel.setHidden(True)
|
self.ui.setvLabel.setHidden(True)
|
||||||
self.ui.setv.setHidden(True)
|
self.ui.setv.setHidden(True)
|
||||||
self.ui.actvLabel.setHidden(True)
|
self.ui.actvLabel.setHidden(True)
|
||||||
self.ui.actv.setHidden(True)
|
self.ui.actv.setHidden(True)
|
||||||
|
self.ui.scriptLabel.setHidden(True)
|
||||||
|
self.ui.script.setHidden(True)
|
||||||
|
self.ui.openButton.setHidden(True)
|
||||||
|
self.ui.runButton.setHidden(True)
|
||||||
|
|
||||||
|
def power_button_press (self):
|
||||||
|
text_pow_state = self.ui.powerButton.text()
|
||||||
|
|
||||||
|
if text_pow_state == "POWER OFF":
|
||||||
|
self.ui.powerButton.setText("POWER ON")
|
||||||
|
|
||||||
|
command = 83 #0x53 'S' ASCII
|
||||||
|
state = 1
|
||||||
|
data = (command, state)
|
||||||
|
byte_data = self.pack_integers_to_bytes(*data)
|
||||||
|
|
||||||
|
self.serial.write(QByteArray(byte_data))
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.ui.powerButton.setText("POWER OFF")
|
||||||
|
|
||||||
|
command = 83 #0x53 'S' ASCII
|
||||||
|
state = 0
|
||||||
|
data = (command, state)
|
||||||
|
byte_data = self.pack_integers_to_bytes(*data)
|
||||||
|
|
||||||
|
self.serial.write(QByteArray(byte_data))
|
||||||
|
|
||||||
|
|
||||||
def conn_button_press (self):
|
def conn_button_press (self):
|
||||||
text_conn = self.ui.connButton.text()
|
text_conn = self.ui.connButton.text()
|
||||||
@@ -171,23 +219,21 @@ class MainWindow(QMainWindow):
|
|||||||
QApplication.processEvents()
|
QApplication.processEvents()
|
||||||
|
|
||||||
# Specify serial port and baud
|
# Specify serial port and baud
|
||||||
#self.serial.setPortName("/dev/ttyACM0")
|
self.serial.setPortName("/dev/ttyACM0")
|
||||||
#self.serial.setBaudRate(115200)
|
self.serial.setBaudRate(115200)
|
||||||
|
|
||||||
#if not self.serial.open(QIODevice.ReadWrite):
|
if not self.serial.open(QIODevice.ReadWrite):
|
||||||
#print(f"Failed to open port: {self.serial.errorString()}")
|
print(f"Failed to open port: {self.serial.errorString()}")
|
||||||
|
|
||||||
command = 73 #0x49 'I' ASCII
|
command = 73 #0x49 'I' ASCII
|
||||||
state = 0
|
state = 0
|
||||||
data = (command, state)
|
data = (command, state)
|
||||||
byte_data = self.pack_integers_to_bytes(*data)
|
byte_data = self.pack_integers_to_bytes(*data)
|
||||||
|
|
||||||
#self.serial.write(QByteArray(byte_data))
|
self.serial.write(QByteArray(byte_data))
|
||||||
|
|
||||||
self.timeouttimer.start()
|
self.timeouttimer.start()
|
||||||
|
|
||||||
self.serial_rx_flag = True
|
|
||||||
|
|
||||||
while ((self.serial_rx_flag == False) and (self.timeoutflag == False)):
|
while ((self.serial_rx_flag == False) and (self.timeoutflag == False)):
|
||||||
QApplication.processEvents()
|
QApplication.processEvents()
|
||||||
|
|
||||||
@@ -195,7 +241,7 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
if self.timeoutflag == True:
|
if self.timeoutflag == True:
|
||||||
self.windowresponse = NoDeviceWindow.get_response(self)
|
self.windowresponse = NoDeviceWindow.get_response(self)
|
||||||
#self.serial.close()
|
self.serial.close()
|
||||||
self.ui.connButton.setText("CONNECT")
|
self.ui.connButton.setText("CONNECT")
|
||||||
self.ui.sn.setHidden(True)
|
self.ui.sn.setHidden(True)
|
||||||
self.ui.snLabel.setHidden(True)
|
self.ui.snLabel.setHidden(True)
|
||||||
@@ -206,6 +252,15 @@ class MainWindow(QMainWindow):
|
|||||||
self.ui.radiolocal.setHidden(True)
|
self.ui.radiolocal.setHidden(True)
|
||||||
self.ui.radioscript.setHidden(True)
|
self.ui.radioscript.setHidden(True)
|
||||||
self.ui.radiopulse.setHidden(True)
|
self.ui.radiopulse.setHidden(True)
|
||||||
|
self.ui.powerButton.setHidden(True)
|
||||||
|
self.ui.setvLabel.setHidden(True)
|
||||||
|
self.ui.setv.setHidden(True)
|
||||||
|
self.ui.actvLabel.setHidden(True)
|
||||||
|
self.ui.actv.setHidden(True)
|
||||||
|
self.ui.scriptLabel.setHidden(True)
|
||||||
|
self.ui.script.setHidden(True)
|
||||||
|
self.ui.openButton.setHidden(True)
|
||||||
|
self.ui.runButton.setHidden(True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.process_serial_number()
|
self.process_serial_number()
|
||||||
@@ -215,7 +270,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.timeoutflag = False
|
self.timeoutflag = False
|
||||||
|
|
||||||
else:
|
else:
|
||||||
#self.serial.close()
|
self.serial.close()
|
||||||
self.ui.connButton.setText("CONNECT")
|
self.ui.connButton.setText("CONNECT")
|
||||||
self.ui.sn.setHidden(True)
|
self.ui.sn.setHidden(True)
|
||||||
self.ui.snLabel.setHidden(True)
|
self.ui.snLabel.setHidden(True)
|
||||||
@@ -225,7 +280,16 @@ class MainWindow(QMainWindow):
|
|||||||
self.ui.fw.setText("---")
|
self.ui.fw.setText("---")
|
||||||
self.ui.radiolocal.setHidden(True)
|
self.ui.radiolocal.setHidden(True)
|
||||||
self.ui.radioscript.setHidden(True)
|
self.ui.radioscript.setHidden(True)
|
||||||
self.ui.radiopulse.setHidden(True)
|
self.ui.radiopulse.setHidden(True)
|
||||||
|
self.ui.powerButton.setHidden(True)
|
||||||
|
self.ui.setvLabel.setHidden(True)
|
||||||
|
self.ui.setv.setHidden(True)
|
||||||
|
self.ui.actvLabel.setHidden(True)
|
||||||
|
self.ui.actv.setHidden(True)
|
||||||
|
self.ui.scriptLabel.setHidden(True)
|
||||||
|
self.ui.script.setHidden(True)
|
||||||
|
self.ui.openButton.setHidden(True)
|
||||||
|
self.ui.runButton.setHidden(True)
|
||||||
|
|
||||||
QApplication.processEvents()
|
QApplication.processEvents()
|
||||||
|
|
||||||
@@ -283,7 +347,6 @@ class MainWindow(QMainWindow):
|
|||||||
sub_sn = self.store_buffer[0:19]
|
sub_sn = self.store_buffer[0:19]
|
||||||
sn_chars = [chr(c) for c in sub_sn if 0 <= c <= 127]
|
sn_chars = [chr(c) for c in sub_sn if 0 <= c <= 127]
|
||||||
sn_str = "".join(sn_chars)
|
sn_str = "".join(sn_chars)
|
||||||
sn_str = "ARRIVE-POWERSIM-001"
|
|
||||||
self.ui.sn.setText(sn_str)
|
self.ui.sn.setText(sn_str)
|
||||||
|
|
||||||
# Get and update FW Rev
|
# Get and update FW Rev
|
||||||
@@ -294,8 +357,7 @@ class MainWindow(QMainWindow):
|
|||||||
minor = sub_fw[2:3]
|
minor = sub_fw[2:3]
|
||||||
full = major + sep + minor
|
full = major + sep + minor
|
||||||
fw_chars = [chr(c) for c in full if 0 <= c <= 127]
|
fw_chars = [chr(c) for c in full if 0 <= c <= 127]
|
||||||
fw_str = "".join(fw_chars)
|
fw_str = "".join(fw_chars)
|
||||||
fw_str = "0:1"
|
|
||||||
self.ui.fw.setText(fw_str)
|
self.ui.fw.setText(fw_str)
|
||||||
|
|
||||||
self.ui.sn.setHidden(False)
|
self.ui.sn.setHidden(False)
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ class Ui_MainWindow(object):
|
|||||||
MainWindow.setToolButtonStyle(Qt.ToolButtonIconOnly)
|
MainWindow.setToolButtonStyle(Qt.ToolButtonIconOnly)
|
||||||
MainWindow.setAnimated(True)
|
MainWindow.setAnimated(True)
|
||||||
MainWindow.setDocumentMode(False)
|
MainWindow.setDocumentMode(False)
|
||||||
#MainWindow.setWindowIcon(QIcon('/home/david-rice/Python/Automotive-Power-Simulator-App/arriveico.png'))
|
MainWindow.setWindowIcon(QIcon('/home/david-rice/Python/Automotive-Power-Simulator-App/arriveico.png'))
|
||||||
MainWindow.setWindowIcon(QIcon('/home/dfr84/Python/Automotive-Power-Simulator-App/arriveico.png'))
|
#MainWindow.setWindowIcon(QIcon('/home/dfr84/Python/Automotive-Power-Simulator-App/arriveico.png'))
|
||||||
fontmain = QFont()
|
fontmain = QFont()
|
||||||
fontmain.setFamilies([u"Optimism Sans"])
|
fontmain.setFamilies([u"Optimism Sans"])
|
||||||
fontmain.setPointSize(8)
|
fontmain.setPointSize(8)
|
||||||
@@ -22,8 +22,8 @@ class Ui_MainWindow(object):
|
|||||||
|
|
||||||
MainWindow.setFont(fontmain)
|
MainWindow.setFont(fontmain)
|
||||||
# Ensure the path is correct for your system!
|
# Ensure the path is correct for your system!
|
||||||
#image_path = "/home/david-rice/Python/Automotive-Power-Simulator-App/appbackground.jpg"
|
image_path = "/home/david-rice/Python/Automotive-Power-Simulator-App/appbackground.jpg"
|
||||||
image_path = "/home/dfr84/Python/Automotive-Power-Simulator-App/appbackground.jpg"
|
#image_path = "/home/dfr84/Python/Automotive-Power-Simulator-App/appbackground.jpg"
|
||||||
|
|
||||||
# --- Define and Apply the Style Sheet ---
|
# --- Define and Apply the Style Sheet ---
|
||||||
bg_style_sheet = f"""
|
bg_style_sheet = f"""
|
||||||
@@ -151,12 +151,12 @@ class Ui_MainWindow(object):
|
|||||||
|
|
||||||
radiostyle = ("""
|
radiostyle = ("""
|
||||||
QRadioButton {
|
QRadioButton {
|
||||||
font-size: 14px;
|
font-size: 12px;
|
||||||
background-color: #FF80D4;
|
background-color: #FF80D4;
|
||||||
border: 1px solid #FF33BB;
|
border: 1px solid #FF33BB;
|
||||||
border-radius: 1px;
|
border-radius: 1px;
|
||||||
spacing: 10px;
|
spacing: 10px;
|
||||||
padding-left: 30px;
|
padding-left: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRadioButton::indicator {
|
QRadioButton::indicator {
|
||||||
@@ -174,7 +174,6 @@ class Ui_MainWindow(object):
|
|||||||
self.fileexplorer = QFileDialog (self.test_area)
|
self.fileexplorer = QFileDialog (self.test_area)
|
||||||
self.fileexplorer.setOption(QFileDialog.Option.DontUseNativeDialog, True)
|
self.fileexplorer.setOption(QFileDialog.Option.DontUseNativeDialog, True)
|
||||||
self.fileexplorer.setObjectName(u"fileexplorer")
|
self.fileexplorer.setObjectName(u"fileexplorer")
|
||||||
self.fileexplorer.setGeometry(QRect(25, 150, 200, 25))
|
|
||||||
|
|
||||||
filedialogstyle = ("""
|
filedialogstyle = ("""
|
||||||
QFileDialog {
|
QFileDialog {
|
||||||
@@ -198,6 +197,28 @@ class Ui_MainWindow(object):
|
|||||||
""")
|
""")
|
||||||
|
|
||||||
self.fileexplorer.setStyleSheet(filedialogstyle)
|
self.fileexplorer.setStyleSheet(filedialogstyle)
|
||||||
|
|
||||||
|
self.scriptLabel = QLabel(self.test_area)
|
||||||
|
self.scriptLabel.setObjectName(u"scriptlabel")
|
||||||
|
self.scriptLabel.setGeometry(QRect(25, 130, 400, 15))
|
||||||
|
self.scriptLabel.setAlignment(Qt.AlignCenter)
|
||||||
|
self.scriptLabel.setStyleSheet(text_label_style)
|
||||||
|
|
||||||
|
self.script = QLabel(self.test_area)
|
||||||
|
self.script.setObjectName(u"script")
|
||||||
|
self.script.setGeometry(QRect(25, 150, 400, 25))
|
||||||
|
self.script.setAlignment(Qt.AlignCenter)
|
||||||
|
self.script.setStyleSheet(label_style)
|
||||||
|
|
||||||
|
self.openButton = QPushButton(self.test_area)
|
||||||
|
self.openButton.setObjectName(u"openButton")
|
||||||
|
self.openButton.setGeometry(QRect(450, 150, 200, 25))
|
||||||
|
self.openButton.setStyleSheet(button_style)
|
||||||
|
|
||||||
|
self.runButton = QPushButton(self.test_area)
|
||||||
|
self.runButton.setObjectName(u"runButton")
|
||||||
|
self.runButton.setGeometry(QRect(675, 150, 200, 25))
|
||||||
|
self.runButton.setStyleSheet(button_style)
|
||||||
|
|
||||||
frame_style = """
|
frame_style = """
|
||||||
QFrame {
|
QFrame {
|
||||||
@@ -232,6 +253,10 @@ class Ui_MainWindow(object):
|
|||||||
self.setv.setText(QCoreApplication.translate("MainWindow", u"00.00V", None))
|
self.setv.setText(QCoreApplication.translate("MainWindow", u"00.00V", None))
|
||||||
self.actvLabel.setText(QCoreApplication.translate("MainWindow", u"VOLTAGE MEASURED", None))
|
self.actvLabel.setText(QCoreApplication.translate("MainWindow", u"VOLTAGE MEASURED", None))
|
||||||
self.actv.setText(QCoreApplication.translate("MainWindow", u"00.00V", None))
|
self.actv.setText(QCoreApplication.translate("MainWindow", u"00.00V", None))
|
||||||
|
self.scriptLabel.setText(QCoreApplication.translate("MainWindow", u"SCRIPT FILE", None))
|
||||||
|
self.script.setText(QCoreApplication.translate("MainWindow", u"---", None))
|
||||||
|
self.openButton.setText(QCoreApplication.translate("MainWindow", u"SCRIPT FILE", None))
|
||||||
|
self.runButton.setText(QCoreApplication.translate("MainWindow", u"RUN SCRIPT", None))
|
||||||
# retranslateUi
|
# retranslateUi
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user