Declaration of a data type with named values (enums) in ST
Neuron Power Engineer offers the enum-editor as an alternative to display and edit data types with named values (also identified as →enums). In this case, you do not need to know the following syntax.
Syntax |
---|
|
Meaning | |
---|---|
Declaration of one or more →data types with named values (also identified as →enums), This declaration is possible within the declaration of a user-defined data type ( Use the optional →initial value to assign a value to the data type. This value might be a constant expression as well, such as a named element (see example
It is possible to use a data type with named values in all places where it is possible to use the base type. Example: It is possible to use the data type |
Moreover, Neuron Power Engineer allows you to specify additional data for the declaration. See "Defining description, comment, JSON string or type for variables or data types" for details.
Example: declaration |
---|
|
Using the named values
Use the following syntax in order to uniquely address a named value within an editor (e.g. within an ST-editor): name_1#name_e1
(with name_1
being the name of the enum and name_e1
being the name of the element) – example: TrafficLight#Red
Neuron recommends to address named values always with the unique name. This will help to avoid later conflicts when modifying the application – because e.g. a named value is also used in a newly installed library.
However, if Neuron Power Engineer is able to derive the named value uniquely from the context, it is possible to only enter the named value. See examples Yellow
and Green
in the following example (for this example, a declaration as specified under "Declaration of a data type with named values (enums) in ST" is required).
Example: usage |
---|
|
Depending on your Neuron Power Engineer configuration (i.e., the start option lc3.expensive.enum.resolving.enable
), you might be able to specify a named value without a unique name – even though the context is not known. However, the named value must be unique. Please mind that the performance might decrease when saving, importing and opening objects and/or projects. If you are interested in changing the current configuration, contact your system integrator and clarify the possible effects of this start option.