Skip to content

Statusbar P09

statusbar_p09

This is part of the janus package.

Attributes

__author__ module-attribute

__author__ = 'Pontus Fischer'
__copyright__ = '(c)2022 DESY, FS-BMX'

__email__ module-attribute

__email__ = 'pontus.fischer@desy.de'

__license__ module-attribute

__license__ = 'GPL'

Classes

StatusbarP09Widget

StatusbarP09Widget(parent: QWidget = None, devices: Dict[str, any] = {})

Bases: QObject, Object

Source code in mfx/roadrunner/janus/widgets/statusbar_p09.py
def __init__(self, parent: QWidget = None, devices: Dict[str, any] = {}):
    QObject.__init__(self)
    Object.__init__(self)
    self.parent = parent
    for dev in self.used_devices:
        if dev in devices:
            self.devices[dev] = devices[dev]
        elif dev in self.janus.devices:
            self.devices[dev] = self.janus.devices[dev]
        else:
            self.janus.log.error("{type(self).__name__}.__init__() "
                    f"missing device {dev}")
    self.setup_ui()
    self.register_persistents()
    self.init_values()
    self.connect_signals()
Attributes
devices class-attribute instance-attribute
devices = {}
parent instance-attribute
parent = parent
used_devices class-attribute instance-attribute
used_devices = ['petra', 'energy', 'undulator', 'vacuum', 'beamshutter0', 'beamshutter1', 'beamshutter2', 'beamshutter3', 'fastshutter_upstream', 'fastshutter', 'gonio', 'motor_detector_z', 'detector']
Functions
connect_signals
connect_signals()
Source code in mfx/roadrunner/janus/widgets/statusbar_p09.py
def connect_signals(self):

    self.devices["petra"].value_changed.connect(self.update_petra)
    self.devices["energy"].value_changed.connect(self.update_energy)
    self.devices["undulator"].value_changed.connect(self.update_undulator)
    self.devices["vacuum"].value_changed.connect(self.update_vacuum)
    self.devices["beamshutter0"].value_changed.connect(self.update_beamshutter0)
    self.devices["beamshutter1"].value_changed.connect(self.update_beamshutter1)
    self.devices["beamshutter2"].value_changed.connect(self.update_beamshutter2)
    self.devices["beamshutter3"].value_changed.connect(self.update_beamshutter3)
    self.devices["fastshutter_upstream"].value_changed.connect(self.update_fastshutter_upstream)
    self.devices["fastshutter"].value_changed.connect(self.update_fastshutter)
    self.devices["gonio"].value_changed.connect(self.update_gonio)
    self.devices["motor_detector_z"].value_changed.connect(self.update_detector_z)
    self.devices["detector"].value_changed.connect(self.update_detector)
init_values
init_values()
Source code in mfx/roadrunner/janus/widgets/statusbar_p09.py
def init_values(self):
    value_infos = [
        {"device": "petra", "attribute": "BeamCurrent", "setter": self.update_petra},
        {"device": "energy", "attribute": "State", "setter": self.update_energy},
        {"device": "energy", "attribute": "Position", "setter": self.update_energy},
        {"device": "undulator", "attribute": "State", "setter": self.update_undulator},
        {"device": "undulator", "attribute": "Position", "setter": self.update_undulator},
        {"device": "vacuum", "attribute": "BeamInEH", "setter": self.update_vacuum},
        {"device": "beamshutter0", "attribute": "Value", "setter": self.update_beamshutter0},
        {"device": "beamshutter1", "attribute": "Value", "setter": self.update_beamshutter1},
        {"device": "beamshutter2", "attribute": "Value", "setter": self.update_beamshutter2},
        {"device": "beamshutter3", "attribute": "Value", "setter": self.update_beamshutter3},
        {"device": "fastshutter_upstream", "attribute": "Value", "setter": self.update_fastshutter_upstream},
        {"device": "fastshutter", "attribute": "Value", "setter": self.update_fastshutter},
        {"device": "gonio", "attribute": "state", "setter": self.update_gonio},
        {"device": "gonio", "attribute": "position", "setter": self.update_gonio},
        {"device": "motor_detector_z", "attribute": "state", "setter": self.update_detector_z},
        {"device": "motor_detector_z", "attribute": "position", "setter": self.update_detector_z},
        {"device": "detector", "attribute": "State", "setter": self.update_detector},
    ]
    for info in value_infos:
        value = self.devices[info["device"]].read(info["attribute"])
        if value is not None:
            info["setter"](info["attribute"], value)
register_persistents
register_persistents()
Source code in mfx/roadrunner/janus/widgets/statusbar_p09.py
def register_persistents(self):
    pass
setup_ui
setup_ui()
Source code in mfx/roadrunner/janus/widgets/statusbar_p09.py
def setup_ui(self):
    from .ui.statusbar_p09_ui import Ui_Statusbar_P09
    self.widget = QWidget(self.parent)
    self.ui = Ui_Statusbar_P09()
    self.ui.setupUi(self.widget)
    value = self.devices["gonio"].read(MotorAttributes.STATE)
    color = DeviceStateColor.to_color(value)
update_beamshutter0
update_beamshutter0(attribute, value)
Source code in mfx/roadrunner/janus/widgets/statusbar_p09.py
def update_beamshutter0(self, attribute, value):
    if attribute == "Value":
        if value == True:
            self.ui.labelStatusBS0.setStyleSheet("background-color: #00ff00")
        else:
            self.ui.labelStatusBS0.setStyleSheet("background-color: #ff0000")
update_beamshutter1
update_beamshutter1(attribute, value)
Source code in mfx/roadrunner/janus/widgets/statusbar_p09.py
def update_beamshutter1(self, attribute, value):
    if attribute == "Value":
        if value == True:
            self.ui.labelStatusBS1.setStyleSheet("background-color: #00ff00")
        else:
            self.ui.labelStatusBS1.setStyleSheet("background-color: #ff0000")
update_beamshutter2
update_beamshutter2(attribute, value)
Source code in mfx/roadrunner/janus/widgets/statusbar_p09.py
def update_beamshutter2(self, attribute, value):
    if attribute == "Value":
        if value == True:
            self.ui.labelStatusBS2.setStyleSheet("background-color: #00ff00")
        else:
            self.ui.labelStatusBS2.setStyleSheet("background-color: #ff0000")
update_beamshutter3
update_beamshutter3(attribute, value)
Source code in mfx/roadrunner/janus/widgets/statusbar_p09.py
def update_beamshutter3(self, attribute, value):
    if attribute == "Value":
        if value == True:
            self.ui.labelStatusBS3.setStyleSheet("background-color: #00ff00")
        else:
            self.ui.labelStatusBS3.setStyleSheet("background-color: #ff0000")
update_detector
update_detector(attribute, value)
Source code in mfx/roadrunner/janus/widgets/statusbar_p09.py
def update_detector(self, attribute, value):
    if attribute == "State":
        color = DeviceStateColor.to_color(value)
        self.ui.labelStatusDetector.setStyleSheet(
                f"background-color: {color.name()};")

        self.ui.labelStatusDetector.setText("Detector status:\n%s"%value)
update_detector_z
update_detector_z(attribute, value)
Source code in mfx/roadrunner/janus/widgets/statusbar_p09.py
def update_detector_z(self, attribute, value):
    #if attribute == MotorAttributes.STATE:
    if attribute == "State" or attribute == MotorAttributes.STATE:
        color = DeviceStateColor.to_color(value)
        self.ui.labelStatusDetectorDistance.setStyleSheet(
                f"background-color: {color.name()};")
    #elif attribute == MotorAttributes.POSITION:
    elif attribute == "Position" or attribute == MotorAttributes.POSITION:
        self.ui.labelStatusDetectorDistance.setText("Detector distance:\n%.2f mm"%(value/1000.))
update_energy
update_energy(attribute, value)
Source code in mfx/roadrunner/janus/widgets/statusbar_p09.py
def update_energy(self, attribute, value):
    if attribute == "State":
        color = DeviceStateColor.to_color(value)
        self.ui.labelStatusMonoEnergy.setStyleSheet(f"background-color: {color.name()};")
    elif attribute == "Position":
        self.ui.labelStatusMonoEnergy.setText("Energy: %.2f eV"%value + "\nWavelength: %.2f "%(12398.4/value)+chr(197))
update_fastshutter
update_fastshutter(attribute, value)
Source code in mfx/roadrunner/janus/widgets/statusbar_p09.py
def update_fastshutter(self, attribute, value):
    if attribute == "Value":
        if value == True:
            self.ui.labelStatusFS_EH3.setStyleSheet("background-color: #00ff00")
        else:
            self.ui.labelStatusFS_EH3.setStyleSheet("background-color: #ff0000")
update_fastshutter_upstream
update_fastshutter_upstream(attribute, value)
Source code in mfx/roadrunner/janus/widgets/statusbar_p09.py
def update_fastshutter_upstream(self, attribute, value):
    if attribute == "Value":
        if value == True:
            self.ui.labelStatusFS_Upstream.setStyleSheet("background-color: #00ff00")
        else:
            self.ui.labelStatusFS_Upstream.setStyleSheet("background-color: #ff0000")
update_gonio
update_gonio(attribute, value)
Source code in mfx/roadrunner/janus/widgets/statusbar_p09.py
def update_gonio(self, attribute, value):
    #if attribute == MotorAttributes.STATE:
    if attribute == "State" or attribute == MotorAttributes.STATE:
        color = DeviceStateColor.to_color(value)
        self.ui.labelStatusCurrentAngle.setStyleSheet(
                f"background-color: {color.name()};")
    #elif attribute == MotorAttributes.POSITION:
    elif attribute == "Position" or attribute == MotorAttributes.POSITION:
        self.ui.labelStatusCurrentAngle.setText("Angle: %.2f"%value+chr(176))
update_petra
update_petra(attribute, value)
Source code in mfx/roadrunner/janus/widgets/statusbar_p09.py
def update_petra(self, attribute, value):
    if attribute == "BeamCurrent":
        self.ui.labelStatusPetraCurrent.setText("Petra current: %.2f mA"%float(value))
        if (float(value) > 75):
            self.ui.labelStatusPetraCurrent.setStyleSheet("background-color: #00ff00;")
        else:
            self.ui.labelStatusPetraCurrent.setStyleSheet("background-color: #ff0000;")
update_undulator
update_undulator(attribute, value)
Source code in mfx/roadrunner/janus/widgets/statusbar_p09.py
def update_undulator(self, attribute, value):
    if attribute == "State":
        color = DeviceStateColor.to_color(value)
        self.ui.labelStatusUndulator.setStyleSheet(f"background-color: {color.name()};")
    elif attribute == "Position":
        self.ui.labelStatusUndulator.setText("Undulator: %.2f eV"%value)
update_vacuum
update_vacuum(attribute, value)
Source code in mfx/roadrunner/janus/widgets/statusbar_p09.py
def update_vacuum(self, attribute, value):
    if attribute == "BeamInEH":
        if value == True:
            self.ui.labelStatusVAC.setStyleSheet("background-color: #00ff00")
        else:
            self.ui.labelStatusVAC.setStyleSheet("background-color: #ff0000")