beautypg.com

Using types – Echelon FTXL User Manual

Page 76

background image

64

Using the LonTalk Interface Developer Utility

Using Types

The LonTalk Interface Developer utility produces type definitions for the network

variables and configuration properties in your model file. For maximum
portability, all types defined by the utility are based on a small set of host-side

equivalents to the built-in Neuron C types. For example, the LonPlatform.h file

contains a type definition for a Neuron C signed integer equivalent type called
ncsInt. This type must be the equivalent of a Neuron C signed integer, a signed

8-bit scalar. For most target platforms, the ncsInt type is defined as signed char

type.

A network variable declared by a Neuron C built-in type does not require a host-

side type definition in the LonNvTypes.h file, but is instead declared with its
respective host-side Neuron C equivalent type as declared in LonPlatform.h.
Important: Network variables that use ordinary C types, such as int or long, are

not interoperable. For interoperability, network variables must use types defined
within the device resource files. These network variable types include standard

network variable types (SNVTs) and user-defined network variable types

(UNVTs). You can use the Resource Editor tool to define your own UNVT.

Example:
A model file contains the following declarations:

network input int

nviInteger;

network output SNVT_count

nvoCount;

network output SNVT_switch

nvoSwitch;

• The nviInteger declaration uses a built-in Neuron-C type, so the LonTalk

Interface Developer utility uses the ncsInt type defined in LonPlatform.h.

• The nvoCount declaration uses a type that is not a built-in Neuron C

type. The utility produces the following type definition:

typedef ncuLong SNVT_count;

The ncuLong type represents the host-side equivalent of a Neuron C
unsigned long, a 16-bit unsigned scalar. It is defined in LonPlatform.h,

and typically maps to the LonWord type. LonWord is a platform-

independent definition of a 16-bit scalar in big-endian notation:

typedef struct {

LonByte msb;

LonByte lsb;

} LonWord;


To use this platform-independent type for numeric operations, you can

use the optional LON_GET_UNSIGNED_WORD or

LON_SET_UNSIGNED_WORD macros. Similar macros are provided for
signed words (16 bit), and for signed and unsigned 32-bit scalars

(DOUBLE).


Important: If a network variable or configuration property is defined

with an initializer in your device’s model file, and if you change the

default definition of multibyte scalars (such as the ncuLong type), you
must modify the initializer generated by the LonTalk Interface Developer

utility if the type is a multibyte scalar type.