HMInfo:10_CUL_HM:background processing of tables, display thru asyncOutput

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@9971 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
martinp876 2015-11-22 15:12:51 +00:00
parent 9f2336d1c6
commit f044d7460d
2 changed files with 204 additions and 110 deletions

View File

@ -2829,7 +2829,7 @@ sub CUL_HM_parseCommon(@){#####################################################
$attr{$mhp->{devN}}{IOgrp} = "$ioOwn:$ioHash->{NAME}" if($ioOwn); $attr{$mhp->{devN}}{IOgrp} = "$ioOwn:$ioHash->{NAME}" if($ioOwn);
CUL_HM_assignIO($mhp->{devH}) ; CUL_HM_assignIO($mhp->{devH}) ;
} }
my ($idstr, $s) = ($ioId, 0xA); my ($idstr, $s) = ($ioId, 0xA);
$idstr =~ s/(..)/sprintf("%02X%s",$s++,$1)/ge; $idstr =~ s/(..)/sprintf("%02X%s",$s++,$1)/ge;
CUL_HM_pushConfig($mhp->{devH}, $ioId, $mhp->{src},0,0,0,0, "0201$idstr"); CUL_HM_pushConfig($mhp->{devH}, $ioId, $mhp->{src},0,0,0,0, "0201$idstr");
@ -3241,6 +3241,7 @@ sub CUL_HM_Get($@) {#+++++++++++++++++ get command+++++++++++++++++++++++++++++
my ($hash, @a) = @_; my ($hash, @a) = @_;
return "no value specified" if(@a < 2); return "no value specified" if(@a < 2);
return "" if(!$hash->{NAME}); return "" if(!$hash->{NAME});
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $devName = InternalVal($name,"device",$name); my $devName = InternalVal($name,"device",$name);
my $st = AttrVal($devName, "subType", ""); my $st = AttrVal($devName, "subType", "");
@ -4675,7 +4676,7 @@ sub CUL_HM_Set($@) {#+++++++++++++++++ set command+++++++++++++++++++++++++++++
} }
($fn,$template) = split(":",($template?$template ($fn,$template) = split(":",($template?$template
:AttrVal($name,"tempListTmpl",$name))); :AttrVal($name,"tempListTmpl",$name)));
if ($modules{HMinfo} && $modules{HMinfo}{define}){ if ($modules{HMinfo}){
if (!$template){ $template = HMinfo_tempListDefFn() .":$fn" ;} if (!$template){ $template = HMinfo_tempListDefFn() .":$fn" ;}
else{ $template = HMinfo_tempListDefFn($fn).":$template";} else{ $template = HMinfo_tempListDefFn($fn).":$template";}
} }
@ -7166,6 +7167,7 @@ sub CUL_HM_4DisText($) { # convert text for 4dis
$txtHex =~ s/ ..:/,/g; #remove addr $txtHex =~ s/ ..:/,/g; #remove addr
$txtHex =~ s/ //g; #remove space $txtHex =~ s/ //g; #remove space
$txtHex =~ s/,00.*//; #remove trailing string $txtHex =~ s/,00.*//; #remove trailing string
$txt{$sAddr} = "";
my @ch = split(",",$txtHex,12); my @ch = split(",",$txtHex,12);
foreach (@ch){$txt{$sAddr}.=chr(hex($_)) if (length($_)==2)}; foreach (@ch){$txt{$sAddr}.=chr(hex($_)) if (length($_)==2)};
} }

View File

@ -12,6 +12,8 @@ sub HMinfo_peerCheck(@);
sub HMinfo_getEntities(@); sub HMinfo_getEntities(@);
sub HMinfo_SetFn($@); sub HMinfo_SetFn($@);
sub HMinfo_SetFnDly($); sub HMinfo_SetFnDly($);
sub HMinfo_noDup(@);
sub HMinfo_register ($);
use Blocking; use Blocking;
use HMConfig; use HMConfig;
@ -986,7 +988,7 @@ sub HMinfo_GetFn($@) {#########################################################
my ($hash,$name,$cmd,@a) = @_; my ($hash,$name,$cmd,@a) = @_;
my ($opt,$optEmpty,$filter) = ("",1,""); my ($opt,$optEmpty,$filter) = ("",1,"");
my $ret; my $ret;
if (@a && ($a[0] =~ m/^-/) && ($a[0] !~ m/^-f$/)){# options provided if (@a && ($a[0] =~ m/^-/) && ($a[0] !~ m/^-f$/)){# options provided
$opt = $a[0]; $opt = $a[0];
$optEmpty = ($opt =~ m/e/)?1:0; $optEmpty = ($opt =~ m/e/)?1:0;
@ -1129,53 +1131,20 @@ sub HMinfo_GetFn($@) {#########################################################
$ret = $cmd." done:" .HMinfo_peerCheck(@entities); $ret = $cmd." done:" .HMinfo_peerCheck(@entities);
} }
elsif($cmd eq "configCheck"){##check peers and register---------------------- elsif($cmd eq "configCheck"){##check peers and register----------------------
my @entities = HMinfo_getEntities($opt,$filter); my $id = ++$hash->{nb}{cnt};
$ret = $cmd." done:" .HMinfo_regCheck(@entities) my $bl = BlockingCall("HMinfo_configCheck", join(",",("$name;$id;$hash->{CL}{NAME}",$opt,$filter)),
.HMinfo_peerCheck(@entities) "HMinfo_bpPost", 30,
.HMinfo_burstCheck(@entities) "HMinfo_bpAbort", "$name:0");
.HMinfo_paramCheck(@entities); $hash->{nb}{$id}{$_} = $bl->{$_} foreach (keys %{$bl});
$ret = "";
my @td = (devspec2array("model=HM-CC-RT-DN.*:FILTER=chanNo=04"),
devspec2array("model=HM.*-TC.*:FILTER=chanNo=02"));
my @tlr;
foreach my $e (@td){
next if(!grep /$e/,@entities );
my $tr = CUL_HM_tempListTmpl($e,"verify",AttrVal($e,"tempListTmpl"
,HMinfo_tempListDefFn().":$e"));
next if ($tr eq "unused");
push @tlr,"$e: $tr" if($tr);
}
$ret .= "\n\n templist mismatch \n ".join("\n ",@tlr) if (@tlr);
$ret .= "\n\n templateCheck: \n";
foreach my $dName (HMinfo_getEntities($opt."v",$filter)){
next if (!defined $defs{$dName}{helper}{tmpl});
foreach (keys %{$defs{$dName}{helper}{tmpl}}){
my ($p,$t)=split(">",$_);
my $tck = HMinfo_templateChk($dName,$t,$p,split(" ",$defs{$dName}{helper}{tmpl}{$_}));
$ret .= "\n ".$tck if ($tck);
}
}
} }
elsif($cmd eq "templateChk"){##template: see if it applies ------------------ elsif($cmd eq "templateChk"){##template: see if it applies ------------------
my $repl; my $id = ++$hash->{nb}{cnt};
if(@a){ my $bl = BlockingCall("HMinfo_templateChk_Get", join(",",("$name;$id;$hash->{CL}{NAME}",$opt,$filter,@a)),
foreach my $dName (HMinfo_getEntities($opt."v",$filter)){ "HMinfo_bpPost", 30,
unshift @a, $dName; "HMinfo_bpAbort", "$name:0");
$repl .= HMinfo_templateChk(@a); $hash->{nb}{$id}{$_} = $bl->{$_} foreach (keys %{$bl});
shift @a; $ret = "";
}
}
else{
foreach my $dName (HMinfo_getEntities($opt."v",$filter)){
next if (!defined $defs{$dName}{helper}{tmpl});
foreach (keys %{$defs{$dName}{helper}{tmpl}}){
my ($p,$t)=split(">",$_);
$repl .= HMinfo_templateChk($dName,$t,$p,split(" ",$defs{$dName}{helper}{tmpl}{$_}));
}
}
}
return $repl;
} }
elsif($cmd eq "templateUsg"){##template: see if it applies ------------------ elsif($cmd eq "templateUsg"){##template: see if it applies ------------------
return HMinfo_templateUsg($opt,$filter,@a); return HMinfo_templateUsg($opt,$filter,@a);
@ -1230,56 +1199,63 @@ sub HMinfo_GetFn($@) {#########################################################
return HMinfo_templateList($a[0]); return HMinfo_templateList($a[0]);
} }
elsif($cmd eq "register") {##print register-------------------------------- elsif($cmd eq "register") {##print register--------------------------------
# devicenameFilter my $id = ++$hash->{nb}{cnt};
my $RegReply = ""; my $bl = BlockingCall("HMinfo_register", join(",",("$name;$id;$hash->{CL}{NAME}",$name,$opt,$filter)),
my @noReg; "HMinfo_bpPost", 30,
foreach my $dName (HMinfo_getEntities($opt."v",$filter)){ "HMinfo_bpAbort", "$name:0");
my $regs = CUL_HM_Get(CUL_HM_name2Hash($dName),$dName,"reg","all"); $hash->{nb}{$id}{$_} = $bl->{$_} foreach (keys %{$bl});
if ($regs !~ m/[0-6]:/){ $ret = "";
push @noReg,$dName; ###################
next; # # devicenameFilter
} # my $RegReply = "";
my ($peerOld,$ptOld,$ptLine,$peerLine) = ("","",pack('A23',""),pack('A23',"")); # my @noReg;
foreach my $reg (split("\n",$regs)){ # foreach my $dName (HMinfo_getEntities($opt."v",$filter)){
my ($peer,$h1) = split ("\t",$reg); # my $regs = CUL_HM_Get(CUL_HM_name2Hash($dName),$dName,"reg","all");
$peer =~s/ //g; # if ($regs !~ m/[0-6]:/){
if ($peer !~ m/3:/){ # push @noReg,$dName;
$RegReply .= $reg."\n"; # next;
next; # }
} # my ($peerOld,$ptOld,$ptLine,$peerLine) = ("","",pack('A23',""),pack('A23',""));
next if (!$h1); # foreach my $reg (split("\n",$regs)){
$peer =~s/3://; # my ($peer,$h1) = split ("\t",$reg);
my ($regN,$h2) = split (":",$h1); # $peer =~s/ //g;
my ($pt,$rN) = unpack 'A2A*',$regN; # if ($peer !~ m/3:/){
if (!defined($hash->{helper}{r}{$rN})){ # $RegReply .= $reg."\n";
$hash->{helper}{r}{$rN}{v} = ""; # next;
$hash->{helper}{r}{$rN}{u} = pack('A5',""); # }
} # next if (!$h1);
my ($val,$unit) = split (" ",$h2); # $peer =~s/3://;
$hash->{helper}{r}{$rN}{v} .= pack('A16',$val); # my ($regN,$h2) = split (":",$h1);
$hash->{helper}{r}{$rN}{u} = pack('A5',"[".$unit."]") if ($unit); # my ($pt,$rN) = unpack 'A2A*',$regN;
if ($pt ne $ptOld){ # if (!defined($hash->{helper}{r}{$rN})){
$ptLine .= pack('A16',$pt); # $hash->{helper}{r}{$rN}{v} = "";
$ptOld = $pt; # $hash->{helper}{r}{$rN}{u} = pack('A5',"");
} # }
if ($peer ne $peerOld){ # my ($val,$unit) = split (" ",$h2);
$peerLine .= pack('A32',$peer); # $hash->{helper}{r}{$rN}{v} .= pack('A16',$val);
$peerOld = $peer; # $hash->{helper}{r}{$rN}{u} = pack('A5',"[".$unit."]") if ($unit);
} # if ($pt ne $ptOld){
} # $ptLine .= pack('A16',$pt);
$RegReply .= $peerLine."\n".$ptLine."\n"; # $ptOld = $pt;
foreach my $rN (sort keys %{$hash->{helper}{r}}){ # }
$hash->{helper}{r}{$rN} =~ s/( o..)/$1 /g # if ($peer ne $peerOld){
if($rN =~ m/^MultiExec /); #shift thhis reading since it does not appear for short # $peerLine .= pack('A32',$peer);
$RegReply .= pack ('A18',$rN) # $peerOld = $peer;
.$hash->{helper}{r}{$rN}{u} # }
.$hash->{helper}{r}{$rN}{v} # }
."\n"; # $RegReply .= $peerLine."\n".$ptLine."\n";
} # foreach my $rN (sort keys %{$hash->{helper}{r}}){
delete $hash->{helper}{r}; # $hash->{helper}{r}{$rN} =~ s/( o..)/$1 /g
} # if($rN =~ m/^MultiExec /); #shift thhis reading since it does not appear for short
$ret = "No regs found for:".join(",",sort @noReg)."\n\n" # $RegReply .= pack ('A18',$rN)
.$RegReply; # .$hash->{helper}{r}{$rN}{u}
# .$hash->{helper}{r}{$rN}{v}
# ."\n";
# }
# delete $hash->{helper}{r};
# }
# $ret = "No regs found for:".join(",",sort @noReg)."\n\n"
# .$RegReply;
} }
elsif($cmd eq "param") {##print param ---------------------------------- elsif($cmd eq "param") {##print param ----------------------------------
my @paramList; my @paramList;
@ -1463,7 +1439,7 @@ sub HMinfo_SetFn($@) {#########################################################
my $fn = $a[0]?$a[0]:AttrVal($name,"configFilename","regSave.cfg"); my $fn = $a[0]?$a[0]:AttrVal($name,"configFilename","regSave.cfg");
$fn = "$attr{global}{modpath}/".AttrVal($name,"configDir",".")."\/".$fn $fn = "$attr{global}{modpath}/".AttrVal($name,"configDir",".")."\/".$fn
if ($fn !~ m/\//); if ($fn !~ m/\//);
my $bl = BlockingCall("HMinfo_purgeConfig", join(",",("$name:$id",$fn)), my $bl = BlockingCall("HMinfo_purgeConfig", join(",",("$name;$id;none",$fn)),
"HMinfo_bpPost", 30, "HMinfo_bpPost", 30,
"HMinfo_bpAbort", "$name:$id"); "HMinfo_bpAbort", "$name:$id");
$hash->{nb}{$id}{$_} = $bl->{$_} foreach (keys %{$bl}); $hash->{nb}{$id}{$_} = $bl->{$_} foreach (keys %{$bl});
@ -1474,7 +1450,7 @@ sub HMinfo_SetFn($@) {#########################################################
my $fn = $a[0]?$a[0]:AttrVal($name,"configFilename","regSave.cfg"); my $fn = $a[0]?$a[0]:AttrVal($name,"configFilename","regSave.cfg");
$fn = "$attr{global}{modpath}/".AttrVal($name,"configDir",".")."\/".$fn $fn = "$attr{global}{modpath}/".AttrVal($name,"configDir",".")."\/".$fn
if ($fn !~ m/\//); if ($fn !~ m/\//);
my $bl = BlockingCall("HMinfo_saveConfig", join(",",("$name:$id",$fn,$opt,$filter)), my $bl = BlockingCall("HMinfo_saveConfig", join(",",("$name;$id;none",$fn,$opt,$filter)),
"HMinfo_bpPost", 30, "HMinfo_bpPost", 30,
"HMinfo_bpAbort", "$name:$id"); "HMinfo_bpAbort", "$name:$id");
$hash->{nb}{$id}{$_} = $bl->{$_} foreach (keys %{$bl}); $hash->{nb}{$id}{$_} = $bl->{$_} foreach (keys %{$bl});
@ -1866,7 +1842,7 @@ sub HMinfo_purgeConfig($) {####################################################
} }
HMinfo_templateWriteUsg($fName); HMinfo_templateWriteUsg($fName);
return $id; return "$id;";
} }
sub HMinfo_saveConfig($) {##################################################### sub HMinfo_saveConfig($) {#####################################################
my ($param) = @_; my ($param) = @_;
@ -1887,7 +1863,7 @@ sub HMinfo_archConfig($$$$) {##################################################
$fN = "$attr{global}{modpath}/".AttrVal($name,"configDir",".")."\/".$fN $fN = "$attr{global}{modpath}/".AttrVal($name,"configDir",".")."\/".$fN
if ($fN !~ m/\//); if ($fN !~ m/\//);
my $id = ++$hash->{nb}{cnt}; my $id = ++$hash->{nb}{cnt};
my $bl = BlockingCall("HMinfo_archConfigExec", join(",",("$name:$id" my $bl = BlockingCall("HMinfo_archConfigExec", join(",",("$name;$id;none"
,$fN ,$fN
,$opt)), ,$opt)),
"HMinfo_archConfigPost", 30, "HMinfo_archConfigPost", 30,
@ -1924,16 +1900,110 @@ sub HMinfo_archConfigExec($) {################################################
} }
sub HMinfo_archConfigPost($) {################################################ sub HMinfo_archConfigPost($) {################################################
my @arr = split(",",shift); my @arr = split(",",shift);
my ($name,$id) = split(":",$arr[0]); my ($name,$id,$cl) = split(";",$arr[0]);
shift @arr; shift @arr;
push @{$modules{CUL_HM}{helper}{confUpdt}},@arr; push @{$modules{CUL_HM}{helper}{confUpdt}},@arr;
delete $defs{$name}{nb}{$id}; delete $defs{$name}{nb}{$id};
return ; return ;
} }
sub HMinfo_configCheck ($){ ###################################################
my ($param) = shift;
my ($id,$opt,$filter) = split ",",$param;
my @entities = HMinfo_getEntities($opt,$filter);
my $ret = "configCheck done:" .HMinfo_regCheck (@entities)
.HMinfo_peerCheck (@entities)
.HMinfo_burstCheck(@entities)
.HMinfo_paramCheck(@entities);
my @td = (devspec2array("model=HM-CC-RT-DN.*:FILTER=chanNo=04"),
devspec2array("model=HM.*-TC.*:FILTER=chanNo=02"));
my @tlr;
foreach my $e (@td){
next if(!grep /$e/,@entities );
my $tr = CUL_HM_tempListTmpl($e,"verify",AttrVal($e,"tempListTmpl"
,HMinfo_tempListDefFn().":$e"));
next if ($tr eq "unused");
push @tlr,"$e: $tr" if($tr);
}
$ret .= "\n\n templist mismatch \n ".join("\n ",@tlr) if (@tlr);
$ret .= "\n\n templateCheck: \n";
foreach my $dName (HMinfo_getEntities($opt."v",$filter)){
next if (!defined $defs{$dName}{helper}{tmpl});
foreach (keys %{$defs{$dName}{helper}{tmpl}}){
my ($p,$t)=split(">",$_);
my $tck = HMinfo_templateChk($dName,$t,$p,split(" ",$defs{$dName}{helper}{tmpl}{$_}));
$ret .= "\n ".$tck if ($tck);
}
}
$ret =~ s/\n/-ret-/g; # replace return with a placeholder - we cannot transfere direct
return "$id;$ret";
}
sub HMinfo_register ($){ ######################################################
my ($param) = shift;
my ($id,$name,$opt,$filter) = split ",",$param;
my $hash = $defs{$name};
my $RegReply = "";
my @noReg;
foreach my $dName (HMinfo_getEntities($opt."v",$filter)){
my $regs = CUL_HM_Get(CUL_HM_name2Hash($dName),$dName,"reg","all");
if ($regs !~ m/[0-6]:/){
push @noReg,$dName;
next;
}
my ($peerOld,$ptOld,$ptLine,$peerLine) = ("","",pack('A23',""),pack('A23',""));
foreach my $reg (split("\n",$regs)){
my ($peer,$h1) = split ("\t",$reg);
$peer =~s/ //g;
if ($peer !~ m/3:/){
$RegReply .= $reg."\n";
next;
}
next if (!$h1);
$peer =~s/3://;
my ($regN,$h2) = split (":",$h1);
my ($pt,$rN) = unpack 'A2A*',$regN;
if (!defined($hash->{helper}{r}{$rN})){
$hash->{helper}{r}{$rN}{v} = "";
$hash->{helper}{r}{$rN}{u} = pack('A5',"");
}
my ($val,$unit) = split (" ",$h2);
$hash->{helper}{r}{$rN}{v} .= pack('A16',$val);
$hash->{helper}{r}{$rN}{u} = pack('A5',"[".$unit."]") if ($unit);
if ($pt ne $ptOld){
$ptLine .= pack('A16',$pt);
$ptOld = $pt;
}
if ($peer ne $peerOld){
$peerLine .= pack('A32',$peer);
$peerOld = $peer;
}
}
$RegReply .= $peerLine."\n".$ptLine."\n";
foreach my $rN (sort keys %{$hash->{helper}{r}}){
$hash->{helper}{r}{$rN} =~ s/( o..)/$1 /g
if($rN =~ m/^MultiExec /); #shift thhis reading since it does not appear for short
$RegReply .= pack ('A18',$rN)
.$hash->{helper}{r}{$rN}{u}
.$hash->{helper}{r}{$rN}{v}
."\n";
}
delete $hash->{helper}{r};
}
my $ret = "No regs found for:".join(",",sort @noReg)."\n\n".$RegReply;
$ret =~ s/\n/-ret-/g; # replace return with a placeholder - we cannot transfere direct
return "$id;$ret";
}
sub HMinfo_bpPost($) {#bp finished ############################################ sub HMinfo_bpPost($) {#bp finished ############################################
my ($rep) = @_; my ($rep) = @_;
my ($name,$id) = split(":",$rep); my ($name,$id,$cl,$ret) = split(";",$rep,4);
if ($ret && defined $defs{$cl}){
$ret =~s/-ret-/\n/g; # re-insert new-line
asyncOutput($defs{$cl},$ret);
}
delete $defs{$name}{nb}{$id}; delete $defs{$name}{nb}{$id};
return; return;
} }
@ -1944,7 +2014,31 @@ sub HMinfo_bpAbort($) {#bp timeout ############################################
return; return;
} }
sub HMinfo_templateChk_Get ($){ ###############################################
my ($param) = shift;
my ($id,$opt,$filter,@a) = split ",",$param;
my $ret;
if(@a){
foreach my $dName (HMinfo_getEntities($opt."v",$filter)){
unshift @a, $dName;
$ret .= HMinfo_templateChk(@a);
shift @a;
}
}
else{
foreach my $dName (HMinfo_getEntities($opt."v",$filter)){
next if (!defined $defs{$dName}{helper}{tmpl});
foreach (keys %{$defs{$dName}{helper}{tmpl}}){
my ($p,$t)=split(">",$_);
$ret .= HMinfo_templateChk($dName,$t,$p,split(" ",$defs{$dName}{helper}{tmpl}{$_}));
}
}
}
$ret = $ret ? $ret
:"templateChk: passed";
$ret =~ s/\n/-ret-/g; # replace return with a placeholder - we cannot transfere direct
return "$id;$ret";
}
sub HMinfo_templateDef(@){##################################################### sub HMinfo_templateDef(@){#####################################################
my ($name,$param,$desc,@regs) = @_; my ($name,$param,$desc,@regs) = @_;
return "insufficient parameter, no param" if(!defined $param); return "insufficient parameter, no param" if(!defined $param);
@ -2190,7 +2284,7 @@ sub HMinfo_templateWrite($){###################################################
HMinfo_templateWriteUsg($fName) if ($HMConfig::culHmTpl{tmplUsgChange}); HMinfo_templateWriteUsg($fName) if ($HMConfig::culHmTpl{tmplUsgChange});
return; return;
} }
sub HMinfo_templateWriteDef($){################################################### sub HMinfo_templateWriteDef($){################################################
my $fName = shift; my $fName = shift;
$HMConfig::culHmTpl{tmplDefChange} = 0; # reset changed bits $HMConfig::culHmTpl{tmplDefChange} = 0; # reset changed bits
my @tmpl =(); my @tmpl =();
@ -2218,7 +2312,7 @@ sub HMinfo_templateWriteDef($){#################################################
return; return;
} }
sub HMinfo_templateWriteUsg($){################################################### sub HMinfo_templateWriteUsg($){################################################
my $fName = shift; my $fName = shift;
$HMConfig::culHmTpl{tmplUsgChange} = 0; # reset changed bits $HMConfig::culHmTpl{tmplUsgChange} = 0; # reset changed bits
my @tmpl =(); my @tmpl =();
@ -2305,9 +2399,7 @@ sub HMinfo_noDup(@) {#return list with no duplicates###########################
} }
########################tetsection#############################################
##############################################################
# HM overview # HM overview
############################################################## ##############################################################
# Gives an overview of all CUL_HM devices and their channels # Gives an overview of all CUL_HM devices and their channels