From 23bcb8591c5cc0af8e5b6970c04e223b1f32b24f Mon Sep 17 00:00:00 2001 From: martinp876 <> Date: Sat, 12 Nov 2016 19:20:48 +0000 Subject: [PATCH] CUL_HM: update alarm time calculation git-svn-id: https://svn.fhem.de/fhem/trunk@12552 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/10_CUL_HM.pm | 34 +++++++++++++++++++++++++++------- fhem/FHEM/98_HMinfo.pm | 18 ++++++++++-------- fhem/FHEM/HMConfig.pm | 2 +- 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/fhem/FHEM/10_CUL_HM.pm b/fhem/FHEM/10_CUL_HM.pm index c771a6601..fdad1f8fc 100755 --- a/fhem/FHEM/10_CUL_HM.pm +++ b/fhem/FHEM/10_CUL_HM.pm @@ -6587,13 +6587,6 @@ sub CUL_HM_SndCmd($$) { ) ){ - # shall we delay commands if IO device is not present? - # it could cause trouble if light switches on after a long period - # repetition will be stopped after 1min forsecurity reason. - my @arr = (); - $hash->{cmdStack} = \@arr if(!$hash->{cmdStack}); - unshift (@{$hash->{cmdStack}}, $cmd);#pushback cmd, wait for opportunity - # push device to list if (!defined $modules{CUL_HM}{$ioName}{tmr}){ # some setup work for this timer @@ -6603,9 +6596,24 @@ sub CUL_HM_SndCmd($$) { $modules{CUL_HM}{$ioName}{pendDev} = \@arr2; } } + + # shall we delay commands if IO device is not present? + # it could cause trouble if light switches on after a long period + # repetition will be stopped after 1min forsecurity reason. + # so do: return cmd to queue and set state to pending again. + # device will be queued @ CUL_HM. Timer will perform cyclic check for IO to return. + # + my @arr = (); + $hash->{cmdStack} = \@arr if(!$hash->{cmdStack}); + $cmd = $hash->{helper}{prt}{rspWait}{cmd} if( $hash->{helper}{prt}{rspWait} + && $hash->{helper}{prt}{rspWait}{cmd}); + unshift (@{$hash->{cmdStack}}, $cmd);#pushback cmd, wait for opportunity + @{$modules{CUL_HM}{$ioName}{pendDev}} = CUL_HM_noDup(@{$modules{CUL_HM}{$ioName}{pendDev}},$hash->{NAME}); CUL_HM_respPendRm($hash);#rm timer - we are out + CUL_HM_protState($hash,"CMDs_pending"); + if ($modules{CUL_HM}{$ioName}{tmr} != 1){# need to start timer my $tn = gettimeofday(); InternalTimer($tn+$IOpoll, "CUL_HM_sndIfOpen", "sndIfOpen:$ioName", 0); @@ -7832,6 +7840,18 @@ sub CUL_HM_CvTflt($) { # config time -> float my ($inValue) = @_; return ($inValue & 0x1f)*((sort {$a <=> $b} keys(%fltCvT))[$inValue >> 5]); } + +sub CUL_HM_flt6CvT($) { # float -> config time + my ($inValue) = @_; + my $exp = ($inValue>127)?1:0; + return ($exp << 7)+int($inValue/($exp?60:1)); +} +sub CUL_HM_CvTflt6($) { # config time -> float + my ($inValue) = @_; + $inValue = 129 if ($inValue == 128); + return ($inValue & 0x7f)*(($inValue >> 7)?60:1); +} + sub CUL_HM_min2time($) { # minutes -> time my $min = shift; $min = $min * 30; diff --git a/fhem/FHEM/98_HMinfo.pm b/fhem/FHEM/98_HMinfo.pm index 5491b2a4a..d1ae39361 100644 --- a/fhem/FHEM/98_HMinfo.pm +++ b/fhem/FHEM/98_HMinfo.pm @@ -1696,7 +1696,7 @@ sub HMInfo_help(){ ############################################################ ."\n remove a template set" ."\n set templateExe -templateName-" ."\n write all assigned templates to the file" - ."\n get templateUsg -templateName-" + ."\n get templateUsg -templateName-[sortPeer|sortTemplate]" ."\n show template usage" ."\n get templateChk [-typeFilter-] -templateName- -peer:[long|short]- [-param1- ...] " ."\n compare whether register match the template values" @@ -2382,7 +2382,7 @@ sub HMinfo_templateUsg(@){##################################################### next if(!defined $defs{$dName}{helper}{tmpl}); foreach my $tid(keys %{$defs{$dName}{helper}{tmpl}}){ my ($p,$t) = split(">",$tid); - if($tFilter){ + if($tFilter && $tFilter =~ m/^sort.*/){ if($tFilter eq "sortTemplate"){ push @ul,sprintf("%-20s|%-15s|%s|%s",$t,$dName,$p,$defs{$dName}{helper}{tmpl}{$tid}); } @@ -2390,8 +2390,9 @@ sub HMinfo_templateUsg(@){##################################################### my ($pn,$ls) = split(":",$p); push @ul,sprintf("%-20s|%-15s|%5s:%-20s|%s",$pn,$t,$ls,$dName,$defs{$dName}{helper}{tmpl}{$tid}); } - elsif($tFilter ne $t){ - next;} +# elsif($tFilter ne $t){ +# next; +# } } else{ my @param; @@ -2404,8 +2405,9 @@ sub HMinfo_templateUsg(@){##################################################### } $para = join(" ",@param); } - - push @ul,sprintf("%-20s|%-15s|%s|%s",$dName,$p,$t,$para);} + push @ul,sprintf("%-20s|%-15s|%s|%s",$dName,$p,$t,$para) if(!$tFilter || $tFilter eq $t); + + } } } return join("\n",sort(@ul)); @@ -2772,7 +2774,7 @@ sub HMinfo_noDup(@) {#return list with no duplicates###########################