Processing a type change – Echelon Neuron C User Manual
Page 85

Neuron C Programmer’s Guide
73
If one or more type-inheriting configuration properties apply to changing
configuration network variables (CPNVs), these type-inheriting CPNVs also
change their type at the same time. If this type-inheriting CPNV is shared among
multiple network variables, all related network variables must change to the new
type. Sharing a type-inheriting configuration property among both changeable
and non-changeable network variables is not supported.
Processing a Type Change
When the application detects a type change request and recognizes the type
detailed in the related SCPTnvType property as a supported type, and also
confirms that all affected network variables can perform the change, the
application performs the type change.
To perform a type change that does not change the size of the network variable,
your application need do nothing but memorize the current type details. A
different part of the application, the type-independent implementation of your
application’s algorithm, queries these details as and when required, and
processes the network variable data accordingly. The processing required in the
type-independent implementation of the application depends on the range of
types supported by your application. For example, if your application only
supports changing between different floating-point types, no additional
processing might be required. If your application supports changing between
different scalar types, it might require the use of scaling factors and network
variable type length to convert the raw network variable value to a scaled value.
For example, the SNVT_lev_cont type is an unsigned short value that represents
percentages from 0 to 100 percent, with a resolution of 0.5%. The actual data
values (also called
raw
values) are in the variable range from 0 to 200. The
scaling factors for SNVT_lev_cont are defined as a=5, b= -1, c=0. To convert from
raw data to scaled fixed-point data, use the following formula:
(
)
(
)
c
raw
a
scaled
b
+
=
*
10
*
Your application can convert the raw data of a changeable type input network
variable, internally, to an actual scaled value for use as a floating-point data
item, for example, using the above formula. To convert the data back to a raw
value for an output network variable, use the following inverted scaling formula:
c
a
scaled
raw
b
−
⎟
⎠
⎞
⎜
⎝
⎛
=
10
*
You can use cast operations and pointer manipulations to handle type changes.
See
on page 75 for an example.
If a network variable type or size is changed and that network variable is a
member of an inheriting configuration property’s application set, and that
property is implemented as a configuration network variable, then the
application must process the same type or length changes that were performed on
the network variable for the configuration network variable.
However, if the configuration property is implemented within a configuration file,
no change to the configuration file is required. The configuration file states the
configuration property’s initial and maximum size (in the CP documentation-
string
length
field), and LNS derives the current and actual type for type-
inheriting CPs from the associated network variable.