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 var productlist = new $.jqx.dataAdapter(productSource, { |
71 productlist = new $.jqx.dataAdapter(productSource, { |
72 beforeLoadComplete: function (records) { |
72 beforeLoadComplete: function (records) { |
73 var 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 (var i = 0; i < records.length; i++) { |
82 for (i = 0; i < records.length; i++) { |
83 var 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 = { |
|
93 datatype: "json", |
|
94 cache: false, |
|
95 datafields: [ |
|
96 { name: 'record', type: 'int' }, |
|
97 { name: 'uuid', type: 'string' }, |
|
98 { name: 'name', type: 'string' }, |
|
99 { name: 'inittemp_lo', type: 'float' }, |
|
100 { name: 'inittemp_hi', type: 'float' }, |
|
101 { name: 'fridgemode', type: 'int' }, |
|
102 { name: 'totalsteps', type: 'int' }, |
|
103 { name: 'duration', type: 'int' }, |
|
104 { name: 'steps', type: 'array' } |
|
105 ], |
|
106 id: 'record', |
|
107 url: "includes/db_profile_fermentation.php" |
|
108 }, |
|
109 profilelist = new $.jqx.dataAdapter(profileSource, { |
|
110 beforeLoadComplete: function (records) { |
|
111 var data = new Array(), |
|
112 empty = {}, i, row; |
|
113 // Create a dummy profile on top of the list. |
|
114 empty['record'] = -1; |
|
115 empty['uuid'] = ''; |
|
116 empty['name'] = 'Wis profiel'; |
|
117 empty['inittemp_lo'] = 20; |
|
118 empty['inittemp_hi'] = 20; |
|
119 empty['fridgemode'] = 0; |
|
120 empty['totalsteps'] = 0; |
|
121 empty['duration'] = 0; |
|
122 empty['steps'] = '[]'; |
|
123 data.push(empty); |
|
124 for (i = 0; i < records.length; i++) { |
|
125 row = records[i]; |
|
126 data.push(row); |
|
127 } |
|
128 return data; |
|
129 }, |
|
130 loadError: function(jqXHR, status, error) { |
|
131 $('#err').text(status + ' ' + error); |
|
132 }, |
|
133 }), |
|
134 gaugeoptions = { |
|
135 min: 0, max: 40, width: 375, height: 375, |
|
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 }, |
|
138 { startValue: yh, endValue: 40, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }, endWidth: 10, startWidth: 10 }], |
|
139 ticksMinor: { interval: 1, size: '5%' }, |
|
140 ticksMajor: { interval: 5, size: '9%' }, |
|
141 labels: { interval: 5 }, |
|
142 style: { fill: '#eeeeee', stroke: '#666666' }, |
|
143 value: 0, |
|
144 colorScheme: 'scheme05' |
|
145 }, |
|
146 gaugeSmalloptions = { |
|
147 min: -15, max: 25, width: 190, height: 190, |
|
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' }}, |
|
150 { startValue: 10, endValue: 25, startWidth: 5, endWidth: 5, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }}], |
|
151 ticksMinor: { interval: 1, size: '5%' }, |
|
152 ticksMajor: { interval: 5, size: '9%' }, |
|
153 labels: { interval: 5 }, |
|
154 style: { fill: '#eeeeee', stroke: '#666666' }, |
|
155 value: 0, |
|
156 colorScheme: 'scheme05', |
|
157 caption: { value: 'Chiller', position: 'bottom', offset: [0, 10] } |
|
158 }, |
|
159 switchoptions = { |
|
160 height: 68, |
|
161 width: 35, |
|
162 onLabel:'AAN', |
|
163 offLabel:'UIT', |
|
164 theme: theme, |
|
165 thumbSize:'50%', |
|
166 orientation: 'vertical' |
|
167 }, |
|
168 targetoptions = { inputMode: 'simple', theme: theme, width: 70, min: 0, max: 40, decimalDigits: 1, spinButtons: true }, |
|
169 url = "getfermenter.php?uuid='" + my_uuid + "'", |
|
170 source = { |
|
171 datatype: "json", |
|
172 datafields: [ |
|
173 { name: 'record', type: 'int' }, |
|
174 { name: 'uuid', type: 'string' }, |
|
175 { name: 'alias', type: 'string' }, |
|
176 { name: 'node', type: 'string' }, |
|
177 { name: 'online', type: 'int' }, |
|
178 { name: 'beercode', type: 'string' }, |
|
179 { name: 'beername', type: 'string' }, |
|
180 { name: 'air_state', type: 'string' }, |
|
181 { name: 'air_temperature', type: 'float' }, |
|
182 { name: 'beer_state', type: 'string' }, |
|
183 { name: 'beer_temperature', type: 'float' }, |
|
184 { name: 'chiller_state', type: 'string' }, |
|
185 { name: 'chiller_temperature', type: 'float' }, |
|
186 { name: 'heater_state', type: 'int' }, |
|
187 { name: 'heater_usage', type: 'int' }, |
|
188 { name: 'cooler_state', type: 'int' }, |
|
189 { name: 'cooler_usage', type: 'int' }, |
|
190 { name: 'fan_state', type: 'int' }, |
|
191 { name: 'fan_usage', type: 'int' }, |
|
192 { name: 'light_address', type: 'string' }, |
|
193 { name: 'light_state', type: 'int' }, |
|
194 { name: 'light_usage', type: 'int' }, |
|
195 { name: 'door_address', type: 'string' }, |
|
196 { name: 'door_state', type: 'int' }, |
|
197 { name: 'psu_address', type: 'string' }, |
|
198 { name: 'psu_state', type: 'int' }, |
|
199 { name: 'mode', type: 'string' }, |
|
200 { name: 'alarm', type: 'int' }, |
|
201 { name: 'setpoint_high', type: 'float' }, |
|
202 { name: 'setpoint_low', type: 'float' }, |
|
203 { name: 'profile_uuid', type: 'string' }, |
|
204 { name: 'profile_name', type: 'string' }, |
|
205 { name: 'profile_state', type: 'string' }, |
|
206 { name: 'profile_percent', type: 'int' }, |
|
207 { name: 'profile_inittemp_high', type: 'float' }, |
|
208 { name: 'profile_inittemp_low', type: 'float' }, |
|
209 { name: 'profile_steps', type: 'string' }, |
|
210 { name: 'stage', type: 'string' }, |
|
211 { name: 'beeruuid', type: 'string' }, |
|
212 { name: 'yeast_lo', type: 'float' }, |
|
213 { name: 'yeast_hi', type: 'float' }, |
|
214 { name: 'webcam_url', type: 'string' }, |
|
215 { name: 'webcam_light', type: 'int' } |
|
216 ], |
|
217 id: 'record', |
|
218 url: url |
|
219 }, |
|
220 dataAdapter = new $.jqx.dataAdapter(source, { |
|
221 loadComplete: function (records) { |
|
222 record = dataAdapter.records[0]; |
|
223 var range, oline = (record.online) ? "On-line" : "Off-line"; |
|
224 $("#info_uuid").html(record.uuid); |
|
225 $("#info_system").html(record.node + "/" + record.alias); |
|
226 $("#info_online").html(oline); |
|
227 $("#info_beer").html(record.beercode + " - " + record.beername); |
|
228 $("#info_mode").jqxDropDownList('selectItem', record.mode); |
|
229 $("#info_stage").jqxDropDownList('selectItem', record.stage); |
|
230 $("#info_profile").html(record.profile_name); |
|
231 blank['name'] = record.alias; |
|
232 blank['code'] = record.alias.toUpperCase(); |
|
233 blank['uuid'] = record.uuid; |
|
234 if (record.profile_name == "") |
|
235 $("#info_mode").jqxDropDownList('disableItem', "PROFILE"); |
|
236 else |
|
237 $("#info_mode").jqxDropDownList('enableItem', "PROFILE"); |
|
238 $("#target_lo").val(record.setpoint_low); |
|
239 $("#target_hi").val(record.setpoint_high); |
|
240 if (record.online && ((record.mode == "FRIDGE") || (record.mode == "BEER"))) { |
|
241 $("#target_lo").jqxNumberInput({ readOnly: false, Width: 70, spinButtons: true }); |
|
242 $("#target_hi").jqxNumberInput({ readOnly: false, Width: 70, spinButtons: true }); |
|
243 } else { |
|
244 $("#target_lo").jqxNumberInput({ readOnly: true, Width: 50, spinButtons: false }); |
|
245 $("#target_hi").jqxNumberInput({ readOnly: true, Width: 50, spinButtons: false }); |
|
246 } |
|
247 |
|
248 if (record.online && record.door_address && (record.door_state != "0")) { |
|
249 $("#fermenter_doorled").html('<div class="LEDyellow_on"></div>Door'); |
|
250 } else { |
|
251 $("#fermenter_doorled").html('<div class="LEDyellow_off"></div>Door'); |
|
252 } |
|
253 if (record.online && record.light_address && (record.light_state != "0")) { |
|
254 $("#fermenter_lightled").html('<div class="LEDyellow_on"></div>Light'); |
|
255 } else { |
|
256 $("#fermenter_lightled").html('<div class="LEDyellow_off"></div>Light'); |
|
257 } |
|
258 |
|
259 if (record.online && (record.mode != "OFF")) { |
|
260 $("#fermenter_powerled").html('<div class="LEDblue_on"></div>Power'); |
|
261 $("#select_beer").jqxDropDownList({ disabled: true }); |
|
262 $("#select_beer").jqxDropDownList('clearSelection'); |
|
263 $("#select_beer").hide(); |
|
264 } else { |
|
265 $("#fermenter_powerled").html('<div class="LEDblue_off"></div>Power'); |
|
266 $("#select_beer").show(); |
|
267 $("#select_beer").jqxDropDownList({ disabled: false }); |
|
268 } |
|
269 if (record.online && (record.alarm != "0")) { |
|
270 $("#fermenter_alarmled").html('<div class="LEDred_on"></div>Alarm'); |
|
271 } else { |
|
272 $("#fermenter_alarmled").html('<div class="LEDred_off"></div>Alarm'); |
|
273 } |
|
274 |
|
275 if (record.online && (record.heater_state != "0")) { |
|
276 $("#fermenter_led1").html('<div class="LEDgreen_on"></div>Heat'); |
|
277 } else { |
|
278 $("#fermenter_led1").html('<div class="LEDgreen_off"></div>Heat'); |
|
279 } |
|
280 if (record.online && (record.cooler_state != "0")) { |
|
281 $("#fermenter_led2").html('<div class="LEDgreen_on"></div>Cool'); |
|
282 } else { |
|
283 $("#fermenter_led2").html('<div class="LEDgreen_off"></div>Cool'); |
|
284 } |
|
285 if (record.online && (record.fan_state != "0")) { |
|
286 $("#fermenter_led3").html('<div class="LEDgreen_on"></div>Fan'); |
|
287 } else { |
|
288 $("#fermenter_led3").html('<div class="LEDgreen_off"></div>Fan'); |
|
289 } |
|
290 if (record.online && (record.mode == "NONE")) { |
|
291 $("#fermenter_toggle1").jqxSwitchButton( 'enable' ); |
|
292 $("#fermenter_toggle2").jqxSwitchButton( 'enable' ); |
|
293 $("#fermenter_toggle3").jqxSwitchButton( 'enable' ); |
|
294 } else { |
|
295 $("#fermenter_toggle1").jqxSwitchButton( 'disable' ); |
|
296 $("#fermenter_toggle2").jqxSwitchButton( 'disable' ); |
|
297 $("#fermenter_toggle3").jqxSwitchButton( 'disable' ); |
|
298 $("#fermenter_toggle1").val( (record.heater_state != "0") ); |
|
299 $("#fermenter_toggle2").val( (record.cooler_state != "0") ); |
|
300 $("#fermenter_toggle3").val( (record.fan_state != "0") ); |
|
301 } |
|
302 |
|
303 if (record.online && (record.mode == "PROFILE")) { |
|
304 if (record.profile_state == "OFF") { |
|
305 $("#select_profile").show(); |
|
306 $("#select_profile").jqxDropDownList({ disabled: false }); |
|
307 $("#info_mode").jqxDropDownList({ disabled: false }); |
|
308 $('#Profile1').jqxButton({ template: "success", value: "Starten" }); |
|
309 $("#Profile1").show(); |
|
310 $("#Profile2").hide(); |
|
311 $("#status_profile").html(''); |
|
312 } else if (record.profile_state == "RUN") { |
|
313 $("#select_profile").jqxDropDownList({ disabled: true }); |
|
314 $("#select_profile").hide(); |
|
315 $("#info_mode").jqxDropDownList({ disabled: true }); |
|
316 $('#Profile1').jqxButton({ template: "danger", value: "Afbreken" }); |
|
317 $('#Profile2').jqxButton({ template: "primary", value: "Pauze" }); |
|
318 $("#Profile1").show(); |
|
319 $("#Profile2").show(); |
|
320 $("#status_profile").html('Profiel actief, '+record.profile_percent+'% gereed'); |
|
321 } else if (record.profile_state == "PAUSE") { |
|
322 $("#select_profile").jqxDropDownList({ disabled: true }); |
|
323 $("#select_profile").hide(); |
|
324 $("#info_mode").jqxDropDownList({ disabled: true }); |
|
325 $('#Profile1').jqxButton({ template: "danger", value: "Afbreken" }); |
|
326 $('#Profile2').jqxButton({ template: "success", value: "Doorgaan" }); |
|
327 $("#Profile1").show(); |
|
328 $("#Profile2").show(); |
|
329 $("#status_profile").html('Profiel pauze, '+record.profile_percent+'% gereed'); |
|
330 } else if (record.profile_state == "DONE") { |
|
331 $("#select_profile").jqxDropDownList({ disabled: true }); |
|
332 $("#select_profile").hide(); |
|
333 $("#info_mode").jqxDropDownList({ disabled: true }); |
|
334 $('#Profile1').jqxButton({ template: "primary", value: "Profiel Ok" }); |
|
335 $("#Profile1").show(); |
|
336 $("#Profile2").hide(); |
|
337 $("#status_profile").html('Profiel is gereed'); |
|
338 } |
|
339 } else { |
|
340 $("#select_profile").show(); |
|
341 $("#select_profile").jqxDropDownList({ disabled: false }); |
|
342 $("#info_mode").jqxDropDownList({ disabled: false }); |
|
343 $("#Profile1").hide(); |
|
344 $("#Profile2").hide(); |
|
345 $("#status_profile").html(''); |
|
346 } |
|
347 if (record.online && (record.webcam_url != "")) { |
|
348 $("#Camera").show(); |
|
349 } else { |
|
350 $("#Camera").hide(); |
|
351 } |
|
352 |
|
353 yl = record.yeast_lo; |
|
354 yh = record.yeast_hi; |
|
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 }, |
|
357 { startValue: yh, endValue: 40, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }, endWidth: 10, startWidth: 10 }] }; |
|
358 $("#gaugeContainer_air").jqxGauge( range ); |
|
359 $("#gaugeContainer_beer").jqxGauge( range ); |
|
360 |
|
361 $("#gaugeContainer_air").jqxGauge({ caption: { value: 'Air: '+record.air_temperature.toFixed(3) }}); |
|
362 $('#gaugeContainer_air').jqxGauge({ value: record.air_temperature }); |
|
363 if (record.air_state == "OK") { |
|
364 $("#gaugeContainer_air").jqxGauge({ disabled: false }); |
|
365 } else { |
|
366 $("#gaugeContainer_air").jqxGauge({ disabled: true }); |
|
367 } |
|
368 $("#gaugeContainer_beer").jqxGauge({ caption: { value: 'Beer: '+record.beer_temperature.toFixed(3) }}); |
|
369 $('#gaugeContainer_beer').jqxGauge({ value: record.beer_temperature }); |
|
370 if (record.beer_state == "OK") { |
|
371 $("#gaugeContainer_beer").jqxGauge({ disabled: false }); |
|
372 } else { |
|
373 $("#gaugeContainer_beer").jqxGauge({ disabled: true }); |
|
374 } |
|
375 $("#gaugeContainer_chiller").jqxGauge({ value: record.chiller_temperature }); |
|
376 if (record.chiller_state == "OK") { |
|
377 $("#gaugeContainer_chiller").jqxGauge({ disabled: false }); |
|
378 } else { |
|
379 $("#gaugeContainer_chiller").jqxGauge({ disabled: true }); |
|
380 } |
|
381 } |
|
382 }); |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
92 $("#select_beer").jqxDropDownList({ |
389 $("#select_beer").jqxDropDownList({ |
93 placeHolder: "Kies bier:", |
390 placeHolder: "Kies bier:", |
94 theme: theme, |
391 theme: theme, |
95 source: productlist, |
392 source: productlist, |
96 displayMember: "code", |
393 displayMember: "code", |
155 height: 24, |
409 height: 24, |
156 dropDownWidth: 500, |
410 dropDownWidth: 500, |
157 autoDropDownHeight: true, |
411 autoDropDownHeight: true, |
158 }); |
412 }); |
159 |
413 |
160 var gaugeoptions = { |
|
161 min: 0, max: 40, width: 375, height: 375, |
|
162 ranges: [{ startValue: 0, endValue: yl, style: { fill: '#3399FF', stroke: '#3399FF' }, endWidth: 10, startWidth: 10 }, |
|
163 { startValue: yl, endValue: yh, style: { fill: '#00CC33', stroke: '#00CC33' }, endWidth: 10, startWidth: 10 }, |
|
164 { startValue: yh, endValue: 40, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }, endWidth: 10, startWidth: 10 }], |
|
165 ticksMinor: { interval: 1, size: '5%' }, |
|
166 ticksMajor: { interval: 5, size: '9%' }, |
|
167 labels: { interval: 5 }, |
|
168 style: { fill: '#eeeeee', stroke: '#666666' }, |
|
169 value: 0, |
|
170 colorScheme: 'scheme05' |
|
171 }; |
|
172 var gaugeSmalloptions = { |
|
173 min: -15, max: 25, width: 190, height: 190, |
|
174 ranges: [{ startValue: -15, endValue: 0, startWidth: 5, endWidth: 5, style: { fill: '#3399FF', stroke: '#3399FF' }}, |
|
175 { startValue: 0, endValue: 10, startWidth: 5, endWidth: 5, style: { fill: '#00CC33', stroke: '#00CC33' }}, |
|
176 { startValue: 10, endValue: 25, startWidth: 5, endWidth: 5, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }}], |
|
177 ticksMinor: { interval: 1, size: '5%' }, |
|
178 ticksMajor: { interval: 5, size: '9%' }, |
|
179 labels: { interval: 5 }, |
|
180 style: { fill: '#eeeeee', stroke: '#666666' }, |
|
181 value: 0, |
|
182 colorScheme: 'scheme05', |
|
183 caption: { value: 'Chiller', position: 'bottom', offset: [0, 10] } |
|
184 }; |
|
185 $("#gaugeContainer_air").jqxGauge( gaugeoptions ); |
414 $("#gaugeContainer_air").jqxGauge( gaugeoptions ); |
186 $("#gaugeContainer_air").jqxGauge( { caption: { value: 'Air: 00.000' }} ); |
415 $("#gaugeContainer_air").jqxGauge( { caption: { value: 'Air: 00.000' }} ); |
187 $("#gaugeContainer_beer").jqxGauge( gaugeoptions ); |
416 $("#gaugeContainer_beer").jqxGauge( gaugeoptions ); |
188 $("#gaugeContainer_beer").jqxGauge( { caption: { value: 'Beer: 00.000' }} ); |
417 $("#gaugeContainer_beer").jqxGauge( { caption: { value: 'Beer: 00.000' }} ); |
189 $("#gaugeContainer_chiller").jqxGauge( gaugeSmalloptions ); |
418 $("#gaugeContainer_chiller").jqxGauge( gaugeSmalloptions ); |
190 |
419 |
191 var switchoptions = { |
|
192 height: 68, |
|
193 width: 35, |
|
194 onLabel:'AAN', |
|
195 offLabel:'UIT', |
|
196 theme: theme, |
|
197 thumbSize:'50%', |
|
198 orientation: 'vertical' |
|
199 }; |
|
200 $("#fermenter_toggle1").jqxSwitchButton( switchoptions ); |
420 $("#fermenter_toggle1").jqxSwitchButton( switchoptions ); |
201 $("#fermenter_toggle2").jqxSwitchButton( switchoptions ); |
421 $("#fermenter_toggle2").jqxSwitchButton( switchoptions ); |
202 $("#fermenter_toggle3").jqxSwitchButton( switchoptions ); |
422 $("#fermenter_toggle3").jqxSwitchButton( switchoptions ); |
203 |
423 |
204 srcMode = [ "OFF", "NONE", "FRIDGE", "BEER", "PROFILE" ]; |
424 srcMode = [ "OFF", "NONE", "FRIDGE", "BEER", "PROFILE" ]; |
205 srcStage = [ "PRIMARY", "SECONDARY", "TERTIARY", "CARBONATION" ]; |
425 srcStage = [ "PRIMARY", "SECONDARY", "TERTIARY", "CARBONATION" ]; |
206 $("#info_mode").jqxDropDownList({ theme: theme, source: srcMode, width: 100, height: 24, dropDownHeight: 156 }); |
426 $("#info_mode").jqxDropDownList({ theme: theme, source: srcMode, width: 100, height: 24, dropDownHeight: 156 }); |
207 $("#info_stage").jqxDropDownList({ theme: theme, source: srcStage, width: 150, height: 24, dropDownHeight: 125 }); |
427 $("#info_stage").jqxDropDownList({ theme: theme, source: srcStage, width: 150, height: 24, dropDownHeight: 125 }); |
208 |
428 |
209 var targetoptions = { inputMode: 'simple', theme: theme, width: 70, min: 0, max: 40, decimalDigits: 1, spinButtons: true }; |
|
210 $("#target_lo").jqxNumberInput( targetoptions ); |
429 $("#target_lo").jqxNumberInput( targetoptions ); |
211 $("#target_hi").jqxNumberInput( targetoptions ); |
430 $("#target_hi").jqxNumberInput( targetoptions ); |
212 |
431 |
213 $("#Profile1").jqxButton({ template: "info", width: '150px', height: 24, theme: theme }); |
432 $("#Profile1").jqxButton({ template: "info", width: '150px', height: 24, theme: theme }); |
214 $("#Profile2").jqxButton({ template: "info", width: '150px', height: 24, theme: theme }); |
433 $("#Profile2").jqxButton({ template: "info", width: '150px', height: 24, theme: theme }); |
268 success: function(data) {}, |
487 success: function(data) {}, |
269 error: function(jqXHR, textStatus, errorThrown) { console.log("sendProfile() error"); } |
488 error: function(jqXHR, textStatus, errorThrown) { console.log("sendProfile() error"); } |
270 }); |
489 }); |
271 } |
490 } |
272 |
491 |
273 var url = "getfermenter.php?uuid='" + my_uuid + "'"; |
|
274 var source = { |
|
275 datatype: "json", |
|
276 datafields: [ |
|
277 { name: 'record', type: 'int' }, |
|
278 { name: 'uuid', type: 'string' }, |
|
279 { name: 'alias', type: 'string' }, |
|
280 { name: 'node', type: 'string' }, |
|
281 { name: 'online', type: 'int' }, |
|
282 { name: 'beercode', type: 'string' }, |
|
283 { name: 'beername', type: 'string' }, |
|
284 { name: 'air_state', type: 'string' }, |
|
285 { name: 'air_temperature', type: 'float' }, |
|
286 { name: 'beer_state', type: 'string' }, |
|
287 { name: 'beer_temperature', type: 'float' }, |
|
288 { name: 'chiller_state', type: 'string' }, |
|
289 { name: 'chiller_temperature', type: 'float' }, |
|
290 { name: 'heater_state', type: 'int' }, |
|
291 { name: 'heater_usage', type: 'int' }, |
|
292 { name: 'cooler_state', type: 'int' }, |
|
293 { name: 'cooler_usage', type: 'int' }, |
|
294 { name: 'fan_state', type: 'int' }, |
|
295 { name: 'fan_usage', type: 'int' }, |
|
296 { name: 'light_address', type: 'string' }, |
|
297 { name: 'light_state', type: 'int' }, |
|
298 { name: 'light_usage', type: 'int' }, |
|
299 { name: 'door_address', type: 'string' }, |
|
300 { name: 'door_state', type: 'int' }, |
|
301 { name: 'psu_address', type: 'string' }, |
|
302 { name: 'psu_state', type: 'int' }, |
|
303 { name: 'mode', type: 'string' }, |
|
304 { name: 'alarm', type: 'int' }, |
|
305 { name: 'setpoint_high', type: 'float' }, |
|
306 { name: 'setpoint_low', type: 'float' }, |
|
307 { name: 'profile_uuid', type: 'string' }, |
|
308 { name: 'profile_name', type: 'string' }, |
|
309 { name: 'profile_state', type: 'string' }, |
|
310 { name: 'profile_percent', type: 'int' }, |
|
311 { name: 'profile_inittemp_high', type: 'float' }, |
|
312 { name: 'profile_inittemp_low', type: 'float' }, |
|
313 { name: 'profile_steps', type: 'string' }, |
|
314 { name: 'stage', type: 'string' }, |
|
315 { name: 'beeruuid', type: 'string' }, |
|
316 { name: 'yeast_lo', type: 'float' }, |
|
317 { name: 'yeast_hi', type: 'float' }, |
|
318 { name: 'webcam_url', type: 'string' }, |
|
319 { name: 'webcam_light', type: 'int' } |
|
320 ], |
|
321 id: 'record', |
|
322 url: url |
|
323 }; |
|
324 |
|
325 var dataAdapter = new $.jqx.dataAdapter(source, { |
|
326 loadComplete: function (records) { |
|
327 record = dataAdapter.records[0]; |
|
328 var oline = (record.online) ? "On-line" : "Off-line"; |
|
329 $("#info_uuid").html(record.uuid); |
|
330 $("#info_system").html(record.node + "/" + record.alias); |
|
331 $("#info_online").html(oline); |
|
332 $("#info_beer").html(record.beercode + " - " + record.beername); |
|
333 $("#info_mode").jqxDropDownList('selectItem', record.mode); |
|
334 $("#info_stage").jqxDropDownList('selectItem', record.stage); |
|
335 $("#info_profile").html(record.profile_name); |
|
336 blank['name'] = record.alias; |
|
337 blank['code'] = record.alias.toUpperCase(); |
|
338 blank['uuid'] = record.uuid; |
|
339 if (record.profile_name == "") |
|
340 $("#info_mode").jqxDropDownList('disableItem', "PROFILE"); |
|
341 else |
|
342 $("#info_mode").jqxDropDownList('enableItem', "PROFILE"); |
|
343 $("#target_lo").val(record.setpoint_low); |
|
344 $("#target_hi").val(record.setpoint_high); |
|
345 if (record.online && ((record.mode == "FRIDGE") || (record.mode == "BEER"))) { |
|
346 $("#target_lo").jqxNumberInput({ readOnly: false, Width: 70, spinButtons: true }); |
|
347 $("#target_hi").jqxNumberInput({ readOnly: false, Width: 70, spinButtons: true }); |
|
348 } else { |
|
349 $("#target_lo").jqxNumberInput({ readOnly: true, Width: 50, spinButtons: false }); |
|
350 $("#target_hi").jqxNumberInput({ readOnly: true, Width: 50, spinButtons: false }); |
|
351 } |
|
352 |
|
353 if (record.online && record.door_address && (record.door_state != "0")) { |
|
354 $("#fermenter_doorled").html('<div class="LEDyellow_on"></div>Door'); |
|
355 } else { |
|
356 $("#fermenter_doorled").html('<div class="LEDyellow_off"></div>Door'); |
|
357 } |
|
358 if (record.online && record.light_address && (record.light_state != "0")) { |
|
359 $("#fermenter_lightled").html('<div class="LEDyellow_on"></div>Light'); |
|
360 } else { |
|
361 $("#fermenter_lightled").html('<div class="LEDyellow_off"></div>Light'); |
|
362 } |
|
363 |
|
364 if (record.online && (record.mode != "OFF")) { |
|
365 $("#fermenter_powerled").html('<div class="LEDblue_on"></div>Power'); |
|
366 $("#select_beer").jqxDropDownList({ disabled: true }); |
|
367 $("#select_beer").jqxDropDownList('clearSelection'); |
|
368 $("#select_beer").hide(); |
|
369 } else { |
|
370 $("#fermenter_powerled").html('<div class="LEDblue_off"></div>Power'); |
|
371 $("#select_beer").show(); |
|
372 $("#select_beer").jqxDropDownList({ disabled: false }); |
|
373 } |
|
374 if (record.online && (record.alarm != "0")) { |
|
375 $("#fermenter_alarmled").html('<div class="LEDred_on"></div>Alarm'); |
|
376 } else { |
|
377 $("#fermenter_alarmled").html('<div class="LEDred_off"></div>Alarm'); |
|
378 } |
|
379 |
|
380 if (record.online && (record.heater_state != "0")) { |
|
381 $("#fermenter_led1").html('<div class="LEDgreen_on"></div>Heat'); |
|
382 } else { |
|
383 $("#fermenter_led1").html('<div class="LEDgreen_off"></div>Heat'); |
|
384 } |
|
385 if (record.online && (record.cooler_state != "0")) { |
|
386 $("#fermenter_led2").html('<div class="LEDgreen_on"></div>Cool'); |
|
387 } else { |
|
388 $("#fermenter_led2").html('<div class="LEDgreen_off"></div>Cool'); |
|
389 } |
|
390 if (record.online && (record.fan_state != "0")) { |
|
391 $("#fermenter_led3").html('<div class="LEDgreen_on"></div>Fan'); |
|
392 } else { |
|
393 $("#fermenter_led3").html('<div class="LEDgreen_off"></div>Fan'); |
|
394 } |
|
395 if (record.online && (record.mode == "NONE")) { |
|
396 $("#fermenter_toggle1").jqxSwitchButton( 'enable' ); |
|
397 $("#fermenter_toggle2").jqxSwitchButton( 'enable' ); |
|
398 $("#fermenter_toggle3").jqxSwitchButton( 'enable' ); |
|
399 } else { |
|
400 $("#fermenter_toggle1").jqxSwitchButton( 'disable' ); |
|
401 $("#fermenter_toggle2").jqxSwitchButton( 'disable' ); |
|
402 $("#fermenter_toggle3").jqxSwitchButton( 'disable' ); |
|
403 $("#fermenter_toggle1").val( (record.heater_state != "0") ); |
|
404 $("#fermenter_toggle2").val( (record.cooler_state != "0") ); |
|
405 $("#fermenter_toggle3").val( (record.fan_state != "0") ); |
|
406 } |
|
407 |
|
408 if (record.online && (record.mode == "PROFILE")) { |
|
409 if (record.profile_state == "OFF") { |
|
410 $("#select_profile").show(); |
|
411 $("#select_profile").jqxDropDownList({ disabled: false }); |
|
412 $("#info_mode").jqxDropDownList({ disabled: false }); |
|
413 $('#Profile1').jqxButton({ template: "success", value: "Starten" }); |
|
414 $("#Profile1").show(); |
|
415 $("#Profile2").hide(); |
|
416 $("#status_profile").html(''); |
|
417 } else if (record.profile_state == "RUN") { |
|
418 $("#select_profile").jqxDropDownList({ disabled: true }); |
|
419 $("#select_profile").hide(); |
|
420 $("#info_mode").jqxDropDownList({ disabled: true }); |
|
421 $('#Profile1').jqxButton({ template: "danger", value: "Afbreken" }); |
|
422 $('#Profile2').jqxButton({ template: "primary", value: "Pauze" }); |
|
423 $("#Profile1").show(); |
|
424 $("#Profile2").show(); |
|
425 $("#status_profile").html('Profiel actief, '+record.profile_percent+'% gereed'); |
|
426 } else if (record.profile_state == "PAUSE") { |
|
427 $("#select_profile").jqxDropDownList({ disabled: true }); |
|
428 $("#select_profile").hide(); |
|
429 $("#info_mode").jqxDropDownList({ disabled: true }); |
|
430 $('#Profile1').jqxButton({ template: "danger", value: "Afbreken" }); |
|
431 $('#Profile2').jqxButton({ template: "success", value: "Doorgaan" }); |
|
432 $("#Profile1").show(); |
|
433 $("#Profile2").show(); |
|
434 $("#status_profile").html('Profiel pauze, '+record.profile_percent+'% gereed'); |
|
435 } else if (record.profile_state == "DONE") { |
|
436 $("#select_profile").jqxDropDownList({ disabled: true }); |
|
437 $("#select_profile").hide(); |
|
438 $("#info_mode").jqxDropDownList({ disabled: true }); |
|
439 $('#Profile1').jqxButton({ template: "primary", value: "Profiel Ok" }); |
|
440 $("#Profile1").show(); |
|
441 $("#Profile2").hide(); |
|
442 $("#status_profile").html('Profiel is gereed'); |
|
443 } |
|
444 } else { |
|
445 $("#select_profile").show(); |
|
446 $("#select_profile").jqxDropDownList({ disabled: false }); |
|
447 $("#info_mode").jqxDropDownList({ disabled: false }); |
|
448 $("#Profile1").hide(); |
|
449 $("#Profile2").hide(); |
|
450 $("#status_profile").html(''); |
|
451 } |
|
452 if (record.online && (record.webcam_url != "")) { |
|
453 $("#Camera").show(); |
|
454 } else { |
|
455 $("#Camera").hide(); |
|
456 } |
|
457 |
|
458 yl = record.yeast_lo; |
|
459 yh = record.yeast_hi; |
|
460 var range = { ranges: [{ startValue: 0, endValue: yl, style: { fill: '#3399FF', stroke: '#3399FF' }, endWidth: 10, startWidth: 10 }, |
|
461 { startValue: yl, endValue: yh, style: { fill: '#00CC33', stroke: '#00CC33' }, endWidth: 10, startWidth: 10 }, |
|
462 { startValue: yh, endValue: 40, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }, endWidth: 10, startWidth: 10 }] }; |
|
463 $("#gaugeContainer_air").jqxGauge( range ); |
|
464 $("#gaugeContainer_beer").jqxGauge( range ); |
|
465 |
|
466 $("#gaugeContainer_air").jqxGauge({ caption: { value: 'Air: '+record.air_temperature.toFixed(3) }}); |
|
467 $('#gaugeContainer_air').jqxGauge({ value: record.air_temperature }); |
|
468 if (record.air_state == "OK") { |
|
469 $("#gaugeContainer_air").jqxGauge({ disabled: false }); |
|
470 } else { |
|
471 $("#gaugeContainer_air").jqxGauge({ disabled: true }); |
|
472 } |
|
473 $("#gaugeContainer_beer").jqxGauge({ caption: { value: 'Beer: '+record.beer_temperature.toFixed(3) }}); |
|
474 $('#gaugeContainer_beer').jqxGauge({ value: record.beer_temperature }); |
|
475 if (record.beer_state == "OK") { |
|
476 $("#gaugeContainer_beer").jqxGauge({ disabled: false }); |
|
477 } else { |
|
478 $("#gaugeContainer_beer").jqxGauge({ disabled: true }); |
|
479 } |
|
480 $("#gaugeContainer_chiller").jqxGauge({ value: record.chiller_temperature }); |
|
481 if (record.chiller_state == "OK") { |
|
482 $("#gaugeContainer_chiller").jqxGauge({ disabled: false }); |
|
483 } else { |
|
484 $("#gaugeContainer_chiller").jqxGauge({ disabled: true }); |
|
485 } |
|
486 } |
|
487 }); |
|
488 |
492 |
489 // Get the data immediatly and then at regular intervals to refresh. |
493 // Get the data immediatly and then at regular intervals to refresh. |
490 dataAdapter.dataBind(); |
494 dataAdapter.dataBind(); |
491 setInterval(function() { |
495 setInterval(function() { |
492 var skip = false; |
496 var skip = false; |