Mon, 15 Apr 2024 17:04:57 +0200
Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
<?php /***************************************************************************** * Copyright (C) 2014-2019 * * Michiel Broek <mbroek at mbse dot eu> * * 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 = ' <!-- showunit(' . $unit . ', ' . $unr . ', ' . $alias . ') -->' . 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) && ($air_state == 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 .= ' <script type="text/javascript">'.PHP_EOL; $outstr .= ' $(document).ready(function () {'.PHP_EOL; if ("$air_state" == "OK") { $outstr .= ' $("#gaugeContainer_air'.$unr.'").jqxGauge({'.PHP_EOL; $outstr .= ' min: -5, max: 45, width: 275, height: 275,'.PHP_EOL; $outstr .= ' ranges: [{ startValue: -5, endValue: 0, style: { fill: \'#3399FF\', stroke: \'#3399FF\' }, endWidth: 10, startWidth: 10 },'.PHP_EOL; $outstr .= ' { startValue: 0, endValue: 16, style: { fill: \'#00CC33\', stroke: \'#00CC33\' }, endWidth: 10, startWidth: 10 },'.PHP_EOL; $outstr .= ' { startValue: 16, endValue: 24, style: { fill: \'#FCA76A\', stroke: \'#FCA76A\' }, endWidth: 10, startWidth: 10 },'.PHP_EOL; $outstr .= ' { startValue: 24, endValue: 45, style: { fill: \'#FC6A6A\', stroke: \'#FC6A6A\' }, endWidth: 10, startWidth: 10 }],'.PHP_EOL; $outstr .= ' ticksMinor: { interval: 1, size: \'5%\' },'.PHP_EOL; $outstr .= ' ticksMajor: { interval: 5, size: \'9%\' },'.PHP_EOL; $outstr .= ' labels: { interval: 5 },'.PHP_EOL; $outstr .= ' value: '.$air_temperature.','.PHP_EOL; $outstr .= ' colorScheme: \'scheme05\','.PHP_EOL; $outstr .= ' animationDuration: 5000,'.PHP_EOL; $outstr .= ' caption: { value: \'Air\', position: \'bottom\', offset: [0, 10] }'.PHP_EOL; $outstr .= ' });'.PHP_EOL; } if ("$beer_state" == "OK") { $outstr .= ' $(\'#gaugeContainer_beer'.$unr.'\').jqxGauge({'.PHP_EOL; $outstr .= ' min: -5, max: 45, width: 275, height: 275,'.PHP_EOL; $outstr .= ' ranges: [{ startValue: -5, endValue: 0, style: { fill: \'#3399FF\', stroke: \'#3399FF\' }, endWidth: 10, startWidth: 10 },'.PHP_EOL; $outstr .= ' { startValue: 0, endValue: 16, style: { fill: \'#00CC33\', stroke: \'#00CC33\' }, endWidth: 10, startWidth: 10 },'.PHP_EOL; $outstr .= ' { startValue: 16, endValue: 24, style: { fill: \'#FCA76A\', stroke: \'#FCA76A\' }, endWidth: 10, startWidth: 10 },'.PHP_EOL; $outstr .= ' { startValue: 24, endValue: 45, style: { fill: \'#FC6A6A\', stroke: \'#FC6A6A\' }, endWidth: 10, startWidth: 10 }],'.PHP_EOL; $outstr .= ' ticksMinor: { interval: 1, size: \'5%\' },'.PHP_EOL; $outstr .= ' ticksMajor: { interval: 5, size: \'9%\' },'.PHP_EOL; $outstr .= ' labels: { interval: 5 },'.PHP_EOL; $outstr .= ' value: '.$beer_temperature.','.PHP_EOL; $outstr .= ' colorScheme: \'scheme05\','.PHP_EOL; $outstr .= ' animationDuration: 5000,'.PHP_EOL; $outstr .= ' caption: { value: \'Beer\', position: \'bottom\', offset: [0, 10] }'.PHP_EOL; $outstr .= ' });'.PHP_EOL; } if ("$chiller_state" == "OK") { $outstr .= ' $(\'#gaugeContainer_chiller'.$unr.'\').jqxGauge({'.PHP_EOL; $outstr .= ' min: -20, max: 25, width: 150, height: 150,'.PHP_EOL; $outstr .= ' ranges: [{ startValue: -20, endValue: 0, startWidth: 5, endWidth: 5, style: { fill: \'#3399FF\', stroke: \'#3399FF\' }},'.PHP_EOL; $outstr .= ' { startValue: 0, endValue: 25, startWidth: 5, endWidth: 5, style: { fill: \'#FC6A6A\', stroke: \'#FC6A6A\' }}],'.PHP_EOL; $outstr .= ' ticksMinor: { interval: 1, size: \'5%\' },'.PHP_EOL; $outstr .= ' ticksMajor: { interval: 5, size: \'9%\' },'.PHP_EOL; $outstr .= ' labels: { interval: 5 },'.PHP_EOL; $outstr .= ' value: '.$chiller_temperature.','.PHP_EOL; $outstr .= ' colorScheme: \'scheme05\','.PHP_EOL; $outstr .= ' animationDuration: 5000,'.PHP_EOL; $outstr .= ' caption: { value: \'Chiller\', position: \'bottom\', offset: [0, 10] }'.PHP_EOL; $outstr .= ' });'.PHP_EOL; } $outstr .= ' setInterval(function(){'.PHP_EOL; $outstr .= ' $.getJSON("getstate.php?uuid='.$unit.'", function(data) {'.PHP_EOL; if ("$air_state" == "OK") { $outstr .= ' $("#load_air_'.$unr.'").html(data.air_temperature);'.PHP_EOL; $outstr .= ' $("#gaugeContainer_air'.$unr.'").jqxGauge(\'value\', data.air_temperature);'.PHP_EOL; } if ("$beer_state" == "OK") { $outstr .= ' $("#load_beer_'.$unr.'").html(data.beer_temperature);'.PHP_EOL; $outstr .= ' $("#gaugeContainer_beer'.$unr.'").jqxGauge(\'value\', data.beer_temperature);'.PHP_EOL; } if ("$chiller_state" == "OK") { $outstr .= ' $("#gaugeContainer_chiller'.$unr.'").jqxGauge(\'value\', data.chiller_temperature);'.PHP_EOL; } $outstr .= ' $("#load_target_lo_'.$unr.'").html(data.target_temperature_lo);'.PHP_EOL; $outstr .= ' $("#load_target_hi_'.$unr.'").html(data.target_temperature_hi);'.PHP_EOL; $outstr .= ' $("#load_select_'.$unr.'").html(data.mode);'.PHP_EOL; $outstr .= ' $("#load_led1_'.$unr.'").html(data.led1);'.PHP_EOL; $outstr .= ' $("#load_led2_'.$unr.'").html(data.led2);'.PHP_EOL; $outstr .= ' $("#load_led3_'.$unr.'").html(data.led3);'.PHP_EOL; $outstr .= ' $("#load_sw1_'.$unr.'").html(data.sw1);'.PHP_EOL; $outstr .= ' $("#load_sw2_'.$unr.'").html(data.sw2);'.PHP_EOL; $outstr .= ' $("#load_sw3_'.$unr.'").html(data.sw3);'.PHP_EOL; if ($mode == "PROFILE") $outstr .= ' $("#prof_state_'.$unr.'").html(data.profile_state);'.PHP_EOL; $outstr .= ' $("#load_alarm_'.$unr.'").html(data.alarm);'.PHP_EOL; $outstr .= ' });'.PHP_EOL; $outstr .= ' }, 10000);'.PHP_EOL; /* * Tooltips */ $outstr .= ' $("#load_air_'.$unr.'").jqxTooltip({ content: "The measured air temperature.", theme: "'.$my_style.'" });'.PHP_EOL; $outstr .= ' $("#load_beer_'.$unr.'").jqxTooltip({ content: "The measured beer temperature.", theme: "'.$my_style.'" });'.PHP_EOL; $outstr .= ' $("#load_target_lo_'.$unr.'").jqxTooltip({ content: "The target low temperature.", theme: "'.$my_style.'" });'.PHP_EOL; $outstr .= ' $("#load_target_hi_'.$unr.'").jqxTooltip({ content: "The target high temperature.", theme: "'.$my_style.'" });'.PHP_EOL; $outstr .= ' $("#load_select_'.$unr.'").jqxTooltip({ content: "Select unit mode.", theme: "'.$my_style.'" });'.PHP_EOL; if (($mode == "NONE") && ($cooler == "yes")) $outstr .= ' $("#load_sw1_'.$unr.'").jqxTooltip({ content: "Manual control cooler.", theme: "'.$my_style.'" });'.PHP_EOL; if (($mode == "NONE") && ($heater == "yes")) $outstr .= ' $("#load_sw2_'.$unr.'").jqxTooltip({ content: "Manual control heater.", theme: "'.$my_style.'" });'.PHP_EOL; if (($mode == "NONE") && ($fan== "yes")) $outstr .= ' $("#load_sw3_'.$unr.'").jqxTooltip({ content: "Manual control fan.", theme: "'.$my_style.'" });'.PHP_EOL; $outstr .= ' });'.PHP_EOL; $outstr .= ' </script>'.PHP_EOL; $outstr .= ' <div id="fermentor">'.PHP_EOL; $outstr .= ' <div id="fermentor_thermometers">'.PHP_EOL; if (("$air_state" == "OK") && ("$beer_state" == "OK") && ("$chiller_state" == "OK")) { $outstr .= ' <div id="gaugeContainer_air'.$unr.'" style="float: left; margin-top: 10px; margin-left: 10px;"></div>'.PHP_EOL; $outstr .= ' <div id="gaugeContainer_beer'.$unr.'" style="float: right; margin-top: 10px; margin-right: 10px;"></div>'.PHP_EOL; $outstr .= ' <div id="gaugeContainer_chiller'.$unr.'" style="float: left; margin-top: 200px;"></div>'.PHP_EOL; } else if (("$air_state" == "OK") && ("$beer_state" == "OK")) { $outstr .= ' <div id="gaugeContainer_air'.$unr.'" style="float: left; margin-top: 48px; margin-left: 48px;"></div>'.PHP_EOL; $outstr .= ' <div id="gaugeContainer_beer'.$unr.'" style="float: right; margin-top: 48px; margin-right: 48px;"></div>'.PHP_EOL; } else if ("$air_state" == "OK") { $outstr .= ' <div id="gaugeContainer_air'.$unr.'" style="margin-top: 48px; margin-left: 222px;"></div>'.PHP_EOL; } $outstr .= ' </div>'.PHP_EOL; $outstr .= ' <div id="fermentor_panel_top">'.PHP_EOL; $outstr .= ' <div id="fermentor_selector">'.PHP_EOL; $outstr .= ' <form id="select_'.$unr.'" action="index.php" method="post">'.PHP_EOL; $outstr .= ' <div id="load_select_'.$unr.'">'.PHP_EOL; strcmp($mode, "OFF") ? $se = "" : $se = " checked"; $outstr .= ' <input type="radio" name="mode" onchange="this.form.submit()" class="select" value="OFF"'.$se.'>Off<br>'.PHP_EOL; strcmp($mode, "NONE") ? $se = "" : $se = " checked"; $outstr .= ' <input type="radio" name="mode" onchange="this.form.submit()" class="select" value="NONE"'.$se.'>None<br>'.PHP_EOL; (strcmp($heater, "no") || strcmp($cooler, "no")) ? $dis = "" : $dis = " disabled"; strcmp($mode, "FRIDGE") ? $se = "" : $se = " checked"; $outstr .= ' <input type="radio" name="mode" onchange="this.form.submit()" class="select" value="FRIDGE"'.$se.$dis.'>Fridge<br>'.PHP_EOL; strcmp($mode, "BEER") ? $se = "" : $se = " checked"; $outstr .= ' <input type="radio" name="mode" onchange="this.form.submit()" class="select" value="BEER"'.$se.$dis.'>Beer<br>'.PHP_EOL; strcmp($mode, "PROFILE") ? $se = "" : $se = " checked"; $outstr .= ' <input type="radio" name="mode" onchange="this.form.submit()" class="select" value="PROFILE"'.$se.$dis.'>Profile'.PHP_EOL; $outstr .= ' </div>'.PHP_EOL; $outstr .= ' <input type="hidden" name="UUID" value="'.$unit.'">'.PHP_EOL; $outstr .= ' </form>'.PHP_EOL; $outstr .= ' </div>'.PHP_EOL; $outstr .= ' <div id="fermentor_alarmled">'.PHP_EOL; $outstr .= ' <div id="load_alarm_'.$unr.'"><div class="LEDred_'.$alarm_led.'"></div></div>Alm'.PHP_EOL; $outstr .= ' </div>'.PHP_EOL; $outstr .= ' <div id="fermentor_powerled">'.PHP_EOL; $outstr .= ' <div class="LEDblue_'.$power_led.'"></div>Pwr'.PHP_EOL; $outstr .= ' </div>'.PHP_EOL; $outstr .= ' <div id="fermentor_mode_control">'.PHP_EOL; if ($mode == "FRIDGE") { $outstr .= ' <form id="set_fridge_'.$unr.'" action="index.php" method="post">'.PHP_EOL; $outstr .= ' <input type="text" name="Fridge_lo" size="5" value="'.$set_temperature_lo.'"><br>'.PHP_EOL; $outstr .= ' <input type="text" name="Fridge_hi" size="5" value="'.$set_temperature_hi.'"><br>'.PHP_EOL; $outstr .= ' <input type="submit" value="Set" name="key">'.PHP_EOL; $outstr .= ' <input type="hidden" value="'.$unit.'" name="UUID">'.PHP_EOL; $outstr .= ' </form>'.PHP_EOL; } if ($mode == "BEER") { $outstr .= ' <form id="set_beer_'.$unr.'" action="index.php" method="post">'.PHP_EOL; $outstr .= ' <input type="text" name="Beer_lo" size="5" value="'.$set_temperature_lo.'">'.PHP_EOL; $outstr .= ' <input type="text" name="Beer_hi" size="5" value="'.$set_temperature_hi.'">'.PHP_EOL; $outstr .= ' <input type="submit" value="Set" name="key">'.PHP_EOL; $outstr .= ' <input type="hidden" value="'.$unit.'" name="UUID">'.PHP_EOL; $outstr .= ' </form>'.PHP_EOL; } if ($mode == "PROFILE") { $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") { if ($profile_name != "") $outstr .= ' <input type="submit" value="Start" name="key">'.PHP_EOL; } else if (startsWith($prof_state, "RUN")) { $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="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="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; } $outstr .= ' </div>'.PHP_EOL; $outstr .= ' </div> <!-- fermentor_panel_top -->'.PHP_EOL; $outstr .= ' <div id="fermentor_panel_display">'.PHP_EOL; $outstr .= ' <div id="fermentor_display1">'.PHP_EOL; $outstr .= ' <div id="load_target_hi_'.$unr.'" class="htemp">'.$set_temperature_hi.'</div>'.PHP_EOL; $outstr .= ' <div id="load_target_lo_'.$unr.'" class="ltemp">'.$set_temperature_lo.'</div>'.PHP_EOL; $outstr .= ' </div>'.PHP_EOL; $outstr .= ' <div id="fermentor_display2">'.PHP_EOL; $outstr .= ' <div id="load_air_'.$unr.'" class="dtemp">'.$air_temperature.'</div>Air'.PHP_EOL; $outstr .= ' </div>'.PHP_EOL; $outstr .= ' <div id="fermentor_display3">'.PHP_EOL; $outstr .= ' <div id="load_beer_'.$unr.'" class="dtemp">'.$beer_temperature.'</div>Beer'.PHP_EOL; $outstr .= ' </div>'.PHP_EOL; $outstr .= ' </div> <!-- fermentor_panel_display -->'.PHP_EOL; $outstr .= ' <div id="fermentor_panel_control">'.PHP_EOL; if ($cooler_state) $cooler_led = "on"; $outstr .= ' <div id="fermentor_led1">'.PHP_EOL; $outstr .= ' <div id="load_led1_'.$unr.'"><div class="LEDgreen_'.$cooler_led.'"></div></div>Cool'.PHP_EOL; $outstr .= ' </div>'.PHP_EOL; if ($heater_state) $heater_led = "on"; $outstr .= ' <div id="fermentor_led2">'.PHP_EOL; $outstr .= ' <div id="load_led2_'.$unr.'"><div class="LEDgreen_'.$heater_led.'"></div></div>Heat'.PHP_EOL; $outstr .= ' </div>'.PHP_EOL; if ($fan_state) $fan_led = "on"; $outstr .= ' <div id="fermentor_led3">'.PHP_EOL; $outstr .= ' <div id="load_led3_'.$unr.'"><div class="LEDgreen_'.$fan_led.'"></div></div>Fan'.PHP_EOL; $outstr .= ' </div>'.PHP_EOL; $outstr .= ' <div id="fermentor_toggle1">'.PHP_EOL; $outstr .= ' <form action="index.php" method="post">'.PHP_EOL; (($mode == "NONE") && ($cooler == "yes")) ? $dis = "" : $dis = " disabled"; ($cooler_state == "0") ? $ch = " checked" : $ch = ""; $outstr .= ' <div id="load_sw1_'.$unr.'">'.PHP_EOL; $outstr .= ' <input type="radio" name="CoolerState" onchange="this.form.submit()" value="0"'.$dis.$ch.'>Off<br>'.PHP_EOL; ($cooler_state == "100") ? $ch = " checked" : $ch = ""; $outstr .= ' <input type="radio" name="CoolerState" onchange="this.form.submit()" value="100"'.$dis.$ch.'>On'.PHP_EOL; $outstr .= ' </div>'.PHP_EOL; $outstr .= ' <input type="hidden" name="UUID" value="'.$unit.'">'.PHP_EOL; $outstr .= ' </form>'.PHP_EOL; $outstr .= ' </div>'.PHP_EOL; $outstr .= ' <div id="fermentor_toggle2">'.PHP_EOL; $outstr .= ' <form action="index.php" method="post">'.PHP_EOL; (($mode == "NONE") && ($heater == "yes")) ? $dis = "" : $dis = " disabled"; ($heater_state == "0") ? $ch = " checked" : $ch = ""; $outstr .= ' <div id="load_sw2_'.$unr.'">'.PHP_EOL; $outstr .= ' <input type="radio" name="HeaterState" onchange="this.form.submit()" value="0"'.$dis.$ch.'>Off<br>'.PHP_EOL; ($heater_state == "100") ? $ch = " checked" : $ch = ""; $outstr .= ' <input type="radio" name="HeaterState" onchange="this.form.submit()" value="100"'.$dis.$ch.'>On'.PHP_EOL; $outstr .= ' </div>'.PHP_EOL; $outstr .= ' <input type="hidden" name="UUID" value="'.$unit.'">'.PHP_EOL; $outstr .= ' </form>'.PHP_EOL; $outstr .= ' </div>'.PHP_EOL; $outstr .= ' <div id="fermentor_toggle3">'.PHP_EOL; $outstr .= ' <form action="index.php" method="post">'.PHP_EOL; (($mode == "NONE") && ($fan== "yes")) ? $dis = "" : $dis = " disabled"; ($fan_state == "0") ? $ch = " checked" : $ch = ""; $outstr .= ' <div id="load_sw3_'.$unr.'">'.PHP_EOL; $outstr .= ' <input type="radio" name="FanState" onchange="this.form.submit()" value="0"'.$dis.$ch.'>Off<br>'.PHP_EOL; ($fan_state == "100") ? $ch = " checked" : $ch = ""; $outstr .= ' <input type="radio" name="FanState" onchange="this.form.submit()" value="100"'.$dis.$ch.'>On'.PHP_EOL; $outstr .= ' </div>'.PHP_EOL; $outstr .= ' <input type="hidden" name="UUID" value="'.$unit.'">'.PHP_EOL; $outstr .= ' </form>'.PHP_EOL; $outstr .= ' </div>'.PHP_EOL; $outstr .= ' </div> <!-- fermentor_panel_control -->'.PHP_EOL; $outstr .= ' </div> <!-- fermentor -->'.PHP_EOL; } return $outstr; } function liveview() { $outstr = PHP_EOL; $answer = send_cmd("LIST"); if (strlen($answer)) { $arr = explode("\r\n", $answer); $outstr .= ' <div id="jqxTabs">'.PHP_EOL; $outstr .= ' <ul>'.PHP_EOL; if (startsWith($arr[0], "212")) { $i = 1; while (1) { if (strcmp($arr[$i], ".") == 0) break; $parts = explode(",", $arr[$i]); $outstr .= ' <li style="margin-left: 20px;">'.$parts[1].'</li>'.PHP_EOL; $i++; } } $outstr .= ' </ul>'.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 .= ' </div> <!-- jqxTabs -->'.PHP_EOL; } return $outstr; } ?>