Skip to content

Commit

Permalink
Add IDFFMODE in PS classes
Browse files Browse the repository at this point in the history
  • Loading branch information
xresende committed Dec 4, 2024
1 parent aa1750f commit 6053a4c
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 20 deletions.
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
54 changes: 36 additions & 18 deletions pyqt-apps/siriushla/as_ps_cycle/cycle_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
from ..widgets.dialog import ProgressDialog, PSStatusDialog
from .tasks import CreateCyclers, VerifyPS, \
SaveTiming, PrepareTiming, RestoreTiming, \
PreparePSSOFBMode, PreparePSOpModeSlowRef, PreparePSCurrentZero, \
PreparePSSOFBMode, PreparePSIDFFMode, \
PreparePSOpModeSlowRef, PreparePSCurrentZero, \
PreparePSParams, PreparePSOpModeCycle, Cycle, CycleTrims


Expand Down Expand Up @@ -56,6 +57,7 @@ def __init__(self, parent=None, checked_accs=(), adv_mode=False):
self._prepared_init_vals = {
'timing': False,
'ps_sofbmode': False,
'ps_idffmode': False,
'ps_om_slowref': False,
'ps_current': False,
'ps_params': False,
Expand All @@ -73,6 +75,7 @@ def __init__(self, parent=None, checked_accs=(), adv_mode=False):
'save_timing': SaveTiming,
'timing': PrepareTiming,
'ps_sofbmode': PreparePSSOFBMode,
'ps_idffmode': PreparePSIDFFMode,
'ps_om_slowref': PreparePSOpModeSlowRef,
'ps_current': PreparePSCurrentZero,
'ps_params': PreparePSParams,
Expand Down Expand Up @@ -145,6 +148,17 @@ def _setup_ui(self):
self.set_ps_sofbmode_off_lb = QLabel(self)
self.set_ps_sofbmode_off_lb.setPixmap(self._pixmap_not)

self.set_ps_idffmode_off_bt = QPushButton(
'3. Turn off PS IDFFMode', self)
self.set_ps_idffmode_off_bt.setToolTip(
'Turn off power supplies IDFFMode.')
self.set_ps_idffmode_off_bt.clicked.connect(
_part(self._run_task, 'ps_idffmode'))
self.set_ps_idffmode_off_bt.clicked.connect(self._set_lastcomm)

self.set_ps_idffmode_off_lb = QLabel(self)
self.set_ps_idffmode_off_lb.setPixmap(self._pixmap_not)

self.set_ps_opmode_slowref_bt = QPushButton(
'4. Set PS OpMode to SlowRef', self)
self.set_ps_opmode_slowref_bt.setToolTip(
Expand Down Expand Up @@ -226,6 +240,7 @@ def _setup_ui(self):
self._prepared_labels = {
'timing': self.prepare_timing_lb,
'ps_sofbmode': self.set_ps_sofbmode_off_lb,
'ps_idffmode': self.set_ps_idffmode_off_lb,
'ps_om_slowref': self.set_ps_opmode_slowref_lb,
'ps_current': self.set_ps_current_zero_lb,
'ps_params': self.prepare_ps_params_lb,
Expand All @@ -250,26 +265,28 @@ def _setup_ui(self):
lay_commsts.addWidget(self.psconn_led, 5, 1)
lay_commsts.addWidget(self.set_ps_sofbmode_off_bt, 6, 0)
lay_commsts.addWidget(self.set_ps_sofbmode_off_lb, 6, 1)
lay_commsts.addWidget(self.set_ps_opmode_slowref_bt, 7, 0)
lay_commsts.addWidget(self.set_ps_opmode_slowref_lb, 7, 1)
lay_commsts.addWidget(self.set_ps_current_zero_bt, 8, 0)
lay_commsts.addWidget(self.set_ps_current_zero_lb, 8, 1)
lay_commsts.addWidget(self.prepare_ps_params_bt, 9, 0)
lay_commsts.addWidget(self.prepare_ps_params_lb, 9, 1)
lay_commsts.addWidget(self.prepare_ps_opmode_bt, 10, 0)
lay_commsts.addWidget(self.prepare_ps_opmode_lb, 10, 1)
lay_commsts.addWidget(self.set_ps_idffmode_off_bt, 7, 0)
lay_commsts.addWidget(self.set_ps_idffmode_off_lb, 7, 1)
lay_commsts.addWidget(self.set_ps_opmode_slowref_bt, 8, 0)
lay_commsts.addWidget(self.set_ps_opmode_slowref_lb, 8, 1)
lay_commsts.addWidget(self.set_ps_current_zero_bt, 9, 0)
lay_commsts.addWidget(self.set_ps_current_zero_lb, 9, 1)
lay_commsts.addWidget(self.prepare_ps_params_bt, 10, 0)
lay_commsts.addWidget(self.prepare_ps_params_lb, 10, 1)
lay_commsts.addWidget(self.prepare_ps_opmode_bt, 11, 0)
lay_commsts.addWidget(self.prepare_ps_opmode_lb, 11, 1)
lay_commsts.addItem(
QSpacerItem(1, 1, QSzPlcy.Ignored, QSzPlcy.Expanding), 11, 0)
lay_commsts.addWidget(lb_cycle, 12, 0)
lay_commsts.addWidget(self.cycle_trims_bt, 13, 0)
lay_commsts.addWidget(self.cycle_trims_lb, 13, 1)
lay_commsts.addWidget(self.cycle_bt, 14, 0)
QSpacerItem(1, 1, QSzPlcy.Ignored, QSzPlcy.Expanding), 12, 0)
lay_commsts.addWidget(lb_cycle, 13, 0)
lay_commsts.addWidget(self.cycle_trims_bt, 14, 0)
lay_commsts.addWidget(self.cycle_trims_lb, 14, 1)
lay_commsts.addWidget(self.cycle_bt, 15, 0)
lay_commsts.addItem(
QSpacerItem(1, 1, QSzPlcy.Ignored, QSzPlcy.Expanding), 15, 0)
lay_commsts.addWidget(lb_rest_ti, 16, 0)
lay_commsts.addWidget(self.restore_timing_bt, 17, 0)
QSpacerItem(1, 1, QSzPlcy.Ignored, QSzPlcy.Expanding), 16, 0)
lay_commsts.addWidget(lb_rest_ti, 17, 0)
lay_commsts.addWidget(self.restore_timing_bt, 18, 0)
lay_commsts.addItem(
QSpacerItem(1, 1, QSzPlcy.Ignored, QSzPlcy.Expanding), 18, 0)
QSpacerItem(1, 1, QSzPlcy.Ignored, QSzPlcy.Expanding), 19, 0)
lay_commsts.setColumnStretch(0, 10)
lay_commsts.setColumnStretch(1, 1)
lay_commsts.setVerticalSpacing(12)
Expand Down Expand Up @@ -435,6 +452,7 @@ def _handle_buttons_enabled(self, enable, cycle=False):
self.save_timing_bt.setEnabled(enable)
self.prepare_timing_bt.setEnabled(enable)
self.set_ps_sofbmode_off_bt.setEnabled(enable)
self.set_ps_idffmode_off_bt.setEnabled(enable)
self.set_ps_opmode_slowref_bt.setEnabled(enable)
self.set_ps_current_zero_bt.setEnabled(enable)
self.prepare_ps_params_bt.setEnabled(enable)
Expand Down
19 changes: 18 additions & 1 deletion pyqt-apps/siriushla/as_ps_cycle/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def function(self):


class PreparePSSOFBMode(BaseTask):
"""Prepare power suplies to cycle."""
"""Prepare power suplies to SOFBMode."""

def __init__(self, **kwargs):
super().__init__(need_controller=True, **kwargs)
Expand All @@ -199,6 +199,23 @@ def function(self):
self._controller.prepare_pwrsupplies_sofbmode()


class PreparePSIDFFMode(BaseTask):
"""Prepare power suplies to IDFFMode."""

def __init__(self, **kwargs):
super().__init__(need_controller=True, **kwargs)

def size(self):
return self._controller.prepare_ps_idffmode_size

def duration(self):
"""Return task maximum duration."""
return self._controller.prepare_ps_idffmode_max_duration

def function(self):
self._controller.prepare_pwrsupplies_idffmode()


class PreparePSOpModeSlowRef(BaseTask):
"""Prepare power suplies to cycle."""

Expand Down

0 comments on commit 6053a4c

Please sign in to comment.