mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
Automatic user defined graphics now for Piri and FS20 too
git-svn-id: https://svn.fhem.de/fhem/trunk@97 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
6effb879ba
commit
68c034bfa6
@ -130,3 +130,6 @@ 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.
|
||||
|
||||
2007-10-16 (CVS)
|
||||
-- feature: User defined graphics now for Piri and FS20 too. Everthing is explained in the config.php.
|
||||
|
@ -30,4 +30,5 @@
|
||||
- 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.
|
||||
|
||||
- Martin 2007-10-16
|
||||
- User defined graphics now for Piri an FS20 too
|
||||
|
@ -63,7 +63,7 @@
|
||||
$showroombuttons=1; #default 1 Values 0/1
|
||||
$imgmaxxroom=$imgmaxxfs20; #Size of the pictures, default=$imgmaxxfs20
|
||||
$imgmaxyroom=30; # default=30
|
||||
$roomfontsizetitel=9; # default=9
|
||||
$roomfontsizetitel=10; # default=10
|
||||
$roommaxiconperline=$fs20maxiconperline; # default=$fs20maxiconperline
|
||||
|
||||
##############################################################################################
|
||||
@ -103,19 +103,6 @@
|
||||
# pgm3 (user www-data) needs the rights to write the logs
|
||||
# from fhz1000.pl (user = ???)
|
||||
|
||||
##############################################################################################
|
||||
## SCIVT-Devices
|
||||
$imgmaxxscivt=725; #Size of the pictures. Default: 725
|
||||
$imgmaxyscivt=52;
|
||||
$maxcountscivt='575'; # Maximum count of pixel (from right to left) (Default:575)
|
||||
$XcorrectMainTextSCIVT=25; # Text of main text from the right side (Default:)
|
||||
$logrotateSCIVTlines=1200; # automatic Logrotate; $logrotate must be 'yes'.
|
||||
# Default:1200
|
||||
# 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 = ???)
|
||||
|
||||
##############################################################################################
|
||||
## KS300-Device
|
||||
$imgmaxxks=725; #Size of the pictures Default: 725
|
||||
@ -165,8 +152,12 @@ $userdef[0]['name']='SolarV';
|
||||
#In which field are the values?? See the example above
|
||||
$userdef[0]['valuefield']=4;
|
||||
|
||||
#Type of Device [temperature | piri] pgm3 will try to generate a gnuplot picture
|
||||
$userdef[0]['gnuplottype']='temperature';
|
||||
|
||||
# example, path to the logfile with the entrys like above
|
||||
$userdef[0]['logpath']=$logpath.'/lse_solarV.log';
|
||||
|
||||
$userdef[0]['room']='user';
|
||||
|
||||
# Semantic eg. Voltage
|
||||
@ -199,6 +190,7 @@ $userdef[0]['logrotatelines']=2200;
|
||||
#
|
||||
#$userdef[1]['name']='';
|
||||
#$userdef[1]['valuefield']=;
|
||||
#$userdef[1]['gnuplottype']='temperature';
|
||||
#$userdef[1]['logpath']='/var/tmp/log.log';
|
||||
#$userdef[1]['room']='';
|
||||
#$userdef[1]['semlong']='';
|
||||
@ -209,10 +201,76 @@ $userdef[0]['logrotatelines']=2200;
|
||||
#$userdef[1]['XcorrectMainText']=25;
|
||||
#$userdef[1]['logrotatelines']=2200;
|
||||
|
||||
#################
|
||||
## Userdef: 2
|
||||
########################
|
||||
# example:
|
||||
# define piriulog FileLog /var/tmp/piriu.log piriu:.*
|
||||
#$userdef[1]['name']='PiriU';
|
||||
#$userdef[1]['valuefield']=3;
|
||||
#$userdef[1]['gnuplottype']='piri';
|
||||
#$userdef[1]['logpath']='/mnt/fhz/piriu.log';
|
||||
#$userdef[1]['room']='wgu';
|
||||
#$userdef[1]['semlong']='Bewegungsmelder';
|
||||
#$userdef[1]['semshort']='';
|
||||
#$userdef[1]['imagemax']=725;
|
||||
#$userdef[1]['imagemay']=52;
|
||||
#$userdef[1]['maxcount']=575;
|
||||
#$userdef[1]['XcorrectMainText']=25;
|
||||
#$userdef[1]['logrotatelines']=2200;
|
||||
|
||||
########################
|
||||
# example:
|
||||
# define piriolog FileLog /var/tmp/pirio.log pirio:.*
|
||||
#$userdef[2]['name']='PiriO';
|
||||
#$userdef[2]['valuefield']=3;
|
||||
#$userdef[2]['gnuplottype']='piri';
|
||||
#$userdef[2]['logpath']='/mnt/fhz/pirio.log';
|
||||
#$userdef[2]['room']='wgo';
|
||||
#$userdef[2]['semlong']='Bewegungsmelder';
|
||||
#$userdef[2]['semshort']='';
|
||||
#$userdef[2]['imagemax']=725;
|
||||
#$userdef[2]['imagemay']=52;
|
||||
#$userdef[2]['maxcount']=575;
|
||||
#$userdef[2]['XcorrectMainText']=25;
|
||||
#$userdef[2]['logrotatelines']=2200;
|
||||
#
|
||||
#$userdef[2]['name']='';
|
||||
|
||||
########################
|
||||
# example:
|
||||
#define solarpumpe.log FileLog /var/tmp/solarpumpe.log solarpumpe:.*(on|off).*
|
||||
#$userdef[3]['name']='SolarPumpe';
|
||||
#$userdef[3]['valuefield']=3;
|
||||
#$userdef[3]['gnuplottype']='fs20';
|
||||
#$userdef[3]['logpath']='/mnt/fhz/solarpumpe.log';
|
||||
#$userdef[3]['room']='cellar';
|
||||
#$userdef[3]['semlong']='Solarpumpe';
|
||||
#$userdef[3]['semshort']='';
|
||||
#$userdef[3]['imagemax']=725;
|
||||
#$userdef[3]['imagemay']=52;
|
||||
#$userdef[3]['maxcount']=575;
|
||||
#$userdef[3]['XcorrectMainText']=25;
|
||||
#$userdef[3]['logrotatelines']=50;
|
||||
#
|
||||
|
||||
##########################
|
||||
# example:
|
||||
#define rolu1.log FileLog /var/tmp/rolu1.log rolu1:.*(on|off|dimup|dimdown).*
|
||||
#$userdef[4]['name']='Rolu1';
|
||||
#$userdef[4]['valuefield']=3;
|
||||
#$userdef[4]['gnuplottype']='fs20';
|
||||
#$userdef[4]['logpath']='/mnt/fhz/rolu1.log';
|
||||
#$userdef[4]['room']='wgu';
|
||||
#$userdef[4]['semlong']='Rolladen';
|
||||
#$userdef[4]['semshort']='';
|
||||
#$userdef[4]['imagemax']=725;
|
||||
#$userdef[4]['imagemay']=52;
|
||||
#$userdef[4]['maxcount']=575;
|
||||
#$userdef[4]['XcorrectMainText']=25;
|
||||
#$userdef[4]['logrotatelines']=30;
|
||||
#
|
||||
#################
|
||||
## Userdef: x
|
||||
#
|
||||
#$userdef[x]['name']='';
|
||||
#........
|
||||
|
||||
|
||||
|
@ -15,6 +15,7 @@ function drawgnuplot($gnudraw,$gnutyp,$gnuplot,$pictype,$logpath,$FHTyrange,$FHT
|
||||
$userdefnr=$FHTy2range; # workaround
|
||||
|
||||
|
||||
$gnuplottype= $userdef['gnuplottype'];
|
||||
$logfile= $userdef['logpath'];
|
||||
$drawuserdef=$userdef['name'];
|
||||
$SemanticLong=$userdef['semlong'];
|
||||
@ -22,6 +23,9 @@ function drawgnuplot($gnudraw,$gnutyp,$gnuplot,$pictype,$logpath,$FHTyrange,$FHT
|
||||
$valuefield=$userdef['valuefield'];
|
||||
$type='UserDef '.$userdefnr;
|
||||
$IN="$gnudraw ($gnutyp $userdefnr)";
|
||||
if ($gnuplottype=='piri') $gnutyp='piri';
|
||||
if ($gnuplottype=='fs20') $gnutyp='FS20';
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -54,11 +58,13 @@ $xrange="set xrange ['$xrange2':'$xrange1']
|
||||
switch ($gnutyp):
|
||||
Case FS20: ############################################
|
||||
$gplotmain=<<<EOD
|
||||
set size 1,0.5
|
||||
set noytics
|
||||
set noy2tics
|
||||
set yrange [-0.2:1.2]
|
||||
set ylabel "On/Off"
|
||||
plot "< awk '{print $1, $3==\"on\"? 1 : $3==\"dimup\"? 0.8 : $3==\"dimdown\"? 0.2 : $3==\"off\"? 0 : 0.5;}' $logfile" using 1:2 title 'On/Off' with steps
|
||||
plot "< awk '{print $1, $3==\"on\"? 1 : $3==\"dimup\"? 0.8 : $3==\"dimdown\"? 0.2 : $3==\"off\"? 0 : 0.5;}' $logfile" using 1:2 title '' with steps
|
||||
EOD;
|
||||
#plot "< awk '{print $1, $3==\"on\"? 1 : 0; }' $logfile" using 1:2 title 'On/Off' with steps
|
||||
break;
|
||||
|
||||
Case WS300_t1: ############################################
|
||||
@ -138,6 +144,22 @@ EOD;
|
||||
Case userdef: ############################################
|
||||
$gplotmain=<<<EOD
|
||||
\n set ylabel '$SemanticLong ( $SemanticShort )'
|
||||
set size 1,0.5
|
||||
set noytics
|
||||
set noy2tics
|
||||
plot "$logfile" using 1:$valuefield axes x1y1 title '$SemanticLong' with lines lw 3
|
||||
EOD;
|
||||
break;
|
||||
Case piri: ############################################
|
||||
$gplotmain=<<<EOD
|
||||
\n set ylabel '$drawuserdef'
|
||||
set noytics
|
||||
set noy2tics
|
||||
set size 1,0.5
|
||||
set yrange [-1.2:2.2]
|
||||
plot "< awk '{print $1, 1; }' $logfile "\
|
||||
using 1:2 title '$drawuserdef' with impulses
|
||||
|
||||
plot "$logfile" using 1:$valuefield axes x1y1 title '$SemanticLong' with lines lw 3
|
||||
EOD;
|
||||
break;
|
||||
|
@ -11,6 +11,15 @@ include "../config.php";
|
||||
include "functions.php";
|
||||
|
||||
|
||||
#function normalize($piriarray)
|
||||
#{
|
||||
# print_r($piriarray);
|
||||
# exit;
|
||||
|
||||
#
|
||||
#}
|
||||
|
||||
|
||||
$userdefnr=$_GET['userdefnr'];
|
||||
|
||||
$room=$userdef[$userdefnr]['room'];
|
||||
@ -23,9 +32,10 @@ include "functions.php";
|
||||
$SemanticShort=$userdef[$userdefnr]['semshort'];
|
||||
$valuefield=$userdef[$userdefnr]['valuefield'];
|
||||
$type='UserDef '.$userdefnr;
|
||||
$logrotateUSERDEFlines=$userdef[0]['logrotatelines'];
|
||||
$maxcountUSERDEF=$userdef[0]['maxcount'];
|
||||
$XcorrectMainTextUSERDEF=$userdef[0]['XcorrectMainText'];
|
||||
$logrotateUSERDEFlines=$userdef[$userdefnr]['logrotatelines'];
|
||||
$maxcountUSERDEF=$userdef[$userdefnr]['maxcount'];
|
||||
$XcorrectMainTextUSERDEF=$userdef[$userdefnr]['XcorrectMainText'];
|
||||
$gnuplottype=$userdef[$userdefnr]['gnuplottype'];
|
||||
|
||||
|
||||
|
||||
@ -73,6 +83,7 @@ include "functions.php";
|
||||
{
|
||||
|
||||
switch ($valuefield):
|
||||
Case 1: $value=$date;break;
|
||||
Case 2: $value=$f2;break;
|
||||
Case 3: $value=$f3;break;
|
||||
Case 4: $value=$f4;break;
|
||||
@ -89,6 +100,8 @@ include "functions.php";
|
||||
$temp=$value;
|
||||
}
|
||||
}
|
||||
|
||||
# normalize($_SESSION["arraydata"]);
|
||||
|
||||
$resultreverse = array_reverse($_SESSION["arraydata"]);
|
||||
$xold=$imgmaxxuserdef;
|
||||
@ -115,6 +128,52 @@ include "functions.php";
|
||||
|
||||
|
||||
if ($maxcountUSERDEF < $_SESSION["maxdata"]) {$anzlines=$maxcountUSERDEF;} else {$anzlines= $_SESSION["maxdata"];}
|
||||
|
||||
|
||||
if ($gnuplottype=='piri' or $gnuplottype=='fs20')
|
||||
{
|
||||
$datumtomorrow= mktime (0,0,0,date("m") ,date("d")+1,date("Y"));
|
||||
$xrange1= date ("Y-m-d",$datumtomorrow);
|
||||
$datumyesterday= mktime (0,0,0,date("m") ,date("d")-5,date("Y"));
|
||||
$xrange2= date ("Y-m-d",$datumyesterday);
|
||||
$xrange="set xrange ['$xrange2':'$xrange1']";
|
||||
$gnuplotfile="../tmp/".$drawuserdef;
|
||||
#$gnuplotpng="../tmp/".$drawuserdef.".png";
|
||||
$gnuplotpng=$drawuserdef.".png";
|
||||
|
||||
$messageA=<<<EOD
|
||||
set output '$gnuplotpng'
|
||||
set terminal png
|
||||
set xdata time
|
||||
set timefmt '%Y-%m-%d_%H:%M:%S'
|
||||
set noytics
|
||||
unset label
|
||||
$xrange
|
||||
set grid
|
||||
set yrange [-0.3:1.3]
|
||||
set size 0.8,0.15
|
||||
set format x ''
|
||||
|
||||
EOD;
|
||||
}
|
||||
|
||||
|
||||
switch ($gnuplottype):
|
||||
Case 'piri':
|
||||
$messageB=<<<EOD
|
||||
plot "< awk '{print $1, 1; }' $file "\
|
||||
using 1:2 title '' with impulses
|
||||
EOD;
|
||||
break;
|
||||
Case 'fs20':
|
||||
$messageB=<<<EOD
|
||||
plot "< awk '{print $1, $3==\"on\"? 1 : $3==\"dimup\"? 0.8 : $3==\"dimdown\"? 0.2 : $3==\"off\"? 0 : 0.5;}' \
|
||||
$file" using 1:2 title '' with steps
|
||||
|
||||
EOD;
|
||||
break;
|
||||
|
||||
default:
|
||||
for ($x = 0; $x < $anzlines; $x++)
|
||||
|
||||
{
|
||||
@ -129,14 +188,34 @@ include "functions.php";
|
||||
$xold=$imgmaxxuserdef-$x;
|
||||
$yold=$y;
|
||||
};
|
||||
ImageLine($im, $imgmaxxuserdef-$x, 0,$imgmaxxuserdef-$x , $imgmaxyuserdef, $yellow);
|
||||
ImageLine($im, $imgmaxxuserdef-$x, 0,$imgmaxxuserdef-$x , $imgmaxyuserdef, $yellow);
|
||||
break;
|
||||
endswitch;
|
||||
|
||||
|
||||
if ($gnuplottype=='piri' or $gnuplottype=='fs20')
|
||||
{
|
||||
$message=$messageA.$messageB;
|
||||
$f1=fopen("$gnuplotfile","w");
|
||||
fputs($f1,$message);
|
||||
fclose($f1);
|
||||
exec("$gnuplot $gnuplotfile",$output);
|
||||
|
||||
$w = imagesx($im);
|
||||
$h = imagesy($im);
|
||||
|
||||
$im2 = imagecreatefrompng("$gnuplotpng");
|
||||
$w2 = imagesx($im2);
|
||||
$h2 = imagesy($im2);
|
||||
ImageCopy($im,$im2,150,0,0,10,$w2-10,$h2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
ImageLine($im, $imgmaxxuserdef-$maxcountUSERDEF, 0,$imgmaxxuserdef-$maxcountUSERDEF , $imgmaxyuserdef, $white);
|
||||
$tempTEMP=$temp;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#############################################################################
|
||||
|
||||
$text=$SemanticLong;
|
||||
|
@ -41,7 +41,7 @@ include "include/gnuplot.php";
|
||||
include "include/functions.php";
|
||||
|
||||
|
||||
$pgm3version='0.8.4';
|
||||
$pgm3version='0.8.5cvs';
|
||||
|
||||
|
||||
$Action = $_POST['Action'];
|
||||
@ -888,7 +888,7 @@ xml_parser_free($xml_parser);
|
||||
echo "<img src='include/userdefs.php?userdefnr=$i' width='$imgmaxxuserdef' height='$imgmaxyuserdef'></td> </tr>";
|
||||
|
||||
if ($showuserdefgnu == $UserDef and $showgnuplot == 1)
|
||||
{ drawgnuplot($UserDef,$type,$gnuplot,$pictype,$logpath,$userdef[$i],1);
|
||||
{ drawgnuplot($UserDef,$type,$gnuplot,$pictype,$logpath,$userdef[$i],$i);
|
||||
$UserDef1=$UserDef.'1';
|
||||
echo "<tr><td colspan=5 align=center><img src='tmp/$UserDef.$pictype'><br>
|
||||
<img src='tmp/$UserDef1.$pictype'>
|
||||
|
Loading…
Reference in New Issue
Block a user