mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-19 18:56:03 +00:00
watchdog: optimize modify to allow optional parameters
git-svn-id: https://svn.fhem.de/fhem/trunk@5622 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
87f52c22a5
commit
0665a677b2
@ -26,10 +26,21 @@ sub
|
|||||||
watchdog_Define($$)
|
watchdog_Define($$)
|
||||||
{
|
{
|
||||||
my ($watchdog, $def) = @_;
|
my ($watchdog, $def) = @_;
|
||||||
my ($name, $type, $re1, $to, $re2, $command) = split("[ \t]+", $def, 6);
|
my ($name, $type, $re1, $to, $re2, $cmd) = split("[ \t]+", $def, 6);
|
||||||
|
|
||||||
return "Usage: define <name> watchdog <re1> <timeout> <re2> <command>"
|
|
||||||
if(!$command);
|
if(defined($watchdog->{TO})) { # modify
|
||||||
|
$re1 = $watchdog->{RE1} if(!defined($re1));
|
||||||
|
$to = $watchdog->{TO} if(!defined($to));
|
||||||
|
$re2 = $watchdog->{RE2} if(!defined($re2));
|
||||||
|
$cmd = $watchdog->{CMD} if(!defined($cmd));
|
||||||
|
$watchdog->{DEF} = "$re1 $to $re2 $cmd";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return "Usage: define <name> watchdog <re1> <timeout> <re2> <command>"
|
||||||
|
if(!$cmd);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
# Checking for misleading regexps
|
# Checking for misleading regexps
|
||||||
eval { "Hallo" =~ m/^$re1$/ };
|
eval { "Hallo" =~ m/^$re1$/ };
|
||||||
@ -45,8 +56,7 @@ watchdog_Define($$)
|
|||||||
$watchdog->{RE1} = $re1;
|
$watchdog->{RE1} = $re1;
|
||||||
$watchdog->{RE2} = $re2;
|
$watchdog->{RE2} = $re2;
|
||||||
$watchdog->{TO} = $to;
|
$watchdog->{TO} = $to;
|
||||||
$watchdog->{CMD} = $command;
|
$watchdog->{CMD} = $cmd;
|
||||||
|
|
||||||
|
|
||||||
if($re1 eq ".") {
|
if($re1 eq ".") {
|
||||||
watchdog_Activate($watchdog)
|
watchdog_Activate($watchdog)
|
||||||
@ -215,6 +225,8 @@ watchdog_Undef($$)
|
|||||||
command once it has triggered (unless you restart fhem)</li>
|
command once it has triggered (unless you restart fhem)</li>
|
||||||
<li>a generic watchdog (one watchdog responsible for more devices) is
|
<li>a generic watchdog (one watchdog responsible for more devices) is
|
||||||
currently not possible.</li>
|
currently not possible.</li>
|
||||||
|
<li>with modify all parameters are optional, and will not be changed if
|
||||||
|
not specified.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
@ -314,6 +326,9 @@ watchdog_Undef($$)
|
|||||||
<li>Ein generischer Watchdog (ein Watchdog, verantwortlich für
|
<li>Ein generischer Watchdog (ein Watchdog, verantwortlich für
|
||||||
mehrere Devices) ist derzeit nicht möglich.</li>
|
mehrere Devices) ist derzeit nicht möglich.</li>
|
||||||
|
|
||||||
|
<li>Bei modify sind alle Parameter optional, und werden nicht geaendert,
|
||||||
|
falls nicht spezifiziert.</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user