When updates occur, Declaring network variables, 47 describes t – Echelon Neuron C User Manual

Page 59

Advertising
background image

Neuron C Programmer’s Guide

47

Note: This discussion uses the terms

writer device

and

reader device

. A writer

device is a device that writes to a particular network variable (an output network
variable). A reader device is a device that reads a particular network variable

(an input network variable). In many cases, a device has both input and output

network variables declared in its program, and therefore acts both as a “writer
device” and a “reader device,” depending on the network variable.

When Updates Occur

The new value of a network variable received by a reader device does not take

effect immediately upon reception and processing of the message. Similarly,
assignment of a new value to an output network variable does not cause a

message to be sent immediately. Rather, updates occur at the end of a critical
section in the application program. A

critical section

is defined as a set of

application program statements during which network variable updates are not

propagated.

A task is an example of a critical section: once begun, each task runs to

completion. When network variable updates are received or requested, they are

posted by the scheduler at the end of each critical section. An application can use
the post_events( ) function to divide a single task into two or more critical

sections. The post_events( ) function can be used to increase throughput and

improve response time since it forms a boundary at which outgoing network
variable updates are sent and incoming network variable updates are processed.

See Chapter 7,

Additional Features

, on page 145, for further discussion of

post_events( ).

Declaring Network Variables

The syntax for declaring a network variable is shown below. The first form of the

declaration is for a simple network variable, and the second form is for a network
variable array.
network input | output [

netvar-modifier

] [

class

]

type

[

connection-info

]

identifier

[

=

initial-value

] [

nv-property-list

] ;

network input | output [

netvar-modifier

] [

class

]

type

[

connection

-

info

]

identifier

[

array

-

bound

]

[

=

initializer

-

list

] [

nv

-

property

-

list

] ;

Note: The brackets around the term

array-bound

do not, in this case, indicate an

optional field. They are required and must be part of the program.

A Neuron-hosted device can declare up to 254 network variables (including array

elements), but the device’s resource capacity (as defined by its memory map)

might not support the maximum number of network variables.

You can declare an array of network variables using the second form of the

syntax shown above. The array can only be single dimension. The

array-bound

must be a constant. Each element of the array is treated as a separate network

variable for purposes of events, transmissions on the network, and so on.

Therefore, each element counts individually towards the maximum number of
network variables on a given device. Each element of the array is then a

separately bindable

network variable.

Advertising