mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
Duplicate pool added
git-svn-id: https://svn.fhem.de/fhem/trunk@462 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
25f3b60e62
commit
51d1510629
@ -536,4 +536,5 @@
|
||||
- bugfix: loosing data when sending FS20 messages in a group
|
||||
- bugfix: better handling of disconnected CUN
|
||||
- feature: softfhtbuffer added to CUL
|
||||
- bugfix: pgm3: Pulldown-Menu without selected FHTDEV not possible any more
|
||||
- bugfix: pgm3: Pulldown-Menu without selected FHTDEV not possible any more
|
||||
- feature: duplicate buffer added for multi-cul/-fhz setups
|
||||
|
@ -73,7 +73,7 @@ CUL_Initialize($)
|
||||
$hash->{GetFn} = "CUL_Get";
|
||||
$hash->{SetFn} = "CUL_Set";
|
||||
$hash->{StateFn} = "CUL_SetState";
|
||||
$hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 filtertimeout " .
|
||||
$hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 " .
|
||||
"showtime:1,0 model:CUL,CUR loglevel:0,1,2,3,4,5,6 " .
|
||||
"CUR_id_list fhtsoftbuffer:1,0";
|
||||
$hash->{ShutdownFn} = "CUL_Shutdown";
|
||||
@ -573,6 +573,8 @@ CUL_Write($$$)
|
||||
|
||||
} elsif($fn eq "04" && substr($msg,0,6) eq "010101") { # FS20
|
||||
$fn = "F";
|
||||
AddDuplicate($hash->{NAME},
|
||||
"0101a001" . substr($msg, 6, 6) . "00" . substr($msg, 12));
|
||||
$msg = substr($msg,6);
|
||||
|
||||
} elsif($fn eq "04" && substr($msg,0,6) eq "020183") { # FHT
|
||||
@ -759,8 +761,9 @@ CUL_Read($)
|
||||
if($foundp) {
|
||||
foreach my $d (@{$foundp}) {
|
||||
next if(!$defs{$d});
|
||||
$defs{$d}{RSSI} = $rssi if($rssi);
|
||||
$defs{$d}{"RSSI_$name"} = $rssi if($rssi);
|
||||
$defs{$d}{RAWMSG} = $rmsg;
|
||||
$defs{$d}{"MSGCNT_$name"}++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ FHZ_Initialize($)
|
||||
$hash->{GetFn} = "FHZ_Get";
|
||||
$hash->{SetFn} = "FHZ_Set";
|
||||
$hash->{StateFn} = "FHZ_SetState";
|
||||
$hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 filtertimeout repeater:1,0 " .
|
||||
$hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 " .
|
||||
"showtime:1,0 model:fhz1000,fhz1300 loglevel:0,1,2,3,4,5,6 ".
|
||||
"fhtsoftbuffer:1,0";
|
||||
}
|
||||
@ -542,6 +542,16 @@ FHZ_Write($$$)
|
||||
return;
|
||||
}
|
||||
|
||||
###############
|
||||
# insert value into the msghist. At the moment this only makes sense for FS20
|
||||
# devices. As the transmitted value differs from the received one, we have to
|
||||
# recompute.
|
||||
if($fn eq "04" && substr($msg,0,6) eq "010101") {
|
||||
AddDuplicate($hash->{NAME},
|
||||
"0101a001" . substr($msg, 6, 6) . "00" . substr($msg, 12));
|
||||
}
|
||||
|
||||
|
||||
my $bstring = FHZ_CompleteMsg($fn, $msg);
|
||||
Log 5, "Sending " . unpack('H*', $bstring);
|
||||
|
||||
@ -689,6 +699,7 @@ FHZ_Read($)
|
||||
foreach my $d (@{$foundp}) {
|
||||
next if(!$defs{$d});
|
||||
$defs{$d}{RAWMSG} = $dmsg;
|
||||
$defs{$d}{"MSGCNT_$name"}++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,8 +89,6 @@ BS_Parse($$)
|
||||
|
||||
my $name= $def->{NAME};
|
||||
|
||||
return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME});
|
||||
|
||||
my $t= TimeNow();
|
||||
|
||||
my $flags= hex(substr($msg, 24, 1)) & 0xdc;
|
||||
|
@ -98,9 +98,6 @@ USF1000_Parse($$)
|
||||
my $def= $defptr{$dev};
|
||||
my $name= $def->{NAME};
|
||||
|
||||
return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME});
|
||||
|
||||
|
||||
my $t= TimeNow();
|
||||
|
||||
# Msg format:
|
||||
|
@ -354,7 +354,6 @@ FS20_Parse($$)
|
||||
my @list;
|
||||
foreach my $n (keys %{ $def }) {
|
||||
my $lh = $def->{$n};
|
||||
return "" if($lh->{IODev} && $lh->{IODev}{NAME} ne $hash->{NAME});
|
||||
$lh->{CHANGED}[0] = $v;
|
||||
$lh->{STATE} = $v;
|
||||
$lh->{READINGS}{state}{TIME} = TimeNow();
|
||||
|
@ -167,8 +167,6 @@ FHT_Set($@)
|
||||
if($a[$i] eq "time") {
|
||||
my @t = localtime;
|
||||
splice(@a,$i,1,("hour",$t[2],"minute",$t[1]));
|
||||
IOWrite($hash, "", sprintf("T04%x", $t[0])) # CUL hack
|
||||
if($hash->{IODev} && $hash->{IODev}->{TYPE} eq "CUL");
|
||||
}
|
||||
}
|
||||
|
||||
@ -348,8 +346,6 @@ FHT_Parse($$)
|
||||
my $def = $defptr{$dev};
|
||||
my $name = $def->{NAME};
|
||||
|
||||
return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME});
|
||||
|
||||
# Short message
|
||||
if(length($msg) < 26) {
|
||||
Log 4,"FHT Short message. Device $name, Message: $msg";
|
||||
|
@ -106,7 +106,6 @@ HMS_Parse($$)
|
||||
}
|
||||
|
||||
my $def = $defptr{$dev};
|
||||
return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME});
|
||||
|
||||
my (@v, @txt);
|
||||
|
||||
|
@ -89,8 +89,6 @@ KS300_Parse($$)
|
||||
my $haverain = 0;
|
||||
my $name= $def->{NAME};
|
||||
|
||||
return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME});
|
||||
|
||||
my @v;
|
||||
my @txt = ( "rain_raw", "rain", "wind", "humidity", "temperature",
|
||||
"israining", "unknown1", "unknown2", "unknown3");
|
||||
|
@ -95,10 +95,6 @@ CUL_WS_Parse($$)
|
||||
return "UNDEFINED CUL_WS: $cde";
|
||||
}
|
||||
|
||||
# It's not our device
|
||||
return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME});
|
||||
|
||||
|
||||
my $tm=TimeNow();
|
||||
$hash = $def;
|
||||
|
||||
|
@ -107,7 +107,6 @@ CUL_EM_Parse($$)
|
||||
|
||||
if($defptr{$cde}) {
|
||||
my $def = $defptr{$cde};
|
||||
return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME});
|
||||
|
||||
$hash = $defptr{$cde};
|
||||
|
||||
|
@ -348,7 +348,6 @@ X10_Parse($$)
|
||||
foreach my $unitcode (@unitcodes) {
|
||||
my $h= $devices{$housecode}{$unitcode};
|
||||
if($h) {
|
||||
return "" if($h->{IODev} && $h->{IODev}{NAME} ne $hash->{NAME});
|
||||
my $name= $h->{NAME};
|
||||
$h->{CHANGED}[0] = $value;
|
||||
$h->{STATE} = $value;
|
||||
|
14
fhem/HISTORY
14
fhem/HISTORY
@ -431,8 +431,16 @@
|
||||
- bugfix: missing blank in attribute list for FHT; exclude report from lazy
|
||||
- typos and anchors in documentation corrected
|
||||
|
||||
- Sun Oct11 2009 (Boris)
|
||||
- Sun Oct 11 2009 (Boris)
|
||||
- finalized 09_BS.pm and documentation
|
||||
|
||||
- Tue Nov10 2009 (Martin Haas)
|
||||
- Bugfix: pgm3: Pulldown-Menu without selected FHTDEV not possible any more
|
||||
- Tue Nov 10 2009 (Martin Haas)
|
||||
- Bugfix: pgm3: Pulldown-Menu without selected FHTDEV not possible any more
|
||||
|
||||
- Thu Nov 12 2009 (Rudi)
|
||||
- The duplicate pool added. The check routine is called from the Dispatch
|
||||
routine (so it will affecc CUL/FHZ and CM11), and for FS20 calls from
|
||||
the CUL and FHZ Write function.
|
||||
Duplicates within 0.5 seconds are filtered if they are not reported by the
|
||||
same IO Unit. Existing check for IODev removed from BS USF1000 FS20 FHT HMS
|
||||
KS300 CUL_WS CUL_EM X10.
|
||||
|
@ -1,11 +1,6 @@
|
||||
FHEM:
|
||||
- RAWTIME
|
||||
|
||||
- Remote serial device via IP (for the FHZ1300 WLAN)
|
||||
- Common buffer for parallel use of two devices: CUL+FHZ, (WS300/EM1000PC?)
|
||||
- fhem-to-fhem module
|
||||
- CUR built-in MENU creation support
|
||||
- Remove or reimplement repeater attribute (cul/fhz/doc)
|
||||
|
||||
Webpgm2
|
||||
- plot data from multiple files in a single picture
|
||||
|
50
fhem/fhem.pl
50
fhem/fhem.pl
@ -39,12 +39,14 @@ use Time::HiRes qw(gettimeofday);
|
||||
##################################################
|
||||
# Forward declarations
|
||||
#
|
||||
sub AddDuplicate($$);
|
||||
sub AnalyzeCommand($$);
|
||||
sub AnalyzeCommandChain($$);
|
||||
sub AnalyzeInput($);
|
||||
sub AssignIoPort($);
|
||||
sub CallFn(@);
|
||||
sub CommandChain($$);
|
||||
sub CheckDuplicate($$);
|
||||
sub DoClose($);
|
||||
sub Dispatch($$);
|
||||
sub FmtDateTime($);
|
||||
@ -151,7 +153,9 @@ my %defaultattr; # Default attributes
|
||||
my %intAt; # Internal at timer hash.
|
||||
my $nextat; # Time when next timer will be triggered.
|
||||
my $intAtCnt=0;
|
||||
my $cvsid = '$Id: fhem.pl,v 1.81 2009-11-08 14:18:06 rudolfkoenig Exp $';
|
||||
my %duplicate; # Pool of received msg for multi-fhz/cul setups
|
||||
my $duplidx=0; # helper for the above pool
|
||||
my $cvsid = '$Id: fhem.pl,v 1.82 2009-11-12 19:08:00 rudolfkoenig Exp $';
|
||||
my $namedef =
|
||||
"where <name> is either:\n" .
|
||||
"- a single device name\n" .
|
||||
@ -175,7 +179,7 @@ $modules{_internal_}{AttrFn} = "GlobalAttr";
|
||||
"?" => { Fn=>"CommandHelp",
|
||||
Hlp=>",get this help" },
|
||||
"attr" => { Fn=>"CommandAttr",
|
||||
Hlp=>"<devspec> <attrname> [<attrval>],set attribute for <devspec>" },
|
||||
Hlp=>"<devspec> <attrname> [<attrval>],set attribute for <devspec>"},
|
||||
"define" => { Fn=>"CommandDefine",
|
||||
Hlp=>"<name> <type> <options>,define a device/at/notify entity" },
|
||||
"deleteattr" => { Fn=>"CommandDeleteAttr",
|
||||
@ -2041,6 +2045,9 @@ Dispatch($$)
|
||||
|
||||
Log 5, "$name dispatch $dmsg";
|
||||
|
||||
my ($isdup, $idx) = CheckDuplicate($name, $dmsg);
|
||||
return $duplicate{$idx}{FND} if($isdup);
|
||||
|
||||
my @found;
|
||||
my $last_module;
|
||||
foreach my $m (sort { $modules{$a}{ORDER} cmp $modules{$b}{ORDER} }
|
||||
@ -2056,6 +2063,7 @@ Dispatch($$)
|
||||
$last_module = $m;
|
||||
last if(int(@found));
|
||||
}
|
||||
|
||||
if(!int(@found)) {
|
||||
my $h = $iohash->{MatchList};
|
||||
if(defined($h)) {
|
||||
@ -2088,6 +2096,44 @@ Dispatch($$)
|
||||
DoTrigger($found, undef);
|
||||
}
|
||||
}
|
||||
$duplicate{$idx}{FND} = \@found;
|
||||
|
||||
return \@found;
|
||||
}
|
||||
|
||||
sub
|
||||
CheckDuplicate($$)
|
||||
{
|
||||
my ($ioname, $msg) = @_;
|
||||
|
||||
# Store only the "relevant" part, as the CUL won't compute the checksum
|
||||
$msg = substr($msg, 8) if($msg =~ m/^81/ && length($msg) > 8);
|
||||
|
||||
my $now = gettimeofday();
|
||||
my $lim = $now-0.5;
|
||||
|
||||
foreach my $oidx (keys %duplicate) {
|
||||
if($duplicate{$oidx}{TIM} < $lim) {
|
||||
delete($duplicate{$oidx});
|
||||
|
||||
} elsif($duplicate{$oidx}{MSG} eq $msg &&
|
||||
$duplicate{$oidx}{ION} ne $ioname) {
|
||||
return (1, $oidx);
|
||||
|
||||
}
|
||||
}
|
||||
$duplicate{$duplidx}{ION} = $ioname;
|
||||
$duplicate{$duplidx}{MSG} = $msg;
|
||||
$duplicate{$duplidx}{TIM} = $now;
|
||||
$duplidx++;
|
||||
return (0, $duplidx-1);
|
||||
}
|
||||
|
||||
sub
|
||||
AddDuplicate($$)
|
||||
{
|
||||
$duplicate{$duplidx}{ION} = shift;
|
||||
$duplicate{$duplidx}{MSG} = shift;
|
||||
$duplicate{$duplidx}{TIM} = gettimeofday();
|
||||
$duplidx++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user