Declaring an input network variable as polled, Declaring an output network variable as polled – Echelon Neuron C User Manual

Page 70

Advertising
background image

58

How Devices Communicate Using Network Variables

mtimer tDelayedPolling;

/////////////////////////// Tasks //////////////////////
// NV update task -- handle update to lamp state
// Use the network variable’s value as the new state
// for the lamp
when (nv_update_occurs(nviLampState)) {
io_out(ioLED,

nviLampState.value

&&

nviLampState.state

?

LED_ON

:

LED_OFF);

}

when (reset) {
// set up timer for delayed power-up polling:
tDelayedPolling = 4ul * random(); // >= 1 second
... // other reset processing
}


when (timer_expires(tDelayedPolling)) {
poll(nviLampState);
}

Declaring an Input Network Variable as Polled

For Neuron-hosted applications, you cannot declare in input network variable as

polled; the Neuron C compiler issues an error message for polled input network

variables.

However, within a model file for a host-based application (such as for a

ShortStack, FTXL, or

i

.LON SmartServer application), you can declare an input

network variable as polled:

network input polled

type netvar

;

For host-based applications, the application code is written in a language other

than Neuron C, and therefore the presence of the poll( ) function within the
application would not cause the compiler to adjust the device’s self-identification

data to allow the network tool to create the network variable binding
appropriately. Thus, within a model file, the declaration of the input network

variable is allowed to be declared as polled so that the ShortStack Micro Server,

FTXL LonTalk protocol stack, or

i

.LON SmartServer can allow the network

variable to be polled.

Declaring an Output Network Variable as Polled

To allow devices to receive network variable updates from other devices only at

specified times, declare the output network variable as polled:

network output polled

type netvar

;

In this special case, the output network variable’s value is never propagated as a

result of its value changing. Instead, the output network variable’s value is sent

only

in response to a poll request from a reader device, or if the propagate( )

function is called for that network variable.

Advertising