Creating and modifying an enumerated nv or cp type – Echelon IzoT Resource Editos User Manual

Page 40

Advertising
background image

32

Creating and Modifying Resources

Creating and Modifying a Structure or Union NV or CP Type

You can create network variable and configuration property types with multiple fields,
each with their own data type, by defining a type as a structure or union. The fields in a
structure are separate, whereas the fields in a union may overlap. For example, if a
structure type contained an UNSIGNED_SHORT and an UNSIGNED_LONG field, the
total size is 24 bits (8 bits for the short, and 16 bits for the long). If a union type
contained these same two fields, the total size is 16 bits; the short shares the first 8 bits
of the long. Unions and structures can both contain any data types, including other
unions and structures, with the exception of bitfields, which can be used in structures,
but not unions.

Note: While the display of the structure type bears a resemblance to Neuron C code, it is
not in Neuron C syntax, and cannot be cut and pasted directly into a Neuron C file. To
implement a variable using a network variable or configuration property type in Neuron
C version 2 or later, simply declare this variable using the type name defined in the
resource file. For example, SNVT_count MyCount; defines a variable, not a network
variable, of type SNVT_count.

To create a union or structure type, follow these steps:

1. Create a new type as described in Creating and Modifying a Network Variable or

Configuration Property Type.

2. Set Data Type to UNION or STRUCTURE. The left pane displays typedef

struct { }

or typedef union { }.

3. Right-click the typedef struct or typedef union statement, and then click

Insert Field on the shortcut menu. Enter attributes, strings, limits, and scales for
the new field as described in Creating and Modifying a Network Variable or
Configuration Property Type
)
. Name must be a valid name for an aggregate member
in the Neuron C language, but is otherwise not limited (i.e. it does not have to start
with “UNVT” or “UCPT” for fields). Each field contains its own data type, strings,
limits, and scales. Repeat this step for each field in the structure.

4. Click OK. The new type appears in the Network Variable Types or

Configuration Property Types folder.

To make changes to a field, click the field in the left pane and modify the field definition.

To remove a field, right-click the field in the left pane, and then click Remove Field on
the shortcut menu.

Creating and Modifying an Enumerated NV or CP Type

You can assign an enumerated type to a network variable type, configuration property
type, or a field in a structure or union. To create an enumerated type, follow these steps:

1. If the enumeration type you will use does not already exist, create it as described in

Creating and Modifying an Enumeration Type.

2. Create a new type as described in Creating and Modifying a Network Variable or

Configuration Property Type. In step 3, set Data Type to enumeration. Enum
Information
appears in the dialog as shown in the following figure:

Advertising