Rejecting a type change, Changeable-type example, Ge 75) – Echelon Neuron C User Manual

Page 87: Ge 75. if the ch

Advertising
background image

Neuron C Programmer’s Guide

75

The get_nv_length_override( ) function returns the current length of the network

variable with the index specified in the argument, or 0xFF to indicate that the
type has not been changed and the network variable’s initial length is still valid.
The system image extension method only works with version 14 firmware, or

newer. To support development of applications that use the best possible method
depending on the target hardware, you can use conditional compilation to

support both methods. This is, for example, used by the NodeBuilder Code
Wizard to allow for the LTM-10A device to exercise and implement support for

changeable-type network variables. The changeable-type example, later in this

chapter, implements such a strategy.

Whenever possible, the system image extension technique should be used,

because of its more robust implementation. However, a compiler directive is

provided to permit the use of the system_image_extensions nv_length_override
directive with targets that do not support system extensions. You can turn the

NLD#477 linker error, which would normally occur in such a condition, into a

linker warning by using the following directive:

#pragma unknown_system_image_extension_isa_warning

Rejecting a Type Change

If a network tool attempts to change the type of a changeable-type network

variable to a type that is not supported by the application, your application must
do the following:

• Report the error within a maximum of 30 seconds from the receipt of the

type change request. To report the error, the application should signal an

invalid_request through the Node Object functional block and optionally

disable the related functional block. If the application does not include a
Node Object functional block, the application can set an application-

specific error code using the error_log( ) function and take the device

offline (use go_offline( )).

By setting the functional block status, the rest of the functional blocks on
your device can continue to function normally. You can use both methods

to provide a more precise indication of the error to a network integrator.

See Chapter 5,

Using Functional Blocks to Implement a Device Interface

,

on page 101, for more information on using functional blocks.

• Reset the SCPTnvType value to the last known good value.
• Reset all other housekeeping data, if any, so that the last known good

type is re-established.

In the interest of future-proof implementations, the application should be sure to
reject all change requests to unknown types, as shown in the changeable-type

example below.

Changeable-Type Example

The following code sample shows a typical implementation of a changeable-type
network variable. It implements nvoVolt as a changeable-type output network

variable. This example uses utility functions, such as getObjStatus( ),
updateNode_Status( ), and setFblockDisable( ). These utility functions are part

Advertising