Declaring synchronous network variables, Synchronous vs. nonsynchronous network variables, Updating synchronous network variables – Echelon Neuron C User Manual

Page 66

Advertising
background image

54

How Devices Communicate Using Network Variables

Declaring Synchronous Network Variables

To declare a synchronous network variable, include a synchronized

or sync

keyword in its declaration. An example declaration is shown below:

network output sync SNVT_temp nvoRelativeTemp;

In the following example, the network variable is declared as synchronous so that
all the updates are sent. (If more than one alarm goes off, we want to receive

notice of all alarms, not just the most recent one.)

// ensure multiple alarms are handled serially
network output sync SNVT_alarm nvoAlarm;

Synchronous output network variables do not have to be connected to
synchronous input network variables. All input network variables operate

synchronously regardless of whether the synchronous attribute was assigned.

Synchronous vs. Nonsynchronous Network Variables

For most applications, nonsynchronous network variables are adequate and
should be used when possible. Many applications need the most

recent

value, not

all of the values, for a given network variable. Widespread use of synchronous

network variables that are frequently updated could delay processing if the
program frequently runs out of buffers (see

Preemption Mode

on page 55).

Depending on the device buffering, channel speed, and congestion of the network,

application performance could be adversely affected by extensive use of
synchronous network variables.
If a program is required to use

relative

(or

delta

) data values, synchronous

network variables might be necessary to preserve the intermediate data values.
For programs using

absolute

data values, nonsynchronous network variables are

usually sufficient.

A nonsynchronous output network variable goes out on the network when the

next output buffer is available. If the program updates the variable again before

that time, only the most recent value goes out. A synchronous output network
variable causes the application to wait for an output buffer if none is available.

In this case, the scheduler enters preemption mode (see

Preemption Mode

on

page 55).

For input network variables, an incoming network variable update always

results in an event for the application. All input network variables operate

synchronously regardless of whether the synchronous attribute was assigned.

Updating Synchronous Network Variables

Synchronous network variables are always updated at the end of each critical

section. If a buffer is not available, the scheduler waits for one. Nonsynchronous

network variables, on the other hand, are updated at the end of critical sections
when the scheduler has application buffers available to do so. Unlike

synchronous network variables, they are not always updated at the end of the

next critical section. As already pointed out, where multiple updates occur, the
intermediate values might never be propagated across the network.

Advertising