- raise exception i case hendi cannot be enabled

git-svn-id: http://moon:8086/svn/projects/HendiControl@369 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
2020-04-19 19:34:55 +00:00
parent 63bd991cb2
commit bcad769329
3 changed files with 45 additions and 37 deletions
+5 -5
View File
@@ -174,10 +174,14 @@ class Controller(TimerListener):
try: try:
msg = self.queue.get(block=True, timeout=wait) msg = self.queue.get(block=True, timeout=wait)
print ("Received: ", msg) print ("Received: ", msg)
except:
continue
if msg == commands.PAUSE: if msg == commands.PAUSE:
pass pass
elif msg == commands.RUN: elif msg == commands.RUN:
self.stirrer.activate()
self.plant.activate(True)
if not self.processTimer.isActive: if not self.processTimer.isActive:
self.fp_log = open(self.receipe['Name'] + '.log', "w") self.fp_log = open(self.receipe['Name'] + '.log', "w")
self.time = 0 self.time = 0
@@ -186,8 +190,6 @@ class Controller(TimerListener):
self.processTimer.start(self.dt / self.sim_warp_factor) self.processTimer.start(self.dt / self.sim_warp_factor)
# Stirrer and plant # Stirrer and plant
self.stirrer.activate()
self.plant.activate(True)
self.stirrer.setCycleTime(self.stirrCycleTime) self.stirrer.setCycleTime(self.stirrCycleTime)
self.receipe_done = False self.receipe_done = False
else: else:
@@ -203,8 +205,6 @@ class Controller(TimerListener):
elif msg == commands.STIRR_OFF: elif msg == commands.STIRR_OFF:
self.stirrer.deactivate() self.stirrer.deactivate()
except:
pass
# Stirrer and plant # Stirrer and plant
self.stirrer.deactivate() self.stirrer.deactivate()
+2 -2
View File
@@ -114,9 +114,9 @@ class HendiCtrl():
self.__write(req) self.__write(req)
rsp = self.__read() rsp = self.__read()
if "OK" not in rsp[0]: if "OK" not in rsp[0]:
raise Exception("Command not accepted ({})".format(rsp[1])) raise Exception(rsp[1])
return rsp[1] return rsp[1] == '1'
def getCapabilties(self): def getCapabilties(self):
return self.caps return self.caps
+12 -4
View File
@@ -16,16 +16,24 @@ class Plant(APlant):
self.cycleCounter = 0 self.cycleCounter = 0
def activate(self, enable=True): def activate(self, enable=True):
if enable == True: if enable:
self.heater.remoteEnable(enable)
self.heater.setSwitch(enable)
if not self.heater.isRemoteEnable(): if not self.heater.isRemoteEnable():
raise Exception ("Heater: Cannot enable remote mode!") try:
self.heater.remoteEnable(enable)
except:
raise Exception("Error: Could not activate heater!")
self.heater.setSwitch(enable)
print ("Plant activated")
else: else:
if self.heater.isRemoteEnable():
self.heater.setSwitch(enable) self.heater.setSwitch(enable)
self.heater.remoteEnable(enable) self.heater.remoteEnable(enable)
print ("Plant deactivated")
def process(self, dt=1): def process(self, dt=1):
if not self.heater.isRemoteEnable():
return
isOn = self.isOn isOn = self.isOn
self.cycleCounter += dt self.cycleCounter += dt
if self.cycleCounter >= self.cycleTime: if self.cycleCounter >= self.cycleTime: