7 Scripting 23
7.4.2.4 Thread management
Several threads can be executed simultaneously in a pseudo-parallel fashion. The global thread table contains
these methods:
• thread.run can be used to start new threads; it accepts the thread function as argument, and returns the
identifier of the resulting thread;
• thread.kill can be used to stop a thread; it accepts the identifier of the thread as an argument;
• thread.killall can be used to stop many threads; it accepts the origin of the threads to kill as an
argument (without an argument, all threads are killed, including the calling one);
• thread.limit allows to ensure that no more than the specified number of threads with the same origin
are present; its first argument is the maximum number of threads, and the second one is one of the strings
"this", "earliest" or "latest", indicating which thread(s) should be killed if their count is above
the limit (it's possible to specify an array of values, like {"this","latest"}, instead).
7.4.2.5 User interface
The global ui table provides means of configuring the LCD display, backlight and beeper.
Functions ui.beep and ui.blink configure the beeper and LCD backlight, respectively. Their first argument
should be a string of "1"s and "0"s, which specifies the pattern, and their second argument should be the number
of seconds after which the preceding behaviour is restored.
The ui.line table has two elements ui.line[1] and ui.line[2], specifying the custom displayed strings
for the LCD rows (or nil for regular operation of said row). This offers more fine-grained control than the DISPLAY
command above.
7.4.2.6 AutoPing integration
The global autoping table allows to query and configure AutoPing.
• autoping.enabled: boolean variable which allows enabling (true) or disabling (false) AutoPing;
• autoping.items[N].enabled: read-only boolean value indicating if the N'th AutoPing item is enabled;
• autoping.items[N].enable: function to call to attempt to enable (with the argument true) or disable
(with the argument false) the N'th AutoPing;
• autoping.items[N].addresses: array of hostnames or IP addresses of the N'th AutoPing item's
elements;
• autoping.items[N].outlets: array of relays controlled by the N'th AutoPing item; the field name is
chosen to match AC products;
• autoping.items[N].script: the name of the scripting function run by the N'th AutoPing item when
it's triggered ("" to cycle the controlled relays);
• autoping.items[N].status: the run-time status of the N'th AutoPing item;
• autoping.ping_interval: ping interval;
• autoping.ping_timeout: ping timeout;
• autoping.post_reboot_delay: post-reboot delay;
• autoping.max_reboot_count: maximum reboot count;
• autoping.pings_before_enabling: pings before enabling.
DLI DIN4 User’s Guide: 20170809T111540Z