Пример #1
0
 def setModel(self, trim):
     TaurusWidget.setModel(self, trim)
     db = PyTango.Database()
     if trim:
         self.setWindowTitle("Trim coil panel: %s" % trim)
         swb = str(
             db.get_device_property(
                 trim, "SwitchBoardProxy")["SwitchBoardProxy"][0])
         ps = str(
             db.get_device_property(
                 trim, "PowerSupplyProxy")["PowerSupplyProxy"][0])
         # check PS class
         if db.get_class_for_device(ps) == "PulsePowerSupply":
             # change ps panel to bimp ps panel (for kicker and pinger)
             make_binpps_panel(self)
             hack_circuitpanel(self, ps)
             self.resize(700, 500)
         # set model
         self.tabs.setModel([trim, ps, trim, trim, swb])
     else:
         self.setWindowTitle("N/A")
         self.circuit_widget.setModel(None)
         # self.cycle_widget.setModel(None)
         self.field_widget.setModel(None)
         self.ps_widget.setModel(None)
         self.magnets_widget.setModel(None)
         self.switchboard_widget.setModel(None)
Пример #2
0
    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)
Пример #3
0
 def setModel(self, device):
     TaurusWidget.setModel(self, device)
     self.devicename_label.setText("<b>%s</b>" % device)
     # self.state_led.setModel("%s/State" % device)
     if device:
         self.state_label.setModel("%s/State" % device)
     else:
         self.state_label.setModel(None)
Пример #4
0
 def setModel(self, circuit, magnet=None):
     TaurusWidget.setModel(self, circuit)
     if circuit is None:
         self.magnet_combobox.clear()
         self.table.setModel(None)
     else:
         db = PyTango.Database()
         magnets = db.get_device_property(circuit, "MagnetProxies")["MagnetProxies"]
         self.magnet_combobox.addItems(magnets)
Пример #5
0
 def setModel(self, model):
     TaurusWidget.setModel(self, model)
     db = PyTango.Database()
     devclass = db.get_class_for_device(str(model))
     # Devices models from magnet device
     if devclass == "Magnet":
         # get circuit device
         # Note: Here, we check for both properties,
         # as there are currently two different builds of the
         # Magnet device; one for R1 and one for the rest of the
         # machine.  This part should be removed in the future,
         # whenever the CircuitProxies property goes away.
         circuit_props = [
             "CircuitProxies",  # old property
             "MainCoilProxy"
         ]  # new property
         circuits = db.get_device_property(model, circuit_props)
         if circuits["CircuitProxies"]:
             circuit = circuits["CircuitProxies"][0]
         else:
             # this will be the only case in the future
             circuit = circuits["MainCoilProxy"][0]
         self.setWindowTitle("Magnet circuit panel: %s" % circuit)
         # get PS device
         ps = str(
             db.get_device_property(
                 circuit, "PowerSupplyProxy")["PowerSupplyProxy"][0])
         # check PS class
         if db.get_class_for_device(ps) == "PulsePowerSupply":
             # no cycling for pulse ps
             self.tabs.removeTab(self.cycle_tab)
             # change ps panel to bimp ps panel (for kicker and pinger)
             make_binpps_panel(self)
             hack_circuitpanel(self, ps)
             self.resize(700, 500)
         # set model
         self.tabs.setModel([circuit, ps, circuit, circuit, circuit])
     # Devices models from circuit device
     elif devclass in ("MagnetCircuit", "TrimCircuit"):
         ps = str(
             db.get_device_property(
                 model, "PowerSupplyProxy")["PowerSupplyProxy"][0])
         if db.get_class_for_device(ps) == "PulsePowerSupply":
             # no cycling for pulse ps
             self.tabs.removeTab(self.cycle_tab)
             make_binpps_panel(self)
             hack_circuitpanel(self, ps)
             self.resize(700, 500)
         self.tabs.setModel([model, ps, model, model, model])
     else:
         self.circuit_widget.setModel(None)
         self.cycle_widget.setModel(None)
         self.field_widget.setModel(None)
         self.ps_widget.setModel(None)
         self.magnets_widget.setModel(None)
Пример #6
0
    def setModel(self, model):
        TaurusWidget.setModel(self, model)
        if model:
            m = self.getModelObj()
            self.down_command = getattr(m, self._down_command)
            self.up_command = getattr(m, self._up_command)

            self.state = m.getAttribute("State")
            self.state.addListener(self.handle_state_event)
        else:
            if self.state:
                self.state.removeListener(self.handle_state_event)
Пример #7
0
 def setModel(self, circuit):
     print "MagnetListPanel setModel", circuit
     TaurusWidget.setModel(self, circuit)
     db = PyTango.Database()
     if circuit:
         magnets = db.get_device_property(circuit, "MagnetProxies")["MagnetProxies"]
         if "SQF" in magnets[0]:
             self.table.setModel(magnets, ["State", "TemperatureInterlock", "shuntResistance"])
         else:
             self.table.setModel(magnets, ["State", "TemperatureInterlock"])
     else:
         self.table.setModel(None)
Пример #8
0
 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)
Пример #9
0
 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)
Пример #10
0
    def setModel(self, attrs):
        if not attrs:
            for att, col in zip(self.attributes, self._columns):
                att and att.removeListener(col.event_received)
        else:
            try:
                TaurusWidget.setModel(self, attrs[0].rsplit("/", 1)[0])
                self.attributes = [Attribute(a) for a in attrs]

                self.table.setColumnCount(len(attrs))
                fmt = "%s [%s]"
                labels = []
                for a in self.attributes:
                    config = a.getConfig()
                    label = fmt % (config.getLabel(), config.getUnit())
                    labels.append(label)

                self.table.setHorizontalHeaderLabels(labels)
                header = self.table.horizontalHeader()
                header.setResizeMode(QtGui.QHeaderView.Stretch)

                # Check if there are any columns at all
                row_lengths = [len(a.read().value) for a in self.attributes
                               if a.read().quality == PyTango.AttrQuality.ATTR_VALID]
                if not any(row_lengths):
                    return None
                self.table.setRowCount(max(row_lengths))

                self._values = {}
                self._config = {}
                self._columns = []

                for i, att in enumerate(self.attributes):
                    # JFF: this is a workaround for a behavior in Taurus. Just
                    # adding a new listener to each attribute does not work, the
                    # previous ones get removed for some reason.
                    col = AttributeColumn(self, i)
                    self._columns.append(col)  # keep reference to prevent GC
                    att.addListener(col.event_received)
            except PyTango.DevFailed:
                pass
Пример #11
0
 def setModel(self, model):
     TaurusWidget.setModel(self, model)
     self.updateConfig()
     conf = Configuration("%s?configuration" % self.model)
     conf.addListener(lambda *args: self.conf_trigger.emit())