from components import AStirrer import time class StirrerSim(AStirrer): def __init__(self, params): AStirrer.__init__(self, params['dt']) def __del__(self): self.activate(False) def on_activate(self, enable): print("on_activate {}".format(enable)) def get_speed(self): if self.isOn and self.is_activated(): return self.speed return 0 def on_set_speed(self, speed): print("Set speed to {} %".format(speed)) if __name__ == '__main__': s = StirrerSim(1.0) s.activate(True) print("Set some speeds") s.set_speed(50) time.sleep(2) s.set_speed(100) time.sleep(2) s.set_speed(50) time.sleep(2) print("Pulsed operation, duty cycle = 50%") s.set_duty_cycle(0.5) s.set_cycle_time(10) for i in range(1, 30): s.process() time.sleep(1) print("Pulsed operation, duty cycle = 20%") s.set_duty_cycle(0.2) s.set_cycle_time(10) for i in range(1, 30): s.process() time.sleep(1) s.activate(False)