Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b914294
Adding autocenter_lucid
NYSBC-Rudra May 16, 2024
5e9abbf
Update autocenter_lucid.py
NYSBC-Rudra May 16, 2024
48cd4f4
Update autocenter_lucid.py
NYSBC-Rudra May 16, 2024
acd5de0
Update control_main.py
NYSBC-Rudra May 20, 2024
021321e
Update control_main.py
NYSBC-Rudra May 20, 2024
1006f23
Update control_main.py
NYSBC-Rudra May 20, 2024
73f91ee
Update control_main.py
NYSBC-Rudra May 20, 2024
2061501
Update control_main.py
NYSBC-Rudra May 20, 2024
86b89a3
Update control_main.py
NYSBC-Rudra May 21, 2024
c1ee51e
Update control_main.py
NYSBC-Rudra May 21, 2024
385bbd3
Update control_main.py
NYSBC-Rudra May 21, 2024
35e0a34
Update control_main.py
NYSBC-Rudra May 21, 2024
0420ea9
Update control_main.py
NYSBC-Rudra May 21, 2024
559ff97
Update control_main.py
NYSBC-Rudra May 21, 2024
e346a16
Update control_main.py
NYSBC-Rudra May 21, 2024
9de5202
Update control_main.py
NYSBC-Rudra May 21, 2024
aea4645
trying QProcess async
NYSBC-Rudra May 21, 2024
cbc9314
Update control_main.py
NYSBC-Rudra May 21, 2024
96db2d4
Making popup seperate value
NYSBC-Rudra May 21, 2024
0cd3dde
Update control_main.py
NYSBC-Rudra May 21, 2024
410f709
Update process_monitor.py
NYSBC-Rudra May 21, 2024
4dede3c
Editing qpopupbox
NYSBC-Rudra May 21, 2024
e7f65a4
Update process_monitor.py
NYSBC-Rudra May 21, 2024
5d2e9f2
Update control_main.py
NYSBC-Rudra May 21, 2024
87a3bfd
fixing button removing autocenter_lucid
NYSBC-Rudra May 23, 2024
66dbeed
Update control_main.py
NYSBC-Rudra May 24, 2024
8be5cc3
adding function to get raster coordinates
NYSBC-Rudra May 24, 2024
52996f9
Update control_main.py
NYSBC-Rudra May 24, 2024
00c97f2
fixing resolution dialog
NYSBC-Rudra May 24, 2024
ae93a67
quick test
NYSBC-Rudra May 28, 2024
e47395a
fixing test function call
NYSBC-Rudra May 28, 2024
73e1878
no response from raster so adding the waitforfinished call
NYSBC-Rudra May 28, 2024
2e10da1
Update control_main.py
NYSBC-Rudra May 28, 2024
f016b5b
removed one connect from raster call
NYSBC-Rudra May 28, 2024
5dca6df
Update control_main.py
NYSBC-Rudra May 28, 2024
db93915
Update control_main.py
NYSBC-Rudra May 28, 2024
00d1fa2
fixing wait for finish
NYSBC-Rudra May 28, 2024
71d7fe7
Update control_main.py
NYSBC-Rudra May 28, 2024
49566a3
removing wait for finished on autocenter
NYSBC-Rudra May 28, 2024
36e5c20
more testing
NYSBC-Rudra May 28, 2024
452014d
returning to normal
NYSBC-Rudra May 28, 2024
f45c135
Update resolution_dialog.py
NYSBC-Rudra May 28, 2024
6ce03a9
Update resolution_dialog.py
NYSBC-Rudra May 28, 2024
fc59b78
restoring resolution diolog, will add later
NYSBC-Rudra May 28, 2024
c6612ae
Update control_main.py
NYSBC-Rudra Jun 5, 2024
4f4bcc7
Update control_main.py
NYSBC-Rudra Jun 11, 2024
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
86 changes: 81 additions & 5 deletions gui/control_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
from qt_epics.QtEpicsPVEntry import QtEpicsPVEntry
from qt_epics.QtEpicsPVLabel import QtEpicsPVLabel
from qtpy import QtCore, QtGui, QtWidgets
from qtpy.QtCore import QModelIndex, QRectF, Qt, QTimer
from qtpy.QtCore import QModelIndex, QRectF, Qt, QTimer, QProcess
from qtpy.QtGui import QIntValidator
from qtpy.QtWidgets import QCheckBox, QFrame, QGraphicsPixmapItem, QApplication
from qtpy.QtWidgets import QCheckBox, QFrame, QGraphicsPixmapItem, QApplication, QMessageBox
from devices import GonioDevice, CameraDevice, MD2Device, LightDevice, MD2ApertureDevice




import albulaUtils
import daq_utils
import db_lib
Expand Down Expand Up @@ -50,7 +53,8 @@
SnapCommentDialog,
StaffScreenDialog,
UserScreenDialog,
CalculatorWindow
CalculatorWindow,
ProcessPopup
)
from gui.raster import RasterCell, RasterGroup
from QPeriodicTable import QPeriodicTable
Expand Down Expand Up @@ -165,6 +169,7 @@ def __init__(self):
self.centerMarkerCharSize = 20
self.centerMarkerCharOffsetX = 12
self.centerMarkerCharOffsetY = 18
self.raster_output = None
self.currentRasterCellList = []
self.redPen = QtGui.QPen(QtCore.Qt.red)
self.bluePen = QtGui.QPen(QtCore.Qt.blue)
Expand Down Expand Up @@ -243,6 +248,7 @@ def __init__(self):
self.controlMasterCheckBox.setChecked(True)
self.XRFInfoDict = self.parseXRFTable() # I don't like this


def setGuiValues(self, values):
for item, value in values.items():
logger.info("resetting %s to %s" % (item, value))
Expand Down Expand Up @@ -1253,6 +1259,7 @@ def createSampleTab(self):
hBoxSampleAlignLayout = QtWidgets.QHBoxLayout()
centerLoopButton = QtWidgets.QPushButton("Center\nLoop")
centerLoopButton.clicked.connect(self.autoCenterLoopCB)
self.init_autocenter()
measureButton = QtWidgets.QPushButton("Measure")
measureButton.clicked.connect(self.measurePolyCB)
loopShapeButton = QtWidgets.QPushButton("Add Raster\nto Queue")
Expand Down Expand Up @@ -1503,7 +1510,8 @@ def createSampleTab(self):
self.dimpleCheckBox.setVisible(False)
self.centeringComboBox.setVisible(False)
annealButton.setVisible(False)
centerLoopButton.setVisible(False)
#unhiding center loop button
#centerLoopButton.setVisible(False)
clearGraphicsButton.setVisible(False)
saveCenteringButton.setVisible(False)
selectAllCenteringButton.setVisible(False)
Expand All @@ -1522,6 +1530,7 @@ def createSampleTab(self):
#self.captureLowMag.set(cv2.CAP_PROP_BUFFERSIZE, 1)
self.captureLowMag = daq_utils.lowMagCamURL
self.capture = self.captureLowMag


#self.sampleCameraThread = VideoThread(
# parent=self, delay=SAMPLE_TIMER_DELAY, camera_object=self.capture
Expand Down Expand Up @@ -3022,8 +3031,75 @@ def omegaTweakCB(self, tv):
self.popupServerMessage("You don't have control")

def autoCenterLoopCB(self):
if self.auto_center_ongoing == True:
self.popupServerMessage("Auto center is already running")
return
logger.info("auto center loop")
self.send_to_server("loop_center_xrec()")
autocenter_call = '/nsls2/data/nyx/legacy/Rudra/lsdcSpoofer/run_auto_center'
popup_info = ProcessPopup(parent = self, window_title='AutoCenter Info', main_text="Waiting for auto center, view detailed text for more info")

popup_info.setIcon(QMessageBox.Information)
x = popup_info.open()
self.autocenter_process = QProcess(parent=self)
self.autocenter_process.readyReadStandardOutput.connect(lambda: popup_info.setDetailedText(bytes(self.autocenter_process.readAllStandardOutput()).decode("utf8")))
self.autocenter_process.finished.connect(lambda: popup_info.setText("AUTO CENTERING FINISHED\n\nopen details for more information"))
self.autocenter_process.finished.connect(lambda: popup_info.setWindowTitle("Done"))
self.autocenter_process.finished.connect(self.close_autocenter)

self.autocenter_process.start(autocenter_call)
self.auto_center_ongoing = True




# with subprocess.Popen(autocenter_call, stdout=subprocess.PIPE, bufsize=1, universal_newlines=True) as p:
# for line in p.stdout:

# popup_info.setText(line + "")

# if p.returncode != 0:
# raise subprocess.CalledProcessError(p.returncode, p.args)

def init_autocenter(self):
self.autocenter_process = QProcess(parent=self)
pythondir = '/opt/conda_envs/lsdc-gui-2023-2-latest/bin/python3'
autocenter_call = '/nsls2/data/nyx/legacy/Rudra/lsdcSpoofer/autocenter_lucid.py'
self.autocenter_process.finished.connect(self.close_autocenter)
self.autocenter_process.start('{} {}'.format(pythondir, autocenter_call))
self.auto_center_ongoing = True

def close_autocenter(self):
self.auto_center_ongoing = False
self.autocenter_process.close()


def handle_raster_output(self, data):
self.raster_output = data





def get_raster_coords(self):
logger.info("getting raster coordinates")
raster_call = '/nsls2/data/nyx/legacy/Rudra/lsdcSpoofer/get_raster_box'
self.raster_output = None
self.raster_process = QProcess(parent=self)

self.raster_process.finished.connect(lambda: self.handle_raster_output(self.raster_process.readAllStandardOutput().data().decode('utf-8')))
#self.raster_process.finished.connect(lambda: self.raster_process.close())
self.raster_process.start(raster_call)
self.raster_process.waitForFinished()
return self.raster_output










def autoRasterLoopCB(self):
self.selectedSampleID = self.selectedSampleRequest["sample"]
Expand Down
1 change: 1 addition & 0 deletions gui/dialog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
from .screen_defaults import ScreenDefaultsDialog
from .resolution_calculator import Calculator
from .resolution_dialog import CalculatorWindow
from .process_monitor import ProcessPopup
24 changes: 24 additions & 0 deletions gui/dialog/process_monitor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import logging
import typing

from qtpy import QtCore, QtGui, QtWidgets
from qtpy.QtCore import Qt

import daq_utils
import db_lib

if typing.TYPE_CHECKING:
from lsdcGui import ControlMain

logger = logging.getLogger()

class ProcessPopup(QtWidgets.QMessageBox):
def __init__(self, parent: "ControlMain",window_title = 'Info', main_text = 'Waiting for somethign in GUI, open more details for more info', detailed_text = 'waiting'):
super(ProcessPopup, self).__init__(parent)
self.setWindowTitle(window_title)
self.setIcon(QtWidgets.QMessageBox.Question)
self.setText(main_text)
self.setDetailedText(detailed_text)