In C or C++, an Enum is used to define a list of labels that are used in place of integral values. A simple example for a variable called TransmissionState would be Park = 1, Reverse = 2, Neutral = 3, Drive = 4, and Low = 5. Similarly you can define Enums and Enum sets in MxVDev. In this example, TransmissionState is the Enum set, Park is an Enum label, and 1 is its value.
When you define Enums for a Signal, you will see the label in MxVDev instead of just seeing the numeric value. Enum labels are presented in TestCases, in the Status Bar across the bottom of the MxVDev main window, in the View Details form, and in other places.
Enum sets are stored in a file named <project name>.mxenum. This file is shared by MxVDev and MxTransIt. By default, this file is in the Project Folder. You can change the location in the Project Settings.
There are two steps to associate Enums with a Signal:
To define an Enum Set in MxVDev, select the Enum Master List button in the Signal Dictionary. In MxTransIt, select Tools->Enum Sets from the main menu. To add a new Enum Set: 1.Click the Add Set button. 2.Use the Enum Set text box to enter the name of your choice. 3.Click the Apply button to change the name. To add a new Enum to an Enum Set: 1.Select the Set in the Master List. 2.Click the Add Enum button. 3.Use the Enum Name text box to enter the name of your choice. 4.Enter the value in the Value box. Values must be unique within the set. 5.Click the Apply button to change the name and set the value. Add Name and Value pairs for the Enums that you want to define. For example you can add FALSE/0, TRUE/-1. Once the Enum Labels are defined they can be associated with numeric signals. Please note the following: •Enum Set names are case sensitive. Enum labels are not case sensitive. •The name of an Enum is its key in the Signal Dictionary, so ensure it is unique. •Enum values must be an integer and can be negative •When a CAN dbc file is imported, all the Enum values associated with the message fields in the imported messages are also imported. |
You can associate an Enum Set with discrete numeric or event Signals. For example, a binary signal which can take values of zero and one could have Enum Labels of TRUE and FALSE associated with it. 1.In the Signal Dictionary, double-click a numeric or event Signal to edit the signal configuration. 2.Click the Enumeration List drop-down list. You are presented with a list of Enum Sets. 3.Select the Enum Set. (Some of the Enums in the set may not be visible.) 4.Be sure the Init, Min, and Max values are appropriate for the Enum Set. To modify an Enum set or the Enum Master list, click
|
•An Enumeration Set enumerates the entities in a set (of states, outcomes, conditions, etc.). Each entity is called an Enum.
•An Enum has a Label string.
•An Enum has a Value. (The Value can be positive or negative Integer.)
•An Enum must to be part of an Enumeration Set.
•An Enumeration Set cannot have more than one Enum with the same Value.
•An Enumeration Set cannot have more than one Enum with the same Label.
Labels are useful because:
•They make sense to the human. - We prefer to have TestCases use labels for this reason.
Values are useful because:
•They imply an order (which may be useful if the set is ordered).
•They can be plotted graphically (although this is useful only if the Values are close together).
•They can have a one to one correspondence to the enumeration in 'C' code.
•Since an Enum set is a set of discrete values, it should be used with discrete or event Signals.
•Enums may be associated with stimulus or response Signals.
•A discrete MxSuite Signal can have zero or one Enumeration Sets associated with it.
•Several Signals can be associated with the same Enumeration Set.
•An Enum Set must have a Name. Enum Labels are prefixed by the name of the Enumeration Set as a means to ensure all Enum Labels are unique.
•When a DBC file is parsed by a CAN Transform, all Enums in the DBC file are loaded into the mxenum file.
•When importing Enums from a DBC file or MxTransIt, by default the Enumeration Set is named the same as the Signal Name.
•By default Enumeration Sets and Enums have GUIDs. This is to facilitate linking after renaming Signals, Enumeration Sets, and Enums.
•When an Enum is used in a TestCase, the value of the Enum is stored in the TestCase so it will be available if the Enum set is deleted or cannot be found. (For example, if the TestCase is copied to another project.)
•Enum values stored in a TestCase are updated when the TestCase is loaded.
Project Settings (location of the .mxenum file)
Editing Ports (Enums in MxTransIt)
Guided Harnessing (Using Enums with an MxVMC)