コード例 #1
0
 def getTemperature(self, maxAge=1.0):
     """
     getTemperature(maxAge = 1.0) --> float
     This routine returns the current temperature mesurment.
     maxAge is the maximum allowable age (in seconds) of the
     temperature data.
     """
     trace("OmegaDp251Thermometer.getTemperature()")
     if not self.isOpen():
         self.openDevice()
     if (maxAge > 0.1 and self.timestamp and self.currentTemperature):
         now = time.time()
         if self.timestamp + maxAge > now:
             return self.currentTemperature
     s = self.sendCmdAndRecvResponse('T')
     if s == None or len(s) == 0:
         return None
     s = s[1:].strip()[:-1]
     try:
         self.currentTemperature = float(s)
     except (ValueError, TypeError):
         raise Device.DeviceError(("Cannot parse Omega "
                                   "temperature value: %s") % s)
     self.timestamp = time.time()
     return self.currentTemperature
コード例 #2
0
 def getPressure(self, maxAge = 1.0):
     """
     getPressure(maxAge = 1.0) --> float
     This routine returns the current pressure mesurment.
     maxAge is the maximum allowable age (in seconds) of the
     pressure data.
     """
     trace ("Mensor2400Barometer.getPressure()")
     if not self.isOpen():
         self.openDevice()
     if (maxAge > 0.1 and self.timestamp and self.currentPressure):
         now = time.time()
         if self.timestamp +maxAge > now:
             return self.currentPressure
     s = self.sendCmdAndRecvResponse('?').split()[1]
     try:
         self.currentPressure = float (s)
     except (ValueError, TypeError):
         raise Device.DeviceError (("Cannot parse Mensor Barometer"
                                                 " value: %s") % s)
     self.timestamp = time.time()
     return self.currentPressure
コード例 #3
0
ファイル: NewportIbthx.py プロジェクト: CSMdatascience/Zygo
 def getTemperature(self, maxAge=1.0):
     """
     getTemperature(maxAge = 1.0) --> float
     This routine returns the current temperature mesurment.
     maxAge is the maximum allowable age (in seconds) of the
     temperature data.
     """
     trace("NewportIbthx.getTemperature()")
     if not self.isOpen():
         self.openDevice()
     if (maxAge > 0.1 and self.tempTimestamp and self.currTemperature):
         now = time.time()
         if self.tempTimestamp + maxAge > now:
             return self.currTemperature
     s = self.sendCmdAndRecvResponse('SRTC')
     try:
         self.currTemperature = float(s)
     except (ValueError, TypeError):
         raise Device.DeviceError(("Cannot parse Newport "
                                   "temperature value: %s") % s)
     self.tempTimestamp = time.time()
     return self.currTemperature