예제 #1
0
 def evaluate (self):
     old = self.distance
     # Compute real distance.
     DistanceSensor.evaluate (self)
     # Update observers.
     if self.distance != old:
         self.notify ()
예제 #2
0
 def evaluate (self):
     # Compute real distance.
     DistanceSensor.evaluate (self)
     # Convert to sharps voltage.
     d = self.distance
     if self.distance is None:
         d = self.RANGE
     if d < self.NEAR:
         self.value = d / self.NEAR * (self.A + self.B / self.NEAR)
     else:
         self.value = self.A + self.B / d
     # Update observers.
     self.notify ()
     # Prepare next update.
     self.scheduler.schedule (self.scheduler.date
             + int (self.scheduler.tick * 0.040), self.evaluate)
예제 #3
0
 def evaluate (self):
     # Compute real distance.
     DistanceSensor.evaluate (self)
     # Convert to sensor voltage.
     d = self.distance
     if self.distance is None:
         d = self.RANGE
     if d < 22.5:
         self.value = -0.014 * d * d + 0.41 * d + 7
     else:
         self.value = -0.657 + 220.431 / d
     self.value *= 0.1 * self.factor
     # Update observers.
     self.notify ()
     # Prepare next update.
     self.scheduler.schedule (self.scheduler.date
             + int (self.scheduler.tick * 0.03), self.evaluate)