Echelon Neuron C User Manual

Page 123

Advertising
background image

Neuron C Programmer’s Guide

111

This expression uses the network variable’s member identifier, not the network

variable’s unique name. Using the context expression to identify a member
network variable therefore promotes modular device design and reuse of code –

multiple functional blocks implementing the same functional profile can all

implement the same network variable members, although each block’s members
are mapped to a different network variable.
Finally, the properties of the functional block’s network variable members can
also be accessed through an extension of this syntax. The syntax for accessing a

functional block’s member’s property is shown below (the

fb-context

syntactical

element is defined above):

fb

-

context

::

member

-

identifier

::

property

-

identifier

[ [

index

-

expr

] ]

Example:

#define NUM_AMMETERS 3

SCPTmaxSndT cp_family cpMaxSendTime;
SCPTminSndT cp_family cpMinSendTime;
SCPTgain cp_family cpGain[4];
SCPTupdateRate cp_family cpUpdateRate;

network output SNVT_amp nvoAmpere[NUM_AMMETERS]
nv_properties

{

cpMaxSendTime,
cpMinSendTime
};

fblock SFPTopenLoopSensor {

nvoAmpere[0] implements nvoValue;

} fbAmpereMeter[NUM_AMMETERS] external_name("AmpereMeter")
fb_properties

{

cpGain, // Each property is an array [4]

static

cpUpdateRate

};

All of the following constructs are examples for valid code:

nvoAmpere[2] = 123;
fbAmpereMeter[2]::nvoValue = 123;
fbAmpereMeter[0]::cpGain[i].multiplier = 2L;
nvoAmpere[2]::cpMaxSendTime.seconds = 30;
fbAmpereMeter[2]::nvoValue::cpMaxSendTime.hour = 0;
z = ((SCPTmaxSndT *)&nvoAmpere[2]::cpMaxSendTime)->day;

Pointers can be used with CP family members as shown; however, the

configuration properties are stored in EEPROM. This causes the compiler to

apply special rules as described for the #pragma relaxed_casting_on directive in
the

Neuron C Reference Guide

.

Because cpGain is a static configuration property, the following expression is

always true:

fbAmpereMeter[0]::cpGain[i].multiplier ==
fbAmpereMeter[1]::cpGain[i].multiplier

The following expressions are

incorrect

and cause a compiler error:

// '.' instead of '::'
fbAmpereMeter[0].cpGain[i].multiplier = 123;

Advertising