Software
Crestron
SIMPL+
This syntax defines a
wait
event to occur at some time in the future, defined by the
value of wait_time. While the wait event is pending execution, it is said to have been
“scheduled”. The wait event may have an optional name, which can be used to refer
back to the event elsewhere in the code.
When a
wait
event definition is reached during execution, the execution of the
statements inside the braces (these braces are not needed if the event is only one
statement long) is deferred until the time defined by wait_time has expired. Until this
occurs, the remainder of the SIMPL+ program executes. If a
wait
event definition is
nested inside of a loop, it is possible that it can be reached multiple times before it
even executes once. If a
wait
event is pending (i.e., has been scheduled, but not
executed), it is not scheduled again until it has been completed.
Once a
wait
event has been scheduled to execute at some later point in time, various
operations can be performed on the event before it actually executes. However, only
named
wait
events can be modified in this manner, since it is necessary to use the
name to refer to the event. The table on the next page lists the available functions,
which can operate on
wait
events.
Functions Available During Wait Events
FUNCTION
DESCRIPTION
CancelWait(name)
Removes the named wait from the schedule. The code never
executes.
CancelAllWait()
Removes all pending waits from the schedule.
PauseWait(name)
Stops the timer for the named wait. The code does not execute
until the timer is started again using ResumeWait().
ResumeWait(name)
Resumes the timer for the named wait, which had been paused
earlier.
PauseAllWait()
Similar to PauseWait(), but acts on all pending wait events.
ResumeAllWait()
Similar to ResumeWait(), but acts on all paused wait events.
RetimeWait(time, name) Sets the time for a pending wait event to the value specified.
This example shows a typical use of wait events. Here, the
SYSTEM ON
button
starts a power up sequence and the
SYSTEM OFF
button likewise starts a power
down sequence.
#DEFINE_CONSTANT PULSETIME 50 // half second
DIGITAL_INPUT system_on, system_off;
DIGITAL_OUTPUT screen_up, screen_down, lift_up, lift_down;
DIGITAL_OUTPUT vcr_on, vcr_off, dvd_on, dvd_off;
DIGITAL_OUTPUT vproj_on, vproj_off;
DIGITAL_OUTPUT vproj_video1, vproj_video2, vproj_rgb;
DIGITAL_OUTPUT lights_pre_1, lights_pre_2, lights_pre_3;
PUSH system_on
{
CancelWait(sysOffWait);
// cancel the system off wait event
Pulse(2000, screen_down); // lower screen for 20 sec.
Pulse(9500,
lift_down);
// lower lift for 9.5 sec.
Wait (1000, sysOnWait1) // 10 second delay
{
Pulse(PULSETIME,
vcr_on);
Pulse(PULSETIME,
dvd_on);
Pulse(PULSETIME,
lights_pre_1);
44
•
SIMPL+
Programming Guide – DOC. 5789A