Dr. Arne Jachens

Set up the Raspberry Pi

no warranty for any of the provided information

To visualize the status of my building equipment I drew a SVG image using Inkscape. All colors and strings which will be used for indicating may occur only once in the image! For visualization the template is copied to a new name and than perl is used to replace the relevant items one by one...

Since there are 256 colors at least, it should be no problem to provide a specific color to each indicator. The used colors are given in the array $template and $Templ at the beginning of the script. Be carefull not to use any of the colors which are part of the HV_colorMap.

The state of the actuators is red to indicate 'off', green for 'on' or 'active' and yellow if automatic controls decides to 'deactivate' or 'auto off' the actuator.

example01 example01 example01

<?php 
/* published under GPL www.gnu.org/licenses/gpl.html */
function HV_showHouse($sens,$act,$opMod){
  include("HV_colorMap.php");
  /*
  print_r($sens); echo "<br>";
  print_r($act); echo "<br>";
  print_r($opMod); echo "<br>";
  */
  
  global $self;
  #set the markers as  in SVG
  $colorTmp["coll"]=" #d50000";
  $colorTmp["THot"]=" #d45500";
  $colorTmp["TLow"]=" #000081";
  $colorTmp["flow"]=" #009300";
  $colorTmp["ret"]="";
  $colorTmp["ret1"]=" #00d200";
  $colorTmp["ret2"]=" #bca1f6";
  $colorTmp["fire"]=" #bccccc";
  $colorTmp["solar"]=" #aa8800";
  $colorTmp["oven"]=" #dc9cff";
  $colorTmp["vent"]=" #123456";
  $colorTmp["pump"]=" #dc9c6a";
  $colorTmp["haus"]=" #123456";
  $colorTmp["serv"]=" #abcdef";
  $colorTmp["TAmb"]=" #0012e2";
  $colorTmp["Tpipe"]=" #11c9e2";
  $colorTmp["erde"]=" #36d71d";
  $colorTmp["zulu"]=" #ebf106";
  $colorTmp["ablu"]=" #f0a708";
  $colorTmp["folu"]=" #11257c";
  $colorTmp["Theat"]=" #d45511";
  $colorTmp["level"]="dummy";
  $colorTmp["bypa"]="dummy";
  $colorTmp["posBp"]=" #";
  $colorTmp["H2O"]=" #";
  $tempvent["vent1"]=" #d3c17c";
  $tempvent["vent2"]=" #d38d7c";
  $tempvent["vent3"]=" #d3257c";
  $strTmp["coll"]="Tcoll";
  $strTmp["THot"]="TtHot";
  $strTmp["TLow"]="TtLow";
  $strTmp["flow"]="Tflow";
  $strTmp["ret"] ="";
  $strTmp["ret1"] ="Tret1";
  $strTmp["ret2"] ="";
  $strTmp["fire"] ="Tfire";
  $strTmp["TAmb"] ="Tamb";
  $strTmp["Tpipe"]="";
  $strTmp["erde"]="Terde";
  $strTmp["zulu"]="Tzulu";
  $strTmp["ablu"]="Tablu";
  $strTmp["folu"]="Tfolu";
  $strTmp["haus"]="Thaus";
  $strTmp["Theat"]="Theat";
  $strTmp["posBp"]="foo";
  $strTmp["H2O"]="H2O";
  $sens['Tpipe']=0.5*($sens['TAmb']+$sens['erde']);
  /*
  if($act["pump"]>0){
    $sens['Theat']=$sens["THot"];
  }else{
    $sens['Theat']=$sens['zulu'];
  }
  */
  $sens['Theat']=$sens['walu'];
  $sens["ret1"]=$sens["ret"];
  $TroomSp = 23.1;
  if($sens["fire"]>$TroomSp+15 AND $act['oven']>0){
    $sens["ret2"]=$sens["THot"];
  }else{
    $sens["ret2"]=min($sens["THot"],$sens["fire"]);
  }

  /* use template */
  $cmd = "cp ./house.svg ./showHouse.svg";
  exec($cmd);
  /* set thermal colors of elements */
  $keys = array_keys($sens);
  for($k=0;$k<count($keys);$k++){
    if (isset($colorTmp[$keys[$k]])){
      list($bgc,$tc) = HV_colorMap($sens[$keys[$k]]);
        if(strlen($colorTmp[$keys[$k]])>5 AND strlen($bgc)>5){
      	  $cmd = "perl -pi -e 's/".$colorTmp[$keys[$k]]."/".$bgc."/g'  showHouse.svg";
      	  exec($cmd);
          /*
          if($keys[$k]=="Theat"){
              echo $sens['Theat']."<br>";
              echo $cmd."<p>";
          }
          */
        }
    }
  } #k
  /* set sensor values */
  for($k=0;$k<count($keys);$k++){
    if (isset($strTmp[$keys[$k]])){
      #echo $keys[$k]." ".$strTmp[$keys[$k]]." ".$sens[$keys[$k]]."<br>";
      if(strlen($strTmp[$keys[$k]])>2 AND strlen($sens[$keys[$k]])>2){
        $cmd = "perl -pi -e 's/".$strTmp[$keys[$k]]."/".$sens[$keys[$k]]."/g' showHouse.svg";
        exec($cmd);
      }
    } #fi
  } #k
  /* set color of vent level */
  $bgc=" #ff0000";
  $off=" #ffffff";
  if($act['vent']<=0){
    $cmd = "perl -pi -e 's/".$tempvent['vent1']."/".$off."/g'  showHouse.svg";
    exec($cmd);
    $cmd = "perl -pi -e 's/".$tempvent['vent2']."/".$off."/g'  showHouse.svg";
    exec($cmd);
    $cmd = "perl -pi -e 's/".$tempvent['vent3']."/".$off."/g'  showHouse.svg";
    exec($cmd);
  }elseif($act['vent']<=0.34){
    $cmd = "perl -pi -e 's/".$tempvent['vent1']."/".$bgc."/g'  showHouse.svg";
    exec($cmd);
    $cmd = "perl -pi -e 's/".$tempvent['vent2']."/".$off."/g'  showHouse.svg";
    exec($cmd);
    $cmd = "perl -pi -e 's/".$tempvent['vent3']."/".$off."/g'  showHouse.svg";
    exec($cmd);
  }elseif($act['vent']<=0.67){
    $cmd = "perl -pi -e 's/".$tempvent['vent1']."/".$bgc."/g'  showHouse.svg";
    exec($cmd);
    $cmd = "perl -pi -e 's/".$tempvent['vent2']."/".$bgc."/g'  showHouse.svg";
    exec($cmd);
    $cmd = "perl -pi -e 's/".$tempvent['vent3']."/".$off."/g'  showHouse.svg";
    exec($cmd);
  }elseif($act['vent']==1.0){
    $cmd = "perl -pi -e 's/".$tempvent['vent1']."/".$bgc."/g'  showHouse.svg";
    exec($cmd);
    $cmd = "perl -pi -e 's/".$tempvent['vent2']."/".$bgc."/g'  showHouse.svg";
    exec($cmd);
    $cmd = "perl -pi -e 's/".$tempvent['vent3']."/".$bgc."/g'  showHouse.svg";
    exec($cmd);
  }
  /* set state of actuators */
  $keys = array_keys($act);
  for($k=0;$k<count($keys);$k++){
    switch($keys[$k]){
    case "pump":
      if($opMod['pump']=="on"){
	$actColor="green";
      }elseif($opMod['pump']=="off"){
	  $actColor="red";
      }else{
        if($act[$keys[$k]]<=0.0){
          $actColor="yellow";
	}else{
	  $actColor="green";
        }
      }
      break;
    case "solar":
      if($opMod['solar']=="on"){
	$actColor="green";
      }elseif($opMod['solar']=="off"){
	  $actColor="red";
      }else{
        if($act[$keys[$k]]<=0.0){
          $actColor="yellow";
	}else{
	  $actColor="green";
        }
      }
      break;
    case "oven":
      if($opMod['oven']=="on"){
	$actColor="green";
      }elseif($opMod['oven']=="off"){
	  $actColor="red";
      }else{
        if($act[$keys[$k]]<0.5){
	  $actColor="yellow";
	}else{
	  $actColor="green";
	}
      }
      break;
    default:
      $actColor="";
    }

    if (isset($colorTmp[$keys[$k]])){
    if(strlen($colorTmp[$keys[$k]])>3 AND strlen($actColor)>=3){
      $cmd = "perl -pi -e 's/".$colorTmp[$keys[$k]]."/".$actColor."/g' showHouse.svg";
      exec($cmd);
    }
    }
  } #k

  /* color the water reservoir */
  for($i=0;$i<10;$i++){
    $ii=($i+1)*10;
    if($ii==100){$ii=99;}
    if($sens['H2O']>$ii){
      $res="";
      $cmd0 = "grep -n 'zisterne".$ii."' showHouse.svg";
      exec($cmd0,$res);
      if(isset($res[0])){
	$lnNo = explode(":",$res[0]);
	$lnNo[0] = $lnNo[0]+2;
	$cmd1 = "perl -pi -e 's/opacity:0/opacity:1/ if $. == ".$lnNo[0]."' showHouse.svg";
	exec($cmd1);
      }
    }
  }

  /* now compose house with colorbar */
  $colorBar = HV_colorMap("bar");
  $result ="<p align='center'><table border='0'><tr><td>\n";
  $result.="<a href='".$self."?what2do=menu'><img src='showHouse.svg'></a>";
  $result.="</td><td align='right' style='width:100px;'>\n";
  $result.=$colorBar;
  $result.="\n</td></tr></table></p>\n";

return $result;
}
?>

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.