Tue, 19 May 2020 13:50:14 +0200
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.
507
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /***************************************************************************** |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * Copyright (C) 2019 |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * Michiel Broek <mbroek at mbse dot eu> |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * This file is part of BMS |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * This is free software; you can redistribute it and/or modify it |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * under the terms of the GNU General Public License as published by the |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * Free Software Foundation; either version 2, or (at your option) any |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * later version. |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * Brewery Managment System is distributed in the hope that it will be useful, |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * General Public License for more details. |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | * along with ThermFerm; see the file COPYING. If not, write to the Free |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | *****************************************************************************/ |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | |
527
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
24 | $(document).ready(function() { |
507
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | |
527
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
26 | $('#jqxMenu').jqxMenu('destroy'); |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
27 | $('#jqxLoader').jqxLoader({ |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
28 | width: 250, |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
29 | height: 150, |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
30 | isModal: true, |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
31 | text: 'Opmaken grafiek ...', |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
32 | theme: theme |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
33 | }); |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
34 | $('#jqxLoader').jqxLoader('open'); |
507
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
35 | |
527
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
36 | function getExportServer() { |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
37 | return 'https://www.jqwidgets.com/export_server/export.php'; |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
38 | } |
507
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
39 | |
527
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
40 | var sourceA = { |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
41 | datatype: 'json', |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
42 | datafields: [ |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
43 | { name: 'date', type: 'date', format: 'yyyy-MM-dd HH:mm' }, |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
44 | { name: 'temperature', type: 'float' }, |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
45 | { name: 'pressure', type: 'float' }, |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
46 | { name: 'uuid', type: 'string' } |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
47 | ], |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
48 | url: 'getco2pressurelog.php?code=' + my_code + '&name=' + my_name |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
49 | }, |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
50 | dataAdapter = new $.jqx.dataAdapter(sourceA, { |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
51 | autoBind: true, |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
52 | async: false, |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
53 | loadComplete: function() { |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
54 | $('#jqxLoader').jqxLoader('close'); |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
55 | }, |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
56 | loadError: function(jqXHR, status, error) { |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
57 | } |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
58 | }), |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
59 | settings = { |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
60 | title: my_code + ' "' + my_name + '"', |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
61 | description: '', |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
62 | source: dataAdapter, |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
63 | xAxis: { |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
64 | dataField: 'date', |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
65 | type: 'date', |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
66 | formatFunction: function(value) { |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
67 | return value.getDate() + '-' + (value.getMonth() + 1) + '-' + value.getFullYear(); |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
68 | }, |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
69 | toolTipFormatFunction: function(value) { |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
70 | var h = value.getHours(), m = value.getMinutes(); |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
71 | return value.getDate() + '-' + (value.getMonth() + 1) + '-' + value.getFullYear() + |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
72 | ' ' + (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m); |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
73 | }, |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
74 | textRotationAngle: 45, |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
75 | howGridLines: false |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
76 | }, |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
77 | colorScheme: 'scheme01', |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
78 | seriesGroups: [ |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
79 | { |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
80 | type: 'area', |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
81 | valueAxis: { minValue: 0, displayValueAxis: false, description: 'Druk in bar' }, |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
82 | series: [{ dataField: 'pressure', lineWidth: 1, displayText: 'Druk', opacity: 0.4 }] |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
83 | }, |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
84 | { |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
85 | type: 'spline', |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
86 | valueAxis: { minValue: 0, description: 'Graden C' }, |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
87 | series: [{ dataField: 'temperature', lineWidth: 1, displayText: 'Temperatuur' }] |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
88 | } |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
89 | ] |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
90 | }; |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
91 | $('#pressure_chart').jqxChart(settings); |
507
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
92 | |
527
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
93 | $('#print').click(function() { |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
94 | var content = $('#pressure_chart')[0].outerHTML, |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
95 | newWindow = window.open('', '', 'width=865, height=425'), |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
96 | document = newWindow.document.open(), |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
97 | pageContent = |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
98 | '<!DOCTYPE html>' + |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
99 | '<html>' + |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
100 | '<head>' + |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
101 | '<link rel="stylesheet" href="jqwidgets/styles/jqx.base.css" type="text/css" />' + |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
102 | '<meta charset="utf-8" />' + |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
103 | '<title>' + my_code + ' ' + my_name + ' hergisting</title>' + |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
104 | '</head>' + |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
105 | '<body>' + content + '</body></html>'; |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
106 | document.write(pageContent); |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
107 | document.close(); |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
108 | newWindow.print(); |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
109 | }); |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
110 | $('#print').jqxButton({ template: 'primary', width: 125, theme: theme }); |
507
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
111 | |
527
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
112 | $('#pdfButton').click(function() { |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
113 | $('#pressure_chart').jqxChart('saveAsPDF', 'hergisting_' + my_code + '.pdf', getExportServer()); |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
114 | }); |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
115 | $('#pdfButton').jqxButton({ template: 'primary', width: 125, theme: theme }); |
507
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
116 | |
527
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
117 | $('#pngButton').click(function() { |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
118 | $('#pressure_chart').jqxChart('saveAsPNG', 'hergisting_' + my_code + '.png', getExportServer()); |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
119 | }); |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
120 | $('#pngButton').jqxButton({ template: 'primary', width: 125, theme: theme }); |
507
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
121 | |
527
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
122 | $('#Close').jqxButton({ template: 'success', width: 125, theme: theme }); |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
123 | $('#Close').click(function() { |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
124 | window.close(); |
9dfefad3ae1d
Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
125 | }); |
507
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
126 | }); |
17f244137a9b
Add refermentation logfile and graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
127 |