Hamburger Hamburger

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

1/HvcLightControl.py
2/HvcHCSR04ultrasonic.py
3/HvcPV.py
4/HvcMotorDriver.py
5/HvcRollerShutter.py
6/manGenMqttMap.py
7/HvcReadSPI.py
8/HvcMqtt.py
9/HvcTables.py
10/HvcMain.py
11/HvcSetGPIO.py
12/HvcWifiRelay.py
13/HvcOperationMode.py
14/HvcControl.py
15/HvcRaw2phys.py
16/HvcWeather.py
17/HvcOneWire.py
18/makeDoc.py
19/HvcFronius.py
20/EnergyManager.py
21/HvcSendI2C.py

php

1/HV_colorMap.php
2/HV_Admin_Login.php
3/HV_readOperationState.php
4/HV_setParameters.php
5/HV_config.php
6/EM_handleJSON.php
7/index.php
8/readFilenames.php
9/HV_restart.php
10/HV_moveGate.php
11/HV_showLog.php
12/HV_RollerShutter.php
13/EM_editParameter.php
14/HV_serviceLog.php
15/HV_H2Olevel.php
16/HV_TempCal.php
17/HV_Fronius.php
18/EM_plot.php
19/readNamedData.php
20/HV_composeH2Oplot.php
21/HVdoc.php
22/HV_showWeatherForecast.php
23/HV_showHouse.php

Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.