Skip to content
Open
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
40 changes: 17 additions & 23 deletions gui/control_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@
import time
from typing import Dict, List, Optional
from pathlib import Path
import threading

from queue import Queue
import cv2
import numpy as np
import requests
from epics import PV
from PyMca5.PyMcaGui.physics.xrf.McaAdvancedFit import McaAdvancedFit
from PyMca5.PyMcaGui.pymca.McaWindow import McaWindow, ScanWindow
from PyMca5.PyMcaPhysics.xrf import Elements
from qt_epics.QtEpicsPVEntry import QtEpicsPVEntry
Expand All @@ -37,7 +33,6 @@
CRYOSTREAM_ONLINE,
HUTCH_TIMER_DELAY,
MINIMUM_RASTER_SIZE,
RASTER_GUI_XREC_FILL_DELAY,
SAMPLE_TIMER_DELAY,
SERVER_CHECK_DELAY,
SET_ENERGY_CHECK,
Expand Down Expand Up @@ -309,7 +304,15 @@ def parseXRFTable(self):


def closeEvent(self, evnt):
self.hutchCornerCamThread.stop()
self.hutchTopCamThread.stop()
self.hutchCornerCamThread.wait()
self.hutchTopCamThread.wait()
self.sampleCameraThread.stop()
self.sampleCameraThread.wait()
self.serverCheckThread.stop()
self.serverCheckThread.wait()
self.albulaInterface.close()
evnt.accept()
sys.exit() # doing this to close any windows left open

Expand Down Expand Up @@ -358,7 +361,6 @@ def createSampleTab(self):
functools.partial(self.dewarViewToggledCB, "dewarView")
)
hBoxRadioLayout1.addWidget(self.dewarViewRadio)
hBoxRadioLayout1.addWidget(self.priorityViewRadio)
self.viewRadioGroup.addButton(self.dewarViewRadio)
vBoxDFlayout.addLayout(hBoxRadioLayout1)
vBoxDFlayout.addWidget(self.dewarTree)
Expand Down Expand Up @@ -577,7 +579,7 @@ def createSampleTab(self):
self.beamsizeComboBox = QtWidgets.QComboBox(self)
self.beamsizeComboBox.addItems(beamSizeOptionList)
self.beamsizeComboBox.setCurrentIndex(current_index)
self.beamsizeComboBox.activated[str].connect(self.beamsizeComboActivatedCB)
self.beamsizeComboBox.currentTextChanged.connect(self.beamsizeComboActivatedCB)
if daq_utils.beamline == "amx" or self.energy_pv.get() < 9000:
self.beamsizeComboBox.setEnabled(False)
colEnergyLabel = QtWidgets.QLabel("Energy (eV):")
Expand Down Expand Up @@ -694,7 +696,7 @@ def createSampleTab(self):
protoOptionList = CollectionProtocols.get_beamline_options(daq_utils.beamline)
self.protoComboBox = QtWidgets.QComboBox(self)
self.protoComboBox.addItems(protoOptionList)
self.protoComboBox.activated[str].connect(self.protoComboActivatedCB)
self.protoComboBox.currentTextChanged.connect(self.protoComboActivatedCB)
hBoxColParams6.addWidget(protoLabel)
hBoxColParams6.addWidget(self.protoStandardRadio)
hBoxColParams6.addWidget(self.protoRasterRadio)
Expand Down Expand Up @@ -765,7 +767,7 @@ def createSampleTab(self):
self.rasterEvalComboBox.setCurrentIndex(
db_lib.beamlineInfo(daq_utils.beamline, "rasterScoreFlag")["index"]
)
self.rasterEvalComboBox.activated[str].connect(self.rasterEvalComboActivatedCB)
self.rasterEvalComboBox.currentTextChanged.connect(self.rasterEvalComboActivatedCB)
self.hBoxRasterLayout1.addWidget(rasterStepLabel)
self.hBoxRasterLayout1.addWidget(self.rasterStepEdit)
self.hBoxRasterLayout1.addWidget(self.rasterGrainCoarseRadio)
Expand Down Expand Up @@ -1252,6 +1254,8 @@ def createSampleTab(self):
focusMinusButton.clicked.connect(functools.partial(self.focusTweakCB, -5))
annealButton = QtWidgets.QPushButton("Anneal")
annealButton.clicked.connect(self.annealButtonCB)
if daq_utils.beamline == "amx":
annealButton.setEnabled(False)
annealTimeLabel = QtWidgets.QLabel("Time")
self.annealTime_ledit = QtWidgets.QLineEdit()
self.annealTime_ledit.setFixedWidth(40)
Expand Down Expand Up @@ -1285,6 +1289,7 @@ def createSampleTab(self):
hBoxSampleAlignLayout = QtWidgets.QHBoxLayout()
centerLoopButton = QtWidgets.QPushButton("Center\nLoop")
centerLoopButton.clicked.connect(self.autoCenterLoopCB)
centerLoopButton.hide()
measureButton = QtWidgets.QPushButton("Measure")
measureButton.clicked.connect(self.measurePolyCB)
loopShapeButton = QtWidgets.QPushButton("Add Raster\nto Queue")
Expand Down Expand Up @@ -1586,9 +1591,9 @@ def createSampleTab(self):
lambda frame: self.updateCam(self.pixmap_item_HutchTop, frame)
)
self.hutchTopCamThread.start()
serverCheckThread = ServerCheckThread(parent=self, delay=SERVER_CHECK_DELAY)
serverCheckThread.visit_dir_changed.connect(QApplication.instance().quit)
serverCheckThread.start()
self.serverCheckThread = ServerCheckThread(parent=self, delay=SERVER_CHECK_DELAY)
self.serverCheckThread.visit_dir_changed.connect(QApplication.instance().quit)
self.serverCheckThread.start()

def updateCam(self, pixmapItem: "QGraphicsPixmapItem", frame):
if pixmapItem == self.pixmap_item:
Expand Down Expand Up @@ -1671,7 +1676,6 @@ def vidActionToggledCB(self):
if self.protoComboBox.currentText() in (CollectionProtocols.RASTER,
CollectionProtocols.STEP_RASTER):
self.protoComboBox.setCurrentText(CollectionProtocols.STANDARD)
self.protoComboActivatedCB(CollectionProtocols.STANDARD)
self.showProtParams()

def adjustGraphics4ZoomChange(self, fov):
Expand Down Expand Up @@ -2380,7 +2384,6 @@ def processChoochResult(self, choochResultFlag):
self.choochF2PrimePeak.setText(str(choochResultObj["f2prime_peak"]))
self.choochResultFlag_pv.put("0")
self.protoComboBox.setCurrentText(CollectionProtocols.STANDARD)
self.protoComboActivatedCB(CollectionProtocols.STANDARD)
except TypeError as e:
logger.error(
"Chooch plotting failed - check whether scan had a strong signal or not: %s"
Expand Down Expand Up @@ -2627,13 +2630,10 @@ def validateFields(self, field_values_dict):
def protoRadioToggledCB(self, text):
if self.protoStandardRadio.isChecked():
self.protoComboBox.setCurrentText(CollectionProtocols.STANDARD)
self.protoComboActivatedCB(text)
elif self.protoRasterRadio.isChecked():
self.protoComboBox.setCurrentText(CollectionProtocols.RASTER)
self.protoComboActivatedCB(text)
elif self.protoVectorRadio.isChecked():
self.protoComboBox.setCurrentText(CollectionProtocols.VECTOR)
self.protoComboActivatedCB(text)
else:
pass

Expand Down Expand Up @@ -3270,7 +3270,6 @@ def takeRasterSnapshot(self, rasterReq):
reqID=rasterReq["uid"],
rasterHeatJpeg=jpegImageFilename,
)
self.send_to_server("insertRasterResult", [str(rasterReq["uid"]), str(visitName)])

def reFillPolyRaster(self):
rasterEvalOption = str(self.rasterEvalComboBox.currentText())
Expand Down Expand Up @@ -4730,7 +4729,6 @@ def mountSampleCB(self):
self.zoom2Radio.setChecked(True)
self.zoomLevelToggledCB("Zoom2")
self.protoComboBox.setCurrentText(CollectionProtocols.STANDARD)
self.protoComboActivatedCB(CollectionProtocols.STANDARD)

def unmountSampleCB(self):
logger.info("unmount sample")
Expand Down Expand Up @@ -5285,10 +5283,6 @@ def popStaffDialogCB(self):
self.popupServerMessage("You don't have control")

def closeAll(self):
self.hutchCornerCamThread.stop()
self.hutchTopCamThread.stop()
self.hutchCornerCamThread.wait()
self.hutchTopCamThread.wait()
QtWidgets.QApplication.instance().quit()

def initCallbacks(self):
Expand Down