def evaluate (self): old = self.distance # Compute real distance. DistanceSensor.evaluate (self) # Update observers. if self.distance != old: self.notify ()
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)
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)