2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-01 01:09:47 +00:00

SVG: gnuplot fix from Olaf. Gnuplot should work with DbLog now.

git-svn-id: https://svn.fhem.de/fhem/trunk@4606 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2014-01-10 14:59:39 +00:00
parent d8fcd70284
commit 5199ca5093

View File

@ -134,6 +134,7 @@ SVG_FwFn($$$$)
my $ret = "";
# plots navigation buttons
if (AttrVal($d,"plotmode",$FW_plotmode) ne "gnuplot") {
if((!$pageHash || !$pageHash->{buttons}) &&
AttrVal($d, "fixedrange", "x") !~ m/^[ 0-9:-]*$/) {
@ -144,6 +145,7 @@ SVG_FwFn($$$$)
$pageHash->{buttons} = 1 if($pageHash);
$ret .= "<br>";
}
}
my $arg="$FW_ME/SVG_showLog?dev=$d".
"&amp;logdev=$hash->{LOGDEVICE}".
@ -734,25 +736,35 @@ SVG_showLog($)
my $errfile = "/tmp/gnuplot.err";
if($pm eq "gnuplot" || !$SVG_devs{$d}{from}) {
# Looking for the logfile....
$defs{$d}{logfile} =~ m,^(.*)/([^/]*)$,; # Dir and File
my $path = "$1/$file";
$path = AttrVal($d,"archivedir","") . "/$file" if(!-f $path);
return ($FW_RETTYPE, "Cannot read $path") if(!-r $path);
# Fix range, as we are without scroll
my $f = 0; # From the beginning of time...
my $t = 9; # till the end
my ($err, $cfg, $plot, undef) = SVG_readgplotfile($wl, $gplot_pgm);
my ($err, $cfg, $plot, $flog) = SVG_readgplotfile($wl, $gplot_pgm);
return ($FW_RETTYPE, $err) if($err);
my $gplot_script = SVG_substcfg(0, $wl, $cfg, $plot, $file,$tmpfile);
my $fr = AttrVal($wl, "fixedrange", undef);
if($fr) {
$fr =~ s/ /\":\"/;
$fr = "set xrange [\"$fr\"]\n";
$gplot_script =~ s/(set timefmt ".*")/$1\n$fr/;
# Read the data from the filelog
my $oll = $attr{global}{verbose};
$attr{global}{verbose} = 0; # Else the filenames will be Log'ged
my @path = split(" ", FW_fC("get $d $file $tmpfile $f $t " .
join(" ", @{$flog})));
$attr{global}{verbose} = $oll;
# replace the path with the temporary filenames of the filelog output
my $i = 0;
$plot =~ s/\".*?using 1:[^ ]+ /"\"$path[$i++]\" using 1:2 "/gse;
my $xrange = "\n"; #We don't have a range, but need the new line
foreach my $p (@path) { # If the file is empty, write a 0 line
next if(!-z $p);
open(FH, ">$p");
print FH "$f 0\n";
close(FH);
}
my $gplot_script = SVG_substcfg(0, $wl, $cfg, $plot, $file, $tmpfile);
open(FH, "|gnuplot >> $errfile 2>&1");# feed it to gnuplot
print FH $gplot_script;
print FH $gplot_script, $xrange, $plot;
close(FH);
} elsif($pm eq "gnuplot-scroll") {
@ -911,7 +923,6 @@ SVG_render($$$$$$$$$)
my $flog = shift; # #FileLog lines, as array pointer
$SVG_RET="";
my $SVG_ss = AttrVal($parent_name, "smallscreen", 0);
return $SVG_RET if(!defined($dp));