Ejemplo n.º 1
0
    def _setup_ui(self):

        hbox = QtGui.QHBoxLayout(self)
        self.setLayout(hbox)

        form_vbox = self.vbox = QtGui.QVBoxLayout(self)

        hbox2 = QtGui.QVBoxLayout(self)
        self.device_and_state = DevnameAndState(self)
        hbox2.addWidget(self.device_and_state)
        self.magnet_type_label = QtGui.QLabel("Magnet type:")
        hbox2.addWidget(self.magnet_type_label)
        form_vbox.addLayout(hbox2)

        # attributes
        self.form = MAXForm(withButtons=False)
        form_vbox.addWidget(self.form, stretch=1)
        self.status_area = StatusArea(self)
        form_vbox.addWidget(self.status_area)
        hbox.addLayout(form_vbox)

        # value bar
        self.valuebar = MAXValueBar(self)
        slider_vbox = QtGui.QVBoxLayout(self)
        slider_vbox.setContentsMargins(10, 10, 10, 10)
        hbox.addLayout(slider_vbox)
        self.current_label = TaurusLabel()
        self.current_label.setAlignment(QtCore.Qt.AlignCenter)
        slider_vbox.addWidget(self.valuebar, 1)
        slider_vbox.addWidget(self.current_label)
Ejemplo n.º 2
0
    def _setup_ui(self):
        vbox = QtGui.QVBoxLayout(self)
        self.setLayout(vbox)

        grid = QtGui.QGridLayout()
        self.form = MAXForm(withButtons=False)

        grid.addWidget(self.form, 0, 0, 2, 1)
        # rescale taurus form methode
        self.form.scrollArea.sizeHint = self.scaleSize
        self.status_label = StatusArea()
        grid.addWidget(self.status_label, 0, 1, 1, 1)

        commandbox = QtGui.QVBoxLayout(self)
        self.start_button = TaurusCommandButton(command="StartCycle")
        self.start_button.setUseParentModel(True)
        self.stop_button = TaurusCommandButton(command="StopCycle")
        self.stop_button.setUseParentModel(True)
        commandbox.addWidget(self.start_button)
        commandbox.addWidget(self.stop_button)
        grid.addLayout(commandbox, 1, 1, 1, 1)

        vbox.addLayout(grid)

        self.trend = TaurusTrend()
        vbox.addWidget(self.trend, stretch=1)
        self.trend_trigger.connect(self.set_trend_paused)

        self.cyclingState = None
Ejemplo n.º 3
0
    def _setup_ui(self):
        hbox = QtGui.QHBoxLayout(self)
        self.setLayout(hbox)
        form_vbox = QtGui.QVBoxLayout(self)

        # devicename label
        hbox2 = QtGui.QVBoxLayout(self)
        self.device_and_state = DevnameAndState(self)
        hbox2.addWidget(self.device_and_state, stretch=2)

        # commands
        commandbox = QtGui.QHBoxLayout(self)
        self.start_button = TaurusCommandButton(command="Start")
        self.start_button.setUseParentModel(True)
        self.stop_button = TaurusCommandButton(command="Stop")
        self.stop_button.setUseParentModel(True)
        self.init_button = TaurusCommandButton(command="Init")
        self.init_button.setUseParentModel(True)
        self.on_button = TaurusCommandButton(command="On")
        self.on_button.setUseParentModel(True)
        self.off_button = TaurusCommandButton(command="Off")
        self.off_button.setUseParentModel(True)
        self.enable_trigger_button = TaurusCommandButton(
            command="EnableTrigger")
        self.enable_trigger_button.setUseParentModel(True)
        self.disable_trigger_button = TaurusCommandButton(
            command="DisableTrigger")
        self.disable_trigger_button.setUseParentModel(True)
        self.reset_button = TaurusCommandButton(command="Reset")
        self.reset_button.setUseParentModel(True)
        commandbox.addWidget(self.start_button)
        commandbox.addWidget(self.stop_button)
        commandbox.addWidget(self.init_button)
        commandbox.addWidget(self.on_button)
        commandbox.addWidget(self.off_button)
        commandbox.addWidget(self.enable_trigger_button)
        commandbox.addWidget(self.disable_trigger_button)
        commandbox.addWidget(self.reset_button)
        hbox2.addLayout(commandbox, stretch=1)
        form_vbox.addLayout(hbox2)

        # attributes
        self.form = MAXForm(withButtons=False)

        form_vbox.addLayout(commandbox)
        form_vbox.addWidget(self.form, stretch=1)
        self.status_area = StatusArea()
        form_vbox.addWidget(self.status_area)
        hbox.addLayout(form_vbox)

        # value bar
        self.valuebar = MAXValueBar(self)
        slider_vbox = QtGui.QVBoxLayout(self)
        slider_vbox.setContentsMargins(10, 10, 10, 10)
        hbox.addLayout(slider_vbox)
        self.current_label = TaurusLabel()
        self.current_label.setAlignment(QtCore.Qt.AlignCenter)
        slider_vbox.addWidget(self.valuebar, 1)
        slider_vbox.addWidget(self.current_label)
Ejemplo n.º 4
0
class CyclePanel(TaurusWidget):
    "Panel for controlling the cycling functionality"

    trend_trigger = QtCore.pyqtSignal(bool)

    attrs = [
        "CyclingTimePlateau", "CyclingIterations", "CyclingSteps",
        "CyclingRampTime", "NominalSetPoint"
    ]
    scale_factor = 1.1

    def __init__(self, parent=None):
        TaurusWidget.__init__(self, parent)
        self._setup_ui()
        print('CyclePanel juste avant setmodel')

    #    self.setModel('sys/tg_test/1')

    def scaleSize(self):
        size = self.form.scrollArea.widget().frameSize()
        return QtCore.QSize(size.width(), size.height() * self.scale_factor)

    def _setup_ui(self):
        vbox = QtGui.QVBoxLayout(self)
        self.setLayout(vbox)

        grid = QtGui.QGridLayout()
        self.form = MAXForm(withButtons=False)

        grid.addWidget(self.form, 0, 0, 2, 1)
        # rescale taurus form methode
        self.form.scrollArea.sizeHint = self.scaleSize
        self.status_label = StatusArea()
        grid.addWidget(self.status_label, 0, 1, 1, 1)

        commandbox = QtGui.QVBoxLayout(self)
        self.start_button = TaurusCommandButton(command="StartCycle")
        self.start_button.setUseParentModel(True)
        self.stop_button = TaurusCommandButton(command="StopCycle")
        self.stop_button.setUseParentModel(True)
        commandbox.addWidget(self.start_button)
        commandbox.addWidget(self.stop_button)
        grid.addLayout(commandbox, 1, 1, 1, 1)

        vbox.addLayout(grid)

        self.trend = TaurusTrend()
        vbox.addWidget(self.trend, stretch=1)
        self.trend_trigger.connect(self.set_trend_paused)

        self.cyclingState = None

    def setModel(self, device):
        print self.__class__.__name__, "setModel", device
        TaurusWidget.setModel(self, device)
        # self.state_button.setModel(device)
        if device:
            self.form.setModel(
                ["%s/%s" % (device, attribute) for attribute in self.attrs])

            self.status_label.setModel("%s/cyclingStatus" % device)

            ps = str(PyTango.Database().get_device_property(
                device, "PowerSupplyProxy")["PowerSupplyProxy"][0])

            self.trend.setPaused()
            self.trend.setModel(["%s/Current" % ps])
            self.trend.setForcedReadingPeriod(0.2)
            self.trend.showLegend(True)

            # let's pause the trend when not cycling
            self.cyclingState = self.getModelObj().getAttribute("cyclingState")
            self.cyclingState.addListener(self.handle_cycling_state)
        else:
            if self.cyclingState:
                self.cyclingState.removeListener(self.handle_cycling_state)
            self.trend.setModel(None)
            self.status_label.setModel(None)

    def handle_cycling_state(self, evt_src, evt_type, evt_value):
        if evt_type in [
                PyTango.EventType.CHANGE_EVENT,
                PyTango.EventType.PERIODIC_EVENT
        ]:
            self.trend_trigger.emit(evt_value.value)

    def set_trend_paused(self, value):
        self.trend.setForcedReadingPeriod(0.2 if value else -1)
        self.trend.setPaused(not value)
Ejemplo n.º 5
0
class BinpPowerSupplyPanel(TaurusWidget):
    "Allows directly controlling the BINP power supply connected to the circuit"
    attrs = ["Voltage"]

    def __init__(self, parent=None):
        TaurusWidget.__init__(self, parent)
        self._setup_ui()

    def _setup_ui(self):
        hbox = QtGui.QHBoxLayout(self)
        self.setLayout(hbox)
        form_vbox = QtGui.QVBoxLayout(self)

        # devicename label
        hbox2 = QtGui.QVBoxLayout(self)
        self.device_and_state = DevnameAndState(self)
        hbox2.addWidget(self.device_and_state, stretch=2)

        # commands
        commandbox = QtGui.QHBoxLayout(self)
        self.start_button = TaurusCommandButton(command="Start")
        self.start_button.setUseParentModel(True)
        self.stop_button = TaurusCommandButton(command="Stop")
        self.stop_button.setUseParentModel(True)
        self.init_button = TaurusCommandButton(command="Init")
        self.init_button.setUseParentModel(True)
        self.on_button = TaurusCommandButton(command="On")
        self.on_button.setUseParentModel(True)
        self.off_button = TaurusCommandButton(command="Off")
        self.off_button.setUseParentModel(True)
        self.enable_trigger_button = TaurusCommandButton(
            command="EnableTrigger")
        self.enable_trigger_button.setUseParentModel(True)
        self.disable_trigger_button = TaurusCommandButton(
            command="DisableTrigger")
        self.disable_trigger_button.setUseParentModel(True)
        self.reset_button = TaurusCommandButton(command="Reset")
        self.reset_button.setUseParentModel(True)
        commandbox.addWidget(self.start_button)
        commandbox.addWidget(self.stop_button)
        commandbox.addWidget(self.init_button)
        commandbox.addWidget(self.on_button)
        commandbox.addWidget(self.off_button)
        commandbox.addWidget(self.enable_trigger_button)
        commandbox.addWidget(self.disable_trigger_button)
        commandbox.addWidget(self.reset_button)
        hbox2.addLayout(commandbox, stretch=1)
        form_vbox.addLayout(hbox2)

        # attributes
        self.form = MAXForm(withButtons=False)

        form_vbox.addLayout(commandbox)
        form_vbox.addWidget(self.form, stretch=1)
        self.status_area = StatusArea()
        form_vbox.addWidget(self.status_area)
        hbox.addLayout(form_vbox)

        # value bar
        self.valuebar = MAXValueBar(self)
        slider_vbox = QtGui.QVBoxLayout(self)
        slider_vbox.setContentsMargins(10, 10, 10, 10)
        hbox.addLayout(slider_vbox)
        self.current_label = TaurusLabel()
        self.current_label.setAlignment(QtCore.Qt.AlignCenter)
        slider_vbox.addWidget(self.valuebar, 1)
        slider_vbox.addWidget(self.current_label)

    def setModel(self, device):
        print self.__class__.__name__, "setModel", device
        TaurusWidget.setModel(self, device)
        self.device_and_state.setModel(device)
        self.status_area.setModel(device)
        if device:
            self.form.setModel(
                ["%s/%s" % (device, attribute) for attribute in self.attrs])
            attrname = "%s/%s" % (device, "Voltage")
            self.valuebar.setModel(attrname)
            # self.state_button.setModel(device)
            attr = Attribute(attrname)
            self.current_label.setText("%s [%s]" % (attr.label, attr.unit))
        else:
            self.form.setModel(None)
            self.valuebar.setModel(None)
Ejemplo n.º 6
0
class MagnetCircuitPanel(TaurusWidget):
    "Displays the important attributes of the circuit device"

    attrs = [
        "energy", "MainFieldComponent", "PowerSupplyReadValue",
        "PowerSupplySetPoint", "fixNormFieldOnEnergyChange"
    ]

    def __init__(self, parent=None):
        TaurusWidget.__init__(self, parent)
        self._setup_ui()
        print('Magnet Circuit juste avant setmodel')
        self.setModel('sys/tg_test/1')

    def _setup_ui(self):

        hbox = QtGui.QHBoxLayout(self)
        self.setLayout(hbox)

        form_vbox = self.vbox = QtGui.QVBoxLayout(self)

        hbox2 = QtGui.QVBoxLayout(self)
        self.device_and_state = DevnameAndState(self)
        hbox2.addWidget(self.device_and_state)
        self.magnet_type_label = QtGui.QLabel("Magnet type:")
        hbox2.addWidget(self.magnet_type_label)
        form_vbox.addLayout(hbox2)

        # attributes
        self.form = MAXForm(withButtons=False)
        form_vbox.addWidget(self.form, stretch=1)
        self.status_area = StatusArea(self)
        form_vbox.addWidget(self.status_area)
        hbox.addLayout(form_vbox)

        # value bar
        self.valuebar = MAXValueBar(self)
        slider_vbox = QtGui.QVBoxLayout(self)
        slider_vbox.setContentsMargins(10, 10, 10, 10)
        hbox.addLayout(slider_vbox)
        self.current_label = TaurusLabel()
        self.current_label.setAlignment(QtCore.Qt.AlignCenter)
        slider_vbox.addWidget(self.valuebar, 1)
        slider_vbox.addWidget(self.current_label)

    def setModel(self, device):
        print self.__class__.__name__, "setModel", device
        TaurusWidget.setModel(self, device)
        self.device_and_state.setModel(device)
        if device:
            self.form.setModel(
                ["%s/%s" % (device, attribute) for attribute in self.attrs])

            #---- Partie qui correspond a l'appel de la bdd de Tango
            # avec types d'aimant etc ... on peut le faire a la main pour tester
            # pour le moment nous sommes obliges de sauter cette partie
            db_ok = False
            if db_ok:
                db = PyTango.Database()
                magnet = db.get_device_property(
                    device, "MagnetProxies")["MagnetProxies"][0]
                magnet_type = PyTango.Database().get_device_property(
                    magnet, "Type")["Type"][0]
            else:
                magnet_type = 'Dipole'

            self.magnet_type_label.setText("Magnet type: <b>%s</b>" %
                                           magnet_type)
            attrname = "%s/%s" % (device, "MainFieldComponent")
            self.valuebar.setModel(attrname)
            attr = Attribute(attrname)
            self.current_label.setText("%s [%s]" % (attr.label, attr.unit))
            self.status_area.setModel(device)
        else:
            self.form.setModel(None)
            self.valuebar.setModel(None)
            self.status_area.setModel(None)
Ejemplo n.º 7
0
class PowerSupplyPanel(TaurusWidget):
    "Allows directly controlling the power supply connected to the circuit"
    attrs = ["long_scalar", "double_scalar", "float_scalar"]

    #   attrs = ["Current", "Voltage", "Resistance"]

    def __init__(self, parent=None):
        print('ddddddddddddddddd')
        TaurusWidget.__init__(self, parent)
        self._setup_ui()
        print('juste avant setmodel')
        self.setModel('sys/tg_test/1')

    def _setup_ui(self):
        print('-----------voici ')
        hbox = QtGui.QHBoxLayout(self)
        self.setLayout(hbox)
        form_vbox = QtGui.QVBoxLayout(self)

        # devicename label
        hbox2 = QtGui.QVBoxLayout(self)
        self.device_and_state = DevnameAndState(self)
        hbox2.addWidget(self.device_and_state, stretch=2)

        # commands
        commandbox = QtGui.QHBoxLayout(self)
        self.start_button = TaurusCommandButton(command="On")
        self.start_button.setUseParentModel(True)
        self.stop_button = TaurusCommandButton(command="Off")
        self.stop_button.setUseParentModel(True)
        self.init_button = TaurusCommandButton(command="Init")
        self.init_button.setUseParentModel(True)
        commandbox.addWidget(self.start_button)
        commandbox.addWidget(self.stop_button)
        commandbox.addWidget(self.init_button)
        hbox2.addLayout(commandbox, stretch=1)
        form_vbox.addLayout(hbox2)

        # attributes
        self.form = MAXForm(withButtons=False)

        form_vbox.addLayout(commandbox)
        form_vbox.addWidget(self.form, stretch=1)
        self.status_area = StatusArea()
        form_vbox.addWidget(self.status_area)
        hbox.addLayout(form_vbox)

        # value bar
        self.valuebar = MAXValueBar(self)
        slider_vbox = QtGui.QVBoxLayout(self)
        slider_vbox.setContentsMargins(10, 10, 10, 10)
        hbox.addLayout(slider_vbox)
        self.current_label = TaurusLabel()
        self.current_label.setAlignment(QtCore.Qt.AlignCenter)
        slider_vbox.addWidget(self.valuebar, 1)
        slider_vbox.addWidget(self.current_label)

    def setModel(self, device):
        print self.__class__.__name__, "setModel", device
        TaurusWidget.setModel(self, device)
        self.device_and_state.setModel(device)
        self.status_area.setModel(device)
        if device:
            self.form.setModel(
                ["%s/%s" % (device, attribute) for attribute in self.attrs])
            attrname = "%s/%s" % (device, "Current")

            self.valuebar.setModel(attrname)
            # self.state_button.setModel(device)
            attr = Attribute(attrname)
            self.current_label.setText("%s [%s]" % (attr.label, attr.unit))
        else:
            self.form.setModel(None)
            self.valuebar.setModel(None)
Ejemplo n.º 8
0
class MagnetCircuitPanel(TaurusWidget):
    "Displays the important attributes of the circuit device"

    attrs = ["energy", "MainFieldComponent", "PowerSupplyReadValue", "PowerSupplySetPoint",
             "fixNormFieldOnEnergyChange"]

    def __init__(self, parent=None):
        TaurusWidget.__init__(self, parent)
        self._setup_ui()

    def _setup_ui(self):

        hbox = QtGui.QHBoxLayout(self)
        self.setLayout(hbox)

        form_vbox = self.vbox = QtGui.QVBoxLayout(self)

        hbox2 = QtGui.QVBoxLayout(self)
        self.device_and_state = DevnameAndState(self)
        hbox2.addWidget(self.device_and_state)
        self.magnet_type_label = QtGui.QLabel("Magnet type:")
        hbox2.addWidget(self.magnet_type_label)
        form_vbox.addLayout(hbox2)

        # attributes
        self.form = MAXForm(withButtons=False)
        form_vbox.addWidget(self.form, stretch=1)
        self.status_area = StatusArea(self)
        form_vbox.addWidget(self.status_area)
        hbox.addLayout(form_vbox)


        # value bar
        self.valuebar = MAXValueBar(self)
        slider_vbox = QtGui.QVBoxLayout(self)
        slider_vbox.setContentsMargins(10, 10, 10, 10)
        hbox.addLayout(slider_vbox)
        self.current_label = TaurusLabel()
        self.current_label.setAlignment(QtCore.Qt.AlignCenter)
        slider_vbox.addWidget(self.valuebar, 1)
        slider_vbox.addWidget(self.current_label)

    def setModel(self, device):
        print self.__class__.__name__, "setModel", device
        TaurusWidget.setModel(self, device)
        self.device_and_state.setModel(device)
        if device:
            self.form.setModel(["%s/%s" % (device, attribute)
                                for attribute in self.attrs])
            db = PyTango.Database()
            magnet = db.get_device_property(device, "MagnetProxies")["MagnetProxies"][0]
            magnet_type = PyTango.Database().get_device_property(magnet, "Type")["Type"][0]
            self.magnet_type_label.setText("Magnet type: <b>%s</b>" % magnet_type)
            attrname = "%s/%s" % (device, "MainFieldComponent")
            self.valuebar.setModel(attrname)
            attr = Attribute(attrname)
            self.current_label.setText("%s [%s]" % (attr.label, attr.unit))
            self.status_area.setModel(device)
        else:
            self.form.setModel(None)
            self.valuebar.setModel(None)
            self.status_area.setModel(None)