from __future__ import annotations
#-----------------------------------------------------------------------------
# Company : SLAC National Accelerator Laboratory
#-----------------------------------------------------------------------------
# Description:
# PyRogue PyDM Run Control Widget
#-----------------------------------------------------------------------------
# This file is part of the rogue software platform. It is subject to
# the license terms in the LICENSE.txt file found in the top-level directory
# of this distribution and at:
# https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
# No part of the rogue software platform, including this file, may be
# copied, modified, propagated, or distributed except according to the terms
# contained in the LICENSE.txt file.
#-----------------------------------------------------------------------------
from pydm.widgets.frame import PyDMFrame
from pydm.widgets import PyDMEnumComboBox, PyDMLabel
from pyrogue.pydm.data_plugins.rogue_plugin import nodeFromAddress
from qtpy.QtCore import Qt
from qtpy.QtWidgets import QVBoxLayout, QHBoxLayout, QFormLayout, QGroupBox, QWidget
[docs]
class RunControl(PyDMFrame):
"""PyDM widget for controlling a ``pyrogue.RunControl`` node.
Parameters
----------
parent : QWidget | None, optional
Parent Qt widget.
init_channel : str | None, optional
Initial Rogue channel address.
"""
def __init__(self, parent: QWidget | None = None, init_channel: str | None = None) -> None:
PyDMFrame.__init__(self, parent, init_channel)
self._node = None
[docs]
def connection_changed(self, connected: bool) -> None:
"""Build controls after first successful channel connection."""
build = (self._node is None) and (self._connected != connected and connected is True)
super(RunControl, self).connection_changed(connected)
if not build:
return
self._node = nodeFromAddress(self.channel)
self._path = self.channel
vb = QVBoxLayout()
self.setLayout(vb)
gb = QGroupBox('Run Control ({})'.format(self._node.name))
vb.addWidget(gb)
vb = QVBoxLayout()
gb.setLayout(vb)
fl = QFormLayout()
fl.setRowWrapPolicy(QFormLayout.DontWrapRows)
fl.setFormAlignment(Qt.AlignHCenter | Qt.AlignTop)
fl.setLabelAlignment(Qt.AlignRight)
vb.addLayout(fl)
w = PyDMEnumComboBox(parent=None, init_channel=self._path + '.runRate')
w.alarmSensitiveContent = False
w.alarmSensitiveBorder = False
fl.addRow('Run Rate:',w)
hb = QHBoxLayout()
vb.addLayout(hb)
fl = QFormLayout()
fl.setRowWrapPolicy(QFormLayout.DontWrapRows)
fl.setFormAlignment(Qt.AlignHCenter | Qt.AlignTop)
fl.setLabelAlignment(Qt.AlignRight)
hb.addLayout(fl)
w = PyDMEnumComboBox(parent=None, init_channel=self._path + '.runState')
w.alarmSensitiveContent = False
w.alarmSensitiveBorder = False
fl.addRow('Run State:',w)
fl = QFormLayout()
fl.setRowWrapPolicy(QFormLayout.DontWrapRows)
fl.setFormAlignment(Qt.AlignHCenter | Qt.AlignTop)
fl.setLabelAlignment(Qt.AlignRight)
hb.addLayout(fl)
w = PyDMLabel(parent=None, init_channel=self._path + '.runCount')
w.showUnits = False
w.precisionFromPV = True
w.alarmSensitiveContent = False
w.alarmSensitiveBorder = False
fl.addRow('Run Count:',w)