Fri, 01 May 2020 21:37:23 +0200
In export to forum, suppress diluted water is the name is set but the volume is 0. Add the treated water profile to the output.
503
b23ef14c6b09
Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /***************************************************************************** |
b23ef14c6b09
Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * Copyright (C) 2019 |
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. |
b23ef14c6b09
Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | *****************************************************************************/ |
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 | 24 | $(document).ready(function() { |
503
b23ef14c6b09
Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | |
526 | 26 | var record = {}, |
27 | blank = {}, | |
28 | newProduct = false, | |
29 | schedule = 0, | |
503
b23ef14c6b09
Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
30 | |
526 | 31 | productSource = { |
32 | datatype: 'json', | |
33 | cache: false, | |
34 | datafields: [ | |
35 | { name: 'code', type: 'string' }, | |
36 | { name: 'name', type: 'string' }, | |
37 | { name: 'uuid', type: 'string' } | |
38 | ], | |
39 | id: 'code', | |
40 | url: 'includes/db_product.php?select=ferment' | |
41 | }, | |
42 | productlist = new $.jqx.dataAdapter(productSource, { | |
43 | beforeLoadComplete: function(records) { | |
44 | var row, i, data = new Array(); | |
45 | // Create a dummy beer on top to store in idle meters. | |
46 | blank['code'] = 'Free'; // Will override this later. | |
47 | blank['name'] = 'Dummy'; | |
48 | blank['uuid'] = '66ecccbf-e942-4a35-af49-8b02314561a5'; | |
49 | data.push(blank); | |
50 | for (i = 0; i < records.length; i++) { | |
51 | row = records[i]; | |
52 | data.push(row); | |
53 | } | |
54 | return data; | |
55 | }, | |
56 | loadError: function(jqXHR, status, error) { | |
57 | $('#err').text(status + ' ' + error); | |
58 | }, | |
59 | }), | |
60 | gaugeoptionst = { | |
61 | min: 10, max: 40, width: 375, height: 375, | |
62 | ranges: [{ startValue: 10, endValue: 20, style: { fill: '#3399FF', stroke: '#3399FF' }, endWidth: 10, startWidth: 10 }, | |
63 | { startValue: 20, endValue: 28, style: { fill: '#00CC33', stroke: '#00CC33' }, endWidth: 10, startWidth: 10 }, | |
64 | { startValue: 28, endValue: 40, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }, endWidth: 10, startWidth: 10 }], | |
65 | ticksMinor: { interval: 1, size: '5%' }, | |
66 | ticksMajor: { interval: 5, size: '9%' }, | |
67 | labels: { interval: 5 }, | |
68 | style: { fill: '#eeeeee', stroke: '#666666' }, | |
69 | value: 0, | |
70 | colorScheme: 'scheme05' | |
71 | }, | |
72 | gaugeoptionsp = { | |
73 | min: 0, max: 6, width: 375, height: 375, | |
74 | ranges: [{ startValue: 0, endValue: 3, style: { fill: '#00CC33', stroke: '#00CC33' }, endWidth: 10, startWidth: 10 }, | |
75 | { startValue: 3, endValue: 6, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }, endWidth: 10, startWidth: 10 }], | |
76 | ticksMinor: { interval: 0.2, size: '5%' }, | |
77 | ticksMajor: { interval: 1, size: '9%' }, | |
78 | labels: { interval: 1 }, | |
79 | style: { fill: '#eeeeee', stroke: '#666666' }, | |
80 | value: 0, | |
81 | colorScheme: 'scheme05' | |
82 | }, | |
83 | url = 'getco2meter.php?uuid="' + my_uuid + '"', | |
84 | source = { | |
85 | datatype: 'json', | |
86 | datafields: [ | |
87 | { name: 'record', type: 'int' }, | |
88 | { name: 'uuid', type: 'string' }, | |
89 | { name: 'alias', type: 'string' }, | |
90 | { name: 'node', type: 'string' }, | |
91 | { name: 'online', type: 'int' }, | |
92 | { name: 'beercode', type: 'string' }, | |
93 | { name: 'beername', type: 'string' }, | |
94 | { name: 'beeruuid', type: 'string' }, | |
95 | { name: 'mode', type: 'string' }, | |
96 | { name: 'alarm', type: 'int' }, | |
97 | { name: 'temperature_state', type: 'string' }, | |
98 | { name: 'temperature', type: 'float' }, | |
99 | { name: 'pressure_state', type: 'string' }, | |
100 | { name: 'pressure_bar', type: 'float' } | |
101 | ], | |
102 | id: 'record', | |
103 | url: url | |
104 | }, | |
105 | dataAdapter = new $.jqx.dataAdapter(source, { | |
106 | loadComplete: function(records) { | |
107 | record = dataAdapter.records[0]; | |
108 | var oline = (record.online) ? 'On-line' : 'Off-line'; | |
109 | $('#info_uuid').html(record.uuid); | |
110 | $('#info_system').html(record.node + '/' + record.alias); | |
111 | $('#info_online').html(oline); | |
112 | $('#info_beer').html(record.beercode + ' - ' + record.beername); | |
113 | $('#info_mode').html(record.mode); | |
114 | blank['name'] = record.alias; | |
115 | blank['code'] = record.alias.toUpperCase(); | |
116 | blank['uuid'] = record.uuid; | |
503
b23ef14c6b09
Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
117 | |
526 | 118 | if (record.online && (record.mode != 'OFF')) { |
119 | $('#co2meter_powerled').html('<div class="LEDblue_on"></div>Power'); | |
120 | $('#select_beer').jqxDropDownList({ disabled: true }); | |
121 | $('#select_beer').jqxDropDownList('clearSelection'); | |
122 | $('#select_beer').hide(); | |
123 | } else { | |
124 | $('#co2meter_powerled').html('<div class="LEDblue_off"></div>Power'); | |
125 | $('#select_beer').show(); | |
126 | $('#select_beer').jqxDropDownList({ disabled: false }); | |
127 | } | |
128 | if (record.online && (record.alarm != '0')) { | |
129 | $('#co2meter_alarmled').html('<div class="LEDred_on"></div>Alarm'); | |
130 | } else { | |
131 | $('#co2meter_alarmled').html('<div class="LEDred_off"></div>Alarm'); | |
132 | } | |
503
b23ef14c6b09
Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
133 | |
526 | 134 | $('#gaugeContainer_temperature').jqxGauge({ caption: { value: 'Temp: ' + record.temperature.toFixed(3) }}); |
135 | $('#gaugeContainer_temperature').jqxGauge({ value: record.temperature }); | |
136 | if (record.temperature_state == 'OK') { | |
137 | $('#gaugeContainer_temperature').jqxGauge({ disabled: false }); | |
138 | } else { | |
139 | $('#gaugeContainer_temperature').jqxGauge({ disabled: true }); | |
140 | } | |
141 | $('#gaugeContainer_pressure').jqxGauge({ caption: { value: 'Bar: ' + record.pressure_bar.toFixed(2) }}); | |
142 | $('#gaugeContainer_pressure').jqxGauge({ value: record.pressure_bar }); | |
143 | if (record.pressure_state == 'OK') { | |
144 | $('#gaugeContainer_pressure').jqxGauge({ disabled: false }); | |
145 | } else { | |
146 | $('#gaugeContainer_pressure').jqxGauge({ disabled: true }); | |
147 | } | |
148 | } | |
149 | }); | |
503
b23ef14c6b09
Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
150 | |
526 | 151 | $('#select_beer').jqxDropDownList({ |
152 | placeHolder: 'Kies bier:', | |
153 | theme: theme, | |
154 | source: productlist, | |
155 | displayMember: 'code', | |
156 | width: 150, | |
157 | height: 24, | |
158 | dropDownWidth: 500, | |
159 | autoDropDownHeight: true, | |
160 | renderer: function(index, label, value) { | |
161 | var datarecord = productlist.records[index]; | |
162 | return datarecord.code + ' - ' + datarecord.name; | |
163 | } | |
164 | }); | |
165 | ||
166 | $('#gaugeContainer_temperature').jqxGauge(gaugeoptionst); | |
167 | $('#gaugeContainer_temperature').jqxGauge({ caption: { value: 'Temp: 00.000' }}); | |
168 | $('#gaugeContainer_pressure').jqxGauge(gaugeoptionsp); | |
169 | $('#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
|
170 | |
526 | 171 | function sendProduct(code, name, uuid) { |
503
b23ef14c6b09
Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
172 | |
526 | 173 | console.log('sendProduct(' + code + ', ' + name + ', ' + uuid + ')'); |
174 | var data = 'uuid=' + record.uuid + '&beeruuid=' + uuid + '&beercode=' + code + '&beername=' + name; | |
175 | $.ajax({ | |
176 | url: 'cmd_co2meter.php', | |
177 | data: data, | |
178 | type: 'POST', | |
179 | success: function(data) {}, | |
180 | error: function(jqXHR, textStatus, errorThrown) { console.log('sendProduct() error'); } | |
181 | }); | |
182 | } | |
503
b23ef14c6b09
Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
183 | |
526 | 184 | // Get the data immediatly and then at regular intervals to refresh. |
185 | dataAdapter.dataBind(); | |
186 | setInterval(function() { | |
187 | var skip = false; | |
188 | if (newProduct) { | |
189 | sendProduct(record.beercode, record.beername, record.beeruuid); | |
190 | newProduct = false; | |
191 | skip = true; | |
192 | } | |
193 | if (skip) { | |
194 | schedule = 4; // 2 seconds wait to get the results | |
195 | } else { | |
196 | if (schedule > 0) | |
197 | schedule--; | |
198 | } | |
503
b23ef14c6b09
Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
199 | |
526 | 200 | if (schedule <= 0) { |
201 | dataAdapter.dataBind(); | |
202 | schedule = 20; | |
203 | } | |
204 | }, 500); | |
503
b23ef14c6b09
Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
205 | |
526 | 206 | $('#select_beer').on('select', function(event) { |
207 | if (event.args) { | |
208 | var index = event.args.index, | |
209 | datarecord = productlist.records[index]; | |
210 | record.beercode = datarecord.code; | |
211 | record.beername = datarecord.name; | |
212 | record.beeruuid = datarecord.uuid; | |
213 | newProduct = true; | |
214 | } | |
215 | }); | |
503
b23ef14c6b09
Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
216 | |
526 | 217 | // The chart button. |
218 | $('#FLog').jqxButton({ template: 'primary', width: '150px', theme: theme }); | |
219 | $('#FLog').click(function() { | |
220 | window.open('log_co2pressure.php?code=' + record.beercode + '&name=' + record.beername); | |
221 | }); | |
503
b23ef14c6b09
Web pages for the CO2 meters added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
222 | }); |