Mon, 05 Oct 2015 15:21:46 +0200
Make sure that a DS2413 device used as input has the output latch turned off.
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | <?php |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | /***************************************************************************** |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * Copyright (C) 2014 |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * Michiel Broek <mbroek at mbse dot eu> |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * This file is part of ThermFerm |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * This is free software; you can redistribute it and/or modify it |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * under the terms of the GNU General Public License as published by the |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * Free Software Foundation; either version 2, or (at your option) any |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * later version. |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * ThermFerm is distributed in the hope that it will be useful, but |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * General Public License for more details. |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | * |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | * along with ThermFerm; see the file COPYING. If not, write to the Free |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | *****************************************************************************/ |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | |
173 | 24 | require_once('utilities.php'); |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | |
207 | 26 | |
27 | if (isset($_POST['action'])) { | |
28 | if ($_POST['action'] == "testdata") | |
29 | testdata(); | |
30 | } else { | |
31 | edit_screen(""); | |
32 | } | |
33 | ||
34 | ||
35 | exit; | |
36 | ||
37 | ||
38 | /***************************************************************************** | |
39 | * | |
40 | */ | |
41 | ||
42 | ||
43 | function global_update() { | |
44 | ||
45 | if ($_POST['key'] == 'Save') { | |
253
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
46 | $cmd = array("GLOBAL PUT"); |
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
47 | $cmd[] = "NAME,".$_POST['Name']; |
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
48 | $cmd[] = "PORT,".$_POST['Port']; |
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
49 | $cmd[] = "TEMP_ADDRESS,".$_POST['TempAddress']; |
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
50 | $cmd[] = "HUM_ADDRESS,".$_POST['HumAddress']; |
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
51 | if (isset($_POST['LCDcols'])) |
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
52 | $cmd[] = "LCD_COLS,".$_POST['LCDcols']; |
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
53 | if (isset($_POST['LCDrows'])) |
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
54 | $cmd[] = "LCD_ROWS,".$_POST['LCDrows']; |
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
55 | $cmd[] = "."; |
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
56 | send_array($cmd); |
207 | 57 | } |
58 | ||
59 | unset($_POST['Name']); | |
60 | unset($_POST['Port']); | |
61 | unset($_POST['TempAddress']); | |
62 | unset($_POST['HumAddress']); | |
63 | unset($_POST['LCDcols']); | |
64 | unset($_POST['LCDrows']); | |
65 | unset($_POST['key']); | |
66 | load('global.php'); | |
67 | } | |
68 | ||
69 | ||
70 | ||
71 | function test_thedata() { | |
72 | ||
73 | if (isset($_POST['Name']) && isset($_POST['Port']) && | |
74 | isset($_POST['TempAddress']) && isset($_POST['HumAddress']) && | |
75 | isset($_POST['key'])) { | |
76 | ||
77 | if ($_POST['key'] == 'Cancel') | |
78 | return 99; | |
79 | ||
80 | if (isset($_POST['LCDcols']) && (($_POST['LCDcols'] != 16) && ($_POST['LCDcols'] != 20))) | |
81 | return 2; | |
82 | ||
83 | if (isset($_POST['LCDrows']) && (($_POST['LCDrows'] != 2) && ($_POST['LCDrows'] != 4))) | |
84 | return 3; | |
85 | ||
86 | } else { | |
87 | return 1; | |
88 | } | |
89 | ||
90 | return 0; | |
91 | } | |
92 | ||
93 | ||
94 | ||
95 | function testdata() | |
96 | { | |
97 | $result = test_thedata(); | |
98 | $error = ''; | |
99 | ||
100 | switch ($result) { | |
101 | case 0: global_update(); | |
102 | return; | |
103 | break; | |
104 | case 1: $error = 'Missing data'; | |
105 | break; | |
106 | case 2: $error = 'LCD columns must be 16 or 20'; | |
107 | break; | |
108 | case 3: $error = 'LCD rows must be 2 or 4'; | |
109 | break; | |
110 | case 99: | |
111 | load('global.php'); | |
112 | break; | |
113 | } | |
114 | ||
115 | edit_screen($error); | |
116 | } | |
117 | ||
118 | ||
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
119 | |
207 | 120 | function edit_screen($error_message) |
121 | { | |
122 | /* | |
123 | * Get list of devices, we need it later | |
124 | */ | |
125 | $answer = send_cmd("DEVICE LIST"); | |
126 | $devices = explode("\r\n", $answer); | |
127 | ||
128 | /* | |
129 | * Get current global data | |
130 | */ | |
131 | $answer = send_cmd("GLOBAL GET"); | |
132 | $reply = explode("\r\n", $answer); | |
133 | ||
134 | $outstr = build_header("ThermFerm - Global Setup"); | |
135 | $outstr .= ' <div id="errors">'.PHP_EOL; | |
136 | $outstr .= ' '.$error_message.PHP_EOL; | |
137 | $outstr .= ' </div> <!-- errors -->'.PHP_EOL; | |
138 | $outstr .= ' <div id="etable">'.PHP_EOL; | |
139 | $outstr .= ' <form method="POST" action="global.php">'.PHP_EOL; | |
140 | $outstr .= ' <table class="editor">'.PHP_EOL; | |
141 | $outstr .= ' <tr class="trhead">'.PHP_EOL; | |
142 | $outstr .= ' <td class="setup" colspan="2" style="text-align: center; height: 20px; padding-top: 5px;">Global Setup</td>'.PHP_EOL; | |
143 | $outstr .= ' </tr>'.PHP_EOL; | |
144 | ||
145 | if (startsWith($reply[0], "213")) { | |
146 | $i = 1; | |
147 | while (1) { | |
148 | if (strcmp($reply[$i], ".") == 0) | |
149 | break; | |
150 | $f = explode(",", $reply[$i]); | |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
151 | |
207 | 152 | if ($f[0] == "NAME") { |
153 | $outstr .= ' <tr class="editor">'.PHP_EOL; | |
154 | $outstr .= ' <td class="editname">System Name</td>'.PHP_EOL; | |
155 | $outstr .= ' <td class="editfield"><input type="text" name="Name" size="50" value="'.$f[1].'"></td>'.PHP_EOL; | |
156 | $outstr .= ' </tr>'.PHP_EOL; | |
157 | } | |
158 | if ($f[0] == "PORT") { | |
159 | $outstr .= ' <tr class="editor">'.PHP_EOL; | |
160 | $outstr .= ' <td class="editname">Telnet port</td>'.PHP_EOL; | |
161 | $outstr .= ' <td class="editfield"><input type="text" name="Port" size="5" value="'.$f[1].'"></td>'.PHP_EOL; | |
162 | $outstr .= ' </tr>'.PHP_EOL; | |
163 | } | |
164 | if ($f[0] == "TEMP_ADDRESS") { | |
165 | $outstr .= ' <tr class="editor">'.PHP_EOL; | |
166 | $outstr .= ' <td class="editname">Room temperature sensor</td>'.PHP_EOL; | |
167 | $outstr .= ' <td class="editfield"><select name="TempAddress">'.PHP_EOL; | |
168 | $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL; | |
169 | if (startsWith($devices[0], "212")) { | |
170 | $j = 1; | |
171 | while (1) { | |
172 | if (strcmp($devices[$j], ".") == 0) | |
173 | break; | |
174 | $g = explode(",", $devices[$j]); | |
175 | if ($g[5] == "IN_ANALOG") { | |
176 | ($f[1] == $g[0]) ? $se = " selected" : $se = ""; | |
177 | $outstr .= ' <option value="'.$g[0].'"'.$se.'>'.$g[1].' '.$g[4].'</option>'.PHP_EOL; | |
178 | } | |
179 | $j++; | |
180 | } | |
181 | } | |
182 | $outstr .= ' </select></td>'.PHP_EOL; | |
183 | $outstr .= ' </tr>'.PHP_EOL; | |
184 | } | |
185 | if ($f[0] == "HUM_ADDRESS") { | |
186 | $outstr .= ' <tr class="editor">'.PHP_EOL; | |
187 | $outstr .= ' <td class="editname">Room humidity sensor</td>'.PHP_EOL; | |
188 | $outstr .= ' <td class="editfield"><select name="HumAddress">'.PHP_EOL; | |
189 | $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL; | |
190 | if (startsWith($devices[0], "212")) { | |
191 | $j = 1; | |
192 | while (1) { | |
193 | if (strcmp($devices[$j], ".") == 0) | |
194 | break; | |
195 | $g = explode(",", $devices[$j]); | |
196 | if ($g[5] == "IN_ANALOG") { | |
197 | ($f[1] == $g[0]) ? $se = " selected" : $se = ""; | |
198 | $outstr .= ' <option value="'.$g[0].'"'.$se.'>'.$g[1].' '.$g[4].'</option>'.PHP_EOL; | |
199 | } | |
200 | $j++; | |
201 | } | |
202 | } | |
203 | $outstr .= ' </select></td>'.PHP_EOL; | |
204 | $outstr .= ' </tr>'.PHP_EOL; | |
205 | } | |
206 | if ($f[0] == "LCD_COLS") { | |
207 | $outstr .= ' <tr class="editor">'.PHP_EOL; | |
208 | $outstr .= ' <td class="editname">LCD columns</td>'.PHP_EOL; | |
209 | $outstr .= ' <td class="editfield"><input type="text" name="LCDcols" size="5" value="'.$f[1].'"></td>'.PHP_EOL; | |
210 | $outstr .= ' </tr>'.PHP_EOL; | |
211 | } | |
212 | if ($f[0] == "LCD_ROWS") { | |
213 | $outstr .= ' <tr class="editor">'.PHP_EOL; | |
214 | $outstr .= ' <td class="editname">LCD rows</td>'.PHP_EOL; | |
215 | $outstr .= ' <td class="editfield"><input type="text" name="LCDrows" size="5" value="'.$f[1].'"></td>'.PHP_EOL; | |
216 | $outstr .= ' </tr>'.PHP_EOL; | |
217 | } | |
218 | $i++; | |
219 | } | |
220 | } | |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
221 | |
207 | 222 | $outstr .= ' <tr class="editor">'.PHP_EOL; |
223 | $outstr .= ' <td class="editname"><input type="submit" value="Save" name="key"></td>'.PHP_EOL; | |
224 | $outstr .= ' <td class="editfield"><input type="submit" value="Cancel" name="key">'; | |
225 | $outstr .= '<input type="hidden" value="testdata" name="action">'; | |
226 | $outstr .= ' </tr>'.PHP_EOL; | |
227 | $outstr .= ' </table>'.PHP_EOL; | |
228 | $outstr .= ' </form>'.PHP_EOL; | |
229 | $outstr .= ' </div> <!-- etable -->'.PHP_EOL; | |
397
00ca08f5a6f8
Fermentation profiles now have a low and high temperature setting so that you can use a temperture window. Each profile step can now set for beer or air temperature reference. The logfiles have an extra temperature field for this. Bumped to version 0.4.2.
Michiel Broek <mbroek@mbse.eu>
parents:
253
diff
changeset
|
230 | $outstr .= ' <script type="text/javascript">'.PHP_EOL; |
00ca08f5a6f8
Fermentation profiles now have a low and high temperature setting so that you can use a temperture window. Each profile step can now set for beer or air temperature reference. The logfiles have an extra temperature field for this. Bumped to version 0.4.2.
Michiel Broek <mbroek@mbse.eu>
parents:
253
diff
changeset
|
231 | $outstr .= ' $(document).ready(function () {'.PHP_EOL; |
00ca08f5a6f8
Fermentation profiles now have a low and high temperature setting so that you can use a temperture window. Each profile step can now set for beer or air temperature reference. The logfiles have an extra temperature field for this. Bumped to version 0.4.2.
Michiel Broek <mbroek@mbse.eu>
parents:
253
diff
changeset
|
232 | $outstr .= ' $("#maintenance").jqxButton({ width: 150, height: 25, theme: \'ui-redmond\' });'.PHP_EOL; |
00ca08f5a6f8
Fermentation profiles now have a low and high temperature setting so that you can use a temperture window. Each profile step can now set for beer or air temperature reference. The logfiles have an extra temperature field for this. Bumped to version 0.4.2.
Michiel Broek <mbroek@mbse.eu>
parents:
253
diff
changeset
|
233 | $outstr .= ' });'.PHP_EOL; |
00ca08f5a6f8
Fermentation profiles now have a low and high temperature setting so that you can use a temperture window. Each profile step can now set for beer or air temperature reference. The logfiles have an extra temperature field for this. Bumped to version 0.4.2.
Michiel Broek <mbroek@mbse.eu>
parents:
253
diff
changeset
|
234 | $outstr .= ' </script>'.PHP_EOL; |
207 | 235 | $outstr .= build_footer(); |
236 | ||
237 | echo $outstr; | |
238 | } | |
239 | ||
240 |