Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IDFFMODE in PS classes #729

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions pyqt-apps/siriushla/as_ps_commands/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
CheckComm, CheckStatus, \
ResetIntlk, CheckIntlk, \
SetSOFBMode, CheckSOFBMode, \
SetIDFFMode, CheckIDFFMode, \
SetOpMode, CheckOpMode, \
SetPwrState, CheckPwrState, CheckInitOk, \
SetPulse, CheckPulse, \
Expand Down Expand Up @@ -109,6 +110,9 @@ def _setup_ui(self):
'Turn Off SOFBMode': {
'cmd': _part(self._set_check_fbp_sofbmode, 'off'),
},
'Turn Off IDFFMode': {
'cmd': _part(self._set_check_fbp_idffmode, 'off'),
},
'Set PS and DCLinks to SlowRef': {
'cmd': self._set_check_opmode_slowref,
},
Expand Down Expand Up @@ -175,6 +179,9 @@ def _setup_ui(self):
'Turn Off SOFBMode': {
'cmd': _part(self._set_check_fbp_sofbmode, 'off'),
},
'Turn Off IDFFMode': {
'cmd': _part(self._set_check_fbp_idffmode, 'off'),
},
'Set PS and DCLinks to SlowRef': {
'cmd': self._set_check_opmode_slowref,
},
Expand Down Expand Up @@ -213,6 +220,9 @@ def _setup_ui(self):
'Turn Off SOFBMode': {
'cmd': _part(self._set_check_fbp_sofbmode, 'off'),
},
'Turn Off IDFFMode': {
'cmd': _part(self._set_check_fbp_idffmode, 'off'),
},
'Reset PS and DCLinks': {
'cmd': _part(self._reset_intlk, 'PS'),
},
Expand Down Expand Up @@ -977,6 +987,28 @@ def _set_check_fbp_sofbmode(self, state):
dlg = ProgressDialog(labels, tasks, self)
dlg.exec_()

def _set_check_fbp_idffmode(self, state):
self.ok_ps.clear()
self.nok_ps.clear()
devices = self._get_selected_ps()
devices = [dev for dev in devices
if PSSearch.conv_psname_2_psmodel(dev) == 'FBP']
if not devices:
return

task0 = CreateTesters(devices, parent=self)
task1 = SetIDFFMode(devices, state=state, parent=self)
task2 = CheckIDFFMode(devices, state=state, parent=self)
task2.itemDone.connect(self._log)
tasks = [task0, task1, task2]

labels = ['Connecting to devices...',
'Turning PS IDFFMode '+state+'...',
'Checking PS IDFFMode '+state+'...']

dlg = ProgressDialog(labels, tasks, self)
dlg.exec_()

def _set_test_ps(self):
self.ok_ps.clear()
self.nok_ps.clear()
Expand Down
16 changes: 16 additions & 0 deletions pyqt-apps/siriushla/as_ps_commands/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,22 @@ def function(self):
self._check(method='check_sofbmode', state=self._state)


class CheckIDFFMode(BaseTask):
"""Check PS IDFFMode."""

def function(self):
"""Check PS IDFFMode."""
self._check(method='check_idffmode', state=self._state)


class SetIDFFMode(BaseTask):
"""Set PS IDFFMode."""

def function(self):
"""Set PS IDFFMode."""
self._set(method='set_idffmode', state=self._state)


class SetOpMode(BaseTask):
"""Set PS OpMode."""

Expand Down
35 changes: 34 additions & 1 deletion pyqt-apps/siriushla/as_ps_control/SummaryWidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def get_prop2width(psname):
'strength_mon': 8})
if psmodel == 'FBP':
dic.update({'sofbmode': 6})
dic.update({'idffmode': 6})
if psname.dis == 'PU':
dic.update({'pulse': 8})
if HasTrim.match(psname):
Expand Down Expand Up @@ -176,6 +177,7 @@ def get_prop2label(psname):
'strength_mon': strength + '-Mon'})
if psmodel == 'FBP':
dic.update({'sofbmode': 'SOFBMode'})
dic.update({'idffmode': 'IDFFMode'})
if psname.dis == 'PU':
dic.update({'pulse': 'Pulse'})
if HasTrim.match(psname):
Expand All @@ -187,7 +189,7 @@ def sort_propties(labels):
default_order = (
'detail', 'bbb', 'udc', 'opmode', 'ctrlmode', 'state', 'pulse',
'intlk', 'alarm', 'reset', 'conn', 'ctrlloop', 'wfmupdate',
'updparms', 'sofbmode', 'accgain', 'accfreeze', 'accclear',
'updparms', 'sofbmode', 'idffmode', 'accgain', 'accfreeze', 'accclear',
'setpoint', 'readback', 'monitor', 'strength_sp',
'strength_rb', 'strength_mon', 'trim')
idcs = list()
Expand Down Expand Up @@ -241,6 +243,7 @@ def __init__(self, name, visible_props, parent=None):
self._has_parmupdt = not self._is_linac and not self._is_regatron\
and not self._is_fofb
self._has_sofbmode = self._is_fbp
self._has_idffmode = self._is_fbp
self._has_wfmupdt = self._has_parmupdt and not self._is_dclink
self._has_analsp = not self._is_reg_slave
self._has_analrb = not self._is_regatron
Expand Down Expand Up @@ -348,6 +351,11 @@ def _setup_ui(self):
self._widgets_dict['sofbmode'] = self.sofbmode_wid
lay.addWidget(self.sofbmode_wid)

if self._has_idffmode:
self.idffmode_wid = self._build_widget(name='idffmode')
self._widgets_dict['idffmode'] = self.idffmode_wid
lay.addWidget(self.idffmode_wid)

if self._is_fofb:
self.accgain_wid = self._build_widget(
name='accgain', orientation='v')
Expand Down Expand Up @@ -526,6 +534,12 @@ def _create_pvs(self):
self._sofbmode_sts = self._prefixed_name.substitute(
propty='SOFBMode-Sts')

if self._has_idffmode:
self._idffmode_sel = self._prefixed_name.substitute(
propty='IDFFMode-Sel')
self._idffmode_sts = self._prefixed_name.substitute(
propty='IDFFMode-Sts')

if self._is_fofb:
self._accgain_sp = self._prefixed_name.substitute(
propty='FOFBAccGain-SP')
Expand Down Expand Up @@ -682,6 +696,11 @@ def fillWidget(self, name):
self.sofbmode_led = SiriusLedState(self, self._sofbmode_sts)
self.sofbmode_wid.layout().addWidget(self.sofbmode_bt)
self.sofbmode_wid.layout().addWidget(self.sofbmode_led)
elif name == 'idffmode' and self._has_idffmode:
self.idffmode_bt = PyDMStateButton(self, self._idffmode_sel)
self.idffmode_led = SiriusLedState(self, self._idffmode_sts)
self.idffmode_wid.layout().addWidget(self.idffmode_bt)
self.idffmode_wid.layout().addWidget(self.idffmode_led)
elif name == 'accgain' and self._is_fofb:
self.accgain_sp = SiriusSpinbox(self, self._accgain_sp)
self.accgain_sp.precisionFromPV = False
Expand Down Expand Up @@ -843,6 +862,20 @@ def sofbmode_off(self):
if self.sofbmode_bt.value:
self.sofbmode_bt.send_value()

def idffmode_on(self):
"""Turn IDFFMode on."""
if hasattr(self, 'idffmode_bt'):
if self.idffmode_bt.isEnabled():
if not self.idffmode_bt.value:
self.idffmode_bt.send_value()

def idffmode_off(self):
"""Turn IDFFMode off."""
if hasattr(self, 'idffmode_bt'):
if self.idffmode_bt.isEnabled():
if self.idffmode_bt.value:
self.idffmode_bt.send_value()

def set_accfreeze_frozen(self):
"""Set power supply AccFreeze to frozen."""
if hasattr(self, 'accfreeze_cb'):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,14 @@ def _create_actions(self):
self.sofbmode_off_act.triggered.connect(
lambda: self._set_sofbmode(False))
self.sofbmode_off_act.setEnabled(False)
self.idffmode_on_act = QAction("Set IDFFMode On", self)
self.idffmode_on_act.triggered.connect(
lambda: self._set_idffmode(True))
self.idffmode_on_act.setEnabled(False)
self.idffmode_off_act = QAction("Set IDFFMode Off", self)
self.idffmode_off_act.triggered.connect(
lambda: self._set_idffmode(False))
self.idffmode_off_act.setEnabled(False)
self.set_accfreeze_frozen_act = QAction(
"Set AccFreeze to frozen", self)
self.set_accfreeze_frozen_act.triggered.connect(
Expand Down Expand Up @@ -556,6 +564,10 @@ def _enable_actions(self):
not self.sofbmode_on_act.isEnabled():
self.sofbmode_on_act.setEnabled(True)
self.sofbmode_off_act.setEnabled(True)
if 'idffmode' in self.visible_props and \
not self.idffmode_on_act.isEnabled():
self.idffmode_on_act.setEnabled(True)
self.idffmode_off_act.setEnabled(True)
if 'accfreeze' in self.visible_props and \
not self.set_accfreeze_frozen_act.isEnabled():
self.set_accfreeze_frozen_act.setEnabled(True)
Expand Down Expand Up @@ -662,6 +674,19 @@ def _set_sofbmode(self, state):
except TypeError:
pass

@Slot(bool)
def _set_idffmode(self, state):
"""Execute turn IDFFMode on/off actions."""
for key, widget in self.ps_widgets_dict.items():
if key in self.filtered_widgets:
try:
if state:
widget.idffmode_on()
else:
widget.idffmode_off()
except TypeError:
pass

@Slot(bool)
def _set_acc_freeze(self, state):
"""Execute turn AccFreeze frozen/unfrozen actions."""
Expand Down Expand Up @@ -708,6 +733,8 @@ def contextMenuEvent(self, event):
if PSSearch.conv_psname_2_psmodel(self._dev_list[0]) == 'FBP':
menu.addAction(self.sofbmode_on_act)
menu.addAction(self.sofbmode_off_act)
menu.addAction(self.idffmode_on_act)
menu.addAction(self.idffmode_off_act)
menu.addSeparator()
action = menu.addAction('Show Connections...')
action.triggered.connect(self.show_connections)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ class PSDetailWidget(_BaseDetailWidget):
'WfmIndex-Mon', 'WfmSyncPulseCount-Mon',
'WfmUpdateAuto-Sel', 'WfmUpdateAuto-Sts',
'SOFBMode-Sel', 'SOFBMode-Sts', 'SOFBUpdate-Cmd',
'IDFFMode-Sel', 'IDFFMode-Sts',
'PRUCtrlQueueSize-Mon', 'SyncPulse-Cmd',
'Wfm-SP', 'Wfm-RB', 'WfmRef-Mon', 'Wfm-Mon',
'Voltage-SP', 'Voltage-RB', 'VoltageRef-Mon', 'Voltage-Mon',
Expand Down
Loading
Loading