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:
@@ -134,15 +134,17 @@ SVG_FwFn($$$$)
|
|||||||
my $ret = "";
|
my $ret = "";
|
||||||
|
|
||||||
# plots navigation buttons
|
# plots navigation buttons
|
||||||
if((!$pageHash || !$pageHash->{buttons}) &&
|
if (AttrVal($d,"plotmode",$FW_plotmode) ne "gnuplot") {
|
||||||
AttrVal($d, "fixedrange", "x") !~ m/^[ 0-9:-]*$/) {
|
if((!$pageHash || !$pageHash->{buttons}) &&
|
||||||
|
AttrVal($d, "fixedrange", "x") !~ m/^[ 0-9:-]*$/) {
|
||||||
|
|
||||||
$ret .= SVG_zoomLink("zoom=-1", "Zoom-in", "zoom in");
|
$ret .= SVG_zoomLink("zoom=-1", "Zoom-in", "zoom in");
|
||||||
$ret .= SVG_zoomLink("zoom=1", "Zoom-out","zoom out");
|
$ret .= SVG_zoomLink("zoom=1", "Zoom-out","zoom out");
|
||||||
$ret .= SVG_zoomLink("off=-1", "Prev", "prev");
|
$ret .= SVG_zoomLink("off=-1", "Prev", "prev");
|
||||||
$ret .= SVG_zoomLink("off=1", "Next", "next");
|
$ret .= SVG_zoomLink("off=1", "Next", "next");
|
||||||
$pageHash->{buttons} = 1 if($pageHash);
|
$pageHash->{buttons} = 1 if($pageHash);
|
||||||
$ret .= "<br>";
|
$ret .= "<br>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $arg="$FW_ME/SVG_showLog?dev=$d".
|
my $arg="$FW_ME/SVG_showLog?dev=$d".
|
||||||
@@ -734,25 +736,35 @@ SVG_showLog($)
|
|||||||
my $errfile = "/tmp/gnuplot.err";
|
my $errfile = "/tmp/gnuplot.err";
|
||||||
|
|
||||||
if($pm eq "gnuplot" || !$SVG_devs{$d}{from}) {
|
if($pm eq "gnuplot" || !$SVG_devs{$d}{from}) {
|
||||||
# Looking for the logfile....
|
# Fix range, as we are without scroll
|
||||||
$defs{$d}{logfile} =~ m,^(.*)/([^/]*)$,; # Dir and File
|
my $f = 0; # From the beginning of time...
|
||||||
my $path = "$1/$file";
|
my $t = 9; # till the end
|
||||||
$path = AttrVal($d,"archivedir","") . "/$file" if(!-f $path);
|
|
||||||
return ($FW_RETTYPE, "Cannot read $path") if(!-r $path);
|
|
||||||
|
|
||||||
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);
|
return ($FW_RETTYPE, $err) if($err);
|
||||||
my $gplot_script = SVG_substcfg(0, $wl, $cfg, $plot, $file,$tmpfile);
|
|
||||||
|
|
||||||
my $fr = AttrVal($wl, "fixedrange", undef);
|
# Read the data from the filelog
|
||||||
if($fr) {
|
my $oll = $attr{global}{verbose};
|
||||||
$fr =~ s/ /\":\"/;
|
$attr{global}{verbose} = 0; # Else the filenames will be Log'ged
|
||||||
$fr = "set xrange [\"$fr\"]\n";
|
my @path = split(" ", FW_fC("get $d $file $tmpfile $f $t " .
|
||||||
$gplot_script =~ s/(set timefmt ".*")/$1\n$fr/;
|
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
|
open(FH, "|gnuplot >> $errfile 2>&1");# feed it to gnuplot
|
||||||
print FH $gplot_script;
|
print FH $gplot_script, $xrange, $plot;
|
||||||
close(FH);
|
close(FH);
|
||||||
|
|
||||||
} elsif($pm eq "gnuplot-scroll") {
|
} elsif($pm eq "gnuplot-scroll") {
|
||||||
@@ -911,7 +923,6 @@ SVG_render($$$$$$$$$)
|
|||||||
my $flog = shift; # #FileLog lines, as array pointer
|
my $flog = shift; # #FileLog lines, as array pointer
|
||||||
|
|
||||||
$SVG_RET="";
|
$SVG_RET="";
|
||||||
|
|
||||||
my $SVG_ss = AttrVal($parent_name, "smallscreen", 0);
|
my $SVG_ss = AttrVal($parent_name, "smallscreen", 0);
|
||||||
return $SVG_RET if(!defined($dp));
|
return $SVG_RET if(!defined($dp));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user