mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-10 10:04:28 +02:00
global: give script or function name in log messages
This commit is contained in:
parent
b0e52aa2d1
commit
f46db91845
46 changed files with 262 additions and 212 deletions
13
mode-button
13
mode-button
|
@ -6,23 +6,24 @@
|
|||
# act on multiple mode and reset button presses
|
||||
# https://git.eworm.de/cgit/routeros-scripts/about/doc/mode-button.md
|
||||
|
||||
:local 0 "mode-button";
|
||||
:global GlobalFunctionsReady;
|
||||
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
||||
|
||||
:global ModeButton;
|
||||
|
||||
:global LogPrintExit;
|
||||
:global LogPrintExit2;
|
||||
|
||||
:set ($ModeButton->"count") ($ModeButton->"count" + 1);
|
||||
|
||||
:local Scheduler [ / system scheduler find where name="ModeButtonScheduler" ];
|
||||
|
||||
:if ([ :len $Scheduler ] = 0) do={
|
||||
$LogPrintExit info ("Creating scheduler ModeButtonScheduler, counting presses...") false;
|
||||
$LogPrintExit2 info $0 ("Creating scheduler ModeButtonScheduler, counting presses...") false;
|
||||
:global ModeButtonScheduler do={
|
||||
:global ModeButton;
|
||||
|
||||
:global LogPrintExit;
|
||||
:global LogPrintExit2;
|
||||
:global ModeButtonScheduler;
|
||||
|
||||
:local LEDInvert do={
|
||||
|
@ -45,7 +46,7 @@
|
|||
/ system scheduler remove ModeButtonScheduler;
|
||||
|
||||
:if ([ :len $Code ] > 0) do={
|
||||
$LogPrintExit info ("Acting on " . $Count . " mode-button presses: " . $Code) false;
|
||||
$LogPrintExit2 info $0 ("Acting on " . $Count . " mode-button presses: " . $Code) false;
|
||||
|
||||
:for I from=1 to=$Count do={
|
||||
$LEDInvert;
|
||||
|
@ -59,12 +60,12 @@
|
|||
|
||||
[ :parse $Code ];
|
||||
} else={
|
||||
$LogPrintExit info ("No action defined for " . $Count . " mode-button presses.") false;
|
||||
$LogPrintExit2 info $0 ("No action defined for " . $Count . " mode-button presses.") false;
|
||||
}
|
||||
}
|
||||
/ system scheduler add name="ModeButtonScheduler" \
|
||||
on-event=":global ModeButtonScheduler; \$ModeButtonScheduler;" interval=3s;
|
||||
} else={
|
||||
$LogPrintExit debug ("Updating scheduler ModeButtonScheduler...") false;
|
||||
$LogPrintExit2 debug $0 ("Updating scheduler ModeButtonScheduler...") false;
|
||||
/ system scheduler set $Scheduler start-time=[ /system clock get time ];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue