2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-04 05:16:45 +00:00

- some problems with InternalTimers fixed

git-svn-id: https://svn.fhem.de/fhem/trunk@4277 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
dietmar63 2013-11-23 18:09:25 +00:00
parent 31a1a27db8
commit aee5d48ca5

View File

@ -152,16 +152,16 @@ sub Twilight_Define($$)
return undef; return undef;
} }
################################################################################ ################################################################################
sub Twilight_Undef($$) sub Twilight_Undef($$) {
{
my ($hash, $arg) = @_; my ($hash, $arg) = @_;
RemoveInternalTimer($hash->{$hash->{SP}{SUNPOS}});
foreach my $key (keys %{$hash->{TW}}) { foreach my $key (keys %{$hash->{TW}}) {
my $hashSx = $hash->{$hash->{TW}{$key}{NAME}}; myRemoveInternalTimer($key, $hash);
RemoveInternalTimer($hashSx);
} }
RemoveInternalTimer($hash); myRemoveInternalTimer ("", $hash);
myRemoveInternalTimer ("perlTime", $hash);
myRemoveInternalTimer ("sunpos", $hash);
return undef; return undef;
} }
################################################################################ ################################################################################
@ -287,30 +287,16 @@ sub myRemoveInternalTimer($$) {
} }
} }
################################################################################ ################################################################################
sub Twilight_WeatherTimerSet($) sub Twilight_Midnight($) {
{
my ($hash) = @_;
my $now = time();
foreach my $key ("ss_weather", "sr_weather" ) {
my $tim = $hash->{TW}{$key}{TIME};
if ($tim-60*60>$now) {
InternalTimer ($tim - 60*60, "Twilight_WeatherTimerUpdate", $hash, 0);
}
}
}
################################################################################
sub Twilight_Midnight($)
{
my ($hash) = @_; my ($hash) = @_;
Twilight_TwilightTimes ($hash, "Mid"); Twilight_TwilightTimes ($hash, "Mid");
Twilight_StandardTimerSet ($hash); Twilight_StandardTimerSet ($hash);
} }
################################ ################################################ ################################ ################################################
sub Twilight_WeatherTimerUpdate($) sub Twilight_WeatherTimerUpdate($) {
{ my ($myHash) = @_;
my ($hash) = @_; my $hash = $myHash->{HASH};
Twilight_TwilightTimes ($hash, "Wea"); Twilight_TwilightTimes ($hash, "Wea");
Twilight_StandardTimerSet ($hash); Twilight_StandardTimerSet ($hash);
@ -325,11 +311,25 @@ sub Twilight_StandardTimerSet($) {
Twilight_WeatherTimerSet ($hash); Twilight_WeatherTimerSet ($hash);
} }
################################################################################ ################################################################################
sub Twilight_WeatherTimerSet($) {
my ($hash) = @_;
my $now = time();
myRemoveInternalTimer ("perlTime", $hash);
foreach my $key ("ss_weather", "sr_weather" ) {
my $tim = $hash->{TW}{$key}{TIME};
if ($tim-60*60>$now) {
myInternalTimer ("perlTime", $tim-60*60, "Twilight_WeatherTimerUpdate", $hash, 0);
}
}
}
################################################################################
sub Twilight_sunposTimerSet($) { sub Twilight_sunposTimerSet($) {
my ($hash) = @_; my ($hash) = @_;
myRemoveInternalTimer ("sunpos", $hash); myRemoveInternalTimer ("sunpos", $hash);
myInternalTimer ("sunpos", time()+$hash->{SUNPOS_OFFSET}, "Twilight_sunpos", $hash, 0); myInternalTimer ("sunpos", time()+$hash->{SUNPOS_OFFSET}, "Twilight_sunpos", $hash, 0);
$hash->{SUNPOS_OFFSET} = 5*60; $hash->{SUNPOS_OFFSET} = 5*60;
} }
################################################################################ ################################################################################
@ -450,7 +450,7 @@ sub Twilight_sunpos($)
my $dLongitude = $hash->{LONGITUDE}; my $dLongitude = $hash->{LONGITUDE};
my $dLatitude = $hash->{LATITUDE}; my $dLatitude = $hash->{LATITUDE};
Log3 $hash, 5, "Compute sunpos for latitude $dLatitude , longitude $dLongitude"; Log3 $hash, 5, "Compute sunpos for latitude $dLatitude , longitude $dLongitude" if($dHours == 0 && $dMinutes <= 6 );
my $pi=3.14159265358979323846; my $pi=3.14159265358979323846;
my $twopi=(2*$pi); my $twopi=(2*$pi);