def recipeliststatus(recipeList, selectedRecipe, currentRecipe): cweb = commonweb.commonweb() retstr = cweb.header("Recipe list") #print recipeList if selectedRecipe is None: selectedRecipe = "" if currentRecipe is None: currentRecipe = "" retstr = retstr + "<b>Current running Recipe :</b>" + \ currentRecipe + "<br><br>\n" retstr = retstr + "<b>Current Selected Recipe:</b>" + \ selectedRecipe + "<br><br>\n" retstr = retstr + '<form method="post" action="/recipelist">' for recipeName in sorted(recipeList): rnstr = "\"" + recipeName + "\"" if recipeName == selectedRecipe: sel = "checked" retstr = retstr + "<b>" else: sel = "" retstr = retstr + '<input type="radio" name="recipe" value=' retstr = retstr + rnstr + sel + ">" + recipeName + '</b></u><br>\n' retstr = retstr + '<input type="submit" value="Set">' retstr = retstr + '</form>' retstr = retstr + cweb.footer() return(retstr)
def switchliststatus(switchDict, selectSwitch, currentSwitch): retstr = "<h1>Recipe list</h1>" cweb = commonweb.commonweb() print switchDict if selectSwitch is None: selectSwitch = "" if currentSwitch is None: currentSwitch = "" retstr = retstr + "<b>Current running Recipe :</b>" + \ currentSwitch + "<br><br>\n" retstr = retstr + "<b>Current Selected Recipe:</b>" + \ selectSwitch + "<br><br>\n" retstr = retstr + '<form method="post" action="/switchlist">' for switchName, switchStatus in switchDict.iteritems(): rnstr = "\"" + switchName + "\"" if switchStatus: sel = "checked" retstr = retstr + "<b>" else: sel = "" retstr = retstr + '<input type="CHECKBOX" name="switch" value=' retstr = retstr + rnstr + sel + ">" + switchName + '</b></u><br>\n' #<input type="submit" class="f" name="next" value="Next"> retstr = retstr + '<input type="submit" value="Update">' retstr = retstr + '</form>' retstr = retstr + cweb.footer() return(retstr)
def gauges(): common = commonweb.commonweb() indexpage = """ <!DOCTYPE html> <html> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript" src="/js/tGauge.js"></script> <!-- <script type="text/javascript" src="js/vGauge.js"></script> <script type="text/javascript" src="js/fetch.js"></script> --> <script type="text/javascript" src="js/stage.js"></script> <body> <h2 id="currentstage">Let's brew</h2> <h3 id="newstage"></h3> <div style="width: 100%; display: table;"> <div style="display: table-row"> <div id="title_HWT" style="width: 250px; height: 20px; font-size:200%; text-align:center;display: table-cell;">HWT </div> <div id="title_mashTune" style="width: 250px; height: 20px; font-size:200%; text-align:center; display: table-cell;">Mash </div> <div id="title_boiler" style="width: 250px; height: 20px; font-size:200%; text-align:center; display: table-cell;">Boil </div> </div> <div style="display: table-row"> <div id="chart_waterHeater" style="width: 250px; height: 250px; display: table-cell;"></div> <div id="chart_mashHeater" style="width: 250px; height: 250px; display: table-cell;"></div> <div id="chart_boiler" style="width: 250px; height: 250px; display: table-cell;"></div> </div> <!-- <div style="display: table-row"> <div id="vol_waterHeater" style="width: 250px; height: 250px; display: table-cell;"></div> <div id="vol_mashHeater" style="width: 250px; height: 250px; display: table-cell;"></div> <div id="vol_boiler" style="width: 250px; height: 250px; display: table-cell;"></div> </div> --> </div> <!-- <p>Temp HWT: <b id="hwt">Unknown</b><p> <p>Temp Boiler: <b id="boiler">Unknown</b><p> --> <script> console.log("Page is done"); </script> <p>Brewtime!</p> </body> </html> """ indexpage = common.header('Chart') + indexpage + common.footer() indexpage = indexpage + "</body>" return(indexpage)
def ingredients(recipeObject): common = commonweb.commonweb() if recipeObject is None: hops = """ <h2>Stuff</h2> <ul> <li>dispenser 1 </li> <li>dispenser 2 </li> </ul> """ misc = "" else: hops = bulletedList('Hops', recipeObject.ingredientsHops()) misc = bulletedList('Misc', recipeObject.ingredientsMisc()) page = common.header('Current Ingredients') + hops + misc page = page + common.footer() page = page + "</body>" return(page)
def graphPage(mylog, label1, label2, label3, label4): fig = plt.figure() ax = fig.add_subplot(111) ax.set_title("Temperature") ax.set_xlabel("time") ax.set_ylabel("temperature") bx = fig.add_subplot(111) cx = fig.add_subplot(111) dx = fig.add_subplot(111) logdata = sorted(mylog) d1 = [] d2 = [] d3 = [] d4 = [] for dt in logdata: status = mylog[dt] d1.append(status[label1]["actual"]) d2.append(status[label2]["actual"]) d3.append(status[label3]["actual"]) d4.append(status[label4]["actual"]) # print sys.getsizeof(mylog) dates = matplotlib.dates.date2num(logdata) ax.plot_date(dates, d1, "r-", label=label1) bx.plot_date(dates, d2, "b-", label=label2) cx.plot_date(dates, d3, "g-", label=label3) dx.plot_date(dates, d4, "y-", label=label4) plt.legend(bbox_to_anchor=(1, 0.3)) common = commonweb.commonweb() graphpg = mpld3.fig_to_html(fig) graphpg = graphpg + common.footer() graphpg = graphpg + "</body>" return graphpg
def index(): common = commonweb.commonweb() indexpage = """ <h2>How to brew</h2> <ul> <li>Go to the <b>Recipe List</b> and select a recipe. Make sure you click the Set button </li> <li>Go to the <b>Run Control</b> page and click on the green Start button. If there is just a red Stop button, then a brew is in progress. Either wait or cancel the brew by clicking the Stop button.</li> <li>The <b>Stages</b> page will show you what step in the brew process you are on.</li> <li>The <b>Status</b> page shows the status of the current stage in the brew process.</li> </ul> """ indexpage = common.header('Hopitty') + indexpage + common.footer() indexpage = indexpage + "</body>" return(indexpage)
def debugStages(self): common = commonweb.commonweb() rs = str(self.stages) rs = rs + common.footer() return rs
def commandPage(self): """ Page to set the run status, i.e. to start the run Also prints some useful info about current status """ print "commandPage" common = commonweb.commonweb() rs = common.header("Run Control") rs = rs + "Run status: " if self.s2b.isAlive(): rs = rs + "Alive" else: rs = rs + "Dead" rs = rs + "<br>" rs = rs + '<form method="post" action="/start">' if self.s2b.stopped(): rs = rs + '<input type="hidden" name="runStatus" value="run">' rs = rs + '<input type="submit"' rs = ( rs + """ style="color: white; background-color: green; font-size: larger; height:50px;width:80px;" """ ) rs = rs + ' value="Start">' else: rs = rs + '<input type="hidden" name="runStatus" value="stop">' rs = rs + '<input type="submit"' rs = ( rs + """ style="color: white; background-color: red; font-size: larger; height:50px;width:80px;" """ ) rs = rs + ' value="Stop">' rs = rs + "Start/stop brewing program" rs = rs + "</form>" rs = rs + '<form method="post" action="/start">' if self.s2b.paused(): rs = rs + '<input type="hidden" name="pauseState" value="False">' rs = rs + '<input type="submit"' rs = ( rs + """ style="color: white; background-color: green; font-size: larger; height:50px;width:80px;" """ ) rs = rs + ' value="Resume">' else: rs = rs + '<input type="hidden" name="pauseState" value="True">' rs = rs + '<input type="submit"' rs = ( rs + """ style="color: black; background-color: yellow; font-size: larger; height:50px;width:80px;" """ ) rs = rs + ' value="Pause">' rs = rs + "Pause brewing process temporarily" rs = rs + "</form>" rs = rs + '<form method="post" action="/start">' rs = rs + '<input type="hidden" name="skipState" value="True">' rs = rs + '<input type="submit"' rs = ( rs + """ style="color: black; background-color: white; font-size: larger; height:50px;width:80px;" """ ) rs = rs + ' value="Skip">' rs = rs + "Skip one stage forward." rs = rs + "</form>" rs = rs + '<form method="post" action="/start">' rs = rs + '<input type="hidden" name="preHeatState" value="True">' rs = rs + '<input type="submit"' rs = ( rs + """ style="color: white; background-color: blue; font-size: larger; height:50px;width:80px;" """ ) rs = rs + ' value="PreHeat">' rs = rs + "Pre heat the strike water to 170F" rs = rs + "</form>" rs = rs + common.footer() return rs
def statusView(s2b, errorState, currentRecipeName): common = commonweb.commonweb() #status = s2b.getStatus() stage = s2b.getStage() ctrlStatus = s2b.getStatus() highLightColor = """<tr style="background-color:green;color:white;">""" if errorState: highLightColor = """<tr style="background-color:red;color:white;">""" retstr = common.header("Brew Status", True) retstr = retstr + """<h2>Recipe: %s</h2>""" % currentRecipeName retstr = retstr + """<h3>Stage: %s</h3>""" % stage if s2b.isAlive(): retstr = retstr + """\ <table border="1"> <tr> <td><b>Controller</b></td> <td><b>Active</b></td> <td><b>Set Value</b></td> <td><b>Actual Value</b></td> <td><b>Power</b></td> <td><b>Done</b></td> </tr> """ for key, c in ctrlStatus.items(): if c['active']: retstr = retstr + highLightColor else: retstr = retstr + """ <tr style="background-color:white;color:gray;"> """ retstr = retstr + """<td> %s </td>""" % key retstr = retstr + """<td> %s </td>""" % yn(c['active']) if c['unit'] is None: retstr = retstr + """<td> </td>""" retstr = retstr + """<td> </td>""" else: retstr = retstr + """<td> %.2f %s</td>""" %\ (c['target'], c['unit']) retstr = retstr + """<td> %.2f %s</td>""" %\ (c['actual'], c['unit']) retstr = retstr + """<td> %s </td>""" % yn(c['powerOn']) retstr = retstr + """<td>%s</td>""" % yn(c['targetMet']) retstr = retstr + "</tr>" retstr = retstr + "</table>" retstr = retstr + "<br>" if not s2b.isAlive(): retstr = retstr + "<h1>ERROR: Controller not responding</h1>" elif s2b.isAlive() and s2b.paused(): retstr = retstr + "Controller running, but paused" elif s2b.isAlive() and not s2b.paused(): retstr = retstr + "Controller running" else: retstr = retstr + "Controller state unknown" retstr = retstr + common.footer() return(retstr)