- 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
+29 -29
View File
@@ -174,37 +174,37 @@ class Controller(TimerListener):
try:
msg = self.queue.get(block=True, timeout=wait)
print ("Received: ", msg)
if msg == commands.PAUSE:
pass
elif msg == commands.RUN:
if not self.processTimer.isActive:
self.fp_log = open(self.receipe['Name'] + '.log', "w")
self.time = 0
self.rast_index = 0
self.reportTimer.start(self.report_interval)
self.processTimer.start(self.dt / self.sim_warp_factor)
# Stirrer and plant
self.stirrer.activate()
self.plant.activate(True)
self.stirrer.setCycleTime(self.stirrCycleTime)
self.receipe_done = False
else:
self.rast_index += 1
self.rast_done = False
self.ovenState = ovenStates.IDLE
elif msg == commands.ABORT:
run = False
elif msg == commands.STIRR_ON:
self.stirrer.activate()
elif msg == commands.STIRR_OFF:
self.stirrer.deactivate()
except:
continue
if msg == commands.PAUSE:
pass
elif msg == commands.RUN:
self.stirrer.activate()
self.plant.activate(True)
if not self.processTimer.isActive:
self.fp_log = open(self.receipe['Name'] + '.log', "w")
self.time = 0
self.rast_index = 0
self.reportTimer.start(self.report_interval)
self.processTimer.start(self.dt / self.sim_warp_factor)
# Stirrer and plant
self.stirrer.setCycleTime(self.stirrCycleTime)
self.receipe_done = False
else:
self.rast_index += 1
self.rast_done = False
self.ovenState = ovenStates.IDLE
elif msg == commands.ABORT:
run = False
elif msg == commands.STIRR_ON:
self.stirrer.activate()
elif msg == commands.STIRR_OFF:
self.stirrer.deactivate()
# Stirrer and plant
self.stirrer.deactivate()
+2 -2
View File
@@ -114,9 +114,9 @@ class HendiCtrl():
self.__write(req)
rsp = self.__read()
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):
return self.caps
+14 -6
View File
@@ -16,16 +16,24 @@ class Plant(APlant):
self.cycleCounter = 0
def activate(self, enable=True):
if enable == True:
self.heater.remoteEnable(enable)
self.heater.setSwitch(enable)
if enable:
if not self.heater.isRemoteEnable():
raise Exception ("Heater: Cannot enable remote mode!")
else:
try:
self.heater.remoteEnable(enable)
except:
raise Exception("Error: Could not activate heater!")
self.heater.setSwitch(enable)
self.heater.remoteEnable(enable)
print ("Plant activated")
else:
if self.heater.isRemoteEnable():
self.heater.setSwitch(enable)
self.heater.remoteEnable(enable)
print ("Plant deactivated")
def process(self, dt=1):
if not self.heater.isRemoteEnable():
return
isOn = self.isOn
self.cycleCounter += dt
if self.cycleCounter >= self.cycleTime: