2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-22 20:24:36 +00:00

89_VCONTROL.pm: double InternalTimer after SET or GET removed; new Internal Duration that shows the duration of the last Poll cycle in seconds

git-svn-id: https://svn.fhem.de/fhem/trunk@7420 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
adamwit 2015-01-03 16:57:17 +00:00
parent d7bf318c8a
commit 4205b23876

View File

@ -49,6 +49,7 @@ my $poll_now = POLL_PAUSED;
my $get_timer_now = GET_TIMER_PAUSED;
my $get_config_now = GET_CONFIG_PAUSED;
my $command_config_file = "";
my $poll_duration = 0;
#Send Parameter
my $send_now = NO_SEND;
my $send_additonal_param="";
@ -213,6 +214,9 @@ VCONTROL_Define($$)
#set Internal Timer on Polling Interval
my $timer = gettimeofday()+1;
Log3($name, 5, "VCONTROL set InternalTimer +1 to $timer");
InternalTimer(gettimeofday()+1, "VCONTROL_Poll", $hash, 0);
return undef;
@ -264,8 +268,13 @@ sub
VCONTROL_Poll($)
{
my $hash = shift;
my $name = $hash->{NAME};
#global Module Trigger that Polling is started
$poll_now=POLL_ACTIVE;
$poll_duration = gettimeofday();
Log3 $name, 4, "VCONTROL: Start of Poll !";
my $timer = gettimeofday()+$hash->{INTERVAL};
Log3($name, 5, "VCONTROL: set InternalTimer to $timer");
InternalTimer(gettimeofday()+$hash->{INTERVAL}, "VCONTROL_Poll", $hash, 0);
}
@ -394,7 +403,10 @@ VCONTROL_Read($)
#End of Poll Interval
if ($poll_now == POLL_ACTIVE && $last_cmd == $cmdcount)
{
Log3 $name, 5, "VCONTROL: End of Poll";
$poll_duration = (gettimeofday() - $poll_duration);
my $duration = sprintf("%.2f", $poll_duration);
$hash->{DURATION} = "$duration";
Log3 $name, 4, "VCONTROL: End of Poll ! Duration: $duration";
$poll_now = POLL_PAUSED;
$last_cmd = 0;
@cmd_list = @poll_cmd_list;
@ -403,6 +415,8 @@ VCONTROL_Read($)
#activate timer get list if questioned
if ($get_timer_now == GET_TIMER_ACTIVE && $send_now == NO_SEND ){
@cmd_list = @get_timer_cmd_list;
Log3 $name, 5, "VCONTROL: Poll TIMER!";
RemoveInternalTimer($hash);
VCONTROL_Poll($hash);
$get_timer_now = GET_TIMER_PAUSED;
}
@ -630,7 +644,12 @@ VCONTROL_Parse($$$$)
@cmd_list = @get_timer_cmd_list;
$get_timer_now = GET_TIMER_PAUSED;
}
VCONTROL_Poll($hash) if (substr($hexline, 0, 2) == "00");
if (substr($hexline, 0, 2) == "00"){
Log3 $pn, 5, "VCONTROL: Poll SET!";
RemoveInternalTimer($hash);
VCONTROL_Poll($hash);
}
}
$send_now = $next_send;
}
@ -793,6 +812,8 @@ sub VCONTROL_Get($@) {
if ($poll_now == POLL_PAUSED ){
@cmd_list = @get_timer_cmd_list;
Log3 $pn, 5, "VCONTROL: Poll GET!";
RemoveInternalTimer($hash);
VCONTROL_Poll($hash);
}
else { $get_timer_now = GET_TIMER_ACTIVE; }