28
CONTENTS
•
wday
, which stands for day of the week (1 is Sunday, 2 is Monday, 7 is Saturday);
•
yday
, which stands for day of the year (1 is January, 1st);
•
hour
, which stands for hours;
•
min
, which stands for minutes;
•
sec
, which stands for seconds;
•
isdst
, which stands for the daylight savings time flag (true or false).
The values corresponding to the keys are the actual restrictions, all of which must be met in order for the condition
to be satisfied. A simple value (i.e. a number for anything but the DST flag, and true/false for the DST flag) matches
only itself. A function (receiving the field's value as argument) matches anything for which it returns true.
Here are some examples of conditions that can be used:
{hour=0,min=0,sec=0} -- matches at midnight;
{hour=7} -- matches anywhere between 7:00:00 and 7:59:59;
{wday=function(d) return d==1 or d==7 end} -- matches weekends.
It is not advised to perform exact matches on seconds since delays of internal operations may be greater than 1
second. It is advised to introduce additional delays to avoid triggering the same match again. The following sample
switches outlet 1 on at 8:00 and off at 17:00.
while true do
local event=wait_until({hour=8,min=0},{hour=17,min=0})
if event==1 then
ON(1)
else -- event==2
OFF(1)
end
delay (120)
end
We match with minute precision here and wait for 2 minutes to avoid double matching.
7.6.2.3
Outlet management
The global variable
outlet
represents a Lua array of outlet objects.
•
outlet[N].on()
: switches the outlet on (affects transient state);
•
outlet[N].off()
: switches the outlet off (affects transient state);
•
outlet[N].cycle()
: cycles the outlet (affects transient state);
•
outlet[N].persistent_state
: boolean representing the persistent requested state of the outlet
(writes will affect transient state as well);
•
outlet[N].transient_state
: boolean representing the transient requested state of the outlet;
•
outlet[N].physical_state
: read-only boolean representing the physical state of the outlet;
•
outlet[N].state
: boolean reflecting outlet physical state when read, modifying transient state when
written;
•
outlet[N].locked
: read-only boolean indicating if the outlet is locked.
Global constants
on
and
off
are
true
and
false
, respectively, useful to make scripts more readable, like
outlet[1].state=on
;
DLI LPC9 User’s Guide: 1.7.24.0
Содержание LPC9
Страница 1: ...DLI LPC9 User s Guide 1 7 24 0 ...
Страница 81: ......