-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatic_main.html
160 lines (157 loc) · 5.11 KB
/
static_main.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<html>
<head>
<script src="static/jquery/external/jquery/jquery.js"></script>
<script src="static/jquery/jquery-ui.js"></script>
<link rel="stylesheet" href="static/jquery/jquery-ui.css">
<script src="static/Chart.js"></script>
<link rel="stylesheet" type="text/css" href="static/jquery.countdown.package-2.1.0/css/jquery.countdown.css">
<script type="text/javascript" src="static/jquery.countdown.package-2.1.0/js/jquery.plugin.js"></script>
<script type="text/javascript" src="static/jquery.countdown.package-2.1.0/js/jquery.countdown.js"></script>
<link rel="stylesheet" href="static/main.css">
<title>{{title}}</title>
</head>
<body>
<div id="tabs">
<ul id="header">
<li><a href="#Brewery">Brewery Control</a></li>
<li><a href="#RecipeConfig">Recipe Config</a></li>
<li><a href="#BreweryConfig">Brewery Config</a></li>
</ul>
<div id="Brewery">
{{{brewery_layout}}}
</div>
<div id="RecipeConfig">
<fieldset>
<legend>Timer</legend>
<div id="Timer"></div>
</fieldset>
<fieldset>
<legend>Mash Schedule</legend>
<button id="add-new-step">New Step</button>
<button id="start-schedule">Run Steps</button>
<button id="pause-schedule">Pause</button>
<ul id="MashSchedule">
</ul>
<div id="MashStepTemplate">
<label for="temp-spinner">Target Temp:</label>
<input id="temp-spinner" name="value">
<label for="time-spinner">Time:</label>
<input id="time-spinner" name="value">
</div>
</fieldset>
</div>
<div id="BreweryConfig">
<div id="i2c_status"></div>
<fieldset>
<label for="i2c_temp1">HLT Temp I2C device: </label>
<select name="i2c_temp1" id="i2c_temp1"></select>
</fieldset>
<div id="i2c_temp1"></div>
<fieldset>
<label for="i2c_temp2">Pump Temp I2C device: </label>
<select name="i2c_temp2" id="i2c_temp2"></select>
</fieldset>
<div id="i2c_temp2"></div>
</div>
</div>
<div id="downStatus" title="Error" style="red">
<p>Server Appears Down!</p>
</div>
<script src="static/main.js"></script>
<script>
$(document).ready(function(){
{{{update_js}}}
registerText("/i2c", "#i2c_status");
registerSelect("/i2c/list", "#i2c_temp1", "/i2c/hlt_temp_id");
registerSelect("/i2c/list", "#i2c_temp2", "/i2c/pump_temp_id");
$("#tabs").tabs();
$("#downStatus").dialog({
dialogClass: "no-close",
modal: true,
autoOpen: false,
width: ($(window).width()*0.75),
position: { my: "center top", at: "center top", of: window }
});
$("#RecipeConfig > fieldset > #Timer").countdown({until:+0});
$("#RecipeConfig > fieldset > #MashSchedule").sortable({
axis: 'y',
containment: "parent",
revert: true
}).disableSelection();
$("#RecipeConfig > fieldset > #MashStepTemplate").hide();
$("#RecipeConfig > fieldset > #MashStepTemplate > #temp-spinner").spinner();
$("#RecipeConfig > fieldset > #MashStepTemplate > #time-spinner").spinner();
$("#RecipeConfig > fieldset > #add-new-step").button().on("click", function(event){
var li = $("<li class='inactive-step'/>");
var c = $("#RecipeConfig > fieldset > #MashStepTemplate").clone();
li.append(c);
c.show();
$("#RecipeConfig > fieldset > #MashSchedule").append(li).sortable('refresh');
});
var mash_step_index = 0;
var setTime = function(seconds) {
$("#RecipeConfig > fieldset > #Timer").countdown('option', {onExpiry:startNextStep, until:+seconds});
};
var setMashTemp = function(temp) {
var heater = $("#Brewery > #hlt > #heater");
heater.prop("value", temp);
heater.change();
};
var startNextStep = function() {
var rampToTemp = function(jobj) {
jobj.switchClass("inactive-step", "ramping-step");
$("#RecipeConfig > fieldset > #pause-schedule").click(); // pause
var checker = function() {
var actual_temp = $("#Brewery > #hlt > #reflow_temp").html().split(':')[1];
var target_temp = $("#Brewery > #hlt > #heater").prop("value");
if( Math.abs(actual_temp-target_temp) <= 1 )
{
jobj.switchClass("ramping-step", "active-step");
$("#RecipeConfig > fieldset > #pause-schedule").click(); // unpause
}
else
setTimeout(checker, 1000);
};
checker();
};
$("#RecipeConfig > fieldset > #MashSchedule > li > div > span > #time-spinner").each(
function(index) {
if( index == mash_step_index )
{
setTime(this.value * 60);
}
});
$("#RecipeConfig > fieldset > #MashSchedule > li > div > span > #temp-spinner").each(
function(index) {
if( index == mash_step_index )
{
setMashTemp(this.value);
}
});
$("#RecipeConfig > fieldset > #MashSchedule > li").each(
function(index) {
if( index == mash_step_index )
{
rampToTemp($(this));
}
else
{
$(this).switchClass("active-step", "inactive-step");
$(this).switchClass("ramping-step", "inactive-step");
}
});
mash_step_index++;
}
$("#RecipeConfig > fieldset > #start-schedule").button().on("click", function(event){
mash_step_index = 0;
startNextStep();
});
$("#RecipeConfig > fieldset > #pause-schedule").button().on("click", function(event){
var pause = $(this).text() === 'Pause';
$(this).text(pause ? 'Resume' : 'Pause');
$("#RecipeConfig > fieldset > #Timer").countdown(pause ? 'pause' : 'resume');
});
}); // close document.ready()
</script>
</body>
</html>