Echelon Neuron C User Manual
Page 107

Neuron C Programmer’s Guide
95
Initialization of Configuration Properties at
Instantiation
You can initialize a configuration property of fixed type in its declaration. When
a network variable array is used as an array of configuration properties, the
following example could occur. Each of the four configuration properties shown
below is initialized to the value '10' (a power-up delay value is a number of
seconds).
network input cp SCPTpwrUpDelay nvcp[4] = {10, 10, 10, 10};
It is
not required
to initialize the configuration property at instantiation, but this
can be useful, as explained in the following example. Assume that we want to
declare two network variables nvoA and nvoB, and we want to associate the
nvcp[0] configuration property with nvoA, and nvcp[1] with nvoB. Furthermore,
in these two instances, we want the power-up delay properties to be 5 seconds,
and 10 seconds, respectively.
We can then
override
the initial value in the declaration with a new initial value
in the instantiation of the property for nvoA, but take advantage of the previous
initialization of nvcp[1] to 10.
Example of Network Variable CP Initialization
network input cp SCPTpwrUpDelay nvcp[4] = {10, 10, 10, 10};
network output SNVT_volt nvoA
nv_properties { nvcp[0] = 5 };
network output SNVT_amp nvoB
nv_properties { nvcp[1] };
Extending the above example, consider another network variable array nvoC of
two members, where we use nvcp[2] and nvcp[3] as configuration properties of
nvoC[0] and nvoC[1], respectively. Also, we want these configuration properties
each initialized to 60 seconds. We can use the following declaration:
network output SNVT_count nvoC[2] = {100, 100}
nv_properties { nvcp[2] = 60 };
The nvoC network variable is an array, so the nvcp[2] property reference is
treated as a
starting point
for the compiler to perform the automatic assignment
of properties, as discussed
Configuration Properties Applying to Arrays
on page
92. The compiler automatically replicates the reference to nvcp[2], which applies
to nvoC[0], and the replication occurs for each subsequent element of the nvoC
array (nvcp[3] to nvoC[1], and so on). In this replication, the compiler also
replicates the initialization (in this case, nvcp[3] is therefore also initialized to
60). It is therefore
not possible
to have
different
initial values for each element's
configuration property, unless these initial values are provided with the
declaration of the configuration network variable array as shown here.
Example of Network Variable CP Initialization
network input cp SCPTpwrUpDelay nvcp[4] = {10, 20, 30, 40};
network output SNVT_volt nvoA
nv_properties { nciPwrUpDly[0] };