Network variable events, The nv_update_occurs event – Echelon Neuron C User Manual
Page 63

Neuron C Programmer’s Guide
51
Network Variable Events
Chapter 2,
, on page 15, introduced the event
scheduling mechanism and discussed a number of predefined events. Four
predefined events are specifically related to network variables:
nv_update_completes [(
network-var-reference
)]
nv_update_fails [(
network-var-reference
)]
nv_update_occurs [(
network-var-reference
)]
nv_update_succeeds [(
network-var-reference
)]
The nv_update_occurs event applies only to input network variables. The other
three events (nv_update_completes, nv_update_fails, nv_update_succeeds) apply
to output network variables when they are updated, and to input network
variables when they are polled.
The event expression may be qualified with a
network-var-reference
, which can
be a network variable name, a network variable array element (as in
network-
var
[
index
]), a network variable array name, or a range of network variables. If
the event is qualified by an array name, the event occurs once for each element
for which the event is applicable.
The form of the event that permits a range of network variables has the syntax
shown below. The range consists of two network variable or network variable
element references, separated by two consecutive dot characters ".." indicating
the range. This syntax applies to all four
event-names
shown above. Each
network variable is assigned a global index by the compiler. An array of network
variables is assigned consecutive indices, one for each element. The range event
applies to all network variables whose global indices are between the global index
for
nvA
and
nvB
, inclusive. The global index of
nvA
must be less than the global
index of
nvB
.
event-name
[(
nvA .. nvB
)]
This section provides an introduction to these events. For convenience, we refer
to them as network variable
completion events
, because they all pertain to
whether or not a network variable update or poll has completed. Note that
completion does not imply success. See also Chapter 6,
Communicate Using Application Messages
, on page 117, which includes more
detailed information on using these completion events.
The nv_update_occurs Event
When a new value has been received for an input network variable, the
nv_update_occurs event evaluates to TRUE. If a specific network variable is not
used to qualify the event, it evaluates to TRUE for any network variable update
on that device.
The nv_update_occurs event is used in many situations. For example, a lamp
program could use this event as follows:
// Use the network variable’s value
// as the new state for the lamp
network input SNVT_switch nviLampState;
when (nv_update_occurs(nviLampState)) {