Defining Types

Predefined types are available to constraint the type of constants, functions parameters, block ports and signals. However, the user can define its own types.

This task shows you how to:


Before you begin: The workbench used to edit the logic should be opened.

Redefine an Existing Type (Alias)

You can redefine an existing type.

  1. Click New Type and select an element of the logic tree.

    The Type Properties dialog box appears:



  2. Change the type name. If needed, add a comment.



  3. Click Pure.

    The list of all pre-defined types is available. If some user-defined types are defined, they are also available in the list.

    Note: The user-defined types are available only if they are defined in the scope of the new type, that is to say above the new type in the specification tree.

  4. Select one of the types, for example Pure.

  5. Click Ok.

    The Status type appears in the tree.

  6. Scroll over Status in the specification tree to see its signature.



Define a Structured Data Type

You can define a structured data type using structures and tuples.

  • A tuple is an ordered list of elements. The elements are accessed by their position.
  • A structure is a set of labeled elements. There is no significant order in a structure (unlike in tuples), elements being accessed by their names.

  1. Click New Type and select the logic root.

    The Type Properties dialog box appears:



  2. Change the type name. If needed, add a comment.



  3. Click Add Element . This action creates a structure with a child having a default name. The name can be changed by clicking it and editing the field.

  4. Repeat the previous step to add a second element to the structure.

  5. Change the default names as defined below:



  6. To change the type of the structure elements, drop-down the combo-box. Select float64 in the type list:



  7. If needed, add a comment to the elements structure.



  8. Click OK.

    The Polar type appears in the tree.

  9. Scroll over Polar in the specification tree to see its signature.



    Note: In a structure declaration, elements are separated by a ";" and labels are followed by ":" .

  10. Double-click Polar in the specification tree to re-edit it.

  11. Right-click the root and select Redefine as > Tuple. This command converts the existing structure into tuple.



  12. Click OK.

  13. Scroll over Polar in the specification tree to see its signature.



    Note: In a tuple declaration, elements are separated by a "*".

Tip: Structures and tuples can be nested.

Define an Enum Type

You can define an enum type. An enum type lists the authorized values for a given signal.

  1. Click New Type and select the logic representation root.

  2. Select Enum in the Kind combo box.



  3. Change the type name and click to add a member at the enumeration list.



  4. Double-click the default name NewLabel0 to change it.

  5. Click to add other elements.

  6. Click and/or to sort the elements.



    Note: The syntax of the element names must follow the rules of the identifiers (refer to LCM EBNF Grammar).

  7. Click OK.

    The RGB type appears in the tree.