www-thermferm/getstate.php

Sun, 07 Jul 2019 14:31:10 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 07 Jul 2019 14:31:10 +0200
branch
stable
changeset 603
fcff55324b84
parent 578
d694abd9d809
child 693
3518c07737d8
permissions
-rw-r--r--

Merged fix from default

171
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 <?php
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 /*****************************************************************************
578
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 529
diff changeset
3 * Copyright (C) 2014-2019
171
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 *
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * Michiel Broek <mbroek at mbse dot eu>
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 *
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * This file is part of ThermFerm
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 *
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * This is free software; you can redistribute it and/or modify it
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * under the terms of the GNU General Public License as published by the
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * Free Software Foundation; either version 2, or (at your option) any
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * later version.
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * ThermFerm is distributed in the hope that it will be useful, but
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 * General Public License for more details.
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 *
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 * along with ThermFerm; see the file COPYING. If not, write to the Free
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 *****************************************************************************/
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 require_once('utilities.php');
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 if (isset($_GET["uuid"]))
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 $uuid = $_GET["uuid"];
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 else
529
00b45f2aaac3 Added alarm LED
Michiel Broek <mbroek@mbse.eu>
parents: 522
diff changeset
29 $uuid = "e53858c3-a97e-4b07-85e9-524257909f45";
171
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30
196
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 193
diff changeset
31 $answer = send_cmd('UNIT GET '.$uuid);
171
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 $arr = explode("\r\n", $answer);
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 $air_temperature = "NA";
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 $air_state = "NA";
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 $beer_temperature = "NA";
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 $beer_state = "NA";
522
4d9ed666431d Liveview completed the chiller thermometer.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
38 $chiller_temperature = "NA";
4d9ed666431d Liveview completed the chiller thermometer.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
39 $chiller_state = "NA";
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: 371
diff changeset
40 $target_temperature_lo = "NA";
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: 371
diff changeset
41 $target_temperature_hi = "NA";
529
00b45f2aaac3 Added alarm LED
Michiel Broek <mbroek@mbse.eu>
parents: 522
diff changeset
42 $led1 = $led2 = $led3 = $sw1 = $sw2 = $sw3 = $alarmled = "";
171
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 $fridge_set = "NA";
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 $beer_set = "NA";
522
4d9ed666431d Liveview completed the chiller thermometer.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
45 $heater = $cooler = $chiller = $fan = $psu = $door = "no";
284
9e6fb5aed618 Profile progress is visible in the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 257
diff changeset
46 $prof_state = "OFF";
371
44665f154ead Prevent undefined variables in getstate.php
Michiel Broek <mbroek@mbse.eu>
parents: 349
diff changeset
47 $mode = "NA";
44665f154ead Prevent undefined variables in getstate.php
Michiel Broek <mbroek@mbse.eu>
parents: 349
diff changeset
48 $cooler_state = "NA";
44665f154ead Prevent undefined variables in getstate.php
Michiel Broek <mbroek@mbse.eu>
parents: 349
diff changeset
49 $heater_state = "NA";
44665f154ead Prevent undefined variables in getstate.php
Michiel Broek <mbroek@mbse.eu>
parents: 349
diff changeset
50 $fan_state = "NA";
257
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
51
171
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 if (startsWith($arr[0], "213")) {
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 $j = 1;
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 while (1) {
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 if (strcmp($arr[$j], ".") == 0)
529
00b45f2aaac3 Added alarm LED
Michiel Broek <mbroek@mbse.eu>
parents: 522
diff changeset
56 break;
171
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 $f = explode(",", $arr[$j]);
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 if ($f[0] == "AIR_STATE")
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 $air_state = $f[1];
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 if (($f[0] == "AIR_TEMPERATURE") && ($air_state == "OK"))
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 $air_temperature = $f[1];
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 if ($f[0] == "BEER_STATE")
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 $beer_state = $f[1];
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 if (($f[0] == "BEER_TEMPERATURE") && ($beer_state == "OK"))
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 $beer_temperature = $f[1];
522
4d9ed666431d Liveview completed the chiller thermometer.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
67 if ($f[0] == "CHILLER_STATE")
4d9ed666431d Liveview completed the chiller thermometer.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
68 $chiller_state = $f[1];
4d9ed666431d Liveview completed the chiller thermometer.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
69 if (($f[0] == "CHILLER_TEMPERATURE") && ($chiller_state == "OK"))
4d9ed666431d Liveview completed the chiller thermometer.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
70 $chiller_temperature = $f[1];
171
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 if ($f[0] == "MODE")
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 $mode = $f[1];
257
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
73 if (($f[0] == "COOLER_ADDRESS") && (strcmp($f[1], "(null)")))
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
74 $cooler = "yes";
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
75 if ($f[0] == "COOLER_STATE") {
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
76 $cooler_state = $f[1];
225
b18b06c17a80 Changed CSS colors for the LED's. Removed the old LED's.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
77 $led1 = $f[1] ? '<div class="LEDgreen_on"></div>' : '<div class="LEDgreen_off"></div>';
257
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
78 }
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
79 if (($f[0] == "HEATER_ADDRESS") && (strcmp($f[1], "(null)")))
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
80 $heater = "yes";
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
81 if ($f[0] == "HEATER_STATE") {
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
82 $heater_state = $f[1];
225
b18b06c17a80 Changed CSS colors for the LED's. Removed the old LED's.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
83 $led2 = $f[1] ? '<div class="LEDgreen_on"></div>' : '<div class="LEDgreen_off"></div>';
257
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
84 }
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
85 if (($f[0] == "FAN_ADDRESS") && (strcmp($f[1], "(null)")))
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
86 $fan = "yes";
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
87 if ($f[0] == "FAN_STATE") {
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
88 $fan_state = $f[1];
225
b18b06c17a80 Changed CSS colors for the LED's. Removed the old LED's.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
89 $led3 = $f[1] ? '<div class="LEDgreen_on"></div>' : '<div class="LEDgreen_off"></div>';
257
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
90 }
349
1f89da6511a9 Added Fan delay logic.
Michiel Broek <mbroek@mbse.eu>
parents: 287
diff changeset
91 if (($f[0] == "PSU_ADDRESS") && (strcmp($f[1], "(null)")))
1f89da6511a9 Added Fan delay logic.
Michiel Broek <mbroek@mbse.eu>
parents: 287
diff changeset
92 $psu = "yes";
1f89da6511a9 Added Fan delay logic.
Michiel Broek <mbroek@mbse.eu>
parents: 287
diff changeset
93 if (($f[0] == "DOOR_ADDRESS") && (strcmp($f[1], "(null)")))
1f89da6511a9 Added Fan delay logic.
Michiel Broek <mbroek@mbse.eu>
parents: 287
diff changeset
94 $door = "yes";
578
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 529
diff changeset
95 if (($f[0] == "BEER_SET_LO") && ($mode == "BEER"))
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 529
diff changeset
96 $target_temperature_lo = $f[1];
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 529
diff changeset
97 if (($f[0] == "BEER_SET_HI") && ($mode == "BEER"))
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 529
diff changeset
98 $target_temperature_hi = $f[1];
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 529
diff changeset
99 if (($f[0] == "FRIDGE_SET_LO") && ($mode == "FRIDGE"))
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 529
diff changeset
100 $target_temperature_lo = $f[1];
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 529
diff changeset
101 if (($f[0] == "FRIDGE_SET_HI") && ($mode == "FRIDGE"))
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 529
diff changeset
102 $target_temperature_hi = $f[1];
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: 371
diff changeset
103 if (($f[0] == "PROF_TARGET_LO") && ($mode == "PROFILE"))
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: 371
diff changeset
104 $target_temperature_lo = $f[1];
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: 371
diff changeset
105 if (($f[0] == "PROF_TARGET_HI") && ($mode == "PROFILE"))
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: 371
diff changeset
106 $target_temperature_hi = $f[1];
284
9e6fb5aed618 Profile progress is visible in the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 257
diff changeset
107 if (($f[0] == "PROF_STATE") && ($mode == "PROFILE"))
287
61be1e1711d3 Make ajax response for profile state the same as the startup state
Michiel Broek <mbroek@mbse.eu>
parents: 284
diff changeset
108 $prof_state = 'State: '.$f[1];
529
00b45f2aaac3 Added alarm LED
Michiel Broek <mbroek@mbse.eu>
parents: 522
diff changeset
109 if ($f[0] == "ALARM")
00b45f2aaac3 Added alarm LED
Michiel Broek <mbroek@mbse.eu>
parents: 522
diff changeset
110 $alarmled = $f[1] ? '<div class="LEDred_on"></div>' : '<div class="LEDred_off"></div>';
171
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 $j++;
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 }
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 }
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115
257
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
116 /*
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
117 * Create the value for the mode select radio buttons
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
118 */
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
119 strcmp($mode, "OFF") ? $se = "" : $se = " checked";
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
120 $modestr = ' <input type="radio" name="mode" onchange="this.form.submit()" class="select" value="OFF"'.$se.'>Off<br>'.PHP_EOL;
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
121 strcmp($mode, "NONE") ? $se = "" : $se = " checked";
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
122 $modestr .= ' <input type="radio" name="mode" onchange="this.form.submit()" class="select" value="NONE"'.$se.'>None<br>'.PHP_EOL;
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
123 (strcmp($heater, "no") || strcmp($cooler, "no")) ? $dis = "" : $dis = " disabled";
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
124 strcmp($mode, "FRIDGE") ? $se = "" : $se = " checked";
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
125 $modestr .= ' <input type="radio" name="mode" onchange="this.form.submit()" class="select" value="FRIDGE"'.$se.$dis.'>Fridge<br>'.PHP_EOL;
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
126 strcmp($mode, "BEER") ? $se = "" : $se = " checked";
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
127 $modestr .= ' <input type="radio" name="mode" onchange="this.form.submit()" class="select" value="BEER"'.$se.$dis.'>Beer<br>'.PHP_EOL;
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
128 strcmp($mode, "PROFILE") ? $se = "" : $se = " checked";
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
129 $modestr .= ' <input type="radio" name="mode" onchange="this.form.submit()" class="select" value="PROFILE"'.$se.$dis.'>Profile'.PHP_EOL;
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
130
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
131
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
132 /*
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
133 * Create the values for the on/off switches
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
134 */
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
135 (($mode == "NONE") && ($cooler == "yes")) ? $dis = "" : $dis = " disabled";
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
136 ($cooler_state == "0") ? $ch = " checked" : $ch = "";
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
137 $sw1 = ' <input type="radio" name="CoolerState" onchange="this.form.submit()" value="0"'.$dis.$ch.'>Off<br>'.PHP_EOL;
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
138 ($cooler_state == "100") ? $ch = " checked" : $ch = "";
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
139 $sw1 .= ' <input type="radio" name="CoolerState" onchange="this.form.submit()" value="100"'.$dis.$ch.'>On'.PHP_EOL;
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
140
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
141 (($mode == "NONE") && ($heater == "yes")) ? $dis = "" : $dis = " disabled";
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
142 ($heater_state == "0") ? $ch = " checked" : $ch = "";
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
143 $sw2 = ' <input type="radio" name="HeaterState" onchange="this.form.submit()" value="0"'.$dis.$ch.'>Off<br>'.PHP_EOL;
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
144 ($heater_state == "100") ? $ch = " checked" : $ch = "";
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
145 $sw2 .= ' <input type="radio" name="HeaterState" onchange="this.form.submit()" value="100"'.$dis.$ch.'>On'.PHP_EOL;
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
146
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
147 (($mode == "NONE") && ($fan== "yes")) ? $dis = "" : $dis = " disabled";
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
148 ($fan_state == "0") ? $ch = " checked" : $ch = "";
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
149 $sw3 = ' <input type="radio" name="FanState" onchange="this.form.submit()" value="0"'.$dis.$ch.'>Off<br>'.PHP_EOL;
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
150 ($fan_state == "100") ? $ch = " checked" : $ch = "";
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
151 $sw3 .= ' <input type="radio" name="FanState" onchange="this.form.submit()" value="100"'.$dis.$ch.'>On'.PHP_EOL;
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
152
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
153
abdba3f9d9e2 Automatic ajax updates of radio buttons
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
154
171
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155 $reply = array (
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: 371
diff changeset
156 'air_temperature' => $air_temperature,
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: 371
diff changeset
157 'beer_temperature' => $beer_temperature,
522
4d9ed666431d Liveview completed the chiller thermometer.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
158 'chiller_temperature' => $chiller_temperature,
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: 371
diff changeset
159 'target_temperature_lo' => $target_temperature_lo,
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: 371
diff changeset
160 'target_temperature_hi' => $target_temperature_hi,
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: 371
diff changeset
161 'mode' => $modestr,
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: 371
diff changeset
162 'led1' => $led1,
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: 371
diff changeset
163 'led2' => $led2,
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: 371
diff changeset
164 'led3' => $led3,
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: 371
diff changeset
165 'sw1' => $sw1,
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: 371
diff changeset
166 'sw2' => $sw2,
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: 371
diff changeset
167 'sw3' => $sw3,
529
00b45f2aaac3 Added alarm LED
Michiel Broek <mbroek@mbse.eu>
parents: 522
diff changeset
168 'profile_state' => $prof_state,
00b45f2aaac3 Added alarm LED
Michiel Broek <mbroek@mbse.eu>
parents: 522
diff changeset
169 'alarm' => $alarmled
171
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 );
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173 echo json_encode($reply);
15f92e5eecef Ajax screen updates now use a single call to the server
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 ?>

mercurial