Echelon Neuron C User Manual

Page 206

Advertising
background image

186

Functional Block Declarations

the program. The array entry is an unsigned short. Its declaration, in the

<echelon.h> file, is:

extern const unsigned short fblock_index_map[ ];

The value for each network variable is set to the global index of the functional

block of which it is a member. If the network variable is not a member of any
functional block, the value for its entry in the fblock_index_map array is set to

the value 0xFF.

Accessing Members and Properties of a
Functional Block from a Program

The network variable members and configuration property (implemented as
network variable) members of a functional block can be accessed from a program

just as any other variable can be accessed. For example, they can be used in
expressions, as function parameters, or as operands of the address operator or

the increment operator. To access a network variable member of a functional

block, or to access a network variable configuration property of a functional block,
the network variable reference can be used in the program just as any other

variable would be.
However, to use a CP family member, you must specify which family member is
being accessed, because more than one functional block could have a member

from the same CP family. The syntax for accessing a configuration property from

a functional block’s property list is:

fb-context

::

property-identifier

[

index-expr

]

fb-context

::

property-identifier

fb-context

:

identifier

[

index-expr

]

identifier

The particular 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, and then the name of the property. Because there cannot be two or

more properties with the same SCPT or UCPT type that apply to the same
functional block, this restriction means that each property is unique within a

particular context. The context uniquely identifies the property. For example, a

functional block array, fba, with 10 elements, could be declared with a property
list referencing a CP family named xyz. There would then be 10 different

members of the CP family xyz, all with the same name. However, adding the

context, such as fba[4]::xyz, or fba[j]::xyz, uniquely identifies the CP family
member.
Example:

// Continuing from the example earlier in the chapter
// that declared MyFb1[2] and MyFb2[2] ...

void f(void)
{

MyFb1[0]::nvoData = muldiv( rawData,

MyFb1[0]::cpGain.multiplier,
MyFb1[0]::cpGain.divider

);

}

Advertising