mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
98_HourCounter.pm : bug: if cvent occurs without value change, wrong calculcation of pulseTimeIncrement, pauseTimeIncrement
git-svn-id: https://svn.fhem.de/fhem/trunk@7336 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
23a38c6c52
commit
8f57a265ad
@ -1,4 +1,4 @@
|
|||||||
# $Id: 98_HourCounter.pm 7281 2014-12-21 12:00:00Z john $
|
# $Id: 98_HourCounter.pm 7336 2014-12-27 20:00:00Z john $
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
#
|
#
|
||||||
# 98_HourCounter.pm
|
# 98_HourCounter.pm
|
||||||
@ -58,6 +58,8 @@
|
|||||||
# 21.12.14 - 1.0.1.1
|
# 21.12.14 - 1.0.1.1
|
||||||
# bug: if OFF is not defined, nothing was counted
|
# bug: if OFF is not defined, nothing was counted
|
||||||
# html : check with tidy
|
# html : check with tidy
|
||||||
|
# 24.12.14 - 1.0.1.2
|
||||||
|
# bug: if cvent occurs without value change, wrong calculcation of pulseTimeIncrement, pauseTimeIncrement
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
|
|
||||||
package main;
|
package main;
|
||||||
@ -67,7 +69,7 @@ use vars qw(%defs);
|
|||||||
use vars qw($readingFnAttributes);
|
use vars qw($readingFnAttributes);
|
||||||
use vars qw(%attr);
|
use vars qw(%attr);
|
||||||
use vars qw(%modules);
|
use vars qw(%modules);
|
||||||
my $HourCounter_Version = "1.0.1.1 - 21.12.2014";
|
my $HourCounter_Version = "1.0.1.2 - 24.12.2014";
|
||||||
|
|
||||||
my @HourCounter_cmdQeue = ();
|
my @HourCounter_cmdQeue = ();
|
||||||
|
|
||||||
@ -239,6 +241,10 @@ sub HourCounter_Define($$$)
|
|||||||
eval { "Hallo" =~ m/^$offRegexp/ };
|
eval { "Hallo" =~ m/^$offRegexp/ };
|
||||||
return "Bad regexp_for_ON : $@" if ($@);
|
return "Bad regexp_for_ON : $@" if ($@);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# some inits
|
||||||
|
$hash->{VERSION} = $HourCounter_Version;
|
||||||
$hash->{helper}{ON_Regexp} = $onRegexp;
|
$hash->{helper}{ON_Regexp} = $onRegexp;
|
||||||
$hash->{helper}{OFF_Regexp} = $offRegexp;
|
$hash->{helper}{OFF_Regexp} = $offRegexp;
|
||||||
$hash->{helper}{isFirstRun} = 1;
|
$hash->{helper}{isFirstRun} = 1;
|
||||||
@ -626,45 +632,50 @@ sub HourCounter_Run($)
|
|||||||
$hasValueChanged = 1;
|
$hasValueChanged = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
# -------------- positive edge
|
if ($hasValueChanged)
|
||||||
if ( $hasValueChanged && $valuePara == 1 )
|
|
||||||
{
|
{
|
||||||
$value = $valuePara;
|
$value = $valuePara;
|
||||||
$valueOld = $valuePara;
|
$valueOld = $valuePara;
|
||||||
|
|
||||||
# handling of counters
|
# -------------- positive edge
|
||||||
$countsPerDay += 1;
|
if ( $valuePara == 1 )
|
||||||
$countsOverall += 1;
|
|
||||||
|
|
||||||
#.. handling of pause
|
|
||||||
if ($isOffDefined)
|
|
||||||
{
|
{
|
||||||
$pauseTimeIncrement += $timeIncrement;
|
# handling of counters
|
||||||
$pauseTimePerDay += $timeIncrement;
|
$countsPerDay += 1;
|
||||||
$pauseTimeOverall += $timeIncrement;
|
$countsOverall += 1;
|
||||||
$pulseTimeIncrement = 0;
|
|
||||||
$pauseTimeEdge = $pauseTimeIncrement;
|
# handling of pause time
|
||||||
|
if ($isOffDefined)
|
||||||
|
{
|
||||||
|
# calc the rest of puse-time until edge
|
||||||
|
$pauseTimeIncrement += $timeIncrement;
|
||||||
|
$pauseTimePerDay += $timeIncrement;
|
||||||
|
$pauseTimeOverall += $timeIncrement;
|
||||||
|
$pulseTimeIncrement = 0;
|
||||||
|
$pauseTimeEdge = $pauseTimeIncrement;
|
||||||
|
}
|
||||||
|
HourCounter_Log $hash, 4, "rising edge; pauseTimeIncr:$pauseTimeIncrement countPerDay:$countsPerDay";
|
||||||
|
}
|
||||||
|
|
||||||
|
# ------------ negative edge
|
||||||
|
elsif ( $valuePara == 0 )
|
||||||
|
{
|
||||||
|
# handlich of pulse time
|
||||||
|
if ($isOffDefined)
|
||||||
|
{
|
||||||
|
$pulseTimeIncrement += $timeIncrement;
|
||||||
|
$pulseTimePerDay += $timeIncrement;
|
||||||
|
$pulseTimeOverall += $timeIncrement;
|
||||||
|
$pauseTimeIncrement = 0;
|
||||||
|
$pulseTimeEdge = $pulseTimeIncrement;
|
||||||
|
}
|
||||||
|
HourCounter_Log $hash, 4, "falling edge pulseTimeIncrement:$pulseTimeIncrement";
|
||||||
}
|
}
|
||||||
HourCounter_Log $hash, 4, "rising edge; pauseTimeIncr:$pauseTimeIncrement countPerDay:$countsPerDay";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ------------ negative edge
|
# ------------ no value change
|
||||||
elsif ( $hasValueChanged && $valuePara == 0 )
|
# it is possible to receive an event without change of value (e.g. Max Shutter does it hourly)
|
||||||
{
|
elsif ($isOffDefined)
|
||||||
$value = $valuePara;
|
|
||||||
$valueOld = $valuePara;
|
|
||||||
|
|
||||||
# handling of pulse time
|
|
||||||
$pulseTimeIncrement += $timeIncrement;
|
|
||||||
$pulseTimePerDay += $timeIncrement;
|
|
||||||
$pulseTimeOverall += $timeIncrement;
|
|
||||||
$pulseTimeEdge = $pulseTimeIncrement;
|
|
||||||
$pauseTimeIncrement = 0;
|
|
||||||
HourCounter_Log $hash, 4, "falling edge pulseTimeIncrement:$pulseTimeIncrement";
|
|
||||||
}
|
|
||||||
|
|
||||||
# --------------- no change
|
|
||||||
elsif ( $valuePara == -1 && $isOffDefined )
|
|
||||||
{
|
{
|
||||||
if ( $valueOld == 0 )
|
if ( $valueOld == 0 )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user