7 Scripting
29
7.6.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; it can accept a second string parameter to act as a description of the
thread running and a third string parameter to redefine the thread origin, which may be useful for
thread.
←
-
killall
and
thread.limit
;
•
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.6.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.
As follows from the above, the number of LCD rows is
# ui.line
. Use
ui.column_count
to retrieve the
number of LCD columns (usually 16).
7.6.2.6
Configuration access
The global variable
config
represents a partial read-only view on the unit configuration (most of them strings):
•
config.serial
: unit serial number;
•
config.hostname
: unit hostname;
•
config.contact
: primary unit contact;
•
config.contacts
: a table storing contacts related to the unit in different ways;
•
config.location
: physical location of the unit;
•
config.timezone
: system time zone;
•
config.hardware_id
: unit hardware model;
•
config.oid
: object identifier of unit model;
•
config.version
: firmware version;
•
config.outlet_label
: kind of endpoint manipulated by the unit (Outlet/Relay).
DLI LPC9 User’s Guide: 1.7.24.0
Summary of Contents for LPC9
Page 1: ...DLI LPC9 User s Guide 1 7 24 0 ...
Page 81: ......