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 736d210e4ee12468f0d68ed7a2ffcc875e319098 Mon Sep 17 00:00:00 2001 From: mjoyce Date: Wed, 30 Oct 2024 14:40:44 -0400 Subject: [PATCH 2/2] fixing instrumentcluster import --- Gui/python/SLDOScanHandler.py | 2 +- Gui/python/SimplifiedMainWidget.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gui/python/SLDOScanHandler.py b/Gui/python/SLDOScanHandler.py index 4e4d433..e09ecab 100644 --- a/Gui/python/SLDOScanHandler.py +++ b/Gui/python/SLDOScanHandler.py @@ -6,7 +6,7 @@ from Gui.python.logging_config import logger from icicle.icicle.adc_board import AdcBoard from icicle.icicle.relay_board import RelayBoard -from icicle.icicle.multiment_cluster import InstrumentNotInstantiated +from icicle.icicle.instrument_cluster import InstrumentNotInstantiated import numpy as np import matplotlib.pyplot as plt import time diff --git a/Gui/python/SimplifiedMainWidget.py b/Gui/python/SimplifiedMainWidget.py index 6a3780b..cb50e08 100644 --- a/Gui/python/SimplifiedMainWidget.py +++ b/Gui/python/SimplifiedMainWidget.py @@ -29,7 +29,7 @@ from Gui.python.Peltier import PeltierSignalGenerator from Gui.python.logging_config import logger import Gui.siteSettings as site_settings -from icicle.icicle.multiment_cluster import InstrumentCluster, InstrumentNotInstantiated +from icicle.icicle.instrument_cluster import InstrumentCluster, InstrumentNotInstantiated