Ejemplo n.º 1
0
 def _validate(self, value):
     """ validation method for forms """
     ## call parent validations
     TextLine._validate(self, value)
     try:
         physical_quantity = physq(1.0, value)
     except magnitude.MagnitudeError:
         raise PhysicalUnitValidError(value, 1)
Ejemplo n.º 2
0
 def _validate(self, value):
     """ validation method for forms """
     ## call parent validations
     TextLine._validate(self, value)
     valList = value.split(' ', 1)
     try:
         numerical_value = float(valList[0])
         if len(valList) > 1:
             physical_unit = physq(numerical_value, valList[1])
     except ValueError:
         raise PhysicalQuantityValidError(value, 1)
     except magnitude.MagnitudeError:
         raise PhysicalQuantityValidError(value, 1)
Ejemplo n.º 3
0
 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))
Ejemplo n.º 4
0
 def ensureC23(obj_snmp):
     """The input quantity and the max unit (acceleration) * s * s
     must have the same dimension
     """
     if obj_snmp.maxQuantityAcceleration:
         convPQinpQuantity = convertQuantity(obj_snmp.inpQuantity)
         convPQmaxQuantityAcceleration = convertQuantity(\
             obj_snmp.maxQuantityAcceleration)
         physFactor = convPQmaxQuantityAcceleration \
                    / convPQinpQuantity \
                    * physq(1.0, "s2")
         if not physFactor.dimensionless():
             raise Invalid("The input quantity '%s' and the "\
                           "max unit (acceleration) '%s' * s * s"\
                           " must have the same dimension" \
                           % (convPQinpQuantity,
                              convPQmaxQuantityAcceleration))