- refactored

This commit is contained in:
jens
2020-12-16 17:10:46 +01:00
parent 48d0baa74f
commit fa93a3911e
11 changed files with 64 additions and 60 deletions
+53
View File
@@ -0,0 +1,53 @@
from components import AStirrer
import time
class StirrerSim(AStirrer):
def name(self):
return "FakeStirrer"
def __init__(self, dt):
super(StirrerSim, self).__init__(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)