www/js/mon_co2meter.js

Thu, 10 Feb 2022 22:15:10 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 10 Feb 2022 22:15:10 +0100
changeset 785
aa79acfdf8a9
parent 694
a165f6c20a44
permissions
-rw-r--r--

Added uuid field in inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts. Added uuid field in profiles mash, styles and water.

503
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*****************************************************************************
678
14322825cb3d The co2meters monitor screen rebuild to use websockets instead of data polling.
Michiel Broek <mbroek@mbse.eu>
parents: 526
diff changeset
2 * Copyright (C) 2019-2020
503
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Michiel Broek <mbroek at mbse dot eu>
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * This file is part of BMS
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 *
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * This is free software; you can redistribute it and/or modify it
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * under the terms of the GNU General Public License as published by the
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * Free Software Foundation; either version 2, or (at your option) any
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * later version.
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 *
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * Brewery Management System istributed in the hope that it will be useful, but
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * General Public License for more details.
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 *
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 * along with ThermFerm; see the file COPYING. If not, write to the Free
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
678
14322825cb3d The co2meters monitor screen rebuild to use websockets instead of data polling.
Michiel Broek <mbroek@mbse.eu>
parents: 526
diff changeset
21 */
503
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
526
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
24 $(document).ready(function() {
503
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25
526
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
26 var record = {},
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
27 blank = {},
503
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28
526
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
29 productSource = {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
30 datatype: 'json',
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
31 cache: false,
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
32 datafields: [
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
33 { name: 'code', type: 'string' },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
34 { name: 'name', type: 'string' },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
35 { name: 'uuid', type: 'string' }
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
36 ],
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
37 id: 'code',
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
38 url: 'includes/db_product.php?select=ferment'
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
39 },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
40 productlist = new $.jqx.dataAdapter(productSource, {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
41 beforeLoadComplete: function(records) {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
42 var row, i, data = new Array();
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
43 // Create a dummy beer on top to store in idle meters.
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
44 blank['code'] = 'Free'; // Will override this later.
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
45 blank['name'] = 'Dummy';
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
46 blank['uuid'] = '66ecccbf-e942-4a35-af49-8b02314561a5';
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
47 data.push(blank);
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
48 for (i = 0; i < records.length; i++) {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
49 row = records[i];
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
50 data.push(row);
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
51 }
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
52 return data;
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
53 },
680
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
54 loadError: function(jqXHR, status, error) { console.log(status + ' ' + error); },
526
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
55 }),
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
56 gaugeoptionst = {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
57 min: 10, max: 40, width: 375, height: 375,
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
58 ranges: [{ startValue: 10, endValue: 20, style: { fill: '#3399FF', stroke: '#3399FF' }, endWidth: 10, startWidth: 10 },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
59 { startValue: 20, endValue: 28, style: { fill: '#00CC33', stroke: '#00CC33' }, endWidth: 10, startWidth: 10 },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
60 { startValue: 28, endValue: 40, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }, endWidth: 10, startWidth: 10 }],
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
61 ticksMinor: { interval: 1, size: '5%' },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
62 ticksMajor: { interval: 5, size: '9%' },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
63 labels: { interval: 5 },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
64 style: { fill: '#eeeeee', stroke: '#666666' },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
65 value: 0,
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
66 colorScheme: 'scheme05'
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
67 },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
68 gaugeoptionsp = {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
69 min: 0, max: 6, width: 375, height: 375,
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
70 ranges: [{ startValue: 0, endValue: 3, style: { fill: '#00CC33', stroke: '#00CC33' }, endWidth: 10, startWidth: 10 },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
71 { startValue: 3, endValue: 6, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }, endWidth: 10, startWidth: 10 }],
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
72 ticksMinor: { interval: 0.2, size: '5%' },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
73 ticksMajor: { interval: 1, size: '9%' },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
74 labels: { interval: 1 },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
75 style: { fill: '#eeeeee', stroke: '#666666' },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
76 value: 0,
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
77 colorScheme: 'scheme05'
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
78 },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
79 url = 'getco2meter.php?uuid="' + my_uuid + '"',
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
80 source = {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
81 datatype: 'json',
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
82 datafields: [
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
83 { name: 'record', type: 'int' },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
84 { name: 'uuid', type: 'string' },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
85 { name: 'alias', type: 'string' },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
86 { name: 'node', type: 'string' },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
87 { name: 'online', type: 'int' },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
88 { name: 'beercode', type: 'string' },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
89 { name: 'beername', type: 'string' },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
90 { name: 'beeruuid', type: 'string' },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
91 { name: 'mode', type: 'string' },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
92 { name: 'alarm', type: 'int' },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
93 { name: 'temperature_state', type: 'string' },
680
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
94 { name: 'temperature_address', type: 'string' },
526
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
95 { name: 'temperature', type: 'float' },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
96 { name: 'pressure_state', type: 'string' },
680
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
97 { name: 'pressure_channel', type: 'int' },
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
98 { name: 'pressure_voltage', type: 'float' },
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
99 { name: 'pressure_zero', type: 'float' },
526
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
100 { name: 'pressure_bar', type: 'float' }
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
101 ],
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
102 id: 'record',
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
103 url: url
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
104 },
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
105 dataAdapter = new $.jqx.dataAdapter(source, {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
106 loadComplete: function(records) {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
107 record = dataAdapter.records[0];
680
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
108 updateScreen();
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
109 blank['name'] = record.alias;
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
110 blank['code'] = record.alias.toUpperCase();
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
111 blank['uuid'] = record.uuid;
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
112 }
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
113 });
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
114
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
115 function updateScreen() {
526
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
116 $('#info_uuid').html(record.uuid);
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
117 $('#info_system').html(record.node + '/' + record.alias);
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
118 $('#info_beer').html(record.beercode + ' - ' + record.beername);
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
119 $('#info_mode').html(record.mode);
503
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120
526
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
121 if (record.online && (record.mode != 'OFF')) {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
122 $('#co2meter_powerled').html('<div class="LEDblue_on"></div>Power');
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
123 $('#select_beer').jqxDropDownList({ disabled: true });
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
124 $('#select_beer').jqxDropDownList('clearSelection');
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
125 $('#select_beer').hide();
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
126 } else {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
127 $('#co2meter_powerled').html('<div class="LEDblue_off"></div>Power');
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
128 $('#select_beer').show();
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
129 $('#select_beer').jqxDropDownList({ disabled: false });
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
130 }
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
131 if (record.online && (record.alarm != '0')) {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
132 $('#co2meter_alarmled').html('<div class="LEDred_on"></div>Alarm');
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
133 } else {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
134 $('#co2meter_alarmled').html('<div class="LEDred_off"></div>Alarm');
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
135 }
503
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136
694
a165f6c20a44 Fixed temperature gauge update after an error.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
137 if (record.online) {
a165f6c20a44 Fixed temperature gauge update after an error.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
138 $('#info_online').html('On-line');
526
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
139 if (record.temperature_state == 'OK') {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
140 $('#gaugeContainer_temperature').jqxGauge({ disabled: false });
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
141 } else {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
142 $('#gaugeContainer_temperature').jqxGauge({ disabled: true });
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
143 }
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
144 if (record.pressure_state == 'OK') {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
145 $('#gaugeContainer_pressure').jqxGauge({ disabled: false });
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
146 } else {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
147 $('#gaugeContainer_pressure').jqxGauge({ disabled: true });
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
148 }
694
a165f6c20a44 Fixed temperature gauge update after an error.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
149 $('#gaugeContainer_temperature').jqxGauge({ caption: { value: 'Temp: ' + record.temperature.toFixed(3) }});
a165f6c20a44 Fixed temperature gauge update after an error.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
150 $('#gaugeContainer_temperature').jqxGauge({ value: record.temperature });
a165f6c20a44 Fixed temperature gauge update after an error.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
151 $('#gaugeContainer_pressure').jqxGauge({ caption: { value: 'Bar: ' + record.pressure_bar.toFixed(2) }});
a165f6c20a44 Fixed temperature gauge update after an error.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
152 $('#gaugeContainer_pressure').jqxGauge({ value: record.pressure_bar });
a165f6c20a44 Fixed temperature gauge update after an error.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
153 } else {
a165f6c20a44 Fixed temperature gauge update after an error.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
154 $('#info_online').html('Off-line');
a165f6c20a44 Fixed temperature gauge update after an error.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
155 $('#gaugeContainer_temperature').jqxGauge({ disabled: true });
a165f6c20a44 Fixed temperature gauge update after an error.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
156 $('#gaugeContainer_pressure').jqxGauge({ disabled: true });
a165f6c20a44 Fixed temperature gauge update after an error.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
157 }
680
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
158 }
503
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159
526
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
160 $('#select_beer').jqxDropDownList({
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
161 placeHolder: 'Kies bier:',
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
162 theme: theme,
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
163 source: productlist,
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
164 displayMember: 'code',
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
165 width: 150,
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
166 height: 24,
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
167 dropDownWidth: 500,
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
168 autoDropDownHeight: true,
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
169 renderer: function(index, label, value) {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
170 var datarecord = productlist.records[index];
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
171 return datarecord.code + ' - ' + datarecord.name;
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
172 }
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
173 });
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
174
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
175 $('#gaugeContainer_temperature').jqxGauge(gaugeoptionst);
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
176 $('#gaugeContainer_temperature').jqxGauge({ caption: { value: 'Temp: 00.000' }});
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
177 $('#gaugeContainer_pressure').jqxGauge(gaugeoptionsp);
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
178 $('#gaugeContainer_pressure').jqxGauge({ caption: { value: 'Bar: 00.000' }});
503
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179
678
14322825cb3d The co2meters monitor screen rebuild to use websockets instead of data polling.
Michiel Broek <mbroek@mbse.eu>
parents: 526
diff changeset
180 // Get the data
526
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
181 dataAdapter.dataBind();
503
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182
526
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
183 $('#select_beer').on('select', function(event) {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
184 if (event.args) {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
185 var index = event.args.index,
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
186 datarecord = productlist.records[index];
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
187 record.beercode = datarecord.code;
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
188 record.beername = datarecord.name;
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
189 record.beeruuid = datarecord.uuid;
678
14322825cb3d The co2meters monitor screen rebuild to use websockets instead of data polling.
Michiel Broek <mbroek@mbse.eu>
parents: 526
diff changeset
190 console.log('Select beer ' + record.beercode + ', ' + record.beername);
680
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
191 websocket.send('{"device":"co2meters","node":"' + record.node + '","unit":"' + record.alias +
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
192 '","beeruuid":"' + record.beeruuid + '","beercode":"' + record.beercode + '","beername":"' + record.beername + '"}');
526
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
193 }
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
194 });
503
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
195
526
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
196 // The chart button.
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
197 $('#FLog').jqxButton({ template: 'primary', width: '150px', theme: theme });
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
198 $('#FLog').click(function() {
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
199 window.open('log_co2pressure.php?code=' + record.beercode + '&name=' + record.beername);
2991acd35cdb Code cleanup and compress.
Michiel Broek <mbroek@mbse.eu>
parents: 507
diff changeset
200 });
678
14322825cb3d The co2meters monitor screen rebuild to use websockets instead of data polling.
Michiel Broek <mbroek@mbse.eu>
parents: 526
diff changeset
201
14322825cb3d The co2meters monitor screen rebuild to use websockets instead of data polling.
Michiel Broek <mbroek@mbse.eu>
parents: 526
diff changeset
202 websocket.onmessage = function(evt) {
14322825cb3d The co2meters monitor screen rebuild to use websockets instead of data polling.
Michiel Broek <mbroek@mbse.eu>
parents: 526
diff changeset
203 var msg = evt.data;
14322825cb3d The co2meters monitor screen rebuild to use websockets instead of data polling.
Michiel Broek <mbroek@mbse.eu>
parents: 526
diff changeset
204 var obj = JSON.parse(msg);
14322825cb3d The co2meters monitor screen rebuild to use websockets instead of data polling.
Michiel Broek <mbroek@mbse.eu>
parents: 526
diff changeset
205 if (obj.device == "co2meters" && obj.node == record.node && obj.unit == record.alias) {
14322825cb3d The co2meters monitor screen rebuild to use websockets instead of data polling.
Michiel Broek <mbroek@mbse.eu>
parents: 526
diff changeset
206 console.log('ws got this device ' + msg);
680
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
207 record.online = obj.online;
678
14322825cb3d The co2meters monitor screen rebuild to use websockets instead of data polling.
Michiel Broek <mbroek@mbse.eu>
parents: 526
diff changeset
208 if (obj.online) {
680
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
209 record.beeruuid = obj.beeruuid;
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
210 record.beercode = obj.beercode;
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
211 record.beername = obj.beername;
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
212 record.mode = obj.mode;
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
213 record.alarm = obj.alarm;
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
214 record.temperature_state = obj.temperature_state;
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
215 record.temperature_address = obj.temperature_address;
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
216 record.temperature = obj.temperature;
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
217 record.pressure_state = obj.pressure_state;
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
218 record.pressure_channel = obj.pressure_channel;
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
219 record.pressure_voltage = obj.pressure_voltage;
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
220 record.pressure_zero = obj.pressure_zero;
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
221 record.pressure_bar = obj.pressure_bar;
678
14322825cb3d The co2meters monitor screen rebuild to use websockets instead of data polling.
Michiel Broek <mbroek@mbse.eu>
parents: 526
diff changeset
222 }
680
0bb48333d133 Fixed missing co2meters websocket data. Added websockets and removed polling for the mon-ispindel screen. The iSpindel SG gauge adjusts the resolution to the highest detected OG.
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
223 updateScreen();
678
14322825cb3d The co2meters monitor screen rebuild to use websockets instead of data polling.
Michiel Broek <mbroek@mbse.eu>
parents: 526
diff changeset
224 }
14322825cb3d The co2meters monitor screen rebuild to use websockets instead of data polling.
Michiel Broek <mbroek@mbse.eu>
parents: 526
diff changeset
225 }
503
b23ef14c6b09 Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
226 });

mercurial