2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-12 22:56:34 +00:00

Making regexp in Client-List of iodevs work in Dispatch

git-svn-id: https://svn.fhem.de/fhem/trunk@3236 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2013-06-01 17:13:50 +00:00
parent 69ab88695c
commit 1c524fbb57

View File

@ -1388,6 +1388,7 @@ AssignIoPort($)
my @fnd = grep { $hash->{TYPE} =~ m/^$_$/; } split(":", $cl);
if(@fnd) {
$hash->{IODev} = $defs{$p};
delete($defs{$p}{".clientArray"}); # Force a recompute
last;
}
}
@ -2582,21 +2583,19 @@ Dispatch($$$)
my @found;
my $cl = $hash->{Clients};
$cl = $iohash->{Clients} if(!$cl);
foreach my $m (sort { $modules{$a}{ORDER} cmp $modules{$b}{ORDER} }
grep {defined($modules{$_}{ORDER})} keys %modules) {
next if(!(defined($cl) && $cl =~ m/:$m:/));
my $clientArray = $hash->{".clientArray"};
$clientArray = computeClientArray($hash, $iohash) if(!$clientArray);
foreach my $m (@{$clientArray}) {
# Module is not loaded or the message is not for this module
next if(!$modules{$m}{Match} || $dmsg !~ m/$modules{$m}{Match}/i);
next if($dmsg !~ m/$modules{$m}{Match}/i);
no strict "refs"; $readingsUpdateDelayTrigger = 1;
@found = &{$modules{$m}{ParseFn}}($hash,$dmsg);
use strict "refs"; $readingsUpdateDelayTrigger = 0;
last if(int(@found));
}
if(!int(@found)) {
my $h = $hash->{MatchList}; $h = $iohash->{MatchList} if(!$h);
if(defined($h)) {
@ -3339,4 +3338,25 @@ fhemTimeLocal($$$$$$) {
return $t-fhemTzOffset($t);
}
sub
computeClientArray($$)
{
my ($hash, $iohash) = @_;
my @a = ();
my @mRe = split(":", $hash->{Clients} ? $hash->{Clients}:$iohash->{Clients});
foreach my $m (sort { $modules{$a}{ORDER} cmp $modules{$b}{ORDER} }
grep { defined($modules{$_}{ORDER}) } keys %modules) {
foreach my $re (@mRe) {
if($m =~ m/^$re$/) {
push @a, $m if($modules{$m}{Match});
last;
}
}
}
$hash->{".clientArray"} = \@a;
return \@a;
}
1;