2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00

plotfunction ptches by Tobias

git-svn-id: https://svn.fhem.de/fhem/trunk@2136 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2012-11-18 08:42:30 +00:00
parent b555cdda20
commit 02296ff6d8
2 changed files with 41 additions and 5 deletions

View File

@ -1320,17 +1320,31 @@ FW_readgplotfile($$$)
open(FH, $gplot_pgm) || return (FW_fatal("$gplot_pgm: $!"), undef);
while(my $l = <FH>) {
$l =~ s/\r//g;
my $plotfn = undef;
if($l =~ m/^#FileLog (.*)$/ &&
($wltype eq "fileplot" || $wl eq "FileLog")) {
push(@filelog, $1);
$plotfn = $1;
} elsif ($l =~ m/^#DbLog (.*)$/ &&
($wltype eq "dbplot" || $wl eq "DbLog")) {
push(@filelog, $1);
$plotfn = $1;
} elsif($l =~ "^plot" || $plot) {
$plot .= $l;
} else {
push(@data, $l);
}
if($plotfn) {
my $specval = AttrVal($wl, "plotfunction", undef);
if ($specval) {
my @spec = split(" ",$specval);
my $spec_count=1;
foreach (@spec) {
$plotfn =~ s/<SPEC$spec_count>/$_/g;
$spec_count++;
}
}
push(@filelog, $plotfn);
}
}
close(FH);

View File

@ -12,7 +12,7 @@ weblink_Initialize($)
my ($hash) = @_;
$hash->{DefFn} = "weblink_Define";
$hash->{AttrList}= "fixedrange plotmode plotsize label title htmlattr";
$hash->{AttrList}= "fixedrange plotmode plotsize label title htmlattr plotfunction";
}
@ -45,7 +45,7 @@ weblink_Define($$)
<a name="weblinkdefine"></a>
<b>Define</b>
<ul>
<code>define &lt;name&gt; weblink [link|fileplot|image|iframe|htmlCode]
<code>define &lt;name&gt; weblink [link|fileplot|dbplot|image|iframe|htmlCode]
&lt;argument&gt;</code>
<br><br>
This is a placeholder used with webpgm2 to be able to integrate links
@ -60,6 +60,7 @@ weblink_Define($$)
<code>define hr weblink htmlCode &lt;hr&gt</code><br>
<code>define w_Frlink weblink htmlCode { WeatherAsHtml("w_Frankfurt") }</code><br>
<code>define MyPlot weblink fileplot &lt;logdevice&gt;:&lt;gnuplot-file&gt;:&lt;logfile&gt;</code><br>
<code>define MyPlot weblink dbplot &lt;logdevice&gt;:&lt;gnuplot-file&gt;</code><br>
</ul>
<br>
@ -133,7 +134,28 @@ weblink_Define($$)
<li>title<br>
A special form of label (see above), which replaces the string &lt;TL&gt;
in the .gplot file. It defaults to the filename of the logfile.
</li>
</li>
<a name="plotfunction"></a>
<li>plotfunction<br>
Space value separated list of values. The value will be used to replace
&lt;SPEC#&gt; type of strings in the .gplot file, with # beginning at 1
(&lt;SPEC1&gt;, &lt;SPEC2&gt;, etc.) in the #FileLog or #DbLog directive.
With this attribute you can use the same .gplot file for multiple devices
with the same logdevice.
<ul><b>Example:</b><br>
<li>#FileLog <SPEC1><br>
with: attr <weblinkdevice> plotfunction "4:IR\x3a:0:"<br>
instead of<br>
#FileLog 4:IR\x3a:0:
</li>
<li>#DbLog <SPEC1><br>
with: attr <weblinkdevice> plotfunction "Garage_Raumtemp:temperature::"<br>
instead of<br>
#DbLog Garage_Raumtemp:temperature::
</li>
</ul>
</li>
</ul>
<br>