98_apptime:improve nice calculation

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@19468 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
martinp876 2019-05-26 07:13:48 +00:00
parent deb0d9a06a
commit 29868d57c7

View File

@ -23,7 +23,6 @@ use vars qw(%prioQueues);
sub apptime_getTiming($$$@);
sub apptime_Initialize($);
use constant DEBUG_OUTPUT_INTATA => 0;
my $apptimeStatus;
@ -46,32 +45,6 @@ my $totCnt = 0;
sub HandleTimeout() {
return undef if(!$nextat);
if (DEBUG_OUTPUT_INTATA) {
my $ms = 0;
my $n = int(@intAtA);
my $j;
for ($j=0; $j < ($n-1); $j++) {
if (!defined($intAtA[$j])) {
Log 0, "Error in intAtA, undefined element $j/$n\n";
}
elsif (!defined($intAtA[$j]->{TRIGGERTIME})) {
Log 0, "Error in intAtA, undefined tim $j/$n\n";
}
next if ($intAtA[$j]->{TRIGGERTIME} <= $intAtA[$j+1]->{TRIGGERTIME});
if (!$ms) {
Log 0, "Error in intAtA, sortErr $j/$n\n";
$ms = 1;
}
}
$j = $n-1;
if (!defined($intAtA[$j])) {
Log 0, "Error in intAtA, undefined element $j/$n\n";
}
elsif (!defined($intAtA[$j]->{TRIGGERTIME})) {
Log 0, "Error in intAtA, undefined tim $j/$n\n";
}
}
my $now = gettimeofday();
if($now < $nextat) {
$selectTimestamp = $now;
@ -106,7 +79,7 @@ sub HandleTimeout() {
$fnname = $cv->GV->NAME;
}
$arg = $at->{ARG};
$shortarg = (defined($arg)?$arg:"");
$shortarg = (defined($arg)?$arg:"_");
$shortarg = "HASH_unnamed" if ( (ref($shortarg) eq "HASH")
&& !defined($shortarg->{NAME}) );
($shortarg,undef) = split(/:|;/,$shortarg,2); # for special long args with delim ;
@ -120,7 +93,7 @@ sub HandleTimeout() {
$now = gettimeofday();
if(%prioQueues) {
my $nice = minNum(keys %prioQueues);
my $nice = minNum(19,keys %prioQueues);
my $entry = shift(@{$prioQueues{$nice}});
delete $prioQueues{$nice} if(!@{$prioQueues{$nice}});