2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

User defined logs with several values in one file are now supported.

git-svn-id: https://svn.fhem.de/fhem/trunk@96 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
martinhaas 2007-10-14 14:20:25 +00:00
parent 69133fcb71
commit 6effb879ba
6 changed files with 102 additions and 51 deletions

View File

@ -127,3 +127,6 @@ Changelog
2007-10-13 (0.8.3)
-- feature: Now it is possible to attach selfmade logfiles from e.g. wired devices. Everthing is explained in config.php.
It is not necessary to tell fhem that there are other logs.
2007-10-14 (0.8.4)
-- feature: User defined logs with several values in one file now supported.

View File

@ -28,5 +28,6 @@
- Martin 2007-10-13
- Now pgm3 shows other logfiles (like from wired devices) too. Changes in index.php, config.php, gnuplot.php, new userdefs.php)
- Martin 2007-10-14
- User defined logs with several values in one file now supported. Changes in index.php, gnuplot.php, userdefs.php and config.php.

View File

@ -1,16 +1,16 @@
<?php
##################################################################################
#### pgm3 -- a PHP-webfrontend for fhem.pl
#### pgm3 -- a PHP-webfrontend for fhz1000.pl
###### required settings
$fhz1000="localhost"; #only php5 ! On which machine is fhem runnning??
# if it is not localhost then the fhz1000.cfg must
# if it is not localhost then the fhem.cfg must
# run global: "port <nr> global"
$fhz1000port="7072"; # port of fhz1000.pl
$fhz1000port="7072"; # port of fhem.pl
$logpath="/var/tmp"; # where are your logs?
$fhz1000_pl="/home/FHZ/fhz1000/fhz1000.pl"; #only required if you are using PHP4
$fhz1000_pl="/home/FHZ/fhem/fhem.pl"; #only required if you are using PHP4
##################################################################################
###### nice to have
@ -131,52 +131,89 @@
# otherwise the system will slow down
# pgm3 (user www-data) needs the rights to write the logs
# from fhz1000.pl (user = ???)
##############################################################################################
## user
## USERDEF
#
# Create your own graphics! If you have separate Programs (e.g. wired devices) then create your own
# logfile and tell pgm3 to use it.
# the logfile must look like this:
###################################
# 2007-10-13_13:45:14 solarI Is: 0.0
###################################
# Field1: <date>_<time> e.g. 2007-10-13_13:45:14
# Field2: <name> e.g. solar
# Field3: <free> this field has no meaning
# Field4: <value> e.g. 0.0 this must be a numeric value
# We only need a data/time-field in the form <date>_<time>, e.g. 2007-10-13_13:45:14
# and a field with a numeric value e.g. 0.0
#Example:
####################################################
# 2007-10-13_13:45:14 solarI Is: 0.0 Vs: 4.5 T: 22
####################################################
# Field1: 2007-10-13_13:45:14
# Field2: solarI
# Field3: Is:
# Field4: 0.0
#...
# Field1 must be the date/time-field. Then tell pgm3 with $userdef[x]['valuefield'] (see below)
# the field with the needed value. It is possible to create several graphics with on logfile.
$UserDefs=0; # Do you want user defined graphics? 1/0 Default: 0
# Do you want user defined graphics? 1/0 Default: 0
$UserDefs=0;
#################
## Userdef: 0 ## Switch $UserDefs to 1 !! ###
$userdef[0]['name']='SolarV'; #Size of the pictures. Default: 725
# No blanks or other special signs!!
$userdef[0]['imagemax']=725;
$userdef[0]['imagemay']=52;
$userdef[0]['maxcount']=575; # Maximum count of pixel (from right to left) (Default:575)
$userdef[0]['XcorrectMainText']=25; # Text of main text from the right side (Default:)
$userdef[0]['logrotatelines']=2200; # automatic Logrotate; $logrotate must be 'yes'.
# Default:2200
# read docs/logrotate if you want adjust it manually!
# otherwise the system will slow down
# pgm3 (user www-data) needs the rights to write the logs
# from fhz1000.pl (user = ???)
$userdef[0]['logpath']=$logpath.'/lse_solarV.log'; # example, path to the logfile with the entrys like above
$userdef[0]['room']='user';
$userdef[0]['semlong']='Voltage'; # Sematic eg. Voltage
$userdef[0]['semshort']='V'; # Sematic short e.g. V
#####################
## Userdef: 0
#################
## Userdef: 1
# $userdef[1]['name']='Solar I'; #Size of the pictures. Default: 725
# .....
# No blanks or other special signs!!
$userdef[0]['name']='SolarV';
#In which field are the values?? See the example above
$userdef[0]['valuefield']=4;
# example, path to the logfile with the entrys like above
$userdef[0]['logpath']=$logpath.'/lse_solarV.log';
$userdef[0]['room']='user';
# Semantic eg. Voltage
$userdef[0]['semlong']='Voltage';
# Semantic short e.g. V
$userdef[0]['semshort']='V';
#Size of the pictures. Default: 725
$userdef[0]['imagemax']=725;
$userdef[0]['imagemay']=52;
# Maximum count of pixel (from right to left) (Default:575)
$userdef[0]['maxcount']=575;
# Text of main text from the right side (Default:)
$userdef[0]['XcorrectMainText']=25;
# automatic Logrotate; $logrotate must be 'yes'.
# Default:2200
# read docs/logrotate if you want adjust it manually!
# otherwise the system will slow down
# pgm3 (user www-data) needs the rights to write the logs
# from fhz1000.pl (user = ???)
$userdef[0]['logrotatelines']=2200;
#################
## Userdef: 1
#
#$userdef[1]['name']='';
#$userdef[1]['valuefield']=;
#$userdef[1]['logpath']='/var/tmp/log.log';
#$userdef[1]['room']='';
#$userdef[1]['semlong']='';
#$userdef[1]['semshort']='';
#$userdef[1]['imagemax']=725;
#$userdef[1]['imagemay']=52;
#$userdef[1]['maxcount']=575;
#$userdef[1]['XcorrectMainText']=25;
#$userdef[1]['logrotatelines']=2200;
#################
## Userdef: 2
#
#$userdef[2]['name']='';
#........
@ -194,8 +231,6 @@
$taillog=1; #make shure to have the correct rights. Values: 0/1
$tailcount=20; #make shure to have the correct rights. Values: 0/1
$taillogorder="/usr/bin/tail -$tailcount $logpath/fhem.log ";
#$taillogorder="/usr/bin/tail -$tailcount $logpath/fhemjens.log ";
# $taillogorder="grep -v comparison $logpath/fhem.log| tail -20";

View File

@ -19,6 +19,7 @@ function drawgnuplot($gnudraw,$gnutyp,$gnuplot,$pictype,$logpath,$FHTyrange,$FHT
$drawuserdef=$userdef['name'];
$SemanticLong=$userdef['semlong'];
$SemanticShort=$userdef['semshort'];
$valuefield=$userdef['valuefield'];
$type='UserDef '.$userdefnr;
$IN="$gnudraw ($gnutyp $userdefnr)";
}
@ -137,7 +138,7 @@ EOD;
Case userdef: ############################################
$gplotmain=<<<EOD
\n set ylabel '$SemanticLong ( $SemanticShort )'
plot "$logfile" using 1:4 axes x1y1 title '$SemanticLong' with lines lw 3
plot "$logfile" using 1:$valuefield axes x1y1 title '$SemanticLong' with lines lw 3
EOD;
break;

View File

@ -14,9 +14,6 @@ include "functions.php";
$userdefnr=$_GET['userdefnr'];
$room=$userdef[$userdefnr]['room'];
#echo "Raum: $room"; exit;
$file= $userdef[$userdefnr]['logpath'];
$drawuserdef=$userdef[$userdefnr]['name'];
@ -24,6 +21,7 @@ include "functions.php";
$imgmaxyuserdef=$userdef[$userdefnr]['imagemay'];
$SemanticLong=$userdef[$userdefnr]['semlong'];
$SemanticShort=$userdef[$userdefnr]['semshort'];
$valuefield=$userdef[$userdefnr]['valuefield'];
$type='UserDef '.$userdefnr;
$logrotateUSERDEFlines=$userdef[0]['logrotatelines'];
$maxcountUSERDEF=$userdef[0]['maxcount'];
@ -69,13 +67,26 @@ include "functions.php";
for ($x = 0; $x < $counter; $x++)
{
list ($date,$userdef,$t,$temp,$h,$hum) = preg_split("/[\s,]+/", $array[$x]);
list ($date,$f2,$f3,$f4,$f5,$f6,$f7,$f8,$f9,$f10) = preg_split("/[\s,]+/", $array[$x]);
if ((($array[$x][14] != $oldmin) or ($array[$x][12] != $oldhour) or ($x==$counter-1))
and ( $date !="NEWLOGS"))
{
switch ($valuefield):
Case 2: $value=$f2;break;
Case 3: $value=$f3;break;
Case 4: $value=$f4;break;
Case 5: $value=$f5;break;
Case 6: $value=$f6;break;
Case 7: $value=$f7;break;
Case 8: $value=$f8;break;
Case 9: $value=$f9;break;
Case 10: $value=$f10;break;
endswitch;
$oldmin=$array[$x][14];
$oldhour=$array[$x][12];
array_push( $_SESSION["arraydata"],array($date,$temp,$hum));
array_push( $_SESSION["arraydata"],array($date,$value));
$temp=$value;
}
}
@ -89,12 +100,12 @@ include "functions.php";
###################
### min/max
$mintemp=100;
$maxtemp=-100;
$mintemp=1000;
$maxtemp=-1000;
for ($x = 0; $x <= $_SESSION["maxdata"]; $x++)
{
if ( $resultreverse[$x][1] > $maxtemp ) $maxtemp=$resultreverse[$x][1];
if ( ($resultreverse[$x][1] < $mintemp) and ($resultreverse[$x][1]>-100) ) $mintemp=$resultreverse[$x][1];
if ( ($resultreverse[$x][1] < $mintemp) and ($resultreverse[$x][1]>-1000) ) $mintemp=$resultreverse[$x][1];
}
$tempdiff=$maxtemp-$mintemp;
if ($tempdiff==0) $tempdiff=1;

View File

@ -41,7 +41,7 @@ include "include/gnuplot.php";
include "include/functions.php";
$pgm3version='0.8.3';
$pgm3version='0.8.4';
$Action = $_POST['Action'];