Choosing the data type – Echelon FTXL User Manual

Page 38

Advertising
background image

26

Creating a Model File

Example: The following declaration defines an input network variable of type

“SNVT_type” with the name “nviAmpere”.

network input SNVT_amp nviAmpere;

You define a simple output network variable using the same syntax, but with the

output modifier:
network output

type

name

;

Example: The following declaration defines an output network variable of type

“SNVT_type” with the name “nvoAmpere”.

network output SNVT_amp nvoAmpere;

By convention, input network variable names have an

nvi

prefix and output

network variables have an

nvo

prefix.

See

Network Variable Syntax

on page 132 for the full network variable

declaration syntax.

The LonTalk Interface Developer utility reads the network variable declarations

in the model file to generate device-specific code. For the example of the

nviAmpere

and

nvoAmpere

pair of network variables above, the utility generates

a standard ANSI C type definition for the

SNVT_amp

network variable type and

implements two global C-language variables:

typedef ncsLong SNVT_amp;


volatile SNVT_amp nviAmpere;

SNVT_amp nvoAmpere;

The ncsLong data type defines the host equivalent of a Neuron C signed long

variable. This type is defined in the LonPlatform.h file.
Your FTXL application can simply read the

nviAmpere

global C variable to

retrieve the most recently received value from that input network variable.

Likewise, your application can write the result of a calculation to the

nvoAmpere

global C variable, and call the appropriate FTXL LonTalk API function to
propagate the network variable to the L

ON

W

ORKS

network.

Choosing the Data Type

Many functional profiles define the exact type of each member network variable.

The

SNVT_amp

type used in the previous section is such a type. Using a

different network variable type within a functional profile that requires this

network variable type renders the implementation of the profile not valid.
Other profiles are generic profiles that allow various network variable types to
implement a member. The

SFPTopenLoopSensor

functional block (described in

the

Defining a Functional Block

on page 27) is an example for such a generic

functional profile. This profile defines the

nvoValue

member to be of type

SNVT_xxx

, which means “any standard network variable type.”

Implementing a generic profile allows you to choose the standard network
variable type from a range of allowed types when you create the model file.
For added flexibility, if the specific functional profile allows it, your application

can implement changeable-type network variables. A

changeable-type network

variable

is network variable that is initially declared with a distinct default type

Advertising