www/js/mon_fermenter.js

changeset 526
2991acd35cdb
parent 494
af28ebe4a779
child 548
c67cd0d9249b
equal deleted inserted replaced
525:8bbc5730aaa8 526:2991acd35cdb
19 * along with ThermFerm; see the file COPYING. If not, write to the Free 19 * along with ThermFerm; see the file COPYING. If not, write to the Free
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *****************************************************************************/ 21 *****************************************************************************/
22 22
23 function createAbortElements() { 23 function createAbortElements() {
24 $('#eventWindow').jqxWindow({ 24 $('#eventWindow').jqxWindow({
25 theme: theme, 25 theme: theme,
26 position: { x: 440, y: 210 }, 26 position: { x: 440, y: 210 },
27 width: 400, 27 width: 400,
28 height: 200, 28 height: 200,
29 resizable: false, 29 resizable: false,
30 isModal: true, 30 isModal: true,
31 modalOpacity: 0.4, 31 modalOpacity: 0.4,
32 okButton: $('#delOk'), 32 okButton: $('#delOk'),
33 cancelButton: $('#delCancel'), 33 cancelButton: $('#delCancel'),
34 initContent: function () { 34 initContent: function() {
35 $('#delOk').jqxButton({ template: "danger", width: '65px', theme: theme }); 35 $('#delOk').jqxButton({ template: 'danger', width: '65px', theme: theme });
36 $('#delCancel').jqxButton({ template: "success", width: '65px', theme: theme }); 36 $('#delCancel').jqxButton({ template: 'success', width: '65px', theme: theme });
37 $('#delCancel').focus(); 37 $('#delCancel').focus();
38 } 38 }
39 }); 39 });
40 $('#eventWindow').jqxWindow('hide'); 40 $('#eventWindow').jqxWindow('hide');
41 } 41 }
42 42
43 43
44 $(document).ready(function () { 44 $(document).ready(function() {
45 45
46 var record = {}, 46 var record = {},
47 blank = {}, 47 blank = {},
48 ppayload = '', 48 ppayload = '',
49 newBase = false, 49 newBase = false,
50 newProduct = false, 50 newProduct = false,
51 newSwitch = false, 51 newSwitch = false,
52 newProfile = false, 52 newProfile = false,
53 schedule = 0, 53 schedule = 0,
54 yl = 12, // Normal yeast temp range 54 yl = 12, // Normal yeast temp range
55 yh = 24, 55 yh = 24,
56 56
57 productSource = { 57 productSource = {
58 datatype: "json", 58 datatype: 'json',
59 cache: false, 59 cache: false,
60 datafields: [ 60 datafields: [
61 { name: 'code', type: 'string' }, 61 { name: 'code', type: 'string' },
62 { name: 'name', type: 'string' }, 62 { name: 'name', type: 'string' },
63 { name: 'uuid', type: 'string' }, 63 { name: 'uuid', type: 'string' },
64 { name: 'stage', type: 'int' }, 64 { name: 'stage', type: 'int' },
65 { name: 'yeast_lo', type: 'float' }, 65 { name: 'yeast_lo', type: 'float' },
66 { name: 'yeast_hi', type: 'float' } 66 { name: 'yeast_hi', type: 'float' }
67 ], 67 ],
68 id: 'code', 68 id: 'code',
69 url: "includes/db_product.php?select=ferment" 69 url: 'includes/db_product.php?select=ferment'
70 }, 70 },
71 productlist = new $.jqx.dataAdapter(productSource, { 71 productlist = new $.jqx.dataAdapter(productSource, {
72 beforeLoadComplete: function (records) { 72 beforeLoadComplete: function(records) {
73 var row, i, data = new Array(); 73 var row, i, data = new Array();
74 // Create a dummy beer on top to store in idle fermenters. 74 // Create a dummy beer on top to store in idle fermenters.
75 blank['code'] = "Free"; // Will override this later. 75 blank['code'] = 'Free'; // Will override this later.
76 blank['name'] = 'Dummy'; 76 blank['name'] = 'Dummy';
77 blank['uuid'] = '66ecccbf-e942-4a35-af49-8b02314561a5'; 77 blank['uuid'] = '66ecccbf-e942-4a35-af49-8b02314561a5';
78 blank['stage'] = 10; 78 blank['stage'] = 10;
79 blank['yeast_lo'] = 12.0; 79 blank['yeast_lo'] = 12.0;
80 blank['yeast_hi'] = 24.0; 80 blank['yeast_hi'] = 24.0;
81 data.push(blank); 81 data.push(blank);
82 for (i = 0; i < records.length; i++) { 82 for (i = 0; i < records.length; i++) {
83 row = records[i]; 83 row = records[i];
84 data.push(row); 84 data.push(row);
85 } 85 }
86 return data; 86 return data;
87 }, 87 },
88 loadError: function(jqXHR, status, error) { 88 loadError: function(jqXHR, status, error) {
89 $('#err').text(status + ' ' + error); 89 $('#err').text(status + ' ' + error);
90 }, 90 },
91 }), 91 }),
92 profileSource = { 92 profileSource = {
93 datatype: "json", 93 datatype: 'json',
94 cache: false, 94 cache: false,
95 datafields: [ 95 datafields: [
96 { name: 'record', type: 'int' }, 96 { name: 'record', type: 'int' },
97 { name: 'uuid', type: 'string' }, 97 { name: 'uuid', type: 'string' },
98 { name: 'name', type: 'string' }, 98 { name: 'name', type: 'string' },
99 { name: 'inittemp_lo', type: 'float' }, 99 { name: 'inittemp_lo', type: 'float' },
100 { name: 'inittemp_hi', type: 'float' }, 100 { name: 'inittemp_hi', type: 'float' },
101 { name: 'fridgemode', type: 'int' }, 101 { name: 'fridgemode', type: 'int' },
102 { name: 'totalsteps', type: 'int' }, 102 { name: 'totalsteps', type: 'int' },
103 { name: 'duration', type: 'int' }, 103 { name: 'duration', type: 'int' },
104 { name: 'steps', type: 'array' } 104 { name: 'steps', type: 'array' }
105 ], 105 ],
106 id: 'record', 106 id: 'record',
107 url: "includes/db_profile_fermentation.php" 107 url: 'includes/db_profile_fermentation.php'
108 }, 108 },
109 profilelist = new $.jqx.dataAdapter(profileSource, { 109 profilelist = new $.jqx.dataAdapter(profileSource, {
110 beforeLoadComplete: function (records) { 110 beforeLoadComplete: function(records) {
111 var data = new Array(), 111 var data = new Array(),
112 empty = {}, i, row; 112 empty = {}, i, row;
113 // Create a dummy profile on top of the list. 113 // Create a dummy profile on top of the list.
114 empty['record'] = -1; 114 empty['record'] = -1;
115 empty['uuid'] = ''; 115 empty['uuid'] = '';
116 empty['name'] = 'Wis profiel'; 116 empty['name'] = 'Wis profiel';
117 empty['inittemp_lo'] = 20; 117 empty['inittemp_lo'] = 20;
118 empty['inittemp_hi'] = 20; 118 empty['inittemp_hi'] = 20;
119 empty['fridgemode'] = 0; 119 empty['fridgemode'] = 0;
120 empty['totalsteps'] = 0; 120 empty['totalsteps'] = 0;
121 empty['duration'] = 0; 121 empty['duration'] = 0;
122 empty['steps'] = '[]'; 122 empty['steps'] = '[]';
123 data.push(empty); 123 data.push(empty);
124 for (i = 0; i < records.length; i++) { 124 for (i = 0; i < records.length; i++) {
125 row = records[i]; 125 row = records[i];
126 data.push(row); 126 data.push(row);
127 } 127 }
128 return data; 128 return data;
129 }, 129 },
130 loadError: function(jqXHR, status, error) { 130 loadError: function(jqXHR, status, error) {
131 $('#err').text(status + ' ' + error); 131 $('#err').text(status + ' ' + error);
132 }, 132 },
133 }), 133 }),
134 gaugeoptions = { 134 gaugeoptions = {
135 min: 0, max: 40, width: 375, height: 375, 135 min: 0, max: 40, width: 375, height: 375,
136 ranges: [{ startValue: 0, endValue: yl, style: { fill: '#3399FF', stroke: '#3399FF' }, endWidth: 10, startWidth: 10 }, 136 ranges: [{ startValue: 0, endValue: yl, style: { fill: '#3399FF', stroke: '#3399FF' }, endWidth: 10, startWidth: 10 },
137 { startValue: yl, endValue: yh, style: { fill: '#00CC33', stroke: '#00CC33' }, endWidth: 10, startWidth: 10 }, 137 { startValue: yl, endValue: yh, style: { fill: '#00CC33', stroke: '#00CC33' }, endWidth: 10, startWidth: 10 },
138 { startValue: yh, endValue: 40, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }, endWidth: 10, startWidth: 10 }], 138 { startValue: yh, endValue: 40, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }, endWidth: 10, startWidth: 10 }],
139 ticksMinor: { interval: 1, size: '5%' }, 139 ticksMinor: { interval: 1, size: '5%' },
140 ticksMajor: { interval: 5, size: '9%' }, 140 ticksMajor: { interval: 5, size: '9%' },
141 labels: { interval: 5 }, 141 labels: { interval: 5 },
142 style: { fill: '#eeeeee', stroke: '#666666' }, 142 style: { fill: '#eeeeee', stroke: '#666666' },
143 value: 0, 143 value: 0,
144 colorScheme: 'scheme05' 144 colorScheme: 'scheme05'
145 }, 145 },
146 gaugeSmalloptions = { 146 gaugeSmalloptions = {
147 min: -15, max: 25, width: 190, height: 190, 147 min: -15, max: 25, width: 190, height: 190,
148 ranges: [{ startValue: -15, endValue: 0, startWidth: 5, endWidth: 5, style: { fill: '#3399FF', stroke: '#3399FF' }}, 148 ranges: [{ startValue: -15, endValue: 0, startWidth: 5, endWidth: 5, style: { fill: '#3399FF', stroke: '#3399FF' }},
149 { startValue: 0, endValue: 10, startWidth: 5, endWidth: 5, style: { fill: '#00CC33', stroke: '#00CC33' }}, 149 { startValue: 0, endValue: 10, startWidth: 5, endWidth: 5, style: { fill: '#00CC33', stroke: '#00CC33' }},
150 { startValue: 10, endValue: 25, startWidth: 5, endWidth: 5, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }}], 150 { startValue: 10, endValue: 25, startWidth: 5, endWidth: 5, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }}],
151 ticksMinor: { interval: 1, size: '5%' }, 151 ticksMinor: { interval: 1, size: '5%' },
152 ticksMajor: { interval: 5, size: '9%' }, 152 ticksMajor: { interval: 5, size: '9%' },
153 labels: { interval: 5 }, 153 labels: { interval: 5 },
154 style: { fill: '#eeeeee', stroke: '#666666' }, 154 style: { fill: '#eeeeee', stroke: '#666666' },
155 value: 0, 155 value: 0,
156 colorScheme: 'scheme05', 156 colorScheme: 'scheme05',
157 caption: { value: 'Chiller', position: 'bottom', offset: [0, 10] } 157 caption: { value: 'Koeler', position: 'bottom', offset: [0, 10] }
158 }, 158 },
159 switchoptions = { 159 switchoptions = {
160 height: 68, 160 height: 68,
161 width: 35, 161 width: 35,
162 onLabel:'AAN', 162 onLabel: 'AAN',
163 offLabel:'UIT', 163 offLabel: 'UIT',
164 theme: theme, 164 theme: theme,
165 thumbSize:'50%', 165 thumbSize: '50%',
166 orientation: 'vertical' 166 orientation: 'vertical'
167 }, 167 },
168 targetoptions = { inputMode: 'simple', theme: theme, width: 70, min: 0, max: 40, decimalDigits: 1, spinButtons: true }, 168 targetoptions = { inputMode: 'simple', theme: theme, width: 70, min: 0, max: 40, decimalDigits: 1, spinButtons: true },
169 url = "getfermenter.php?uuid='" + my_uuid + "'", 169 url = 'getfermenter.php?uuid="' + my_uuid + '"',
170 source = { 170 source = {
171 datatype: "json", 171 datatype: 'json',
172 datafields: [ 172 datafields: [
173 { name: 'record', type: 'int' }, 173 { name: 'record', type: 'int' },
174 { name: 'uuid', type: 'string' }, 174 { name: 'uuid', type: 'string' },
175 { name: 'alias', type: 'string' }, 175 { name: 'alias', type: 'string' },
176 { name: 'node', type: 'string' }, 176 { name: 'node', type: 'string' },
177 { name: 'online', type: 'int' }, 177 { name: 'online', type: 'int' },
178 { name: 'beercode', type: 'string' }, 178 { name: 'beercode', type: 'string' },
179 { name: 'beername', type: 'string' }, 179 { name: 'beername', type: 'string' },
180 { name: 'air_state', type: 'string' }, 180 { name: 'air_state', type: 'string' },
181 { name: 'air_temperature', type: 'float' }, 181 { name: 'air_temperature', type: 'float' },
182 { name: 'beer_state', type: 'string' }, 182 { name: 'beer_state', type: 'string' },
183 { name: 'beer_temperature', type: 'float' }, 183 { name: 'beer_temperature', type: 'float' },
184 { name: 'chiller_state', type: 'string' }, 184 { name: 'chiller_state', type: 'string' },
185 { name: 'chiller_temperature', type: 'float' }, 185 { name: 'chiller_temperature', type: 'float' },
186 { name: 'heater_state', type: 'int' }, 186 { name: 'heater_state', type: 'int' },
187 { name: 'heater_usage', type: 'int' }, 187 { name: 'heater_usage', type: 'int' },
188 { name: 'cooler_state', type: 'int' }, 188 { name: 'cooler_state', type: 'int' },
189 { name: 'cooler_usage', type: 'int' }, 189 { name: 'cooler_usage', type: 'int' },
190 { name: 'fan_state', type: 'int' }, 190 { name: 'fan_state', type: 'int' },
191 { name: 'fan_usage', type: 'int' }, 191 { name: 'fan_usage', type: 'int' },
192 { name: 'light_address', type: 'string' }, 192 { name: 'light_address', type: 'string' },
193 { name: 'light_state', type: 'int' }, 193 { name: 'light_state', type: 'int' },
194 { name: 'light_usage', type: 'int' }, 194 { name: 'light_usage', type: 'int' },
195 { name: 'door_address', type: 'string' }, 195 { name: 'door_address', type: 'string' },
196 { name: 'door_state', type: 'int' }, 196 { name: 'door_state', type: 'int' },
197 { name: 'psu_address', type: 'string' }, 197 { name: 'psu_address', type: 'string' },
198 { name: 'psu_state', type: 'int' }, 198 { name: 'psu_state', type: 'int' },
199 { name: 'mode', type: 'string' }, 199 { name: 'mode', type: 'string' },
200 { name: 'alarm', type: 'int' }, 200 { name: 'alarm', type: 'int' },
201 { name: 'setpoint_high', type: 'float' }, 201 { name: 'setpoint_high', type: 'float' },
202 { name: 'setpoint_low', type: 'float' }, 202 { name: 'setpoint_low', type: 'float' },
203 { name: 'profile_uuid', type: 'string' }, 203 { name: 'profile_uuid', type: 'string' },
204 { name: 'profile_name', type: 'string' }, 204 { name: 'profile_name', type: 'string' },
205 { name: 'profile_state', type: 'string' }, 205 { name: 'profile_state', type: 'string' },
206 { name: 'profile_percent', type: 'int' }, 206 { name: 'profile_percent', type: 'int' },
207 { name: 'profile_inittemp_high', type: 'float' }, 207 { name: 'profile_inittemp_high', type: 'float' },
208 { name: 'profile_inittemp_low', type: 'float' }, 208 { name: 'profile_inittemp_low', type: 'float' },
209 { name: 'profile_steps', type: 'string' }, 209 { name: 'profile_steps', type: 'string' },
210 { name: 'stage', type: 'string' }, 210 { name: 'stage', type: 'string' },
211 { name: 'beeruuid', type: 'string' }, 211 { name: 'beeruuid', type: 'string' },
212 { name: 'yeast_lo', type: 'float' }, 212 { name: 'yeast_lo', type: 'float' },
213 { name: 'yeast_hi', type: 'float' }, 213 { name: 'yeast_hi', type: 'float' },
214 { name: 'webcam_url', type: 'string' }, 214 { name: 'webcam_url', type: 'string' },
215 { name: 'webcam_light', type: 'int' } 215 { name: 'webcam_light', type: 'int' }
216 ], 216 ],
217 id: 'record', 217 id: 'record',
218 url: url 218 url: url
219 }, 219 },
220 dataAdapter = new $.jqx.dataAdapter(source, { 220 dataAdapter = new $.jqx.dataAdapter(source, {
221 loadComplete: function (records) { 221 loadComplete: function(records) {
222 record = dataAdapter.records[0]; 222 record = dataAdapter.records[0];
223 var range, oline = (record.online) ? "On-line" : "Off-line"; 223 var range, oline = (record.online) ? 'On-line' : 'Off-line';
224 $("#info_uuid").html(record.uuid); 224 $('#info_uuid').html(record.uuid);
225 $("#info_system").html(record.node + "/" + record.alias); 225 $('#info_system').html(record.node + '/' + record.alias);
226 $("#info_online").html(oline); 226 $('#info_online').html(oline);
227 $("#info_beer").html(record.beercode + " - " + record.beername); 227 $('#info_beer').html(record.beercode + ' - ' + record.beername);
228 $("#info_mode").jqxDropDownList('selectItem', record.mode); 228 $('#info_mode').jqxDropDownList('selectItem', record.mode);
229 $("#info_stage").jqxDropDownList('selectItem', record.stage); 229 $('#info_stage').jqxDropDownList('selectItem', record.stage);
230 $("#info_profile").html(record.profile_name); 230 $('#info_profile').html(record.profile_name);
231 blank['name'] = record.alias; 231 blank['name'] = record.alias;
232 blank['code'] = record.alias.toUpperCase(); 232 blank['code'] = record.alias.toUpperCase();
233 blank['uuid'] = record.uuid; 233 blank['uuid'] = record.uuid;
234 if (record.profile_name == "") 234 if (record.profile_name == '')
235 $("#info_mode").jqxDropDownList('disableItem', "PROFILE"); 235 $('#info_mode').jqxDropDownList('disableItem', 'PROFILE');
236 else 236 else
237 $("#info_mode").jqxDropDownList('enableItem', "PROFILE"); 237 $('#info_mode').jqxDropDownList('enableItem', 'PROFILE');
238 $("#target_lo").val(record.setpoint_low); 238 $('#target_lo').val(record.setpoint_low);
239 $("#target_hi").val(record.setpoint_high); 239 $('#target_hi').val(record.setpoint_high);
240 if (record.online && ((record.mode == "FRIDGE") || (record.mode == "BEER"))) { 240 if (record.online && ((record.mode == 'FRIDGE') || (record.mode == 'BEER'))) {
241 $("#target_lo").jqxNumberInput({ readOnly: false, Width: 70, spinButtons: true }); 241 $('#target_lo').jqxNumberInput({ readOnly: false, Width: 70, spinButtons: true });
242 $("#target_hi").jqxNumberInput({ readOnly: false, Width: 70, spinButtons: true }); 242 $('#target_hi').jqxNumberInput({ readOnly: false, Width: 70, spinButtons: true });
243 } else { 243 } else {
244 $("#target_lo").jqxNumberInput({ readOnly: true, Width: 50, spinButtons: false }); 244 $('#target_lo').jqxNumberInput({ readOnly: true, Width: 50, spinButtons: false });
245 $("#target_hi").jqxNumberInput({ readOnly: true, Width: 50, spinButtons: false }); 245 $('#target_hi').jqxNumberInput({ readOnly: true, Width: 50, spinButtons: false });
246 } 246 }
247 247
248 if (record.online && record.door_address && (record.door_state != "0")) { 248 if (record.online && record.door_address && (record.door_state != '0')) {
249 $("#fermenter_doorled").html('<div class="LEDyellow_on"></div>Door'); 249 $('#fermenter_doorled').html('<div class="LEDyellow_on"></div>Door');
250 } else { 250 } else {
251 $("#fermenter_doorled").html('<div class="LEDyellow_off"></div>Door'); 251 $('#fermenter_doorled').html('<div class="LEDyellow_off"></div>Door');
252 } 252 }
253 if (record.online && record.light_address && (record.light_state != "0")) { 253 if (record.online && record.light_address && (record.light_state != '0')) {
254 $("#fermenter_lightled").html('<div class="LEDyellow_on"></div>Light'); 254 $('#fermenter_lightled').html('<div class="LEDyellow_on"></div>Light');
255 } else { 255 } else {
256 $("#fermenter_lightled").html('<div class="LEDyellow_off"></div>Light'); 256 $('#fermenter_lightled').html('<div class="LEDyellow_off"></div>Light');
257 } 257 }
258 258
259 if (record.online && (record.mode != "OFF")) { 259 if (record.online && (record.mode != 'OFF')) {
260 $("#fermenter_powerled").html('<div class="LEDblue_on"></div>Power'); 260 $('#fermenter_powerled').html('<div class="LEDblue_on"></div>Power');
261 $("#select_beer").jqxDropDownList({ disabled: true }); 261 $('#select_beer').jqxDropDownList({ disabled: true });
262 $("#select_beer").jqxDropDownList('clearSelection'); 262 $('#select_beer').jqxDropDownList('clearSelection');
263 $("#select_beer").hide(); 263 $('#select_beer').hide();
264 } else { 264 } else {
265 $("#fermenter_powerled").html('<div class="LEDblue_off"></div>Power'); 265 $('#fermenter_powerled').html('<div class="LEDblue_off"></div>Power');
266 $("#select_beer").show(); 266 $('#select_beer').show();
267 $("#select_beer").jqxDropDownList({ disabled: false }); 267 $('#select_beer').jqxDropDownList({ disabled: false });
268 } 268 }
269 if (record.online && (record.alarm != "0")) { 269 if (record.online && (record.alarm != '0')) {
270 $("#fermenter_alarmled").html('<div class="LEDred_on"></div>Alarm'); 270 $('#fermenter_alarmled').html('<div class="LEDred_on"></div>Alarm');
271 } else { 271 } else {
272 $("#fermenter_alarmled").html('<div class="LEDred_off"></div>Alarm'); 272 $('#fermenter_alarmled').html('<div class="LEDred_off"></div>Alarm');
273 } 273 }
274 274
275 if (record.online && (record.heater_state != "0")) { 275 if (record.online && (record.heater_state != '0')) {
276 $("#fermenter_led1").html('<div class="LEDgreen_on"></div>Heat'); 276 $('#fermenter_led1').html('<div class="LEDgreen_on"></div>Heat');
277 } else { 277 } else {
278 $("#fermenter_led1").html('<div class="LEDgreen_off"></div>Heat'); 278 $('#fermenter_led1').html('<div class="LEDgreen_off"></div>Heat');
279 } 279 }
280 if (record.online && (record.cooler_state != "0")) { 280 if (record.online && (record.cooler_state != '0')) {
281 $("#fermenter_led2").html('<div class="LEDgreen_on"></div>Cool'); 281 $('#fermenter_led2').html('<div class="LEDgreen_on"></div>Cool');
282 } else { 282 } else {
283 $("#fermenter_led2").html('<div class="LEDgreen_off"></div>Cool'); 283 $('#fermenter_led2').html('<div class="LEDgreen_off"></div>Cool');
284 } 284 }
285 if (record.online && (record.fan_state != "0")) { 285 if (record.online && (record.fan_state != '0')) {
286 $("#fermenter_led3").html('<div class="LEDgreen_on"></div>Fan'); 286 $('#fermenter_led3').html('<div class="LEDgreen_on"></div>Fan');
287 } else { 287 } else {
288 $("#fermenter_led3").html('<div class="LEDgreen_off"></div>Fan'); 288 $('#fermenter_led3').html('<div class="LEDgreen_off"></div>Fan');
289 } 289 }
290 if (record.online && (record.mode == "NONE")) { 290 if (record.online && (record.mode == 'NONE')) {
291 $("#fermenter_toggle1").jqxSwitchButton( 'enable' ); 291 $('#fermenter_toggle1').jqxSwitchButton('enable');
292 $("#fermenter_toggle2").jqxSwitchButton( 'enable' ); 292 $('#fermenter_toggle2').jqxSwitchButton('enable');
293 $("#fermenter_toggle3").jqxSwitchButton( 'enable' ); 293 $('#fermenter_toggle3').jqxSwitchButton('enable');
294 } else { 294 } else {
295 $("#fermenter_toggle1").jqxSwitchButton( 'disable' ); 295 $('#fermenter_toggle1').jqxSwitchButton('disable');
296 $("#fermenter_toggle2").jqxSwitchButton( 'disable' ); 296 $('#fermenter_toggle2').jqxSwitchButton('disable');
297 $("#fermenter_toggle3").jqxSwitchButton( 'disable' ); 297 $('#fermenter_toggle3').jqxSwitchButton('disable');
298 $("#fermenter_toggle1").val( (record.heater_state != "0") ); 298 $('#fermenter_toggle1').val(record.heater_state != '0');
299 $("#fermenter_toggle2").val( (record.cooler_state != "0") ); 299 $('#fermenter_toggle2').val(record.cooler_state != '0');
300 $("#fermenter_toggle3").val( (record.fan_state != "0") ); 300 $('#fermenter_toggle3').val(record.fan_state != '0');
301 } 301 }
302 302
303 if (record.online && (record.mode == "PROFILE")) { 303 if (record.online && (record.mode == 'PROFILE')) {
304 if (record.profile_state == "OFF") { 304 if (record.profile_state == 'OFF') {
305 $("#select_profile").show(); 305 $('#select_profile').show();
306 $("#select_profile").jqxDropDownList({ disabled: false }); 306 $('#select_profile').jqxDropDownList({ disabled: false });
307 $("#info_mode").jqxDropDownList({ disabled: false }); 307 $('#info_mode').jqxDropDownList({ disabled: false });
308 $('#Profile1').jqxButton({ template: "success", value: "Starten" }); 308 $('#Profile1').jqxButton({ template: 'success', value: 'Starten' });
309 $("#Profile1").show(); 309 $('#Profile1').show();
310 $("#Profile2").hide(); 310 $('#Profile2').hide();
311 $("#status_profile").html(''); 311 $('#status_profile').html('');
312 } else if (record.profile_state == "RUN") { 312 } else if (record.profile_state == 'RUN') {
313 $("#select_profile").jqxDropDownList({ disabled: true }); 313 $('#select_profile').jqxDropDownList({ disabled: true });
314 $("#select_profile").hide(); 314 $('#select_profile').hide();
315 $("#info_mode").jqxDropDownList({ disabled: true }); 315 $('#info_mode').jqxDropDownList({ disabled: true });
316 $('#Profile1').jqxButton({ template: "danger", value: "Afbreken" }); 316 $('#Profile1').jqxButton({ template: 'danger', value: 'Afbreken' });
317 $('#Profile2').jqxButton({ template: "primary", value: "Pauze" }); 317 $('#Profile2').jqxButton({ template: 'primary', value: 'Pauze' });
318 $("#Profile1").show(); 318 $('#Profile1').show();
319 $("#Profile2").show(); 319 $('#Profile2').show();
320 $("#status_profile").html('Profiel actief, '+record.profile_percent+'% gereed'); 320 $('#status_profile').html('Profiel actief, ' + record.profile_percent + '% gereed');
321 } else if (record.profile_state == "PAUSE") { 321 } else if (record.profile_state == 'PAUSE') {
322 $("#select_profile").jqxDropDownList({ disabled: true }); 322 $('#select_profile').jqxDropDownList({ disabled: true });
323 $("#select_profile").hide(); 323 $('#select_profile').hide();
324 $("#info_mode").jqxDropDownList({ disabled: true }); 324 $('#info_mode').jqxDropDownList({ disabled: true });
325 $('#Profile1').jqxButton({ template: "danger", value: "Afbreken" }); 325 $('#Profile1').jqxButton({ template: 'danger', value: 'Afbreken' });
326 $('#Profile2').jqxButton({ template: "success", value: "Doorgaan" }); 326 $('#Profile2').jqxButton({ template: 'success', value: 'Doorgaan' });
327 $("#Profile1").show(); 327 $('#Profile1').show();
328 $("#Profile2").show(); 328 $('#Profile2').show();
329 $("#status_profile").html('Profiel pauze, '+record.profile_percent+'% gereed'); 329 $('#status_profile').html('Profiel pauze, ' + record.profile_percent + '% gereed');
330 } else if (record.profile_state == "DONE") { 330 } else if (record.profile_state == 'DONE') {
331 $("#select_profile").jqxDropDownList({ disabled: true }); 331 $('#select_profile').jqxDropDownList({ disabled: true });
332 $("#select_profile").hide(); 332 $('#select_profile').hide();
333 $("#info_mode").jqxDropDownList({ disabled: true }); 333 $('#info_mode').jqxDropDownList({ disabled: true });
334 $('#Profile1').jqxButton({ template: "primary", value: "Profiel Ok" }); 334 $('#Profile1').jqxButton({ template: 'primary', value: 'Profiel Ok' });
335 $("#Profile1").show(); 335 $('#Profile1').show();
336 $("#Profile2").hide(); 336 $('#Profile2').hide();
337 $("#status_profile").html('Profiel is gereed'); 337 $('#status_profile').html('Profiel is gereed');
338 } 338 }
339 } else { 339 } else {
340 $("#select_profile").show(); 340 $('#select_profile').show();
341 $("#select_profile").jqxDropDownList({ disabled: false }); 341 $('#select_profile').jqxDropDownList({ disabled: false });
342 $("#info_mode").jqxDropDownList({ disabled: false }); 342 $('#info_mode').jqxDropDownList({ disabled: false });
343 $("#Profile1").hide(); 343 $('#Profile1').hide();
344 $("#Profile2").hide(); 344 $('#Profile2').hide();
345 $("#status_profile").html(''); 345 $('#status_profile').html('');
346 } 346 }
347 if (record.online && (record.webcam_url != "")) { 347 if (record.online && (record.webcam_url != '')) {
348 $("#Camera").show(); 348 $('#Camera').show();
349 } else { 349 } else {
350 $("#Camera").hide(); 350 $('#Camera').hide();
351 } 351 }
352 352
353 yl = record.yeast_lo; 353 yl = record.yeast_lo;
354 yh = record.yeast_hi; 354 yh = record.yeast_hi;
355 range = { ranges: [{ startValue: 0, endValue: yl, style: { fill: '#3399FF', stroke: '#3399FF' }, endWidth: 10, startWidth: 10 }, 355 range = { ranges: [{ startValue: 0, endValue: yl, style: { fill: '#3399FF', stroke: '#3399FF' }, endWidth: 10, startWidth: 10 },
356 { startValue: yl, endValue: yh, style: { fill: '#00CC33', stroke: '#00CC33' }, endWidth: 10, startWidth: 10 }, 356 { startValue: yl, endValue: yh, style: { fill: '#00CC33', stroke: '#00CC33' }, endWidth: 10, startWidth: 10 },
357 { startValue: yh, endValue: 40, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }, endWidth: 10, startWidth: 10 }] }; 357 { startValue: yh, endValue: 40, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }, endWidth: 10, startWidth: 10 }]};
358 $("#gaugeContainer_air").jqxGauge( range ); 358 $('#gaugeContainer_air').jqxGauge(range);
359 $("#gaugeContainer_beer").jqxGauge( range ); 359 $('#gaugeContainer_beer').jqxGauge(range);
360 360
361 $("#gaugeContainer_air").jqxGauge({ caption: { value: 'Air: '+record.air_temperature.toFixed(3) }}); 361 $('#gaugeContainer_air').jqxGauge({ caption: { value: 'Lucht: ' + record.air_temperature.toFixed(3) }});
362 $('#gaugeContainer_air').jqxGauge({ value: record.air_temperature }); 362 $('#gaugeContainer_air').jqxGauge({ value: record.air_temperature });
363 if (record.air_state == "OK") { 363 if (record.air_state == 'OK') {
364 $("#gaugeContainer_air").jqxGauge({ disabled: false }); 364 $('#gaugeContainer_air').jqxGauge({ disabled: false });
365 } else { 365 } else {
366 $("#gaugeContainer_air").jqxGauge({ disabled: true }); 366 $('#gaugeContainer_air').jqxGauge({ disabled: true });
367 } 367 }
368 $("#gaugeContainer_beer").jqxGauge({ caption: { value: 'Beer: '+record.beer_temperature.toFixed(3) }}); 368 $('#gaugeContainer_beer').jqxGauge({ caption: { value: 'Bier: ' + record.beer_temperature.toFixed(3) }});
369 $('#gaugeContainer_beer').jqxGauge({ value: record.beer_temperature }); 369 $('#gaugeContainer_beer').jqxGauge({ value: record.beer_temperature });
370 if (record.beer_state == "OK") { 370 if (record.beer_state == 'OK') {
371 $("#gaugeContainer_beer").jqxGauge({ disabled: false }); 371 $('#gaugeContainer_beer').jqxGauge({ disabled: false });
372 } else { 372 } else {
373 $("#gaugeContainer_beer").jqxGauge({ disabled: true }); 373 $('#gaugeContainer_beer').jqxGauge({ disabled: true });
374 } 374 }
375 $("#gaugeContainer_chiller").jqxGauge({ value: record.chiller_temperature }); 375 $('#gaugeContainer_chiller').jqxGauge({ value: record.chiller_temperature });
376 if (record.chiller_state == "OK") { 376 if (record.chiller_state == 'OK') {
377 $("#gaugeContainer_chiller").jqxGauge({ disabled: false }); 377 $('#gaugeContainer_chiller').jqxGauge({ disabled: false });
378 } else { 378 } else {
379 $("#gaugeContainer_chiller").jqxGauge({ disabled: true }); 379 $('#gaugeContainer_chiller').jqxGauge({ disabled: true });
380 } 380 }
381 } 381 }
382 }); 382 });
383 383
384 384 $('#select_beer').jqxDropDownList({
385 385 placeHolder: 'Kies bier:',
386 386 theme: theme,
387 387 source: productlist,
388 388 displayMember: 'code',
389 $("#select_beer").jqxDropDownList({ 389 width: 150,
390 placeHolder: "Kies bier:", 390 height: 24,
391 theme: theme, 391 dropDownWidth: 500,
392 source: productlist, 392 autoDropDownHeight: true,
393 displayMember: "code", 393 renderer: function(index, label, value) {
394 width: 150, 394 var datarecord = productlist.records[index];
395 height: 24, 395 return datarecord.code + ' - ' + datarecord.name;
396 dropDownWidth: 500, 396 }
397 autoDropDownHeight: true, 397 });
398 renderer: function (index, label, value) { 398 $('#select_profile').jqxDropDownList({
399 var datarecord = productlist.records[index]; 399 placeHolder: 'Kies profiel:',
400 return datarecord.code + " - " + datarecord.name; 400 theme: theme,
401 } 401 source: profilelist,
402 }); 402 displayMember: 'name',
403 $("#select_profile").jqxDropDownList({ 403 width: 150,
404 placeHolder: "Kies profiel:", 404 height: 24,
405 theme: theme, 405 dropDownWidth: 500,
406 source: profilelist, 406 autoDropDownHeight: true,
407 displayMember: "name", 407 });
408 width: 150, 408
409 height: 24, 409 $('#gaugeContainer_air').jqxGauge(gaugeoptions);
410 dropDownWidth: 500, 410 $('#gaugeContainer_air').jqxGauge({ caption: { value: 'Lucht: 00.000' }});
411 autoDropDownHeight: true, 411 $('#gaugeContainer_beer').jqxGauge(gaugeoptions);
412 }); 412 $('#gaugeContainer_beer').jqxGauge({ caption: { value: 'Bier: 00.000' }});
413 413 $('#gaugeContainer_chiller').jqxGauge(gaugeSmalloptions);
414 $("#gaugeContainer_air").jqxGauge( gaugeoptions ); 414
415 $("#gaugeContainer_air").jqxGauge( { caption: { value: 'Air: 00.000' }} ); 415 $('#fermenter_toggle1').jqxSwitchButton(switchoptions);
416 $("#gaugeContainer_beer").jqxGauge( gaugeoptions ); 416 $('#fermenter_toggle2').jqxSwitchButton(switchoptions);
417 $("#gaugeContainer_beer").jqxGauge( { caption: { value: 'Beer: 00.000' }} ); 417 $('#fermenter_toggle3').jqxSwitchButton(switchoptions);
418 $("#gaugeContainer_chiller").jqxGauge( gaugeSmalloptions ); 418
419 419 srcMode = ['OFF', 'NONE', 'FRIDGE', 'BEER', 'PROFILE'];
420 $("#fermenter_toggle1").jqxSwitchButton( switchoptions ); 420 srcStage = ['PRIMARY', 'SECONDARY', 'TERTIARY', 'CARBONATION'];
421 $("#fermenter_toggle2").jqxSwitchButton( switchoptions ); 421 $('#info_mode').jqxDropDownList({ theme: theme, source: srcMode, width: 100, height: 24, dropDownHeight: 156 });
422 $("#fermenter_toggle3").jqxSwitchButton( switchoptions ); 422 $('#info_stage').jqxDropDownList({ theme: theme, source: srcStage, width: 150, height: 24, dropDownHeight: 125 });
423 423
424 srcMode = [ "OFF", "NONE", "FRIDGE", "BEER", "PROFILE" ]; 424 $('#target_lo').jqxNumberInput(targetoptions);
425 srcStage = [ "PRIMARY", "SECONDARY", "TERTIARY", "CARBONATION" ]; 425 $('#target_hi').jqxNumberInput(targetoptions);
426 $("#info_mode").jqxDropDownList({ theme: theme, source: srcMode, width: 100, height: 24, dropDownHeight: 156 }); 426
427 $("#info_stage").jqxDropDownList({ theme: theme, source: srcStage, width: 150, height: 24, dropDownHeight: 125 }); 427 $('#Profile1').jqxButton({ template: 'info', width: '150px', height: 24, theme: theme });
428 428 $('#Profile2').jqxButton({ template: 'info', width: '150px', height: 24, theme: theme });
429 $("#target_lo").jqxNumberInput( targetoptions ); 429 $('#Profile1').hide(); // Hide these until they are needed.
430 $("#target_hi").jqxNumberInput( targetoptions ); 430 $('#Profile2').hide();
431 431
432 $("#Profile1").jqxButton({ template: "info", width: '150px', height: 24, theme: theme }); 432 function sendBase(stage, mode, tlo, thi) {
433 $("#Profile2").jqxButton({ template: "info", width: '150px', height: 24, theme: theme }); 433
434 $("#Profile1").hide(); // Hide these until they are needed. 434 console.log('sendBase(' + stage + ', ' + mode + ', ' + tlo + ', ' + thi + ')');
435 $("#Profile2").hide(); 435 var data = 'node=' + record.node + '&alias=' + record.alias + '&payload={"stage":"' + stage;
436 436 data += '","mode":"' + mode + '","setpoint":{"low":' + tlo + ',"high":' + thi + '}}';
437 function sendBase(stage, mode, tlo, thi) { 437 $.ajax({
438 438 url: 'cmd_fermenter.php',
439 console.log("sendBase("+stage+", "+mode+", "+tlo+", "+thi+")"); 439 data: data,
440 var data = 'node=' + record.node + '&alias=' + record.alias + '&payload={"stage":"' + stage; 440 type: 'POST',
441 data += '","mode":"' + mode + '","setpoint":{"low":' + tlo + ',"high":' + thi + '}}'; 441 success: function(data) {},
442 $.ajax({ 442 error: function(jqXHR, textStatus, errorThrown) { console.log('sendBase() error'); }
443 url: "cmd_fermenter.php", 443 });
444 data: data, 444 }
445 type: "POST", 445
446 success: function(data) {}, 446 function sendSwitch(sw1, sw2, sw3, sw4) {
447 error: function(jqXHR, textStatus, errorThrown) { console.log("sendBase() error"); } 447
448 }); 448 console.log('sendSwitch(' + sw1 + ', ' + sw2 + ', ' + sw3 + ', ' + sw4 + ')');
449 } 449 var data = 'node=' + record.node + '&alias=' + record.alias + '&payload=';
450 450 data += '{"heater":{"state":' + sw1 + '},"cooler":{"state":' + sw2 + '},"fan":{"state":' + sw3 + '},"light":{"state":' + sw4 + '}}';
451 function sendSwitch(sw1, sw2, sw3, sw4) { 451 $.ajax({
452 452 url: 'cmd_fermenter.php',
453 console.log("sendSwitch("+sw1+", "+sw2+", "+sw3+", "+sw4+")"); 453 data: data,
454 var data = 'node='+record.node+'&alias='+record.alias+'&payload='; 454 type: 'POST',
455 data += '{"heater":{"state":'+sw1+'},"cooler":{"state":'+sw2+'},"fan":{"state":'+sw3+'},"light":{"state":'+sw4+'}}'; 455 success: function(data) {},
456 $.ajax({ 456 error: function(jqXHR, textStatus, errorThrown) { console.log('sendSwitch() error'); }
457 url: "cmd_fermenter.php", 457 });
458 data: data, 458 }
459 type: "POST", 459
460 success: function(data) {}, 460 function sendProduct(code, name, uuid, yeast_lo, yeast_hi) {
461 error: function(jqXHR, textStatus, errorThrown) { console.log("sendSwitch() error"); } 461
462 }); 462 console.log('sendProduct(' + code + ', ' + name + ', ' + uuid + ', ' + yeast_lo + ', ' + yeast_hi + ')');
463 } 463 var data = 'node=' + record.node + '&alias=' + record.alias + '&payload=';
464 464 data += '{"product":{"code":"' + code + '","name":"' + name + '","uuid":"' + uuid + '","yeast_lo":' + yeast_lo + ',"yeast_hi":' + yeast_hi + '}}';
465 function sendProduct(code, name, uuid, yeast_lo, yeast_hi) { 465 $.ajax({
466 466 url: 'cmd_fermenter.php',
467 console.log("sendProduct("+code+", "+name+", "+uuid+", "+yeast_lo+", "+yeast_hi+")"); 467 data: data,
468 var data = 'node='+record.node+'&alias='+record.alias+'&payload='; 468 type: 'POST',
469 data += '{"product":{"code":"'+code+'","name":"'+name+'","uuid":"'+uuid+'","yeast_lo":'+yeast_lo+',"yeast_hi":'+yeast_hi+'}}'; 469 success: function(data) {},
470 $.ajax({ 470 error: function(jqXHR, textStatus, errorThrown) { console.log('sendProduct() error'); }
471 url: "cmd_fermenter.php", 471 });
472 data: data, 472 }
473 type: "POST", 473
474 success: function(data) {}, 474 function sendProfile(payload) {
475 error: function(jqXHR, textStatus, errorThrown) { console.log("sendProduct() error"); } 475
476 }); 476 console.log('sendProfile(' + payload + ')');
477 } 477 var data = 'node=' + record.node + '&alias=' + record.alias + '&payload=' + payload;
478 478 $.ajax({
479 function sendProfile(payload) { 479 url: 'cmd_fermenter.php',
480 480 data: data,
481 console.log("sendProfile("+payload+")"); 481 type: 'POST',
482 var data = 'node='+record.node+'&alias='+record.alias+'&payload='+payload; 482 success: function(data) {},
483 $.ajax({ 483 error: function(jqXHR, textStatus, errorThrown) { console.log('sendProfile() error'); }
484 url: "cmd_fermenter.php", 484 });
485 data: data, 485 }
486 type: "POST", 486
487 success: function(data) {}, 487
488 error: function(jqXHR, textStatus, errorThrown) { console.log("sendProfile() error"); } 488 // Get the data immediatly and then at regular intervals to refresh.
489 }); 489 dataAdapter.dataBind();
490 } 490 setInterval(function() {
491 491 var skip = false;
492 492 if (newBase) {
493 // Get the data immediatly and then at regular intervals to refresh. 493 sendBase(record.stage, record.mode, record.setpoint_low, record.setpoint_high);
494 dataAdapter.dataBind(); 494 newBase = false;
495 setInterval(function() { 495 skip = true;
496 var skip = false; 496 }
497 if (newBase) { 497 if (newSwitch) {
498 sendBase(record.stage, record.mode, record.setpoint_low, record.setpoint_high); 498 sendSwitch(record.heater_state, record.cooler_state, record.fan_state, record.light_state);
499 newBase = false; 499 newSwitch = false;
500 skip = true; 500 skip = true;
501 } 501 }
502 if (newSwitch) { 502 if (newProduct) {
503 sendSwitch(record.heater_state, record.cooler_state, record.fan_state, record.light_state); 503 sendProduct(record.beercode, record.beername, record.beeruuid, record.yeast_lo, record.yeast_hi);
504 newSwitch = false; 504 newProduct = false;
505 skip = true; 505 skip = true;
506 } 506 }
507 if (newProduct) { 507 if (newProfile) {
508 sendProduct(record.beercode, record.beername, record.beeruuid, record.yeast_lo, record.yeast_hi); 508 sendProfile(ppayload);
509 newProduct = false; 509 newProfile = false;
510 skip = true; 510 skip = true;
511 } 511 }
512 if (newProfile) { 512 if (skip) {
513 sendProfile(ppayload); 513 schedule = 4; // 2 seconds wait to get the results
514 newProfile = false; 514 } else {
515 skip = true; 515 if (schedule > 0)
516 } 516 schedule--;
517 if (skip) { 517 }
518 schedule = 4; // 2 seconds wait to get the results 518
519 } else { 519 if (schedule <= 0) {
520 if (schedule > 0) 520 dataAdapter.dataBind();
521 schedule--; 521 schedule = 20;
522 } 522 }
523 523 }, 500);
524 if (schedule <= 0) { 524
525 dataAdapter.dataBind(); 525 $('#info_mode').on('change', function(event) {
526 schedule = 20; 526 var args = event.args;
527 } 527 if (args) {
528 }, 500); 528 record.mode = args.item.value;
529 529 $('#fermenter_toggle1').val(0);
530 $('#info_mode').on('change', function (event) { 530 $('#fermenter_toggle2').val(0);
531 var args = event.args; 531 $('#fermenter_toggle3').val(0);
532 if (args) { 532 }
533 record.mode = args.item.value; 533 newBase = true;
534 $("#fermenter_toggle1").val(0); 534 });
535 $("#fermenter_toggle2").val(0); 535 $('#info_stage').on('select', function(event) {
536 $("#fermenter_toggle3").val(0); 536 var args = event.args;
537 } 537 if (args)
538 newBase = true; 538 record.stage = args.item.value;
539 }); 539 newBase = true;
540 $('#info_stage').on('select', function (event) { 540 });
541 var args = event.args; 541 $('#select_beer').on('select', function(event) {
542 if (args) 542 if (event.args) {
543 record.stage = args.item.value; 543 var index = event.args.index,
544 newBase = true; 544 datarecord = productlist.records[index];
545 }); 545 record.beercode = datarecord.code;
546 $("#select_beer").on('select', function (event) { 546 record.beername = datarecord.name;
547 if (event.args) { 547 record.beeruuid = datarecord.uuid;
548 var index = event.args.index, 548 record.yeast_lo = datarecord.yeast_lo;
549 datarecord = productlist.records[index]; 549 record.yeast_hi = datarecord.yeast_hi;
550 record.beercode = datarecord.code; 550 newProduct = true;
551 record.beername = datarecord.name; 551 }
552 record.beeruuid = datarecord.uuid; 552 });
553 record.yeast_lo = datarecord.yeast_lo; 553 $('#select_profile').on('select', function(event) {
554 record.yeast_hi = datarecord.yeast_hi; 554 if (event.args) {
555 newProduct = true; 555 var index = event.args.index,
556 } 556 datarecord = profilelist.records[index],
557 }); 557 row, i;
558 $("#select_profile").on('select', function (event) { 558 if (datarecord.record == -1) {
559 if (event.args) { 559 ppayload = '{"profile":null}';
560 var index = event.args.index, 560 } else {
561 datarecord = profilelist.records[index], 561 ppayload = '{"profile":{"uuid":"' + datarecord.uuid + '","name":"' + datarecord.name + '",';
562 row, i; 562 ppayload += '"inittemp":{"low":' + datarecord.inittemp_lo + ',"high":' + datarecord.inittemp_hi + '},';
563 if (datarecord.record == -1) { 563 ppayload += '"fridgemode":' + datarecord.fridgemode + ',"steps":[';
564 ppayload = '{"profile":null}'; 564 for (i = 0; i < datarecord.steps.length; i++) {
565 } else { 565 row = datarecord.steps[i];
566 ppayload = '{"profile":{"uuid":"'+datarecord.uuid+'","name":"'+datarecord.name+'",'; 566 if (i > 0)
567 ppayload += '"inittemp":{"low":'+datarecord.inittemp_lo+',"high":'+datarecord.inittemp_hi+'},'; 567 ppayload += ',';
568 ppayload += '"fridgemode":'+datarecord.fridgemode+',"steps":['; 568 ppayload += '{"steptime":' + row['steptime'] + ',"resttime":' + row['resttime'];
569 for (i = 0; i < datarecord.steps.length; i++) { 569 ppayload += ',"target_lo":' + row['target_lo'] + ',"target_hi":' + row['target_hi'];
570 row = datarecord.steps[i]; 570 ppayload += ',"fridgemode":' + row['fridgemode'] + ',"name":"' + row['name'] + '"}';
571 if (i > 0) 571 }
572 ppayload += ','; 572 ppayload += ']}}';
573 ppayload += '{"steptime":'+row['steptime']+',"resttime":'+row['resttime']; 573 }
574 ppayload += ',"target_lo":'+row['target_lo']+',"target_hi":'+row['target_hi']; 574 newProfile = true;
575 ppayload += ',"fridgemode":'+row['fridgemode']+',"name":"'+row['name']+'"}'; 575 }
576 } 576 });
577 ppayload += ']}}'; 577
578 } 578 $('#target_lo').on('change', function(event) {
579 newProfile = true; 579 record.setpoint_low = parseFloat(event.args.value);
580 } 580 // Keep the high target above the low.
581 }); 581 if (record.setpoint_low > record.setpoint_high) {
582 582 record.setpoint_high = record.setpoint_low;
583 $('#target_lo').on('change', function (event) { 583 $('#target_hi').val(record.setpoint_high);
584 record.setpoint_low = parseFloat(event.args.value); 584 }
585 // Keep the high target above the low. 585 newBase = true;
586 if (record.setpoint_low > record.setpoint_high) { 586 });
587 record.setpoint_high = record.setpoint_low; 587 $('#target_hi').on('change', function(event) {
588 $("#target_hi").val(record.setpoint_high); 588 record.setpoint_high = parseFloat(event.args.value);
589 } 589 // Keep the low target below the high.
590 newBase = true; 590 if (record.setpoint_high < record.setpoint_low) {
591 }); 591 record.setpoint_low = record.setpoint_high;
592 $('#target_hi').on('change', function (event) { 592 $('#target_lo').val(record.setpoint_low);
593 record.setpoint_high = parseFloat(event.args.value); 593 }
594 // Keep the low target below the high. 594 newBase = true;
595 if (record.setpoint_high < record.setpoint_low) { 595 });
596 record.setpoint_low = record.setpoint_high; 596
597 $("#target_lo").val(record.setpoint_low); 597 $('#fermenter_toggle1').on('checked', function(event) {
598 } 598 if (record.mode == 'NONE') {
599 newBase = true; 599 record.heater_state = 0;
600 }); 600 newSwitch = true;
601 601 }
602 $("#fermenter_toggle1").on('checked', function (event) { 602 });
603 if (record.mode == "NONE") { 603 $('#fermenter_toggle1').on('unchecked', function(event) {
604 record.heater_state = 0; 604 if (record.mode == 'NONE') {
605 newSwitch = true; 605 record.heater_state = 100;
606 } 606 record.cooler_state = 0;
607 }); 607 $('#fermenter_toggle2').val(0);
608 $("#fermenter_toggle1").on('unchecked', function (event) { 608 newSwitch = true;
609 if (record.mode == "NONE") { 609 }
610 record.heater_state = 100; 610 });
611 record.cooler_state = 0; 611 $('#fermenter_toggle2').on('checked', function(event) {
612 $("#fermenter_toggle2").val(0); 612 if (record.mode == 'NONE') {
613 newSwitch = true; 613 record.cooler_state = 0;
614 } 614 newSwitch = true;
615 }); 615 }
616 $("#fermenter_toggle2").on('checked', function (event) { 616 });
617 if (record.mode == "NONE") { 617 $('#fermenter_toggle2').on('unchecked', function(event) {
618 record.cooler_state = 0; 618 if (record.mode == 'NONE') {
619 newSwitch = true; 619 record.cooler_state = 100;
620 } 620 record.heater_state = 0;
621 }); 621 $('#fermenter_toggle1').val(0);
622 $("#fermenter_toggle2").on('unchecked', function (event) { 622 newSwitch = true;
623 if (record.mode == "NONE") { 623 }
624 record.cooler_state = 100; 624 });
625 record.heater_state = 0; 625 $('#fermenter_toggle3').on('checked', function(event) {
626 $("#fermenter_toggle1").val(0); 626 if (record.mode == 'NONE') {
627 newSwitch = true; 627 record.fan_state = 0;
628 } 628 newSwitch = true;
629 }); 629 }
630 $("#fermenter_toggle3").on('checked', function (event) { 630 });
631 if (record.mode == "NONE") { 631 $('#fermenter_toggle3').on('unchecked', function(event) {
632 record.fan_state = 0; 632 if (record.mode == 'NONE') {
633 newSwitch = true; 633 record.fan_state = 100;
634 } 634 newSwitch = true;
635 }); 635 }
636 $("#fermenter_toggle3").on('unchecked', function (event) { 636 });
637 if (record.mode == "NONE") { 637 $('#Profile1').click(function() {
638 record.fan_state = 100; 638 if (record.mode == 'PROFILE') {
639 newSwitch = true; 639 if (record.profile_state == 'OFF') {
640 } 640 ppayload = '{"profile":{"command":"start"}}';
641 }); 641 newProfile = true;
642 $("#Profile1").click(function () { 642 } else if ((record.profile_state == 'RUN') || (record.profile_state == 'PAUSE')) {
643 if (record.mode == "PROFILE") { 643 // Open a popup to confirm this action.
644 if (record.profile_state == "OFF") { 644 $('#eventWindow').jqxWindow('open');
645 ppayload = '{"profile":{"command":"start"}}'; 645 $('#delOk').click(function() {
646 newProfile = true; 646 ppayload = '{"profile":{"command":"abort"}}';
647 } else if ((record.profile_state == "RUN") || (record.profile_state == "PAUSE")) { 647 newProfile = true;
648 // Open a popup to confirm this action. 648 });
649 $('#eventWindow').jqxWindow('open'); 649 } else if (record.profile_state == 'DONE') {
650 $("#delOk").click(function () { 650 ppayload = '{"profile":{"command":"done"}}';
651 ppayload = '{"profile":{"command":"abort"}}'; 651 newProfile = true;
652 newProfile = true; 652 }
653 }); 653 }
654 } else if (record.profile_state == "DONE") { 654 });
655 ppayload = '{"profile":{"command":"done"}}'; 655 $('#Profile2').click(function() {
656 newProfile = true; 656 if (record.mode == 'PROFILE') {
657 } 657 if ((record.profile_state == 'RUN') || (record.profile_state == 'PAUSE')) {
658 } 658 ppayload = '{"profile":{"command":"pause"}}';
659 }); 659 newProfile = true;
660 $("#Profile2").click(function () { 660 }
661 if (record.mode == "PROFILE") { 661 }
662 if ((record.profile_state == "RUN") || (record.profile_state == "PAUSE")) { 662 });
663 ppayload = '{"profile":{"command":"pause"}}'; 663
664 newProfile = true; 664 // The chart button.
665 } 665 $('#FLog').jqxButton({ template: 'primary', width: '150px', theme: theme });
666 } 666 $('#FLog').click(function() {
667 }); 667 window.open('log_fermentation.php?code=' + record.beercode + '&name=' + record.beername);
668 668 });
669 // The chart button. 669 $('#Camera').jqxButton({ template: 'primary', width: '150px', theme: theme });
670 $("#FLog").jqxButton({ template: "primary", width: '150px', theme: theme }); 670 $('#Camera').click(function() {
671 $("#FLog").click(function () { 671 record.light_state = 100;
672 window.open('log_fermentation.php?code=' + record.beercode + '&name=' + record.beername); 672 newSwitch = true;
673 }); 673 window.open(record.webcam_url);
674 $("#Camera").jqxButton({ template: "primary", width: '150px', theme: theme }); 674 });
675 $("#Camera").click(function () { 675 createAbortElements();
676 record.light_state = 100;
677 newSwitch = true;
678 window.open(record.webcam_url);
679 });
680 createAbortElements();
681 }); 676 });

mercurial