Types of events used in when clauses, Predefined events – Echelon Neuron C User Manual
Page 30

18
Focusing on a Single Device
event
This expression is either a predefined event (see the following section)
or any valid Neuron C expression (which can contain a predefined
event). Predefined events as well as expressions are enclosed in
parentheses. One or more when clauses can be associated with the
same task.
task
A Neuron C compound statement, consisting of a series of Neuron C
declarations and statements, enclosed in braces, which are identical
to those found in a Neuron C function definition. The task is
identical to the body of a void function (that is, it cannot return a
value). A return statement can be used to terminate execution of the
task but is not required.
Types of Events Used in When Clauses
The events defined in a when clause fall into two general categories: predefined
events and user-defined events.
Predefined events
use keywords built into the
compiler. Examples of predefined events include input pin state changes,
network variable changes, timer expiration, and message reception.
User-
defined events
can be any valid Neuron C expression that evaluates or converts
to a Boolean value.
The distinction between user-defined events and predefined events is not critical.
Use predefined events whenever possible, because they require less code space.
There is one exception to the statement that a when clause can be any valid C
expression. The offline, online, and wink predefined events must appear by
themselves if used. All other predefined events may be combined into any
arbitrary expressions. This restriction only applies to when clauses.
Examples:
when
(msg_arrives) //
O.K.
when (msg_arrives && flag == TRUE) // O.K.
when
(online)
//
O.K.
when (online && flag == TRUE)
// Not permitted.
Predefined Events
The timer_expires event shown earlier is one type of predefined event. Table 4
lists other predefined events that are represented by unique keywords.
Table 4. Predefined Events
Predefined Event
Where Described in This Manual
flush_completes Chapter
7
io_changes this
chapter
io_in_ready this
chapter
io_out_ready this
chapter
io_update_occurs this
chapter