Dr. Arne Jachens

Set up the Raspberry Pi

no warranty for any of the provided information

Keine Erläuterungen gefunden.

<?php
include_once("readFilenames.php");
/*
$month = "04";
$msg = HV_composeH2Oplot($month);
echo $msg;
HV_H2Oplot($month);
*/

function HV_composeH2Oplot($month){
    global $debug;
    $msg = "<p><aj>HV_composeH2Oplot</aj><ol>\n";
    $time = array();
    $level = array();
    $year  = date('Y');
    $path = $year."-".$month."/";
    $allLogFiles = readFilenames($path,".txt");
    sort($allLogFiles);
 

  $time = array();
  $level = array();
  $m=-1;
  for($l =0;$l<count($allLogFiles);$l++){
      $thisF = $allLogFiles[$l];
      $myPos = strpos($thisF,"ensors");
      if($myPos>0){
          $thisDate = substr($thisF,$myPos+10,10);
          $thisLogFile = $allLogFiles[$l];
          /* filter logs of month */
          $m++;
          $msg .= "<li>".$path.$thisLogFile."</li>\n";
          /* extract updated H2O levels */
          $lastLevel = -1;
          $fid = fopen($path.$thisLogFile, "r");
          /* find column H2O */
          $line = fgets( $fid, 2048 );
          if($m==0){
              $colNames = explode("\t",$line);
              for($c=0;$c<count($colNames);$c++){
                  if(trim($colNames[$c])=="H2O"){$cc=$c;}
              } #c
          } #fi

          $line = fgets( $fid, 2048 );
          while(!feof($fid)){
              if($line[0]!=" #"){
                  $values = explode("\t",$line);
                  $timeStamp = $thisDate."T".trim($values[0]);
                  $thisLevel = round( trim( $values[$cc] ) ,0);
                  if($thisLevel!=$lastLevel){
                      $lastLevel = $thisLevel;
                      array_push($time, $timeStamp);
                      array_push($level, $thisLevel);
                  } #fi
              } #fi
              $line = fgets( $fid, 2048 );
          } #while
          fclose($fid);
      } #fi
  } #l
  $msg.= "</ol>\n";

  $file = $path."H2O_".$month.".lev";
  $fid = fopen($file,"w");
  for($t=0;$t<count($time);$t++){
      $string = $t."\t".$time[$t]."\t".$level[$t]."\n";
      fputs($fid,$string);
  } #t
  fclose($fid);
  if($debug){echo $msg;}
  return $msg;
}

function HV_H2Oplot($month){
  $file = "H2O_".$month.".lev";
  $year = date('Y');

  $plot = "set xdata time\n";
  $plot.= "set timefmt '%Y-%m-%dT%H:%M'\n";
  $plot.= "set format x '%d'\n";

  $plot.= "set title 'Füllstand Zisterne ".$month.".".$year."'\n";

  $plot.= "set style line 1 lt 1 lc rgb '#4169e1' lw 1 pt 7 ps 0.5\n";

  $plot.= "set xrange ['".$year."-".$month."-01':'".$year."-".$month."-31']\n";
  $plot.= "set yrange [0:100]\n";
  $plot.= "set xtics ('05' '".$year."-".$month."-05', '10' '".$year."-".$month."-10', '15' '".$year."-".$month."-15', '20' '".$year."-".$month."-20', '25' '".$year."-".$month."-25')\n";

  $plot.= "set grid\n";

  $plot.= "set term svg\n";
  $plot.= "set output 'H2O.svg'\n";

  $plot.= "plot '".$year."-".$month."/".$file."' u 2:3 ls 1 w lp notitle";

  $pid = fopen("H2O.gp","w");
  fputs($pid,$plot);
  fclose($pid);

  $cmd = "gnuplot H2O.gp";
  exec($cmd);
}
?>

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.