def __init__(self, controllers, recipelist, server=myserver.myserver(host="0.0.0.0", port=8080)): self.count = 0 self.wapp = Bottle() self.controllers = controllers self.recipelist = recipelist self.server = server self.stages = {} self.runningRecipeName = "" self.selectedRecipeName = "" self.recipeObject = None self.switchdict = {"lights": True, "camera": False, "sound": True} matplotlib.use("Agg") # Routing statements self.wapp.route("/status", "GET", self.statusPage) self.wapp.route("/", "GET", self.indexPage) self.wapp.route("/start", "GET", self.commandPage) self.wapp.route("/start", "POST", self.doCommand) self.wapp.route("/recipelist", "GET", self.recipeliststatusPage) self.wapp.route("/recipelist", "POST", self.dorecipeliststatus) self.wapp.route("/debugStages", "GET", self.debugStages) self.wapp.route("/readrecipes", "GET", self.getTestRecipeList) self.wapp.route("/switchlist", "GET", self.switchliststatusPage) self.wapp.route("/switchlist", "POST", self.doswitchliststatus) self.wapp.route("/temp", "GET", self.tempPage) self.wapp.route("/ingredients", "GET", self.ingredientsPage) self.wapp.route("/static/<filename>", "GET", self.server_static) self.s2b = stages2beer.s2b(controllers, self.stages) self.dl = ctrl.datalogger(controllers)
def doCommand(self): print "doCommand" runStatus = request.forms.get('runStatus') if runStatus == 'stop': self.s2b.stop() self.dl.stop() self.s2b.unpause() elif runStatus == 'run': print "starting" print self.s2b.isAlive() if not self.s2b.isAlive(): self.runningRecipeName = self.selectedRecipeName self.s2b = stages2beer.s2b(self.controllers, self.stages) self.dl = ctrl.datalogger(self.controllers) self.s2b.start() self.dl.start() pauseState = request.forms.get('pauseState') if pauseState == "True": self.s2b.pause() else: self.s2b.unpause() skipState = request.forms.get('skipState') if skipState == "True": self.s2b.skip() preHeatState = request.forms.get('preHeatState') if preHeatState == "True": if not self.s2b.isAlive(): preHeat = {"name": "heat_only", "recipe": {"01": {"waterHeater": 170}}} js = recipeReader.jsonStages(preHeat, self.controllers) self.s2b = stages2beer.s2b(self.controllers, js.getStages()) self.s2b.start() else: print "Already running, can not switch to preheat" return(self.commandPage())
def __init__(self, controllers, recipelist, server=myserver.myserver(host="0.0.0.0", port=8080)): self.count = 0 self.wapp = Bottle() self.controllers = controllers self.recipelist = recipelist self.server = server self.stages = {} self.runningRecipeName = "" self.selectedRecipeName = "" self.recipeObject = None self.switchdict = {"lights": True, "camera": False, "sound": True} matplotlib.use('Agg') # Routing statements self.wapp.route('/status', 'GET', self.statusPage) self.wapp.route('/', 'GET', self.indexPage) self.wapp.route('/start', 'GET', self.commandPage) self.wapp.route('/start', 'POST', self.doCommand) self.wapp.route('/recipelist', 'GET', self.recipeliststatusPage) self.wapp.route('/recipelist', 'POST', self.dorecipeliststatus) self.wapp.route('/debugStages', 'GET', self.debugStages) self.wapp.route('/readrecipes', 'GET', self.getTestRecipeList) self.wapp.route('/gauges', 'GET', self.getGauges) self.wapp.route('/apipath/currentstage', 'GET', self.apicurrentstage) self.wapp.route('/switchlist', 'GET', self.switchliststatusPage) self.wapp.route('/switchlist', 'POST', self.doswitchliststatus) self.wapp.route('/temp', 'GET', self.tempPage) self.wapp.route('/ingredients', 'GET', self.ingredientsPage) self.wapp.route('/apipath/appliance/<appliance>', 'GET', self.applianceWrap) self.wapp.route('/static/<filename>', 'GET', self.server_static) self.wapp.route('/js/<filename>', 'GET', self.js) self.s2b = stages2beer.s2b(controllers, self.stages) self.dl = ctrl.datalogger(controllers)
else: recipeName = b.getRecipeName() stages = b.getStages() else: recipeName = "" stages = {} equipmentchecker = checker.equipment(controllers, stages) if not equipmentchecker.check(): logging.error("Error: equipment vs recipe validation failed") logging.info("Running " + recipeName) if (stages != {}) and (stages is not None): brun = stages2beer.s2b(controllers, stages) dl = ctrl.datalogger(controllers) if checkonly: if brun.check(): logging.info("Check OK") else: logging.info("ERROR: Check failed") sys.exit(1) elif quick: if brun.quickRun(): logging.info("Quick run OK") else: logging.error("ERROR: Quick run failed") sys.exit(1) else: brun.start()