20
CONTENTS
All functions defined this way will be usable from the web UI and callable externally. If you want to define a function
for internal use, not to be called from outside, prefix it with
local
:
local function my_internal_function()
... statements go here ...
end
Functions in Lua are called with their arguments parenthesised, e.g.
func(arg1,arg2)
. Functions with no
arguments are caled with empty parentheses, like
func()
. However, according to Lua syntax, a single string
function argument doesn't need parentheses, thus allowing the BASIC-like commands to avoid them if there's only
one argument.
7.3
Threading
Multiple threads of execution can be running at the same time. Any number of threads may run concurrently.
Thread control
No threads currently running.
Start
thread:
do_some_lua_stuff
Start
User script thread list
Threads can be started from the web UI, via an HTTP request, by an
AutoPing
trigger, or from other threads using
thread.run
. They can be explicitly stopped using the web UI or by calling
thread.kill
or
thread.
←
-
killall
from the script, or implicitly by calling
thread.limit
.
Every thread has an 'origin', which is usually a string identifying the function that started the thread. For instance,
when you create a function like this:
function my_function()
... statements go here ...
end
and then start it with the web UI, its origin is the
"my_function"
string. Threads created by other threads inherit
their parent's origin, which can be useful when stopping a group of threads.
7.4
API levels
The scripting engine presents two sets of functions that you can use to write scripts:
• Legacy functions - functions which are designed to resemble the BASIC commands of the previous genera-
tions of EPCR/LPC controllers;
• Modern API - functions and objects which are designed to be easier to use.
You can use and even freely mix them as you wish, but only the modern API will receive further development atten-
tion. Some features are exposed only via the modern API because they had no corresponding legacy commands.
DLI DIN4 User’s Guide: 20170809T111540Z
Содержание DIN4
Страница 1: ...DLI DIN4 User s Guide 20170809T111540Z ...
Страница 57: ......