Processing a size change – Echelon LonTal Stack User Manual

Page 135

Advertising
background image

LonTalk Stack Developer’s Guide

123

then the application must process the type changes for both the network variable

and the configuration network variable.

If the network variable is a member of a configuration property’s application set

where the configuration property is shared among multiple network variables,

the application must process the type and length changes for all network
variables involved.
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 network management tools derive the
current and actual type for type-inheriting CPs from the associated network

variable.
Your application must always support the NVT_CAT_INITIAL type category. If
the requested type is of that category, your application must ignore all other

content of the SCPTnvType configuration property and change the related
network variable’s type back to its initial type. The network variable’s initial

type is the type declared in the model file.

Processing a Size Change

If a supported change to the SCPTnvType configuration property results in a
change in the size of a network variable type, your application must provide code

to inform the LonTalk host stack about the current length of the changeable-type

network variable. The current length information must be kept in non-volatile
memory.
The LonTalk API provides a callback handler function, LonGetNvSize(), that
allows you to inform the API of the network variable’s current size. The following

code shows an example implementation for the callback handler function.

unsigned LonGetNvSize(const unsigned index) {

const LidNvDefinition* const nvTable = LonGetNvTable();

unsigned size = LonGetDeclaredNvSize(index);


if (index < LonNvCount &&

nvTable[index].Definition.Flags & LON_NV_CHANGEABLE)
{

const SCPTnvType* pNvType = myGetNvTypeCp(index);

// if the NV uses the initial type, its size is
// the declared size set above

if (pNvType->type_category != NVT_CAT_INITIAL) {

size

=

pNvType->type_length;

}

}
return

size;

}

The example uses a myGetNvTypeCp() function (that you provide) to determine
the type of a network variable, based on your knowledge of the relationships

between the network variables and configuration properties implemented.
If the changeable-type network variable is member of an inheriting configuration
property that is implemented as a configuration property network variable, the

type information must be propagated from the changeable-type network variable

to the type-inheriting configuration property, so that the LonGetNvSize()

Advertising