Declaring configuration properties within files, Declaring configuration properties within, Files – Echelon Neuron C User Manual

Page 98

Advertising
background image

86

Using Configuration Properties to Configure Device Behavior

configuration property, or with the entire configuration network variable array

being handled as a single configuration property. See

Instantiation of

Configuration Properties

on page 88 for details.

A configuration network variable's declaration can contain an

initial-value

or an

initializer-list

, like any other network variable declaration, as discussed in the

previous chapter.

Unlike

any other network variable, a configuration network

variable cannot, itself, also have a network variable property list. That is, you
cannot define configuration properties that apply to other configuration

properties.
When using a network variable array as a configuration property or properties,
particular care should be given to the compiler's rules of initialization for that

network variable array. The array elements can be initialized in the declaration,

as is the case with any variable or array variable declaration. If some or all of
the array elements are not initialized, the uninitialized elements default to a zero

initialization. However, each array element can be initialized when it appears as

a property in a properties clause, and this declaration overrides the initialization
in the declaration, but only for the element that appears in that property clause.

Similarly, if the entire network variable array is used as a single configuration

property, the entire array can be initialized when it appears as a property in a
properties clause.
You cannot change the type of a configuration property unless it inherits its type
from a changeable-type network variable.

Declaring Configuration Properties within Files

You can declare a configuration property that is to be implemented within a

configuration file using a CP family declaration. A CP family declaration can be
thought of as a

meta

-declaration, defining a type construct for later use in the

program. It can be used to declare a collection of many configuration properties,

identical in type and certain other settings, but individually applying to one or
more different network variables, functional blocks (as described in Chapter 5,

Using Functional Blocks to Implement a Device Interface

, on page 101), or the

device itself. A CP family can have zero members, one member, or many
members. No code or data is generated until you declare members of the CP

family, as described later. In this regard, the CP family is similar to a C

language typedef.

The syntax for declaring a CP family is shown below:

[const]

type

cp_family [

cp

-

modifiers

]

family-ident

[=

initial

-

value

] ;

family-ident : identifier

[

array-bound

]

identifier

Example:

SCPTgain cp_family cpGain = { 2, 3 };

The

type

for a CP family cannot be just a standard C type, such as int or char.

Instead, the declaration must use a configuration property type (CPT) from a

resource file. The configuration property type can either be a standard
configuration property type (SCPT) or a user configuration property type (UCPT).

There are over 300 SCPT definitions available today, and you can create your
own manufacturer-specific types using UCPTs. The SCPT definitions are stored

Advertising