def getDisplayUnit(self): """get unit tuple (displUnit, displayString) """ displUnit = None displayString = None if self.inptype == u"cnt": if self.displUnitVelocity is not None: displUnit = convertUnit(self.displUnitVelocity) displayString = str(self.displUnitVelocity) elif self.inptype == u"gauge": if self.displUnitAbs is not None: displUnit = convertUnit(self.displUnitAbs) displayString = str(self.displUnitAbs) else: if self.displUnitVelocity is not None: displUnit = convertUnit(self.displUnitVelocity) displayString = str(self.displUnitVelocity) return (displUnit, displayString)
def ensureC3(obj_snmp): """The input quantity and the display unit must have the same dimension """ convPQinpQuantity = convertQuantity(obj_snmp.inpQuantity) convPUdisplUnitAbs = convertUnit(obj_snmp.displUnitAbs) physFactor = convPUdisplUnitAbs / convPQinpQuantity if not physFactor.dimensionless(): raise Invalid("The input quantity '%s' and the "\ "display unit '%s'"\ " must have the same dimension" \ % (convPQinpQuantity, convPUdisplUnitAbs))
def ensureC4(obj_snmp): """The input quantity and the display unit (velocity) * s must have the same dimension """ if obj_snmp.displUnitVelocity: convPQinpQuantity = convertQuantity(obj_snmp.inpQuantity) convPUdisplUnitVelocity = convertUnit(obj_snmp.displUnitVelocity) physFactor = convPUdisplUnitVelocity \ / convPQinpQuantity \ * physq(1.0, "s") if not physFactor.dimensionless(): raise Invalid("The input quantity '%s' and the "\ "display unit (velocity) '%s' * s"\ " must have the same dimension" \ % (convPQinpQuantity, convPUdisplUnitVelocity))
def ensureC5(obj_snmp): """The input quantity and the display unit (acceleration) * s * s must have the same dimension """ if obj_snmp.displUnitAcceleration: convPQinpQuantity = convertQuantity(obj_snmp.inpQuantity) convPUdisplUnitAcceleration = convertUnit(\ obj_snmp.displUnitAcceleration) physFactor = convPUdisplUnitAcceleration \ / convPQinpQuantity \ * physq(1.0, "s2") if not physFactor.dimensionless(): raise Invalid("The input quantity '%s' and the "\ "display unit (acceleration) '%s' * s * s"\ " must have the same dimension" \ % (convPQinpQuantity, convPUdisplUnitAcceleration))
def getPUdisplUnitAcceleration(self): return convertUnit(self.displUnitAcceleration)
def getPUdisplUnitVelocity(self): return convertUnit(self.displUnitVelocity)
def getPUdisplUnitAbs(self): return convertUnit(self.displUnitAbs)