Dr. Arne JachensDr. Arne Jachens

Heizungssteuerung Web-Interface

HV_showHouse

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["walu"]="Twalu";
  $strTmp["haus2"]="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]]) AND $sens[$keys[$k]]>-100){
      #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']>=0.99){
    $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;
}
?>

Index of Library

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

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