mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
made sleep nonblocking in at/notify/etc
git-svn-id: https://svn.fhem.de/fhem/trunk@1398 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
b88ece1aaf
commit
7dff85e2fc
@ -20,6 +20,7 @@
|
||||
- feature: FHEMWEB console (== inform timer)
|
||||
- feature: remove dependency on Google::Weather, major rewrite (Boris)
|
||||
- feature: started experimental interface implementation (fhem API v2) (Boris)
|
||||
- feature: sleep issued in at/notify/etc is not blocking fhem anymore
|
||||
|
||||
|
||||
- 2011-12-31 (5.2)
|
||||
|
@ -1020,12 +1020,11 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
Example:
|
||||
<ul>
|
||||
<code>sleep 0.5</code><br>
|
||||
<code>notify btn3 set lamp toggle;;sleep 0.5;;set lamp toggle</code>
|
||||
<code>define n3 notify btn3.* set lamp toggle;;sleep 0.5;;set lamp toggle</code>
|
||||
</ul>
|
||||
<br>
|
||||
Note: As the server is <b>not</b> multithreaded, everything is blocked for
|
||||
the given amount.<br>
|
||||
|
||||
Note: sleep followed by another command and issued in at/notify/etc is not
|
||||
blocking fhem.<br>
|
||||
</ul>
|
||||
|
||||
|
||||
|
23
fhem/fhem.pl
23
fhem/fhem.pl
@ -183,6 +183,7 @@ my $namedef =
|
||||
"- a range seperated by dash (-)\n";
|
||||
my $stt_sec; # Used by SecondsTillTomorrow()
|
||||
my $stt_day; # Used by SecondsTillTomorrow()
|
||||
my @cmdList; # Remaining commands in a chain. Used by sleep
|
||||
|
||||
$init_done = 0;
|
||||
|
||||
@ -683,7 +684,8 @@ AnalyzeCommandChain($$)
|
||||
$cmd =~ s/#.*$//s;
|
||||
|
||||
$cmd =~ s/;;/SeMiCoLoN/g;
|
||||
foreach my $subcmd (split(";", $cmd)) {
|
||||
@cmdList = split(";", $cmd);
|
||||
while(my $subcmd = shift @cmdList) {
|
||||
$subcmd =~ s/SeMiCoLoN/;/g;
|
||||
my $lret = AnalyzeCommand($c, $subcmd);
|
||||
push(@ret, $lret) if(defined($lret));
|
||||
@ -725,7 +727,6 @@ AnalyzeCommand($$)
|
||||
$cmd =~ s/^(\\\n|[ \t])*//;# Strip space or \\n at the begginning
|
||||
$cmd =~ s/[ \t]*$//;
|
||||
|
||||
|
||||
Log 5, "Cmd: >$cmd<";
|
||||
return undef if(!$cmd);
|
||||
|
||||
@ -1929,10 +1930,26 @@ CommandSleep($$)
|
||||
|
||||
return "Cannot interpret $param as seconds" if($param !~ m/^[0-9\.]+$/);
|
||||
Log 4, "sleeping for $param";
|
||||
select(undef, undef, undef, $param);
|
||||
|
||||
if(!$cl && @cmdList && $param && $init_done) {
|
||||
InternalTimer(gettimeofday()+$param, "WakeUpFn", join(";;", @cmdList), 0);
|
||||
@cmdList=();
|
||||
|
||||
} else {
|
||||
select(undef, undef, undef, $param);
|
||||
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub
|
||||
WakeUpFn($)
|
||||
{
|
||||
my $param = shift;
|
||||
my $ret = AnalyzeCommandChain(undef, $param);
|
||||
Log 2, "After sleep: $ret" if($ret);
|
||||
}
|
||||
|
||||
|
||||
#####################################
|
||||
# Return the time to the next event (or undef if there is none)
|
||||
|
Loading…
Reference in New Issue
Block a user