Dr. Arne Jachens

Set up the Raspberry Pi

no warranty for any of the provided information

Keine Erläuterungen gefunden.

<?php 
/* published under GPL www.gnu.org/licenses/gpl.html */
function HV_showSwitches($opMod){
  include("HV_config.php");
  $menu = "<form action='?what2do=writeConfig' method='POST'>\n";
  $menu.= "<table border='0'>\n";
  $menu.= "<tr><td>Heizmodus:</td><td> </td>
           <td align='right'>Winter:   <input type='radio' name='opMod' value='winter'";
  if($opMod['opMod']=="winter"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right'>Sommer:   <input type='radio' name='opMod' value='summer'";
  if($opMod['opMod']=="summer"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td> </td><td align='right'>Urlaub <input type='radio' name='opMod' value='vacation'";
  if($opMod['opMod']=="vacation"){$menu.= "checked='checked'";}
  $menu.= "></td></tr>\n";

  $menu.= "<tr><td>Solar:</td>
           <td align='right'>ON   <input type='radio' name='stateSolar' value='on'";
  if($opMod['solar']=="on"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right'>OFF  <input type='radio' name='stateSolar' value='off'";
  if($opMod['solar']=="off"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right'>AUTO <input type='radio' name='stateSolar' value='auto'";
  if($opMod['solar']=="auto"){$menu.= "checked='checked'";}
  $menu.= "></td><td> </td><td> </td></tr>\n";

  $menu.= "<tr><td>Ofen:</td>
           <td align='right'>ON   <input type='radio' name='stateOven' value='on'";
  if($opMod['oven']=="on"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right'>OFF  <input type='radio' name='stateOven' value='off'";
  if($opMod['oven']=="off"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right'>AUTO <input type='radio' name='stateOven' value='auto'";
  if($opMod['oven']=="auto"){$menu.= "checked='checked'";}
  $menu.= "></td><td> </td><td> </td></tr>\n";

  $menu.= "<tr><td>Pumpe:</td>
           <td align='right'>ON   <input type='radio' name='statePump' value='on'";
  if($opMod['pump']=="on"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right'>OFF  <input type='radio' name='statePump' value='off'";
  if($opMod['pump']=="off"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right'>AUTO <input type='radio' name='statePump' value='auto'";
  if($opMod['pump']=="auto"){$menu.= "checked='checked'";}
  $menu.= "></td><td> </td></tr>\n";

/*
  $menu.= "<tr><td>Printer:</td>
           <td align='right'>ON   <input type='radio' name='stateServ' value='on'";
  if($opMod['']=="on"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right'>OFF  <input type='radio' name='stateServ' value='off'";
  if($opMod['']=="off"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right'>AUTO <input type='radio' name='stateServ' value='auto'";
  if($opMod['']=="auto"){$menu.= "checked='checked'";}
  $menu.= "></td><td> </td><td> </td></tr>\n";
*/

  $menu.= "<tr><td>Bypass:</td>
           <td align='right'>OPEN   <input type='radio' name='stateBP' value='open'";
  if($opMod['byPs']=="open"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right'>SHUT  <input type='radio' name='stateBP' value='shut'";
  if($opMod['byPs']=="shut"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right'>AUTO <input type='radio' name='stateBP' value='auto'";
  if($opMod['byPs']=="auto"){$menu.= "checked='checked'";}
  $menu.= "></td><td> </td></tr>\n";

  $menu.= "<tr><td>Lüftung:</td>
           <td align='right'>OFF   <input type='radio' name='stateVent' value='off'";
  if($opMod['vent']=="off"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right'>min  <input type='radio' name='stateVent' value='minimal'";
  if($opMod['vent']=="minimal"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right'>normal <input type='radio' name='stateVent' value='normal'";
  if($opMod['vent']=="normal"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right'>  max <input type='radio' name='stateVent' value='maximal'";
  if($opMod['vent']=="maximal"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right'>AUTO <input type='radio' name='stateVent' value='auto'";
  if($opMod['vent']=="auto"){$menu.= "checked='checked'";}
  $menu.= "></td></tr>\n";

  $menu.= "<tr><td colspan='4' align='center'><input type='submit' value='submit'></td></tr>\n";
  $menu.= "<tr><td colspan='4' align='center'> </td></tr>\n";
  $menu.= "</form>\n";
  return $menu;
}

function HV_writeConfig($confFile){
    $failCount=0;
    if(isset($_POST['stateSolar'])) {$opMod['solar'] = $_POST['stateSolar'];}else{$failcount++;}
    if(isset($_POST['stateOven']))  {$opMod['oven']  = $_POST['stateOven'];}else{$failcount++;}
    if(isset($_POST['statePump']))  {$opMod['pump']  = $_POST['statePump'];}else{$failcount++;}
    if(isset($_POST['stateVent']))  {$opMod['vent']  = $_POST['stateVent'];}else{$failcount++;}
    if(isset($_POST['stateBP']))    {$opMod['byPs']  = $_POST['stateBP'];}else{$failcount++;}
    if(isset($_POST['opMod']))      {$opMod['opMod'] = $_POST['opMod'];}else{$failcount++;}

    $keys = array_keys($opMod);
    $opModStr = "{";
    $opModStr .= "\"".$keys[0]."\": \"".$opMod[$keys[0]]."\"";
    for($o=1;$o<count($opMod);$o++){
        $opModStr .= ", \"".$keys[$o]."\": \"".$opMod[$keys[$o]]."\"";
    } #o
    $opModStr .= "}";

    if ($failCount==0){  
        $pf = fopen($confFile,"w");
        fputs($pf,$opModStr);
        fclose($pf);
    }else{
        echo "<p><b>Writing operation Mode failed!</b></p>";
    }
 }

function HV_editParameters($parFile){
    $parDesc["THausSoll"] = "Zieltemperatur unseres Hauses, wenn es in Marens Zimmer kälter ist, Schaltet die Heizung ein.";
    $parDesc["TOfenAn"] = "Speichertemperatur, bei der der Ofen eingeschaltet wird";
    $parDesc["TOfenAus"] = "Speichertemperatur, bei der der Ofen ausgeschaltet wird";
    $parDesc["DeltaTKollektor"] = "Soviel muss der Kollektor wärmer sein als der Speicher, damit die Solaranlage eingeschaltet wird";
    $parDesc["hourSolarOff"] = "ab dieser Stunde wird (im Winter) die Solaranlage nicht mehr eingeschaltet";
    $parDesc["ventMinimal"] = "Level Lüftungsansteuerung [0:1]";
    $parDesc["ventNormal"] = "Level Lüftungsansteuerung [0:1]";
    $parDesc["debug"] = "Setze <tt>debug=True</tt>, um zu sehen, wie die Skripte durchlaufen werden.";
    
    $parameters = HV_readParameters($parFile);
    
    $menu = "<form action='?what2do=writeParameters' method='POST'>\n";
    $menu.= "<table border='0'>\n";
    $keys = array_keys($parameters);
    for($k=0;$k<count($keys);$k++){
        $thisPar = $keys[$k];
        $menu.= "<tr><td>".$thisPar.":</td>";
        $menu.= "<td><input type='text' name='".$thisPar."' value='".$parameters[$thisPar]."' length='4'></td>";
        $menu.= "<td>".$parDesc[$thisPar]."</td></tr>";
        
    } #k

    $menu.= "<tr><td colspan='2' align='center'><input type='submit' name='' value='submit'></td>
<td><a href='?what2do=TempCal'>Temperatur Kalibrierung</a>
<a href='?what2do=HeatCal'>Steuerkurven</a></td></tr>\n";
    $menu.= "</table>\n";
    $menu.= "</form>\n";

  return $menu;


}

function HV_writeParameters($paramFile){
    global $debug;
    if($debug){
        echo "<p><aj>HV_writeParameters( )</aj>: ".$paramFile."</p>\n";
    }
    
    /* check for  available parameters */
    $parameters = HV_readParameters($paramFile);
    $keys = array_keys($parameters);
    
    /* POST values from form */
    $failcount=0;
    for($k=0;$k<count($keys);$k++){
        $thisPar = $keys[$k];
        if(isset($_POST[$thisPar])) {
            $parameters[$thisPar] = $_POST[$thisPar];
        }else{
            $failcount++;
            if($debug){echo "POST[".$thisPar."] did not work</br>";}
        }
    } #k
    if($parameters['debug']!=TRUE and $parameters['debug']!="True"){
        $debug = FALSE;
    }
        
    /* compose yml */
    $paramStr = "{";
    $paramStr .= "\"".$keys[0]."\": \"".$parameters[$keys[0]]."\"";
    for($o=1;$o<count($keys);$o++){
        $paramStr .= ", \"".$keys[$o]."\": \"".$parameters[$keys[$o]]."\"";
    } #o
    $paramStr .= "}";

    if ($failcount==0){  
        $pf = fopen($paramFile,"w");
        fputs($pf,$paramStr);
        fclose($pf);
    }else{
        if(!isset($_POST['opMod'])){
            echo "<p><b>Writing parameters failed!</b></p>";
        } #skip waring, when fallthrough from opMod
    }
    

    return "<p>parameters written</p>";
}

function HV_readParameters($parFile){
    global $debug;
    $fid = fopen($parFile,"r");
    $paramStr = trim(fgets($fid,2048));  
    fclose($fid);
    $paramStr = substr($paramStr,1);
    $paramStr = substr($paramStr,0,strlen($paramStr)-2);
    $paramStr = str_replace("\"","",$paramStr);
    $tmp = explode(",",$paramStr);
    for($m=0;$m<count($tmp);$m++){
        $thisM = explode(":",$tmp[$m]);
        $parameters[trim($thisM[0])] = trim($thisM[1]);
    } #m

    if($parameters['debug']!=TRUE and $parameters['debug']!="True"){
        $debug = FALSE;
    }
    if($debug){
        echo "<p><aj>HV_readParameters( )</aj></p>\n";
        print_r($parameters);
    }
    return $parameters;
}




?>

python

1HvcControl.py
2HvcHCSR04ultrasonic.py
3HvcMain.py
4HvcMotorDriver.py
5HvcOneWire.py
6HvcOperationMode.py
7HvcRaw2phys.py
8HvcReadSPI.py
9HvcSendI2C.py
10HvcSetGPIO.py
11HvcTables.py
12HvcWeather.py
13makeDoc.py

php

1HV_Admin_Login.php
2HV_colorMap.php
3HV_composeH2Oplot.php
4HV_config.php
5HV_H2Olevel.php
6HV_readOperationState.php
7HV_restart.php
8HV_serviceLog.php
9HV_setParameters.php
10HV_showHouse.php
11HV_showLog.php
12HV_showWeatherForecast.php
13HV_TempCal.php
14index.php
15readFilenames.php
16readNamedData.php

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