5 Commits

4 changed files with 121 additions and 34 deletions
+2 -2
View File
@@ -21,7 +21,7 @@ from pyrcc5 import hush_resources
_pymodule = os.path.basename(__file__) _pymodule = os.path.basename(__file__)
_appname, _appext = _pymodule.split(".") _appname, _appext = _pymodule.split(".")
_appversion = "2.0.0" _appversion = "2.3.0"
# _title = """HIPA Power Usage & Saving Hierarchy""" #, HUSH!""" # _title = """HIPA Power Usage & Saving Hierarchy""" #, HUSH!"""
_title = """HUSH!""" _title = """HUSH!"""
@@ -185,7 +185,7 @@ class StartMain(BaseWindow):
All rights reserved.</p> All rights reserved.</p>
<p>Author: J. Chrin, Spring 2023 </p> <p>Author: J. Chrin, Spring 2023 </p>
<p>(EPICS db adapted from A. Kovach, 2016) <p> <p>(EPICS db adapted from A. Kovach, 2016) <p>
<p>IOC Administrator: H. Lutz </p> <p>IOC Administrator: P. Fernandez (prev. H. Lutz) </p>
<p>1st Responsible: A. Barchetti, Tel. 4779 <p>1st Responsible: A. Barchetti, Tel. 4779
or 3301 (Control Room) </p> or 3301 (Control Room) </p>
+10 -5
View File
@@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
cd /hipa/bd/applications/hush/hla/2.1.0 cd /hipa/bd/applications/hush/hla/2.3.0
# For use if script is sourced rather than executed # For use if script is sourced rather than executed
appNameDefault="hush.sh" appNameDefault="hush.sh"
module unload gcc module unload gcc
module load gcc/7.3.0 module load gcc/7.5.0
if [ -z "$PS1" ] # no prompt? if [ -z "$PS1" ] # no prompt?
### if [ -v PS1 ] # On Bash 4.2+ ... ### if [ -v PS1 ] # On Bash 4.2+ ...
@@ -17,6 +17,9 @@ else
echo "Interactive/sourced script" echo "Interactive/sourced script"
fi fi
_EPICS_HOST_ARCH=${RHREL}-x86_64
_EPICS_BASE=base-7.0.8
# Select Python Version here. Currently one of 3.5, 3.7, 3.8 and 3.10 # Select Python Version here. Currently one of 3.5, 3.7, 3.8 and 3.10
PYTHON_VERSION=3.10 PYTHON_VERSION=3.10
@@ -32,6 +35,7 @@ if [ "$1" ]; then
elif [ "$1" == "3.7" -o "$1" == "37" ]; then elif [ "$1" == "3.7" -o "$1" == "37" ]; then
PYTHON_VERSION=3.7 PYTHON_VERSION=3.7
PYTHON_VERSION_DIR=37 PYTHON_VERSION_DIR=37
export LD_PRELOAD=/usr/local/epics/${_EPICS_BASE}/lib/${_EPICS_HOST_ARCH}/libca.so:/usr/local/epics/${_EPICS_BASE}/lib/${_EPICS_HOST_ARCH}/libCom.so
elif [ "$1" == "3.8" -o "$1" == "38" ]; then elif [ "$1" == "3.8" -o "$1" == "38" ]; then
PYTHON_VERSION=3.8 PYTHON_VERSION=3.8
PYTHON_VERSION_DIR=38 PYTHON_VERSION_DIR=38
@@ -50,13 +54,11 @@ fi
echo "PYTHON_VERSION $PYTHON_VERSION" echo "PYTHON_VERSION $PYTHON_VERSION"
_EPICS_HOST_ARCH=${RHREL}-x86_64
#_EPICS_HOST_ARCH=${EPICS_HOST_ARCH}
. /opt/gfa/python $PYTHON_VERSION . /opt/gfa/python $PYTHON_VERSION
#C_EXT version for Py 3.5, 3.7. 3.8, 3.10: #C_EXT version for Py 3.5, 3.7. 3.8, 3.10:
export PYTHONPATH=.:/opt/gfa/cafe/python/pycafe/cafe-1.19.3/lib/${_EPICS_HOST_ARCH}:/hipa/bd/applications/deps/apps4ops/v1.10.0 export PYTHONPATH=.:/opt/gfa/cafe/python/pycafe/cafe-1.21.0/lib/${_EPICS_HOST_ARCH}:/hipa/bd/applications/deps/apps4ops/v1.12.0
echo $PYTHONPATH echo $PYTHONPATH
@@ -111,3 +113,6 @@ else
fi fi
if [ "${PYTHON_VERSION}" == "3.7" ] ; then
unset LD_PRELOAD
fi
Binary file not shown.
+109 -27
View File
@@ -19,7 +19,11 @@ from qtpy.QtWidgets import (
QPushButton, QTabBar, QTabWidget, QTableWidgetItem, QTextEdit, QVBoxLayout, QPushButton, QTabBar, QTabWidget, QTableWidgetItem, QTextEdit, QVBoxLayout,
QWidget) QWidget)
from common.packages import elog try:
import elog
except:
from common.packages import elog
from apps4ops.bdbase.utils import _line from apps4ops.bdbase.utils import _line
@@ -81,7 +85,7 @@ class AppGui(QWidget):
self.table_pwr_dict = {} self.table_pwr_dict = {}
self.offtime_dict = {} self.offtime_dict = {}
self.I_min = 1.0 self.I_min = 1.0 #0.09 for testing
self.with_rf = False self.with_rf = False
self.sec_state_list = ["ZIP2-HUSH:STATE", "ZIW2-HUSH:STATE", self.sec_state_list = ["ZIP2-HUSH:STATE", "ZIW2-HUSH:STATE",
@@ -92,10 +96,16 @@ class AppGui(QWidget):
self.cafe.open(["ZHIPA-HUSH:LASTPWR", "ZHIPA-HUSH:TOTPWR", self.cafe.open(["ZHIPA-HUSH:LASTPWR", "ZHIPA-HUSH:TOTPWR",
"ZHIPA-HUSH:LASTSAVE", "ZHIPA-HUSH:TOTSAVE"]) "ZHIPA-HUSH:LASTSAVE", "ZHIPA-HUSH:TOTSAVE"])
self.cafe.open(self.sec_state_list) self.cafe.open(self.sec_state_list)
self.cafe.open("UCN:BEAMREQ:STATUS") #self.cafe.open("UCNQ:BEAMREQ:STATUS")
self.cafe.openNowAndWait(0.1) self.cafe.openNowAndWait(0.1)
self.cafe.monitor("UCNQ:BEAMREQ:STATUS") self.uncq_beam_req = self.cafe.getCache("UCNQ:BEAMREQ:STATUS")
if self.uncq_beam_req is None:
self.uncq_beam_req = "stopped"
self.beam_req_running = False \
if self.uncq_beam_req == "stopped" else True
#self.cafe.monitor("UCNQ:BEAMREQ:STATUS")
idx = self.settings.data["header"].index("IP2") idx = self.settings.data["header"].index("IP2")
self.sectorI_dict = {} self.sectorI_dict = {}
@@ -158,8 +168,8 @@ class AppGui(QWidget):
ucn_line = ["PK1", "PK2", "UCN"] ucn_line = ["PK1", "PK2", "UCN"]
sinq_line = ["PK1", "PK2", "SINQ"] sinq_line = ["PK1", "PK2", "SINQ"]
pk1_line = ["IW2"] pk1_line = ["IW2", "PK1"]
pk2_line = ["IW2"] pk2_line = ["IW2", "PK1", "PK2"]
for sector in self.settings.data["header"][idx:]: for sector in self.settings.data["header"][idx:]:
gateway_indices = self.get_standby_index_list(sector) gateway_indices = self.get_standby_index_list(sector)
@@ -172,22 +182,49 @@ class AppGui(QWidget):
idx].trigger_monitor_float.emit( idx].trigger_monitor_float.emit(
pvd.value[0], pvd.status, pvd.alarmSeverity) pvd.value[0], pvd.status, pvd.alarmSeverity)
def enable_disable_ucn(sect, sector_line, value):
def enable_disable_ucn(sect, sector_line, value):
self.sectorI_dict[sect] = value self.sectorI_dict[sect] = value
'''
beam_req_running = True beam_req_running = True
beam_req_status = self.cafe.getCache("UCNQ:BEAMREQ:STATUS")
#print(" beam_req_status", beam_req_status, flush=True)
if beam_req_status is not None:
if beam_req_status == "stopped":
beam_req_running = False
def is_beam_req_running():
beam_req_running = True
beam_req_status = self.uncq_beam_req #self.cafe.getCache("UCNQ:BEAMREQ:STATUS")
if beam_req_status is not None:
if beam_req_status == "stopped":
beam_req_running = False
return beam_req_running
'''
for sector in sector_line: for sector in sector_line:
beam_req_flag = True beam_req_flag = False
if sector == "UCN": if sector == "UCN":
beam_req_flag = beam_req_running beam_req_flag = self.beam_req_running #is_beam_req_running()
'''
with self.lock:
if not beam_req_flag:
if not self.table_sol_dict[
sector].init_value_button.isEnabled():
self.table_sol_dict[
sector].init_value_button.setEnabled(True)
if not self.table_pwr_dict[
sector].init_value_button.isEnabled():
self.table_pwr_dict[
sector].init_value_button.setEnabled(True)
else:
if self.table_sol_dict[
sector].init_value_button.isEnabled():
self.table_sol_dict[
sector].init_value_button.setEnabled(False)
if self.table_pwr_dict[
sector].init_value_button.isEnabled():
self.table_pwr_dict[
sector].init_value_button.setEnabled(False)
'''
# 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 or beam_req_flag: if self.sectorI_dict[sector] > self.I_min or beam_req_flag:
@@ -195,7 +232,6 @@ 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)
else: else:
if not self.table_sol_dict[ if not self.table_sol_dict[
sector].standby_value_button.isEnabled(): sector].standby_value_button.isEnabled():
@@ -220,9 +256,16 @@ class AppGui(QWidget):
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
#print("==>sector firing", sect, "with value", value)
for sector in sector_line: for sector in sector_line:
if self.sectorI_dict["PK1"] > self.I_min or self.sectorI_dict[ #print("sector", sector, "in line", sector_line,
"PK2"] > self.I_min: # "has value", self.sectorI_dict[sector]
#)
#if self.sectorI_dict["PK1"] > self.I_min or self.sectorI_dict[
# "PK2"] > self.I_min:
if self.sectorI_dict[sector] > self.I_min:
if self.table_sol_dict[ if self.table_sol_dict[
sector].standby_value_button.isEnabled(): sector].standby_value_button.isEnabled():
self.table_sol_dict[ self.table_sol_dict[
@@ -233,6 +276,18 @@ class AppGui(QWidget):
self.table_sol_dict[ self.table_sol_dict[
sector].standby_value_button.setEnabled(True) sector].standby_value_button.setEnabled(True)
def receive_ucnq_update(value, status, alarm_severity):
del status, alarm_severity
self.uncq_beam_req = value
print("self.uncq_beam_req", self.uncq_beam_req)
self.beam_req_running = True
if self.uncq_beam_req is not None:
if self.uncq_beam_req == "stopped":
self.beam_req_running = False
enable_disable_ucn("UCN", ucn_line, self.sectorI_dict["UCN"])
def receive_ucn_update(value, status, alarm_severity): def receive_ucn_update(value, status, alarm_severity):
del status, alarm_severity del status, alarm_severity
enable_disable_ucn("UCN", ucn_line, value) enable_disable_ucn("UCN", ucn_line, value)
@@ -249,6 +304,9 @@ class AppGui(QWidget):
del status, alarm_severity del status, alarm_severity
enable_disable_pk("PK2", pk2_line, value) enable_disable_pk("PK2", pk2_line, value)
self.gui_header.beam_current_wgt_dict[
"UCNQ"].trigger_monitor_str.connect(receive_ucnq_update)
self.gui_header.beam_current_wgt_dict[ self.gui_header.beam_current_wgt_dict[
"UCN"].trigger_monitor_float.connect(receive_ucn_update) "UCN"].trigger_monitor_float.connect(receive_ucn_update)
self.gui_header.beam_current_wgt_dict[ self.gui_header.beam_current_wgt_dict[
@@ -258,6 +316,11 @@ class AppGui(QWidget):
self.gui_header.beam_current_wgt_dict[ self.gui_header.beam_current_wgt_dict[
"PK2"].trigger_monitor_float.connect(receive_pk2_update) "PK2"].trigger_monitor_float.connect(receive_pk2_update)
pvd = self.cafe.getPV("UCNQ:BEAMREQ:STATUS")
self.gui_header.beam_current_wgt_dict[
"UCNQ"].trigger_monitor_str.emit(
pvd.value[0], pvd.status, pvd.alarmSeverity)
# Not required any longer # Not required any longer
@Slot(int, str, object) @Slot(int, str, object)
@@ -358,9 +421,17 @@ class AppGui(QWidget):
val_now = self.sector_designated_magnet_values_dict[sector][pv] val_now = self.sector_designated_magnet_values_dict[sector][pv]
val_standby = self.sector_designated_magnet_standby_dict[sector][pv] val_standby = self.sector_designated_magnet_standby_dict[sector][pv]
#print(sector, val_now, val_standby) #print(sector, val_now, val_standby)
if abs(val_now) > (1.2 * abs(val_standby)): if sector == "UCN":
is_standby = False is_standby = False
break if not (abs(val_now) > (1.2 * abs(val_standby))):
is_standby = True
break
else:
if abs(val_now) > (1.2 * abs(val_standby)):
is_standby = False
break
with self.lock: with self.lock:
if not is_standby: if not is_standby:
@@ -981,6 +1052,7 @@ class AppGui(QWidget):
hbox.setSpacing(10) hbox.setSpacing(10)
hbox.setAlignment(Qt.AlignTop) hbox.setAlignment(Qt.AlignTop)
qw = QWidget() qw = QWidget()
qw.setLayout(hbox) qw.setLayout(hbox)
@@ -1032,11 +1104,19 @@ class AppGui(QWidget):
pass pass
# HIPA Log Book # HIPA Log Book
else: else:
attributes["Eintrag"] = self.elog_enum.eintrag.INFO.name required_dict = self.parent.settings.data['ElogBooks'][
attributes["Effekt"] = self.elog_enum.effekt.NONE.name # keiner self.parent.logbook]['Required']
optional_dict = self.parent.settings.data['ElogBooks'][
self.parent.logbook]['Optional']
attributes["Eintrag"] = required_dict['Eintrag'][
self.elog_enum.eintrag.INFO]
attributes["Effekt"] = optional_dict["Effekt"][
self.elog_enum.effekt.NONE] # NONE='', NO=keiner
# "Elektorversogung" # "Elektorversogung"
attributes["System"] = self.elog_enum.system.ELECTRICAL_SUPPLY.name attributes["System"] = optional_dict["System"][
attributes["Ort"] = self.elog_enum.ort.GLOBAL.name self.elog_enum.system.ELECTRICAL_SUPPLY]
attributes["Ort"] = optional_dict["Ort"][
self.elog_enum.ort.GLOBAL]
log_mess = self.parent.message.replace("<br>", "\n") log_mess = self.parent.message.replace("<br>", "\n")
@@ -1048,8 +1128,10 @@ class AppGui(QWidget):
self.statusbar.showMessage("Reset Savings Account." + self.statusbar.showMessage("Reset Savings Account." +
"Last values sent to elog") "Last values sent to elog")
except Exception as ex: except Exception as ex:
print("Exception in sendelog.py", str(ex), flush=True) print("Exception in gui.py", str(ex), flush=True)
mess = "Failed to write last saving values to elog:" + str(ex) print(attributes)
mess = ("Failed to write last saving values to " +
"logbook {0}: {1}").format(self.parent.logbook, str(ex))
self.show_log_message( self.show_log_message(
MsgSeverity.ERROR, _pymodule, _line(), mess) MsgSeverity.ERROR, _pymodule, _line(), mess)
self.statusbar.showMessage(mess) self.statusbar.showMessage(mess)