From e09dfa796534b4072a3bbbcdfeabf83dd85aa2b7 Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Sun, 18 Nov 2012 08:42:30 +0000 Subject: [PATCH] plotfunction ptches by Tobias git-svn-id: https://fhem.svn.sourceforge.net/svnroot/fhem/trunk/fhem@2136 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/01_FHEMWEB.pm | 18 ++++++++++++++++-- FHEM/98_weblink.pm | 28 +++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/FHEM/01_FHEMWEB.pm b/FHEM/01_FHEMWEB.pm index 5b52c101b..a0fa4cf8b 100755 --- a/FHEM/01_FHEMWEB.pm +++ b/FHEM/01_FHEMWEB.pm @@ -1320,17 +1320,31 @@ FW_readgplotfile($$$) open(FH, $gplot_pgm) || return (FW_fatal("$gplot_pgm: $!"), undef); while(my $l = ) { $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//$_/g; + $spec_count++; + } + } + push(@filelog, $plotfn); + } } close(FH); diff --git a/FHEM/98_weblink.pm b/FHEM/98_weblink.pm index e9ed0e0c4..e82c9c84e 100755 --- a/FHEM/98_weblink.pm +++ b/FHEM/98_weblink.pm @@ -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($$) Define
    - define <name> weblink [link|fileplot|image|iframe|htmlCode] + define <name> weblink [link|fileplot|dbplot|image|iframe|htmlCode] <argument>

    This is a placeholder used with webpgm2 to be able to integrate links @@ -60,6 +60,7 @@ weblink_Define($$) define hr weblink htmlCode <hr>
    define w_Frlink weblink htmlCode { WeatherAsHtml("w_Frankfurt") }
    define MyPlot weblink fileplot <logdevice>:<gnuplot-file>:<logfile>
    + define MyPlot weblink dbplot <logdevice>:<gnuplot-file>

@@ -133,7 +134,28 @@ weblink_Define($$)
  • title
    A special form of label (see above), which replaces the string <TL> in the .gplot file. It defaults to the filename of the logfile. -
  • + + + +
  • plotfunction
    + Space value separated list of values. The value will be used to replace + <SPEC#> type of strings in the .gplot file, with # beginning at 1 + (<SPEC1>, <SPEC2>, etc.) in the #FileLog or #DbLog directive. + With this attribute you can use the same .gplot file for multiple devices + with the same logdevice. +
      Example:
      +
    • #FileLog
      + with: attr plotfunction "4:IR\x3a:0:"
      + instead of
      + #FileLog 4:IR\x3a:0: +
    • +
    • #DbLog
      + with: attr plotfunction "Garage_Raumtemp:temperature::"
      + instead of
      + #DbLog Garage_Raumtemp:temperature:: +
    • +
    +