Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 29f63ccb75 | |||
| 71702f5f7a | |||
| fb623ee4fc | |||
| 44a113d85d | |||
| d0bc302915 |
126
base.py
126
base.py
@@ -5,7 +5,6 @@ from collections import OrderedDict
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import getpass
|
import getpass
|
||||||
import h5py
|
import h5py
|
||||||
import inspect
|
|
||||||
import logging
|
import logging
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import platform
|
import platform
|
||||||
@@ -58,6 +57,7 @@ CENTRAL_WIDGET_MINIMUM_WIDTH = 1240
|
|||||||
SLS_CENTRAL_WIDGET_MINIMUM_HEIGHT = 840
|
SLS_CENTRAL_WIDGET_MINIMUM_HEIGHT = 840
|
||||||
SLS_CENTRAL_WIDGET_MINIMUM_WIDTH = 940
|
SLS_CENTRAL_WIDGET_MINIMUM_WIDTH = 940
|
||||||
|
|
||||||
|
|
||||||
class BaseWindow(QMainWindow):
|
class BaseWindow(QMainWindow):
|
||||||
""" BaseWindow
|
""" BaseWindow
|
||||||
"""
|
"""
|
||||||
@@ -129,8 +129,8 @@ class BaseWindow(QMainWindow):
|
|||||||
|
|
||||||
if os.access(_dirname, os.W_OK):
|
if os.access(_dirname, os.W_OK):
|
||||||
|
|
||||||
all_fig_data[canvas][idx].savefig(save_dest)
|
all_fig_data[canvas][idx].savefig(
|
||||||
|
save_dest)
|
||||||
|
|
||||||
elif not write_message_fired:
|
elif not write_message_fired:
|
||||||
|
|
||||||
@@ -145,38 +145,33 @@ class BaseWindow(QMainWindow):
|
|||||||
_line(), _mess, {})
|
_line(), _mess, {})
|
||||||
write_message_fired = True
|
write_message_fired = True
|
||||||
|
|
||||||
|
|
||||||
if not write_message_fired:
|
if not write_message_fired:
|
||||||
attach_files.append(save_dest)
|
attach_files.append(save_dest)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resultsSeq = self.settings.data["GUI"]["resultsSeq"]
|
resultsSeq = self.settings.data["GUI"]["resultsSeq"]
|
||||||
titleSeq = self.settings.data["GUI"]["subResultsTabTitle"]
|
titleSeq = self.settings.data["GUI"]["subResultsTabTitle"]
|
||||||
if self.all_data:
|
if self.all_data:
|
||||||
fig_data = self.all_data['Figure data']
|
fig_data = self.all_data['Figure data']
|
||||||
for i, (nfig, name) in enumerate(zip(resultsSeq, titleSeq)):
|
for i, (nfig, name) in enumerate(
|
||||||
|
zip(resultsSeq, titleSeq)):
|
||||||
print(i, nfig, name, flush=True)
|
print(i, nfig, name, flush=True)
|
||||||
print(fig_data, flush=True)
|
print(fig_data, flush=True)
|
||||||
extract_and_attach(i, nfig, name, fig_data)
|
extract_and_attach(i, nfig, name, fig_data)
|
||||||
except KeyError as ex:
|
except KeyError as ex:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resultsSeq = self.settings.data["GUI2"]["resultsSeq"]
|
resultsSeq = self.settings.data["GUI2"]["resultsSeq"]
|
||||||
titleSeq = self.settings.data["GUI2"]["subResultsTabTitle"]
|
titleSeq = self.settings.data["GUI2"]["subResultsTabTitle"]
|
||||||
if self.all_data_2:
|
if self.all_data_2:
|
||||||
fig_data = self.all_data_2['Figure data']
|
fig_data = self.all_data_2['Figure data']
|
||||||
for i, (nfig, name) in enumerate(zip(resultsSeq, titleSeq)):
|
for i, (nfig, name) in enumerate(
|
||||||
|
zip(resultsSeq, titleSeq)):
|
||||||
extract_and_attach(i, nfig, name, fig_data)
|
extract_and_attach(i, nfig, name, fig_data)
|
||||||
except KeyError as ex:
|
except KeyError as ex:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Not so nice.. send a signal instead?
|
# Not so nice.. send a signal instead?
|
||||||
if attach_files:
|
if attach_files:
|
||||||
self.parent.attach_files = attach_files
|
self.parent.attach_files = attach_files
|
||||||
@@ -263,7 +258,7 @@ class BaseWindow(QMainWindow):
|
|||||||
self.parent.add_to_hdf(dataH5, proc=True, raw=True)
|
self.parent.add_to_hdf(dataH5, proc=True, raw=True)
|
||||||
self.parent.hdf_save_completed = True
|
self.parent.hdf_save_completed = True
|
||||||
|
|
||||||
_mess = "Processed data saved to {}".format(
|
_mess = "Data saved to {}".format(
|
||||||
self.parent.hdf_filename)
|
self.parent.hdf_filename)
|
||||||
self.parent.trigger_log_message.emit(
|
self.parent.trigger_log_message.emit(
|
||||||
MsgSeverity.INFO.name, _pymodule, _line(), _mess,
|
MsgSeverity.INFO.name, _pymodule, _line(), _mess,
|
||||||
@@ -275,7 +270,6 @@ class BaseWindow(QMainWindow):
|
|||||||
MsgSeverity.ERROR.name, _pymodule, _line(), _mess, {})
|
MsgSeverity.ERROR.name, _pymodule, _line(), _mess, {})
|
||||||
self.parent.hdf_save_completed = False
|
self.parent.hdf_save_completed = False
|
||||||
|
|
||||||
|
|
||||||
class HDFThread(QThread):
|
class HDFThread(QThread):
|
||||||
"""Thread for hdf analysis
|
"""Thread for hdf analysis
|
||||||
"""
|
"""
|
||||||
@@ -351,7 +345,6 @@ class BaseWindow(QMainWindow):
|
|||||||
self.parent.trigger_log_message.emit(
|
self.parent.trigger_log_message.emit(
|
||||||
MsgSeverity.ERROR.name, _pymodule, _line(), mess, {})
|
MsgSeverity.ERROR.name, _pymodule, _line(), mess, {})
|
||||||
|
|
||||||
|
|
||||||
class AnalysisThread(QThread):
|
class AnalysisThread(QThread):
|
||||||
"""Analysis thread
|
"""Analysis thread
|
||||||
"""
|
"""
|
||||||
@@ -379,13 +372,16 @@ class BaseWindow(QMainWindow):
|
|||||||
def run(self):
|
def run(self):
|
||||||
"""Run thread
|
"""Run thread
|
||||||
"""
|
"""
|
||||||
print("RUN IN BASE CLASS", flush=True)
|
print("RUN ANLYSIS THREAD FROM WITHIN IN BASE CLASS", flush=True)
|
||||||
|
|
||||||
|
# Reset all_data fro parent
|
||||||
|
self.parent.all_data = None
|
||||||
|
|
||||||
all_dict = self.analysis_procedure.measure_and_analyze(
|
all_dict = self.analysis_procedure.measure_and_analyze(
|
||||||
self.input_parameters)
|
self.input_parameters)
|
||||||
|
|
||||||
# Emit results
|
# Emit results
|
||||||
if all_dict:
|
if all_dict is not None:
|
||||||
self.trigger_thread_event.emit(all_dict)
|
self.trigger_thread_event.emit(all_dict)
|
||||||
mess = self.messages['success']
|
mess = self.messages['success']
|
||||||
self.parent.trigger_log_message.emit(
|
self.parent.trigger_log_message.emit(
|
||||||
@@ -395,7 +391,6 @@ class BaseWindow(QMainWindow):
|
|||||||
self.parent.trigger_log_message.emit(
|
self.parent.trigger_log_message.emit(
|
||||||
MsgSeverity.WARN.name, _pymodule, _line(), mess, {})
|
MsgSeverity.WARN.name, _pymodule, _line(), mess, {})
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, parent=None, pymodule=None, appversion=None, title="",
|
def __init__(self, parent=None, pymodule=None, appversion=None, title="",
|
||||||
user_mode=UserMode.OPERATION, facility=Facility.SwissFEL,
|
user_mode=UserMode.OPERATION, facility=Facility.SwissFEL,
|
||||||
extended=True, has_optics=True, has_procedure=True):
|
extended=True, has_optics=True, has_procedure=True):
|
||||||
@@ -412,7 +407,6 @@ class BaseWindow(QMainWindow):
|
|||||||
self.user_mode = user_mode
|
self.user_mode = user_mode
|
||||||
self.appname, self.appext = self.pymodule.split(".")
|
self.appname, self.appext = self.pymodule.split(".")
|
||||||
|
|
||||||
|
|
||||||
print("=============================================")
|
print("=============================================")
|
||||||
print("Starting {0} at: {1}".format(self.appname, datetime.now()))
|
print("Starting {0} at: {1}".format(self.appname, datetime.now()))
|
||||||
print("User: {0} Host: {1}".format(os.getlogin(), os.uname()[1]))
|
print("User: {0} Host: {1}".format(os.getlogin(), os.uname()[1]))
|
||||||
@@ -498,7 +492,6 @@ class BaseWindow(QMainWindow):
|
|||||||
|
|
||||||
self.hdf_save_completed = False if self.autopost_hdf else True
|
self.hdf_save_completed = False if self.autopost_hdf else True
|
||||||
|
|
||||||
|
|
||||||
self.all_input_parameters = {} # gui
|
self.all_input_parameters = {} # gui
|
||||||
self.all_input_labels = {} # gui
|
self.all_input_labels = {} # gui
|
||||||
self.all_expert_parameters = {} # gui
|
self.all_expert_parameters = {} # gui
|
||||||
@@ -526,8 +519,8 @@ class BaseWindow(QMainWindow):
|
|||||||
print(("Base class without user supplied AnalysisProcedure class."
|
print(("Base class without user supplied AnalysisProcedure class."
|
||||||
+ " import Error:"), e, flush=True)
|
+ " import Error:"), e, flush=True)
|
||||||
|
|
||||||
##self.trigger_elog_entry.connect(self.receive_elog_notification)
|
# self.trigger_elog_entry.connect(self.receive_elog_notification)
|
||||||
##self.trigger_hdf_save.connect(self.save_to_hdf)
|
# self.trigger_hdf_save.connect(self.save_to_hdf)
|
||||||
|
|
||||||
self.msg_severity_qcolor = {
|
self.msg_severity_qcolor = {
|
||||||
MsgSeverity.FATAL: QColor(
|
MsgSeverity.FATAL: QColor(
|
||||||
@@ -615,7 +608,6 @@ class BaseWindow(QMainWindow):
|
|||||||
self.show_log_message(MsgSeverity.INFO.name, _pymodule, _line(),
|
self.show_log_message(MsgSeverity.INFO.name, _pymodule, _line(),
|
||||||
"Application configured")
|
"Application configured")
|
||||||
|
|
||||||
|
|
||||||
def read_input_parameters(self):
|
def read_input_parameters(self):
|
||||||
|
|
||||||
for key, dictval in self.settings.data["Parameters"].items():
|
for key, dictval in self.settings.data["Parameters"].items():
|
||||||
@@ -659,7 +651,6 @@ class BaseWindow(QMainWindow):
|
|||||||
self.all_input_labels[key] = dictval["data"]["text"]
|
self.all_input_labels[key] = dictval["data"]["text"]
|
||||||
#print(key, self.settings.data["Parameters"][key]["flag"])
|
#print(key, self.settings.data["Parameters"][key]["flag"])
|
||||||
|
|
||||||
|
|
||||||
if "Expert" not in self.settings.data:
|
if "Expert" not in self.settings.data:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -704,7 +695,6 @@ class BaseWindow(QMainWindow):
|
|||||||
self.expert_labels[key] = dictval["data"]["text"]
|
self.expert_labels[key] = dictval["data"]["text"]
|
||||||
self.all_expert_labels[key] = dictval["data"]["text"]
|
self.all_expert_labels[key] = dictval["data"]["text"]
|
||||||
|
|
||||||
|
|
||||||
def init_toolbar(self):
|
def init_toolbar(self):
|
||||||
""" Prepare toolbar
|
""" Prepare toolbar
|
||||||
"""
|
"""
|
||||||
@@ -812,19 +802,20 @@ class BaseWindow(QMainWindow):
|
|||||||
exit_toolbar.addWidget(spacer_wgt)
|
exit_toolbar.addWidget(spacer_wgt)
|
||||||
#_qsize = exit_toolbar.iconSize()
|
#_qsize = exit_toolbar.iconSize()
|
||||||
#print("qsize", _qsize)
|
#print("qsize", _qsize)
|
||||||
true_list = [self.autopost_epics, self.autopost_hdf, self.autopost_elog]
|
true_list = [
|
||||||
|
self.autopost_epics,
|
||||||
|
self.autopost_hdf,
|
||||||
|
self.autopost_elog]
|
||||||
|
|
||||||
if true_list.count(True) > 1:
|
if true_list.count(True) > 1:
|
||||||
exit_toolbar.setIconSize(QSize(true_list.count(True)*30+10, 24))
|
exit_toolbar.setIconSize(
|
||||||
|
QSize(true_list.count(True) * 30 + 10, 24))
|
||||||
# exit_toolbar.setIconSize(_qsize)
|
# exit_toolbar.setIconSize(_qsize)
|
||||||
self.add_actions(exit_toolbar, (
|
self.add_actions(exit_toolbar, (
|
||||||
save_all_action, "Space", None, "Space", quit_action))
|
save_all_action, "Space", None, "Space", quit_action))
|
||||||
else:
|
else:
|
||||||
self.add_actions(exit_toolbar, (quit_action,))
|
self.add_actions(exit_toolbar, (quit_action,))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def combine_save_icons(self): # epics=False, hdf=False, elog=False):
|
def combine_save_icons(self): # epics=False, hdf=False, elog=False):
|
||||||
|
|
||||||
epics = self.autopost_epics
|
epics = self.autopost_epics
|
||||||
@@ -868,8 +859,8 @@ class BaseWindow(QMainWindow):
|
|||||||
painter.end()
|
painter.end()
|
||||||
return combinedIcon
|
return combinedIcon
|
||||||
|
|
||||||
|
# Actions
|
||||||
|
|
||||||
################# Actions
|
|
||||||
def add_actions(self, target, actions):
|
def add_actions(self, target, actions):
|
||||||
""" Add to toolbar
|
""" Add to toolbar
|
||||||
"""
|
"""
|
||||||
@@ -904,8 +895,6 @@ class BaseWindow(QMainWindow):
|
|||||||
action.setCheckable(True)
|
action.setCheckable(True)
|
||||||
return action
|
return action
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def verify_close_event(self):
|
def verify_close_event(self):
|
||||||
""" Overrides QMainWindow method
|
""" Overrides QMainWindow method
|
||||||
"""
|
"""
|
||||||
@@ -1031,7 +1020,6 @@ class BaseWindow(QMainWindow):
|
|||||||
qdialog.setLayout(layout)
|
qdialog.setLayout(layout)
|
||||||
qdialog.show()
|
qdialog.show()
|
||||||
|
|
||||||
|
|
||||||
# def save_to_hdf_started(self):
|
# def save_to_hdf_started(self):
|
||||||
# QApplication.processEvents()
|
# QApplication.processEvents()
|
||||||
# def save_to_hdf_finished(self):
|
# def save_to_hdf_finished(self):
|
||||||
@@ -1056,14 +1044,12 @@ class BaseWindow(QMainWindow):
|
|||||||
# enable signal
|
# enable signal
|
||||||
# self.gui_frame.autopost_save.blockSignals(False)
|
# self.gui_frame.autopost_save.blockSignals(False)
|
||||||
|
|
||||||
|
|
||||||
def set_new_hdf_filename(self, time_in_seconds=None,
|
def set_new_hdf_filename(self, time_in_seconds=None,
|
||||||
reanalysis_time_in_seconds=None):
|
reanalysis_time_in_seconds=None):
|
||||||
|
|
||||||
self.hdf_filename = (self.hdf_dest + self.add_date_to_path(
|
self.hdf_filename = (self.hdf_dest + self.add_date_to_path(
|
||||||
time_in_seconds, reanalysis_time_in_seconds) + ".h5")
|
time_in_seconds, reanalysis_time_in_seconds) + ".h5")
|
||||||
|
|
||||||
|
|
||||||
def add_date_to_path(self, time_in_seconds=None,
|
def add_date_to_path(self, time_in_seconds=None,
|
||||||
reanalysis_time_in_seconds=None):
|
reanalysis_time_in_seconds=None):
|
||||||
|
|
||||||
@@ -1091,7 +1077,6 @@ class BaseWindow(QMainWindow):
|
|||||||
else:
|
else:
|
||||||
return str(self.appname + "_" + _date_label)
|
return str(self.appname + "_" + _date_label)
|
||||||
|
|
||||||
|
|
||||||
def verify_save_to_hdf(self):
|
def verify_save_to_hdf(self):
|
||||||
""" To be called by user from save_to_hdf
|
""" To be called by user from save_to_hdf
|
||||||
A return of True tells the user to continue to next step
|
A return of True tells the user to continue to next step
|
||||||
@@ -1122,7 +1107,6 @@ class BaseWindow(QMainWindow):
|
|||||||
QApplication.processEvents()
|
QApplication.processEvents()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
if self.hdf_save_completed:
|
if self.hdf_save_completed:
|
||||||
_mess = "Data previously saved to hdf:\n{0}".format(
|
_mess = "Data previously saved to hdf:\n{0}".format(
|
||||||
self.hdf_filename)
|
self.hdf_filename)
|
||||||
@@ -1131,10 +1115,8 @@ class BaseWindow(QMainWindow):
|
|||||||
QApplication.processEvents()
|
QApplication.processEvents()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def add_to_hdf(self, dataH5=None, proc=True, raw=False):
|
def add_to_hdf(self, dataH5=None, proc=True, raw=False):
|
||||||
""" Abstract method to be overwritten by user. Optional.
|
""" Abstract method to be overwritten by user. Optional.
|
||||||
"""
|
"""
|
||||||
@@ -1164,7 +1146,6 @@ class BaseWindow(QMainWindow):
|
|||||||
)
|
)
|
||||||
QM.exec()
|
QM.exec()
|
||||||
|
|
||||||
|
|
||||||
def add_pvs_to_hdf(self, dataH5, top_group="experiment", pv_list=None,
|
def add_pvs_to_hdf(self, dataH5, top_group="experiment", pv_list=None,
|
||||||
from_hdf=False):
|
from_hdf=False):
|
||||||
|
|
||||||
@@ -1192,7 +1173,6 @@ class BaseWindow(QMainWindow):
|
|||||||
{})
|
{})
|
||||||
return isOK
|
return isOK
|
||||||
|
|
||||||
|
|
||||||
if from_hdf:
|
if from_hdf:
|
||||||
return isOK
|
return isOK
|
||||||
|
|
||||||
@@ -1218,8 +1198,6 @@ class BaseWindow(QMainWindow):
|
|||||||
MsgSeverity.WARN.name, _pymodule, _line(), _mess, {})
|
MsgSeverity.WARN.name, _pymodule, _line(), _mess, {})
|
||||||
return isOK
|
return isOK
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def add_general_to_hdf(self, dataH5):
|
def add_general_to_hdf(self, dataH5):
|
||||||
isOK = True
|
isOK = True
|
||||||
user_dict = {}
|
user_dict = {}
|
||||||
@@ -1270,7 +1248,6 @@ class BaseWindow(QMainWindow):
|
|||||||
MsgSeverity.WARN.name, _pymodule, _line(), _mess, {})
|
MsgSeverity.WARN.name, _pymodule, _line(), _mess, {})
|
||||||
return isOK
|
return isOK
|
||||||
|
|
||||||
|
|
||||||
@Slot()
|
@Slot()
|
||||||
def save_to_hdf_dialog(self):
|
def save_to_hdf_dialog(self):
|
||||||
""" This uses the widget interface to allow the user to enter
|
""" This uses the widget interface to allow the user to enter
|
||||||
@@ -1292,7 +1269,6 @@ class BaseWindow(QMainWindow):
|
|||||||
'Reanalysis time in seconds']
|
'Reanalysis time in seconds']
|
||||||
self.set_new_hdf_filename(ts_in_seconds, now_in_seconds)
|
self.set_new_hdf_filename(ts_in_seconds, now_in_seconds)
|
||||||
|
|
||||||
|
|
||||||
input_options['Destination'] = self.hdf_filename
|
input_options['Destination'] = self.hdf_filename
|
||||||
input_options['Time in seconds'] = self.all_data['Ambient data'][
|
input_options['Time in seconds'] = self.all_data['Ambient data'][
|
||||||
'Time in seconds']
|
'Time in seconds']
|
||||||
@@ -1300,7 +1276,6 @@ class BaseWindow(QMainWindow):
|
|||||||
self.hdf_dialog = QSaveHDF(self, input_options=input_options,
|
self.hdf_dialog = QSaveHDF(self, input_options=input_options,
|
||||||
from_dialog=True)
|
from_dialog=True)
|
||||||
|
|
||||||
|
|
||||||
def verify_send_to_elog(self):
|
def verify_send_to_elog(self):
|
||||||
|
|
||||||
if self.analysis_thread is not None:
|
if self.analysis_thread is not None:
|
||||||
@@ -1356,14 +1331,12 @@ class BaseWindow(QMainWindow):
|
|||||||
_attach_files = []
|
_attach_files = []
|
||||||
_message = ""
|
_message = ""
|
||||||
|
|
||||||
|
|
||||||
QSendToELOG(self, logbook=_logbook, categoryIdx=_category_idx,
|
QSendToELOG(self, logbook=_logbook, categoryIdx=_category_idx,
|
||||||
domainIdx=_domain_idx, sectionIdx=_section_idx,
|
domainIdx=_domain_idx, sectionIdx=_section_idx,
|
||||||
title=self.title, message=_message,
|
title=self.title, message=_message,
|
||||||
attachFile=_attach_files)
|
attachFile=_attach_files)
|
||||||
QApplication.processEvents()
|
QApplication.processEvents()
|
||||||
|
|
||||||
|
|
||||||
def initiate_cycling(self, pv_list=[]):
|
def initiate_cycling(self, pv_list=[]):
|
||||||
if not pv_list:
|
if not pv_list:
|
||||||
return False
|
return False
|
||||||
@@ -1432,7 +1405,6 @@ class BaseWindow(QMainWindow):
|
|||||||
qm.warning(self, "Set Optics", _mess, QMessageBox.Ok)
|
qm.warning(self, "Set Optics", _mess, QMessageBox.Ok)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
@Slot()
|
@Slot()
|
||||||
def set_optics(self):
|
def set_optics(self):
|
||||||
""" Abstract method to be overwritten by user
|
""" Abstract method to be overwritten by user
|
||||||
@@ -1455,7 +1427,6 @@ class BaseWindow(QMainWindow):
|
|||||||
)
|
)
|
||||||
QM.exec()
|
QM.exec()
|
||||||
|
|
||||||
|
|
||||||
def verify_save_to_epics(self):
|
def verify_save_to_epics(self):
|
||||||
""" To be called by user from save_to_epics
|
""" To be called by user from save_to_epics
|
||||||
"""
|
"""
|
||||||
@@ -1510,7 +1481,6 @@ class BaseWindow(QMainWindow):
|
|||||||
)
|
)
|
||||||
QM.exec()
|
QM.exec()
|
||||||
|
|
||||||
|
|
||||||
def send_to_log_window(self, pv_list: list = [], status: int = 1,
|
def send_to_log_window(self, pv_list: list = [], status: int = 1,
|
||||||
status_list: list = [], operation: str = 'set/get',
|
status_list: list = [], operation: str = 'set/get',
|
||||||
pymodule=_pymodule, line: int = _line()):
|
pymodule=_pymodule, line: int = _line()):
|
||||||
@@ -1530,11 +1500,9 @@ class BaseWindow(QMainWindow):
|
|||||||
"See Log window").format(ibad, len(status_list))
|
"See Log window").format(ibad, len(status_list))
|
||||||
self.statusbar.showMessage(_mess)
|
self.statusbar.showMessage(_mess)
|
||||||
|
|
||||||
|
|
||||||
def send_to_epics(self, pv_dict: dict = None, pv_names: list = None,
|
def send_to_epics(self, pv_dict: dict = None, pv_names: list = None,
|
||||||
pv_values: list = None) -> (int, list):
|
pv_values: list = None) -> (int, list):
|
||||||
|
|
||||||
|
|
||||||
if pv_dict is not None:
|
if pv_dict is not None:
|
||||||
pv_values = []
|
pv_values = []
|
||||||
pv_names = list(pv_dict.keys())
|
pv_names = list(pv_dict.keys())
|
||||||
@@ -1564,15 +1532,15 @@ class BaseWindow(QMainWindow):
|
|||||||
status = self.cyca.ICAFE_NORMAL
|
status = self.cyca.ICAFE_NORMAL
|
||||||
status_list = []
|
status_list = []
|
||||||
try:
|
try:
|
||||||
status, status_list = self.cafe.setCompoundList(pv_names, pv_values)
|
status, status_list = self.cafe.setCompoundList(
|
||||||
except:
|
pv_names, pv_values)
|
||||||
|
except BaseException:
|
||||||
print("Exception raised in cafe.setCompoundList", flush=True)
|
print("Exception raised in cafe.setCompoundList", flush=True)
|
||||||
status = self.cyca.ECAFE_BADTYPE
|
status = self.cyca.ECAFE_BADTYPE
|
||||||
for pv, val in zip(pv_names, pv_values):
|
for pv, val in zip(pv_names, pv_values):
|
||||||
print("pv/val", pv, val, flush=True)
|
print("pv/val", pv, val, flush=True)
|
||||||
status_list.append(self.ECAFE_BADTYPE)
|
status_list.append(self.ECAFE_BADTYPE)
|
||||||
|
|
||||||
|
|
||||||
if status != self.cyca.ICAFE_NORMAL:
|
if status != self.cyca.ICAFE_NORMAL:
|
||||||
ibad = 0
|
ibad = 0
|
||||||
for _status, _pv in zip(status_list, pv_names):
|
for _status, _pv in zip(status_list, pv_names):
|
||||||
@@ -1674,7 +1642,7 @@ class BaseWindow(QMainWindow):
|
|||||||
self.screenshot_titles.clear()
|
self.screenshot_titles.clear()
|
||||||
self.screenshot_items.clear()
|
self.screenshot_items.clear()
|
||||||
|
|
||||||
############################### Init
|
# Init
|
||||||
def init_statusbar_wgt(self):
|
def init_statusbar_wgt(self):
|
||||||
""" Configure statusbar
|
""" Configure statusbar
|
||||||
"""
|
"""
|
||||||
@@ -1771,9 +1739,9 @@ class BaseWindow(QMainWindow):
|
|||||||
# Fill all data from HDF file
|
# Fill all data from HDF file
|
||||||
###hdf_all_data = self.load_hdf_file()
|
###hdf_all_data = self.load_hdf_file()
|
||||||
|
|
||||||
###if not hdf_all_data:
|
# if not hdf_all_data:
|
||||||
### self.hdf_thread_finished()
|
# self.hdf_thread_finished()
|
||||||
### return
|
# return
|
||||||
|
|
||||||
self.hdf_thread = self.HDFThread(
|
self.hdf_thread = self.HDFThread(
|
||||||
self, self.analysis_procedure, all_data=None) # =hdf_all_data
|
self, self.analysis_procedure, all_data=None) # =hdf_all_data
|
||||||
@@ -1786,8 +1754,8 @@ class BaseWindow(QMainWindow):
|
|||||||
self.hdf_thread.start()
|
self.hdf_thread.start()
|
||||||
QApplication.processEvents()
|
QApplication.processEvents()
|
||||||
|
|
||||||
|
|
||||||
# To be overloaded by user
|
# To be overloaded by user
|
||||||
|
|
||||||
def verify_analysis_preconditions(self):
|
def verify_analysis_preconditions(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -1818,7 +1786,6 @@ class BaseWindow(QMainWindow):
|
|||||||
if not self.verify_analysis_preconditions():
|
if not self.verify_analysis_preconditions():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
self.analysis_thread = self.AnalysisThread(
|
self.analysis_thread = self.AnalysisThread(
|
||||||
self, self.analysis_procedure, self.input_parameters)
|
self, self.analysis_procedure, self.input_parameters)
|
||||||
|
|
||||||
@@ -1828,11 +1795,9 @@ class BaseWindow(QMainWindow):
|
|||||||
self.analysis_thread.started.connect(self.analysis_thread_started)
|
self.analysis_thread.started.connect(self.analysis_thread_started)
|
||||||
self.analysis_thread.finished.connect(self.analysis_thread_finished)
|
self.analysis_thread.finished.connect(self.analysis_thread_finished)
|
||||||
|
|
||||||
|
|
||||||
self.analysis_thread.start()
|
self.analysis_thread.start()
|
||||||
QApplication.processEvents()
|
QApplication.processEvents()
|
||||||
|
|
||||||
|
|
||||||
@Slot()
|
@Slot()
|
||||||
def analysis_thread_started(self):
|
def analysis_thread_started(self):
|
||||||
""" Change state of widgets when measuring
|
""" Change state of widgets when measuring
|
||||||
@@ -1856,7 +1821,6 @@ class BaseWindow(QMainWindow):
|
|||||||
self.gui_frame.in_hdf_measurement_procedure()
|
self.gui_frame.in_hdf_measurement_procedure()
|
||||||
QApplication.processEvents()
|
QApplication.processEvents()
|
||||||
|
|
||||||
|
|
||||||
@Slot()
|
@Slot()
|
||||||
def hdf_thread_finished(self):
|
def hdf_thread_finished(self):
|
||||||
""" Reset widgets to intial pre-measurement state
|
""" Reset widgets to intial pre-measurement state
|
||||||
@@ -1865,7 +1829,6 @@ class BaseWindow(QMainWindow):
|
|||||||
QApplication.processEvents()
|
QApplication.processEvents()
|
||||||
#print("Thread Finished")
|
#print("Thread Finished")
|
||||||
|
|
||||||
|
|
||||||
@Slot(dict)
|
@Slot(dict)
|
||||||
def receive_analysis_results(self, all_dict):
|
def receive_analysis_results(self, all_dict):
|
||||||
self.all_data = all_dict
|
self.all_data = all_dict
|
||||||
@@ -1880,7 +1843,7 @@ class BaseWindow(QMainWindow):
|
|||||||
try:
|
try:
|
||||||
results_data = all_dict['Processed data']['Results']
|
results_data = all_dict['Processed data']['Results']
|
||||||
self.gui_frame.send_to_results_output_wgt(results_data)
|
self.gui_frame.send_to_results_output_wgt(results_data)
|
||||||
except:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#print("IDX+++", self.gui_frame.central_tab_widget.indexOf('Emittance'), flush=True)
|
#print("IDX+++", self.gui_frame.central_tab_widget.indexOf('Emittance'), flush=True)
|
||||||
@@ -1894,7 +1857,11 @@ class BaseWindow(QMainWindow):
|
|||||||
# for j in range(len(self.gui_frame.level1_tab_wgt)):
|
# for j in range(len(self.gui_frame.level1_tab_wgt)):
|
||||||
j = self.gui_frame.central_tab_widget.currentIndex()
|
j = self.gui_frame.central_tab_widget.currentIndex()
|
||||||
for i in range(self.gui_frame.level1_tab_wgt[j].count()):
|
for i in range(self.gui_frame.level1_tab_wgt[j].count()):
|
||||||
print(j, i, self.gui_frame.level1_tab_wgt[j].tabText(i), flush=True)
|
print(
|
||||||
|
j,
|
||||||
|
i,
|
||||||
|
self.gui_frame.level1_tab_wgt[j].tabText(i),
|
||||||
|
flush=True)
|
||||||
if self.gui_frame.level1_tab_wgt[j].tabText(i) == "Plots":
|
if self.gui_frame.level1_tab_wgt[j].tabText(i) == "Plots":
|
||||||
self.gui_frame.level1_tab_wgt[j].setCurrentIndex(i)
|
self.gui_frame.level1_tab_wgt[j].setCurrentIndex(i)
|
||||||
else:
|
else:
|
||||||
@@ -1902,14 +1869,20 @@ class BaseWindow(QMainWindow):
|
|||||||
else:
|
else:
|
||||||
|
|
||||||
for i in range(self.gui_frame.central_tab_widget.count()):
|
for i in range(self.gui_frame.central_tab_widget.count()):
|
||||||
print(i, self.gui_frame.central_tab_widget.tabText(i), flush=True)
|
print(
|
||||||
|
i,
|
||||||
|
self.gui_frame.central_tab_widget.tabText(i),
|
||||||
|
flush=True)
|
||||||
if self.gui_frame.central_tab_widget.tabText(i) == "Plots":
|
if self.gui_frame.central_tab_widget.tabText(i) == "Plots":
|
||||||
self.gui_frame.central_tab_widget.setCurrentIndex(i)
|
self.gui_frame.central_tab_widget.setCurrentIndex(i)
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
for i in range(self.gui_frame.measurement_tab_wgt.count()):
|
for i in range(self.gui_frame.measurement_tab_wgt.count()):
|
||||||
print(i, self.gui_frame.measurement_tab_wgt.tabText(i), flush=True)
|
print(
|
||||||
|
i,
|
||||||
|
self.gui_frame.measurement_tab_wgt.tabText(i),
|
||||||
|
flush=True)
|
||||||
if self.gui_frame.measurement_tab_wgt.tabText(i) == "Plots":
|
if self.gui_frame.measurement_tab_wgt.tabText(i) == "Plots":
|
||||||
self.gui_frame.measurement_tab_wgt.setCurrentIndex(i)
|
self.gui_frame.measurement_tab_wgt.setCurrentIndex(i)
|
||||||
else:
|
else:
|
||||||
@@ -1936,7 +1909,6 @@ class BaseWindow(QMainWindow):
|
|||||||
# self.trigger_progressbar.emit(PROGRESS_THREAD_ABORTING)
|
# self.trigger_progressbar.emit(PROGRESS_THREAD_ABORTING)
|
||||||
QApplication.processEvents()
|
QApplication.processEvents()
|
||||||
|
|
||||||
|
|
||||||
@Slot(str, str, int, str, dict)
|
@Slot(str, str, int, str, dict)
|
||||||
def receive_log_message(self, severity, module, line, message, options={}):
|
def receive_log_message(self, severity, module, line, message, options={}):
|
||||||
'''Receive message from thread for routing to log window'''
|
'''Receive message from thread for routing to log window'''
|
||||||
@@ -2015,7 +1987,6 @@ class BaseWindow(QMainWindow):
|
|||||||
QApplication.processEvents()
|
QApplication.processEvents()
|
||||||
time.sleep(0.0001)
|
time.sleep(0.0001)
|
||||||
|
|
||||||
|
|
||||||
def initialize_application(self, appname=_appname, delay=None,
|
def initialize_application(self, appname=_appname, delay=None,
|
||||||
facility=Facility.SwissFEL):
|
facility=Facility.SwissFEL):
|
||||||
"""
|
"""
|
||||||
@@ -2104,12 +2075,10 @@ class BaseWindow(QMainWindow):
|
|||||||
#pSplashNotice = QCheckBox(self.splash_screen);
|
#pSplashNotice = QCheckBox(self.splash_screen);
|
||||||
# pSplashNotice.setChecked(Qt.Checked)
|
# pSplashNotice.setChecked(Qt.Checked)
|
||||||
|
|
||||||
|
|
||||||
self.splash_progressbar = QProgressBar(self.splash_screen)
|
self.splash_progressbar = QProgressBar(self.splash_screen)
|
||||||
self.splash_timer = QTimer()
|
self.splash_timer = QTimer()
|
||||||
self.splash_screen.show()
|
self.splash_screen.show()
|
||||||
|
|
||||||
|
|
||||||
# Custom progress bar stylesheet
|
# Custom progress bar stylesheet
|
||||||
progressbar_stylesheet = """
|
progressbar_stylesheet = """
|
||||||
QProgressBar:horizontal {
|
QProgressBar:horizontal {
|
||||||
@@ -2159,7 +2128,6 @@ class BaseWindow(QMainWindow):
|
|||||||
|
|
||||||
return self.splash_screen
|
return self.splash_screen
|
||||||
|
|
||||||
|
|
||||||
def initialize_finished(self, myapp):
|
def initialize_finished(self, myapp):
|
||||||
self.splash_timer.stop()
|
self.splash_timer.stop()
|
||||||
self.splash_progressbar.setValue(100)
|
self.splash_progressbar.setValue(100)
|
||||||
@@ -2180,8 +2148,6 @@ class BaseWindow(QMainWindow):
|
|||||||
Qt.AlignmentFlag(Qt.AlignCenter | Qt.AlignTop))
|
Qt.AlignmentFlag(Qt.AlignCenter | Qt.AlignTop))
|
||||||
self.splash_screen.finish(myapp)
|
self.splash_screen.finish(myapp)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def check_status_list(self, pymodule: str = _pymodule,
|
def check_status_list(self, pymodule: str = _pymodule,
|
||||||
operation: str = "channel access",
|
operation: str = "channel access",
|
||||||
pv_list: list = None, status_list: list = None,
|
pv_list: list = None, status_list: list = None,
|
||||||
@@ -2200,7 +2166,6 @@ class BaseWindow(QMainWindow):
|
|||||||
if stat is None:
|
if stat is None:
|
||||||
status_list[i] = self.cafe.getStatus(pv)
|
status_list[i] = self.cafe.getStatus(pv)
|
||||||
|
|
||||||
|
|
||||||
brk = ("------------------------------------------------------" +
|
brk = ("------------------------------------------------------" +
|
||||||
"------------------------------------------------------")
|
"------------------------------------------------------")
|
||||||
self.trigger_log_message.emit(
|
self.trigger_log_message.emit(
|
||||||
@@ -2230,7 +2195,6 @@ class BaseWindow(QMainWindow):
|
|||||||
|
|
||||||
return status_list
|
return status_list
|
||||||
|
|
||||||
|
|
||||||
def check_status(self, pymodule: str = _pymodule,
|
def check_status(self, pymodule: str = _pymodule,
|
||||||
operation: str = "channel access",
|
operation: str = "channel access",
|
||||||
pv: str = None, stat: int = None,
|
pv: str = None, stat: int = None,
|
||||||
@@ -2238,7 +2202,7 @@ class BaseWindow(QMainWindow):
|
|||||||
|
|
||||||
if not pv:
|
if not pv:
|
||||||
return
|
return
|
||||||
if stat == None:
|
if stat is None:
|
||||||
stat = self.cafe.getStatus(pv)
|
stat = self.cafe.getStatus(pv)
|
||||||
|
|
||||||
if stat != self.cyca.ICAFE_NORMAL:
|
if stat != self.cyca.ICAFE_NORMAL:
|
||||||
|
|||||||
612
guiframe.py
612
guiframe.py
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user