Echelon Neuron C User Manual
Page 69

Neuron C Programmer’s Guide
57
The reader device makes its request through the poll( ) function. The syntax is
shown below:
poll ([
network-var
]);
network-var
is an input network variable identifier.
If no network variable is specified, all input network variables for the device are
polled. For Neuron-hosted applications, an explicit polled declaration is not
allowed for an input network variable; see
Declaring an Input Network Variable
on page 58.
The
network-var
identifier can also be a network variable array identifier, or an
element of a network variable array, as in
network_var
[
index
]. If a network
variable array name is used without an index, all elements of the array are
polled.
The new value resulting from the poll is not immediately available after the
poll( ) function call. Use a qualified nv_update_occurs event in a when clause, or
some other conditional statement, to obtain the new, polled value.
Example:
mtimer tDelayedPolling;
network input SNVT_switch nviCooling;
when (reset) {
// set up timer for delayed power-up polling:
tDelayedPolling = 4ul * random(); // >= 1 second
... // other reset processing
}
when (timer_expires(tDelayedPolling)) {
poll(nviCooling);
...
}
when (nv_update_occurs(nviCooling)) {
...
}
Here is a lamp program that includes a poll of the input network variable
nviLampState after a reset event. The device obtains the most recent value of
nviLampState, and then uses that value after reset.
// LAMP.NC -- Sample lamp actuator program,
// polls the switch on reset
///////////////// Network Variables ////////////////////
network input SNVT_switch nviLampState;
//////////////////////// Constants /////////////////////
#define LED_ON 0
#define LED_OFF 1
/////////////////////// I/O Objects ////////////////////
IO_0 output bit ioLED = LED_OFF;