Validating a type change – Echelon LonTal Stack User Manual

Page 133

Advertising
background image

LonTalk Stack Developer’s Guide

121

Validating a Type Change

The SCPTnvType configuration property is defined by the following structure:

typedef LON_STRUCT_BEGIN(SCPTnvType) {
ncuInt type_program_ID[8];
ncuInt type_scope;
ncuLong type_index;
ncsInt type_category;
ncuInt type_length;
ncsLong scaling_factor_a;
ncsLong scaling_factor_b;
ncsLong scaling_factor_c;
} LON_STRUCT_END(SCPTnvType);

When validating a change to a network variable, an application can check five of
the fields in the SCPTnvType configuration property:

• The program ID template of the resource file that contains the network

variable type definition (type_program_ID[8])

• The scope of the resource file that contains the network variable type

definition (type_scope)

• The index within the specified resource file of the network variable type

definition (type_index)

• The category of the network variable type (type_category)
• The length of the network variable type (type_length)

The type_program_ID and type_scope values specify a program ID template
and a resource scope that together uniquely identify a resource file set. The

type_index value identifies the network variable type within that resource file

set. If the type_scope value is 0, the type_index value is a SNVT index. For
example, checking the type_scope and type_program_ID fields lets you accept

only types that you created.

The type_category enumeration is defined in the <snvt_nvt.h> include file as:

typedef enum nv_type_category_t {

NVT_CAT_INITIAL = 0,

// Initial (default) type

NVT_CAT_SIGNED_CHAR,

// Signed Char

NVT_CAT_UNSIGNED_CHAR,

// Unsigned Char

NVT_CAT_SIGNED_SHORT,

// 8-bit Signed Short

NVT_CAT_UNSIGNED_SHORT,

// 8-bit Unsigned Short

NVT_CAT_SIGNED_LONG,

// 16-bit Signed Long

NVT_CAT_UNSIGNED_LONG,

// 16-bit Unsigned Long

NVT_CAT_ENUM,

// Enumeration

NVT_CAT_ARRAY,

// Array

NVT_CAT_STRUCT,

// Structure

NVT_CAT_UNION,

// Union

NVT_CAT_BITFIELD,

// Bitfield

NVT_CAT_FLOAT,

// 32-bit Floating Point

NVT_CAT_SIGNED_QUAD,

// 32-bit Signed Quad

NVT_CAT_REFERENCE,

// Reference

NVT_CAT_NUL = -1

// Invalid Value

} nv_type_category_t;

Advertising