- redefine activate method

- for task introduced open() conext method
This commit is contained in:
jens
2020-12-18 15:58:02 +01:00
parent a3510ffe8f
commit 4e508c86c5
9 changed files with 85 additions and 62 deletions
+9 -11
View File
@@ -7,7 +7,6 @@ class HeaterHendi(AHeater):
AHeater.__init__(self)
self.hendi = HendiCtrl(params['port'], params['speed'])
self.power_set = self.get_power_min()
self.is_active = False
self.power_eff = 0
def get_power_min(self):
@@ -19,21 +18,21 @@ class HeaterHendi(AHeater):
return caps['pwr_watts_max']
def activate(self, enable):
self.is_active = enable
if not self.hendi.isRemoteEnable():
self.hendi.remoteEnable(1)
if enable:
self.hendi.setSwitch(1)
self.hendi.remoteEnable(1)
else:
self.hendi.setSwitch(0)
self.hendi.remoteEnable(0)
def is_activated(self):
s = self.hendi.getSwitch()
s = self.hendi.isRemoteEnable()
return '1' in s
def process(self):
power = self.power_set if self.is_active else 0
power = self.power_set
if power == 0:
self.hendi.setSwitch(0)
else:
self.hendi.setSwitch(1)
self.hendi.setPowerWatts(power)
self.power_eff = self.hendi.getPowerWatts()
@@ -41,5 +40,4 @@ class HeaterHendi(AHeater):
self.power_set = max(self.get_power_min(), min(self.get_power_max(), power))
def get_power(self):
result = self.hendi.getPowerWatts()
return result
return self.power_eff
+2 -4
View File
@@ -47,15 +47,13 @@ class StirrerPololu1376(AStirrer):
return self.speed
return 0
def on_activate(self, enable):
def activate(self, enable):
print("activate {}".format(enable))
if enable:
self.ser_send("go")
self.set_speed(self.speed)
else:
self.ser_send("X")
print("on_activate {}".format(enable))
def on_set_speed(self, speed):
self.ser_send("F" + str(int(speed)) + "%")
print("Set speed to {} %".format(speed))
+2 -5
View File
@@ -6,11 +6,8 @@ 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 activate(self, enable):
print("activate {}".format(enable))
def get_speed(self):
if self.isOn and self.is_activated():