Fixed Issues with PGM2 (Function-Names)

git-svn-id: https://fhem.svn.sourceforge.net/svnroot/fhem/trunk/fhem@1180 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
odroegehorn
2012-01-07 12:07:47 +00:00
parent 0a5f244905
commit 3f4c2893a2
2 changed files with 196 additions and 200 deletions

View File

@@ -1,7 +1,7 @@
################################################################################# #################################################################################
# Copyright notice # Copyright notice
# #
# (c) 2008-2009 # (c) 2008-2012
# Copyright: Dr. Olaf Droegehorn # Copyright: Dr. Olaf Droegehorn
# o.droegehorn@dhs-computertechnik.de # o.droegehorn@dhs-computertechnik.de
# www.dhs-computertechnik.de # www.dhs-computertechnik.de
@@ -52,8 +52,8 @@ sub FHEMRENDERER_setAttr($$);
sub FHEMRENDERER_parseXmlList($); sub FHEMRENDERER_parseXmlList($);
sub FHEMRENDERER_render($); sub FHEMRENDERER_render($);
sub FHEMRENDERER_fatal($); sub FHEMRENDERER_fatal($);
sub pF($@); sub FHEMRENDERER_pF($@);
sub pO(@); sub FHEMRENDERER_pO(@);
#sub FHEMRENDERER_zoomLink($$$$); #sub FHEMRENDERER_zoomLink($$$$);
sub FHEMRENDERER_calcWeblink($$); sub FHEMRENDERER_calcWeblink($$);
@@ -221,7 +221,7 @@ FHEMRENDERER_Get($@)
if($t eq "fileplot") { if($t eq "fileplot") {
my @va = split(":", $v, 3); my @va = split(":", $v, 3);
if(@va != 3 || !$__devs{$va[0]}{INT}{currentlogfile}) { if(@va != 3 || !$__devs{$va[0]}{INT}{currentlogfile}) {
pO "<td>Broken definition: $v</a></td>"; FHEMRENDERER_pO "<td>Broken definition: $v</a></td>";
} else { } else {
if($va[2] eq "CURRENT") { if($va[2] eq "CURRENT") {
$__devs{$va[0]}{INT}{currentlogfile}{VAL} =~ m,([^/]*)$,; $__devs{$va[0]}{INT}{currentlogfile}{VAL} =~ m,([^/]*)$,;
@@ -295,7 +295,7 @@ FHEMRENDERER_parseXmlList($)
%__types = (); %__types = ();
$__title = ""; $__title = "";
foreach my $l (split("\n", fC("xmllist"))) { foreach my $l (split("\n", FHEMRENDERER_fC("xmllist"))) {
####### Device ####### Device
if($l =~ m/^\t\t<(.*) name="(.*)" state="(.*)" sets="(.*)" attrs="(.*)">/){ if($l =~ m/^\t\t<(.*) name="(.*)" state="(.*)" sets="(.*)" attrs="(.*)">/){
@@ -428,7 +428,7 @@ FHEMRENDERER_render($)
my ($f,$t)=($__devs{$d}{from}, $__devs{$d}{to}); my ($f,$t)=($__devs{$d}{from}, $__devs{$d}{to});
my @path = split(" ", fC("get $d $file $FHEMRENDERER_tmpfile$wl $f $t " . my @path = split(" ", FHEMRENDERER_fC("get $d $file $FHEMRENDERER_tmpfile$wl $f $t " .
join(" ", @filelog))); join(" ", @filelog)));
my $i = 0; my $i = 0;
$plot =~ s/\".*?using 1:[^ ]+ /"\"$path[$i++]\" using 1:2 "/gse; $plot =~ s/\".*?using 1:[^ ]+ /"\"$path[$i++]\" using 1:2 "/gse;
@@ -466,7 +466,7 @@ FHEMRENDERER_render($)
# $f = 0 if(!$f); # From the beginning of time... # $f = 0 if(!$f); # From the beginning of time...
# $t = 9 if(!$t); # till the end # $t = 9 if(!$t); # till the end
# #
# my $ret = fC("get $d $file INT $f $t " . join(" ", @filelog)); # my $ret = FHEMRENDERER_fC("get $d $file INT $f $t " . join(" ", @filelog));
# SVG_render($file, $__plotsize, $f, $t, \@data, $internal_data, $plot); # SVG_render($file, $__plotsize, $f, $t, \@data, $internal_data, $plot);
# #
# open (FH, ">$FHEMRENDERER_tmpfile$wl.svg"); # open (FH, ">$FHEMRENDERER_tmpfile$wl.svg");
@@ -482,13 +482,13 @@ sub
FHEMRENDERER_fatal($) FHEMRENDERER_fatal($)
{ {
my ($msg) = @_; my ($msg) = @_;
pO "<html><body>$msg</body></html>"; FHEMRENDERER_pO "<html><body>$msg</body></html>";
} }
################## ##################
# print formatted # print formatted
sub sub
pF($@) FHEMRENDERER_pF($@)
{ {
my $fmt = shift; my $fmt = shift;
$__RET .= sprintf $fmt, @_; $__RET .= sprintf $fmt, @_;
@@ -497,7 +497,7 @@ pF($@)
################## ##################
# print output # print output
sub sub
pO(@) FHEMRENDERER_pO(@)
{ {
$__RET .= shift; $__RET .= shift;
} }
@@ -505,7 +505,7 @@ pO(@)
################## ##################
# fhem command # fhem command
sub sub
fC($) FHEMRENDERER_fC($)
{ {
my ($cmd) = @_; my ($cmd) = @_;
#Log 0, "Calling $cmd"; #Log 0, "Calling $cmd";

View File

@@ -1,189 +1,185 @@
Description of the 02_FHEMRENDERER Module: Description of the 02_FHEMRENDERER Module:
(c) Olaf Droegehorn (c) Olaf Droegehorn
o.droegehorn@dhs-computertechnik.de o.droegehorn@dhs-computertechnik.de
www.dhs-computertechnik.de www.dhs-computertechnik.de
################################################################################# #################################################################################
# Copyright notice # Copyright notice
# #
# (c) 2008-2009 # (c) 2008-2011
# Copyright: Dr. Olaf Droegehorn # Copyright: Dr. Olaf Droegehorn
# All rights reserved # All rights reserved
# #
# This script free software; you can redistribute it and/or modify # This script free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# The GNU General Public License can be found at # The GNU General Public License can be found at
# http://www.gnu.org/copyleft/gpl.html. # http://www.gnu.org/copyleft/gpl.html.
# A copy is found in the textfile GPL.txt and important notices to the license # A copy is found in the textfile GPL.txt and important notices to the license
# from the author is found in LICENSE.txt distributed with these scripts. # from the author is found in LICENSE.txt distributed with these scripts.
# #
# This script is distributed in the hope that it will be useful, # This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# This copyright notice MUST APPEAR in all copies of the script! # This copyright notice MUST APPEAR in all copies of the script!
################################################################################# #################################################################################
Versions: Versions:
V1.0: Initial Version V1.0: Initial Version
V1.1: Bugfix: Enabled multiple RENERER Instances V1.1: Bugfix: Enabled multiple RENERER Instances
V1.2: Bugfix: Corrected Function-Names to avoid collision with PGM2
General Description:
General Description:
The FHEMRENDERER module is intended to render (draw) graphics based on the FHEM Log-Files.
This can be done either based on a timer (used in the module) or based on a direct call of GET. The FHEMRENDERER module is intended to render (draw) graphics based on the FHEM Log-Files.
The rendered graphics will be stored in a pre-defined directory with a predefined prefix of the files. This can be done either based on a timer (used in the module) or based on a direct call of GET.
The rendered graphics will be stored in a pre-defined directory with a predefined prefix of the files.
The FHEMRENDERER uses attributes to control the behaviour:
plotmode gnuplot The FHEMRENDERER uses attributes to control the behaviour:
plotsize 800,200 plotmode gnuplot
refresh 00:10:00 plotsize 800,200
room Unsorted refresh 00:10:00
status off room Unsorted
tmpfile /tmp/ status off
multiprocess off tmpfile /tmp/
These attributes have the following meaning: These attributes have the following meaning:
plotmode, plotsize: Control gnuplot and the desired output plotmode, plotsize: Control gnuplot and the desired output
refresh: type HH:MM:SS, is the time-interval in which the re-rendering is done refresh: type HH:MM:SS, is the time-interval in which the re-rendering is done
status: Tells if the timer-based re-rendering is on/off status: Tells if the timer-based re-rendering is on/off
tmpfile: Is the path (and prefix, if given) of the graphic-files, that will be rendered tmpfile: Is the path (and prefix, if given) of the graphic-files, that will be rendered
multiprocess: You can set "on" or "off". If multiprocess is "on" the time-scheduled renderings will be done in a
mutli-process manner, and FHEM will not be blocked by the rendering process. NOTE: The timer-based rendering renders ONLY those fileplots, for which you have defined a WebLink !
See WebLink for more details on how to define.
NOTE: The timer-based rendering renders ONLY those fileplots, for which you have defined a WebLink !
See WebLink for more details on how to define. NOTE: At the moment the renderer supports only GNUPLOT, meaning gnuplot is used to draw the graphics. The supported
modes are (gnuplot and gnuplot-scroll).
NOTE: At the moment the renderer supports only GNUPLOT, meaning gnuplot is used to draw the graphics. The supported
modes are (gnuplot and gnuplot-scroll).
Supported commands are:
Supported commands are: define/set/get/attributes
define/set/get/attributes
DEFINE
DEFINE define <name> <type> <type-specific>
define <name> <type> <type-specific> Define a device. You need devices if you want to manipulate them (e.g. set on/off).
Use "define <name> ?" to get a list of possible types.
Define a device. You need devices if you want to manipulate them (e.g. set on/off).
Use "define <name> ?" to get a list of possible types. Type FHEMRENDERER
Type FHEMRENDERER define <name> FHEMRENDERER [global]
define <name> FHEMRENDERER [global] This defines a new "device", that is of type FHEMRENDERER. The option 'global' can be used if needed for sorting reasons.
Otherwise this option has no real meaning for FHEMRENDERER.
This defines a new "device", that is of type FHEMRENDERER. The option 'global' can be used if needed for sorting reasons.
Otherwise this option has no real meaning for FHEMRENDERER. As a side-effect of defining this "device" the following attributes will be set for this "device":
plotmode gnuplot
As a side-effect of defining this "device" the following attributes will be set for this "device": plotsize 800,200
plotmode gnuplot refresh 00:10:00
plotsize 800,200 room Unsorted
refresh 00:10:00 status off
room Unsorted tmpfile /tmp/
status off
tmpfile /tmp/
multiprocess off NOTE: The Logfile will report (with LogLevel 2) that the FHEMRENDERER has been defined.
Examples:
NOTE: The Logfile will report (with LogLevel 2) that the FHEMRENDERER has been defined. define renderer FHEMRENDERER
Examples: SET
define renderer FHEMRENDERER
set <name> <type-specific>
SET
Set parameters of a device / send signals to a device. You can get a list of possible commands by
set <name> <type-specific> set <name> ?
Set parameters of a device / send signals to a device. You can get a list of possible commands by Type FHEMRENDERER:
set <name> ? set FHEMRENDERER on/off
Type FHEMRENDERER: This switches the timer-based rendering on/off. The attribute 'status' will be modified accordingly.
set FHEMRENDERER on/off NOTE: only WebLink based graphics will be rendered.
This switches the timer-based rendering on/off. The attribute 'status' will be modified accordingly. GET
NOTE: only WebLink based graphics will be rendered. get <name> <type-specific>
GET Ask a value directly from the device, and wait for an answer. In general, you can get a list of possible commands by
get <name> <type-specific> get <device> ?
Ask a value directly from the device, and wait for an answer. In general, you can get a list of possible commands by Type FHEMRENDERER:
get <device> ? get FHEMRENDERER [[file-name] device type logfile [pos=zoom=XX&off=YYY]]
Type FHEMRENDERER: the get function supports different sets of arguments:
get FHEMRENDERER [[file-name] device type logfile [pos=zoom=XX&off=YYY]] Arguments:
NONE: all WebLink based FilePlots will be rerendered
the get function supports different sets of arguments: The resulting filename will be '<attr-tmpfile><weblinkname>.png'
Arguments: THREE: '<device> <type> <logfile>'
NONE: all WebLink based FilePlots will be rerendered In this case only one specific graphic will be rendered:
The resulting filename will be '<attr-tmpfile><weblinkname>.png' A graphic will be rendered for 'device', where device is a FileLog, based on the type 'type' based on the given 'logfile'
THREE: '<device> <type> <logfile>' The resulting filename will be '<attr-tmpfile>logfile.png'
In this case only one specific graphic will be rendered: FOUR: '<file-name> <device> <type> <logfile>'
A graphic will be rendered for 'device', where device is a FileLog, based on the type 'type' based on the given 'logfile' In this case only one specific graphic will be rendered:
The resulting filename will be '<attr-tmpfile>logfile.png' A graphic will be rendered for 'device', where device is a FileLog, based on the type 'type' based on the given 'logfile'
FOUR: '<file-name> <device> <type> <logfile>' The resulting filename will be '<attr-tmpfile><file-name>.png'
In this case only one specific graphic will be rendered: FIVE: '<file-name> <device> <type> <logfile> pos=zoom=XX&off=YYY'
A graphic will be rendered for 'device', where device is a FileLog, based on the type 'type' based on the given 'logfile' In this case only one specific graphic will be rendered assuming that plotmode is 'gnuplot-scroll':
The resulting filename will be '<attr-tmpfile><file-name>.png' A graphic will be rendered for 'device', where device is a FileLog, based on the type 'type' based on the given 'logfile'
FIVE: '<file-name> <device> <type> <logfile> pos=zoom=XX&off=YYY' The 'zoom' will be either qday/day/week/month/year (same as used in FHEMWEB).
In this case only one specific graphic will be rendered assuming that plotmode is 'gnuplot-scroll': The offset 'off' is either 0 (then the second part can be omitted, or -1/-2.... to jump back in time.
A graphic will be rendered for 'device', where device is a FileLog, based on the type 'type' based on the given 'logfile' The resulting filename will be '<attr-tmpfile><file-name>.png'
The 'zoom' will be either qday/day/week/month/year (same as used in FHEMWEB).
The offset 'off' is either 0 (then the second part can be omitted, or -1/-2.... to jump back in time. NOTE: If you want to use zoom AND offset then you have to concatenate via '&' !!
The resulting filename will be '<attr-tmpfile><file-name>.png'
NOTE: combinations are possible in limited ranges:
NOTE: If you want to use zoom AND offset then you have to concatenate via '&' !! meaning: you can add the 'pos=zoom=XX&off=YY' to any of the first three sets.
This may e.g. result in rendering all WebLinks with a specific zoom or offset
NOTE: combinations are possible in limited ranges: (if you just pass the 'pos=zoom=xx&off=yy' parameter);
meaning: you can add the 'pos=zoom=XX&off=YY' to any of the first three sets.
This may e.g. result in rendering all WebLinks with a specific zoom or offset Any rendered image (one or all WebLinks) will be stored in <attr-tmpfile> followed by a filename'.png'. The filename will be
(if you just pass the 'pos=zoom=xx&off=yy' parameter); either derived (from weblink-name or logfile-name) or, for single files, can be assigend.
Any rendered image (one or all WebLinks) will be stored in <attr-tmpfile> followed by a filename'.png'. The filename will be Examples:
either derived (from weblink-name or logfile-name) or, for single files, can be assigend. get FHEMRENDERER
get FHEMRENDERER pos=zoom=week&off=-1
Examples: get FHEMRENDERER azlog fht az-2008-38.log pos=zoom=0
get FHEMRENDERER get FHEMRENDERER livingroomgraphics wzlog fht wz-2008-38.log pos=zoom=0
get FHEMRENDERER pos=zoom=week&off=-1
get FHEMRENDERER azlog fht az-2008-38.log pos=zoom=0
get FHEMRENDERER livingroomgraphics wzlog fht wz-2008-38.log pos=zoom=0 ATTR
attr <name> <attrname> <value>
ATTR
Set an attribute to something defined by define.
attr <name> <attrname> <value> Use "attr <name> ?" to get a list of possible attributes.
Set an attribute to something defined by define. Type FHEMRENDERER:
Use "attr <name> ?" to get a list of possible attributes. attr FHEMRENDERER <attrname> <value>
Type FHEMRENDERER: Attributes: <Values>
attr FHEMRENDERER <attrname> <value> plotmode gnuplot / gnuplot-scroll
plotsize Dimension of graphic e.g. 800,200
Attributes: <Values> refresh Timer-Interval for rerendering (HH:MM:SS)
plotmode gnuplot / gnuplot-scroll status Status of the Timer (off/on)
plotsize Dimension of graphic e.g. 800,200 tmpfile Path and prefix of for the rendered graphics (e.g. /tmp/)
refresh Timer-Interval for rerendering (HH:MM:SS)
status Status of the Timer (off/on)
tmpfile Path and prefix of for the rendered graphics (e.g. /tmp/)
multiprocess on / off
Installation:
Copy the file pgm5/02_FHEMRENDERER.pm to the installed FHEM directory.
This gives you a graphic rendering engine (gnuplot & gnuplot-scroll at the moment), which can be configured to renderer images in intervals.
Installation: The *.gplot files should be reused from the built-in FHEMWEB and should reside in the installed FHEM directory. Here we don't provide specific *.gplot files as the mechanisms are exactly the same.
Copy the file pgm5/02_FHEMRENDERER.pm to the installed FHEM directory.
This gives you a graphic rendering engine (gnuplot & gnuplot-scroll at the moment), which can be configured to renderer images in intervals. If you want to have access to plotted logs, then make sure that gnuplot is installed and set the logtype for the FileLog device (see commandref.html and example/04_log).
Copy the file contrib/99_weblink.pm to the installed FHEM directory.
The *.gplot files should be reused from the built-in FHEMWEB and should reside in the installed FHEM directory. Here we don't provide specific *.gplot files as the mechanisms are exactly the same.
If you want to have access to plotted logs, then make sure that gnuplot is installed and set the logtype for the FileLog device (see commandref.html and example/04_log).
Copy the file contrib/99_weblink.pm to the installed FHEM directory.