--- a/www-thermferm/liveview.php Thu Jan 10 16:33:42 2019 +0100 +++ b/www-thermferm/liveview.php Mon Jan 14 22:46:27 2019 +0100 @@ -1,6 +1,6 @@ <?php /***************************************************************************** - * Copyright (C) 2014-2018 + * Copyright (C) 2014-2019 * * Michiel Broek <mbroek at mbse dot eu> * @@ -42,7 +42,7 @@ $air_temperature = "NA"; $beer_temperature = "NA"; $chiller_temperature = "NA"; - $profile = ""; + $profile_uuid = $profile_name = ""; $producr_code = ""; $product_name = ""; $prof_state = "OFF"; @@ -51,6 +51,7 @@ $heater_state = $cooler_state = $fan_state = 0; foreach($arr as $l) { +// syslog(LOG_NOTICE, $l); $vals = explode(",", $l); if (strcmp($vals[0], "MODE") == 0) { $mode = $vals[1]; @@ -99,8 +100,11 @@ if (strcmp($vals[0], "FAN_STATE") == 0) { $fan_state = $vals[1]; } - if (strcmp($vals[0], "PROFILE") == 0) { - $profile = $vals[1]; + if (strcmp($vals[0], "PROFILE_UUID") == 0) { + $profile_uuid = $vals[1]; + } + if (strcmp($vals[0], "PROFILE_NAME") == 0) { + $profile_name = $vals[1]; } if (strcmp($vals[0], "PROF_STATE") == 0) { $prof_state = $vals[1]; @@ -275,69 +279,24 @@ $outstr .= ' </form>'.PHP_EOL; } if ($mode == "PROFILE") { - /* - * First, load a list with available profiles. - */ - $answer = send_cmd("PROFILE LIST"); - $reply = explode("\r\n", $answer); - - /* - * Show loaded profile. - */ - if ($profile == "(null)") { - $prof_name = "None"; - }else { - if (startsWith($reply[0], "212")) { - $i = 1; - while (1) { - if (strcmp($reply[$i], ".") == 0) - break; - $f = explode(",", $reply[$i]); - if ($f[0] == $profile) { - $prof_name = $f[1]; - break; - } - $i++; - } - } - } - $outstr .= ' <div style="color: blue; width: 148px; height: 23px; overflow: hidden;">Profile: '.$prof_name.'</div>'.PHP_EOL; + $outstr .= ' <div style="color: blue; width: 148px; height: 23px; overflow: hidden;">Profile: '.$profile_name.'</div>'.PHP_EOL; $outstr .= ' <div id="prof_state_'.$unr.'" style="color: blue; width: 148px; height: 23px; overflow: hidden;">State: '.$prof_state.'</div>'.PHP_EOL; $outstr .= ' <form id="set_profile_'.$unr.'" action="index.php" method="post">'.PHP_EOL; if ($prof_state == "OFF") { - $outstr .= ' <select name="SetProfile" style="width: 130px;">'.PHP_EOL; - $outstr .= ' <option value="">None</option>'.PHP_EOL; - if (startsWith($reply[0], "212")) { - $i = 1; - while (1) { - if (strcmp($reply[$i], ".") == 0) - break; - $f = explode(",", $reply[$i]); - if ($f[2] > 0) { - ($f[0] == $profile) ? $se = " selected" : $se = ""; - $outstr .= ' <option value="'.$f[0].'"'.$se.'>'.$f[1].'</option>'.PHP_EOL; - } - $i++; - } - } - $outstr .= ' </select>'.PHP_EOL; - $outstr .= ' <input type="submit" value="Set" name="key">'.PHP_EOL; - if ($profile != "(null)") + if ($profile_name != "") $outstr .= ' <input type="submit" value="Start" name="key">'.PHP_EOL; } else if (startsWith($prof_state, "RUN")) { - $outstr .= ' <input type="hidden" value="'.$profile.'" name="SetProfile">'.PHP_EOL; $outstr .= ' <input type="submit" value="Pause" name="key">'.PHP_EOL; $outstr .= ' <input type="submit" value="Abort" name="key">'.PHP_EOL; } else if ($prof_state == "PAUSE") { - $outstr .= ' <input type="hidden" value="'.$profile.'" name="SetProfile">'.PHP_EOL; $outstr .= ' <input type="submit" value="Resume" name="key">'.PHP_EOL; $outstr .= ' <input type="submit" value="Abort" name="key">'.PHP_EOL; } else if ($prof_state == "DONE") { - $outstr .= ' <input type="hidden" value="'.$profile.'" name="SetProfile">'.PHP_EOL; $outstr .= ' <input type="submit" value="Off" name="key">'.PHP_EOL; } + $outstr .= ' <input type="hidden" value="'.$profile_uuid.'" name="SetProfile">'.PHP_EOL; // Only to select the right form. $outstr .= ' <input type="hidden" value="'.$unit.'" name="UUID">'.PHP_EOL; $outstr .= ' </form>'.PHP_EOL; }