Files
brewpi/components/actor/stirrersim.py

51 lines
836 B
Python

from components import AStirrer
import time
class StirrerSim(AStirrer):
def __init__(self, dt):
AStirrer.__init__(self, dt)
def activate(self, enable):
pass
def get_speed(self):
if self.isOn and self.is_activated():
return self.speed
return 0
def _on_set_speed(self, speed):
pass
def _on_process(self):
pass
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)