Author |
|
ward Newbie
Joined: November 28 2001 Location: United States
Online Status: Offline Posts: 1
|
Posted: November 28 2001 at 14:54 | IP Logged
|
|
|
After reading over the manual
(admittedly, quite quickly), it
is unclear what happens in the
following situation...
a motion sensor indicates movement
which triggers a macro which
turns the light on and then 'wait's
to turn it off. Then, before
the light is turned off, motion is
again detected. It would seem that
the macro would be run again and
it should detect that the light is
on and simply terminate. However,
this will not adjust the 'wait'
correctly if I want "The light will
stay on 15 minutes after motion is
detected".
How would I program that function?
Many thanks, this looks package looks very cool.
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 01 2001 at 15:28 | IP Logged
|
|
|
Ward,
You are correct in that the macro would again be executed as a separate instance. You could obtain the functionality that you want by using a global variable to keep track of the other macros. There are a number of different ways that you could accomplish this. I'll detail one that comes to mind...
Declare a global variable which will hold the time the light should be turned off...ie 15 minutes into the future.
When your macro executes from motion being detected, have it update this global variable with the current time plus 15 minutes ( or 14 mins, 59 seconds to resolve any timing issues). Then have your macro wait for 15 minutes. When the macro resumes execution, have it check the global variable and compare it to the current time. If the current time is greater than the global, then shut the light off. This way every time motion is detected, a new macro will spawn and set the global to 15 minutes from when motion was detected. If the current time is not greater than the global, just have the macro exit as another macro will be timing out soon.
Let me know if this helps,
Dave.
|
Back to Top |
|
|
|
|