submastership devl

This commit is contained in:
2024-03-01 20:33:28 +01:00
parent d6c4eb0764
commit 4d6784fece
12 changed files with 366 additions and 287 deletions

5
create_hush_links Executable file
View File

@@ -0,0 +1,5 @@
ln -s hush.py hush_g1.py
ln -s hush.py hush_g2.py
ln -s hush.py hush_o2.py
ln -s hush.py hush_pif.py
ln -s hush.py hush_g3.py

1
hush_g1.py Symbolic link
View File

@@ -0,0 +1 @@
hush.py

View File

@@ -2,7 +2,7 @@
cd /proscan/bd/applications/hush/hla/1.3.0
# For use if script is sourced rather than executed
appNameDefault="hush.sh"
appNameDefault="hush_g1.sh"
configBase="config"
configSector=${configBase}/g1
echo "${configSector}"
@@ -84,6 +84,7 @@ fi
#echo "$appName $@ $#"
baseName="${appName##*/}"
name=$(echo "$baseName" | cut -f 1 -d '.')
nameconfig=$(echo "$baseName" | cut -f 1 -d '_')
nameLog=${name}-$USER
echo "Application: $name"
echo "nameLog: $nameLog"
@@ -109,11 +110,11 @@ if [ "${STDOUT_FLAG}" -gt "0" ] ; then
rm -f $STDOUT_DIR/${nameLog}.log
fi
python ${name}.py -u ${configSector}/${name}.json >> $STDOUT_DIR/${nameLog}.log 2>&1 &
python ${name}.py -u ${configSector}/${nameconfig}.json >> $STDOUT_DIR/${nameLog}.log 2>&1 &
chmod 777 $STDOUT_DIR/${nameLog}.log
else
#Run instead without std::out
python ${name}.py -u ${configSector}/${name}.json &
python ${name}.py -u ${configSector}/${nameconfig}.json &
fi

1
hush_g2.py Symbolic link
View File

@@ -0,0 +1 @@
hush.py

View File

@@ -2,7 +2,7 @@
cd /proscan/bd/applications/hush/hla/1.3.0
# For use if script is sourced rather than executed
appNameDefault="hush.sh"
appNameDefault="hush_g2.sh"
configBase="config"
configSector=${configBase}/g2
echo "${configSector}"
@@ -84,6 +84,7 @@ fi
#echo "$appName $@ $#"
baseName="${appName##*/}"
name=$(echo "$baseName" | cut -f 1 -d '.')
nameconfig=$(echo "$baseName" | cut -f 1 -d '_')
nameLog=${name}-$USER
echo "Application: $name"
echo "nameLog: $nameLog"
@@ -109,11 +110,11 @@ if [ "${STDOUT_FLAG}" -gt "0" ] ; then
rm -f $STDOUT_DIR/${nameLog}.log
fi
python ${name}.py -u ${configSector}/${name}.json >> $STDOUT_DIR/${nameLog}.log 2>&1 &
python ${name}.py -u ${configSector}/${nameconfig}.json >> $STDOUT_DIR/${nameLog}.log 2>&1 &
chmod 777 $STDOUT_DIR/${nameLog}.log
else
#Run instead without std::out
python ${name}.py -u ${configSector}/${name}.json &
python ${name}.py -u ${configSector}/${nameconfig}.json &
fi

1
hush_g3.py Symbolic link
View File

@@ -0,0 +1 @@
hush.py

View File

@@ -2,7 +2,7 @@
cd /proscan/bd/applications/hush/hla/1.3.0
# For use if script is sourced rather than executed
appNameDefault="hush.sh"
appNameDefault="hush_g3.sh"
configBase="config"
configSector=${configBase}/g3
echo "${configSector}"
@@ -83,6 +83,7 @@ fi
#echo "$appName $@ $#"
baseName="${appName##*/}"
name=$(echo "$baseName" | cut -f 1 -d '.')
nameconfig=$(echo "$baseName" | cut -f 1 -d '_')
nameLog=${name}-$USER
echo "Application: $name"
echo "nameLog: $nameLog"
@@ -108,11 +109,11 @@ if [ "${STDOUT_FLAG}" -gt "0" ] ; then
rm -f $STDOUT_DIR/${nameLog}.log
fi
python ${name}.py -u ${configSector}/${name}.json >> $STDOUT_DIR/${nameLog}.log 2>&1 &
python ${name}.py -u ${configSector}/${nameconfig}.json >> $STDOUT_DIR/${nameLog}.log 2>&1 &
chmod 777 $STDOUT_DIR/${nameLog}.log
else
#Run instead without std::out
python ${name}.py -u ${configSector}/${name}.json &
python ${name}.py -u ${configSector}/${nameconfig}.json &
fi

1
hush_o2.py Symbolic link
View File

@@ -0,0 +1 @@
hush.py

View File

@@ -2,7 +2,7 @@
cd /proscan/bd/applications/hush/hla/1.3.0
# For use if script is sourced rather than executed
appNameDefault="hush.sh"
appNameDefault="hush_o2.sh"
configBase="config"
configSector=${configBase}/o2
echo "${configSector}"
@@ -85,6 +85,7 @@ fi
#echo "$appName $@ $#"
baseName="${appName##*/}"
name=$(echo "$baseName" | cut -f 1 -d '.')
nameconfig=$(echo "$baseName" | cut -f 1 -d '_')
nameLog=${name}-$USER
echo "Application: $name"
echo "nameLog: $nameLog"
@@ -110,11 +111,11 @@ if [ "${STDOUT_FLAG}" -gt "0" ] ; then
rm -f $STDOUT_DIR/${nameLog}.log
fi
python ${name}.py -u ${configSector}/${name}.json >> $STDOUT_DIR/${nameLog}.log 2>&1 &
python ${name}.py -u ${configSector}/${nameconfig}.json >> $STDOUT_DIR/${nameLog}.log 2>&1 &
chmod 777 $STDOUT_DIR/${nameLog}.log
else
#Run instead without std::out
python ${name}.py -u ${configSector}/${name}.json &
python ${name}.py -u ${configSector}/${nameconfig}.json &
fi

1
hush_pif.py Symbolic link
View File

@@ -0,0 +1 @@
hush.py

View File

@@ -2,7 +2,7 @@
cd /proscan/bd/applications/hush/hla/1.3.0
# For use if script is sourced rather than executed
appNameDefault="hush.sh"
appNameDefault="hush_pif.sh"
configBase="config"
configSector=${configBase}/pif
echo "${configSector}"
@@ -86,6 +86,7 @@ fi
#echo "$appName $@ $#"
baseName="${appName##*/}"
name=$(echo "$baseName" | cut -f 1 -d '.')
nameconfig=$(echo "$baseName" | cut -f 1 -d '_')
nameLog=${name}-$USER
echo "Application: $name"
echo "nameLog: $nameLog"
@@ -111,11 +112,11 @@ if [ "${STDOUT_FLAG}" -gt "0" ] ; then
rm -f $STDOUT_DIR/${nameLog}.log
fi
python ${name}.py -u ${configSector}/${name}.json >> $STDOUT_DIR/${nameLog}.log 2>&1 &
python ${name}.py -u ${configSector}/${nameconfig}.json >> $STDOUT_DIR/${nameLog}.log 2>&1 &
chmod 777 $STDOUT_DIR/${nameLog}.log
else
#Run instead without std::out
python ${name}.py -u ${configSector}/${name}.json &
python ${name}.py -u ${configSector}/${nameconfig}.json &
fi

View File

@@ -9,7 +9,7 @@ from datetime import timedelta
from qtpy.QtGui import QColor, QPixmap
from qtpy.QtCore import __version__ as QT_VERSION_STR
from qtpy.QtCore import QEventLoop, Qt, Slot
from qtpy.QtCore import QEventLoop, Qt, QTimer, Slot
from qtpy.QtWidgets import (
QApplication, QFrame, QGridLayout, QGroupBox, QHBoxLayout, QLabel,
QMessageBox, QPushButton, QTabBar, QTabWidget, QTableWidgetItem,
@@ -20,14 +20,14 @@ from common.packages import elog
from apps4ops.bdbase.utils import _line
from apps4ops.bdbase.enumkind import MsgSeverity
from caqtwidgets.pvwidgets import (
CAQLabel, CAQLineEdit, CAQMenu, CAQMessageButton, CAQTableWidget,
CAQLabel, CAQLineEdit, CAQMessageButton, CAQTableWidget,
CAQTextEntry, QHLine)
_pymodule = os.path.basename(__file__)
# storing the directory in dir variable
dir = os.path.dirname(elog.__file__)
print(dir)
elog_directory = os.path.dirname(elog.__file__)
print(elog_directory)
class AppGui(QWidget):
'''The GUI class
@@ -113,7 +113,6 @@ class AppGui(QWidget):
self.reset_lastpwr(), 1, 0, 1, 1,
Qt.AlignmentFlag(Qt.AlignTop|Qt.AlignCenter))
self.expert_labels = self.parent.expert_labels
self.settings = self.parent.settings
@@ -129,13 +128,31 @@ class AppGui(QWidget):
self.cafe.open(self.sec_state_list)
self.cafe.openNowAndWait(0.1)
# Overload from guiheader.py
self.sector_disruptor_dict = {}
self.sector_disruptor_dict["G1"] = "Geschlossen"
self.sector_disruptor_dict["SH"] = "Geschlossen"
self.sector_disruptor_dict["G2"] = "Geschlossen"
self.sector_disruptor_dict["O2"] = "Geschlossen"
self.sector_disruptor_dict["PIF"] = "Geschlossen"
self.sector_disruptor_dict["G3"] = "Geschlossen"
self.submastership_dict = {
"G1": "UNDEF", "G2": "UNDEF", "O2": "UNDEF", "PIF": "UNDEF", "G3": "UNDEF"}
for key in self.submastership_dict:
pvname = self.settings.data[key]["mastershipStatus"]
value = self.cafe.get(pvname)
self.submastership_dict[key] = value
# [1:] do not include SH for target specific HLA
self.idx = 0 if "Controlroom" in self.settings.data["Master"] else 1
self.magnet_tab_wgt = self.group_sector_qtabwidget()
self.magnet_tab_wgt.setFixedHeight(380)
self.gui_frame.measurement_layout.addWidget(
self.magnet_tab_wgt, 0, 2, 3, 2, alignment=Qt.AlignTop)
self.submastership_dict = {
"G1": None, "G2": None, "O2": None, "PIF": None, "G3": None}
_row = self.gui_frame.measurement_layout.rowCount()
self.gui_frame.measurement_layout.addWidget(
@@ -176,271 +193,318 @@ class AppGui(QWidget):
self.gui_frame.measurement_layout.addWidget(
qf2, 0, 7, 1, 1, alignment=Qt.AlignTop)
# Overload from guiheader.py
self.sector_disruptor_dict = {}
self.sector_disruptor_dict["G1"] = "Geschlossen"
self.sector_disruptor_dict["SH"] = "Geschlossen"
self.sector_disruptor_dict["G2"] = "Geschlossen"
self.sector_disruptor_dict["O2"] = "Geschlossen"
self.sector_disruptor_dict["PIF"] = "Geschlossen"
self.sector_disruptor_dict["G3"] = "Geschlossen"
def enable_disable_beamline(sect, sector_line, value):
def is_submaster(local_sector):
if local_sector in self.submastership_dict:
return bool(
"MASTERSHIP" in self.submastership_dict[local_sector])
#"UNDEF" in self.submastership_dict[local_sector])
#"Geschlossen" in self.submastership_dict[local_sector])
else:
return self.gui_header.is_master()
self.sector_disruptor_dict[sect] = value
#print("sect/value", sect, value)
for sector in sector_line:
if "Geschlossen" not in self.sector_disruptor_dict[
sector] or not is_submaster(sector): #not self.gui_header.is_master():
#print("sector/value", sector, value)
#print("isMaster", self.gui_header.is_master())
#print("master", self.gui_header.mastership)
#print("assigned master", self.assigned_master)
if self.table_sol_dict[
sector].standby_value_button.isEnabled():
self.table_sol_dict[
sector].standby_value_button.setEnabled(False)
if not self.gui_header.is_master():
if self.table_sol_dict[
sector].restore_value_button.isEnabled():
self.table_sol_dict[
sector].restore_value_button.setEnabled(False)
else:
print("Geschlossen? sector/value/ismaster", sector, value,
self.gui_header.mastership)
if not self.table_sol_dict[
sector].standby_value_button.isEnabled():
self.table_sol_dict[
sector].standby_value_button.setEnabled(True)
if not self.table_sol_dict[
sector].restore_value_button.isEnabled():
self.table_sol_dict[
sector].restore_value_button.setEnabled(True)
# [1:] do not include SH for target specific HLA
idx = 0 if "Controlroom" in self.settings.data["Master"] else 1
def receive_sh_update(value, status, alarm_severity):
enable_disable_beamline("SH", self.gui_header.sh_line, value)
def receive_g1_update(value, status, alarm_severity):
enable_disable_beamline("G1", self.gui_header.g1_line, value)
def receive_g3_update(value, status, alarm_severity):
enable_disable_beamline("G3", self.gui_header.g3_line[idx:], value)
def receive_o2_update(value, status, alarm_severity):
enable_disable_beamline("O2", self.gui_header.o2_line[idx:], value)
def receive_g2_update(value, status, alarm_severity):
enable_disable_beamline("G2", self.gui_header.g2_line[idx:], value)
def receive_pif_update(value, status, alarm_severity):
enable_disable_beamline(
"PIF", self.gui_header.pif_line[idx:], value)
if "G1" in self.settings.data["headerMagnetSector"]:
if "Controlroom" in self.assigned_master:
self.gui_header.beam_current_wgt_dict[
"G1"].trigger_monitor_str.connect(receive_g1_update)
"MASTER"].trigger_monitor_str.connect(self.receive_master_update)
pvd = self.cafe.getPVCache(
self.settings.data["G1"]["status"], dt="str")
receive_g1_update(pvd.value[0], pvd.alarmStatus, pvd.alarmSeverity)
if "SH" in self.settings.data["headerMagnetSector"]:
self.gui_header.beam_current_wgt_dict[
"BMA1"].trigger_monitor_str.connect(receive_sh_update)
pvd = self.cafe.getPVCache(
self.settings.data["SH"]["status"], dt="str")
receive_sh_update(pvd.value[0], pvd.alarmStatus, pvd.alarmSeverity)
if "G2" in self.settings.data["headerMagnetSector"]:
self.gui_header.beam_current_wgt_dict[
"G2"].trigger_monitor_str.connect(receive_g2_update)
pvd = self.cafe.getPVCache(
self.settings.data["G2"]["status"], dt="str")
receive_g2_update(pvd.value[0], pvd.alarmStatus, pvd.alarmSeverity)
if "O2" in self.settings.data["headerMagnetSector"]:
self.gui_header.beam_current_wgt_dict[
"O2"].trigger_monitor_str.connect(receive_o2_update)
pvd = self.cafe.getPVCache(
self.settings.data["O2"]["status"], dt="str")
receive_o2_update(pvd.value[0], pvd.alarmStatus, pvd.alarmSeverity)
if "PIF" in self.settings.data["headerMagnetSector"]:
self.gui_header.beam_current_wgt_dict[
"PIF"].trigger_monitor_str.connect(receive_pif_update)
pvd = self.cafe.getPVCache(
self.settings.data["PIF"]["status"], dt="str")
receive_pif_update(pvd.value[0], pvd.alarmStatus, pvd.alarmSeverity)
if "G3" in self.settings.data["headerMagnetSector"]:
self.gui_header.beam_current_wgt_dict[
"G3"].trigger_monitor_str.connect(receive_g3_update)
pvd = self.cafe.getPVCache(
self.settings.data["G3"]["status"], dt="str")
receive_g3_update(pvd.value[0], pvd.alarmStatus, pvd.alarmSeverity)
def receive_b1b2_update(value, status, alarm_severity):
#Enable Only on shutdown and if there is no current in the machine
comet_I = self.cafe.getCache("MMAC3:STR:2")
if comet_I is None:
comet_I = 0.002
if value != "Shutdown" or comet_I > 0.002 or \
not self.gui_header.is_master():
if self.table_sol_dict["B1B2"].standby_value_button.isEnabled():
self.table_sol_dict[
"B1B2"].standby_value_button.setEnabled(False)
if not self.gui_header.is_master():
if self.table_sol_dict[
"B1B2"].restore_value_button.isEnabled():
self.table_sol_dict[
"B1B2"].restore_value_button.setEnabled(False)
else:
if not self.table_sol_dict[
"B1B2"].standby_value_button.isEnabled():
self.table_sol_dict[
"B1B2"].standby_value_button.setEnabled(True)
if not self.table_sol_dict[
"B1B2"].restore_value_button.isEnabled():
self.table_sol_dict[
"B1B2"].restore_value_button.setEnabled(True)
'''
if "B1B2" in self.settings.data["headerMagnetSector"]:
self.gui_header.shift_type.trigger_monitor_str.connect(
receive_b1b2_update)
#holds shifttype
pvd = self.cafe.getPVCache(
self.settings.data["B1B2"]["status"], dt="str")
receive_b1b2_update(pvd.value[0], pvd.alarmStatus, pvd.alarmSeverity)
'''
# end overload from guiheader.py
@Slot()
def receive_master_update(value, status, alarm_severity):
idx = self.sh_idx
for key, wgt_val in self.gui_header.master_to_wgt.items():
#master = self.gui_header.beam_current_wgt_group[wgt_val]
if value in key:
for i in range(0, self.magnet_tab_wgt.count()):
tabtext = self.magnet_tab_wgt.tabText(i)
if tabtext == wgt_val:
idx = i
break
self.magnet_tab_wgt.setCurrentIndex(idx)
self.gui_header.beam_current_wgt_dict[
"MASTER"].trigger_monitor_str.connect(receive_master_update)
pvd = self.cafe.getPVCache(
self.settings.data["MASTER"]["status"], dt="str")
try:
self.gui_header.beam_current_wgt_dict[
"MASTER"].trigger_monitor_str.emit(pvd.value[0], pvd.status,
pvd.alarmSeverity)
except Exception as ex:
print("EMIT FAILED", str(ex))
#print("EMIT SUCCEEDED ===========>")
#receive_master_update(pvd.value[0], pvd.status, pvd.alarmSeverity)
@Slot(int)
def simulation_update(state):
if bool(state):
color = self.gui_header.sim_color
else:
color = self.gui_header.op_color
self.gui_header.pf_off_color = color
###JC COMMENT OUT TO MAKE VISIBLE WHEN TESTING#
self.gui_header.color_pframe(color)
#print("SIMULATION IS TRUE??", self.input_parameters["simulation"])
self.settings.data["MASTER"]["status"], dt="str")
try:
self.gui_header.beam_current_wgt_dict[
"MASTER"].trigger_monitor_str.emit(pvd.value[0], pvd.status,
pvd.alarmSeverity)
except Exception as ex:
print("EMIT FAILED", str(ex))
self.gui_frame.simulation_checkbox.stateChanged.connect(
simulation_update)
def receive_sec_state(handle, pv, pvdata):
pvsplit = pv.split("-")
sec = pvsplit[0][1:]
if pvdata.status == self.cyca.ICAFE_CA_OP_CONN_DOWN:
return
def already_in_standby():
devices = self.settings.data[sec]["iocDevice"]
pv_list = []
standby_value_list = []
for magnet in devices:
pv_magnet = magnet + ":SOL:2"
pv_list.append(pv_magnet)
# get standby values
idx = self.settings.data[sec]["device"].index(magnet)
standby_value = self.settings.data[sec]["standby"][idx]
standby_value_list.append(standby_value)
QApplication.processEvents()
value_list, status, status_list = self.cafe.getScalarList(
pv_list, cacheFlag=True)
if status != self.cyca.ICAFE_NORMAL:
self.check_status_list(_pymodule, "getScalarListCache",
pv_list, status_list, _line())
# check standby values
in_standby = True
for value, standby in zip(value_list, standby_value_list):
if abs(value) < abs(standby) * 0.8 or abs(value) > abs(
standby) * 1.2:
in_standby = False
break
return in_standby
if pvdata.value[0] == "ON" and not already_in_standby():
self.table_sol_dict[sec].init_value_button.setEnabled(True)
self.table_pwr_dict[sec].init_value_button.setEnabled(True)
else:
self.table_sol_dict[sec].init_value_button.setEnabled(False)
self.table_pwr_dict[sec].init_value_button.setEnabled(False)
self.simulation_update)
for state in self.sec_state_list:
for sector in self.settings.data["headerMagnetSector"]:
if sector in state:
self.cafe.monitor(state, receive_sec_state)
self.cafe.monitor(state, self.receive_sec_state)
break
for key in self.sector_disruptor_dict:
if key in self.settings.data["headerMagnetSector"]:
print(key, flush=True)
pvd = self.cafe.getPVCache(
self.settings.data[key]["status"], dt="str")
pvd.show()
if "G1" in key:
self.gui_header.beam_current_wgt_dict[
key].trigger_monitor_str.connect(self.receive_g1_update)
elif "SH" in key:
self.gui_header.beam_current_wgt_dict[
"BMA1"].trigger_monitor_str.connect(self.receive_sh_update)
elif "G2" in key:
self.gui_header.beam_current_wgt_dict[
key].trigger_monitor_str.connect(self.receive_g2_update)
elif "O2" in key:
self.gui_header.beam_current_wgt_dict[
key].trigger_monitor_str.connect(self.receive_o2_update)
elif "PIF" in key:
self.gui_header.beam_current_wgt_dict[
key].trigger_monitor_str.connect(self.receive_pif_update)
elif "G3" in key:
self.gui_header.beam_current_wgt_dict[
key].trigger_monitor_str.connect(self.receive_g3_update)
'''
if "G1" in key:
self.receive_g1_update(
pvd.value[0], pvd.alarmStatus, pvd.alarmSeverity)
elif "SH" in key:
self.receive_sh_update(
pvd.value[0], pvd.alarmStatus, pvd.alarmSeverity)
elif "G2" in key:
self.receive_g2_update(
pvd.value[0], pvd.alarmStatus, pvd.alarmSeverity)
elif "O2" in key:
self.receive_o2_update(
pvd.value[0], pvd.alarmStatus, pvd.alarmSeverity)
elif "PIF" in key:
self.receive_pif_update(
pvd.value[0], pvd.alarmStatus, pvd.alarmSeverity)
elif "G3" in key:
self.receive_g3_update(
pvd.value[0], pvd.alarmStatus, pvd.alarmSeverity)
'''
def enable_disable_beamline(self, sect, sector_line, value):
def is_submaster(local_sector, local_sector_line):
print("===========", local_sector, local_sector_line)
if local_sector in self.submastership_dict and \
"Controlroom" not in self.assigned_master:
print(local_sector,
self.submastership_dict[local_sector].upper(),
flush=True)
if "PIF" in local_sector and ("G3" in local_sector_line or "G3" in self.assigned_master):
print("HERE", flush=True)
print(self.submastership_dict, flush=True)
print("bool", bool(
"MASTERSHIP" in self.submastership_dict[
"G3"].upper()), flush=True)
return bool(
"MASTERSHIP" in self.submastership_dict[
"G3"].upper())
else:
print("HERE//", flush=True )
return bool(
"MASTERSHIP" in self.submastership_dict[
local_sector].upper())
#"UNDEF" in self.submastership_dict[local_sector])
#"Geschlossen" in self.submastership_dict[local_sector])
else:
return self.gui_header.is_master()
print("sect/value/sector_line", sect, value, sector_line, flush=True)
if not sector_line:
return
self.sector_disruptor_dict[sect] = value
for sector in reversed(sector_line):
if "Geschlossen" not in self.sector_disruptor_dict[
sector] or not is_submaster(sector, sector_line): #not self.gui_header.is_master():
print("sector/value", sector, value)
print("isMaster", self.gui_header.is_master())
print("master", self.gui_header.mastership)
print("assigned master", self.assigned_master)
if self.table_sol_dict[
sector].standby_value_button.isEnabled():
self.table_sol_dict[
sector].standby_value_button.setEnabled(False)
if not self.gui_header.is_master():
if self.table_sol_dict[
sector].restore_value_button.isEnabled():
self.table_sol_dict[
sector].restore_value_button.setEnabled(False)
else:
print("Geschlossen? sector/value/ismaster", sector, value,
self.gui_header.mastership)
if not self.table_sol_dict[
sector].standby_value_button.isEnabled():
self.table_sol_dict[
sector].standby_value_button.setEnabled(True)
if not self.table_sol_dict[
sector].restore_value_button.isEnabled():
self.table_sol_dict[
sector].restore_value_button.setEnabled(True)
def receive_sh_update(self, value, status, alarm_severity):
self.enable_disable_beamline("SH", self.gui_header.sh_line, value)
def receive_g1_update(self, value, status, alarm_severity):
self.enable_disable_beamline("G1", self.gui_header.g1_line, value)
def receive_g3_update(self, value, status, alarm_severity):
self.enable_disable_beamline("G3", self.gui_header.g3_line[self.idx:], value)
def receive_o2_update(self, value, status, alarm_severity):
self.enable_disable_beamline("O2", self.gui_header.o2_line[self.idx:], value)
def receive_g2_update(self, value, status, alarm_severity):
self.enable_disable_beamline("G2", self.gui_header.g2_line[self.idx:], value)
def receive_pif_update(self, value, status, alarm_severity):
self.enable_disable_beamline(
"PIF", self.gui_header.pif_line[self.idx:], value)
def receive_b1b2_update(self, value, status, alarm_severity):
#Enable Only on shutdown and if there is no current in the machine
comet_I = self.cafe.getCache("MMAC3:STR:2")
if comet_I is None:
comet_I = 0.002
if value != "Shutdown" or comet_I > 0.002 or \
not self.gui_header.is_master():
if self.table_sol_dict["B1B2"].standby_value_button.isEnabled():
self.table_sol_dict[
"B1B2"].standby_value_button.setEnabled(False)
if not self.gui_header.is_master():
if self.table_sol_dict[
"B1B2"].restore_value_button.isEnabled():
self.table_sol_dict[
"B1B2"].restore_value_button.setEnabled(False)
else:
if not self.table_sol_dict[
"B1B2"].standby_value_button.isEnabled():
self.table_sol_dict[
"B1B2"].standby_value_button.setEnabled(True)
if not self.table_sol_dict[
"B1B2"].restore_value_button.isEnabled():
self.table_sol_dict[
"B1B2"].restore_value_button.setEnabled(True)
# end overload from guiheader.py
@Slot(str, int, int)
def receive_master_update(self, value, status, alarm_severity):
idx = self.sh_idx
for key, wgt_val in self.gui_header.master_to_wgt.items():
#master = self.gui_header.beam_current_wgt_group[wgt_val]
if value in key:
for i in range(0, self.magnet_tab_wgt.count()):
tabtext = self.magnet_tab_wgt.tabText(i)
if tabtext == wgt_val:
idx = i
break
self.magnet_tab_wgt.setCurrentIndex(idx)
@Slot(int)
def simulation_update(self, state):
if bool(state):
color = self.gui_header.sim_color
else:
color = self.gui_header.op_color
self.gui_header.pf_off_color = color
###JC COMMENT OUT TO MAKE VISIBLE WHEN TESTING#
self.gui_header.color_pframe(color)
#print("SIMULATION IS TRUE??", self.input_parameters["simulation"])
def receive_sec_state(self, handle, pv, pvdata):
if pvdata.status == self.cyca.ICAFE_CA_OP_CONN_DOWN:
return
pvsplit = pv.split("-")
sec = pvsplit[0][1:]
def already_in_standby():
devices = self.settings.data[sec]["iocDevice"]
pv_list = []
standby_value_list = []
for magnet in devices:
pv_magnet = magnet + ":SOL:2"
pv_list.append(pv_magnet)
# get standby values
idx = self.settings.data[sec]["device"].index(magnet)
standby_value = self.settings.data[sec]["standby"][idx]
standby_value_list.append(standby_value)
QApplication.processEvents()
value_list, status, status_list = self.cafe.getScalarList(
pv_list, cacheFlag=True)
if status != self.cyca.ICAFE_NORMAL:
self.check_status_list(_pymodule, "getScalarListCache",
pv_list, status_list, _line())
# check standby values
in_standby = True
for value, standby in zip(value_list, standby_value_list):
if abs(value) < abs(standby) * 0.8 or abs(value) > abs(
standby) * 1.2:
in_standby = False
break
return in_standby
if pvdata.value[0] == "ON" and not already_in_standby():
self.table_sol_dict[sec].init_value_button.setEnabled(True)
self.table_pwr_dict[sec].init_value_button.setEnabled(True)
else:
self.table_sol_dict[sec].init_value_button.setEnabled(False)
self.table_pwr_dict[sec].init_value_button.setEnabled(False)
##Non-embedded defs
def group_submaster_status(self):
@Slot(str, int, int)
def receive_submaster_update(value, status, alarm_severity):
sender = self.sender()
self.submastership_dict[sender.sector] = value
if status == self.cyca.ICAFE_CA_OP_CONN_DOWN:
return
sender = self.sender()
self.submastership_dict[sender.sector] = value
#Check on value and act accordingly
print("receive_submaster", sender.sector, value, flush=True)
if "G1" in sender.sector:
pvd = self.cafe.getPVCache(
self.settings.data["G1"]["status"], dt="str")
self.receive_g1_update(pvd.value[0], pvd.alarmStatus, pvd.alarmSeverity)
elif "G2" in sender.sector:
pvd = self.cafe.getPVCache(
self.settings.data["G2"]["status"], dt="str")
self.receive_g2_update(pvd.value[0], pvd.alarmStatus, pvd.alarmSeverity)
elif "O2" in sender.sector:
pvd = self.cafe.getPVCache(
self.settings.data["O2"]["status"], dt="str")
self.receive_o2_update(pvd.value[0], pvd.alarmStatus, pvd.alarmSeverity)
elif "PIF" in sender.sector:
pvd = self.cafe.getPVCache(
self.settings.data["PIF"]["status"], dt="str")
self.receive_pif_update(pvd.value[0], pvd.alarmStatus, pvd.alarmSeverity)
elif "G3" in sender.sector:
pvd = self.cafe.getPVCache(
self.settings.data["G3"]["status"], dt="str")
self.receive_g3_update(pvd.value[0], pvd.alarmStatus, pvd.alarmSeverity)
print("receive_submaster->", sender.sector, flush=True)
pv_id = "mastershipStatus"
qgrid = QGridLayout()
qgb = QGroupBox("Mastership Status")
no_beamlines = 0
for i, sector in enumerate(self.settings.data["headerMagnetSector"]):
sector_list = self.settings.data["headerMagnetSector"]
for i, sector in enumerate(sector_list):
if "mastershipStatus" in self.settings.data[sector]:
no_beamlines += 1
qgb_inner = QGroupBox(sector)
@@ -457,19 +521,25 @@ class AppGui(QWidget):
pv_name = pv_name.decode('ascii')
qw = CAQLabel(self, pv_name=str(pv_name))
qw.sector = sector
qw.sector_list = sector_list
qw.trigger_monitor_str.connect(receive_submaster_update)
value = self.cafe.getCache(
pvd = self.cafe.getPVCache(
self.settings.data[sector][pv_id], dt='str')
qw.trigger_monitor_str.emit(value, 1, 0)
time.sleep(0.2)
qw.trigger_monitor_str.emit(pvd.value[0], pvd.status,
pvd.alarmSeverity)
print("emit value ========================================>", sector, pvd.value[0])
qw.setFixedWidth(120)
qw.setText("submastership")
qw.setText("")
qw_layout = QHBoxLayout()
qw_layout.addWidget(qw)
qgb_inner.setLayout(qw_layout)
qgrid.addWidget(qgb_inner, 0, i, 1, 1,
Qt.AlignTop|Qt.AlignHCenter)
Qt.AlignmentFlag(Qt.AlignTop|Qt.AlignHCenter))
@@ -789,7 +859,7 @@ class AppGui(QWidget):
self.table_pwr_dict[sector].init_value_button.isEnabled(
) and table.init_value_button.isEnabled())
QApplication.processEvents(QEventLoop.AllEvents, 1.0)
QApplication.processEvents(QEventLoop.AllEvents, 1)
# Do NOT do updates if in standby mode!
# Update button is disabled when in standby
@@ -811,7 +881,7 @@ class AppGui(QWidget):
time.sleep(0.05)
self.table_sol_dict[sector].init_value_button.setEnabled(True)
QApplication.processEvents(QEventLoop.AllEvents, 1.0)
QApplication.processEvents(QEventLoop.AllEvents, 1)
if not self.input_parameters["simulation"]:
status, status_list, pv_list = table.set_standby_values()
@@ -881,7 +951,6 @@ class AppGui(QWidget):
delay = 0.09
pass
init_column = True
standby_column = True
if "B1B2" in sector:
@@ -889,7 +958,6 @@ class AppGui(QWidget):
standby_column = False
standby_values = None
table_sol = CAQTableWidget(
self, pv_list=pv_dict["SOL:2"], show_units=True, notify_freq_hz=1,
notify_unison=True, scale_factor=1, show_timestamp=False,
@@ -1019,6 +1087,7 @@ class AppGui(QWidget):
pv_status = self.settings.data[sector]["status"]
beamline_status = self.cafe.getCache(pv_status)
if beamline_status is not None and init_column:
# in HIPA this was I < self.I_min:
if "Geschlossen" in beamline_status:
@@ -1043,7 +1112,7 @@ class AppGui(QWidget):
print("SUM up all the values", pv, init_sum, flush=True)
#B1B2 is not is not in state machine
if "B1B2" in table_pwr.init_value_button.sector:
retrun
return
if not self.input_parameters["simulation"]:
stat = self.cafe.set(pv, init_sum)
self.check_status(_pymodule, "set", pv, stat, _line())
@@ -1233,6 +1302,7 @@ class AppGui(QWidget):
qgrid.addWidget(qsm, 0, 1, 1, 1)
qgrid.addWidget(qss, 0, 2, 1, 1)
qgrid.addWidget(qstandby, 0, 3, 1, 1)
for i, pv in enumerate(self.sec_state_list):
pvsplit = pv.split("-")
sec = pvsplit[0][1:]
@@ -1265,18 +1335,13 @@ class AppGui(QWidget):
qw.setLayout(qgrid)
qw.setFixedWidth(460)
qw.setFixedHeight(280)
return qw
def reset_lastpwr(self):
sector_label = [None] * len(self.sec_state_list)
pv_initpwr = [None] * len(self.sec_state_list)
pv_lastpwr = [None] * len(self.sec_state_list)
qgrid = QGridLayout()
qsection = QLabel("Section")
qsection.setAlignment(Qt.AlignmentFlag(Qt.AlignBottom|Qt.AlignHCenter))
@@ -1307,7 +1372,7 @@ class AppGui(QWidget):
print(ex, self.settings.data[sector])
weight = "bold" if sector in self.settings.data[
"headerMagnetSector"] else "medium"
"headerMagnetSector"] else "medium"
color_str = "color : {0}; font-weight:{1};".format(color, weight)
incolor = "QLabel {" + color_str + "}"
@@ -1323,7 +1388,6 @@ class AppGui(QWidget):
qgrid.addWidget(pv_initpwr[i], i + 1, 1, 1, 1, Qt.AlignRight)
qgrid.addWidget(pv_lastpwr[i], i + 1, 2, 1, 1, Qt.AlignLeft)
qgrid.setContentsMargins(9, 9, 9, 9)
qgrid.setSpacing(10)