Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 29f63ccb75 | |||
| 71702f5f7a | |||
| fb623ee4fc | |||
| 44a113d85d | |||
| d0bc302915 | |||
| 4cf494982e | |||
| bba3ecf4c1 | |||
| 0d763f267c | |||
| e785db369f | |||
| 4783ec5a32 | |||
| 73b187b5a8 | |||
| 532e81f165 | |||
| 4babb18676 | |||
| e7118162d4 | |||
| 425c8125d2 | |||
| aeb7e2907f | |||
| b17b3200fc | |||
| aa31b65750 | |||
| 886f7e0972 | |||
| 5fb1d9fe5b | |||
| fcca4f08d4 | |||
| ce700a0c14 | |||
| ac9d3b3e22 | |||
| fd212a441d |
218
base.py
218
base.py
@@ -5,7 +5,6 @@ from collections import OrderedDict
|
||||
from datetime import datetime
|
||||
import getpass
|
||||
import h5py
|
||||
import inspect
|
||||
import logging
|
||||
import numpy as np
|
||||
import platform
|
||||
@@ -58,6 +57,7 @@ CENTRAL_WIDGET_MINIMUM_WIDTH = 1240
|
||||
SLS_CENTRAL_WIDGET_MINIMUM_HEIGHT = 840
|
||||
SLS_CENTRAL_WIDGET_MINIMUM_WIDTH = 940
|
||||
|
||||
|
||||
class BaseWindow(QMainWindow):
|
||||
""" BaseWindow
|
||||
"""
|
||||
@@ -75,6 +75,7 @@ class BaseWindow(QMainWindow):
|
||||
QThread.__init__(self)
|
||||
self.parent = parent
|
||||
self.settings = self.parent.settings
|
||||
|
||||
self.folder_name = folder_name
|
||||
self.time_in_seconds = time_in_seconds
|
||||
self.reanalysis_time = reanalysis_time
|
||||
@@ -109,17 +110,28 @@ class BaseWindow(QMainWindow):
|
||||
|
||||
name = name_base + "_{0}".format(
|
||||
idx) if idx > 0 else name_base
|
||||
|
||||
save_dest = (folder_name + date_str + '_' + name +
|
||||
'.png')
|
||||
|
||||
|
||||
if not os.path.exists(save_dest):
|
||||
if all_fig_data[canvas][idx] is not None:
|
||||
_dirname = os.path.dirname(save_dest)
|
||||
|
||||
#print("DIRECTORY NAME IS ", _dirname)
|
||||
# print("exists?", os.path.exists(_dirname),
|
||||
# os.path.exists(save_dest))
|
||||
|
||||
if not os.path.isfile(save_dest):
|
||||
if all_fig_data[canvas][idx] is not None:
|
||||
|
||||
if not os.path.exists(_dirname):
|
||||
|
||||
os.makedirs(_dirname)
|
||||
|
||||
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:
|
||||
|
||||
_mess = ("Do not have write permission " +
|
||||
@@ -133,38 +145,33 @@ class BaseWindow(QMainWindow):
|
||||
_line(), _mess, {})
|
||||
write_message_fired = True
|
||||
|
||||
|
||||
if not write_message_fired:
|
||||
attach_files.append(save_dest)
|
||||
|
||||
|
||||
|
||||
|
||||
try:
|
||||
resultsSeq = self.settings.data["GUI"]["resultsSeq"]
|
||||
titleSeq = self.settings.data["GUI"]["subResultsTabTitle"]
|
||||
if self.all_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(fig_data, flush=True)
|
||||
extract_and_attach(i, nfig, name, fig_data)
|
||||
except KeyError as ex:
|
||||
pass
|
||||
|
||||
|
||||
try:
|
||||
resultsSeq = self.settings.data["GUI2"]["resultsSeq"]
|
||||
titleSeq = self.settings.data["GUI2"]["subResultsTabTitle"]
|
||||
if self.all_data_2:
|
||||
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)
|
||||
except KeyError as ex:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
# Not so nice.. send a signal instead?
|
||||
if attach_files:
|
||||
self.parent.attach_files = attach_files
|
||||
@@ -229,8 +236,8 @@ class BaseWindow(QMainWindow):
|
||||
|
||||
self.parent.from_hdf = from_hdf
|
||||
|
||||
print("t=========================>", ts_in_seconds, " // ", now_in_seconds)
|
||||
print("from hdf5=========================>", from_hdf)
|
||||
print("t", ts_in_seconds, now_in_seconds)
|
||||
print("from hdf5, dialog=====>", from_hdf, self.from_dialog)
|
||||
|
||||
if self.parent.hdf_filename is None or not self.from_dialog:
|
||||
self.parent.set_new_hdf_filename(ts_in_seconds,
|
||||
@@ -251,7 +258,7 @@ class BaseWindow(QMainWindow):
|
||||
self.parent.add_to_hdf(dataH5, proc=True, raw=True)
|
||||
self.parent.hdf_save_completed = True
|
||||
|
||||
_mess = "Processed data saved to {}".format(
|
||||
_mess = "Data saved to {}".format(
|
||||
self.parent.hdf_filename)
|
||||
self.parent.trigger_log_message.emit(
|
||||
MsgSeverity.INFO.name, _pymodule, _line(), _mess,
|
||||
@@ -263,7 +270,6 @@ class BaseWindow(QMainWindow):
|
||||
MsgSeverity.ERROR.name, _pymodule, _line(), _mess, {})
|
||||
self.parent.hdf_save_completed = False
|
||||
|
||||
|
||||
class HDFThread(QThread):
|
||||
"""Thread for hdf analysis
|
||||
"""
|
||||
@@ -339,7 +345,6 @@ class BaseWindow(QMainWindow):
|
||||
self.parent.trigger_log_message.emit(
|
||||
MsgSeverity.ERROR.name, _pymodule, _line(), mess, {})
|
||||
|
||||
|
||||
class AnalysisThread(QThread):
|
||||
"""Analysis thread
|
||||
"""
|
||||
@@ -367,13 +372,16 @@ class BaseWindow(QMainWindow):
|
||||
def run(self):
|
||||
"""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(
|
||||
self.input_parameters)
|
||||
|
||||
# Emit results
|
||||
if all_dict:
|
||||
if all_dict is not None:
|
||||
self.trigger_thread_event.emit(all_dict)
|
||||
mess = self.messages['success']
|
||||
self.parent.trigger_log_message.emit(
|
||||
@@ -383,7 +391,6 @@ class BaseWindow(QMainWindow):
|
||||
self.parent.trigger_log_message.emit(
|
||||
MsgSeverity.WARN.name, _pymodule, _line(), mess, {})
|
||||
|
||||
|
||||
def __init__(self, parent=None, pymodule=None, appversion=None, title="",
|
||||
user_mode=UserMode.OPERATION, facility=Facility.SwissFEL,
|
||||
extended=True, has_optics=True, has_procedure=True):
|
||||
@@ -395,13 +402,11 @@ class BaseWindow(QMainWindow):
|
||||
self.appversion = appversion if appversion else _appversion
|
||||
self.source_file = None
|
||||
self.author = _author
|
||||
self.appversion = _appversion
|
||||
self.title = title
|
||||
self.facility = facility
|
||||
self.user_mode = user_mode
|
||||
self.appname, self.appext = self.pymodule.split(".")
|
||||
|
||||
|
||||
print("=============================================")
|
||||
print("Starting {0} at: {1}".format(self.appname, datetime.now()))
|
||||
print("User: {0} Host: {1}".format(os.getlogin(), os.uname()[1]))
|
||||
@@ -427,6 +432,7 @@ class BaseWindow(QMainWindow):
|
||||
self.filename = None
|
||||
self.hdf_filename_loaded = "NONE" # For loading into hdf dockwidget
|
||||
self.hdf_filename = None # For saving
|
||||
self.hdf_user_dict = {}
|
||||
self.hdf_dialog = None
|
||||
self.from_hdf = False
|
||||
|
||||
@@ -441,9 +447,13 @@ class BaseWindow(QMainWindow):
|
||||
|
||||
self.menu = self.menuBar()
|
||||
|
||||
|
||||
|
||||
self.elog_dest = self.settings.data["Elog"]["destination"]
|
||||
|
||||
try:
|
||||
self.elog_add_date_to_dir = self.settings.data["Elog"]["addDateToDir"]
|
||||
except KeyError:
|
||||
self.elog_add_date_to_dir = True
|
||||
|
||||
self.screenshot_dest = self.settings.data["screenshot"]["destination"]
|
||||
self.stdlog_dest = (self.settings.data["stdlog"]["destination"] +
|
||||
self.appname + "-" + os.getlogin() + ".log")
|
||||
@@ -482,7 +492,6 @@ class BaseWindow(QMainWindow):
|
||||
|
||||
self.hdf_save_completed = False if self.autopost_hdf else True
|
||||
|
||||
|
||||
self.all_input_parameters = {} # gui
|
||||
self.all_input_labels = {} # gui
|
||||
self.all_expert_parameters = {} # gui
|
||||
@@ -510,8 +519,8 @@ class BaseWindow(QMainWindow):
|
||||
print(("Base class without user supplied AnalysisProcedure class."
|
||||
+ " import Error:"), e, flush=True)
|
||||
|
||||
##self.trigger_elog_entry.connect(self.receive_elog_notification)
|
||||
##self.trigger_hdf_save.connect(self.save_to_hdf)
|
||||
# self.trigger_elog_entry.connect(self.receive_elog_notification)
|
||||
# self.trigger_hdf_save.connect(self.save_to_hdf)
|
||||
|
||||
self.msg_severity_qcolor = {
|
||||
MsgSeverity.FATAL: QColor(
|
||||
@@ -566,6 +575,12 @@ class BaseWindow(QMainWindow):
|
||||
elif self.facility == Facility.HIPA:
|
||||
from pyqtacc.hipa.guiheader import GUIHeader
|
||||
from pyqtacc.hipa.sendeloghipa import QSendToELOG
|
||||
elif self.facility == Facility.PROSCAN:
|
||||
from pyqtacc.proscan.guiheader import GUIHeader
|
||||
from pyqtacc.proscan.sendelogproscan import QSendToELOG
|
||||
elif self.facility == Facility.ESS:
|
||||
from pyqtacc.ess.guiheader import GUIHeader
|
||||
from pyqtacc.ess.sendelogess import QSendToELOG
|
||||
|
||||
self.gui_header = GUIHeader(self, user_mode=self.user_mode,
|
||||
extended=extended)
|
||||
@@ -593,7 +608,6 @@ class BaseWindow(QMainWindow):
|
||||
self.show_log_message(MsgSeverity.INFO.name, _pymodule, _line(),
|
||||
"Application configured")
|
||||
|
||||
|
||||
def read_input_parameters(self):
|
||||
|
||||
for key, dictval in self.settings.data["Parameters"].items():
|
||||
@@ -637,7 +651,6 @@ class BaseWindow(QMainWindow):
|
||||
self.all_input_labels[key] = dictval["data"]["text"]
|
||||
#print(key, self.settings.data["Parameters"][key]["flag"])
|
||||
|
||||
|
||||
if "Expert" not in self.settings.data:
|
||||
return
|
||||
|
||||
@@ -682,7 +695,6 @@ class BaseWindow(QMainWindow):
|
||||
self.expert_labels[key] = dictval["data"]["text"]
|
||||
self.all_expert_labels[key] = dictval["data"]["text"]
|
||||
|
||||
|
||||
def init_toolbar(self):
|
||||
""" Prepare toolbar
|
||||
"""
|
||||
@@ -790,12 +802,19 @@ class BaseWindow(QMainWindow):
|
||||
exit_toolbar.addWidget(spacer_wgt)
|
||||
#_qsize = exit_toolbar.iconSize()
|
||||
#print("qsize", _qsize)
|
||||
true_list = [self.autopost_epics, self.autopost_hdf, self.autopost_elog]
|
||||
exit_toolbar.setIconSize(QSize(true_list.count(True)*30+10, 24))
|
||||
#exit_toolbar.setIconSize(_qsize)
|
||||
self.add_actions(exit_toolbar, (save_all_action, "Space", None, "Space",
|
||||
quit_action))
|
||||
true_list = [
|
||||
self.autopost_epics,
|
||||
self.autopost_hdf,
|
||||
self.autopost_elog]
|
||||
|
||||
if true_list.count(True) > 1:
|
||||
exit_toolbar.setIconSize(
|
||||
QSize(true_list.count(True) * 30 + 10, 24))
|
||||
# exit_toolbar.setIconSize(_qsize)
|
||||
self.add_actions(exit_toolbar, (
|
||||
save_all_action, "Space", None, "Space", quit_action))
|
||||
else:
|
||||
self.add_actions(exit_toolbar, (quit_action,))
|
||||
|
||||
def combine_save_icons(self): # epics=False, hdf=False, elog=False):
|
||||
|
||||
@@ -840,8 +859,8 @@ class BaseWindow(QMainWindow):
|
||||
painter.end()
|
||||
return combinedIcon
|
||||
|
||||
# Actions
|
||||
|
||||
################# Actions
|
||||
def add_actions(self, target, actions):
|
||||
""" Add to toolbar
|
||||
"""
|
||||
@@ -876,8 +895,6 @@ class BaseWindow(QMainWindow):
|
||||
action.setCheckable(True)
|
||||
return action
|
||||
|
||||
|
||||
|
||||
def verify_close_event(self):
|
||||
""" Overrides QMainWindow method
|
||||
"""
|
||||
@@ -1003,7 +1020,6 @@ class BaseWindow(QMainWindow):
|
||||
qdialog.setLayout(layout)
|
||||
qdialog.show()
|
||||
|
||||
|
||||
# def save_to_hdf_started(self):
|
||||
# QApplication.processEvents()
|
||||
# def save_to_hdf_finished(self):
|
||||
@@ -1028,14 +1044,12 @@ class BaseWindow(QMainWindow):
|
||||
# enable signal
|
||||
# self.gui_frame.autopost_save.blockSignals(False)
|
||||
|
||||
|
||||
def set_new_hdf_filename(self, time_in_seconds=None,
|
||||
reanalysis_time_in_seconds=None):
|
||||
|
||||
self.hdf_filename = (self.hdf_dest + self.add_date_to_path(
|
||||
time_in_seconds, reanalysis_time_in_seconds) + ".h5")
|
||||
|
||||
|
||||
def add_date_to_path(self, time_in_seconds=None,
|
||||
reanalysis_time_in_seconds=None):
|
||||
|
||||
@@ -1057,9 +1071,11 @@ class BaseWindow(QMainWindow):
|
||||
_month = when.strftime("%m")
|
||||
_day = when.strftime("%d")
|
||||
|
||||
if self.elog_add_date_to_dir:
|
||||
return str(_year + "/" + _month + "/" + _day + "/" + self.appname +
|
||||
"_" + _date_label)
|
||||
|
||||
else:
|
||||
return str(self.appname + "_" + _date_label)
|
||||
|
||||
def verify_save_to_hdf(self):
|
||||
""" To be called by user from save_to_hdf
|
||||
@@ -1091,7 +1107,6 @@ class BaseWindow(QMainWindow):
|
||||
QApplication.processEvents()
|
||||
return False
|
||||
|
||||
|
||||
if self.hdf_save_completed:
|
||||
_mess = "Data previously saved to hdf:\n{0}".format(
|
||||
self.hdf_filename)
|
||||
@@ -1102,7 +1117,6 @@ class BaseWindow(QMainWindow):
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def add_to_hdf(self, dataH5=None, proc=True, raw=False):
|
||||
""" Abstract method to be overwritten by user. Optional.
|
||||
"""
|
||||
@@ -1132,7 +1146,6 @@ class BaseWindow(QMainWindow):
|
||||
)
|
||||
QM.exec()
|
||||
|
||||
|
||||
def add_pvs_to_hdf(self, dataH5, top_group="experiment", pv_list=None,
|
||||
from_hdf=False):
|
||||
|
||||
@@ -1160,7 +1173,6 @@ class BaseWindow(QMainWindow):
|
||||
{})
|
||||
return isOK
|
||||
|
||||
|
||||
if from_hdf:
|
||||
return isOK
|
||||
|
||||
@@ -1186,16 +1198,19 @@ class BaseWindow(QMainWindow):
|
||||
MsgSeverity.WARN.name, _pymodule, _line(), _mess, {})
|
||||
return isOK
|
||||
|
||||
|
||||
|
||||
def add_general_to_hdf(self, dataH5):
|
||||
isOK = True
|
||||
user_dict = {}
|
||||
|
||||
user_dict['Comment'] = self.hdf_dialog.user_dict[
|
||||
'Comment'] if self.hdf_dialog is not None else str(
|
||||
"HDF file generated via Save All button")
|
||||
|
||||
#user_dict['Comment'] is prefilled in get_data in savehdf.py
|
||||
# user_dict['Comment'] = self.hdf_dialog.user_dict[
|
||||
# 'Comment'] if self.hdf_dialog is not None else str(
|
||||
# "HDF file generated via Save All button")
|
||||
#user_dict['Comment'] = self.hdf_dialog.comment.document().toPlainText()
|
||||
if self.hdf_user_dict:
|
||||
user_dict['Comment'] = self.hdf_user_dict['Comment']
|
||||
else:
|
||||
user_dict['Comment'] = "HDF file generated via Save All button"
|
||||
user_dict['Author'] = self.author
|
||||
user_dict['Application'] = self.pymodule
|
||||
user_dict['Version'] = self.appversion
|
||||
@@ -1233,13 +1248,12 @@ class BaseWindow(QMainWindow):
|
||||
MsgSeverity.WARN.name, _pymodule, _line(), _mess, {})
|
||||
return isOK
|
||||
|
||||
|
||||
@Slot()
|
||||
def save_to_hdf_dialog(self):
|
||||
""" This uses the widget interface to allow the user to enter
|
||||
additional meta-data
|
||||
"""
|
||||
|
||||
print("save_to_hdf_dialog==>", flush=True)
|
||||
if not self.verify_save_to_hdf():
|
||||
return False
|
||||
|
||||
@@ -1262,7 +1276,6 @@ class BaseWindow(QMainWindow):
|
||||
self.hdf_dialog = QSaveHDF(self, input_options=input_options,
|
||||
from_dialog=True)
|
||||
|
||||
|
||||
def verify_send_to_elog(self):
|
||||
|
||||
if self.analysis_thread is not None:
|
||||
@@ -1318,14 +1331,12 @@ class BaseWindow(QMainWindow):
|
||||
_attach_files = []
|
||||
_message = ""
|
||||
|
||||
|
||||
QSendToELOG(self, logbook=_logbook, categoryIdx=_category_idx,
|
||||
domainIdx=_domain_idx, sectionIdx=_section_idx,
|
||||
title=self.title, message=_message,
|
||||
attachFile=_attach_files)
|
||||
QApplication.processEvents()
|
||||
|
||||
|
||||
def initiate_cycling(self, pv_list=[]):
|
||||
if not pv_list:
|
||||
return False
|
||||
@@ -1394,7 +1405,6 @@ class BaseWindow(QMainWindow):
|
||||
qm.warning(self, "Set Optics", _mess, QMessageBox.Ok)
|
||||
break
|
||||
|
||||
|
||||
@Slot()
|
||||
def set_optics(self):
|
||||
""" Abstract method to be overwritten by user
|
||||
@@ -1417,7 +1427,6 @@ class BaseWindow(QMainWindow):
|
||||
)
|
||||
QM.exec()
|
||||
|
||||
|
||||
def verify_save_to_epics(self):
|
||||
""" To be called by user from save_to_epics
|
||||
"""
|
||||
@@ -1472,7 +1481,6 @@ class BaseWindow(QMainWindow):
|
||||
)
|
||||
QM.exec()
|
||||
|
||||
|
||||
def send_to_log_window(self, pv_list: list = [], status: int = 1,
|
||||
status_list: list = [], operation: str = 'set/get',
|
||||
pymodule=_pymodule, line: int = _line()):
|
||||
@@ -1492,11 +1500,9 @@ class BaseWindow(QMainWindow):
|
||||
"See Log window").format(ibad, len(status_list))
|
||||
self.statusbar.showMessage(_mess)
|
||||
|
||||
|
||||
def send_to_epics(self, pv_dict: dict = None, pv_names: list = None,
|
||||
pv_values: list = None) -> (int, list):
|
||||
|
||||
|
||||
if pv_dict is not None:
|
||||
pv_values = []
|
||||
pv_names = list(pv_dict.keys())
|
||||
@@ -1526,15 +1532,15 @@ class BaseWindow(QMainWindow):
|
||||
status = self.cyca.ICAFE_NORMAL
|
||||
status_list = []
|
||||
try:
|
||||
status, status_list = self.cafe.setCompoundList(pv_names, pv_values)
|
||||
except:
|
||||
status, status_list = self.cafe.setCompoundList(
|
||||
pv_names, pv_values)
|
||||
except BaseException:
|
||||
print("Exception raised in cafe.setCompoundList", flush=True)
|
||||
status = self.cyca.ECAFE_BADTYPE
|
||||
for pv, val in zip(pv_names, pv_values):
|
||||
print("pv/val", pv, val, flush=True)
|
||||
status_list.append(self.ECAFE_BADTYPE)
|
||||
|
||||
|
||||
if status != self.cyca.ICAFE_NORMAL:
|
||||
ibad = 0
|
||||
for _status, _pv in zip(status_list, pv_names):
|
||||
@@ -1636,7 +1642,7 @@ class BaseWindow(QMainWindow):
|
||||
self.screenshot_titles.clear()
|
||||
self.screenshot_items.clear()
|
||||
|
||||
############################### Init
|
||||
# Init
|
||||
def init_statusbar_wgt(self):
|
||||
""" Configure statusbar
|
||||
"""
|
||||
@@ -1733,9 +1739,9 @@ class BaseWindow(QMainWindow):
|
||||
# Fill all data from HDF file
|
||||
###hdf_all_data = self.load_hdf_file()
|
||||
|
||||
###if not hdf_all_data:
|
||||
### self.hdf_thread_finished()
|
||||
### return
|
||||
# if not hdf_all_data:
|
||||
# self.hdf_thread_finished()
|
||||
# return
|
||||
|
||||
self.hdf_thread = self.HDFThread(
|
||||
self, self.analysis_procedure, all_data=None) # =hdf_all_data
|
||||
@@ -1748,8 +1754,8 @@ class BaseWindow(QMainWindow):
|
||||
self.hdf_thread.start()
|
||||
QApplication.processEvents()
|
||||
|
||||
|
||||
# To be overloaded by user
|
||||
|
||||
def verify_analysis_preconditions(self):
|
||||
return True
|
||||
|
||||
@@ -1780,7 +1786,6 @@ class BaseWindow(QMainWindow):
|
||||
if not self.verify_analysis_preconditions():
|
||||
return
|
||||
|
||||
|
||||
self.analysis_thread = self.AnalysisThread(
|
||||
self, self.analysis_procedure, self.input_parameters)
|
||||
|
||||
@@ -1790,11 +1795,9 @@ class BaseWindow(QMainWindow):
|
||||
self.analysis_thread.started.connect(self.analysis_thread_started)
|
||||
self.analysis_thread.finished.connect(self.analysis_thread_finished)
|
||||
|
||||
|
||||
self.analysis_thread.start()
|
||||
QApplication.processEvents()
|
||||
|
||||
|
||||
@Slot()
|
||||
def analysis_thread_started(self):
|
||||
""" Change state of widgets when measuring
|
||||
@@ -1818,7 +1821,6 @@ class BaseWindow(QMainWindow):
|
||||
self.gui_frame.in_hdf_measurement_procedure()
|
||||
QApplication.processEvents()
|
||||
|
||||
|
||||
@Slot()
|
||||
def hdf_thread_finished(self):
|
||||
""" Reset widgets to intial pre-measurement state
|
||||
@@ -1827,7 +1829,6 @@ class BaseWindow(QMainWindow):
|
||||
QApplication.processEvents()
|
||||
#print("Thread Finished")
|
||||
|
||||
|
||||
@Slot(dict)
|
||||
def receive_analysis_results(self, all_dict):
|
||||
self.all_data = all_dict
|
||||
@@ -1842,7 +1843,7 @@ class BaseWindow(QMainWindow):
|
||||
try:
|
||||
results_data = all_dict['Processed data']['Results']
|
||||
self.gui_frame.send_to_results_output_wgt(results_data)
|
||||
except:
|
||||
except BaseException:
|
||||
pass
|
||||
|
||||
#print("IDX+++", self.gui_frame.central_tab_widget.indexOf('Emittance'), flush=True)
|
||||
@@ -1856,7 +1857,11 @@ class BaseWindow(QMainWindow):
|
||||
# for j in range(len(self.gui_frame.level1_tab_wgt)):
|
||||
j = self.gui_frame.central_tab_widget.currentIndex()
|
||||
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":
|
||||
self.gui_frame.level1_tab_wgt[j].setCurrentIndex(i)
|
||||
else:
|
||||
@@ -1864,14 +1869,20 @@ class BaseWindow(QMainWindow):
|
||||
else:
|
||||
|
||||
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":
|
||||
self.gui_frame.central_tab_widget.setCurrentIndex(i)
|
||||
else:
|
||||
pass
|
||||
|
||||
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":
|
||||
self.gui_frame.measurement_tab_wgt.setCurrentIndex(i)
|
||||
else:
|
||||
@@ -1898,7 +1909,6 @@ class BaseWindow(QMainWindow):
|
||||
# self.trigger_progressbar.emit(PROGRESS_THREAD_ABORTING)
|
||||
QApplication.processEvents()
|
||||
|
||||
|
||||
@Slot(str, str, int, str, dict)
|
||||
def receive_log_message(self, severity, module, line, message, options={}):
|
||||
'''Receive message from thread for routing to log window'''
|
||||
@@ -1977,7 +1987,6 @@ class BaseWindow(QMainWindow):
|
||||
QApplication.processEvents()
|
||||
time.sleep(0.0001)
|
||||
|
||||
|
||||
def initialize_application(self, appname=_appname, delay=None,
|
||||
facility=Facility.SwissFEL):
|
||||
"""
|
||||
@@ -1999,6 +2008,12 @@ class BaseWindow(QMainWindow):
|
||||
elif facility == Facility.HIPA:
|
||||
from pyqtacc.qrc_resources.facility.hipa.pyrcc5 import qrc_resources
|
||||
print("FACILITY HIPA")
|
||||
elif facility == Facility.PROSCAN:
|
||||
from pyqtacc.qrc_resources.facility.proscan.pyrcc5 import qrc_resources
|
||||
print("FACILITY PROSCAN")
|
||||
elif facility == Facility.ESS:
|
||||
from pyqtacc.qrc_resources.facility.ess.pyrcc5 import qrc_resources
|
||||
print("FACILITY ESS")
|
||||
else:
|
||||
print("Unknown Facility; assuming SLS")
|
||||
from pyqtacc.qrc_resources.facility.sls.pyrcc5 import qrc_resources
|
||||
@@ -2050,7 +2065,8 @@ class BaseWindow(QMainWindow):
|
||||
<p style='color:black; font-weight:bold;
|
||||
font-size:20px; margin-right:22px;'>
|
||||
This message will self-destruct in {1} seconds<br></p>
|
||||
""".format(appname, round(delay)), Qt.AlignCenter | Qt.AlignTop)
|
||||
""".format(appname, round(delay)),
|
||||
Qt.AlignmentFlag(Qt.AlignCenter | Qt.AlignTop))
|
||||
width = 860 + (len(appname) - 10) * 15
|
||||
height = 220
|
||||
self.splash_screen.resize(width, height)
|
||||
@@ -2059,12 +2075,10 @@ class BaseWindow(QMainWindow):
|
||||
#pSplashNotice = QCheckBox(self.splash_screen);
|
||||
# pSplashNotice.setChecked(Qt.Checked)
|
||||
|
||||
|
||||
self.splash_progressbar = QProgressBar(self.splash_screen)
|
||||
self.splash_timer = QTimer()
|
||||
self.splash_screen.show()
|
||||
|
||||
|
||||
# Custom progress bar stylesheet
|
||||
progressbar_stylesheet = """
|
||||
QProgressBar:horizontal {
|
||||
@@ -2104,7 +2118,8 @@ class BaseWindow(QMainWindow):
|
||||
{1:>2} second{2} remaining<br></p>
|
||||
""".format(self.splash_appname, seconds_remaining, sec_str)
|
||||
|
||||
self.splash_screen.showMessage(mess, Qt.AlignCenter|Qt.AlignTop)
|
||||
self.splash_screen.showMessage(
|
||||
mess, Qt.AlignmentFlag(Qt.AlignCenter | Qt.AlignTop))
|
||||
self.processEvents()
|
||||
#print(val, seconds_remaining)
|
||||
|
||||
@@ -2113,11 +2128,10 @@ class BaseWindow(QMainWindow):
|
||||
|
||||
return self.splash_screen
|
||||
|
||||
|
||||
def initialize_finished(self, myapp):
|
||||
self.splash_timer.stop()
|
||||
self.splash_progressbar.setValue(100)
|
||||
time.sleep(1.5)
|
||||
time.sleep(0.4)
|
||||
# app.processEvents()
|
||||
self.splash_screen.showMessage(
|
||||
"""
|
||||
@@ -2130,19 +2144,28 @@ class BaseWindow(QMainWindow):
|
||||
Ready....
|
||||
|
||||
<br></p>
|
||||
""".format(self.splash_appname), Qt.AlignCenter | Qt.AlignTop)
|
||||
""".format(self.splash_appname),
|
||||
Qt.AlignmentFlag(Qt.AlignCenter | Qt.AlignTop))
|
||||
self.splash_screen.finish(myapp)
|
||||
|
||||
|
||||
|
||||
def check_status_list(self, pymodule: str = _pymodule,
|
||||
operation: str = "channel access",
|
||||
pv_list: list = None, status_list: list = None,
|
||||
line: int = _line()):
|
||||
|
||||
if None in (pv_list, status_list):
|
||||
if pv_list is None:
|
||||
return
|
||||
|
||||
check_stat = False
|
||||
if status_list is None:
|
||||
check_stat = True
|
||||
elif None in status_list:
|
||||
check_stat = True
|
||||
if check_stat:
|
||||
for i, (pv, stat) in enumerate(zip(pv_list, status_list)):
|
||||
if stat is None:
|
||||
status_list[i] = self.cafe.getStatus(pv)
|
||||
|
||||
brk = ("------------------------------------------------------" +
|
||||
"------------------------------------------------------")
|
||||
self.trigger_log_message.emit(
|
||||
@@ -2151,7 +2174,7 @@ class BaseWindow(QMainWindow):
|
||||
options = {}
|
||||
|
||||
for i, (pv, stat) in enumerate(zip(pv_list, status_list)):
|
||||
if stat == self.cyca.ICAFE_NORMAL:
|
||||
if stat != self.cyca.ICAFE_NORMAL:
|
||||
mess = "Error in '{0}' for element [{1}], {2}.".format(
|
||||
operation, i, pv)
|
||||
options['statusCode'] = (
|
||||
@@ -2170,14 +2193,17 @@ class BaseWindow(QMainWindow):
|
||||
self.trigger_log_message.emit(
|
||||
MsgSeverity.INFO.name, pymodule, line, mess, {})
|
||||
|
||||
return status_list
|
||||
|
||||
def check_status(self, pymodule: str = _pymodule,
|
||||
operation: str = "channel access",
|
||||
pv: str = None, stat: int = None,
|
||||
line: int = _line()):
|
||||
|
||||
if None in (pv, status):
|
||||
if not pv:
|
||||
return
|
||||
if stat is None:
|
||||
stat = self.cafe.getStatus(pv)
|
||||
|
||||
if stat != self.cyca.ICAFE_NORMAL:
|
||||
mess = "Error in '{0}' for {1}.".format(operation, pv)
|
||||
@@ -2188,3 +2214,5 @@ class BaseWindow(QMainWindow):
|
||||
options['statusInfo'] = self.cafe.getStatusInfo(stat)
|
||||
self.trigger_log_message.emit(
|
||||
MsgSeverity.WARN.name, pymodule, line, mess, options)
|
||||
|
||||
return stat
|
||||
|
||||
@@ -19,6 +19,8 @@ class Facility(IntEnum):
|
||||
SwissFEL = 1
|
||||
SLS = 2
|
||||
HIPA = 3
|
||||
PROSCAN = 4
|
||||
ESS = 5
|
||||
|
||||
class MsgSeverity(IntEnum):
|
||||
""" For use with message logger
|
||||
|
||||
895
guiframe.py
895
guiframe.py
File diff suppressed because it is too large
Load Diff
@@ -38,7 +38,6 @@ class QSaveHDF(QDialog):
|
||||
self.user_dict = {}
|
||||
self.user_dict['Comment'] = None
|
||||
#self.file_name = None
|
||||
|
||||
#self.excluded_input = ['Year', 'Month', 'Date']
|
||||
|
||||
if 'Time in seconds' in input_options.keys():
|
||||
@@ -244,6 +243,7 @@ class QSaveHDF(QDialog):
|
||||
|
||||
def save(self):
|
||||
self.get_data()
|
||||
self.parent.hdf_user_dict = self.user_dict
|
||||
self.parent.hdf_filename = self.user_dict['Destination']
|
||||
self.parent.save_to_hdf(from_dialog=self.from_dialog)
|
||||
self.close()
|
||||
|
||||
13
sendelog.py
13
sendelog.py
@@ -9,22 +9,13 @@ from qtpy.QtWidgets import (QComboBox, QDialog, QFileDialog, QHBoxLayout,
|
||||
QVBoxLayout)
|
||||
|
||||
import elog # https://github.com/paulscherrerinstitute/py_elog
|
||||
from pyqtacc.bdbase.enumkind import MsgSeverity
|
||||
from apps4ops.bdbase.enumkind import MsgSeverity
|
||||
from apps4ops.bdbase.utils import _line
|
||||
|
||||
_version = "1.0.0"
|
||||
_pymodule = os.path.basename(__file__)
|
||||
_appname, _appext = _pymodule.split(".")
|
||||
|
||||
def _line():
|
||||
"""Macro to return the current line number.
|
||||
|
||||
The current line number within the file is used when
|
||||
reporting messages to the message logging window.
|
||||
|
||||
Returns:
|
||||
int: Current line number.
|
||||
"""
|
||||
return inspect.currentframe().f_back.f_lineno
|
||||
|
||||
class QSendToELOG(QDialog):
|
||||
""" Graphical interface to elog
|
||||
|
||||
@@ -9,22 +9,14 @@ from qtpy.QtWidgets import (
|
||||
QLineEdit, QPushButton, QTextEdit, QVBoxLayout)
|
||||
|
||||
import elog # https://github.com/paulscherrerinstitute/py_elog
|
||||
from pyqtacc.bdbase.enumkind import MsgSeverity
|
||||
|
||||
from apps4ops.bdbase.enumkind import MsgSeverity
|
||||
from apps4ops.bdbase.utils import _line
|
||||
|
||||
_version = "1.0.0"
|
||||
_pymodule = os.path.basename(__file__)
|
||||
_appname, _appext = _pymodule.split(".")
|
||||
|
||||
def _line():
|
||||
"""Macro to return the current line number.
|
||||
|
||||
The current line number within the file is used when
|
||||
reporting messages to the message logging window.
|
||||
|
||||
Returns:
|
||||
int: Current line number.
|
||||
"""
|
||||
return inspect.currentframe().f_back.f_lineno
|
||||
|
||||
class QSendToELOGFrame(QDialog):
|
||||
""" Graphical interface to elog
|
||||
|
||||
32
setup_version
Normal file
32
setup_version
Normal file
@@ -0,0 +1,32 @@
|
||||
#to be executed from top directory
|
||||
#create a directory with version number given below.
|
||||
mkdir -p v1.7.0
|
||||
cd v1.7.0
|
||||
mkdir -p apps4ops
|
||||
mkdir -p caqtwidgets
|
||||
mkdir -p common
|
||||
ln -s apps4ops pyqtacc
|
||||
cd apps4ops
|
||||
mkdir -p bdbase
|
||||
mkdir -p qrc_resources
|
||||
mkdir -p sf
|
||||
mkdir -p sls
|
||||
mkdir -p hipa
|
||||
cd bdbase
|
||||
git clone git@gitlab.psi.ch:pyqtacc/bdbase.git .
|
||||
cd ../qrc_resources
|
||||
git clone git@gitlab.psi.ch:pyqtacc/qrc_resources.git .
|
||||
cd ../sf
|
||||
git clone git@gitlab.psi.ch:pyqtacc/sf.git .
|
||||
cd ../sls
|
||||
git clone git@gitlab.psi.ch:pyqtacc/sls.git .
|
||||
cd ../hipa
|
||||
git clone git@gitlab.psi.ch:pyqtacc/hipa.git .
|
||||
cd ../../
|
||||
mkdir -p common
|
||||
cd common
|
||||
git clone git@gitlab.psi.ch:pyqtacc/common.git .
|
||||
cd ../
|
||||
cd caqtwidgets
|
||||
git clone git@gitlab.psi.ch:cafe/caqtwidgets.git .
|
||||
cd ../../
|
||||
12
utils.py
12
utils.py
@@ -10,3 +10,15 @@ def _line():
|
||||
int: Current line number.
|
||||
"""
|
||||
return currentframe().f_back.f_lineno
|
||||
|
||||
|
||||
def line_no():
|
||||
"""Macro to return the current line number.
|
||||
|
||||
The current line number within the file is used when
|
||||
reporting messages to the message logging window.
|
||||
|
||||
Returns:
|
||||
int: Current line number.
|
||||
"""
|
||||
return currentframe().f_back.f_lineno
|
||||
|
||||
Reference in New Issue
Block a user