Validating a type change, If it is valid, the – Echelon Neuron C User Manual

Page 84

Advertising
background image

72

How Devices Communicate Using Network Variables

Validating a Type Change

There are several ways that your application can determine if it supports a

particular SCPTnvType value. It can look for specific types, as specified by the
type_program_ID, type_scope, and type_index fields. Alternatively, it can look

for specific type categories, as defined by the type_category and type_length

fields.

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. The

type_program_ID, type_scope, and type_index values uniquely identify a type to
your application as well as to any network tools that need to determine the

current type, or modify the type, of the network variable to which the property

applies. Your application can ignore these values if the remaining fields in the
SCPTnvType structure provide sufficient information for the application.
The type_category enumeration is defined in the <snvt_nvt.h> include file as

follows:

typedef enum nv_type_category_t {

/* 0 */ NVT_CAT_INITIAL = 0, // Initial (default)

type

/* 1 */ NVT_CAT_SIGNED_CHAR,

// Signed Char

/* 2 */ NVT_CAT_UNSIGNED_CHAR, // Unsigned Char

/* 3 */ NVT_CAT_SIGNED_SHORT,

// 8-bit Signed Short

/* 4 */ NVT_CAT_UNSIGNED_SHORT, // 8-bit Unsigned Short

/* 5 */ NVT_CAT_SIGNED_LONG,

// 16-bit Signed Long

/* 6 */ NVT_CAT_UNSIGNED_LONG, // 16-bit Unsigned Long

/* 7 */ NVT_CAT_ENUM,

// Enumeration

/* 8 */ NVT_CAT_ARRAY,

// Array

/* 9 */ NVT_CAT_STRUCT,

// Structure

/* 10 */ NVT_CAT_UNION,

// Union

/* 11 */ NVT_CAT_BITFIELD, // Bitfield

/* 12 */ NVT_CAT_FLOAT,

// 32-bit Floating Point

/* 13 */ NVT_CAT_SIGNED_QUAD,

// 32-bit Signed Quad

/* 14 */ NVT_CAT_REFERENCE,

// Reference

/* -1 */ NVT_CAT_NUL = -1 // Invalid Value

} nv_type_category_t;

This enumeration describes the type, stating whether it is a signed short, or

floating-point, or structure, for example, but not providing information about
structure or union fields or other similar details. The type_length field is

necessary to provide the number of bytes of a structure or union type, though it is

set for all types. To support all scalar types, test for a type_category value
between NVT_CAT_SIGNED_CHAR and NVT_UNSIGNED_LONG, plus

NVT_CAT_SIGNED_QUAD. To also support floating point types, also test for a

type_category value of NVT_FLOAT.

The SCPTnvType configuration property can be shared between multiple

changeable-type network variables. In this case, the application must make sure
to process all network variables from the property’s application set —

SCTPnvType applies to all these network variables, and so does the type change

request. The type change can only be accepted if all related network variables can
perform the required change.

Advertising