|
|
@@ -54,9 +54,29 @@ class AppGui(QWidget):
|
|
|
|
self.send_to_log_window = self.parent.send_to_log_window
|
|
|
|
self.send_to_log_window = self.parent.send_to_log_window
|
|
|
|
self.show_log_message = self.parent.show_log_message
|
|
|
|
self.show_log_message = self.parent.show_log_message
|
|
|
|
self.statusbar = self.parent.statusbar
|
|
|
|
self.statusbar = self.parent.statusbar
|
|
|
|
|
|
|
|
self.settings = self.parent.settings
|
|
|
|
|
|
|
|
|
|
|
|
self.gui_frame = self.parent.gui_frame
|
|
|
|
self.gui_frame = self.parent.gui_frame
|
|
|
|
self.gui_header = self.parent.gui_header
|
|
|
|
self.gui_header = self.parent.gui_header
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.simple_standby = None
|
|
|
|
|
|
|
|
self.simple_awake = None
|
|
|
|
|
|
|
|
self.simple_status = None
|
|
|
|
|
|
|
|
self.simple_groupbox = None
|
|
|
|
|
|
|
|
self.groupbox_awake_sss = self.settings.data[
|
|
|
|
|
|
|
|
'statusStyleSheet']['awake-qgroupbox']
|
|
|
|
|
|
|
|
self.groupbox_standby_sss = self.settings.data[
|
|
|
|
|
|
|
|
'statusStyleSheet']['standby-qgroupbox']
|
|
|
|
|
|
|
|
self.label_awake_sss = self.settings.data[
|
|
|
|
|
|
|
|
'statusStyleSheet']['awake-qlabel']
|
|
|
|
|
|
|
|
self.label_standby_sss = self.settings.data[
|
|
|
|
|
|
|
|
'statusStyleSheet']['standby-qlabel']
|
|
|
|
|
|
|
|
self.awake_text = self.settings.data[
|
|
|
|
|
|
|
|
'statusStyleSheet']['awake-text']
|
|
|
|
|
|
|
|
self.standby_text = self.settings.data[
|
|
|
|
|
|
|
|
'statusStyleSheet']['standby-text']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.font_gui = self.parent.gui_frame.font_gui
|
|
|
|
self.font_gui = self.parent.gui_frame.font_gui
|
|
|
|
self.input_parameters = self.parent.input_parameters
|
|
|
|
self.input_parameters = self.parent.input_parameters
|
|
|
|
self.input_labels = self.parent.input_labels
|
|
|
|
self.input_labels = self.parent.input_labels
|
|
|
@@ -74,12 +94,16 @@ class AppGui(QWidget):
|
|
|
|
self.gui_frame.central_tab_widget.tabBar().setTabText(1, "IOC")
|
|
|
|
self.gui_frame.central_tab_widget.tabBar().setTabText(1, "IOC")
|
|
|
|
|
|
|
|
|
|
|
|
self.expert_labels = self.parent.expert_labels
|
|
|
|
self.expert_labels = self.parent.expert_labels
|
|
|
|
self.settings = self.parent.settings
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.lock = threading.Lock()
|
|
|
|
self.lock = threading.Lock()
|
|
|
|
self.timer = QTimer()
|
|
|
|
self.timer = QTimer()
|
|
|
|
self.timer.setSingleShot(True)
|
|
|
|
self.timer.setSingleShot(True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.timer_blink = QTimer()
|
|
|
|
|
|
|
|
self.timer_blink.setSingleShot(True)
|
|
|
|
|
|
|
|
self.timer_blink.count = 0
|
|
|
|
|
|
|
|
|
|
|
|
self.obj_to_upper = bool(random.randint(1, 10) > 3)
|
|
|
|
self.obj_to_upper = bool(random.randint(1, 10) > 3)
|
|
|
|
|
|
|
|
|
|
|
|
self.table_sol_dict = {}
|
|
|
|
self.table_sol_dict = {}
|
|
|
@@ -113,6 +137,8 @@ class AppGui(QWidget):
|
|
|
|
for sector in self.settings.data["header"][idx:]:
|
|
|
|
for sector in self.settings.data["header"][idx:]:
|
|
|
|
self.sectorI_dict[sector] = 0
|
|
|
|
self.sectorI_dict[sector] = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.simple_sector_list = self.settings.data["header"][idx:]
|
|
|
|
|
|
|
|
|
|
|
|
self.sector_designated_magnet_standby_dict = {}
|
|
|
|
self.sector_designated_magnet_standby_dict = {}
|
|
|
|
self.sector_designated_magnet_values_dict = {}
|
|
|
|
self.sector_designated_magnet_values_dict = {}
|
|
|
|
|
|
|
|
|
|
|
@@ -126,14 +152,34 @@ class AppGui(QWidget):
|
|
|
|
|
|
|
|
|
|
|
|
print(sector, self.sector_designated_magnet_standby_dict[sector])
|
|
|
|
print(sector, self.sector_designated_magnet_standby_dict[sector])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_wgt = self.group_sector_status()
|
|
|
|
|
|
|
|
self.gui_frame.measurement_layout.addWidget(
|
|
|
|
|
|
|
|
status_wgt, 2, 0, 2, 1, alignment=Qt.AlignTop) # | Qt.AlignHCenter)
|
|
|
|
|
|
|
|
|
|
|
|
wgt = self.group_sector_qtabwidget()
|
|
|
|
wgt = self.group_sector_qtabwidget()
|
|
|
|
self.gui_frame.measurement_layout.addWidget(
|
|
|
|
self.gui_frame.measurement_layout.addWidget(
|
|
|
|
wgt, 0, 1, 6, 3, alignment=Qt.AlignTop)
|
|
|
|
wgt, 0, 1, 6, 3, alignment=Qt.AlignTop)
|
|
|
|
|
|
|
|
|
|
|
|
status_wgt = self.group_sector_status()
|
|
|
|
self.groupbox_simple_mode = self.group_simple_mode()
|
|
|
|
|
|
|
|
qgridlo = QGridLayout()
|
|
|
|
|
|
|
|
qgridlo.setContentsMargins(5, 30, 5, 10)
|
|
|
|
|
|
|
|
qgridlo.addWidget(self.groupbox_simple_mode, 0, 0, 1, 1, Qt.AlignCenter)
|
|
|
|
|
|
|
|
qgridlo.setAlignment(Qt.AlignTop | Qt.AlignHCenter)
|
|
|
|
|
|
|
|
qgridlo.setVerticalSpacing(10)
|
|
|
|
|
|
|
|
qwgt = QWidget()
|
|
|
|
|
|
|
|
qwgt.setLayout(qgridlo)
|
|
|
|
|
|
|
|
qwgt.setFixedWidth(1400)
|
|
|
|
|
|
|
|
qwgt.setFixedHeight(800)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.gui_frame.central_tab_widget.insertTab(0, qwgt, "Skin")
|
|
|
|
|
|
|
|
self.gui_frame.central_tab_widget.setCurrentIndex(0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.gui_frame.measurement_layout.addWidget(
|
|
|
|
|
|
|
|
status_wgt, 2, 0, 2, 1, alignment=Qt.AlignTop) # | Qt.AlignHCenter)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.gui_frame.results_wgt.setFixedWidth(1500)
|
|
|
|
self.gui_frame.results_wgt.setFixedWidth(1500)
|
|
|
@@ -202,6 +248,7 @@ class AppGui(QWidget):
|
|
|
|
|
|
|
|
|
|
|
|
for sector in sector_line:
|
|
|
|
for sector in sector_line:
|
|
|
|
beam_req_flag = False
|
|
|
|
beam_req_flag = False
|
|
|
|
|
|
|
|
idx = self.simple_sector_list.index(sector)
|
|
|
|
|
|
|
|
|
|
|
|
if sector == "UCN":
|
|
|
|
if sector == "UCN":
|
|
|
|
beam_req_flag = self.beam_req_running #is_beam_req_running()
|
|
|
|
beam_req_flag = self.beam_req_running #is_beam_req_running()
|
|
|
@@ -233,15 +280,20 @@ class AppGui(QWidget):
|
|
|
|
sector].standby_value_button.isEnabled():
|
|
|
|
sector].standby_value_button.isEnabled():
|
|
|
|
self.table_sol_dict[
|
|
|
|
self.table_sol_dict[
|
|
|
|
sector].standby_value_button.setEnabled(False)
|
|
|
|
sector].standby_value_button.setEnabled(False)
|
|
|
|
|
|
|
|
if self.simple_standby:
|
|
|
|
|
|
|
|
self.simple_standby[idx].setEnabled(False)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if not self.table_sol_dict[
|
|
|
|
if not self.table_sol_dict[
|
|
|
|
sector].standby_value_button.isEnabled():
|
|
|
|
sector].standby_value_button.isEnabled():
|
|
|
|
self.table_sol_dict[
|
|
|
|
self.table_sol_dict[
|
|
|
|
sector].standby_value_button.setEnabled(True)
|
|
|
|
sector].standby_value_button.setEnabled(True)
|
|
|
|
|
|
|
|
if self.simple_standby:
|
|
|
|
|
|
|
|
self.simple_standby[idx].setEnabled(True)
|
|
|
|
|
|
|
|
|
|
|
|
def enable_disable_end(sect, sector_line, value):
|
|
|
|
def enable_disable_end(sect, sector_line, value):
|
|
|
|
self.sectorI_dict[sect] = value
|
|
|
|
self.sectorI_dict[sect] = value
|
|
|
|
for sector in sector_line:
|
|
|
|
for sector in sector_line:
|
|
|
|
|
|
|
|
idx = self.simple_sector_list.index(sector)
|
|
|
|
# if self.sectorI_dict['UCN'] > self.I_min or self.sectorI_dict[
|
|
|
|
# if self.sectorI_dict['UCN'] > self.I_min or self.sectorI_dict[
|
|
|
|
# 'SINQ'] > self.I_min:
|
|
|
|
# 'SINQ'] > self.I_min:
|
|
|
|
if self.sectorI_dict[sector] > self.I_min:
|
|
|
|
if self.sectorI_dict[sector] > self.I_min:
|
|
|
@@ -249,18 +301,23 @@ class AppGui(QWidget):
|
|
|
|
sector].standby_value_button.isEnabled():
|
|
|
|
sector].standby_value_button.isEnabled():
|
|
|
|
self.table_sol_dict[
|
|
|
|
self.table_sol_dict[
|
|
|
|
sector].standby_value_button.setEnabled(False)
|
|
|
|
sector].standby_value_button.setEnabled(False)
|
|
|
|
|
|
|
|
if self.simple_standby:
|
|
|
|
|
|
|
|
self.simple_standby[idx].setEnabled(False)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if not self.table_sol_dict[
|
|
|
|
if not self.table_sol_dict[
|
|
|
|
sector].standby_value_button.isEnabled():
|
|
|
|
sector].standby_value_button.isEnabled():
|
|
|
|
self.table_sol_dict[
|
|
|
|
self.table_sol_dict[
|
|
|
|
sector].standby_value_button.setEnabled(True)
|
|
|
|
sector].standby_value_button.setEnabled(True)
|
|
|
|
|
|
|
|
if self.simple_standby:
|
|
|
|
|
|
|
|
self.simple_standby[idx].setEnabled(True)
|
|
|
|
|
|
|
|
|
|
|
|
def enable_disable_pk(sect, sector_line, value):
|
|
|
|
def enable_disable_pk(sect, sector_line, value):
|
|
|
|
self.sectorI_dict[sect] = value
|
|
|
|
self.sectorI_dict[sect] = value
|
|
|
|
|
|
|
|
self.sectorI_dict["IW2"] = self.cafe.getCache("MXC2:IST:2")
|
|
|
|
#print("==>sector firing", sect, "with value", value)
|
|
|
|
#print("==>sector firing", sect, "with value", value)
|
|
|
|
|
|
|
|
|
|
|
|
for sector in sector_line:
|
|
|
|
for sector in sector_line:
|
|
|
|
|
|
|
|
idx = self.simple_sector_list.index(sector)
|
|
|
|
#print("sector", sector, "in line", sector_line,
|
|
|
|
#print("sector", sector, "in line", sector_line,
|
|
|
|
# "has value", self.sectorI_dict[sector]
|
|
|
|
# "has value", self.sectorI_dict[sector]
|
|
|
|
#)
|
|
|
|
#)
|
|
|
@@ -271,11 +328,15 @@ class AppGui(QWidget):
|
|
|
|
sector].standby_value_button.isEnabled():
|
|
|
|
sector].standby_value_button.isEnabled():
|
|
|
|
self.table_sol_dict[
|
|
|
|
self.table_sol_dict[
|
|
|
|
sector].standby_value_button.setEnabled(False)
|
|
|
|
sector].standby_value_button.setEnabled(False)
|
|
|
|
|
|
|
|
if self.simple_standby:
|
|
|
|
|
|
|
|
self.simple_standby[idx].setEnabled(False)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if not self.table_sol_dict[
|
|
|
|
if not self.table_sol_dict[
|
|
|
|
sector].standby_value_button.isEnabled():
|
|
|
|
sector].standby_value_button.isEnabled():
|
|
|
|
self.table_sol_dict[
|
|
|
|
self.table_sol_dict[
|
|
|
|
sector].standby_value_button.setEnabled(True)
|
|
|
|
sector].standby_value_button.setEnabled(True)
|
|
|
|
|
|
|
|
if self.simple_standby:
|
|
|
|
|
|
|
|
self.simple_standby[idx].setEnabled(True)
|
|
|
|
|
|
|
|
|
|
|
|
def receive_ucnq_update(value, status, alarm_severity):
|
|
|
|
def receive_ucnq_update(value, status, alarm_severity):
|
|
|
|
del status, alarm_severity
|
|
|
|
del status, alarm_severity
|
|
|
@@ -414,8 +475,42 @@ class AppGui(QWidget):
|
|
|
|
pv_standby_dict[pv_magnet] = standby_value
|
|
|
|
pv_standby_dict[pv_magnet] = standby_value
|
|
|
|
return pv_standby_dict
|
|
|
|
return pv_standby_dict
|
|
|
|
|
|
|
|
|
|
|
|
def is_sector_standby(self, sector, pv_name, value):
|
|
|
|
def is_sector_standby(self, sector, pv_name=None, value=None):
|
|
|
|
self.sector_designated_magnet_values_dict[sector][pv_name] = value
|
|
|
|
|
|
|
|
|
|
|
|
idx = self.simple_sector_list.index(sector)
|
|
|
|
|
|
|
|
text_color = self.settings.data[sector]["color"]
|
|
|
|
|
|
|
|
text_color_str = f'color: {text_color};'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def paint_awake():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sss = ('QGroupBox {background-color:#ffe87c; font-weight: bold; ' +
|
|
|
|
|
|
|
|
text_color_str + '}')
|
|
|
|
|
|
|
|
self.simple_groupbox[idx].setStyleSheet(sss)
|
|
|
|
|
|
|
|
self.simple_status[idx].setStyleSheet(
|
|
|
|
|
|
|
|
'QLabel{color:black; font-weight: bold;}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.simple_groupbox[idx].setStyleSheet(sss) #self.groupbox_awake_sss)
|
|
|
|
|
|
|
|
self.simple_status[idx].setText('Status: AWAKE')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.status_dict[sector].setStyleSheet(self.label_awake_sss)
|
|
|
|
|
|
|
|
self.status_dict[sector].setText(self.awake_text) #self.settings.data['statusStyleSheet']['awake-text'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def paint_asleep():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sss = ('QGroupBox {background-color:#546bab; font-weight: bold; ' +
|
|
|
|
|
|
|
|
text_color_str + '}')
|
|
|
|
|
|
|
|
self.simple_groupbox[idx].setStyleSheet(sss)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.simple_status[idx].setStyleSheet(
|
|
|
|
|
|
|
|
'QLabel{color:white; font-weight: bold;}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.simple_groupbox[idx].setStyleSheet(sss) #self.groupbox_standby_sss)
|
|
|
|
|
|
|
|
self.simple_status[idx].setText('Status: STANDBY')
|
|
|
|
|
|
|
|
self.status_dict[sector].setStyleSheet(self.label_standby_sss)
|
|
|
|
|
|
|
|
self.status_dict[sector].setText(self.standby_text) #self.settings.data['statusStyleSheet']['standby-text'])
|
|
|
|
|
|
|
|
if value and pv_name:
|
|
|
|
|
|
|
|
self.sector_designated_magnet_values_dict[sector][pv_name] = value
|
|
|
|
#print(self.sector_designated_magnet_values_dict[sector], flush=True)
|
|
|
|
#print(self.sector_designated_magnet_values_dict[sector], flush=True)
|
|
|
|
is_standby = True
|
|
|
|
is_standby = True
|
|
|
|
for pv in self.sector_designated_magnet_values_dict[sector]:
|
|
|
|
for pv in self.sector_designated_magnet_values_dict[sector]:
|
|
|
@@ -445,6 +540,8 @@ class AppGui(QWidget):
|
|
|
|
):
|
|
|
|
):
|
|
|
|
self.table_pwr_dict[sector].init_value_button.setEnabled(
|
|
|
|
self.table_pwr_dict[sector].init_value_button.setEnabled(
|
|
|
|
True)
|
|
|
|
True)
|
|
|
|
|
|
|
|
if self.simple_awake:
|
|
|
|
|
|
|
|
paint_awake()
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if self.table_sol_dict[sector].init_value_button.isEnabled():
|
|
|
|
if self.table_sol_dict[sector].init_value_button.isEnabled():
|
|
|
|
self.table_sol_dict[sector].init_value_button.setEnabled(
|
|
|
|
self.table_sol_dict[sector].init_value_button.setEnabled(
|
|
|
@@ -452,7 +549,10 @@ class AppGui(QWidget):
|
|
|
|
if self.table_pwr_dict[sector].init_value_button.isEnabled():
|
|
|
|
if self.table_pwr_dict[sector].init_value_button.isEnabled():
|
|
|
|
self.table_pwr_dict[sector].init_value_button.setEnabled(
|
|
|
|
self.table_pwr_dict[sector].init_value_button.setEnabled(
|
|
|
|
False)
|
|
|
|
False)
|
|
|
|
|
|
|
|
if self.simple_standby:
|
|
|
|
|
|
|
|
paint_asleep()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return is_standby
|
|
|
|
|
|
|
|
|
|
|
|
@Slot(float, int, int)
|
|
|
|
@Slot(float, int, int)
|
|
|
|
def designated_magnet_cb(self, value, status, alarm_severity):
|
|
|
|
def designated_magnet_cb(self, value, status, alarm_severity):
|
|
|
@@ -494,6 +594,12 @@ class AppGui(QWidget):
|
|
|
|
qsa.setFont(f)
|
|
|
|
qsa.setFont(f)
|
|
|
|
qsa.setAlignment(Qt.AlignCenter)
|
|
|
|
qsa.setAlignment(Qt.AlignCenter)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qstat = QLabel("Status \n ")
|
|
|
|
|
|
|
|
f = qstat.font()
|
|
|
|
|
|
|
|
f.setPixelSize(13)
|
|
|
|
|
|
|
|
qstat.setFont(f)
|
|
|
|
|
|
|
|
qstat.setAlignment(Qt.AlignCenter)
|
|
|
|
|
|
|
|
|
|
|
|
qti = QLabel("Time in \nSaving Mode")
|
|
|
|
qti = QLabel("Time in \nSaving Mode")
|
|
|
|
f = qti.font()
|
|
|
|
f = qti.font()
|
|
|
|
f.setPixelSize(13)
|
|
|
|
f.setPixelSize(13)
|
|
|
@@ -508,22 +614,29 @@ class AppGui(QWidget):
|
|
|
|
|
|
|
|
|
|
|
|
qgrid.addWidget(qlp, 0, 2, 1, 1)
|
|
|
|
qgrid.addWidget(qlp, 0, 2, 1, 1)
|
|
|
|
qgrid.addWidget(qsa, 0, 3, 1, 1)
|
|
|
|
qgrid.addWidget(qsa, 0, 3, 1, 1)
|
|
|
|
qgrid.addWidget(qti, 0, 4, 1, 1)
|
|
|
|
qgrid.addWidget(qstat, 0, 4, 1, 1)
|
|
|
|
qgrid.addWidget(qtotsav, 0, 5, 1, 1)
|
|
|
|
qgrid.addWidget(qti, 0, 5, 1, 1)
|
|
|
|
|
|
|
|
qgrid.addWidget(qtotsav, 0, 6, 1, 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.status_dict = {}
|
|
|
|
|
|
|
|
|
|
|
|
for i, sector in enumerate(self.settings.data["header"][idx:]):
|
|
|
|
for i, sector in enumerate(self.settings.data["header"][idx:]):
|
|
|
|
a, b, c, d, e, f = self.sector_status(sector)
|
|
|
|
a, b, c, d, e, f = self.sector_status(sector)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.status_dict[sector] = QLabel('')
|
|
|
|
|
|
|
|
|
|
|
|
a.setContentsMargins(2, 0, 0, 0)
|
|
|
|
a.setContentsMargins(2, 0, 0, 0)
|
|
|
|
qgrid.addWidget(a, i + 1, 0, 1, 1)
|
|
|
|
qgrid.addWidget(a, i + 1, 0, 1, 1)
|
|
|
|
qgrid.addWidget(b, i + 1, 1, 1, 1)
|
|
|
|
qgrid.addWidget(b, i + 1, 1, 1, 1)
|
|
|
|
qgrid.addWidget(c, i + 1, 2, 1, 1)
|
|
|
|
qgrid.addWidget(c, i + 1, 2, 1, 1)
|
|
|
|
qgrid.addWidget(d, i + 1, 3, 1, 1)
|
|
|
|
qgrid.addWidget(d, i + 1, 3, 1, 1)
|
|
|
|
qgrid.addWidget(e, i + 1, 4, 1, 1)
|
|
|
|
qgrid.addWidget(self.status_dict[sector], i + 1, 4, 1, 1)
|
|
|
|
qgrid.addWidget(f, i + 1, 5, 1, 1)
|
|
|
|
qgrid.addWidget(e, i + 1, 5, 1, 1)
|
|
|
|
|
|
|
|
qgrid.addWidget(f, i + 1, 6, 1, 1)
|
|
|
|
qh_line = QHLine()
|
|
|
|
qh_line = QHLine()
|
|
|
|
qh_line.setFixedHeight(10)
|
|
|
|
qh_line.setFixedHeight(10)
|
|
|
|
row = qgrid.rowCount()
|
|
|
|
row = qgrid.rowCount()
|
|
|
|
qgrid.addWidget(qh_line, row, 1, 1, 5)
|
|
|
|
qgrid.addWidget(qh_line, row, 1, 1, 7)
|
|
|
|
#qgrid.setRowMinimumHeight(row, 60)
|
|
|
|
#qgrid.setRowMinimumHeight(row, 60)
|
|
|
|
|
|
|
|
|
|
|
|
qtot = QLabel("Total:")
|
|
|
|
qtot = QLabel("Total:")
|
|
|
@@ -538,11 +651,11 @@ class AppGui(QWidget):
|
|
|
|
CAQLineEdit(self, pv_name="ZHIPA-HUSH:TOTPWR", show_units=True),
|
|
|
|
CAQLineEdit(self, pv_name="ZHIPA-HUSH:TOTPWR", show_units=True),
|
|
|
|
row + 1, 2, 1, 1)
|
|
|
|
row + 1, 2, 1, 1)
|
|
|
|
qgrid.addWidget(
|
|
|
|
qgrid.addWidget(
|
|
|
|
CAQLineEdit(self, pv_name="ZHIPA-HUSH:LASTSAVE", show_units=False),
|
|
|
|
CAQLineEdit(self, pv_name="ZHIPA-HUSH:LASTSAVE", show_units=True),
|
|
|
|
row + 1, 3, 1, 1)
|
|
|
|
row + 1, 3, 1, 2)
|
|
|
|
qgrid.addWidget(
|
|
|
|
qgrid.addWidget(
|
|
|
|
CAQLineEdit(self, pv_name="ZHIPA-HUSH:TOTSAVE", show_units=False),
|
|
|
|
CAQLineEdit(self, pv_name="ZHIPA-HUSH:TOTSAVE", show_units=True),
|
|
|
|
row + 1, 5, 1, 1)
|
|
|
|
row + 1, 6, 1, 2)
|
|
|
|
|
|
|
|
|
|
|
|
qgrid.setContentsMargins(9, 20, 9, 9)
|
|
|
|
qgrid.setContentsMargins(9, 20, 9, 9)
|
|
|
|
|
|
|
|
|
|
|
@@ -550,7 +663,7 @@ class AppGui(QWidget):
|
|
|
|
qw.setContentsMargins(9, 9, 9, 9)
|
|
|
|
qw.setContentsMargins(9, 9, 9, 9)
|
|
|
|
qw.setObjectName("OUTER")
|
|
|
|
qw.setObjectName("OUTER")
|
|
|
|
qw.setLayout(qgrid)
|
|
|
|
qw.setLayout(qgrid)
|
|
|
|
qw.setFixedWidth(496) # 480
|
|
|
|
qw.setFixedWidth(596) # 496
|
|
|
|
qw.setFixedHeight(346) # 480
|
|
|
|
qw.setFixedHeight(346) # 480
|
|
|
|
|
|
|
|
|
|
|
|
return qw
|
|
|
|
return qw
|
|
|
@@ -644,6 +757,7 @@ class AppGui(QWidget):
|
|
|
|
sector_wgt_dict = {}
|
|
|
|
sector_wgt_dict = {}
|
|
|
|
sector_wgt_dict["INJ2"] = self.ca_table_rf_widget(sector="INJ2")
|
|
|
|
sector_wgt_dict["INJ2"] = self.ca_table_rf_widget(sector="INJ2")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for sector in self.settings.data["header"][idx:]:
|
|
|
|
for sector in self.settings.data["header"][idx:]:
|
|
|
|
sector_wgt_dict[sector] = self.ca_table_sector_widget(
|
|
|
|
sector_wgt_dict[sector] = self.ca_table_sector_widget(
|
|
|
|
sector=sector)
|
|
|
|
sector=sector)
|
|
|
@@ -789,7 +903,7 @@ class AppGui(QWidget):
|
|
|
|
if sector == "UCN":
|
|
|
|
if sector == "UCN":
|
|
|
|
write_to_restore_ucn()
|
|
|
|
write_to_restore_ucn()
|
|
|
|
|
|
|
|
|
|
|
|
QApplication.processEvents(QEventLoop.AllEvents, 1)
|
|
|
|
#QApplication.processEvents() #QEventLoop.AllEvents, 1)
|
|
|
|
|
|
|
|
|
|
|
|
# Do NOT do updates if in standby mode!
|
|
|
|
# Do NOT do updates if in standby mode!
|
|
|
|
# Update button is disabled when in standby
|
|
|
|
# Update button is disabled when in standby
|
|
|
@@ -798,6 +912,9 @@ class AppGui(QWidget):
|
|
|
|
# updates of SOL also update PWR, and vice-versa
|
|
|
|
# updates of SOL also update PWR, and vice-versa
|
|
|
|
# Do not click if already on standby!!
|
|
|
|
# Do not click if already on standby!!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print(f'on_sector_standby: TARGET = {target} SECTOR = {sector}',
|
|
|
|
|
|
|
|
flush=True)
|
|
|
|
|
|
|
|
|
|
|
|
with self.lock:
|
|
|
|
with self.lock:
|
|
|
|
update_enabled = is_update_enabled()
|
|
|
|
update_enabled = is_update_enabled()
|
|
|
|
|
|
|
|
|
|
|
@@ -813,13 +930,15 @@ class AppGui(QWidget):
|
|
|
|
time.sleep(0.05)
|
|
|
|
time.sleep(0.05)
|
|
|
|
self.table_sol_dict[sector].init_value_button.setEnabled(True)
|
|
|
|
self.table_sol_dict[sector].init_value_button.setEnabled(True)
|
|
|
|
|
|
|
|
|
|
|
|
QApplication.processEvents(QEventLoop.AllEvents, 1)
|
|
|
|
print(f'after self-lock TARGET = {target} SECTOR = {sector}', flush=True)
|
|
|
|
|
|
|
|
|
|
|
|
if not self.input_parameters["simulation"]:
|
|
|
|
if not self.input_parameters["simulation"]:
|
|
|
|
if sector == "UCN":
|
|
|
|
if sector == "UCN":
|
|
|
|
write_to_restore_ucn()
|
|
|
|
write_to_restore_ucn()
|
|
|
|
status, status_list, pv_list = table.set_standby_values()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print(f'before table-set_standby_valkues(): TARGET = {target} SECTOR = {sector}')
|
|
|
|
|
|
|
|
status, status_list, pv_list = table.set_standby_values()
|
|
|
|
|
|
|
|
print(f'after table-set_standby_valkues(): TARGET = {target} SECTOR = {sector}')
|
|
|
|
if status != self.cyca.ICAFE_NORMAL:
|
|
|
|
if status != self.cyca.ICAFE_NORMAL:
|
|
|
|
#self.check_status_list(pv_list, status_list, _line())
|
|
|
|
#self.check_status_list(pv_list, status_list, _line())
|
|
|
|
self.check_status_list(
|
|
|
|
self.check_status_list(
|
|
|
@@ -834,9 +953,16 @@ class AppGui(QWidget):
|
|
|
|
# Disable because table.set_standby_values() enables it
|
|
|
|
# Disable because table.set_standby_values() enables it
|
|
|
|
if not update_enabled:
|
|
|
|
if not update_enabled:
|
|
|
|
with self.lock:
|
|
|
|
with self.lock:
|
|
|
|
|
|
|
|
print(f'before FINAL self.lock TARGET = {target} SECTOR = {sector}')
|
|
|
|
self.table_pwr_dict[sector].init_value_button.setEnabled(False)
|
|
|
|
self.table_pwr_dict[sector].init_value_button.setEnabled(False)
|
|
|
|
table.init_value_button.setEnabled(False)
|
|
|
|
table.init_value_button.setEnabled(False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.timer_blink.singleShot(
|
|
|
|
|
|
|
|
250, lambda: self.blink_target_beamline(sector, standby=True))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print(f'END TARGET = {target} SECTOR = {sector}', flush=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def on_sector_restore(self):
|
|
|
|
def on_sector_restore(self):
|
|
|
|
target = self.sender()
|
|
|
|
target = self.sender()
|
|
|
|
sector = target.sector
|
|
|
|
sector = target.sector
|
|
|
@@ -856,6 +982,9 @@ class AppGui(QWidget):
|
|
|
|
#stat = self.cafe.set(pv, 1)
|
|
|
|
#stat = self.cafe.set(pv, 1)
|
|
|
|
#self.check_status(pv, stat, _line())
|
|
|
|
#self.check_status(pv, stat, _line())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.timer_blink.singleShot(
|
|
|
|
|
|
|
|
250, lambda: self.blink_target_beamline(sector, standby=False))
|
|
|
|
|
|
|
|
|
|
|
|
table_pwr = self.table_pwr_dict[sector]
|
|
|
|
table_pwr = self.table_pwr_dict[sector]
|
|
|
|
row_pwr_dict = table_pwr.get_init_values()
|
|
|
|
row_pwr_dict = table_pwr.get_init_values()
|
|
|
|
sum_pwr = sum(list(row_pwr_dict.values()))
|
|
|
|
sum_pwr = sum(list(row_pwr_dict.values()))
|
|
|
@@ -1089,14 +1218,14 @@ class AppGui(QWidget):
|
|
|
|
#"The current accounting figures\nwill be entered into elog\n " +
|
|
|
|
#"The current accounting figures\nwill be entered into elog\n " +
|
|
|
|
"To execute the reset,\nplease enter the password:"
|
|
|
|
"To execute the reset,\nplease enter the password:"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
pwedit = QLineEdit()
|
|
|
|
|
|
|
|
#pwedit.setObjectName("Write")
|
|
|
|
#pwedit.setObjectName("Write")
|
|
|
|
#pwedit.setFixedWidth(40)
|
|
|
|
#pwedit.setFixedWidth(40)
|
|
|
|
#pwedit.setFixedHeight(25)
|
|
|
|
#pwedit.setFixedHeight(25)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qd = QInputDialog(self)
|
|
|
|
qd = QInputDialog(self)
|
|
|
|
|
|
|
|
#pwedit = QLineEdit(qd)
|
|
|
|
#qd.resize(500,100)
|
|
|
|
#qd.resize(500,100)
|
|
|
|
#qd.setObjectName('Password')
|
|
|
|
#qd.setObjectName('Password')
|
|
|
|
#qd.setWindowFlag(Qt.WindowType.WindowMinimizeButtonHint, False)
|
|
|
|
#qd.setWindowFlag(Qt.WindowType.WindowMinimizeButtonHint, False)
|
|
|
@@ -1397,3 +1526,160 @@ class AppGui(QWidget):
|
|
|
|
qw.setFixedHeight(280)
|
|
|
|
qw.setFixedHeight(280)
|
|
|
|
|
|
|
|
|
|
|
|
return qw
|
|
|
|
return qw
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def group_simple_mode(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.simple_status = [None] * len(self.simple_sector_list)
|
|
|
|
|
|
|
|
self.simple_standby = [None] * len(self.simple_sector_list)
|
|
|
|
|
|
|
|
self.simple_awake = [None] * len(self.simple_sector_list)
|
|
|
|
|
|
|
|
self.simple_groupbox = [None] * len(self.simple_sector_list)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qgrido = QGridLayout()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qwo = QGroupBox('Skin View')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hlength = 3
|
|
|
|
|
|
|
|
irow = 0
|
|
|
|
|
|
|
|
icolumn = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for i, sector in enumerate(self.simple_sector_list):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.simple_status[i] = QLabel(' Status: ')
|
|
|
|
|
|
|
|
pv = 'Z' + sector + '-HUSH:TOTPWR'
|
|
|
|
|
|
|
|
print('pv=', pv, flush=True)
|
|
|
|
|
|
|
|
power = CAQLabel(self, pv, show_units=True, notify_freq_hz=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.simple_standby[i] = QPushButton(' Standby ')
|
|
|
|
|
|
|
|
self.simple_standby[i].sector = sector
|
|
|
|
|
|
|
|
self.simple_standby[i].setObjectName('Controller')
|
|
|
|
|
|
|
|
self.simple_standby[i].setProperty('actOnBeam', True)
|
|
|
|
|
|
|
|
self.simple_standby[i].setToolTip(
|
|
|
|
|
|
|
|
('Restore devices to their standby values'))
|
|
|
|
|
|
|
|
self.simple_standby[i].clicked.connect(self.on_sector_standby)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.simple_awake[i] = QPushButton(' Awake ')
|
|
|
|
|
|
|
|
self.simple_awake[i].sector = sector
|
|
|
|
|
|
|
|
self.simple_awake[i].setObjectName('Controller')
|
|
|
|
|
|
|
|
self.simple_awake[i].setProperty('actOnBeam', True)
|
|
|
|
|
|
|
|
self.simple_awake[i].setToolTip(
|
|
|
|
|
|
|
|
('Restore devices to their pre-standby values'))
|
|
|
|
|
|
|
|
self.simple_awake[i].clicked.connect(self.on_sector_restore)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qgrid = QGridLayout()
|
|
|
|
|
|
|
|
qgrid.addWidget(self.simple_status[i], 0, 0, 1, 1, Qt.AlignCenter)
|
|
|
|
|
|
|
|
qgrid.addWidget(power, 0, 1, 1, 1, Qt.AlignLeft)
|
|
|
|
|
|
|
|
qgrid.addWidget(self.simple_standby[i], 1, 0, 1, 1, Qt.AlignCenter)
|
|
|
|
|
|
|
|
qgrid.addWidget(self.simple_awake[i], 1, 1, 1, 1, Qt.AlignCenter)
|
|
|
|
|
|
|
|
qgrid.setContentsMargins(5, 20, 5, 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.simple_groupbox[i] = QGroupBox(sector)
|
|
|
|
|
|
|
|
self.simple_groupbox[i].setContentsMargins(5, 0, 5, 0)
|
|
|
|
|
|
|
|
self.simple_groupbox[i].setAlignment(Qt.AlignCenter)
|
|
|
|
|
|
|
|
self.simple_groupbox[i].setObjectName("OUTER")
|
|
|
|
|
|
|
|
text_color = self.settings.data[sector]["color"]
|
|
|
|
|
|
|
|
text_color_str = f'color: {text_color}; '
|
|
|
|
|
|
|
|
sss = ("QGroupBox {" + text_color_str + "font-weight: bold;}")
|
|
|
|
|
|
|
|
self.simple_groupbox[i].setStyleSheet(sss)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.simple_groupbox[i].setLayout(qgrid)
|
|
|
|
|
|
|
|
self.simple_groupbox[i].setFixedWidth(270) #280
|
|
|
|
|
|
|
|
self.simple_groupbox[i].setFixedHeight(140) #140
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
irow = 0 if i < (hlength) else 1
|
|
|
|
|
|
|
|
icolumn = i%hlength # if i < (hlength) else int(i - hlength)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qgrido.addWidget(self.simple_groupbox[i], irow, icolumn, 1, 1,
|
|
|
|
|
|
|
|
Qt.AlignCenter)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#message = ""
|
|
|
|
|
|
|
|
#ql = QLabel(message)
|
|
|
|
|
|
|
|
#ql.setStyleSheet('QLabel {color:black;}')
|
|
|
|
|
|
|
|
#ql.setAlignment(Qt.AlignHCenter|Qt.AlignBottom)
|
|
|
|
|
|
|
|
#cspan = qgrido.columnCount()
|
|
|
|
|
|
|
|
#qgrido.addWidget(ql, irow+1, 0, 2, cspan,
|
|
|
|
|
|
|
|
# Qt.AlignHCenter|Qt.AlignBottom)
|
|
|
|
|
|
|
|
qgrido.setContentsMargins(5, 15, 5, 15)
|
|
|
|
|
|
|
|
qgrido.setAlignment(Qt.AlignCenter)
|
|
|
|
|
|
|
|
qgrido.setVerticalSpacing(20)
|
|
|
|
|
|
|
|
qgrido.setHorizontalSpacing(25)
|
|
|
|
|
|
|
|
qwo.setContentsMargins(5, 15, 5, 10)
|
|
|
|
|
|
|
|
qwo.setAlignment(Qt.AlignCenter)
|
|
|
|
|
|
|
|
qwo.setObjectName("OUTER")
|
|
|
|
|
|
|
|
qwo.setLayout(qgrido)
|
|
|
|
|
|
|
|
wlength = len(self.simple_sector_list) if irow == 0 else int(hlength)
|
|
|
|
|
|
|
|
qwo.setFixedWidth(310 * wlength)
|
|
|
|
|
|
|
|
qwo.setFixedHeight(240 * (irow+1) - 80*irow)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return qwo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def blink_target_beamline(self, sector, standby=False):
|
|
|
|
|
|
|
|
idx = self.simple_sector_list.index(sector)
|
|
|
|
|
|
|
|
text_color = self.settings.data[sector]["color"]
|
|
|
|
|
|
|
|
text_color_str = f'color: {text_color};'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Deactivate
|
|
|
|
|
|
|
|
standby_enabled = self.simple_standby[idx].isEnabled()
|
|
|
|
|
|
|
|
awake_enabled = self.simple_awake[idx].isEnabled()
|
|
|
|
|
|
|
|
self.simple_standby[idx].setEnabled(False)
|
|
|
|
|
|
|
|
self.simple_awake[idx].setEnabled(False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
is_standby = self.is_sector_standby(sector, None, None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ready = False
|
|
|
|
|
|
|
|
if (standby and not is_standby) or (not standby and is_standby):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
endpt = 0 if standby else 1
|
|
|
|
|
|
|
|
ramping = 'Ramping down \u21D3' if standby else 'Ramping up \u21D1'
|
|
|
|
|
|
|
|
self.simple_status[idx].setText(ramping)
|
|
|
|
|
|
|
|
end = 14 #must be even no
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for i in range(0, end):
|
|
|
|
|
|
|
|
if i%2 == endpt:
|
|
|
|
|
|
|
|
sss = ('QGroupBox {background-color:#ffe87c; font-weight: bold; ' +
|
|
|
|
|
|
|
|
text_color_str + '}')
|
|
|
|
|
|
|
|
self.simple_status[idx].setStyleSheet(
|
|
|
|
|
|
|
|
'QLabel{color:black; font-weight: bold;}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sss = ('QGroupBox {background-color:#546bab;; font-weight: bold; ' +
|
|
|
|
|
|
|
|
text_color_str + '}')
|
|
|
|
|
|
|
|
self.simple_status[idx].setStyleSheet(
|
|
|
|
|
|
|
|
'QLabel{color:white; font-weight: bold;}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.simple_groupbox[idx].setStyleSheet(sss)
|
|
|
|
|
|
|
|
#self.simple_status[idx].setText('Status: AWAKE')
|
|
|
|
|
|
|
|
#self.simple_status[idx].setStyleSheet(
|
|
|
|
|
|
|
|
# 'QLabel{color:black; font-weight: bold;}')
|
|
|
|
|
|
|
|
self.simple_status[idx].setText(ramping)
|
|
|
|
|
|
|
|
QApplication.processEvents()
|
|
|
|
|
|
|
|
time.sleep(0.5)
|
|
|
|
|
|
|
|
is_standby = self.is_sector_standby(sector, None, None)
|
|
|
|
|
|
|
|
if standby and is_standby:
|
|
|
|
|
|
|
|
ready = True
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
elif not standby and not is_standby:
|
|
|
|
|
|
|
|
ready = True
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Activate
|
|
|
|
|
|
|
|
#if not ready:
|
|
|
|
|
|
|
|
self.simple_standby[idx].setEnabled(standby_enabled)
|
|
|
|
|
|
|
|
self.simple_awake[idx].setEnabled(awake_enabled)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pv = self.settings.data[sector]['device'][0] + ":SOL:2.PROC"
|
|
|
|
|
|
|
|
stat = self.cafe.set(pv, 1)
|
|
|
|
|
|
|
|
self.check_status(_pymodule, "set", pv, stat, _line())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QApplication.processEvents()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|