Heating and Ventilation Control
/EM_editParameter
Keine Erläuterungen gefunden.
<?php include_once "EM_handleJSON.php"; function editParameter($file){ $dict = readJSON($file); $parameter = dict2param($dict); $keys = array_keys($parameter); $inputType = "number"; $html = "<form action='?what2do=writeParameter' method='POST'>\n"; $html.= "<table>\n"; for($p=0;$p<count($parameter);$p++){ if($p/2.0==floor($p/2)){ $bg = "class='dark formField'"; }else{ $bg = "class='light formField'"; } if(strpos($keys[$p],"Light")>0){ $html.= "<tr><td colspan='3' style='column-span:all; background-color:yellow;'><em>Lichtsteuerung</em></td></tr>\n"; } if(strpos("_".$keys[$p],"shutterOpen")>0){ $html.= "<tr><td colspan='3' style='column-span:all; background-color:yellow;'><em>Rolladensteuerung</em></td></tr>\n"; } if(strpos($keys[$p],"Time")>0){ $inputType = "time"; }else{ $inputType = "number' step='any"; } $html.= "<tr><td ".$bg.">".$keys[$p]."</td>"; $html.= "<td ".$bg."><input class='formField' type='".$inputType."' value='".$parameter[$keys[$p]]."' name='".$keys[$p]."' /></td><td ".$bg."> </td><tr/>\n"; } $html.= "<tr><td> </td><td><input class='formField' type='submit' value='submit'></td><td> </td><tr/>\n"; $html.= "</table>\n"; $html.= "</form>\n"; return $html; } function postParameter($parameter){ $parNames = array_keys($parameter); for($p=0;$p<count($parNames);$p++){ $parameter[$parNames[$p]] = str_replace(",",".", $_POST[$parNames[$p]]); } #print_r($parameter); return $parameter; } function writeParameter($parameter,$parFile){ $parStr = "{"; $parNames = array_keys($parameter); for($p=0;$p<count($parNames);$p++){ if($p>0){$parStr.=", ";} if(is_numeric($parameter[$parNames[$p]])){ $parStr.= "\"".$parNames[$p]."\": ".$parameter[$parNames[$p]]; }else{ $parStr.= "\"".$parNames[$p]."\": \"".$parameter[$parNames[$p]]."\""; } } $parStr.= "}"; #echo $parStr; $pid = fopen($parFile,"w"); fputs($pid,$parStr); fclose($pid); $html = "<h2>Parameter geschrieben.</h2>"; return $html; } function HV_showSwitches($opMod){ $switchPos = array("on", "auto", "off"); $switches = array_keys($opMod); $form = "<form action='?what2do=writeOpMode' method='POST'>\n"; $form.= "<table class='color'>\n"; $kk=-1; for($k=0;$k<count($switches);$k++){ if($switches[$k]!="opMod"){ $kk++; if(0.5*$kk==floor($kk/2)){ $bg = " class='dark formField'"; }else{ $bg = " class='light formField'"; } $form.= "<tr><td".$bg.">".$switches[$k]."</td>"; for($s=0;$s<count($switchPos);$s++){ if($opMod[$switches[$k]]==$switchPos[$s]){ if($switchPos[$s]=="on"){ $extraStyle = " style='color:black; background-color:lime;'"; }elseif($switchPos[$s]=="auto"){ $extraStyle = " style='color:black; background-color:yellow;'"; }elseif($switchPos[$s]=="off"){ $extraStyle = " style='color:black; background-color:red;'"; } #fi }else{ $extraStyle = ""; } $form.= "<td".$bg."><input class='formField'".$extraStyle."type='submit' name='".$switches[$k]."' value='".$switchPos[$s]."'></td>"; } #s $form.= "</tr>\n"; } #fi } #k $form.= "</table>\n"; $form.= "</form>\n"; return $form; } ?>
python
php
Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.