2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-07 23:09:26 +00:00

improve archive batch handling

git-svn-id: https://svn.fhem.de/fhem/trunk@4821 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
martinp876 2014-02-06 14:44:16 +00:00
parent fa3fb8489b
commit 6a714fce0a
2 changed files with 58 additions and 37 deletions

View File

@ -589,7 +589,8 @@ sub CUL_HM_Attr(@) {#################################
}
elsif($attrName eq "autoReadReg"){
if ($cmd eq "set"){
CUL_HM_complConfigTest($name);
CUL_HM_complConfigTest($name)
if (!CUL_HM_getAttrInt($name,"ignore"));;
}
}
CUL_HM_queueUpdtCfg($name) if ($updtReq);
@ -2563,7 +2564,7 @@ sub CUL_HM_Set($@) {
my @cH = ($hash);
push @cH,$defs{$hash->{$_}} foreach(grep /^channel/,keys %{$hash});
delete $_->{READINGS} foreach (@cH);
delete $modules{CUL_HM}{helper}{cfgCmpl}{$_->{NAME}};
delete $modules{CUL_HM}{helper}{cfgCmpl}{$name};
CUL_HM_complConfig($_->{NAME}) foreach (@cH);
}
elsif($sect eq "register"){
@ -2573,7 +2574,7 @@ sub CUL_HM_Set($@) {
foreach my $h(@cH){
delete $h->{READINGS}{$_}
foreach (grep /^(\.?)(R-|RegL)/,keys %{$h->{READINGS}});
delete $modules{CUL_HM}{helper}{cfgCmpl}{$_->{NAME}};
delete $modules{CUL_HM}{helper}{cfgCmpl}{$name};
CUL_HM_complConfig($h->{NAME});
}
}
@ -3722,7 +3723,7 @@ sub CUL_HM_getConfig($){
my $id = CUL_HM_IOid($hash);
my $dst = substr($hash->{DEF},0,6);
my $name = $hash->{NAME};
CUL_HM_configUpdate($name);
delete $modules{CUL_HM}{helper}{cfgCmpl}{$name};
CUL_HM_complConfigTest($name);
CUL_HM_PushCmdStack($hash,'++'.$flag.'01'.$id.$dst.'00040000000000')
@ -5746,8 +5747,7 @@ sub CUL_HM_peersValid($) {# is list valid?
sub CUL_HM_reglUsed($) {# provide data for HMinfo
my $name = shift;
my $hash = $defs{$name};
my $devId = substr($hash->{DEF},0,6);
my $chn = substr($hash->{DEF}."01",6,2);
my ($devId,$chn) = unpack 'A6A2',$hash->{DEF}."01";
return undef if (AttrVal(CUL_HM_id2Name($devId),"subType","") eq "virtual");
my @pNames;

View File

@ -25,7 +25,7 @@ sub HMinfo_Initialize($$) {####################################################
$hash->{AttrFn} = "HMinfo_Attr";
$hash->{AttrList} = "loglevel:0,1,2,3,4,5,6 "
."sumStatus sumERROR "
."autoUpdate autoArchieve "
."autoUpdate autoArchive "
."hmAutoReadScan hmIoMaxDly "
."hmManualOper:0_auto,1_manual "
."configDir configFilename "
@ -116,7 +116,7 @@ sub HMinfo_autoUpdate($){#in:name, send status-request
(undef,$name)=split":",$name,2;
HMinfo_SetFn($defs{$name},$name,"update") if ($name);
# HMinfo_archConfig($defs{$name},$name,"","")
# if (AttrVal($name,"autoArchieve",undef) &&
# if (AttrVal($name,"autoArchive",undef) &&
# scalar(@{$modules{CUL_HM}{helper}{confUpdt}}));
InternalTimer(gettimeofday()+$defs{$name}{helper}{autoUpdate},
"HMinfo_autoUpdate","sUpdt:".$name,0)
@ -144,6 +144,7 @@ sub HMinfo_regCheck(@) { ######################################################
foreach my $eName (@entities){
my $ehash = $defs{$eName};
next if (!$ehash);
my @lsNo = CUL_HM_reglUsed($eName);
my @mReg = ();
@ -1041,36 +1042,49 @@ sub HMinfo_saveConfig($) {#####################################################
return $id;
}
sub HMinfo_archConfig($$$$) {#####################################################
# save config only if register are complete
my ($hash,$name,$opt,$fn) = @_;
my @eN;
if ($opt eq "-a"){@eN = HMinfo_getEntities("d","");}
else {@eN = @{$modules{CUL_HM}{helper}{confUpdt}}}
my @names;
push @names,CUL_HM_getAssChnNames($_) foreach(@eN);
@{$modules{CUL_HM}{helper}{confUpdt}} = ();
my @archs;
foreach(HMinfo_noDup(@names)){
if (CUL_HM_peersValid($_) !=1 ||HMinfo_regCheck($_)){
push @{$modules{CUL_HM}{helper}{confUpdt}},$_;
}
else{
push @archs,$_;
}
sub HMinfo_archConfig($$$$) {################################################
# save config only if register are complete
my ($hash,$name,$opt,$fN) = @_;
my $id = ++$hash->{nb}{cnt};
my $bl = BlockingCall("HMinfo_archConfigExec", join(",",("$name:$id"
,$fN
,$opt)),
"HMinfo_archConfigPost", 30,
"HMinfo_bpAbort", "$name:$id");
$hash->{nb}{$id}{$_} = $bl->{$_} foreach (keys %{$bl});
@{$modules{CUL_HM}{helper}{confUpdt}} = ();
return ;
}
sub HMinfo_archConfigExec($) {################################################
# save config only if register are complete
my ($id,$fN,$opt) = split ",",shift;
my @eN;
if ($opt eq "-a"){@eN = HMinfo_getEntities("d","");}
else {@eN = @{$modules{CUL_HM}{helper}{confUpdt}}}
my @names;
push @names,CUL_HM_getAssChnNames($_) foreach(@eN);
@{$modules{CUL_HM}{helper}{confUpdt}} = ();
my @archs;
@eN = ();
foreach(HMinfo_noDup(@names)){
if (CUL_HM_peersValid($_) !=1 ||HMinfo_regCheck($_)){
push @eN,$_;
}
my $id = ++$hash->{nb}{cnt};
my $bl = BlockingCall("HMinfo_saveConfig", join(",",("$name:$id"
,$fn
,"c"
,"\^(".join("|",@archs).")\$")
,"strict"),
"HMinfo_bpPost", 30,
"HMinfo_bpAbort", "$name:$id");
$hash->{nb}{$id}{$_} = $bl->{$_} foreach (keys %{$bl});
return (@{$modules{CUL_HM}{helper}{confUpdt}}
?"data incomplete:".join(",",@{$modules{CUL_HM}{helper}{confUpdt}})
:"");
else{
push @archs,$_;
}
}
HMinfo_saveConfig(join(",",( $id
,$fN
,"c"
,"\^(".join("|",@archs).")\$")
,"strict"));
return (@eN ? join(",",@eN) : "");
}
sub HMinfo_archConfigPost($) {################################################
my $post = shift;
push @{$modules{CUL_HM}{helper}{confUpdt}},split(",",$post) if ($post);
return ;
}
sub HMinfo_bpPost($) {#bp finished#############################################
@ -1898,6 +1912,13 @@ sub HMinfo_noDup(@) {#return list with no duplicates
</code></ul>
will trigger the update every 10 min<br>
</li>
<li><a name="#HMinfoautoArchive">autoArchive</a>
if set fhem will update the configFile each time the new data is available.
The update will happen with <a ref="#HMinfoautoUpdate">autoUpdate</a>. It will not
work it autoUpdate is not used.<br>
see also <a ref="#HMinfoarchConfig">archConfig</a>
<br>
</li>
<li><a name="#HMinfohmAutoReadScan">hmAutoReadScan</a>
defines the time in seconds CUL_HM tries to schedule the next autoRead
from the queue. Despite this timer FHEM will take care that only one device from the queue will be