From 58b84edf1d798db91b207e5a9e08110a39244257 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Mon, 28 Jul 2008 12:33:29 +0000 Subject: [PATCH] Preparing 4.4: Doc checking and small fixes git-svn-id: https://svn.fhem.de/fhem/trunk@217 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 3 + fhem/FHEM/92_FileLog.pm | 45 +++++---- fhem/HISTORY | 8 ++ fhem/Makefile | 31 +++++-- fhem/contrib/99_SUNRISE.pm | 1 + fhem/docs/commandref.html | 138 +++++++++++++++------------- fhem/docs/faq.html | 37 ++++---- fhem/docs/fhem.html | 53 +++++------ fhem/docs/pgm2-1.png | Bin 37956 -> 54031 bytes fhem/fhem.pl | 13 ++- fhem/webfrontend/pgm2/01_FHEMWEB.pm | 114 ++++++++++++++++------- fhem/webfrontend/pgm2/em.gplot | 5 +- fhem/webfrontend/pgm2/fht.gplot | 8 +- fhem/webfrontend/pgm2/fs20.gplot | 8 +- fhem/webfrontend/pgm2/ks300_1.gplot | 10 +- fhem/webfrontend/pgm2/ks300_2.gplot | 8 +- fhem/webfrontend/pgm2/ks300_3.gplot | 8 +- fhem/webfrontend/pgm2/mpiri.gplot | 9 +- fhem/webfrontend/pgm2/piri.gplot | 8 +- 19 files changed, 292 insertions(+), 215 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 36cac8166..65a9e300f 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -414,3 +414,6 @@ - ==DATE== (4.4) - feature: RM100-2 battery empty warning (mare 23.07.08) - feature: optimising the pgm2/SVG memory usage + - feature: autoloading FHEM modules + - bugfix: STATE/$value is carrying again the correct value + - feature: enhancing the Makefile and the documentation diff --git a/fhem/FHEM/92_FileLog.pm b/fhem/FHEM/92_FileLog.pm index 471ef75a4..ca2ba1a7e 100755 --- a/fhem/FHEM/92_FileLog.pm +++ b/fhem/FHEM/92_FileLog.pm @@ -203,6 +203,7 @@ FileLog_Get($@) $h{fh} = new IO::File "> $fname[$i]"; } $h{re} = $fld[1]; + $h{df} = defined($fld[2]) ? $fld[2] : ""; $h{fn} = $fld[3]; $h{didx} = 10 if($fld[3] && $fld[3] eq "delta-d"); @@ -210,9 +211,15 @@ FileLog_Get($@) if($fld[0] =~ m/"(.*)"/) { $h{col} = $1; - $h{isfix} = 1; + $h{type} = 0; } else { $h{col} = $fld[0]-1; + $h{type} = 1; + } + if($h{fn}) { + $h{type} = 4; + $h{type} = 2 if($h{didx}); + $h{type} = 3 if($h{fn} eq "int"); } $h{ret} = ""; $d[$i] = \%h; @@ -225,19 +232,20 @@ FileLog_Get($@) for my $i (0..int(@a)-1) { # Process each req. field my $h = $d[$i]; - my $re = $h->{re}; - next if($re && $l !~ m/$re/); # 20% + next if($h->{re} && $l !~ m/$h->{re}/); # 20% my $col = $h->{col}; - my $line = ""; + my $t = $h->{type}; + my $line; - if($h->{isfix}) { # Fixed text - $line = "$fld[0] $col"; - } elsif(!$h->{fn}) { # The column - $line = "$fld[0] $fld[$col]"; + if($t == 0) { # Fixed text + $line = "$fld[0] $col\n"; - } elsif($h->{didx}) { # delta-h or delta-d + } elsif($t == 1) { # The column + $line = "$fld[0] $fld[$col]\n"; + + } elsif($t == 2) { # delta-h or delta-d my $hd = $h->{didx}; my $ld = substr($fld[0],0,$hd); @@ -248,31 +256,29 @@ FileLog_Get($@) $ts = "$lda[1]:30:00" if($hd == 13); my $v = $fld[$col]-$h->{last1}; $v = 0 if($v < 0); # Skip negative delta - $line = sprintf("%s_%s %0.1f", $lda[0],$ts, $v); + $line = sprintf("%s_%s %0.1f\n", $lda[0],$ts, $v); } $h->{last1} = $fld[$col]; $h->{last3} = $ld; } $h->{last2} = $fld[$col]; $lastdate{$hd} = $fld[0]; + next if(!$line); - } elsif($h->{fn} eq "int") { # int function + } elsif($t == 3) { # int function my $val = $fld[$col]; - $line = "$fld[0] $1" if($val =~ m/^([0-9]+).*/); + $line = "$fld[0] $1\n" if($val =~ m/^([0-9]+).*/); - } else { - $line = "$fld[0] " . eval($h->{fn}); + } else { # evaluate + $line = "$fld[0] " . eval($h->{fn}) . "\n"; } - next if(!$line); - - $h->{count}++; - $line .= "\n"; if($outf eq "-") { $h->{ret} .= $line; } else { my $fh = $h->{fh}; print $fh $line; + $h->{count}++; } } } @@ -292,7 +298,6 @@ FileLog_Get($@) if($outf eq "-") { $h->{ret} .= $line; - $h->{count}++; } else { my $fh = $h->{fh}; print $fh $line; @@ -300,7 +305,7 @@ FileLog_Get($@) } } if($outf eq "-") { - $h->{ret} .= "$from $h->{df}\n" if(!$h->{count} && $h->{df} ne ""); + $h->{ret} .= "$from $h->{df}\n" if(!$h->{ret} && $h->{df} ne ""); $ret .= $h->{ret} if($h->{ret}); $ret .= "#$a[$i]\n"; } else { diff --git a/fhem/HISTORY b/fhem/HISTORY index e97db89cf..456a339be 100644 --- a/fhem/HISTORY +++ b/fhem/HISTORY @@ -305,3 +305,11 @@ Tested with Firefox 3.0. Todo: Test with IE+Adobe Plugin/Opera. - feature: HOWTO for webpgm2 (first chapter) + +Fri Jul 25 18:14:26 MEST 2008 + - Autoloading modules. In order to make module installation easier and + to optimize memory usage, modules are loaded when the first device of a + certain category is defined. Exceptions are the modules prefixed with 99, + these are considered "utility" modules and are loaded at the beginning. + Some of the older 99_x modules were renamed (99_SVG, 99_dummy), and most + contrib modules were moved to the main FHEM directory. diff --git a/fhem/Makefile b/fhem/Makefile index a946bb9d7..2f90ea22f 100644 --- a/fhem/Makefile +++ b/fhem/Makefile @@ -1,30 +1,43 @@ BINDIR=/usr/local/bin MODDIR=/usr/local/lib +VARDIR=/var/log/fhem VERS=4.3 DATE=2008-07-12 -DIR=fhem-$(VERS) all: @echo Nothing to do for all. @echo To install, check the Makefile, and then \'make install\' + @echo or \'make install-pgm2\' to install a web frontend too. -install: +install:install-base + cp examples/sample_fhem $(VARDIR)/fhem.cfg + @echo + @echo + @echo Edit $(VARDIR)/fhem.cfg then type perl $(BINDIR)/fhem.pl $(VARDIR)/fhem.cfg + +install-pgm2:install-base + cp webfrontend/pgm2/* $(MODDIR)/FHEM + cp docs/commandref.html docs/faq.html docs/HOWTO.html $(MODDIR)/FHEM + cp examples/sample_pgm2 $(VARDIR)/fhem.cfg + cd examples; for i in *; do cp $$i $(MODDIR)/FHEM/example.$$i; done + @echo + @echo + @echo Edit $(VARDIR)/fhem.cfg then start perl $(BINDIR)/fhem.pl $(VARDIR)/fhem.cfg + +install-base: cp fhem.pl $(BINDIR) cp -r FHEM $(MODDIR) - perl -pi -e 's,modpath .,modpath $(MODDIR),' examples/* - -install-pgm2: - cp fhem.pl $(BINDIR) - cp -r FHEM $(MODDIR) - cp -r webfrontend/pgm2/* $(MODDIR) - perl -pi -e 's,modpath .,modpath $(MODDIR),' examples/* + mkdir -p $(VARDIR) + perl -pi -e 's,modpath \.,modpath $(MODDIR),' examples/* + perl -pi -e 's,/tmp,$(VARDIR),' examples/* dist: @echo Version is $(VERS), Date is $(DATE) mkdir .f cp -r CHANGED FHEM HISTORY Makefile README.CVS em1010pc\ TODO contrib docs examples fhem.pl test webfrontend .f + find .f -name CVS -print | xargs rm -rf find .f -name \*.orig -print | xargs rm -f find .f -name .#\* -print | xargs rm -f find .f -type f -print |\ diff --git a/fhem/contrib/99_SUNRISE.pm b/fhem/contrib/99_SUNRISE.pm index 1e490098b..5970c66c8 100755 --- a/fhem/contrib/99_SUNRISE.pm +++ b/fhem/contrib/99_SUNRISE.pm @@ -1,4 +1,5 @@ ############################################## +# - Use 99_SUNRISE_EL.pm instead of this module # - Be aware: Installing the DateTime modules might be tedious, one way is: # perl -MCPAN -e shell # cpan> install DateTime::Event::Sunrise diff --git a/fhem/docs/commandref.html b/fhem/docs/commandref.html index 8a8e9d3b3..8127cf2ac 100644 --- a/fhem/docs/commandref.html +++ b/fhem/docs/commandref.html @@ -166,9 +166,16 @@ make editing of multiline commands transparent.

  • modpath
    Specify the path to the modules directory FHEM. The path - should not contain the directory FHEM. Every file there with the - name pattern <number>_<name>.pm will be loaded in the order - of the number. + should not contain the directory FHEM. Upon setting the + attribute, the directory will be scanned for filenames of the form + NN_<NAME>.pm, and make them available for device definition under + <NAME>. If the first device of type <NAME> is defined, the + module will be loaded, and its function with the name + <NAME>_initialize will be called. Exception to this rule are + modules with NN=99, these are considered to be utility modules + containing only perl helper functions, they are loaded at startup (i.e. + modpath attribute definition time). +

  • @@ -325,7 +332,7 @@ make editing of multiline commands transparent.

  • logtype
    Can be applied to FileLog devices.
    - Used by the pgm2 webfrontend to offer gnuplot images made from the + Used by the pgm2 webfrontend to offer gnuplot/SVG images made from the logs. The string is made up of tokens separated by comma (,), each token specifies a different gnuplot program. The token may contain a colon (:), the part before the colon defines the name of the program, @@ -357,13 +364,10 @@ make editing of multiline commands transparent.

    above, both programs evaluate the same log.
  • text
    - Shows the logfile as it is (plain text). + Shows the logfile as it is (plain text). Not gnuplot definition + is needed.
  • - The corresponding gnuplot files (up to the "text" one) must be - installed, see the fhemweb.pl configuration for the destination - directory.
    - Example:
    attr fhtlog1 logtype ks300_1:Temp/Rain,ks300_2:Hum/Wind,text:Raw-data
    @@ -385,42 +389,40 @@ make editing of multiline commands transparent.

    devices:
    @@ -1148,9 +1166,8 @@ make editing of multiline commands transparent.

    of the sunset/sunrise functions should be used with the relative (+) flag -
  • In order to use the sunrise_rel()/sunset_rel() functions, copy the - 99_SUNRISE_EL.pm file from the contrib into the modules (FHEM) - directory, and put { sunrise_coord(long, lat, "") } into your +
  • In order to use the sunrise_rel()/sunset_rel() functions, + put { sunrise_coord(long, lat, "") } into your lastinclude file, as in the above example. If you are not using sunrise_coord, then the coordinates for Frankfurt am Main, Germany will be used. @@ -1217,10 +1234,8 @@ make editing of multiline commands transparent.

    href="#list">list output in paranthesis after the device name, or the string you see when you do a detailed list of the device.
  • -
  • Each undefined device (FS20, HMS, FHT) will be reported with the device name "UNDEFINED". The % parameter will contain the type (FS20, @@ -1235,8 +1250,8 @@ make editing of multiline commands transparent.

    define <name> weblink [link|fileplot] <argument>

    This is a placeholder used with webpgm2 to be able to integrate links - into it, and to be able to put more than one gnuplot picture on one page. - It has no set or get methods. + into it, and to be able to put more than one gnuplot/SVG picture on one + page. It has no set or get methods. Examples: @@ -1271,11 +1284,6 @@ make editing of multiline commands transparent.

    define myvar dummy
    set myvar 7
    - Notes: - > @@ -2221,8 +2229,8 @@ Send buffer:
    2007-10-19 00:31:24 desired-temp 22.5
  • - If you add the 99_SUNRISE_EL.pm from the contrib directory to your module - directory, then you have access to the following functions:
    + By using the 99_SUNRISE_EL.pm module, you have access to the following + functions: