2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

Preparing THE SPLIT

git-svn-id: https://svn.fhem.de/fhem/trunk@2075 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2012-11-04 13:29:55 +00:00
parent 82b312330b
commit 6bfffbb57b
10 changed files with 1327 additions and 1270 deletions

View File

@ -7,6 +7,7 @@
- feature: optional second parameter to fhem() to make it silent - feature: optional second parameter to fhem() to make it silent
- feature: autoloading commands, XmlList/etc renamed from 99 to 98. - feature: autoloading commands, XmlList/etc renamed from 99 to 98.
- feature: FHEMWEB returns external files in chunks to save memory - feature: FHEMWEB returns external files in chunks to save memory
- feature: commandref.html splitted: documentation is now appended to the modules.
- 2012-10-28 (5.3) - 2012-10-28 (5.3)
- feature: added functions trim, ltrim, rtrim, UntoggleDirect, UntoggleIndirect - feature: added functions trim, ltrim, rtrim, UntoggleDirect, UntoggleIndirect

View File

@ -475,13 +475,3 @@ ZWave_Undef($$)
} }
1; 1;
=begin html
<a name="CUL"></a>
<h3>CUL</h3>
<ul>
text
</ul>
=end html

View File

@ -333,3 +333,5 @@ energy_Undef($$)
return undef; return undef;
} }
1;

View File

@ -345,3 +345,4 @@ if ( $kind ne 0 ){
} }
} }
1;

View File

@ -1,154 +1,154 @@
############################################## ##############################################
# $Id: 76_MSGFile.pm 2012-06-20 18:29:00 rbente # $Id: 76_MSGFile.pm 2012-06-20 18:29:00 rbente
############################################## ##############################################
package main; package main;
use strict; use strict;
use warnings; use warnings;
use Switch; use Switch;
my %sets = ( my %sets = (
"add" => "MSGFile", "add" => "MSGFile",
"clear" => "MSGFile", "clear" => "MSGFile",
"list" => "MSGFile" "list" => "MSGFile"
); );
############################################## ##############################################
# Initialize Function # Initialize Function
# Attributes are: # Attributes are:
# filename the name of the file # filename the name of the file
# filemode new = file will be created from scratch # filemode new = file will be created from scratch
# append = add the new lines to the end of the existing data # append = add the new lines to the end of the existing data
# CR 0 = no CR added to the end of the line # CR 0 = no CR added to the end of the line
# 1 = CR added to the end of the line # 1 = CR added to the end of the line
############################################## ##############################################
sub sub
MSGFile_Initialize($) MSGFile_Initialize($)
{ {
my ($hash) = @_; my ($hash) = @_;
$hash->{SetFn} = "MSGFile_Set"; $hash->{SetFn} = "MSGFile_Set";
$hash->{DefFn} = "MSGFile_Define"; $hash->{DefFn} = "MSGFile_Define";
$hash->{UndefFn} = "MSGFile_Undef"; $hash->{UndefFn} = "MSGFile_Undef";
$hash->{AttrList} = "loglevel:0,1,2,3,4,5,6 filename filemode:new,append CR:0,1"; $hash->{AttrList} = "loglevel:0,1,2,3,4,5,6 filename filemode:new,append CR:0,1";
} }
############################################## ##############################################
# Set Function # Set Function
# all the data are stored in the global array @data # all the data are stored in the global array @data
# as counter we use a READING named msgcount # as counter we use a READING named msgcount
############################################## ##############################################
sub sub
MSGFile_Set($@) MSGFile_Set($@)
{ {
my ($hash, @a) = @_; my ($hash, @a) = @_;
return "Unknown argument $a[1], choose one of -> " . join(" ", sort keys %sets) return "Unknown argument $a[1], choose one of -> " . join(" ", sort keys %sets)
if(!defined($sets{$a[1]})); if(!defined($sets{$a[1]}));
my $name = shift @a; my $name = shift @a;
return "no set value specified" if(int(@a) < 1); return "no set value specified" if(int(@a) < 1);
return "Unknown argument ?" if($a[0] eq "?"); return "Unknown argument ?" if($a[0] eq "?");
my $v = join(" ", @a); my $v = join(" ", @a);
##### we like to add another line of data ##### we like to add another line of data
if($a[0] eq "add") if($a[0] eq "add")
{ {
##### split the line in command and data ##### split the line in command and data
my $mx = shift @a; my $mx = shift @a;
my $my = join(" ",@a); my $my = join(" ",@a);
##### check if we like to have and CR at the end of the line ##### check if we like to have and CR at the end of the line
if(AttrVal($name, "CR", "0") eq "1") if(AttrVal($name, "CR", "0") eq "1")
{ {
$my = $my . "\n"; $my = $my . "\n";
} }
##### get the highest number of lines, store the line in @data and increase ##### get the highest number of lines, store the line in @data and increase
##### the counter, at the end set the status ##### the counter, at the end set the status
my $count = $hash->{READINGS}{msgcount}{VAL}; my $count = $hash->{READINGS}{msgcount}{VAL};
$data{$name}{$count} = $my; $data{$name}{$count} = $my;
$hash->{READINGS}{msgcount}{TIME} = TimeNow(); $hash->{READINGS}{msgcount}{TIME} = TimeNow();
$hash->{READINGS}{msgcount}{VAL} = $count + 1; $hash->{READINGS}{msgcount}{VAL} = $count + 1;
$hash->{STATE} = "addmsg"; $hash->{STATE} = "addmsg";
} }
##### we like to clear our buffer, first clear all lines of @data ##### we like to clear our buffer, first clear all lines of @data
##### and then set the counter to 0 and the status to clear ##### and then set the counter to 0 and the status to clear
if($a[0] eq "clear") if($a[0] eq "clear")
{ {
my $i; my $i;
for($i=0;$i<ReadingsVal($name,"msgcount",0);$i++) for($i=0;$i<ReadingsVal($name,"msgcount",0);$i++)
{ {
$data{$name}{$i} = ""; $data{$name}{$i} = "";
} }
$hash->{READINGS}{msgcount}{TIME} = TimeNow(); $hash->{READINGS}{msgcount}{TIME} = TimeNow();
$hash->{READINGS}{msgcount}{VAL} = 0; $hash->{READINGS}{msgcount}{VAL} = 0;
$hash->{STATE} = "clear"; $hash->{STATE} = "clear";
} }
##### we like to see the buffer ##### we like to see the buffer
if($a[0] eq "list") if($a[0] eq "list")
{ {
my $i; my $i;
my $mess = "---- Lines of data for $name ----\n"; my $mess = "---- Lines of data for $name ----\n";
for($i=0;$i<ReadingsVal($name,"msgcount",0);$i++) for($i=0;$i<ReadingsVal($name,"msgcount",0);$i++)
{ {
$mess .= $data{$name}{$i}; $mess .= $data{$name}{$i};
} }
return "$mess---- End of data for $name ----"; return "$mess---- End of data for $name ----";
} }
Log GetLogLevel($name,2), "messenger set $name $v"; Log GetLogLevel($name,2), "messenger set $name $v";
# set stats # set stats
# $hash->{CHANGED}[0] = $v; # $hash->{CHANGED}[0] = $v;
$hash->{READINGS}{state}{TIME} = TimeNow(); $hash->{READINGS}{state}{TIME} = TimeNow();
$hash->{READINGS}{state}{VAL} = $v; $hash->{READINGS}{state}{VAL} = $v;
return undef; return undef;
} }
############################################## ##############################################
# Define Function # Define Function
# set the counter to 0 # set the counter to 0
# and filemode to "new" # and filemode to "new"
############################################## ##############################################
sub sub
MSGFile_Define($$) MSGFile_Define($$)
{ {
my ($hash, $def) = @_; my ($hash, $def) = @_;
my @a = split("[ \t][ \t]*", $def); my @a = split("[ \t][ \t]*", $def);
my $errmsg = "wrong syntax: define <name> MSGFile filename"; my $errmsg = "wrong syntax: define <name> MSGFile filename";
my $name = $hash->{NAME}; my $name = $hash->{NAME};
return $errmsg if(@a != 3); return $errmsg if(@a != 3);
$attr{$name}{filename} = $a[2]; $attr{$name}{filename} = $a[2];
$attr{$name}{filemode} = "new"; $attr{$name}{filemode} = "new";
$attr{$name}{CR} = "1"; $attr{$name}{CR} = "1";
$hash->{STATE} = "ready"; $hash->{STATE} = "ready";
$hash->{TYPE} = "MSGFile"; $hash->{TYPE} = "MSGFile";
$hash->{READINGS}{msgcount}{TIME} = TimeNow(); $hash->{READINGS}{msgcount}{TIME} = TimeNow();
$hash->{READINGS}{msgcount}{VAL} = 0; $hash->{READINGS}{msgcount}{VAL} = 0;
return undef; return undef;
} }
############################################## ##############################################
# Undefine Function # Undefine Function
# flush all lines of data # flush all lines of data
############################################## ##############################################
sub sub
MSGFile_Undef($$) MSGFile_Undef($$)
{ {
my ($hash, $name) = @_; my ($hash, $name) = @_;
my $i; my $i;
############ flush the data ############ flush the data
for($i=0;$i<ReadingsVal($name,"msgcount",0);$i++) for($i=0;$i<ReadingsVal($name,"msgcount",0);$i++)
{ {
$data{$name}{$i} = ""; $data{$name}{$i} = "";
} }
delete($modules{MSGFile}{defptr}{$hash->{CODE}}) if($hash && $hash->{CODE}); delete($modules{MSGFile}{defptr}{$hash->{CODE}}) if($hash && $hash->{CODE});
return undef; return undef;
} }
1; 1;

View File

@ -1,158 +1,158 @@
############################################## ##############################################
# $Id: 76_MSGFile.pm 2012-06-20 18:29:00 rbente # $Id: 76_MSGFile.pm 2012-06-20 18:29:00 rbente
############################################## ##############################################
package main; package main;
use strict; use strict;
use warnings; use warnings;
use Switch; use Switch;
my %sets = ( my %sets = (
"add" => "MSGMail", "add" => "MSGMail",
"clear" => "MSGMail", "clear" => "MSGMail",
"list" => "MSGMail" "list" => "MSGMail"
); );
############################################## ##############################################
# Initialize Function # Initialize Function
# Attributes are: # Attributes are:
# authfile the name of the file which contains userid and password # authfile the name of the file which contains userid and password
# smtphost the smtp server hostname # smtphost the smtp server hostname
# smtpport the port of the smtp host # smtpport the port of the smtp host
# subject subject of the email # subject subject of the email
# from from mailaddress (sender) # from from mailaddress (sender)
# to to mailaddress (receipent) # to to mailaddress (receipent)
# cc carbon copy address(es) (delimiter is comma) # cc carbon copy address(es) (delimiter is comma)
# CR 0 = no CR added to the end of the line # CR 0 = no CR added to the end of the line
# 1 = CR added to the end of the line # 1 = CR added to the end of the line
############################################## ##############################################
sub sub
MSGMail_Initialize($) MSGMail_Initialize($)
{ {
my ($hash) = @_; my ($hash) = @_;
$hash->{SetFn} = "MSGMail_Set"; $hash->{SetFn} = "MSGMail_Set";
$hash->{DefFn} = "MSGMail_Define"; $hash->{DefFn} = "MSGMail_Define";
$hash->{UndefFn} = "MSGMail_Undef"; $hash->{UndefFn} = "MSGMail_Undef";
$hash->{AttrList} = "loglevel:0,1,2,3,4,5,6 authfile smtphost smtpport subject from to cc CR:0,1"; $hash->{AttrList} = "loglevel:0,1,2,3,4,5,6 authfile smtphost smtpport subject from to cc CR:0,1";
} }
############################################## ##############################################
# Set Function # Set Function
# all the data are stored in the global array @data # all the data are stored in the global array @data
# as counter we use a READING named msgcount # as counter we use a READING named msgcount
############################################## ##############################################
sub sub
MSGMail_Set($@) MSGMail_Set($@)
{ {
my ($hash, @a) = @_; my ($hash, @a) = @_;
return "Unknown argument $a[1], choose one of -> " . join(" ", sort keys %sets) return "Unknown argument $a[1], choose one of -> " . join(" ", sort keys %sets)
if(!defined($sets{$a[1]})); if(!defined($sets{$a[1]}));
my $name = shift @a; my $name = shift @a;
return "no set value specified" if(int(@a) < 1); return "no set value specified" if(int(@a) < 1);
# return "Unknown argument ?" if($a[0] eq "?"); # return "Unknown argument ?" if($a[0] eq "?");
my $v = join(" ", @a); my $v = join(" ", @a);
##### we like to add another line of data ##### we like to add another line of data
if($a[0] eq "add") if($a[0] eq "add")
{ {
##### split the line in command and data ##### split the line in command and data
my $mx = shift @a; my $mx = shift @a;
my $my = join(" ",@a); my $my = join(" ",@a);
##### check if we like to have and CR at the end of the line ##### check if we like to have and CR at the end of the line
if(AttrVal($name, "CR", "0") eq "1") if(AttrVal($name, "CR", "0") eq "1")
{ {
$my = $my . "\n"; $my = $my . "\n";
} }
##### get the highest number of lines, stored the line in @data and increase ##### get the highest number of lines, stored the line in @data and increase
##### the counter, at the end set the status ##### the counter, at the end set the status
my $count = $hash->{READINGS}{msgcount}{VAL}; my $count = $hash->{READINGS}{msgcount}{VAL};
$data{$name}{$count} = $my; $data{$name}{$count} = $my;
$hash->{READINGS}{msgcount}{TIME} = TimeNow(); $hash->{READINGS}{msgcount}{TIME} = TimeNow();
$hash->{READINGS}{msgcount}{VAL} = $count + 1; $hash->{READINGS}{msgcount}{VAL} = $count + 1;
$hash->{STATE} = "addmsg"; $hash->{STATE} = "addmsg";
} }
##### we like to clear our buffer, first clear all lines of @data ##### we like to clear our buffer, first clear all lines of @data
##### and then set the counter to 0 and the status to clear ##### and then set the counter to 0 and the status to clear
if($a[0] eq "clear") if($a[0] eq "clear")
{ {
my $i; my $i;
for($i=0;$i<ReadingsVal($name,"msgcount",0);$i++) for($i=0;$i<ReadingsVal($name,"msgcount",0);$i++)
{ {
$data{$name}{$i} = ""; $data{$name}{$i} = "";
} }
$hash->{READINGS}{msgcount}{TIME} = TimeNow(); $hash->{READINGS}{msgcount}{TIME} = TimeNow();
$hash->{READINGS}{msgcount}{VAL} = 0; $hash->{READINGS}{msgcount}{VAL} = 0;
$hash->{STATE} = "clear"; $hash->{STATE} = "clear";
} }
##### we like to see the buffer ##### we like to see the buffer
if($a[0] eq "list")
{
my $i;
my $mess = "---- Lines of data for $name ----\n";
for($i=0;$i<ReadingsVal($name,"msgcount",0);$i++)
{
$mess .= $data{$name}{$i};
}
return "$mess---- End of data for $name ----";
}
Log GetLogLevel($name,2), "messenger set $name $v";
# set stats if($a[0] eq "list")
# $hash->{CHANGED}[0] = $v; {
$hash->{READINGS}{state}{TIME} = TimeNow(); my $i;
$hash->{READINGS}{state}{VAL} = $v; my $mess = "---- Lines of data for $name ----\n";
return undef; for($i=0;$i<ReadingsVal($name,"msgcount",0);$i++)
} {
$mess .= $data{$name}{$i};
}
return "$mess---- End of data for $name ----";
}
Log GetLogLevel($name,2), "messenger set $name $v";
############################################## # set stats
# Define Function # $hash->{CHANGED}[0] = $v;
# set the counter to 0 $hash->{READINGS}{state}{TIME} = TimeNow();
############################################## $hash->{READINGS}{state}{VAL} = $v;
sub return undef;
MSGMail_Define($$) }
{
my ($hash, $def) = @_;
my @a = split("[ \t][ \t]*", $def);
my $errmsg = "wrong syntax: define <name> MSGMail from to smtphost authfile";
my $name = $hash->{NAME};
return $errmsg if(@a != 6); ##############################################
##### set all the Attributes # Define Function
$attr{$name}{from} = $a[2]; # set the counter to 0
$attr{$name}{to} = $a[3]; ##############################################
$attr{$name}{smtphost} = $a[4]; sub
$attr{$name}{authfile} = $a[5]; MSGMail_Define($$)
$attr{$name}{subject} = "FHEM "; {
$attr{$name}{CR} = "1"; my ($hash, $def) = @_;
my @a = split("[ \t][ \t]*", $def);
my $errmsg = "wrong syntax: define <name> MSGMail from to smtphost authfile";
my $name = $hash->{NAME};
$hash->{STATE} = "ready"; return $errmsg if(@a != 6);
$hash->{TYPE} = "MSGMail"; ##### set all the Attributes
$hash->{READINGS}{msgcount}{TIME} = TimeNow(); $attr{$name}{from} = $a[2];
$hash->{READINGS}{msgcount}{VAL} = 0; $attr{$name}{to} = $a[3];
return undef; $attr{$name}{smtphost} = $a[4];
} $attr{$name}{authfile} = $a[5];
############################################## $attr{$name}{subject} = "FHEM ";
# Undefine Function $attr{$name}{CR} = "1";
# flush all lines of data
##############################################
sub
MSGMail_Undef($$)
{
my ($hash, $name) = @_;
my $i;
############ flush the data
for($i=0;$i<ReadingsVal($name,"msgcount",0);$i++)
{
$data{$name}{$i} = "";
}
delete($modules{MSGMail}{defptr}{$hash->{CODE}}) if($hash && $hash->{CODE});
return undef;
}
1; $hash->{STATE} = "ready";
$hash->{TYPE} = "MSGMail";
$hash->{READINGS}{msgcount}{TIME} = TimeNow();
$hash->{READINGS}{msgcount}{VAL} = 0;
return undef;
}
##############################################
# Undefine Function
# flush all lines of data
##############################################
sub
MSGMail_Undef($$)
{
my ($hash, $name) = @_;
my $i;
############ flush the data
for($i=0;$i<ReadingsVal($name,"msgcount",0);$i++)
{
$data{$name}{$i} = "";
}
delete($modules{MSGMail}{defptr}{$hash->{CODE}}) if($hash && $hash->{CODE});
return undef;
}
1;

View File

@ -0,0 +1,74 @@
#!/usr/bin/perl
use strict;
use warnings;
my $docIn = "docs/commandref_frame.html";
my $docOut = "docs/commandref.html";
my @modDir = ("FHEM");
open(IN, "$docIn") || die "Cant open $docIn: $!\n";
open(OUT, ">$docOut") || die "Cant open $docOut: $!\n";
my %mods;
foreach my $modDir (@modDir) {
opendir(DH, $modDir) || die "Cant open $modDir: $!\n";
while(my $l = readdir DH) {
next if($l !~ m/^\d\d_.*\.pm$/);
my $of = $l;
$l =~ s/.pm$//;
$l =~ s/^[0-9][0-9]_//;
$mods{$l} = "$modDir/$of";
}
}
# First run: check what is a command and what is a helper module
my $status;
my %noindex;
while(my $l = <IN>) {
last if($l =~ m/<h3>Introduction/);
$noindex{$1} = 1 if($l =~ m/href="#(.*)"/);
}
seek(IN,0,0);
# Second run: create the file
# Header
while(my $l = <IN>) {
print OUT $l;
last if($l =~ m/#global/);
}
# index for devices.
foreach my $mod (sort keys %mods) {
next if($noindex{$mod});
print OUT " <a href='#$mod'>$mod</a> &nbsp;\n";
}
# Copy the middle part
while(my $l = <IN>) {
last if($l =~ m/name="perl"/);
print OUT $l;
}
# Copy the doc part from the module
foreach my $mod (sort keys %mods) {
open(MOD, $mods{$mod}) || die("Cant open $mods{$mod}:$!\n");
my $skip = 1;
while(my $l = <MOD>) {
if($l =~ m/^=begin html/) {
$skip = 0;
} elsif($l =~ m/^=end html/) {
$skip = 1;
} elsif(!$skip) {
print OUT $l;
}
}
close(MOD);
}
# Copy the tail
print OUT '<a name="perl"></a>',"\n";
while(my $l = <IN>) {
print OUT $l;
}
close(OUT);

View File

@ -0,0 +1,63 @@
#!/usr/bin/perl
use strict;
use warnings;
my $docIn = "docs/commandref.html";
my $docOut = "docs/commandref_frame.html";
my @modDir = ("FHEM", "contrib", "webfrontend/pgm5");
open(IN, "$docIn") || die "Cant open $docIn: $!\n";
open(OUT, ">$docOut") || die "Cant open $docOut: $!\n";
my %mods;
foreach my $modDir (@modDir) {
opendir(DH, $modDir) || die "Cant open $modDir: $!\n";
while(my $l = readdir DH) {
next if($l !~ m/^\d\d_.*\.pm$/);
my $of = $l;
$l =~ s/.pm$//;
$l =~ s/^[0-9][0-9]_//;
$mods{lc($l)} = "$modDir/$of" if(!$mods{lc($l)});
}
}
my %fnd;
my $modFileName;
while(my $l = <IN>) {
$l =~ s/[\r\n]//g;
if($l =~ m,^<a name="(.*)"></a>$,) {
if($modFileName) {
print MODOUT "=end html\n=cut\n";
close(MODOUT);
rename "$modFileName.NEW", $modFileName;
}
my $mod = lc($1);
if($mods{$mod}) {
print "Double-Fnd: $mod\n" if($fnd{$mod});
$fnd{$mod} = 1;
$modFileName = $mods{$mod};
open(MODIN, "$modFileName") || die("Cant open $modFileName: $!\n");
open(MODOUT, ">$modFileName.NEW") || die("Cant open $modFileName.NEW: $!\n");
my $seen1;
while(my $l = <MODIN>) {
$seen1 = 1 if($l =~ m/^1;[\r\n]*/);
last if($l =~ m/=pod/ && $seen1);
print MODOUT $l;
}
print MODOUT "\n\=pod\n=begin html\n\n";
} else {
print "Not a module: $mod\n";
$modFileName = "";
}
}
if($modFileName){
print MODOUT "$l\n";
} else {
print OUT "$l\n";
}
}
foreach my $mod (sort {$mods{$a} cmp $mods{$b}} keys %mods) {
print "Missing doc for $mods{$mod}\n" if(!$fnd{$mod});
}

File diff suppressed because it is too large Load Diff

View File

@ -75,7 +75,7 @@
Nightly SVN version: a Nightly SVN version: a
<a href="http://www.dhs-computertechnik.de/downloads/fhem-cvs.tgz"> <a href="http://www.dhs-computertechnik.de/downloads/fhem-cvs.tgz">
tarball</a>, or from the fhem commandline via <a tarball</a>, or from the fhem commandline via <a
href="commandref.html#updatefhem">updatefhem</a>. <br><br> href="commandref.html#update">update</a>. <br><br>
Please fill out our <a href="survey.pl">survey</a>, Please fill out our <a href="survey.pl">survey</a>,