Crestron SIMPL+ Reference Manual page 33

Language reference guide
Hide thumbs Also See for SIMPL+:
Table of Contents

Advertisement

Crestron SIMPL+
Language Reference Guide - DOC. 5797G
®
A SIMPL program drives the trig signal and monitors the state of the analog_output
with an ANALOG DEBUGGER (Speedkey: TEST2) symbol. If the system did not
task switch out, the only TEST2 output would show 32000. If this program were run,
there would be many outputs, indicating each time the FOR loop exceeded the
allotted time, the SIMPL program would be given time to run and the TEST2 symbol
would post the results.
If it were critical that the analog_output were only updated with the final value, the
following alternative solution could be used:
DIGITAL_INPUT trig;
ANALOG_OUTPUT i;
INTEGER j, q;
PUSH trig
{
j=0;
FOR(j=0 to 32000)
{
q = j;
}
i = q;
}
This program output would only show the final result; the TEST2 would be triggered
once with the value 32000. The system will still perform whatever task switching it
requires.
When an event has task switched away, it is possible that the event may be retriggered
and a new copy of the event will start running. Therefore, SIMPL+ events are
considered to be re-entrant. The event may be reentered only a limited number of
times before an Rstack overflow error occurs (refer to "Common Runtime Errors"
that begins on page 302). In order to prevent the event from running multiple times,
consider the following example:
DIGITAL_INPUT trig;
INTEGER I;
PUSH trig
{
FOR(I = 0 TO 32000)
{
// code
}
}
This code will task switch away at some point in the FOR loop. If trig is hit again
while the event is task switched out, a new copy will run. This code can be changed
to prevent multiple copies from running.
DIGITAL_INPUT trig;
INTEGER I, Running;
PUSH trig
{
IF(!Running)
Software
®
SIMPL+
23

Advertisement

Table of Contents
loading

Table of Contents