Heizungssteuerung Web-Interface
HV_composeH2Oplot
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); } ?>
Index of Library
Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.