1Set up the Raspberry Pi
2Electrical Connection of Sensores and Actuators
3Set up the Connection
4Heating Control

no warranty for any of the provided information

HV_showLog

Is used by:
index

This script utilizes Gnuplot to visualize the logfile data.

As 'default' a list of all existing logfiles is generated, to choose from. The intention of 'mode' is to provide specific diagrams depending on whether you want to analyze the solar or oven behaviour...
The respecting curves are plotted and as result the html image tag to the figure is returned. log file of solar heating control

<?php 
/* published under GPL www.gnu.org/licenses/gpl.html */
  /*
  $file="2013-08-24T00-00-01.log";
  $mode="solar";
  HV_showLog($file,$mode);
  */

function HV_showLog(){
  include_once("readNamedData.php");
  $path="./";
  $delimiter="\t";
  if(isset($_GET['mode'])){
    $mode=$_GET['mode'];
    $file=$_GET['file'];
    $ambient=$path."ambient".substr($file,0,10).".tsv";
    if (file_exists($ambient)){$showAmbient=TRUE;}else{echo $ambient." not foud!\n";}
  }else{
    $mode="default";
  }
  switch($mode){
  case "solar":
    $data = readNamedData($file,$path,$delimiter);
    $keys = array_keys($data);
    for($k=0;$k<count($keys);$k++){
      $ColNo[$keys[$k]]=$k+1;
    } #k
    $tmp=explode("T",$file);
    $date=$tmp[0];
    $plot = "set grid\n";
    $plot.= "set term png\n";
    $plot.= "set output 'log.png'\n";
    $plot.= "set xlabel 'time'\n";
    $plot.= "set ylabel 'Temperature [C]'\n";
    $plot.= "set y2label 'Power [kW]'\n";
    $plot.= "set y2range [0:7]\n";
    $plot.= "set key top left Left reverse\n";
    $plot.= "set xdata time\n";
    $plot.= "set timefmt '%Y-%m-%dT%H:%M:%S'\n";
    $plot.= "set xtics ('00:00' '".$date."T00:00:00'";
    $plot.= ", '03:00' '".$date."T03:00:00'";
    $plot.= ", '06:00' '".$date."T06:00:00'";
    $plot.= ", '09:00' '".$date."T09:00:00'";
    $plot.= ", '12:00' '".$date."T12:00:00'";
    $plot.= ", '15:00' '".$date."T15:00:00'";
    $plot.= ", '18:00' '".$date."T18:00:00'";
    $plot.= ", '21:00' '".$date."T21:00:00'";
    $plot.= ", '24:00' '".$date."T24:00:00' )\n";
    $plot.= "set y2tics\n";
    $plot.= "plot '".$file."' u 1:(2.5*$".$ColNo['solar']."*69.7/1000*($".$ColNo['flow']."-$".$ColNo['ret'].")) axis x1y2 w l lc rgb '#c0c0c0' title 'P_solar',\\\n";
    if($showAmbient){
      $plot.=" '".$ambient."' u 1:2 w lp lc rgb 'black' title 'T_aussen', \\\n";
    }
    $plot.= " '".$file."' u 1:".$ColNo['flow']." w l lc rgb '#008000' title 'T_Vorlauf',\\\n";
    $plot.= " '".$file."' u 1:".$ColNo['ret']."  w l lc rgb '#00ff00' title 'T_Ruecklauf',\\\n";
    $plot.= " '".$file."' u 1:".$ColNo['tLow']." w l lc rgb 'orange' lw 3 title 'T_Speicher unten',\\\n";
    $plot.= " '".$file."' u 1:".$ColNo['tHot']." w l lc rgb 'red' lw 3 title 'T_Seicher oben',\\\n";
    $plot.= " '".$file."' u 1:".$ColNo['coll']." w l lc rgb '#800080' lw 3 title 'T_Kollektor',\\\n";
    $plot.= " '".$file."' u 1:($".$ColNo['solar']."*100) w p lc rgb 'blue' title 'A_solar'\n";
    #$plot.= "pause -1";
    $fd = fopen("log.gp","w");
    fputs($fd,$plot);
    fclose($fd);
    exec("gnuplot log.gp");
    sleep(1);
    $result ="<p align='center'><img src='log.png' alt='logfile'></p>";
    $result.="<p align='center'><a href='?what2do=showLog'>show Logfile</a></p>\n";
    return $result;
    break;
case "heating":
    $data = readNamedData($file,$path,$delimiter);
    $keys = array_keys($data);
    for($k=0;$k<count($keys);$k++){
      $ColNo[$keys[$k]]=$k+1;
    } #k
    $tmp=explode("T",$file);
    $date=$tmp[0];
    $plot = "set grid\n";
    $plot.= "set term png\n";
    $plot.= "set output 'log.png'\n";
    $plot.= "set xlabel 'time'\n";
    $plot.= "set ylabel 'Temperature [C]'\n";
   # $plot.= "set y2label 'Power [kW]'\n";
   # $plot.= "set y2range [0:7]\n";
    $plot.= "set key top left Left reverse\n";
    $plot.= "set xdata time\n";
    $plot.= "set timefmt '%Y-%m-%dT%H:%M:%S'\n";
    $plot.= "set xtics ('00:00' '".$date."T00:00:00'";
    $plot.= ", '03:00' '".$date."T03:00:00'";
    $plot.= ", '06:00' '".$date."T06:00:00'";
    $plot.= ", '09:00' '".$date."T09:00:00'";
    $plot.= ", '12:00' '".$date."T12:00:00'";
    $plot.= ", '15:00' '".$date."T15:00:00'";
    $plot.= ", '18:00' '".$date."T18:00:00'";
    $plot.= ", '21:00' '".$date."T21:00:00'";
    $plot.= ", '24:00' '".$date."T24:00:00' )\n";
   # $plot.= "set y2tics\n";
    if($showAmbient){
      $plot.="plot '".$ambient."' u 1:2 w lp lc rgb 'black' title 'T_aussen', \\\n";
      $plot.=" '".$ambient."' u 1:4 w lp lc rgb 'yellow' title 'Sonnenschein', \\\n";
      $plot.= " '".$file."' u 1:".$ColNo['tLow']." w l lc rgb 'orange' lw 3 title 'T_Speicher unten',\\\n";
    }else{
      $plot.= "plot '".$file."' u 1:".$ColNo['tLow']." w l lc rgb 'orange' lw 3 title 'T_Speicher unten',\\\n";
    }
    $plot.= " '".$file."' u 1:".$ColNo['tHot']." w l lc rgb 'red' lw 3 title 'T_Seicher oben',\\\n";
    $plot.= " '".$file."' u 1:".$ColNo['fire']." w l lc rgb '#008000' lw 3 title 'T_Ofen',\\\n";
    $plot.= " '".$file."' u 1:($".$ColNo['oven']."*20) w p lc rgb 'blue' title 'A_oven'\n";
    #$plot.= "pause -1";
    $fd = fopen("log.gp","w");
    fputs($fd,$plot);
    fclose($fd);
    exec("gnuplot log.gp");
    sleep(1);
    $result ="<p align='center'><img src='log.png' alt='logfile'></p>";
    $result.="<p align='center'><a href='?what2do=showLog'>show Logfile</a></p>\n";
    return $result;
  break;
  case "ventilation":
    $file=substr($file,0,strlen($file)-3)."vent";
    $data = readNamedData($file,$path,$delimiter);
    $keys = array_keys($data);
    for($k=0;$k<count($keys);$k++){
      $ColNo[$keys[$k]]=$k+1;
    } #k
    $tmp=explode("T",$file);
    $date=$tmp[0];
    $plot = "set grid\n";
    $plot.= "set term png\n";
    $plot.= "set output 'log.png'\n";
    $plot.= "set xlabel 'time'\n";
    $plot.= "set ylabel 'Temperature [C]'\n";
   # $plot.= "set y2label 'ventilation level'\n";
    $plot.= "set y2range [0:4]\n";
    $plot.= "set key top left Left reverse\n";
    $plot.= "set xdata time\n";
 #   $plot.= "set boxwidth 1.0\n";
    $plot.= "set timefmt '%Y-%m-%dT%H:%M:%S'\n";
    $plot.= "set xtics ('00:00' '".$date."T00:00:00'";
    $plot.= ", '03:00' '".$date."T03:00:00'";
    $plot.= ", '06:00' '".$date."T06:00:00'";
    $plot.= ", '09:00' '".$date."T09:00:00'";
    $plot.= ", '12:00' '".$date."T12:00:00'";
    $plot.= ", '15:00' '".$date."T15:00:00'";
    $plot.= ", '18:00' '".$date."T18:00:00'";
    $plot.= ", '21:00' '".$date."T21:00:00'";
    $plot.= ", '24:00' '".$date."T24:00:00' )\n";
    $plot.= "set y2tics ('off' 0, 'min' 1, 'normal' 2, 'max' 3)\n";
    #$plot.= "plot '".$file."' u 1:".$ColNo['level']." axis x1y2  with boxes fs solid lc rgb '#c0c0c0' title 'ventilation',\\\n";
$plot.= "plot '".$file."' u 1:".$ColNo['level']." axis x1y2  w steps lw 2 lc rgb '#c0c0c0' title 'ventilation',\\\n";
    $plot.= " '".$file."' u 1:".$ColNo['mode']." w l lc rgb 'yellow' lw 1 notitle,\\\n";
    if($showAmbient){
      $plot.=" '".$ambient."' u 1:2 w lp lc rgb 'black' lw 3 title 'T_aussen', \\\n";
    }
    $plot.= " '".$file."' u 1:".$ColNo['Terde']." w l lc rgb '#0000ff' lw 3 title 'T_Erde',\\\n";
    $plot.= " '".$file."' u 1:".$ColNo['Tzulu']."  w l lc rgb '#00ff00' lw 3 title 'T_Zuluft',\\\n";
    $plot.= " '".$file."' u 1:".$ColNo['Tablu']." w l lc rgb 'red' lw 3 title 'T_Abluft',\\\n";
    $plot.= " '".$file."' u 1:".$ColNo['Tfolu']." w l lc rgb 'cyan' lw 3 title 'T_Fortluft'\n";
    $fd = fopen("log.gp","w");
    fputs($fd,$plot);
    fclose($fd);
    exec("gnuplot log.gp");
    sleep(1);
    $result ="<p align='center'><img src='log.png' alt='logfile'></p>";
    $result.="<p align='center'><a href='?what2do=showLog'>show Logfile</a></p>\n";
    return $result;
    break;
  default:
    include_once("readFilenames.php");
    $files = readFilenames("./","\.log");
    sort($files);
    $list ="<ul>\n";
    for($f=0;$f<count($files);$f++){
      $list.="<li>".$files[$f]." <a href='?what2do=showLog&mode=solar&file=".$files[$f]."'>solar</a>   
                            <a href='?what2do=showLog&mode=heating&file=".$files[$f]."'>heating</a>  
                            <a href='?what2do=showLog&mode=ventilation&file=".$files[$f]."'>ventilation</a></li>\n";
    } #f
    $list.="</ul>\n";
    return $list;
  } #switch

}
?>
1HV_Admin_Login
2HV_colorMap
3HV_config
4HV_convertASCII
5HV_getSunPrediction
6HV_heatingControl
7HV_loop
8HV_readOperationState
9HV_readTemperatures
10HV_restart
11HV_serviceLog
12HV_setActuators
13HV_setParameters
14HV_showHouse
15HV_showLog
16HV_showRawValues
17HV_showWeatherForecast
18HV_thermos200
19HV_ventProg
20HV_writeLog
21index
22MoistAir
23readFilenames
24readNamedData
25tableInterpol

 

gnuplot

gnuplot is used to visualise the results - via script you can do infinite diagrams in 1 second.
Run 'test' in gnuplot to get an owerview of the available line- and symbolstyles.

Login
Valid HTML 4.01!