73_km200: bugfix - Forward declaration made obsolete
git-svn-id: https://svn.fhem.de/fhem/trunk@26723 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -51,9 +51,6 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use constant false => 0;
|
use constant false => 0;
|
||||||
use constant true => 1;
|
use constant true => 1;
|
||||||
sub km200_Define($$);
|
|
||||||
sub km200_Undefine($$);
|
|
||||||
sub km200_GetErrorMessage($$$$);
|
|
||||||
|
|
||||||
###START###### Initialize module ##############################################################################START####
|
###START###### Initialize module ##############################################################################START####
|
||||||
sub km200_Initialize($) {
|
sub km200_Initialize($) {
|
||||||
@@ -280,10 +277,6 @@ sub km200_Define($$) {
|
|||||||
@{$hash->{Secret}{KM200DONOTPOLL}} = ();
|
@{$hash->{Secret}{KM200DONOTPOLL}} = ();
|
||||||
####END####### Writing values to global hash ################################################################END#####
|
####END####### Writing values to global hash ################################################################END#####
|
||||||
|
|
||||||
###START###### Reset fullResponse error message ############################################################START####
|
|
||||||
readingsSingleUpdate( $hash, "fullResponse", "OK", 1);
|
|
||||||
####END####### Reset fullResponse error message #############################################################END#####
|
|
||||||
|
|
||||||
###START###### For Debugging purpose only ##################################################################START####
|
###START###### For Debugging purpose only ##################################################################START####
|
||||||
Log3 $name, 4, $name. " : km200 - Define H : " .$hash;
|
Log3 $name, 4, $name. " : km200 - Define H : " .$hash;
|
||||||
Log3 $name, 4, $name. " : km200 - Define D : " .$def;
|
Log3 $name, 4, $name. " : km200 - Define D : " .$def;
|
||||||
@@ -292,6 +285,23 @@ sub km200_Define($$) {
|
|||||||
Log3 $name, 4, $name. " : km200 - Define Adr : " .$url;
|
Log3 $name, 4, $name. " : km200 - Define Adr : " .$url;
|
||||||
####END####### For Debugging purpose only ###################################################################END#####
|
####END####### For Debugging purpose only ###################################################################END#####
|
||||||
|
|
||||||
|
### Proceed with km200 Initialization as soon fhem is initialized
|
||||||
|
# https://forum.fhem.de/index.php/topic,130351.msg1246281.html#msg1246281
|
||||||
|
# Die InternalTimer Eintraege werden erst abgearbeitet, wenn $init_done = 1 ist.
|
||||||
|
InternalTimer(0, \&km200_FirstInit, $hash );
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
####END####### Activate module after module has been used via fhem command "define" ############################END#####
|
||||||
|
|
||||||
|
###START###### Initialize km200 after fhem Initialization is done #############################################START####
|
||||||
|
sub km200_FirstInit($) {
|
||||||
|
my $hash = @_;
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
|
###START###### Reset fullResponse error message ############################################################START####
|
||||||
|
readingsSingleUpdate( $hash, "fullResponse", "OK", 1);
|
||||||
|
####END####### Reset fullResponse error message #############################################################END#####
|
||||||
|
|
||||||
###START###### Check whether communication to the physical unit is possible ################################START####
|
###START###### Check whether communication to the physical unit is possible ################################START####
|
||||||
my $Km200Info ="";
|
my $Km200Info ="";
|
||||||
@@ -324,7 +334,7 @@ sub km200_Define($$) {
|
|||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
####END####### Activate module after module has been used via fhem command "define" ############################END#####
|
####END####### Initialize km200 after fhem Initialization is done ##############################################END#####
|
||||||
|
|
||||||
|
|
||||||
###START###### To bind unit of value to DbLog entries #########################################################START####
|
###START###### To bind unit of value to DbLog entries #########################################################START####
|
||||||
@@ -444,62 +454,62 @@ sub km200_Attr(@) {
|
|||||||
}
|
}
|
||||||
####END#### Check whether timeout is not too short
|
####END#### Check whether timeout is not too short
|
||||||
}
|
}
|
||||||
### Check whether DoNotPoll attribute have been provided
|
elsif($a[2] eq 'DoNotPoll') {
|
||||||
elsif($a[2] eq "DoNotPoll") {
|
#my @KM200_DONOTPOLL = ();
|
||||||
my @KM200_DONOTPOLL = ();
|
my @temp = @a;
|
||||||
my @temp = @a;
|
|
||||||
|
|
||||||
### Stop the current timer
|
### Stop the current timer
|
||||||
RemoveInternalTimer($hash);
|
RemoveInternalTimer($hash);
|
||||||
Log3 $name, 4, $name. " : km200 - InternalTimer has been removed.";
|
Log3 $name, 4, $name. " : km200 - InternalTimer has been removed.";
|
||||||
|
|
||||||
### Delete the first 3 items of the array
|
### Delete the first 3 items of the array
|
||||||
splice @temp, 0, 3;
|
splice @temp, 0, 3;
|
||||||
|
|
||||||
### Insert empty field as minimum entry
|
### Insert empty field as minimum entry
|
||||||
push @temp, "";
|
push @temp, "";
|
||||||
|
|
||||||
### Transform string entries seperated by blank into array
|
### Transform string entries seperated by blank into array
|
||||||
@KM200_DONOTPOLL = split(/\s+/, $temp[0]);
|
my @KM200_DONOTPOLL = split m/\s+/, $temp[0] // ();
|
||||||
|
|
||||||
### Remove trailing slash of each item if available
|
### Remove trailing slash of each item if available
|
||||||
|
|
||||||
### For each item found in this empty parent directory
|
### For each item found in this empty parent directory
|
||||||
foreach my $item (@KM200_DONOTPOLL) {
|
for my $item (@KM200_DONOTPOLL) {
|
||||||
### Delete trailing slash
|
### Delete trailing slash
|
||||||
$item =~ s/\/$//;
|
$item =~ s/\/$//;
|
||||||
}
|
}
|
||||||
|
|
||||||
### Save list of services not to be polled into hash
|
### Save list of services not to be polled into hash
|
||||||
@{$hash->{Secret}{KM200DONOTPOLL}} = @KM200_DONOTPOLL;
|
@{$hash->{Secret}{KM200DONOTPOLL}} = @KM200_DONOTPOLL;
|
||||||
|
|
||||||
### Get original list of root services back
|
### Get original list of root services back
|
||||||
@{$hash->{Secret}{KM200ALLSERVICES}} = @{$hash->{Secret}{KM200ALLSERVICESBACKUP}};
|
@{$hash->{Secret}{KM200ALLSERVICES}} = @{$hash->{Secret}{KM200ALLSERVICESBACKUP}};
|
||||||
|
|
||||||
### For every blacklisted service
|
### For every blacklisted service
|
||||||
foreach my $SearchWord(@KM200_DONOTPOLL) {
|
for my $SearchWord(@KM200_DONOTPOLL) {
|
||||||
### Filter all blocked root services out of services to be polled
|
last if @{$hash->{Secret}{KM200ALLSERVICES}}|| ref @{$hash->{Secret}{KM200ALLSERVICES}} ne 'ARRAY';
|
||||||
my $FoundPosition = first_index{ $_ eq $SearchWord }@{$hash->{Secret}{KM200ALLSERVICES}};
|
### Filter all blocked root services out of services to be polled
|
||||||
if ($FoundPosition >= 0) {
|
my $FoundPosition = first_index{ $_ eq $SearchWord }@{$hash->{Secret}{KM200ALLSERVICES}};
|
||||||
splice(@{$hash->{Secret}{KM200ALLSERVICES}}, $FoundPosition, 1);
|
if ($FoundPosition >= 0) {
|
||||||
}
|
splice(@{$hash->{Secret}{KM200ALLSERVICES}}, $FoundPosition, 1);
|
||||||
}
|
}
|
||||||
### Message for debugging purposes
|
}
|
||||||
Log3 $name, 5, $name. "km200 module is only polling the following services! \n @{$hash->{Secret}{KM200ALLSERVICES}}";
|
### Message for debugging purposes
|
||||||
Log3 $name, 5, $name. "km200 module is NOT polling the following services! \n @{$hash->{Secret}{KM200DONOTPOLL}}";
|
Log3 $name, 5, $name. "km200 module is only polling the following services! \n @{$hash->{Secret}{KM200ALLSERVICES}}";
|
||||||
Log3 $name, 4, $name. " : km200 - The following services will not be polled: ". $a[3];
|
Log3 $name, 5, $name. "km200 module is NOT polling the following services! \n @{$hash->{Secret}{KM200DONOTPOLL}}";
|
||||||
|
Log3 $name, 4, $name. " : km200 - The following services will not be polled: ". $a[3];
|
||||||
|
|
||||||
### Interrupting all currently running Polling
|
### Interrupting all currently running Polling
|
||||||
@{$hash->{Secret}{KM200DYNSERVICES}} = "";
|
@{$hash->{Secret}{KM200DYNSERVICES}} = "";
|
||||||
$hash->{temp}{ServiceCounterDyn} = 0;
|
$hash->{temp}{ServiceCounterDyn} = 0;
|
||||||
|
|
||||||
### Delete all Readings
|
### Delete all Readings
|
||||||
fhem( "deletereading $name .*" );
|
fhem( "deletereading $name .*" );
|
||||||
|
|
||||||
### Re-start the sounding of values from KM200 but wait the period of $hash->{POLLINGTIMEOUT} + 10s
|
### Re-start the sounding of values from KM200 but wait the period of $hash->{POLLINGTIMEOUT} + 10s
|
||||||
InternalTimer(gettimeofday()+$hash->{POLLINGTIMEOUT}+10, "km200_GetInitService", $hash, 1);
|
InternalTimer(gettimeofday()+$hash->{POLLINGTIMEOUT}+10, "km200_GetInitService", $hash, 1);
|
||||||
Log3 $name, 4, $name. " : km200 - Sounding of services re-started after change of DoNotPoll attribute";
|
Log3 $name, 4, $name. " : km200 - Sounding of services re-started after change of DoNotPoll attribute";
|
||||||
}
|
}
|
||||||
### Check whether time-out for Read-Back has been provided
|
### Check whether time-out for Read-Back has been provided
|
||||||
if($a[2] eq "ReadBackDelay") {
|
if($a[2] eq "ReadBackDelay") {
|
||||||
$ReadBackDelay = $a[3];
|
$ReadBackDelay = $a[3];
|
||||||
@@ -2570,6 +2580,7 @@ sub km200_GetDynService($) {
|
|||||||
++$ServiceCounterDyn;
|
++$ServiceCounterDyn;
|
||||||
$hash->{temp}{ServiceCounterDyn} = $ServiceCounterDyn;
|
$hash->{temp}{ServiceCounterDyn} = $ServiceCounterDyn;
|
||||||
km200_GetDynService($hash);
|
km200_GetDynService($hash);
|
||||||
|
# $init_done ? km200_GetDynService($hash) : InternalTimer(gettimeofday()+30, \&km200_GetDynService, $hash, 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
### Log entries for debugging purposes
|
### Log entries for debugging purposes
|
||||||
|
|||||||
Reference in New Issue
Block a user