From f797941b81aca09ee7b5a93e46bab949f8fb2688 Mon Sep 17 00:00:00 2001 From: David M Kim Date: Wed, 2 Aug 2023 13:23:27 -0400 Subject: [PATCH 1/7] update to the peltier so it checks the tempdifference, deleted unused method --- Gui/QtGUIutils/PeltierCoolingApp.py | 92 ++++++++++++++++++----------- 1 file changed, 56 insertions(+), 36 deletions(-) diff --git a/Gui/QtGUIutils/PeltierCoolingApp.py b/Gui/QtGUIutils/PeltierCoolingApp.py index 5bc189ce..79e24dfc 100644 --- a/Gui/QtGUIutils/PeltierCoolingApp.py +++ b/Gui/QtGUIutils/PeltierCoolingApp.py @@ -4,6 +4,8 @@ from PyQt5.QtWidgets import QWidget, QMessageBox from PyQt5.QtCore import * from Gui.python.Peltier import * +from Gui.siteSettings import * + import time import os @@ -15,12 +17,19 @@ class Peltier(QWidget): tempReading2 = pyqtSignal(float) powerReading = pyqtSignal(int) setTempSignal = pyqtSignal(float) + urgentSignal = pyqtSignal(bool) + def __init__(self, dimension): super(Peltier, self).__init__() self.Ph2ACFDirectory = os.getenv("GUI_dir") + self.t1 = 0.0 + self.t2 = 0.0 + self.emergencySwitch = False + self.powerStatusValue = 0 self.setupUi() self.show() + def setupUi(self): self.gridLayout = QtWidgets.QGridLayout(self) @@ -36,7 +45,7 @@ def setupUi(self): self.gridLayout.addWidget(self.currentTempDisplay, 3, 0, 1, 2) self.currentTempDisplay2 = QtWidgets.QLCDNumber(self) - self.gridLayout.addWidget(self.currentTempDisplay2, 3, 2, 1, 2) + self.gridLayout.addWidget(self.currentTempDisplay2, 4, 0, 1, 2) self.setTempButton = QtWidgets.QPushButton("Set Temperature", self) self.setTempButton.setEnabled(False) @@ -50,6 +59,9 @@ def setupUi(self): self.currentTempLabel = QtWidgets.QLabel(self) self.gridLayout.addWidget(self.currentTempLabel, 2, 0, 1, 1) + self.currentTempLabel2 = QtWidgets.QLabel(self) + self.gridLayout.addWidget(self.currentTempLabel2, 4, 1, 1, 1) + self.polarityButton = QtWidgets.QPushButton("Change Polarity", self) self.polarityButton.setEnabled(False) self.polarityButton.clicked.connect(self.polarityToggle) @@ -72,8 +84,6 @@ def setupUi(self): self.gridLayout.addWidget(self.powerStatus, 1, 3, 1, 1) - - self.setLayout(self.gridLayout) def setup(self): @@ -99,6 +109,7 @@ def setup(self): # Create QTimer that will call functions self.timer = QTimer() self.timer.timeout.connect(self.controllerMonitoring) + self.timer.timeout.connect(self.controllerMonitoring2) self.tempReading.connect(lambda temp: self.currentTempDisplay.display(temp)) self.tempReading2.connect(lambda temp: self.currentTempDisplay2.display(temp)) self.powerReading.connect(lambda power: self.setPowerStatus(power)) @@ -128,16 +139,26 @@ def setPowerStatus(self, power): def powerToggle(self): if self.powerStatusValue == 0: - try: - self.pelt.sendCommand(self.pelt.createCommand('Power On/Off Write', ['0','0','0','0','0','0','0','1'])) - except Exception as e: - print("Could not turn on controller due to error: ", e) + if self.emergencySwitch == False: + try: + self.pelt.sendCommand(self.pelt.createCommand('Power On/Off Write', ['0','0','0','0','0','0','0','1'])) + except Exception as e: + print("Could not turn on controller due to error: ", e) + else: + reply = QMessageBox.question(None, "Warning", "The most recent test was aborted due to temperature.\nAre you sure you want to turn on?", + QMessageBox.No | QMessageBox.Yes, QMessageBox.No) + if reply == QMessageBox.Yes: + self.emergencySwitch = False + try: + self.pelt.sendCommand(self.pelt.createCommand('Power On/Off Write', ['0','0','0','0','0','0','0','1'])) + except Exception as e: + print("Could not turn on controller due to error: ", e) elif self.powerStatusValue == 1: try: self.pelt.sendCommand(self.pelt.createCommand('Power On/Off Write', ['0','0','0','0','0','0','0','0'])) except Exception as e: print("Could not turn off controller due to error: " , e) - + def setPolarityStatus(self, polarity): if polarity[8] == '0': self.polarityValue = 'HEAT WP1+ and WP2-' @@ -161,8 +182,6 @@ def polarityToggle(self): self.pelt.sendCommand(self.pelt.createCommand('Control Output Polarity Write', ['0','0','0','0','0','0','0', polarityCommand])) self.polarityButton.setText(self.polarityValue) #FIXME Probably a better idea to read polarity from controller - - def setTemp(self)-> None: try: message = self.convertSetTempValueToList(self.setTempInput.value()) @@ -203,27 +222,17 @@ def convertSetTempValueToList(self, temp: float) -> list: # Shutdown the peltier if it is on and stop threads that are running # Currently not implemented def shutdown(self): - try: - self.pelt.sendCommand(self.pelt.createCommand('Power On/Off Write', ['0','0','0','0','0','0','0','0'])) - except Exception as e: - print("Could not turn off controller due to error: " , e) + if self.powerStatusValue == 1: + try: + self.pelt.sendCommand(self.pelt.createCommand('Power On/Off Write', ['0','0','0','0','0','0','0','0'])) + except Exception as e: + print("Could not turn off controller due to error: " , e) try: self.tempPower.readTemp = False except AttributeError: pass - - - def getPower(self): - try: - self.power = self.pelt.checkPower() - except Exception as e: - self.powerTimer.stop() - print("Could not check power due to error: " , e) - - - def controllerMonitoring(self): try: message, passed = self.pelt.sendCommand(self.pelt.createCommand('Input1', ['0','0','0','0','0','0','0','0'])) @@ -232,6 +241,8 @@ def controllerMonitoring(self): self.tempReading.emit(temp) self.tempLimit(temp) + self.t1 = temp + power, passed = self.pelt.sendCommand(self.pelt.createCommand('Power On/Off Read' ,['0','0','0','0','0','0','0','0'])) self.powerReading.emit(int(power[8])) return @@ -246,6 +257,9 @@ def controllerMonitoring2(self): temp = int(temp,16)/100 self.tempReading2.emit(temp) self.tempLimit(temp) + + self.t2 = temp + self.tempDiff() return except Exception as e: @@ -253,19 +267,25 @@ def controllerMonitoring2(self): return def tempLimit(self, temp): - try: - temp >= 5 - #self.closeEvent() #Will change this to take effect if the code runs + if temp >= defaultPeltierMaxTemp and self.emergencySwitch == False: print("Temperature too high") - return - except: - return - - def setBandwidth(self): - signalworker = signalWorker('Proportional Bandwidth Write', message) - + self.haltSig = True + self.urgentSignal.emit(self.haltSig) + self.emergencySwitch = True + else: + pass + + def tempDiff(self): + if abs(self.t2-self.t1) > defaultPeltierMaxTempDiff and self.emergencySwitch == False: + print("Temp difference too big") + self.haltSig = True + self.urgentSignal.emit(self.haltSig) + self.emergencySwitch = True + else: + pass + if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) ui = Peltier(500) - sys.exit(app.exec_()) + sys.exit(app.exec_()) \ No newline at end of file From b5e6ddfed33725d566be674ed72ca25cfdd41fab Mon Sep 17 00:00:00 2001 From: David M Kim Date: Wed, 2 Aug 2023 14:06:13 -0400 Subject: [PATCH 2/7] added maxtemp,maxtempdiff to sitesettings_template. PeltCoolingApp still imports sitesettings.py --- Gui/siteSettings_template.py | 59 +++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/Gui/siteSettings_template.py b/Gui/siteSettings_template.py index 173e09dc..2078d665 100644 --- a/Gui/siteSettings_template.py +++ b/Gui/siteSettings_template.py @@ -5,14 +5,14 @@ # Set gpib debug mode to True if you want to see SCPI commands sent to HV and LV devices: GPIB_DebugMode = False - -## The following block sets defaults that are to be used in the simplified (non-expert) mode. ## -## This mode is currently under development, so these values don't currently do anything ## - +# Ph2_ACF version being used +defaultACFVersion = "4.0.13" # default FC7 boardName -defaultFC7 = "fc7.board.1" +defaultFC7 = ['fc7.board.1'] # default IP address of IP address -defaultFC7IP = '192.168.1.80' +defaultFC7IP = ['192.168.1.80'] +# default fpga config +#defaultFPGAConfig = 'IT-uDTC_L12-KSU-3xQUAD_L8-KSU2xQUAD_x1G28' # default FMC board number defaultFMC = '0' # default mode for LV powering (Direct,SLDO,etc) @@ -34,32 +34,42 @@ defaultUSBPortLV = ["ASRL/dev/ttyUSBLV::INSTR"] # default model for LV power supply defaultLVModel = ["KeySight E3633 (RS232)"] -#default BaudRate for Arduino sensor -defaultSensorBaudRate = 9600 -################################# - +# default setting for module ( "SingleSCC","TFPX Quad","TEPX Quad","TBPX Quad","Yellow Module (Purdue)"): +defaultModuleType = "TFPX Quad" +# default mode for LV powering (Direct,SLDO,etc) +defaultPowerMode = "SLDO" -## Specify whether of not you want to monitor chip temperature during the tests ## -## Set this to "1" if you want the monitoring enabled. Set it to "0" if you want it disabled. ## -Monitor_RD53A = "1" -Monitor_CROC = "0" +#defaultVoltageMap = { +# "Direct" : 1.28, +# "SLDO" : 1.90 +#} #setting default HV current compliance in mA defaultHVCurrentCompliance = 0.00001 - -#setting HV bias voltage in V +#setting default HV bias voltage in V defaultHVsetting = -60 +#default BaudRate for Arduino sensor +defaultSensorBaudRate = 9600 +#default DBServerIP +defaultDBServerIP = '127.0.0.1' +#default DBName +defaultDBName = 'SampleDB' +defaultTargetThr = ['2000','1500','1200','1000','800'] +##### The following settings are for SLDO scans developed for Purdue.##### +##### Do not modify these settings unless you know what you are doing.#### +#default settings for SLDO scan. +defaultSLDOscanVoltage = 0.0 +defaultSLDOscanMaxCurrent = 0.0 -## Configuring the current settings for each module type. These values are in Amps. + +# Configuring the current settings for each module type. These values are in Amps. ModuleCurrentMap = { "SingleSCC" : 0.6, "TFPX Quad" : 6.5, "TEPX Quad" : 6, "TBPX Quad" : 6.5, "Yellow Module (Purdue)": 6.5, - - "CROC 1x2" : 4.5, - + "CROC 1x2" : 4.0, "TFPX CROC Quad" : 6.5, "CROC SCC" : 2.0, } @@ -71,9 +81,7 @@ "TEPX Quad" : 2.0, "TBPX Quad" : 2.98, "Yellow Module (Purdue)": 2.8, - - "CROC 1x2" : 2.2, - + "CROC 1x2" : 2.0, "TFPX CROC Quad" : 2.98, "CROC SCC" : 1.8, } @@ -99,4 +107,7 @@ defaultPeltierPort = '/dev/ttyUSBPeltier' defaultPeltierBaud = 9600 defaultPeltierSetTemp = 20 -defaultPeltierWarningTemp = 40 \ No newline at end of file +#defaultPeltierWarningTemp = 40 +defaultPeltierMaxTemp = 30 +defaultPeltierMaxTempDiff = 5 + From b3ba0f146e8ff92f484dd23fe8176019ea32c47c Mon Sep 17 00:00:00 2001 From: Ryan De Los Santos Date: Tue, 30 Jan 2024 10:44:31 -0500 Subject: [PATCH 3/7] update run_Docker.sh to use new docker image and setup --- run_Docker.sh | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/run_Docker.sh b/run_Docker.sh index 672dea76..79d16435 100644 --- a/run_Docker.sh +++ b/run_Docker.sh @@ -1,15 +1,34 @@ #!/bin/bash SOCK=/tmp/.X11-unix; XAUTH=/tmp/.docker.xauth; xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -; chmod 777 $XAUTH; - +mode=$1 +echo "the mode is $mode" ## Change the ports in 'mydevicelist' to those which you wish to use with the GUI############# mydevices="" -mydevicelist=("/dev/ttyUSBLV" "/dev/ttyUSBHV" "/dev/ttyUSBPeltier" "/dev/ttyACM0") +target="tty" +mydevicelist=() +for sysdevpath in $(find /sys/bus/usb/devices/usb*/ -name dev); do + syspath="${sysdevpath%/dev}" + devname="$(udevadm info -q name -p $syspath)" + device="/dev/$devname" + if [[ $device =~ $target ]]; then + mydevicelist+=("$device") + fi +done +#echo "${mydevicelist[@]}" + +aliasout=$(ls -alF /dev/ttyUSB*) +aliasprint=$(echo "$aliasout" | awk '{print $9}' | grep "$target") +#echo $aliasprint +aliasarr=($aliasprint) +for usbalias in "${aliasarr[@]}"; do + mydevicelist+=("$usbalias") +done for mydevice in "${mydevicelist[@]}"; do mydevices+="--device=$mydevice " mydevices+=" " - echo "device loaded $mydevices" + echo "device loaded $mydevice" done mydevices=$(echo $mydevices | xargs) echo $mydevices | xargs @@ -17,5 +36,19 @@ echo $mydevices | xargs #docker run --rm -ti -v $PWD:$PWD -v ${PWD}/Ph2_ACF/test:/home/cmsTkUser/Ph2_ACF_GUI/Ph2_ACF/test -v ${PWD}/data:/home/cmsTkUser/Ph2_ACF_GUI/data $devices -w $PWD -e DISPLAY=$DISPLAY -v $XSOCK:$XSOCK -v $XAUTH:$XAUTH -e XAUTHORITY=$XAUTH --net host local/testimage #docker run --rm -ti -v $PWD:$PWD -v ${PWD}/Ph2_ACF/test:/home/cmsTkUser/Ph2_ACF_GUI/Ph2_ACF/test -v ${PWD}/data:/home/cmsTkUser/Ph2_ACF_GUI/data --device=/dev/ttyUSBHV --device=/dev/ttyUSBLV --device=/dev/ttyUSBPeltier --device=/dev/ttyACM0 -w $PWD -e DISPLAY=$DISPLAY -v $XSOCK:$XSOCK -v $XAUTH:$XAUTH -e XAUTHORITY=$XAUTH --net host local/testimage -docker run --rm -ti $mydevices -v $PWD:$PWD -v ${PWD}/Ph2_ACF/test:/home/cmsTkUser/Ph2_ACF_GUI/Ph2_ACF/test -v ${PWD}/Gui/siteConfig.py:/home/cmsTkUser/Ph2_ACF_GUI/Gui/siteSettings.py:ro -v ${PWD}/data:/home/cmsTkUser/Ph2_ACF_GUI/data -w $PWD -e DISPLAY=$DISPLAY -v $XSOCK:$XSOCK -v $XAUTH:$XAUTH -e XAUTHORITY=$XAUTH --net host majoyce2/ph2_acf_gui:latest -#docker run --rm -ti $mydevices -v $PWD:$PWD -v ${PWD}/Ph2_ACF/test:/home/cmsTkUser/Ph2_ACF_GUI/Ph2_ACF/test -v ${PWD}/Gui/siteConfig.py:/home/cmsTkUser/Ph2_ACF_GUI/Gui/siteSettings.py:ro -v ${PWD}/data:/home/cmsTkUser/Ph2_ACF_GUI/data -w $PWD -e DISPLAY=$DISPLAY -v $XSOCK:$XSOCK -v $XAUTH:$XAUTH -e XAUTHORITY=$XAUTH --net host local/testimage +#docker run --rm -ti $mydevices -v $PWD:$PWD -v ${PWD}/Ph2_ACF/test:/home/cmsTkUser/Ph2_ACF_GUI/Ph2_ACF/test -v ${PWD}/Gui/siteConfig.py:/home/cmsTkUser/Ph2_ACF_GUI/Gui/siteSettings.py:ro -v ${PWD}/data:/home/cmsTkUser/Ph2_ACF_GUI/data -w $PWD -e DISPLAY=$DISPLAY -v $XSOCK:$XSOCK -v $XAUTH:$XAUTH -e XAUTHORITY=$XAUTH --net host majoyce2/ph2_acf_gui:latest + +#docker run --rm -ti $mydevices -v $PWD:$PWD -v ${PWD}/Ph2_ACF/test:/home/cmsTkUser/Ph2_ACF_GUI/Ph2_ACF/test -v ${PWD}/Gui/siteConfig.py:/home/cmsTkUser/Ph2_ACF_GUI/Gui/siteSettings.py:ro -v ${PWD}/data:/home/cmsTkUser/Ph2_ACF_GUI/data -w $PWD -e DISPLAY=$DISPLAY -v $XSOCK:$XSOCK -v $XAUTH:$XAUTH -e XAUTHORITY=$XAUTH --net host majoyce2/ph2_acf_gui:latest + +#docker run --rm -ti $mydevices -v $PWD:$PWD -v ${PWD}/icicle/icicle:/home/cmsTkUser/Ph2_ACF_GUI/icicle/icicle:ro -v ${PWD}/Gui/siteConfig.py:/home/cmsTkUser/Ph2_ACF_GUI/Gui/siteSettings.py -v ${PWD}/Ph2_ACF/test:/home/cmsTkUser/Ph2_ACF_GUI/Ph2_ACF/test -v ${PWD}/data:/home/cmsTkUser/Ph2_ACF_GUI/data -v ${PWD}/Gui/QtGUIutils/:/home/cmsTkUser/Ph2_ACF_GUI/Gui/QtGUIutils/ -v ${PWD}/Gui/GUIutils/:/home/cmsTkUser/Ph2_ACF_GUI/Gui/GUIutils/ -w $PWD -e DISPLAY=$DISPLAY -v $XSOCK:$XSOCK -v $XAUTH:$XAUTH -e XAUTHORITY=$XAUTH --net host local/testimage +if [[ $mode == "dev" ]] +then + echo "running as $mode" + docker run --rm -ti $mydevices -v ${PWD}:${PWD} -v ${PWD}/icicle/icicle:/home/cmsTkUser/Ph2_ACF_GUI/icicle/icicle:ro -v ${PWD}/Gui/siteConfig.py:/home/cmsTkUser/Ph2_ACF_GUI/Gui/siteSettings.py -v ${PWD}/Ph2_ACF/test:/home/cmsTkUser/Ph2_ACF_GUI/Ph2_ACF/test -v ${PWD}/data:/home/cmsTkUser/Ph2_ACF_GUI/data -v ${PWD}/Gui/QtGUIutils/:/home/cmsTkUser/Ph2_ACF_GUI/Gui/QtGUIutils/ -v ${PWD}/Gui/GUIutils/:/home/cmsTkUser/Ph2_ACF_GUI/Gui/GUIutils/ -v ${PWD}/Gui/python/:/home/cmsTkUser/Ph2_ACF_GUI/Gui/python/ -v ${PWD}/InnerTrackerTests/:/home/cmsTkUser/Ph2_ACF_GUI/Gui/InnerTrackerTests/ -v ${PWD}/Configuration:/home/cmsTkUser/Ph2_ACF_GUI/Configuration -w $PWD -e DISPLAY=$DISPLAY -v $XSOCK:$XSOCK -v $XAUTH:$XAUTH -e XAUTHORITY=$XAUTH --net host majoyce2/ph2_acf_gui_dev:latest +else + echo "running as user" + docker run --rm -ti $mydevices -v ${PWD}:${PWD} -v ${PWD}/InnerTrackerTests:/home/cmsTkUser/Ph2_ACF_GUI/Gui/InnerTrackerTests -v ${PWD}/icicle/icicle:/home/cmsTkUser/Ph2_ACF_GUI/icicle/icicle:ro -v ${PWD}/Gui/siteConfig.py:/home/cmsTkUser/Ph2_ACF_GUI/Gui/siteSettings.py -v ${PWD}/Ph2_ACF/test:/home/cmsTkUser/Ph2_ACF_GUI/Ph2_ACF/test -v ${PWD}/data:/home/cmsTkUser/Ph2_ACF_GUI/data -v ${PWD}/Gui/QtGUIutils/:/home/cmsTkUser/Ph2_ACF_GUI/Gui/QtGUIutils/ -v ${PWD}/Gui/GUIutils/:/home/cmsTkUser/Ph2_ACF_GUI/Gui/GUIutils/ -v ${PWD}/Gui/python/:/home/cmsTkUser/Ph2_ACF_GUI/Gui/python/ -v ${PWD}/Configuration:/home/cmsTkUser/Ph2_ACF_GUI/Configuration -w $PWD -e DISPLAY=$DISPLAY -v $XSOCK:$XSOCK -v $XAUTH:$XAUTH -e XAUTHORITY=$XAUTH --net host majoyce2/ph2_acf_gui_user:v4-14 +fi + + +#docker run --rm -ti $mydevices -v ${PWD}:${PWD} -v ${PWD}/icicle/icicle:/home/cmsTkUser/Ph2_ACF_GUI/icicle/icicle:ro -v ${PWD}/Gui/siteConfig.py:/home/cmsTkUser/Ph2_ACF_GUI/Gui/siteSettings.py -v ${PWD}/Ph2_ACF/test:/home/cmsTkUser/Ph2_ACF_GUI/Ph2_ACF/test -v ${PWD}/data:/home/cmsTkUser/Ph2_ACF_GUI/data -v ${PWD}/Gui/QtGUIutils/:/home/cmsTkUser/Ph2_ACF_GUI/Gui/QtGUIutils/ -v ${PWD}/Gui/GUIutils/:/home/cmsTkUser/Ph2_ACF_GUI/Gui/GUIutils/ -v ${PWD}/Gui/python/:/home/cmsTkUser/Ph2_ACF_GUI/Gui/python/ -w $PWD -e DISPLAY=$DISPLAY -v $XSOCK:$XSOCK -v $XAUTH:$XAUTH -e XAUTHORITY=$XAUTH --net host local/testimage From 599e533c5415cdd11f5cb1888258c670aab8e1aa Mon Sep 17 00:00:00 2001 From: Ryan De Los Santos Date: Tue, 30 Jan 2024 11:35:13 -0500 Subject: [PATCH 4/7] Fix import statements --- Gui/QtGUIutils/PeltierCoolingApp.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Gui/QtGUIutils/PeltierCoolingApp.py b/Gui/QtGUIutils/PeltierCoolingApp.py index 6e71e808..8e1ea392 100644 --- a/Gui/QtGUIutils/PeltierCoolingApp.py +++ b/Gui/QtGUIutils/PeltierCoolingApp.py @@ -1,8 +1,9 @@ from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtWidgets import QWidget, QMessageBox -from PyQt5.QtCore import * -from Gui.python.Peltier import * -from Gui.siteSettings import * +from PyQt5.QtCore import pyqtSignal, QTimer + +from Gui.python.Peltier import PeltierSignalGenerator +import Gui.siteSettings as settings import time import os @@ -255,7 +256,10 @@ def setTemp(self)-> None: ["0", "0", "0", "0", "0", "0", "0", "0"], ) ) - message = self.convertSetTempListToValue(message) + try: + message = self.convertSetTempListToValue(message) + except Exception as e: + logger.warn(f"Failed to send message due to error: {e}") self.setTempSignal.emit(message) @@ -342,7 +346,7 @@ def controllerMonitoring2(self): return def tempLimit(self, temp): - if temp >= defaultPeltierMaxTemp and self.emergencySwitch == False: + if temp >= settings.defaultPeltierMaxTemp and self.emergencySwitch == False: print("Temperature too high") self.haltSig = True self.urgentSignal.emit(self.haltSig) @@ -351,7 +355,7 @@ def tempLimit(self, temp): pass def tempDiff(self): - if abs(self.t2-self.t1) > defaultPeltierMaxTempDiff and self.emergencySwitch == False: + if abs(self.t2-self.t1) > settings.defaultPeltierMaxTempDiff and self.emergencySwitch == False: print("Temp difference too big") self.haltSig = True self.urgentSignal.emit(self.haltSig) From 01a04b3a45e19d5bdede029f2b14157ca9dca670 Mon Sep 17 00:00:00 2001 From: Ryan De Los Santos Date: Tue, 30 Jan 2024 13:25:34 -0500 Subject: [PATCH 5/7] Fixed import and added debug statements --- Gui/QtGUIutils/PeltierCoolingApp.py | 32 ++++++++----------- Gui/QtGUIutils/QtApplication.py | 48 +++++++++++++++++++---------- 2 files changed, 44 insertions(+), 36 deletions(-) diff --git a/Gui/QtGUIutils/PeltierCoolingApp.py b/Gui/QtGUIutils/PeltierCoolingApp.py index 8e1ea392..6bbb729a 100644 --- a/Gui/QtGUIutils/PeltierCoolingApp.py +++ b/Gui/QtGUIutils/PeltierCoolingApp.py @@ -1,6 +1,6 @@ from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtWidgets import QWidget, QMessageBox -from PyQt5.QtCore import pyqtSignal, QTimer +from PyQt5.QtCore import pyqtSignal, QTimer, Qt from Gui.python.Peltier import PeltierSignalGenerator import Gui.siteSettings as settings @@ -91,23 +91,6 @@ def setupUi(self): self.polarityButton.clicked.connect(self.polarityToggle) self.gridLayout.addWidget(self.polarityButton, 2, 1, 1, 1) - self.powerStatus = QtWidgets.QLabel(self) - self.powerStatusLabel = QtWidgets.QLabel("Power Status of Peltier: ", self) - self.powerButton = QtWidgets.QPushButton("Peltier Power On/Off") - self.powerButton.setEnabled(False) - self.powerButton.clicked.connect(self.powerToggle) - self.gridLayout.addWidget(self.powerButton, 0, 2, 1, 1) - self.gridLayout.addWidget(self.powerStatusLabel, 1, 2, 1, 1) - - self.image = QtGui.QPixmap() - redledimage = QtGui.QImage(self.Ph2ACFDirectory + "/Gui/icons/led-red-on.png").scaled(QtCore.QSize(60,10), Qt.KeepAspectRatio, Qt.SmoothTransformation) - self.redledpixmap = QtGui.QPixmap.fromImage(redledimage) - greenledimage = QtGui.QImage(self.Ph2ACFDirectory + "/Gui/icons/green-led-on.png" ).scaled(QtCore.QSize(60,10), Qt.KeepAspectRatio, Qt.SmoothTransformation) - self.greenledpixmap = QtGui.QPixmap.fromImage(greenledimage) - self.powerStatus.setPixmap(self.redledpixmap) # The power status will initially always show that it's off, if it's actually on the status will be update in 0.5 seconds. - self.gridLayout.addWidget(self.powerStatus, 1, 3, 1, 1) - - self.setLayout(self.gridLayout) def setup(self): @@ -347,7 +330,7 @@ def controllerMonitoring2(self): def tempLimit(self, temp): if temp >= settings.defaultPeltierMaxTemp and self.emergencySwitch == False: - print("Temperature too high") + logger.warn("Temperature is too high! Shutting down test!") self.haltSig = True self.urgentSignal.emit(self.haltSig) self.emergencySwitch = True @@ -356,7 +339,16 @@ def tempLimit(self, temp): def tempDiff(self): if abs(self.t2-self.t1) > settings.defaultPeltierMaxTempDiff and self.emergencySwitch == False: - print("Temp difference too big") + + logger.warn( + """ + Temperature difference too high between thermistors, + there is probably a runaway heating issue. + Ensure that peltier plate is sufficiently + cooled. Shutting down test! + """ + ) + self.haltSig = True self.urgentSignal.emit(self.haltSig) self.emergencySwitch = True diff --git a/Gui/QtGUIutils/QtApplication.py b/Gui/QtGUIutils/QtApplication.py index febd8015..4f081492 100644 --- a/Gui/QtGUIutils/QtApplication.py +++ b/Gui/QtGUIutils/QtApplication.py @@ -18,7 +18,6 @@ QMessageBox, ) - import sys import os import pyvisa @@ -350,24 +349,34 @@ def checkLogin(self): self.TryHostAddress, self.TryDatabase, ) + logger.debug("Attempted to connect to database") if isActive(self.connection): + logger.debug("Database connection active") self.destroyLogin() if self.expertMode: + logger.debug("About to create expert window") self.createMain() else: + logger.debug("About to create simplified window") self.createSimplifiedMain() + logger.debug("Running checkFirmware()") self.checkFirmware() + else: + logger.error("Database connection failed") else: self.connection = "Offline" self.destroyLogin() + if self.expertMode: + logger.debug("Launching expert mode offline") self.createMain() + logger.debug("About to checkFirmware") self.checkFirmware() else: + logger.debug("Launching simplified mode offline") self.createSimplifiedMain() - # self.checkFirmware() except Exception as err: print("Failed to connect the database: {}".format(repr(err))) @@ -417,6 +426,7 @@ def createMain(self): BeBoard.setIPAddress(site_settings.FC7List[firmwareName]) BeBoard.setFPGAConfig(settings.FPGAConfigList[firmwareName]) self.FwDict[firmwareName] = BeBoard + logger.debug("Added FC7 to dictionary") except Exception as err: print("Failed to list the firmware: {}".format(repr(err))) @@ -470,7 +480,7 @@ def createMain(self): lambda state, x="{0}".format(index - 1): self.showLogFw(x) ) StatusLayout.addWidget(LogButton, index, 6, 1, 1) - + logger.debug("Added widgets to expert window") if self.FwUnderUsed != "": index = self.getIndex(self.FwUnderUsed, self.StatusList) self.occupyFw("{0}".format(index)) @@ -580,6 +590,7 @@ def createMain(self): self.LVPowerLayout.addStretch(1) self.LVPowerGroup.setLayout(self.LVPowerLayout) + logger.debug("Setup LV and HV") self.relay_group = QGroupBox("Relay Box") self.relay_group.setDisabled(True) @@ -619,7 +630,7 @@ def createMain(self): relay_layout.addWidget(self.relay_model_status) relay_layout.addStretch(1) self.relay_group.setLayout(relay_layout) - + logger.debug("Setup Relay") self.multimeter_group = QGroupBox("Multimeter") self.multimeter_group.setDisabled(True) multimeter_layout = QHBoxLayout() @@ -660,13 +671,13 @@ def createMain(self): multimeter_layout.addWidget(self.multimeter_status) multimeter_layout.addStretch(1) self.multimeter_group.setLayout(multimeter_layout) - + logger.debug("Setup Multimeter widgets") self.ArduinoGroup = ArduinoWidget() self.ArduinoGroup.stop.connect(self.GlobalStop) self.ArduinoControl = QCheckBox("Use arduino monitoring") self.ArduinoControl.setChecked(True) self.ArduinoControl.toggled.connect(self.switchArduinoPanel) - + logger.debug("Setup Arduino Widgets") self.MainOption = QGroupBox("Main") kMinimumWidth = 120 @@ -683,7 +694,7 @@ def createMain(self): self.SummaryButton.setMaximumHeight(kMaximumHeight) self.SummaryButton.clicked.connect(self.openSummaryWindow) SummaryLabel = QLabel("Statistics of test status") - + logger.debug("Setup Summary widgets") self.NewTestButton = QPushButton("&New") self.NewTestButton.setDefault(True) self.NewTestButton.setMinimumWidth(kMinimumWidth) @@ -697,7 +708,7 @@ def createMain(self): if self.ProcessingTest == True: self.NewTestButton.setDisabled(True) NewTestLabel = QLabel("Open new test") - + logger.debug("Setup New test button") self.NewProductionTestButton = QPushButton("&Production Test") self.NewProductionTestButton.setMinimumWidth(kMinimumWidth) self.NewProductionTestButton.setMaximumWidth(kMaximumWidth) @@ -708,7 +719,7 @@ def createMain(self): ) # FIXME This is to temporarily disable the test until LV can be added. self.NewProductionTestButton.clicked.connect(self.openNewProductionTest) NewProductionTestLabel = QLabel("Open production test") - + logger.debug("Setup NewProductionTest Widgets") self.ReviewButton = QPushButton("&Review") self.ReviewButton.setMinimumWidth(kMinimumWidth) self.ReviewButton.setMaximumWidth(kMaximumWidth) @@ -716,7 +727,7 @@ def createMain(self): self.ReviewButton.setMaximumHeight(kMaximumHeight) self.ReviewButton.clicked.connect(self.openReviewWindow) ReviewLabel = QLabel("Review all results") - + logger.debug("Setup ReviewButton widget") self.ReviewModuleButton = QPushButton("&Show Module") self.ReviewModuleButton.setMinimumWidth(kMinimumWidth) self.ReviewModuleButton.setMaximumWidth(kMaximumWidth) @@ -726,13 +737,14 @@ def createMain(self): self.ReviewModuleEdit = QLineEdit("") self.ReviewModuleEdit.setEchoMode(QLineEdit.Normal) self.ReviewModuleEdit.setPlaceholderText("Enter Module ID") - + logger.debug("Setup ReviewModuleEdit") self.PeltierCooling = Peltier(100) + logger.debug("Instantiate Peltier") self.PeltierBox = QGroupBox("Peltier Controller", self) self.PeltierLayout = QGridLayout() self.PeltierLayout.addWidget(self.PeltierCooling) self.PeltierBox.setLayout(self.PeltierLayout) - + logger.debug("Setup Peltier widget") layout = QGridLayout() layout.addWidget(self.NewTestButton, 0, 0, 1, 1) layout.addWidget(NewTestLabel, 0, 1, 1, 2) @@ -744,7 +756,7 @@ def createMain(self): layout.addWidget(ReviewLabel, 3, 1, 1, 2) layout.addWidget(self.ReviewModuleButton, 4, 0, 1, 1) layout.addWidget(self.ReviewModuleEdit, 4, 1, 1, 2) - + logger.debug("Added all widgets to layout") #################################################### # Functions for expert mode #################################################### @@ -760,6 +772,7 @@ def createMain(self): DBConsoleLabel = QLabel("Console for database") layout.addWidget(self.DBConsoleButton, 5, 0, 1, 1) layout.addWidget(DBConsoleLabel, 5, 1, 1, 2) + logger.debug("Added expert-only widgets") #################################################### # Functions for expert mode (END) @@ -790,6 +803,7 @@ def createMain(self): self.RefreshButton.clicked.connect(self.update) self.RefreshButton.clicked.connect(self.setDefault) + logger.debug("Setup Refresh button") self.LogoutButton = QPushButton("&Logout") # Fixme: more conditions to be added if self.ProcessingTest: @@ -797,7 +811,7 @@ def createMain(self): self.LogoutButton.clicked.connect(self.destroyMain) self.LogoutButton.clicked.connect(self.setLoginUI) self.LogoutButton.clicked.connect(self.createLogin) - + logger.debug("Setup Logout buttons") self.ExitButton = QPushButton("&Exit") # Fixme: more conditions to be added if self.ProcessingTest: @@ -828,9 +842,10 @@ def createMain(self): self.mainLayout.addWidget(self.PeltierBox, 12, 1, 1, 1) self.mainLayout.addWidget(self.AppOption, 13, 1, 1, 1) self.mainLayout.addWidget(self.LogoGroupBox, 13, 0, 1, 1) - + logger.debug("Setup mainLayout") + self.setDefault() - + logger.debug("Ran setDefault") # create a dictionary to easily disable groupboxes later self.groupbox_mapping = { "hv": self.HVPowerGroup, @@ -839,6 +854,7 @@ def createMain(self): "multimeter": self.multimeter_group, } + def setDefault(self): if self.expertMode is False: self.HVPowerGroup.setDisabled(True) From 2155ac724360375e6b1bd281884f1c033e9da72b Mon Sep 17 00:00:00 2001 From: Ryan De Los Santos Date: Tue, 30 Jan 2024 13:57:24 -0500 Subject: [PATCH 6/7] Added flag to enable dual temperature monitoring --- Gui/QtGUIutils/PeltierCoolingApp.py | 29 ++++++++++++++++------------- Gui/siteConfig.py | 1 + 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Gui/QtGUIutils/PeltierCoolingApp.py b/Gui/QtGUIutils/PeltierCoolingApp.py index 6bbb729a..f5e5a0e6 100644 --- a/Gui/QtGUIutils/PeltierCoolingApp.py +++ b/Gui/QtGUIutils/PeltierCoolingApp.py @@ -71,8 +71,6 @@ def setupUi(self): self.currentTempDisplay = QtWidgets.QLCDNumber(self) self.gridLayout.addWidget(self.currentTempDisplay, 4, 0, 1, 1) - self.currentTempDisplay2 = QtWidgets.QLCDNumber(self) - self.gridLayout.addWidget(self.currentTempDisplay2, 4, 0, 1, 2) self.setTempButton = QtWidgets.QPushButton("Set Temperature", self) self.setTempButton.setEnabled(False) @@ -83,14 +81,18 @@ def setupUi(self): self.setTempInput.setRange(-50, 50) self.gridLayout.addWidget(self.setTempInput, 2, 0, 1, 1) - self.currentTempLabel2 = QtWidgets.QLabel(self) - self.gridLayout.addWidget(self.currentTempLabel2, 4, 1, 1, 1) self.polarityButton = QtWidgets.QPushButton("Change Polarity", self) self.polarityButton.setEnabled(False) self.polarityButton.clicked.connect(self.polarityToggle) self.gridLayout.addWidget(self.polarityButton, 2, 1, 1, 1) + if settings.dualTempReading: + self.currentTempDisplay2 = QtWidgets.QLCDNumber(self) + self.gridLayout.addWidget(self.currentTempDisplay2, 4, 0, 1, 2) + self.currentTempLabel2 = QtWidgets.QLabel(self) + self.gridLayout.addWidget(self.currentTempLabel2, 4, 1, 1, 1) + self.setLayout(self.gridLayout) def setup(self): @@ -140,11 +142,12 @@ def setup(self): # Create QTimer that will call functions self.timer = QTimer() self.timer.timeout.connect(self.controllerMonitoring) - self.timer.timeout.connect(self.controllerMonitoring2) self.tempReading.connect(lambda temp: self.currentTempDisplay.display(temp)) - self.tempReading2.connect( - lambda temp: self.currentTempDisplay2.display(temp) - ) + if settings.dualTempReading: + self.tempReading2.connect( + lambda temp: self.currentTempDisplay2.display(temp) + ) + self.timer.timeout.connect(self.controllerMonitoring2) self.powerReading.connect(lambda power: self.setPowerStatus(power)) self.timer.start(500) # Perform monitoring functions every 500ms @@ -166,7 +169,7 @@ def setPowerStatus(self, power): self.powerStatus.setPixmap(self.redledpixmap) self.powerStatusValue = 0 else: - print("Unkown power status") + logger.error("Unkown power status") def powerToggle(self): if self.powerStatusValue == 0: @@ -183,7 +186,7 @@ def powerToggle(self): try: self.pelt.sendCommand(self.pelt.createCommand('Power On/Off Write', ['0','0','0','0','0','0','0','1'])) except Exception as e: - print("Could not turn on controller due to error: ", e) + logger.error("Could not turn on controller due to error: ", e) elif self.powerStatusValue == 1: try: self.pelt.sendCommand( @@ -192,7 +195,7 @@ def powerToggle(self): ) ) except Exception as e: - print("Could not turn off controller due to error: " , e) + logger.error("Could not turn off controller due to error: " , e) def setPolarityStatus(self, polarity): if polarity[8] == "0": @@ -202,7 +205,7 @@ def setPolarityStatus(self, polarity): self.polarityValue = "HEAT WP2+ and WP1-" self.polarityButton.setText(self.polarityValue) else: - print("Unexpected value sent back from polarity change function") + logger.error("Unexpected value sent back from polarity change function") def polarityToggle(self): if self.polarityValue == "HEAT WP1+ and WP2-": @@ -222,7 +225,7 @@ def polarityToggle(self): ) self.polarityButton.setText( self.polarityValue - ) # FIXME Probably a better idea to read polarity from controller + ) def setTemp(self)-> None: try: diff --git a/Gui/siteConfig.py b/Gui/siteConfig.py index eef4a3fd..2979b571 100644 --- a/Gui/siteConfig.py +++ b/Gui/siteConfig.py @@ -133,3 +133,4 @@ defaultPeltierBaud = 9600 defaultPeltierSetTemp = 20 defaultPeltierWarningTemp = 40 +dualTempReading = True From f978aed3479110ab1185191fb4134509333c18f4 Mon Sep 17 00:00:00 2001 From: Ryan De Los Santos Date: Tue, 30 Jan 2024 13:57:57 -0500 Subject: [PATCH 7/7] Add dual temp monitoring variable to settings template --- Gui/siteSettings_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gui/siteSettings_template.py b/Gui/siteSettings_template.py index 48cdda1d..a1c3dd23 100644 --- a/Gui/siteSettings_template.py +++ b/Gui/siteSettings_template.py @@ -141,4 +141,4 @@ #defaultPeltierWarningTemp = 40 defaultPeltierMaxTemp = 30 defaultPeltierMaxTempDiff = 5 - +dualTempReading = False