From e369990086d468a57f076db8fbcc0439416e445f Mon Sep 17 00:00:00 2001 From: mjoyce Date: Tue, 15 Oct 2024 16:06:10 -0400 Subject: [PATCH 1/2] Adding Lauda chiller to GUI --- Gui/QtGUIutils/LaudaApp.py | 91 +++++++++++++++++++++++++++++++++ Gui/QtGUIutils/QtApplication.py | 42 ++++++++++----- 2 files changed, 121 insertions(+), 12 deletions(-) create mode 100644 Gui/QtGUIutils/LaudaApp.py diff --git a/Gui/QtGUIutils/LaudaApp.py b/Gui/QtGUIutils/LaudaApp.py new file mode 100644 index 0000000..a058a03 --- /dev/null +++ b/Gui/QtGUIutils/LaudaApp.py @@ -0,0 +1,91 @@ +from PyQt5 import QtWidgets +from PyQt5.QtWidgets import QWidget +import Gui.siteSettings as site_settings +from icicle.icicle.lauda import Lauda +import os + + +class LaudaWidget(QWidget): + + def __init__(self, dimension): + + self.myLauda = Lauda(resource=site_settings.lauda_resource) + + super(LaudaWidget, self).__init__() + self.Ph2ACFDirectory = os.getenv("GUI_dir") + self.setupUi() + self.show() + + def setupUi(self): + kMinimumWidth = 150 + kMaximumWidth = 150 + kMinimumHeight = 30 + kMaximumHeight = 100 + + self.StartChillerButton = QtWidgets.QPushButton("Start") + self.StartChillerButton.setMinimumWidth(kMinimumWidth) + self.StartChillerButton.setMaximumWidth(kMaximumWidth) + self.StartChillerButton.setMinimumHeight(kMinimumHeight) + self.StartChillerButton.setMaximumHeight(kMaximumHeight) + self.StartChillerButton.clicked.connect(self.startChiller) + self.StartChillerButton.setCheckable(True) + + self.StopChillerButton = QtWidgets.QPushButton("Stop") + self.StopChillerButton.setMinimumWidth(kMinimumWidth) + self.StopChillerButton.setMaximumWidth(kMaximumWidth) + self.StopChillerButton.setMinimumHeight(kMinimumHeight) + self.StopChillerButton.setMaximumHeight(kMaximumHeight) + self.StopChillerButton.clicked.connect(self.stopChiller) + self.StopChillerButton.setCheckable(True) + + self.SetTempButton = QtWidgets.QPushButton("Set Temperature") + self.SetTempButton.setMinimumWidth(kMinimumWidth) + self.SetTempButton.setMaximumWidth(kMaximumWidth) + self.SetTempButton.setMinimumHeight(kMinimumHeight) + self.SetTempButton.setMaximumHeight(kMaximumHeight) + self.SetTempButton.clicked.connect(self.setTemperature) + self.SetTempButton.setCheckable(True) + + self.SetTempEdit = QtWidgets.QLineEdit("") + self.SetTempEdit.setMinimumWidth(140) + self.SetTempEdit.setEchoMode(QtWidgets.QLineEdit.Normal) + self.SetTempEdit.setPlaceholderText("Set Temperature") + self.SetTempEdit.textChanged.connect(lambda : self.SetTempButton.setChecked(False)) + + self.ChillerLayout = QtWidgets.QGridLayout(self) + self.ChillerLayout.addWidget(self.StartChillerButton, 0, 0, 1, 1) + self.ChillerLayout.addWidget(self.StopChillerButton,1,0,1,1) + self.ChillerLayout.addWidget(self.SetTempButton,2,0,1,1) + self.ChillerLayout.addWidget(self.SetTempEdit,2,1,1,2) + + self.setLayout(self.ChillerLayout) + + def resourceExists(self): + return False if self.lauda_resource == None else True + + def startChiller(self): + self.StartChillerButton.setChecked(True) + self.StopChillerButton.setChecked(False) + + self.myLauda.set("START","START") + + def stopChiller(self): + self.StartChillerButton.setChecked(False) + self.StopChillerButton.setChecked(True) + + self.myLauda.set("STOP", "STOP") + + def setTemperature(self): + self.SetTempButton.setChecked(True) + + try: + self.myLauda.set("TEMPERATURE_TARGET",float(self.setTempEdit.text())) + except ValueError: + print("Temperature target must be a float.") + +if __name__ == "__main__": + import sys + + app = QtWidgets.QApplication(sys.argv) + ui = LaudaWidget(500) + sys.exit(app.exec_()) diff --git a/Gui/QtGUIutils/QtApplication.py b/Gui/QtGUIutils/QtApplication.py index 79afa0b..c626287 100644 --- a/Gui/QtGUIutils/QtApplication.py +++ b/Gui/QtGUIutils/QtApplication.py @@ -32,6 +32,7 @@ import Gui.siteSettings as site_settings from Gui.GUIutils.FirmwareUtil import fwStatusParser, FwStatusCheck from Gui.GUIutils.guiUtils import isActive +from Gui.QtGUIutils.LaudaApp import LaudaWidget from Gui.QtGUIutils.PeltierCoolingApp import Peltier from Gui.QtGUIutils.QtFwCheckWindow import QtFwCheckWindow from Gui.QtGUIutils.QtFwStatusWindow import QtFwStatusWindow @@ -46,7 +47,7 @@ from Gui.python.ArduinoWidget import ArduinoWidget from Gui.python.SimplifiedMainWidget import SimplifiedMainWidget # from icicle.icicle.instrument_cluster import BadStatusForOperationError, InstrumentCluster -from icicle.icicle.multiment_cluster import InstrumentCluster +from icicle.icicle.instrument_cluster import InstrumentCluster @@ -705,7 +706,7 @@ def createMain(self): kMaximumWidth = 150 kMinimumHeight = 30 kMaximumHeight = 100 - + self.SummaryButton = QPushButton("&Status summary") if not self.expertMode: self.SummaryButton.setDisabled(True) @@ -777,6 +778,10 @@ def createMain(self): layout.addWidget(ReviewLabel, 2, 1, 1, 2) layout.addWidget(self.ReviewModuleButton, 3, 0, 1, 1) layout.addWidget(self.ReviewModuleEdit, 3, 1, 1, 2) + + self.ChillerOption = QGroupBox("Chiller", self) + self.ChillerLayout = QGridLayout() + self.ChillerOption.setLayout(self.ChillerLayout) #################################################### # Functions for expert mode @@ -798,7 +803,7 @@ def createMain(self): #################################################### # Functions for expert mode (END) #################################################### - + self.MainOption.setLayout(layout) self.AppOption = QGroupBox() @@ -851,17 +856,28 @@ def createMain(self): #self.mainLayout.addWidget(self.HVPowerRemoteControl, 2, 0, 1, 1) self.mainLayout.addWidget(self.HVPowerGroup, 2, 0, 1, 1) #self.mainLayout.addWidget(self.LVPowerRemoteControl, 2, 1, 1, 1) - self.mainLayout.addWidget(self.LVPowerGroup, 2, 1, 1, 1) + self.mainLayout.addWidget(self.LVPowerGroup, 2, 1, 1, 3) #self.mainLayout.addWidget(self.relay_remote_control, 4, 0, 1, 1) self.mainLayout.addWidget(self.relay_group, 3, 0, 1, 1) #self.mainLayout.addWidget(self.multimeter_remote_control, 4, 1, 1, 1) - self.mainLayout.addWidget(self.multimeter_group, 3, 1, 1, 1) - self.mainLayout.addWidget(self.ArduinoGroup, 5, 1, 1, 1) - self.mainLayout.addWidget(self.ArduinoControl, 4, 1, 1, 1) - self.mainLayout.addWidget(self.MainOption, 0, 1, 2, 1) - self.mainLayout.addWidget(self.PeltierBox, 4, 0, 4, 1) - self.mainLayout.addWidget(self.AppOption, 6, 1, 1, 1) - self.mainLayout.addWidget(self.LogoGroupBox, 7, 1, 1, 1) + self.mainLayout.addWidget(self.multimeter_group, 3, 1, 1, 3) + self.mainLayout.addWidget(self.MainOption, 0, 1, 2, 3) + self.mainLayout.addWidget(self.PeltierBox, 4, 0, 3, 1) + self.mainLayout.addWidget(self.LogoGroupBox, 7, 0, 1, 4) + + # Placing in try/except to avoid needing to change siteConfig + try: + self.MyLauda = LaudaWidget(100) + self.ChillerLayout.addWidget(self.MyLauda) + + self.mainLayout.addWidget(self.ChillerOption, 4, 1, 3, 2) + self.mainLayout.addWidget(self.ArduinoControl, 4, 3, 1, 1) + self.mainLayout.addWidget(self.ArduinoGroup, 5, 3, 1, 2) + self.mainLayout.addWidget(self.AppOption, 6, 3, 1, 1) + except AttributeError: + self.mainLayout.addWidget(self.ArduinoControl, 4, 1, 1, 3) + self.mainLayout.addWidget(self.ArduinoGroup, 5, 1, 1, 3) + self.mainLayout.addWidget(self.AppOption, 6, 1, 1, 3) self.setDefault() @@ -1001,6 +1017,7 @@ def destroyMain(self): self.ArduinoControl.deleteLater() self.PeltierBox.deleteLater() self.MainOption.deleteLater() + self.ChillerOption.deleteLater() self.AppOption.deleteLater() self.LogoGroupBox.deleteLater() self.mainLayout.removeWidget(self.FirmwareStatus) @@ -1017,6 +1034,7 @@ def destroyMain(self): self.mainLayout.removeWidget(self.ArduinoControl) self.mainLayout.removeWidget(self.PeltierBox) self.mainLayout.removeWidget(self.MainOption) + self.mainLayout.removeWidget(self.ChillerOption) self.mainLayout.removeWidget(self.AppOption) self.mainLayout.removeWidget(self.LogoGroupBox) QApplication.closeAllWindows() @@ -1202,7 +1220,7 @@ def goExpert(self): self.destroyMain() self.createMain() self.checkFirmware() - + ############################################################### ## Global stop signal ############################################################### From c6d26a00ba2a6c1cfb86f80a0c3465ad362c0ee7 Mon Sep 17 00:00:00 2001 From: mjoyce Date: Mon, 28 Oct 2024 15:50:28 -0400 Subject: [PATCH 2/2] TestCombo updates when Serial number is changed --- Gui/QtGUIutils/QtStartWindow.py | 26 +++++++++++++++++++++++--- Gui/python/CustomizedWidget.py | 19 +++++++++++-------- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/Gui/QtGUIutils/QtStartWindow.py b/Gui/QtGUIutils/QtStartWindow.py index 56f1093..bca5bf9 100644 --- a/Gui/QtGUIutils/QtStartWindow.py +++ b/Gui/QtGUIutils/QtStartWindow.py @@ -52,7 +52,7 @@ from Gui.QtGUIutils.QtRunWindow import QtRunWindow from Gui.QtGUIutils.QtFwCheckDetails import QtFwCheckDetails #from Gui.QtGUIutils.QtApplication import * -from Gui.python.CustomizedWidget import BeBoardBox +from Gui.python.CustomizedWidget import BeBoardBox, debounce #from Gui.python.Firmware import * #from Gui.GUIutils.DBConnection import * from Gui.GUIutils.FirmwareUtil import FEPowerUpVD @@ -62,7 +62,7 @@ ModuleCurrentMap, ) -from InnerTrackerTests.TestSequences import TestList +from InnerTrackerTests.TestSequences import TestDict from siteSettings import icicle_instrument_setup # from Gui.QtGUIutils.QtProductionTestWindow import * @@ -283,7 +283,8 @@ def createHead(self): TestLabel = QLabel("Test:") self.TestCombo = QComboBox() #self.TestList = getAllTests(self.master.connection) - self.TestList = TestList + self.TestList = TestDict["Default"] + if not self.master.instruments: if "AllScan" in self.TestList: self.TestList.remove("AllScan") @@ -304,6 +305,7 @@ def createHead(self): beboard.removeAllOpticalGroups() self.BeBoardWidget = BeBoardBox(self.master, self.firmware) # FLAG + self.BeBoardWidget.ModuleRow.SerialEdit.editingFinished.connect(self.createSerialUpdateCallback(self.BeBoardWidget)) self.mainLayout.addWidget(self.TestBox, 0, 0) self.mainLayout.addWidget(self.BeBoardWidget, 1, 0) @@ -501,3 +503,21 @@ def closeEvent(self, event): logger.error(e) else: event.ignore() + + def createSerialUpdateCallback(self, widget): + return lambda: self.onSerialNumberUpdate(widget) + + @debounce(500) + def onSerialNumberUpdate(self,widget): + data = widget.fetchModuleTypeDB(widget.ModuleRow.getSerialNumber()) + if data: + if self.TestCombo.isEnabled() and data['type'] in TestDict.keys(): + self.TestCombo.clear() + self.TestCombo.addItems(TestDict[data['type']]) + if widget.ModuleRow.TypeCombo.isEnabled(): + widget.ModuleRow.TypeCombo.setCurrentText(data['type']) + if widget.ModuleRow.VersionCombo.isEnabled(): + widget.ModuleRow.VersionCombo.setCurrentText(data['version']) + + widget.updateList() + diff --git a/Gui/python/CustomizedWidget.py b/Gui/python/CustomizedWidget.py index 2bf0199..a35702d 100644 --- a/Gui/python/CustomizedWidget.py +++ b/Gui/python/CustomizedWidget.py @@ -111,11 +111,12 @@ def createRow(self): def setType(self): - #this method is created to set moudle type under online mode and comboBox is hidden + #this method is created to set module type under online mode and comboBox is hidden if self.SerialEdit.text().startswith("RH"): chipType = "CROC 1x2" self.TypeCombo.setCurrentText(chipType) + if self.SerialEdit.text().startswith("SH"): chipType = "TFPX CROC Quad" self.TypeCombo.setCurrentText(chipType) @@ -443,6 +444,7 @@ def __init__(self, master, firmware): self.master = master self.firmware = firmware self.ModuleList = [] + self.ModuleRow = ModuleBox(self.firmware) self.ChipWidgetDict = {} self.mainLayout = QVBoxLayout() # Use QVBoxLayout for vertical layout @@ -466,11 +468,10 @@ def __init__(self, master, firmware): self.setMinimumSize(900, 300) # Set minimum size (width, height) def initList(self): - ModuleRow = ModuleBox(self.firmware) - self.ModuleList.append(ModuleRow) - ModuleRow.TypeCombo.currentTextChanged.connect(self.updateList) - ModuleRow.VersionCombo.currentTextChanged.connect(self.updateList) - ModuleRow.SerialEdit.editingFinished.connect(self.createSerialUpdateCallback(ModuleRow)) + self.ModuleList.append(self.ModuleRow) + self.ModuleRow.TypeCombo.currentTextChanged.connect(self.updateList) + self.ModuleRow.VersionCombo.currentTextChanged.connect(self.updateList) + #self.ModuleRow.SerialEdit.editingFinished.connect(self.createSerialUpdateCallback(self.ModuleRow)) def createList(self): self.ListLayout = QGridLayout() @@ -542,7 +543,9 @@ def updateList(self, *args): self.ListLayout.addWidget(newButton, len(self.ModuleList), 1, 1, 1) self.update() - def createSerialUpdateCallback(self, module): + #Put this functionality in QtStartWindow.py. Need to see if + #it affects simplified version. + '''def createSerialUpdateCallback(self, module): return lambda: self.onSerialNumberUpdate(module) @debounce(500) @@ -554,7 +557,7 @@ def onSerialNumberUpdate(self, module): if module.VersionCombo.isEnabled(): module.VersionCombo.setCurrentText(data['version']) - self.updateList() + self.updateList()''' def fetchModuleTypeDB(self, moduleName): if not self.master.purdue_connected: return None