diff -r 13555c27b592 -r 5b6d7b640e52 www-thermferm/liveview.php --- a/www-thermferm/liveview.php Thu Apr 25 14:26:47 2024 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,431 +0,0 @@ - - * - * This file is part of ThermFerm - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * ThermFerm is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ThermFerm; see the file COPYING. If not, write to the Free - * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - *****************************************************************************/ - - -require_once('utilities.php'); - - - -function showunit($unit, $unr, $alias) -{ - global $my_style; - - $outstr = ' ' . PHP_EOL; - $air_state = $beer_state = $chiller_state = 1; - $answer = send_cmd("UNIT GET ".$unit); - $arr = explode("\r\n", $answer); - - if (startsWith($arr[0], "213")) { - - $set_temperature_lo = "NA"; - $set_temperature_hi = "NA"; - $air_temperature = "NA"; - $beer_temperature = "NA"; - $chiller_temperature = "NA"; - $profile_uuid = $profile_name = ""; - $producr_code = ""; - $product_name = ""; - $prof_state = "OFF"; - $power_led = $alarm_led = $cooler_led = $heater_led = $fan_led = "off"; - $heater = $cooler = $fan = "no"; - $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]; - if (strcmp($mode, "OFF")) - $power_led = "on"; - } - if (strcmp($vals[0], "PRODUCT_CODE") == 0) { - $product_code = $vals[1]; - } - if (strcmp($vals[0], "PRODUCT_NAME") == 0) { - $product_name = $vals[1]; - } - if (strcmp($vals[0], "AIR_STATE") == 0) { - $air_state = $vals[1]; - } - if ((strcmp($vals[0], "AIR_TEMPERATURE") == 0) && (strcmp($air_state, "YES") == 0)) { - $air_temperature = $vals[1]; - } - if (strcmp($vals[0], "BEER_STATE") == 0) { - $beer_state = $vals[1]; - } - if ((strcmp($vals[0], "BEER_TEMPERATURE") == 0) && ($beer_state == 0)) { - $beer_temperature = $vals[1]; - } - if (strcmp($vals[0], "CHILLER_STATE") == 0) { - $chiller_state = $vals[1]; - } - if ((strcmp($vals[0], "CHILLER_TEMPERATURE") == 0) && ($chiller_state == 0)) { - $chiller_temperature = $vals[1]; - } - if ((strcmp($vals[0], "HEATER_ADDRESS") == 0) && (strcmp($vals[1], "(null)"))) { - $heater = "yes"; - } - if (strcmp($vals[0], "HEATER_STATE") == 0) { - $heater_state = $vals[1]; - } - if ((strcmp($vals[0], "COOLER_ADDRESS") == 0) && (strcmp($vals[1], "(null)"))) { - $cooler = "yes"; - } - if (strcmp($vals[0], "COOLER_STATE") == 0) { - $cooler_state = $vals[1]; - } - if ((strcmp($vals[0], "FAN_ADDRESS") == 0) && (strcmp($vals[1], "(null)"))) { - $fan = "yes"; - } - if (strcmp($vals[0], "FAN_STATE") == 0) { - $fan_state = $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]; - } - if (($vals[0] == "BEER_SET_LO") && ($mode == "BEER")) { - $set_temperature_lo = $vals[1]; - } - if (($vals[0] == "BEER_SET_HI") && ($mode == "BEER")) { - $set_temperature_hi = $vals[1]; - } - if (($vals[0] == "FRIDGE_SET_LO") && ($mode == "FRIDGE")) { - $set_temperature_lo = $vals[1]; - } - if (($vals[0] == "FRIDGE_SET_HI") && ($mode == "FRIDGE")) { - $set_temperature_hi = $vals[1]; - } - if (($vals[0] == "PROF_TARGET_LO") && ($mode == "PROFILE")) { - $set_temperature_lo = $vals[1]; - } - if (($vals[0] == "PROF_TARGET_HI") && ($mode == "PROFILE")) { - $set_temperature_hi = $vals[1]; - } - } - - $logname = $product_code . " " . $product_name; - $outstr .= ' '.PHP_EOL; - - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - if (("$air_state" == "YES") && ("$beer_state" == "YES") && ("$chiller_state" == "YES")) { - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - } else if (("$air_state" == "YES") && ("$beer_state" == "YES")) { - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - } else if ("$air_state" == "YES") { - $outstr .= '
'.PHP_EOL; - } - $outstr .= '
'.PHP_EOL; - - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - strcmp($mode, "OFF") ? $se = "" : $se = " checked"; - $outstr .= ' Off
'.PHP_EOL; - strcmp($mode, "NONE") ? $se = "" : $se = " checked"; - $outstr .= ' None
'.PHP_EOL; - (strcmp($heater, "no") || strcmp($cooler, "no")) ? $dis = "" : $dis = " disabled"; - strcmp($mode, "FRIDGE") ? $se = "" : $se = " checked"; - $outstr .= ' Fridge
'.PHP_EOL; - strcmp($mode, "BEER") ? $se = "" : $se = " checked"; - $outstr .= ' Beer
'.PHP_EOL; - strcmp($mode, "PROFILE") ? $se = "" : $se = " checked"; - $outstr .= ' Profile'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - - $outstr .= '
'.PHP_EOL; - $outstr .= '
Alm'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
Pwr'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - - $outstr .= '
'.PHP_EOL; - if ($mode == "FRIDGE") { - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= '
'.PHP_EOL; - } - if ($mode == "BEER") { - $outstr .= '
'.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= '
'.PHP_EOL; - } - if ($mode == "PROFILE") { - $outstr .= '
Profile: '.$profile_name.'
'.PHP_EOL; - $outstr .= '
State: '.$prof_state.'
'.PHP_EOL; - - $outstr .= '
'.PHP_EOL; - if ($prof_state == "OFF") { - if ($profile_name != "") - $outstr .= ' '.PHP_EOL; - - } else if (startsWith($prof_state, "RUN")) { - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - } else if ($prof_state == "PAUSE") { - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - } else if ($prof_state == "DONE") { - $outstr .= ' '.PHP_EOL; - } - $outstr .= ' '.PHP_EOL; // Only to select the right form. - $outstr .= ' '.PHP_EOL; - $outstr .= '
'.PHP_EOL; - } - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.$set_temperature_hi.'
'.PHP_EOL; - $outstr .= '
'.$set_temperature_lo.'
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.$air_temperature.'
Air'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.$beer_temperature.'
Beer'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - - $outstr .= '
'.PHP_EOL; - if ($cooler_state) - $cooler_led = "on"; - $outstr .= '
'.PHP_EOL; - $outstr .= '
Cool'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - if ($heater_state) - $heater_led = "on"; - $outstr .= '
'.PHP_EOL; - $outstr .= '
Heat'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - if ($fan_state) - $fan_led = "on"; - $outstr .= '
'.PHP_EOL; - $outstr .= '
Fan'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - (($mode == "NONE") && ($cooler == "yes")) ? $dis = "" : $dis = " disabled"; - ($cooler_state == "0") ? $ch = " checked" : $ch = ""; - $outstr .= '
'.PHP_EOL; - $outstr .= ' Off
'.PHP_EOL; - ($cooler_state == "100") ? $ch = " checked" : $ch = ""; - $outstr .= ' On'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - (($mode == "NONE") && ($heater == "yes")) ? $dis = "" : $dis = " disabled"; - ($heater_state == "0") ? $ch = " checked" : $ch = ""; - $outstr .= '
'.PHP_EOL; - $outstr .= ' Off
'.PHP_EOL; - ($heater_state == "100") ? $ch = " checked" : $ch = ""; - $outstr .= ' On'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - (($mode == "NONE") && ($fan== "yes")) ? $dis = "" : $dis = " disabled"; - ($fan_state == "0") ? $ch = " checked" : $ch = ""; - $outstr .= '
'.PHP_EOL; - $outstr .= ' Off
'.PHP_EOL; - ($fan_state == "100") ? $ch = " checked" : $ch = ""; - $outstr .= ' On'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - - $outstr .= '
'.PHP_EOL; - } - - return $outstr; -} - - - -function liveview() -{ - $outstr = PHP_EOL; - - $answer = send_cmd("LIST"); - if (strlen($answer)) { - $arr = explode("\r\n", $answer); - - $outstr .= '
'.PHP_EOL; - $outstr .= ' '.PHP_EOL; - - if (startsWith($arr[0], "212")) { - $i = 1; - while (1) { - if (strcmp($arr[$i], ".") == 0) - break; - $parts = explode(",", $arr[$i]); - $outstr .= showunit($parts[0], $i, $parts[1]); - $i++; - } - } - $outstr .= '
'.PHP_EOL; - } - - return $outstr; -} - - -?>