www-thermferm/getstate.php

changeset 529
00b45f2aaac3
parent 522
4d9ed666431d
child 578
d694abd9d809
equal deleted inserted replaced
528:908ef02d5d22 529:00b45f2aaac3
24 require_once('utilities.php'); 24 require_once('utilities.php');
25 25
26 if (isset($_GET["uuid"])) 26 if (isset($_GET["uuid"]))
27 $uuid = $_GET["uuid"]; 27 $uuid = $_GET["uuid"];
28 else 28 else
29 $uuid = "48c9ae27-3f58-41c9-ae4b-1d57b249c45a"; 29 $uuid = "e53858c3-a97e-4b07-85e9-524257909f45";
30 30
31 $answer = send_cmd('UNIT GET '.$uuid); 31 $answer = send_cmd('UNIT GET '.$uuid);
32 $arr = explode("\r\n", $answer); 32 $arr = explode("\r\n", $answer);
33 33
34 $air_temperature = "NA"; 34 $air_temperature = "NA";
37 $beer_state = "NA"; 37 $beer_state = "NA";
38 $chiller_temperature = "NA"; 38 $chiller_temperature = "NA";
39 $chiller_state = "NA"; 39 $chiller_state = "NA";
40 $target_temperature_lo = "NA"; 40 $target_temperature_lo = "NA";
41 $target_temperature_hi = "NA"; 41 $target_temperature_hi = "NA";
42 $led1 = $led2 = $led3 = $sw1 = $sw2 = $sw3 = ""; 42 $led1 = $led2 = $led3 = $sw1 = $sw2 = $sw3 = $alarmled = "";
43 $fridge_set = "NA"; 43 $fridge_set = "NA";
44 $beer_set = "NA"; 44 $beer_set = "NA";
45 $heater = $cooler = $chiller = $fan = $psu = $door = "no"; 45 $heater = $cooler = $chiller = $fan = $psu = $door = "no";
46 $prof_state = "OFF"; 46 $prof_state = "OFF";
47 $mode = "NA"; 47 $mode = "NA";
48 $cooler_state = "NA"; 48 $cooler_state = "NA";
49 $heater_state = "NA"; 49 $heater_state = "NA";
50 $fan_state = "NA"; 50 $fan_state = "NA";
51 51
52
53 if (startsWith($arr[0], "213")) { 52 if (startsWith($arr[0], "213")) {
54 $j = 1; 53 $j = 1;
55 while (1) { 54 while (1) {
56 if (strcmp($arr[$j], ".") == 0) 55 if (strcmp($arr[$j], ".") == 0)
57 break; 56 break;
58 $f = explode(",", $arr[$j]); 57 $f = explode(",", $arr[$j]);
59 58
60 if ($f[0] == "AIR_STATE") 59 if ($f[0] == "AIR_STATE")
61 $air_state = $f[1]; 60 $air_state = $f[1];
62 if (($f[0] == "AIR_TEMPERATURE") && ($air_state == "OK")) 61 if (($f[0] == "AIR_TEMPERATURE") && ($air_state == "OK"))
101 $target_temperature_lo = $f[1]; 100 $target_temperature_lo = $f[1];
102 if (($f[0] == "PROF_TARGET_HI") && ($mode == "PROFILE")) 101 if (($f[0] == "PROF_TARGET_HI") && ($mode == "PROFILE"))
103 $target_temperature_hi = $f[1]; 102 $target_temperature_hi = $f[1];
104 if (($f[0] == "PROF_STATE") && ($mode == "PROFILE")) 103 if (($f[0] == "PROF_STATE") && ($mode == "PROFILE"))
105 $prof_state = 'State: '.$f[1]; 104 $prof_state = 'State: '.$f[1];
105 if ($f[0] == "ALARM")
106 $alarmled = $f[1] ? '<div class="LEDred_on"></div>' : '<div class="LEDred_off"></div>';
106 $j++; 107 $j++;
107 } 108 }
108 } 109 }
109 110
110 111
158 'led2' => $led2, 159 'led2' => $led2,
159 'led3' => $led3, 160 'led3' => $led3,
160 'sw1' => $sw1, 161 'sw1' => $sw1,
161 'sw2' => $sw2, 162 'sw2' => $sw2,
162 'sw3' => $sw3, 163 'sw3' => $sw3,
163 'profile_state' => $prof_state 164 'profile_state' => $prof_state,
165 'alarm' => $alarmled
164 ); 166 );
165 167
166 168
167 echo json_encode($reply); 169 echo json_encode($reply);
168 ?> 170 ?>

mercurial