From 41803786aa3b2de572cd03d64cd6b1bc0f87f17f Mon Sep 17 00:00:00 2001 From: david rice Date: Tue, 20 Jan 2026 08:24:36 +0000 Subject: [PATCH] Updates --- __pycache__/ui_connerror.cpython-312.pyc | Bin 3893 -> 3898 bytes __pycache__/ui_mainwindow.cpython-312.pyc | Bin 13973 -> 16022 bytes __pycache__/ui_scanning.cpython-312.pyc | Bin 2624 -> 2629 bytes main.py | 98 ++++++++++++++++++---- ui_mainwindow.py | 39 +++++++-- 5 files changed, 112 insertions(+), 25 deletions(-) diff --git a/__pycache__/ui_connerror.cpython-312.pyc b/__pycache__/ui_connerror.cpython-312.pyc index c58dfb94e3946eb07df0f3210e4f5cf8b206e28b..3536310f2ffa7a7c790ac5e8829f103f37e99443 100644 GIT binary patch delta 42 wcmdlgw@Z%eG%qg~0}z~2+sKv6CFrJ~k)NBYpORRXnW9^inVh=0nQIdZ0RH|A^8f$< delta 37 rcmdlbw^feoG%qg~0}wpQ*vOU3#p9@-k)NBYpORK&VY0b{YZD6q$T15T diff --git a/__pycache__/ui_mainwindow.cpython-312.pyc b/__pycache__/ui_mainwindow.cpython-312.pyc index eb7a30eb54be6895bfbed782d480d1643f17f344..cfff473d708fe26e467e79b696775cd610d78070 100644 GIT binary patch delta 1316 zcmZuvOKcle6!o*?`1v!A661`2HFoPy+{6y?XYz3fQc?nu+%$4sB0}T*#wISY9mWZz zp)4vPL{}|bfv7~m5k&z-pdc@Z#0FSJ;v-u#$R!F=7v8W5r3eYJV&2$^YAH{eqx;UB zbKae~@BQotZ|Z-fD2+^9+e|+5+u5)6pCb8B7C7)*NNLPFNCkh==BAwzsf12j~+b9xV18v!vAz%k+naQy@ZM1Xl$t^K(Zy7IzRcSQcO8oqK* z8t>zdDt1(`0QPR&G-?Mebu=6`Ly9RK=bO_LRN-0v@P!+CEHtlDw1TJA2?8PuDYNJ}>Ny z@(%J&G~CkO)HY7<*s^ch1^m=8>#SgBv0K1_n#EmY$sxQY0<%3`zQWGfZU^rg7Vy(V z-FCCBib*TQ6#<88W>+z>mE277<}jqa9+)}XsdiPct9V(!K}h)DmOoUM4*aVvP*Tt^ z76_YltZZ9RpMBHKa!5C8sW*mBOO>cqN?Q1m_DW9bB&T>~^e`3t$hx7uI2NCnN;t+R zV$W`9;+G~Jb;4(W!(ezOMkduo;0yr|0Uv?$1pEXh3G@<(6KEc=PtHvfmKLEP7s27+ z771|)mO~EJBSMGdrCXuT5FCbE&mE12Oj~gFRh`j_GrAkw3zTP)ymL;#^T$8mTESMq z)>E}H6&tg2{ks?T61*)g;EV8k$gHuKU!3I~NdeEnUttrqN0p~v;-9?yE1u<87>sle zE=gU8@P&+HNiDTyBozTHK7}?B-jY3%rxnW3-*HvDGKoa@-AK`rCAwqVe|R{XXV+I! XBOC|QOt;|;1xljZe@J1X%!%Zcj)8-rLhV+WAld{S#S zo6QXlp6eWv7da%abEsbAP+gL`!f6BZhTt7am(^^qaM*od5tiZU;Qye-z{v|!r+$$` zeFgs&4vWds#%){$Eb#DL$SS;fpK&M)PbGsUk6)2EFf6L%Cm*nsn!MApib<1yvY(ZS zn+H&|NCQMDg9tScp$Q^9L4+=d@B$I~KthwLCga#V!-G%qg~0}vQi$8F?}W)pPP&&bbB)lW$*%S_QN%1ln(T*P*c82|$H4FCWD delta 38 scmX>qazKRpG%qg~0}wpQ$lJ&r&Bo)PpOK%Ns-KcpWMQ(oob4Pl0Mxk)c>n+a diff --git a/main.py b/main.py index d437c28..e236a1d 100644 --- a/main.py +++ b/main.py @@ -69,6 +69,10 @@ class MainWindow(QMainWindow): self.ui.connButton.setCheckable(True) 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 self.ui.radiolocal.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.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) + # Set initial size initial_width = 1000 initial_height = 600 @@ -101,8 +109,8 @@ class MainWindow(QMainWindow): self.setFixedSize(1000, 600) # Setup serial port - #self.serial = QSerialPort(self) - #self.serial.readyRead.connect(self.on_data_received) + self.serial = QSerialPort(self) + self.serial.readyRead.connect(self.on_data_received) # Create serial rx flag self.serial_rx_flag = False @@ -137,6 +145,10 @@ class MainWindow(QMainWindow): self.ui.setv.setHidden(False) self.ui.actvLabel.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": self.ui.powerButton.setHidden(True) @@ -144,20 +156,56 @@ class MainWindow(QMainWindow): self.ui.setv.setHidden(True) self.ui.actvLabel.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": 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.actv.setHidden(True) + self.ui.scriptLabel.setHidden(True) + self.ui.script.setHidden(True) + self.ui.openButton.setHidden(True) + self.ui.runButton.setHidden(True) else: 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.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): text_conn = self.ui.connButton.text() @@ -171,23 +219,21 @@ class MainWindow(QMainWindow): QApplication.processEvents() # Specify serial port and baud - #self.serial.setPortName("/dev/ttyACM0") - #self.serial.setBaudRate(115200) + self.serial.setPortName("/dev/ttyACM0") + self.serial.setBaudRate(115200) - #if not self.serial.open(QIODevice.ReadWrite): - #print(f"Failed to open port: {self.serial.errorString()}") + if not self.serial.open(QIODevice.ReadWrite): + print(f"Failed to open port: {self.serial.errorString()}") command = 73 #0x49 'I' ASCII state = 0 data = (command, state) byte_data = self.pack_integers_to_bytes(*data) - #self.serial.write(QByteArray(byte_data)) + self.serial.write(QByteArray(byte_data)) self.timeouttimer.start() - self.serial_rx_flag = True - while ((self.serial_rx_flag == False) and (self.timeoutflag == False)): QApplication.processEvents() @@ -195,7 +241,7 @@ class MainWindow(QMainWindow): if self.timeoutflag == True: self.windowresponse = NoDeviceWindow.get_response(self) - #self.serial.close() + self.serial.close() self.ui.connButton.setText("CONNECT") self.ui.sn.setHidden(True) self.ui.snLabel.setHidden(True) @@ -206,6 +252,15 @@ class MainWindow(QMainWindow): self.ui.radiolocal.setHidden(True) self.ui.radioscript.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: self.process_serial_number() @@ -215,7 +270,7 @@ class MainWindow(QMainWindow): self.timeoutflag = False else: - #self.serial.close() + self.serial.close() self.ui.connButton.setText("CONNECT") self.ui.sn.setHidden(True) self.ui.snLabel.setHidden(True) @@ -225,7 +280,16 @@ class MainWindow(QMainWindow): self.ui.fw.setText("---") self.ui.radiolocal.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() @@ -283,7 +347,6 @@ class MainWindow(QMainWindow): sub_sn = self.store_buffer[0:19] sn_chars = [chr(c) for c in sub_sn if 0 <= c <= 127] sn_str = "".join(sn_chars) - sn_str = "ARRIVE-POWERSIM-001" self.ui.sn.setText(sn_str) # Get and update FW Rev @@ -294,8 +357,7 @@ class MainWindow(QMainWindow): minor = sub_fw[2:3] full = major + sep + minor fw_chars = [chr(c) for c in full if 0 <= c <= 127] - fw_str = "".join(fw_chars) - fw_str = "0:1" + fw_str = "".join(fw_chars) self.ui.fw.setText(fw_str) self.ui.sn.setHidden(False) diff --git a/ui_mainwindow.py b/ui_mainwindow.py index e113d5f..4a80f4f 100644 --- a/ui_mainwindow.py +++ b/ui_mainwindow.py @@ -13,8 +13,8 @@ class Ui_MainWindow(object): MainWindow.setToolButtonStyle(Qt.ToolButtonIconOnly) MainWindow.setAnimated(True) MainWindow.setDocumentMode(False) - #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/david-rice/Python/Automotive-Power-Simulator-App/arriveico.png')) + #MainWindow.setWindowIcon(QIcon('/home/dfr84/Python/Automotive-Power-Simulator-App/arriveico.png')) fontmain = QFont() fontmain.setFamilies([u"Optimism Sans"]) fontmain.setPointSize(8) @@ -22,8 +22,8 @@ class Ui_MainWindow(object): MainWindow.setFont(fontmain) # Ensure the path is correct for your system! - #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/david-rice/Python/Automotive-Power-Simulator-App/appbackground.jpg" + #image_path = "/home/dfr84/Python/Automotive-Power-Simulator-App/appbackground.jpg" # --- Define and Apply the Style Sheet --- bg_style_sheet = f""" @@ -151,12 +151,12 @@ class Ui_MainWindow(object): radiostyle = (""" QRadioButton { - font-size: 14px; + font-size: 12px; background-color: #FF80D4; border: 1px solid #FF33BB; border-radius: 1px; spacing: 10px; - padding-left: 30px; + padding-left: 40px; } QRadioButton::indicator { @@ -174,7 +174,6 @@ class Ui_MainWindow(object): self.fileexplorer = QFileDialog (self.test_area) self.fileexplorer.setOption(QFileDialog.Option.DontUseNativeDialog, True) self.fileexplorer.setObjectName(u"fileexplorer") - self.fileexplorer.setGeometry(QRect(25, 150, 200, 25)) filedialogstyle = (""" QFileDialog { @@ -198,6 +197,28 @@ class Ui_MainWindow(object): """) 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 = """ QFrame { @@ -232,6 +253,10 @@ class Ui_MainWindow(object): self.setv.setText(QCoreApplication.translate("MainWindow", u"00.00V", None)) self.actvLabel.setText(QCoreApplication.translate("MainWindow", u"VOLTAGE MEASURED", 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