Пример #1
0
 def ensureC21(obj_snmp):
     """The input quantity and the max unit must have the same dimension
     """
     if obj_snmp.maxQuantityAbs:
         convPQinpQuantity = convertQuantity(obj_snmp.inpQuantity)
         convPQmaxQuantityAbs = convertQuantity(obj_snmp.maxQuantityAbs)
         physFactor = convPQinpQuantity / convPQmaxQuantityAbs
         if not physFactor.dimensionless():
             raise Invalid("The input quantity '%s' and the "\
                           "max unit '%s'"\
                           " must have the same dimension" \
                           % (convPQinpQuantity, convPQmaxQuantityAbs))
Пример #2
0
 def ensureCapacityUnit(physicalMedia):
     if physicalMedia.capacity is not None:
         physicalInput = convertQuantity(physicalMedia.capacity)
         if not physicalInput.isBitUnit():
             raise Invalid(
                 "No capacity specification: '%s'." % \
                 (physicalMedia.capacity))
Пример #3
0
 def ensureAnnualChargesUnit(contract):
     if contract.annualCharges is not None:
         annualCharges = convertQuantity(contract.annualCharges)
         if not annualCharges.isCurrency():
             raise Invalid(
                 "No currency specification: '%s'." % \
                 (contract.annualCharges))
Пример #4
0
 def ensureC1(obj_snmp):
     """The input quantity must have a dimension
     """
     convPQinpQuantity = convertQuantity(obj_snmp.inpQuantity)
     if convPQinpQuantity.dimensionless():
         raise Invalid("The input quantity '%s' must have a dimension" \
                       % (convPQinpQuantity))
Пример #5
0
 def ensureLengthUnit(link):
     if link.length is not None:
         physicalInput = convertQuantity(link.length)
         if not physicalInput.isLength():
             raise Invalid(
                 "No length specification: '%s'." % \
                 (link.length))
Пример #6
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))
Пример #7
0
 def ensureC22(obj_snmp):
     """The input quantity and the max unit (velocity) '%s' * s
     must have the same dimension
     """
     if obj_snmp.maxQuantityVelocity:
         convPQinpQuantity = convertQuantity(obj_snmp.inpQuantity)
         convPQmaxQuantityVelocity = convertQuantity(\
             obj_snmp.maxQuantityVelocity)
         physFactor = convPQmaxQuantityVelocity \
                    / convPQinpQuantity \
                    * physq(1.0, "s")
         if not physFactor.dimensionless():
             raise Invalid("The input quantity '%s' and the "\
                           "max unit (velocity) '%s' * s"\
                           " must have the same dimension" \
                           % (convPQinpQuantity,
                              convPQmaxQuantityVelocity))
Пример #8
0
 def ensureMaxLength4LinkType(link):
     if link.length is not None:
         physicalInput = convertQuantity(link.length)
         physicalMaxLength = maxLength4LinkType(link.mediaType)
         if physicalInput > physicalMaxLength:
             raise Invalid(
                 "Length over: '%s'." % \
                 (physicalMaxLength))
Пример #9
0
 def getMaxQuantity(self):
     """get unit tuple (maxQuantity, maxString)
     """
     maxQuantity = None
     maxString = None
     if self.inptype == u"cnt":
         if self.maxQuantityVelocity is not None:
             maxQuantity = convertQuantity(self.maxQuantityVelocity)
             maxString = str(self.maxQuantityVelocity)
     elif self.inptype == u"gauge":
         if self.maxQuantityAbs is not None:
             maxQuantity = convertQuantity(self.maxQuantityAbs)
             maxString = str(self.maxQuantityAbs)
     else:
         if self.maxQuantityVelocity is not None:
             maxQuantity = convertQuantity(self.maxQuantityVelocity)
             maxString = str(self.maxQuantityVelocity)
     return (maxQuantity, maxString)
Пример #10
0
 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))
Пример #11
0
 def convertQuantity(self, quantityString):
     return convertQuantity(quantityString)
Пример #12
0
def maxLength4LinkType(linkType):
    return convertQuantity('100 m');
Пример #13
0
 def generateValuePng(self, params=None):
     """generate Picture
     """
     rrdFile = self.getRrdFilename()
     if not os.path.exists(self.getRrdFilename()):
         return None
     unitInRrd = convertQuantity(self.inpQuantity) \
               / convertQuantity("1.0 s")
     (displUnit, displayString) = self.getDisplayUnit()
     (minQuantity, minString) = self.getMinQuantity()
     (maxQuantity, maxString) = self.getMaxQuantity()
     if unitInRrd is not None and \
        displUnit is not None:
         multiplier = float(unitInRrd / displUnit)
     else:
         multiplier = 1.0
     if 1:  ##fileage > 60:
         rrdFile = self.getRrdFilename()
         argList = []
         argList.append(params['targetname'])
         # Defs
         self.rrdConfigureDefs(argList, rrdFile)
         # CDefs
         if self.snmpIndexType == u"index":
             self.rrdConfigureCDefsIndex(argList, multiplier)
         else:
             self.rrdConfigureCDefs(argList, multiplier)
         # Minimum settings
         if self.snmpIndexType == u"index":
             self.rrdConfigureMinimumIndex(argList)
         else:
             self.rrdConfigureMinimum(argList)
         # Maximum settings
         if self.snmpIndexType == u"index":
             self.rrdConfigureMaximumIndex(argList)
         else:
             self.rrdConfigureMaximum(argList)
         argList.append("--start=%d" % params['starttime'])
         argList.append("--end=%d" % params['endtime'])
         try:
             if params['width'] is not None:
                 argList.append("--width=%d" % int(params['width']))
             else:
                 argList.append("--width=540")
         except ValueError:
             argList.append("--width=540")
         try:
             if params['height'] is not None:
                 argList.append("--height=%d" % int(params['height']))
             else:
                 argList.append("--height=120")
         except ValueError:
             argList.append("--height=120")
         argList.append("--color=SHADEA#E5FFF9")
         argList.append("--color=SHADEB#E5FFF9")
         argList.append("--color=BACK#E5FFF9")
         argList.append("--color=CANVAS#ffffff")
         argList.append("--watermark=ICT-OK.ORG")
         argList.append("--vertical-label=%s" % displayString)
         # Legend
         self.rrdConfigureLegend(argList)
         # Graph
         if self.snmpIndexType == u"index":
             self.rrdConfigureGraphsIndex(argList)
         else:
             self.rrdConfigureGraphs(argList)
         argList.append("--imgformat=PNG")
         argList.append("--imginfo=<IMG SRC=\"/img/%s\" WIDTH=\"%lu\" " \
                        "HEIGHT=\"%lu\" ALT=\"Demo\">")
         #print "argList: ", argList
         rrdtool.graph(*argList)
Пример #14
0
 def getPQmaxQuantityAcceleration(self):
     return convertQuantity(self.maxQuantityAcceleration)
Пример #15
0
 def getPQmaxQuantityVelocity(self):
     return convertQuantity(self.maxQuantityVelocity)
Пример #16
0
 def getPQmaxQuantityAbs(self):
     return convertQuantity(self.maxQuantityAbs)
Пример #17
0
 def getPQinpQuantity(self):
     return convertQuantity(self.inpQuantity)