def __init__(self, model, parent=None): QWidget.__init__(self, parent) uic.loadUi("MotorWidget.ui", self) self.connect(self.configButton, SIGNAL("clicked()"), self.openConfig) self.connect(self.goButton, SIGNAL("clicked()"), self.go) self.connect(self.moveNegButton, SIGNAL("clicked()"), self.moveNeg) self.connect(self.movePosButton, SIGNAL("clicked()"), self.movePos) self.connect(self.disableButton, SIGNAL("toggled(bool)"), self.disable) self.stateLabel.setModel("%s/state" % model) self.positionLCD.setModel("%s/position" % model) self.motor = DeviceProxy(str(model)) try: self.nameLabel.setText(self.motor.alias()) except Exception: match = re.search(r"((?:[^/]+/){2}[^/]+)$", model) if not match: self.nameLabel.setText(model) else: self.nameLabel.setText(match.group(1)) pos = AttributeProxy("%s/position" % model) try: self.unitLabel.setText(pos.get_config().unit) except Exception: self.unitLabel.setText("") self.absMotionEdit.setText(str(self.motor.position))
def get_limits(attrib_name): attr_proxy = AttributeProxy(attrib_name) attr_config = attr_proxy.get_config() lower_limit = attr_config.min_value upper_limit = attr_config.max_value lower_warning = attr_config.alarms.min_warning upper_warning = attr_config.alarms.max_warning lower_alarm = attr_config.alarms.min_alarm upper_alarm = attr_config.alarms.max_alarm return [lower_limit, lower_alarm, lower_warning], [upper_limit, upper_alarm, upper_warning]
def test_Attributes(self): self._total = 0 for number in self._attrs: self._writes = 0 device = self._devices[number] devAttrs = [] for attrName in list(device.get_attribute_list()): attr = AttributeProxy("%s/%s" % (device.name(), attrName)) if attr.get_config().writable == AttrWriteType.READ_WRITE: devAttrs.append(attrName) otherAttrs = [] for attrName, attrDesc in self._attrs[number].iteritems(): if isinstance(attrDesc, Descriptor): if attrDesc.hasSubAttrs(): for subAttrDesc in attrDesc.subAttrs(): if subAttrDesc.writable: subAttrName = "%s_%s" % (attrName, subAttrDesc.name) self._checkAttrsLists(subAttrName, devAttrs, otherAttrs) # TODO: ignore, they will have their own test elif attrDesc.writable: self._checkAttrsLists(attrName, devAttrs, otherAttrs) self.assertAttibute(attrName, attrDesc, device) for attrName, attrDesc in self._deviceStaticAttrs().iteritems(): if isinstance(attrDesc, Descriptor) and attrDesc.writable: self._checkAttrsLists(attrName, devAttrs, otherAttrs) self.assertAttibute(attrName, attrDesc, device) self._subtotal = self._writes self._total += self._subtotal self._logger.info("plc%d: %d attributes write tested" % (number, self._subtotal)) if len(devAttrs) > 0: self._logger.warning("Unchecked device write attributes: %s" % (devAttrs)) if len(otherAttrs) > 0: self._logger.warning("Described write attributes not present: " "%s" % (otherAttrs)) self._logger.info("Total %d write attributes tested" % (self._total)) self._logger.info("Attributes write test succeed")