Accessing property values from a program – Echelon Neuron C User Manual

Page 103

Advertising
background image

Neuron C Programmer’s Guide

91

member that is shared between two or more network variables. The use of the

static keyword creates a CP family member that is shared between all the
members of a network variable array, but not with any other network variables

outside the array. See

Sharing of Configuration Properties

on page 96 for more

information on this topic.

Accessing Property Values from a Program

You can access configuration properties from a program just as you can access

any other variable. For example, you can use configuration properties as

function parameters and you can use addresses of configuration properties.

However, to use a CP family member in an expression, you must specify

which

family member to access, because there could be more than one member of the
same CP family with the same name applying to different network variables.

The syntax for accessing a configuration property from a network variable’s

property list uses the Neuron C context operator, a double colon, as shown below:

nv-context

::

property-reference

nv-context

:

identifier

[

index-expr

]

identifier

property-reference : property-identifier

[

index-expr

]

property-identifier

Example:

// CP for heartbeat and throttle (default 1 min each)
SCPTmaxSndT cp_family cpMaxSendT = { 0, 0, 1, 0, 0 };
SCPTminSndT cp_family cpMinSendT = { 0, 0, 1, 0, 0 };

// NV with heartbeat and throttle:
network output SNVT_lev_percent nvoValue
nv_properties

{

cpMaxSendT,

cpMinSendT = { 0, 0, 0, 30, 0 }

};

void f(void)
{
...

if (nvoValue::cpMaxSendT.seconds > 0) {

...
}
}

The particular CP family member is identified by a qualifier that precedes it.
This qualifier is called the

context

. The context is followed by two consecutive

colon characters, called the

context operator

, and then the name of the property.

Because there cannot be two or more properties with the same configuration
property type that apply to the same network variable, each property is unique

within a particular context. The context therefore uniquely identifies the

property. For example, a network variable array, nvoArray, with 10 elements,
could be declared with a property list referencing a CP family named cpXyz.

There would then be 10 different members of the cpXyz CP family, all with the

same name. However, adding the context, such as nvoArray[4]::cpXyz, or
nvoArray[j]::cpXyz, uniquely identifies the CP family member.

Advertising