54 lines
962 B
Python
54 lines
962 B
Python
from components import AStirrer
|
|
import time
|
|
|
|
|
|
class Stirrer_sim(AStirrer):
|
|
def name(self):
|
|
return "FakeStirrer"
|
|
|
|
def __init__(self, dt):
|
|
super(Stirrer_sim, self).__init__(dt)
|
|
|
|
def __del__(self):
|
|
self.activate(False)
|
|
|
|
def on_activate(self, enable):
|
|
print("on_activate {}".format(enable))
|
|
|
|
def getSpeed(self):
|
|
if self.isOn and self.is_activated():
|
|
return self.speed
|
|
return 0
|
|
|
|
def onSetSpeed(self, speed):
|
|
print("Set speed to {} %".format(speed))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
s = Stirrer_sim(1.0)
|
|
s.activate(True)
|
|
|
|
print ("Set some speeds")
|
|
s.setSpeed(50)
|
|
time.sleep(2)
|
|
s.setSpeed(100)
|
|
time.sleep(2)
|
|
s.setSpeed(50)
|
|
time.sleep(2)
|
|
|
|
print ("Pulsed operation, duty cycle = 50%")
|
|
s.setDutyCycle(0.5)
|
|
s.setCycleTime(10)
|
|
for i in range(1, 30):
|
|
s.process()
|
|
time.sleep(1)
|
|
|
|
print ("Pulsed operation, duty cycle = 20%")
|
|
s.setDutyCycle(0.2)
|
|
s.setCycleTime(10)
|
|
for i in range(1, 30):
|
|
s.process()
|
|
time.sleep(1)
|
|
|
|
s.activate(False)
|