Wed, 30 Jul 2014 15:26:29 +0200
Improved dashboard panel style, added (ugly) led's
100 | 1 | <?php |
2 | /***************************************************************************** | |
3 | * Copyright (C) 2014 | |
4 | * | |
5 | * Michiel Broek <mbroek at mbse dot eu> | |
6 | * | |
7 | * This file is part of ThermFerm | |
8 | * | |
9 | * This is free software; you can redistribute it and/or modify it | |
10 | * under the terms of the GNU General Public License as published by the | |
11 | * Free Software Foundation; either version 2, or (at your option) any | |
12 | * later version. | |
13 | * | |
14 | * ThermFerm is distributed in the hope that it will be useful, but | |
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | * General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with ThermFerm; see the file COPYING. If not, write to the Free | |
21 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
22 | *****************************************************************************/ | |
23 | ||
24 | ||
25 | require_once('utilities.php'); | |
26 | ||
27 | ||
28 | ||
113
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
29 | function showunit($unit, $unr) |
100 | 30 | { |
117 | 31 | global $my_style; |
32 | ||
100 | 33 | $outstr = ''; |
102
e37b9c571a56
Units can display the temperature
Michiel Broek <mbroek@mbse.eu>
parents:
100
diff
changeset
|
34 | $air_state = $beer_state = 1; |
100 | 35 | |
36 | $sock = open_socket(); | |
37 | if ($sock == false) { | |
38 | return ''; | |
39 | } | |
40 | ||
41 | socket_write($sock, "UNIT " . $unit, 4096); | |
42 | $answer = ""; | |
43 | while (1) { | |
44 | $line = socket_read($sock, 4096); | |
45 | if ($line === '') | |
46 | break; | |
47 | $answer .= $line; | |
48 | } | |
49 | socket_close($sock); | |
50 | ||
51 | $sock = open_socket(); | |
52 | if ($sock == false) { | |
53 | return ''; | |
54 | } | |
55 | ||
56 | socket_write($sock, "LIST UNIT", 4096); | |
57 | $answer = ""; | |
58 | while (1) { | |
59 | $line = socket_read($sock, 4096); | |
60 | if ($line === '') | |
61 | break; | |
62 | $answer .= $line; | |
63 | } | |
64 | socket_close($sock); | |
65 | $arr = explode("\r\n", $answer); | |
66 | ||
67 | if (startsWith($arr[0], "213")) { | |
68 | ||
117 | 69 | $outstr .= ' <script type="text/javascript">'.PHP_EOL; |
70 | $outstr .= ' $(document).ready(function () {'.PHP_EOL; | |
121
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
71 | |
123
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
72 | $outstr .= ' var source'.$unr.' ='.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
73 | $outstr .= ' {'.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
74 | $outstr .= ' datatype: "json",'.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
75 | $outstr .= ' datafields: ['.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
76 | $outstr .= ' { name: \'Date\' },'.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
77 | $outstr .= ' { name: \'Mode\' },'.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
78 | $outstr .= ' { name: \'Air\', type: \'float\' },'.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
79 | $outstr .= ' { name: \'Beer\', type: \'float\' },'.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
80 | $outstr .= ' { name: \'Target\', type: \'float\' },'.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
81 | $outstr .= ' { name: \'Heater\' },'.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
82 | $outstr .= ' { name: \'Cooler\' },'.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
83 | $outstr .= ' { name: \'Fan\' },'.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
84 | $outstr .= ' { name: \'Door\' }'.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
85 | $outstr .= ' ],'.PHP_EOL; |
124
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
123
diff
changeset
|
86 | $outstr .= ' url: \'getlog.php?unit='.$unit.'\''.PHP_EOL; |
123
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
87 | $outstr .= ' };'.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
88 | |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
89 | $outstr .= ' var dataAdapter'.$unr.' = new $.jqx.dataAdapter(source'.$unr.','.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
90 | $outstr .= ' {'.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
91 | $outstr .= ' autoBind: true,'.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
92 | $outstr .= ' async: false,'.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
93 | $outstr .= ' downloadComplete: function () { },'.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
94 | $outstr .= ' loadComplete: function () { },'.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
95 | $outstr .= ' loadError: function () { }'.PHP_EOL; |
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
96 | $outstr .= ' });'.PHP_EOL; |
121
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
97 | |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
98 | $outstr .= ' var settings'.$unr.' = {'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
99 | $outstr .= ' title: "Fermentation temperature '.$unr.'",'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
100 | $outstr .= ' description: "",'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
101 | $outstr .= ' padding: { left: 5, top: 5, right: 5, bottom: 5 },'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
102 | $outstr .= ' titlePadding: { left: 90, top: 0, right: 0, bottom: 10 },'.PHP_EOL; |
123
597688feda2f
Now uses the real data for the chart
Michiel Broek <mbroek@mbse.eu>
parents:
122
diff
changeset
|
103 | $outstr .= ' source: dataAdapter'.$unr.','.PHP_EOL; |
121
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
104 | $outstr .= ' categoryAxis:'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
105 | $outstr .= ' {'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
106 | $outstr .= ' dataField: \'Date\','.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
107 | $outstr .= ' textRotationAngle: 45,'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
108 | $outstr .= ' showGridLines: false'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
109 | $outstr .= ' },'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
110 | $outstr .= ' colorScheme: \'scheme01\','.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
111 | $outstr .= ' seriesGroups:'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
112 | $outstr .= ' [{'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
113 | $outstr .= ' type: \'line\','.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
114 | $outstr .= ' columnsGapPercent: 30,'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
115 | $outstr .= ' seriesGapPercent: 0,'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
116 | $outstr .= ' valueAxis:'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
117 | $outstr .= ' {'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
118 | $outstr .= ' description: \'Degrees C\''.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
119 | $outstr .= ' },'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
120 | $outstr .= ' series: ['.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
121 | $outstr .= ' { dataField: \'Air\', displayText: \'Air\' },'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
122 | $outstr .= ' { dataField: \'Beer\', displayText: \'Beer\' }'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
123 | $outstr .= ' ]'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
124 | $outstr .= ' }]'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
125 | $outstr .= ' };'.PHP_EOL; |
03306c3bfd60
Initial setup to draw charts
Michiel Broek <mbroek@mbse.eu>
parents:
118
diff
changeset
|
126 | $outstr .= ' $("#fermentor_chart_'.$unr.'").jqxChart(settings'.$unr.');'.PHP_EOL; |
117 | 127 | $outstr .= ' });'.PHP_EOL; |
128 | $outstr .= ' </script>'.PHP_EOL; | |
100 | 129 | $outstr .= ' <div id="fermentor">'.PHP_EOL; |
122
e57043423e72
Added fermentor maintenance windows
Michiel Broek <mbroek@mbse.eu>
parents:
121
diff
changeset
|
130 | $outstr .= ' <div id="fermentor_chart_'.$unr.'" style="width:720px; height:377px; float:left"></div>'.PHP_EOL; |
100 | 131 | |
115 | 132 | $set_temperature = "N/A"; |
133 | $air_temperature = "N/A"; | |
134 | $beer_temperature = "N/A"; | |
151
ab90da2da45d
Improved dashboard panel style, added (ugly) led's
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
135 | $power_led = $cooler_led = $heater_led = $fan_led = "off"; |
115 | 136 | |
100 | 137 | foreach($arr as $l) { |
138 | $vals = explode(",", $l); | |
139 | if (strcmp($vals[0], "MODE") == 0) { | |
113
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
140 | $mode = $vals[1]; |
151
ab90da2da45d
Improved dashboard panel style, added (ugly) led's
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
141 | if (strcmp($mode, "OFF")) |
ab90da2da45d
Improved dashboard panel style, added (ugly) led's
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
142 | $power_led = "on"; |
100 | 143 | } |
102
e37b9c571a56
Units can display the temperature
Michiel Broek <mbroek@mbse.eu>
parents:
100
diff
changeset
|
144 | if (strcmp($vals[0], "AIR_STATE") == 0) { |
e37b9c571a56
Units can display the temperature
Michiel Broek <mbroek@mbse.eu>
parents:
100
diff
changeset
|
145 | $air_state = $vals[1]; |
e37b9c571a56
Units can display the temperature
Michiel Broek <mbroek@mbse.eu>
parents:
100
diff
changeset
|
146 | } |
115 | 147 | if ((strcmp($vals[0], "AIR_TEMPERATURE") == 0) && ($air_state == 0)) { |
148 | $air_temperature = $vals[1]; | |
102
e37b9c571a56
Units can display the temperature
Michiel Broek <mbroek@mbse.eu>
parents:
100
diff
changeset
|
149 | } |
e37b9c571a56
Units can display the temperature
Michiel Broek <mbroek@mbse.eu>
parents:
100
diff
changeset
|
150 | if (strcmp($vals[0], "BEER_STATE") == 0) { |
e37b9c571a56
Units can display the temperature
Michiel Broek <mbroek@mbse.eu>
parents:
100
diff
changeset
|
151 | $beer_state = $vals[1]; |
e37b9c571a56
Units can display the temperature
Michiel Broek <mbroek@mbse.eu>
parents:
100
diff
changeset
|
152 | } |
115 | 153 | if ((strcmp($vals[0], "BEER_TEMPERATURE") == 0) && ($beer_state == 0)) { |
154 | $beer_temperature = $vals[1]; | |
102
e37b9c571a56
Units can display the temperature
Michiel Broek <mbroek@mbse.eu>
parents:
100
diff
changeset
|
155 | } |
100 | 156 | } |
151
ab90da2da45d
Improved dashboard panel style, added (ugly) led's
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
157 | $outstr .= ' <div id="fermentor_panel_top">'.PHP_EOL; |
113
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
158 | $outstr .= ' <div id="fermentor_selector">'.PHP_EOL; |
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
159 | $outstr .= ' Mode '.$mode.PHP_EOL; |
116
065a242ed7ec
Added jquery script. Added radio buttons for unit mode
Michiel Broek <mbroek@mbse.eu>
parents:
115
diff
changeset
|
160 | $outstr .= ' <form>'.PHP_EOL; |
065a242ed7ec
Added jquery script. Added radio buttons for unit mode
Michiel Broek <mbroek@mbse.eu>
parents:
115
diff
changeset
|
161 | strcmp($mode, "OFF") ? $se = "" : $se = " checked"; |
065a242ed7ec
Added jquery script. Added radio buttons for unit mode
Michiel Broek <mbroek@mbse.eu>
parents:
115
diff
changeset
|
162 | $outstr .= ' <input type="radio" name="mode'.$unr.'" value="OFF"'.$se.'>Off<br>'.PHP_EOL; |
065a242ed7ec
Added jquery script. Added radio buttons for unit mode
Michiel Broek <mbroek@mbse.eu>
parents:
115
diff
changeset
|
163 | strcmp($mode, "NONE") ? $se = "" : $se = " checked"; |
065a242ed7ec
Added jquery script. Added radio buttons for unit mode
Michiel Broek <mbroek@mbse.eu>
parents:
115
diff
changeset
|
164 | $outstr .= ' <input type="radio" name="mode'.$unr.'" value="NONE"'.$se.'>None<br>'.PHP_EOL; |
065a242ed7ec
Added jquery script. Added radio buttons for unit mode
Michiel Broek <mbroek@mbse.eu>
parents:
115
diff
changeset
|
165 | strcmp($mode, "FRIDGE") ? $se = "" : $se = " checked"; |
065a242ed7ec
Added jquery script. Added radio buttons for unit mode
Michiel Broek <mbroek@mbse.eu>
parents:
115
diff
changeset
|
166 | $outstr .= ' <input type="radio" name="mode'.$unr.'" value="FRIDGE"'.$se.' disabled>Fridge<br>'.PHP_EOL; |
065a242ed7ec
Added jquery script. Added radio buttons for unit mode
Michiel Broek <mbroek@mbse.eu>
parents:
115
diff
changeset
|
167 | strcmp($mode, "BEER") ? $se = "" : $se = " checked"; |
065a242ed7ec
Added jquery script. Added radio buttons for unit mode
Michiel Broek <mbroek@mbse.eu>
parents:
115
diff
changeset
|
168 | $outstr .= ' <input type="radio" name="mode'.$unr.'" value="BEER"'.$se.' disabled>Beer<br>'.PHP_EOL; |
065a242ed7ec
Added jquery script. Added radio buttons for unit mode
Michiel Broek <mbroek@mbse.eu>
parents:
115
diff
changeset
|
169 | strcmp($mode, "PROFILE") ? $se = "" : $se = " checked"; |
065a242ed7ec
Added jquery script. Added radio buttons for unit mode
Michiel Broek <mbroek@mbse.eu>
parents:
115
diff
changeset
|
170 | $outstr .= ' <input type="radio" name="mode'.$unr.'" value="PROFILE"'.$se.' disabled>Profile'.PHP_EOL; |
065a242ed7ec
Added jquery script. Added radio buttons for unit mode
Michiel Broek <mbroek@mbse.eu>
parents:
115
diff
changeset
|
171 | $outstr .= ' </form>'.PHP_EOL; |
113
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
172 | $outstr .= ' </div>'.PHP_EOL; |
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
173 | $outstr .= ' <div id="fermentor_powerled">'.PHP_EOL; |
151
ab90da2da45d
Improved dashboard panel style, added (ugly) led's
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
174 | $outstr .= ' <img src="images/led_green_'.$power_led.'.png"><br>Pwr'.PHP_EOL; |
113
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
175 | $outstr .= ' </div>'.PHP_EOL; |
151
ab90da2da45d
Improved dashboard panel style, added (ugly) led's
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
176 | $outstr .= ' </div> <!-- fermentor_panel_top -->'.PHP_EOL; |
ab90da2da45d
Improved dashboard panel style, added (ugly) led's
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
177 | |
ab90da2da45d
Improved dashboard panel style, added (ugly) led's
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
178 | $outstr .= ' <div id="fermentor_panel_display">'.PHP_EOL; |
113
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
179 | $outstr .= ' <div id="fermentor_display1">'.PHP_EOL; |
115 | 180 | $outstr .= ' '.$set_temperature.'<br>Set'.PHP_EOL; |
113
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
181 | $outstr .= ' </div>'.PHP_EOL; |
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
182 | $outstr .= ' <div id="fermentor_display2">'.PHP_EOL; |
115 | 183 | $outstr .= ' '.$air_temperature.'<br>Air'.PHP_EOL; |
113
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
184 | $outstr .= ' </div>'.PHP_EOL; |
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
185 | $outstr .= ' <div id="fermentor_display3">'.PHP_EOL; |
115 | 186 | $outstr .= ' '.$beer_temperature.'<br>Beer'.PHP_EOL; |
113
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
187 | $outstr .= ' </div>'.PHP_EOL; |
151
ab90da2da45d
Improved dashboard panel style, added (ugly) led's
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
188 | $outstr .= ' </div> <!-- fermentor_panel_display -->'.PHP_EOL; |
ab90da2da45d
Improved dashboard panel style, added (ugly) led's
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
189 | |
ab90da2da45d
Improved dashboard panel style, added (ugly) led's
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
190 | $outstr .= ' <div id="fermentor_panel_control">'.PHP_EOL; |
113
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
191 | $outstr .= ' <div id="fermentor_led1">'.PHP_EOL; |
151
ab90da2da45d
Improved dashboard panel style, added (ugly) led's
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
192 | $outstr .= ' <img src="images/led_green_'.$cooler_led.'.png"><br>Cool'.PHP_EOL; |
113
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
193 | $outstr .= ' </div>'.PHP_EOL; |
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
194 | $outstr .= ' <div id="fermentor_led2">'.PHP_EOL; |
151
ab90da2da45d
Improved dashboard panel style, added (ugly) led's
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
195 | $outstr .= ' <img src="images/led_green_'.$heater_led.'.png"><br>Heat'.PHP_EOL; |
113
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
196 | $outstr .= ' </div>'.PHP_EOL; |
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
197 | $outstr .= ' <div id="fermentor_led3">'.PHP_EOL; |
151
ab90da2da45d
Improved dashboard panel style, added (ugly) led's
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
198 | $outstr .= ' <img src="images/led_green_'.$fan_led.'.png"><br>Fan'.PHP_EOL; |
113
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
199 | $outstr .= ' </div>'.PHP_EOL; |
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
200 | $outstr .= ' <div id="fermentor_toggle1">'.PHP_EOL; |
117 | 201 | $outstr .= ' <form>'.PHP_EOL; |
202 | strcmp($mode, "NONE") ? $se = " disabled" : $se = ""; | |
203 | $ch = " checked"; | |
204 | $outstr .= ' <input type="radio" name="cooler'.$unr.'" value="OFF"'.$se.$ch.'>Off<br>'.PHP_EOL; | |
151
ab90da2da45d
Improved dashboard panel style, added (ugly) led's
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
205 | $outstr .= ' <input type="radio" name="cooler'.$unr.'" value="ON"'.$se.'>On'.PHP_EOL; |
117 | 206 | $outstr .= ' </form>'.PHP_EOL; |
113
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
207 | $outstr .= ' </div>'.PHP_EOL; |
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
208 | $outstr .= ' <div id="fermentor_toggle2">'.PHP_EOL; |
117 | 209 | $outstr .= ' <form>'.PHP_EOL; |
210 | strcmp($mode, "NONE") ? $se = " disabled" : $se = ""; | |
211 | $outstr .= ' <input type="radio" name="heater'.$unr.'" value="OFF"'.$se.$ch.'>Off<br>'.PHP_EOL; | |
151
ab90da2da45d
Improved dashboard panel style, added (ugly) led's
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
212 | $outstr .= ' <input type="radio" name="heater'.$unr.'" value="ON"'.$se.'>On'.PHP_EOL; |
117 | 213 | $outstr .= ' </form>'.PHP_EOL; |
113
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
214 | $outstr .= ' </div>'.PHP_EOL; |
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
215 | $outstr .= ' <div id="fermentor_toggle3">'.PHP_EOL; |
117 | 216 | $outstr .= ' <form>'.PHP_EOL; |
217 | strcmp($mode, "NONE") ? $se = " disabled" : $se = ""; | |
218 | $outstr .= ' <input type="radio" name="fan'.$unr.'" value="OFF"'.$se.$ch.'>Off<br>'.PHP_EOL; | |
151
ab90da2da45d
Improved dashboard panel style, added (ugly) led's
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
219 | $outstr .= ' <input type="radio" name="fan'.$unr.'" value="ON"'.$se.'>On'.PHP_EOL; |
117 | 220 | $outstr .= ' </form>'.PHP_EOL; |
113
cf3f906ffe0d
Created control panel layout
Michiel Broek <mbroek@mbse.eu>
parents:
112
diff
changeset
|
221 | $outstr .= ' </div>'.PHP_EOL; |
151
ab90da2da45d
Improved dashboard panel style, added (ugly) led's
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
222 | $outstr .= ' </div> <!-- fermentor_panel_control -->'.PHP_EOL; |
ab90da2da45d
Improved dashboard panel style, added (ugly) led's
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
223 | |
122
e57043423e72
Added fermentor maintenance windows
Michiel Broek <mbroek@mbse.eu>
parents:
121
diff
changeset
|
224 | $outstr .= ' </div> <!-- fermentor -->'.PHP_EOL; |
100 | 225 | } |
226 | ||
227 | return $outstr; | |
228 | } | |
229 | ||
230 | ||
231 | ||
232 | function liveview() | |
233 | { | |
234 | $outstr = PHP_EOL; | |
235 | ||
236 | $sock = open_socket(); | |
237 | if ($sock !== false) { | |
238 | socket_write($sock, "LIST", 4096); | |
239 | ||
240 | /* | |
241 | * Multiple reads until the remote closed the connection | |
242 | */ | |
243 | $answer = ""; | |
244 | while (1) { | |
245 | $line = socket_read($sock, 4096); | |
246 | if ($line === '') | |
247 | break; | |
248 | $answer .= $line; | |
249 | } | |
250 | socket_close($sock); | |
251 | $arr = explode("\r\n", $answer); | |
252 | ||
117 | 253 | $outstr .= ' <div id="jqxTabs">'.PHP_EOL; |
254 | $outstr .= ' <ul>'.PHP_EOL; | |
100 | 255 | if (startsWith($arr[0], "212")) { |
256 | $i = 1; | |
257 | while (1) { | |
258 | if (strcmp($arr[$i], ".") == 0) | |
259 | break; | |
260 | $parts = explode(",", $arr[$i]); | |
131
528dc0bb81ab
Always use uuid to select units and remove numeric record id's.
Michiel Broek <mbroek@mbse.eu>
parents:
124
diff
changeset
|
261 | $outstr .= ' <li style="margin-left: 20px;">'.$parts[1].'</li>'.PHP_EOL; |
117 | 262 | $i++; |
263 | } | |
264 | } | |
265 | $outstr .= ' </ul>'.PHP_EOL; | |
266 | ||
267 | if (startsWith($arr[0], "212")) { | |
268 | $i = 1; | |
269 | while (1) { | |
270 | if (strcmp($arr[$i], ".") == 0) | |
271 | break; | |
272 | $parts = explode(",", $arr[$i]); | |
131
528dc0bb81ab
Always use uuid to select units and remove numeric record id's.
Michiel Broek <mbroek@mbse.eu>
parents:
124
diff
changeset
|
273 | $outstr .= showunit($parts[0], $i); |
100 | 274 | $i++; |
275 | } | |
276 | } | |
117 | 277 | $outstr .= ' </div> <!-- jqxTabs -->'.PHP_EOL; |
100 | 278 | } |
279 | ||
280 | return $outstr; | |
281 | } | |
282 | ||
283 | ||
284 | ?> |