Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestCombo updates when Serial number is changed #317

Open
wants to merge 2 commits into
base: DEV
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions Gui/QtGUIutils/LaudaApp.py
Original file line number Diff line number Diff line change
@@ -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_())
42 changes: 30 additions & 12 deletions Gui/QtGUIutils/QtApplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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



Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -798,7 +803,7 @@ def createMain(self):
####################################################
# Functions for expert mode (END)
####################################################

self.MainOption.setLayout(layout)

self.AppOption = QGroupBox()
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -1202,7 +1220,7 @@ def goExpert(self):
self.destroyMain()
self.createMain()
self.checkFirmware()

###############################################################
## Global stop signal
###############################################################
Expand Down
26 changes: 23 additions & 3 deletions Gui/QtGUIutils/QtStartWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 *
Expand Down Expand Up @@ -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")
Expand All @@ -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)
Expand Down Expand Up @@ -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()

19 changes: 11 additions & 8 deletions Gui/python/CustomizedWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down