www/js/mon_ispindel.js

Tue, 19 May 2020 13:50:14 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 19 May 2020 13:50:14 +0200
changeset 680
0bb48333d133
parent 655
f4e00869f39f
child 681
7ed5c380e21b
permissions
-rw-r--r--

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.

570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*****************************************************************************
578
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
2 * Copyright (C) 2019-2020
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Michiel Broek <mbroek at mbse dot eu>
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * This file is part of BMS
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 *
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * This is free software; you can redistribute it and/or modify it
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * under the terms of the GNU General Public License as published by the
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * Free Software Foundation; either version 2, or (at your option) any
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * later version.
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 *
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * Brewery Management System istributed in the hope that it will be useful, but
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * General Public License for more details.
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 *
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 * along with ThermFerm; see the file COPYING. If not, write to the Free
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 *****************************************************************************/
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 $(document).ready(function() {
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 var record = {},
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 blank = {},
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 productSource = {
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 datatype: 'json',
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 cache: false,
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 datafields: [
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 { name: 'code', type: 'string' },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 { name: 'name', type: 'string' },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 { name: 'uuid', type: 'string' }
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 ],
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 id: 'code',
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 url: 'includes/db_product.php?select=ferment'
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 productlist = new $.jqx.dataAdapter(productSource, {
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 beforeLoadComplete: function(records) {
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 var row, i, data = new Array();
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 // Create a dummy beer on top to store in idle meters.
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 blank['code'] = 'Free'; // Will override this later.
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 blank['name'] = 'Dummy';
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 blank['uuid'] = '66ecccbf-e942-4a35-af49-8b02314561a5';
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 data.push(blank);
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 for (i = 0; i < records.length; i++) {
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 row = records[i];
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 data.push(row);
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 }
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 return data;
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
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: 655
diff changeset
54 loadError: function(jqXHR, status, error) { console.log(status + ' ' + error); },
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 }),
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 gaugeoptionst = {
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 min: 10, max: 40, width: 375, height: 375,
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 ranges: [{ startValue: 10, endValue: 20, style: { fill: '#3399FF', stroke: '#3399FF' }, endWidth: 10, startWidth: 10 },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 { startValue: 20, endValue: 28, style: { fill: '#00CC33', stroke: '#00CC33' }, endWidth: 10, startWidth: 10 },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 { startValue: 28, endValue: 40, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }, endWidth: 10, startWidth: 10 }],
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 ticksMinor: { interval: 1, size: '5%' },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 ticksMajor: { interval: 5, size: '9%' },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 labels: { interval: 5 },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 style: { fill: '#eeeeee', stroke: '#666666' },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 value: 0,
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 colorScheme: 'scheme05'
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 gaugeoptionsg = {
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 orientation: 'vertical',
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 labels: { position: 'near', interval: 10 },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 ticksMinor: { size: '5%', interval: 2 },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 ticksMajor: { size: '9%', interval: 10 },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 ticksPosition: 'near',
579
1253a237b620 Added check for database changes for iSpindels such as a new beer, or changing mode. Added denity in Plato and SG to the iSpindel web screen. The iSpindels must be calibrated in Plato! A bit of documentation updated.
Michiel Broek <mbroek@mbse.eu>
parents: 578
diff changeset
74 min: 0990, max: 1150, width: 120, height: 375,
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 value: 1000,
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 pointer: { pointerType: 'arrow', size: '15%', visible: true, offset: 0 },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 colorScheme: 'scheme05',
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 showRanges: false
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 },
578
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
80 url = 'getispindel.php?uuid="' + my_uuid + '"',
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 source = {
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 datatype: 'json',
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 datafields: [
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 { name: 'record', type: 'int' },
578
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
85 { name: 'uuid', type: 'string' },
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
86 { name: 'alias', type: 'string' },
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 { name: 'node', type: 'string' },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 { name: 'online', type: 'int' },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 { name: 'beercode', type: 'string' },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 { name: 'beername', type: 'string' },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 { name: 'beeruuid', type: 'string' },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 { name: 'alarm', type: 'int' },
578
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
93 { name: 'angle', type: 'float' },
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 { name: 'temperature', type: 'float' },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 { name: 'battery', type: 'float' },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 { name: 'gravity', type: 'float' },
578
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
97 { name: 'up_interval', type: 'int' },
628
a42166cbb19a Record iSpindel original plato by updating to the highest measured value. Reset this value when a new beer is set. Added current status to the monitor screen.
Michiel Broek <mbroek@mbse.eu>
parents: 596
diff changeset
98 { name: 'mode', type: 'string' },
a42166cbb19a Record iSpindel original plato by updating to the highest measured value. Reset this value when a new beer is set. Added current status to the monitor screen.
Michiel Broek <mbroek@mbse.eu>
parents: 596
diff changeset
99 { name: 'og_gravity', type: 'float' }
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 ],
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 id: 'record',
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 url: url
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 },
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 dataAdapter = new $.jqx.dataAdapter(source, {
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 loadComplete: function(records) {
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 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: 655
diff changeset
107 updateScreen();
578
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
108 blank['name'] = record.alias;
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
109 blank['code'] = record.alias.toUpperCase();
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
110 blank['uuid'] = record.uuid;
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: 655
diff changeset
111 }
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: 655
diff changeset
112 });
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113
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: 655
diff changeset
114 function 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: 655
diff changeset
115
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: 655
diff changeset
116 $('#info_uuid').html(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: 655
diff changeset
117 $('#info_system').html(record.node + '/' + 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: 655
diff changeset
118 $('#info_beer').html(record.beercode + ' - ' + record.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: 655
diff changeset
119 $('#info_mode').jqxDropDownList('selectItem', record.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: 655
diff changeset
120
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: 655
diff changeset
121 if (record.online) {
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: 655
diff changeset
122 $('#info_online').html('On-line');
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: 655
diff changeset
123 if (record.mode != 'OFF') {
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 $('#ispindel_powerled').html('<div class="LEDblue_on"></div>Power');
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 $('#select_beer').jqxDropDownList({ disabled: true });
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 $('#select_beer').jqxDropDownList('clearSelection');
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 $('#select_beer').hide();
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 } else {
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 $('#ispindel_powerled').html('<div class="LEDblue_off"></div>Power');
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 $('#select_beer').show();
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131 $('#select_beer').jqxDropDownList({ disabled: false });
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
132 }
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 if (record.online && (record.alarm != '0')) {
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 $('#ispindel_alarmled').html('<div class="LEDred_on"></div>Alarm');
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 } else {
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 $('#ispindel_alarmled').html('<div class="LEDred_off"></div>Alarm');
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 }
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 $('#gaugeContainer_temperature').jqxGauge({ caption: { value: record.temperature.toFixed(3) + '°C' }});
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140 $('#gaugeContainer_temperature').jqxGauge({ value: record.temperature });
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: 655
diff changeset
141 $('#gaugeContainer_temperature').jqxGauge({ disabled: false });
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: 655
diff changeset
142 $('#gaugeContainer_gravity').jqxLinearGauge({ disabled: false });
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143
628
a42166cbb19a Record iSpindel original plato by updating to the highest measured value. Reset this value when a new beer is set. Added current status to the monitor screen.
Michiel Broek <mbroek@mbse.eu>
parents: 596
diff changeset
144 var sg = plato_to_sg(record.gravity);
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 $('#info_battery').val(record.battery);
578
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
146 $('#info_tilt').val(record.angle);
579
1253a237b620 Added check for database changes for iSpindels such as a new beer, or changing mode. Added denity in Plato and SG to the iSpindel web screen. The iSpindels must be calibrated in Plato! A bit of documentation updated.
Michiel Broek <mbroek@mbse.eu>
parents: 578
diff changeset
147 $('#info_plato').val(record.gravity);
628
a42166cbb19a Record iSpindel original plato by updating to the highest measured value. Reset this value when a new beer is set. Added current status to the monitor screen.
Michiel Broek <mbroek@mbse.eu>
parents: 596
diff changeset
148 $('#info_sg').val(sg);
a42166cbb19a Record iSpindel original plato by updating to the highest measured value. Reset this value when a new beer is set. Added current status to the monitor screen.
Michiel Broek <mbroek@mbse.eu>
parents: 596
diff changeset
149
629
92afe6b59610 Division by zero protection
Michiel Broek <mbroek@mbse.eu>
parents: 628
diff changeset
150 if (record.og_gravity) {
92afe6b59610 Division by zero protection
Michiel Broek <mbroek@mbse.eu>
parents: 628
diff changeset
151 var og = plato_to_sg(record.og_gravity);
655
f4e00869f39f Calculate the svg using Brew by the Numbers, Micahel L. Hall.
Michiel Broek <mbroek@mbse.eu>
parents: 645
diff changeset
152 var svg = calc_svg(og, sg);
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: 655
diff changeset
153 var max = Math.ceil(og * 100, 0) * 10;
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154
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: 655
diff changeset
155 console.log ('set max ' + max);
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: 655
diff changeset
156 $('#gaugeContainer_gravity').jqxLinearGauge({ max: max });
629
92afe6b59610 Division by zero protection
Michiel Broek <mbroek@mbse.eu>
parents: 628
diff changeset
157 $('#vg_og1').html(og.toFixed(4));
92afe6b59610 Division by zero protection
Michiel Broek <mbroek@mbse.eu>
parents: 628
diff changeset
158 $('#vg_og2').html(record.og_gravity.toFixed(1) + '&deg;P');
92afe6b59610 Division by zero protection
Michiel Broek <mbroek@mbse.eu>
parents: 628
diff changeset
159 $('#vg_sg1').html(sg.toFixed(4));
92afe6b59610 Division by zero protection
Michiel Broek <mbroek@mbse.eu>
parents: 628
diff changeset
160 $('#vg_sg2').html(record.gravity.toFixed(1) + '&deg;P');
631
450ac489bbe7 Added battery status percentage.
Michiel Broek <mbroek@mbse.eu>
parents: 629
diff changeset
161 $('#vg_svg').html(svg.toFixed(1) + '%');
629
92afe6b59610 Division by zero protection
Michiel Broek <mbroek@mbse.eu>
parents: 628
diff changeset
162 $('#vg_abv').html(abvol(og, sg).toFixed(2) + '%');
92afe6b59610 Division by zero protection
Michiel Broek <mbroek@mbse.eu>
parents: 628
diff changeset
163 } else {
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: 655
diff changeset
164 $('#gaugeContainer_gravity').jqxLinearGauge({ max: 1150 });
629
92afe6b59610 Division by zero protection
Michiel Broek <mbroek@mbse.eu>
parents: 628
diff changeset
165 $('#vg_og1').html('');
92afe6b59610 Division by zero protection
Michiel Broek <mbroek@mbse.eu>
parents: 628
diff changeset
166 $('#vg_og2').html('');
92afe6b59610 Division by zero protection
Michiel Broek <mbroek@mbse.eu>
parents: 628
diff changeset
167 $('#vg_sg1').html('');
92afe6b59610 Division by zero protection
Michiel Broek <mbroek@mbse.eu>
parents: 628
diff changeset
168 $('#vg_sg2').html('');
92afe6b59610 Division by zero protection
Michiel Broek <mbroek@mbse.eu>
parents: 628
diff changeset
169 $('#vg_svg').html('');
92afe6b59610 Division by zero protection
Michiel Broek <mbroek@mbse.eu>
parents: 628
diff changeset
170 $('#vg_abv').html('');
92afe6b59610 Division by zero protection
Michiel Broek <mbroek@mbse.eu>
parents: 628
diff changeset
171 }
92afe6b59610 Division by zero protection
Michiel Broek <mbroek@mbse.eu>
parents: 628
diff changeset
172
631
450ac489bbe7 Added battery status percentage.
Michiel Broek <mbroek@mbse.eu>
parents: 629
diff changeset
173 var batt = record.battery - 3.064; // 0% voltage.
450ac489bbe7 Added battery status percentage.
Michiel Broek <mbroek@mbse.eu>
parents: 629
diff changeset
174 if (batt < 0)
450ac489bbe7 Added battery status percentage.
Michiel Broek <mbroek@mbse.eu>
parents: 629
diff changeset
175 batt = 0;
450ac489bbe7 Added battery status percentage.
Michiel Broek <mbroek@mbse.eu>
parents: 629
diff changeset
176 batt = Math.round(batt / 1.17875 * 100); // 100% range
632
8a2f2e76c727 Fix battery level above 100%
Michiel Broek <mbroek@mbse.eu>
parents: 631
diff changeset
177 if (batt > 100)
8a2f2e76c727 Fix battery level above 100%
Michiel Broek <mbroek@mbse.eu>
parents: 631
diff changeset
178 batt = 100;
631
450ac489bbe7 Added battery status percentage.
Michiel Broek <mbroek@mbse.eu>
parents: 629
diff changeset
179 $('#vg_batt').html(batt + '%');
450ac489bbe7 Added battery status percentage.
Michiel Broek <mbroek@mbse.eu>
parents: 629
diff changeset
180
629
92afe6b59610 Division by zero protection
Michiel Broek <mbroek@mbse.eu>
parents: 628
diff changeset
181 var gravity = sg * 1000;
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 $('#gaugeContainer_gravity').jqxLinearGauge({ value: gravity });
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: 655
diff changeset
183
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: 655
diff changeset
184 } else { // offline
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: 655
diff changeset
185 $('#info_online').html('Off-line');
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: 655
diff changeset
186 $('#ispindel_powerled').html('<div class="LEDblue_off"></div>Power');
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: 655
diff changeset
187 $('#select_beer').show();
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: 655
diff changeset
188 $('#select_beer').jqxDropDownList({ disabled: false });
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: 655
diff changeset
189 $('#ispindel_alarmled').html('<div class="LEDred_on"></div>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: 655
diff changeset
190 $('#gaugeContainer_temperature').jqxGauge({ disabled: true });
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: 655
diff changeset
191 $('#gaugeContainer_gravity').jqxLinearGauge({ disabled: true });
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
192 }
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: 655
diff changeset
193 }
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
194
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
195 $('#select_beer').jqxDropDownList({
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
196 placeHolder: 'Kies bier:',
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 theme: theme,
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198 source: productlist,
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199 displayMember: 'code',
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 width: 150,
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201 height: 24,
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202 dropDownWidth: 500,
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
203 autoDropDownHeight: true,
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
204 renderer: function(index, label, value) {
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 var datarecord = productlist.records[index];
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206 return datarecord.code + ' - ' + datarecord.name;
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207 }
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208 });
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209
596
2270a73628b5 iSpindel battery voltage shows 3 decimals.
Michiel Broek <mbroek@mbse.eu>
parents: 593
diff changeset
210 $('#info_battery').jqxNumberInput(Show3dec);
587
31caffee8c9c Changed several float precision values. Changed some database fields to double. Everything has now the same precision as received values from the iSpindel.
Michiel Broek <mbroek@mbse.eu>
parents: 580
diff changeset
211 $('#info_tilt').jqxNumberInput(Show5dec);
31caffee8c9c Changed several float precision values. Changed some database fields to double. Everything has now the same precision as received values from the iSpindel.
Michiel Broek <mbroek@mbse.eu>
parents: 580
diff changeset
212 $('#info_plato').jqxNumberInput(Show2dec);
579
1253a237b620 Added check for database changes for iSpindels such as a new beer, or changing mode. Added denity in Plato and SG to the iSpindel web screen. The iSpindels must be calibrated in Plato! A bit of documentation updated.
Michiel Broek <mbroek@mbse.eu>
parents: 578
diff changeset
213 $('#info_sg').jqxNumberInput(Show4dec);
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215 $('#gaugeContainer_temperature').jqxGauge(gaugeoptionst);
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: 655
diff changeset
216 $('#gaugeContainer_temperature').jqxGauge({ caption: { value: '0.000°C' }});
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 $('#gaugeContainer_gravity').jqxLinearGauge(gaugeoptionsg);
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218
578
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
219 srcMode = ['OFF', 'ON'];
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
220 $('#info_mode').jqxDropDownList({ theme: theme, source: srcMode, width: 100, height: 24, dropDownHeight: 65 });
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
221
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: 655
diff changeset
222 // Get the data immediatly.
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223 dataAdapter.dataBind();
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
224
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
225 $('#select_beer').on('select', function(event) {
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
226 if (event.args) {
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
227 var index = event.args.index,
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228 datarecord = productlist.records[index];
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
229 record.beercode = datarecord.code;
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
230 record.beername = datarecord.name;
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
231 record.beeruuid = datarecord.uuid;
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: 655
diff changeset
232 console.log('Select beer ' + record.beercode + ', ' + record.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: 655
diff changeset
233 websocket.send('{"device":"ispindels","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: 655
diff changeset
234 '","beeruuid":"' + record.beeruuid + '","beercode":"' + record.beercode + '","beername":"' + record.beername + '"}');
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
235 }
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
236 });
645
3b1510050c9b Changed the last dropdown lists events to select
Michiel Broek <mbroek@mbse.eu>
parents: 632
diff changeset
237 $('#info_mode').on('select', function(event) {
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: 655
diff changeset
238 if (event.args && event.args.item.value != record.mode) {
593
e0230bf4ac3f Less logging noise.
Michiel Broek <mbroek@mbse.eu>
parents: 587
diff changeset
239 record.mode = event.args.item.value;
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: 655
diff changeset
240 console.log('set mode ' + record.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: 655
diff changeset
241 websocket.send('{"device":"ispindels","node":"' + record.node + '","unit":"' + record.alias + '","mode":"' + record.mode + '"}');
578
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
242 }
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
243 });
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
244
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
245 // The chart button.
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
246 $('#VLog').jqxButton({ template: 'primary', width: '150px', theme: theme });
580
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents: 579
diff changeset
247 $('#VLog').click(function() {
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents: 579
diff changeset
248 window.open('log_ispindel.php?code=' + record.beercode + '&name=' + record.beername);
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents: 579
diff changeset
249 });
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: 655
diff changeset
250
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: 655
diff changeset
251 websocket.onmessage = function(evt) {
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: 655
diff changeset
252 var msg = evt.data;
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: 655
diff changeset
253 var obj = JSON.parse(msg);
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: 655
diff changeset
254 if (obj.device == "ispindels" && obj.node == record.node) {
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: 655
diff changeset
255 console.log('ws got this device ' + msg);
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: 655
diff changeset
256 record.online = obj.online;
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: 655
diff changeset
257 if (obj.online) {
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: 655
diff changeset
258 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: 655
diff changeset
259 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: 655
diff changeset
260 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: 655
diff changeset
261 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: 655
diff changeset
262 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: 655
diff changeset
263 record.angle = obj.angle;
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: 655
diff changeset
264 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: 655
diff changeset
265 record.battery = obj.battery;
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: 655
diff changeset
266 record.gravity = obj.gravity;
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: 655
diff changeset
267 record.up_interval = obj.up_interval;
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: 655
diff changeset
268 record.og_gravity = obj.og_gravity;
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: 655
diff changeset
269 }
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: 655
diff changeset
270 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: 655
diff changeset
271 }
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: 655
diff changeset
272 ws_global(msg);
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: 655
diff changeset
273 }
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
274 });

mercurial