to close
You are actually already using these whether you realize it or not - you’ll be able to recognize them in some of the standard code once we are through.
A Type Def is a custom control that has all the instances linked so that one can change the original and immediately have the changes reflected throughout the project. (NI Documentation here)
For this example, we will be creating and modifying a Type Def for a state machine
Just a formality, but we will open several devices in Begin.vi
Due to the constructs of this data structure, it can be implemented in Periodic Tasks or in Teleop, because our state machine tutorial already shows a similar one in Periodic Tasks.vi, we will implement this one in Teleop.
To start, create a enum control on the front panel, and right click on it. From the menu, select “Make Type Def.”
Right click again and select “Open Type Def”
Once the Type Def is open, we can set the items of the enum. For this example the Up, Down, and Initialize, have been entered.
Back in Teleop.vi, we will use a feedback node to keep track of the current state.
Here we realize that a mistake was made - we want to have a state for getting the user input.
If we right click on the constant that was made from our original control, we can reopen the typedef.
And we just add the get user input case to the values,
We also need to tell LabVIEW to apply the changes
Back in teleop, notice that both instances of the Type Def have updated.
And we finish out (most of this is implemented in our State Machines tutorial, so for details on that, click here)
While this is a short example, the power of the Type Def grows exponentially. This last year our team had to add a case to a state machine that already had eleven (or so) cases, in the past, that would have meant deleting all the next case constants, modifying the case structure to take the new one, . . . Fortunately we had implemented a Type Def for our possible modes, and adding that case became as simple as the above example.
Google Form to request details