Echelon Neuron C User Manual
Page 81

Neuron C Programmer’s Guide
69
You can use a changeable-type network variable to implement a generic
functional block that works with different types of inputs and outputs. For
example, you can create a general-purpose device that can be used with a variety
of sensors or actuators, and then create a functional block that allows the
integrator to select the network variable type depending on the physical sensor or
actuator attached to the device during installation.
You can support type changing to any network variable type defined in a resource
file (that is, any SNVT or UNVT in a resource file). You can only create a
changeable-type network variable if the network variable is a member of a
functional block, and if it is not a configuration network variable. An integrator
typically uses a plug-in that you create to change network variable types. A
network variable cannot change its type or size while it is connected (because the
change would make the connection invalid).
The NodeBuilder Code Wizard generates code that contains a framework for
supporting changeable-type network variables; see
Using a Changeable-Type
Network Variable
in the
NodeBuilder User’s Guide
for details.
The following details all that is required to create a changeable-type network
variable without the use of the NodeBuilder Code Wizard, followed by a detailed
discussion of the requirements that the application must meet to support the
changeable-type network variables. The section completes with a commented
source code example.
To create a changeable-type network variable, follow these steps:
1
Implement the network variable with the changeable_type keyword.
This keyword results in information being provided in the device
interface description. This information specifies that the variable’s
implementation permits the type of the network variable to be changed
by a network tool. You must declare an initial type for the network
variable, and the size of the initial type must be equal to the largest
network variable size that your application supports.
For example, the following declaration declares a changeable-type output
network variable, with an initial type of SNVT_volt_f. This type is a 4-
byte floating-point value, so this network variable can support changes to
any network variable type of 4 or fewer bytes.
network output changeable_type SNVT_volt_f nvoValue;
2
Set the changeable-interface bit in the program ID for the device
template. You can set this bit by setting Has Changeable Interface in the
standard program ID calculator when you create the device template, as
described in the
NodeBuilder User’s Guide
.
3 Implement
a
SCPTnvType configuration property that applies to the
changeable-type network variable. See Chapter 4,
Properties to Configure Device Behavior
, on page 83, for more
information about configuration properties. This configuration property
is used by network tools to notify your application of changes to the
network variable type.
Your application requires notification of changes to this configuration
property. You can provide this notification by declaring the configuration
property with the reset_required or object_disabled modifier and checking
the SCPTnvType value in the director function, or you can implement