LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add an item to all state machine constants

I have a state machine using an enum for the state indicator.  In the current state, the next state is indicated by an enum constant.  If I want to add a state, how can I update all of the constants?  Here is the problem.  If I add (or delete) an item in the selector of the case structure, it is red because the enum constants do not have that value in them.  Conversely, if I add an item to one of the constants I can "Add case for every value" and add it to the seletor, but then I have to manually add that item to each of the other constants.  Also, the way I usually create the constants is to pop-up on the exit tunnel for the enum in the case structure and "Create constant".  Unfortunately, that tunnel retains the choices of the old enum and the new choice must be manually added.  Is there any way around this?  I would like a method that allows me to add or delete choices at will and have all of the constants automatically update to match.

Roy
0 Kudos
Message 1 of 4
(2,845 Views)

Well LabVIEW has just what you need in the "type def"! The next time you create a enum, right click on it, select create a control go to the front panel, right click on the control and select "Advanced" and then "Customize" to enter the control editor (if you have selected in your front panel "tools", "options", "front panel", "open the control editor with a double click", you can ust double click on the control to enter the control editor). In the control editor you will see a toolbar pull down with the "Control" option. If you pull it down and change to "Type Def" you can modify the control and all copies of it will now get automatically updated, including constants created from the type definition. The strict type def controls the look of the control as well, so it is most often used to make sure that operator interface instances of a control look the same. When you save this new type def it should ask you whether to update all instances, which will update the original control , you will have to go back and make a constant from the new control type to replace that original one, but now every copy made from that one will update when you update the type definition, and you can do that from the constant on the diagram by right clicking and selecting "open type def".

 

 

P.M.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



Message 2 of 4
(2,841 Views)
DUH SMACK! Thanks, LV_Pro.  I think I have done this in the past, and forgot.  As I recall, I had to keep the control, but just made it invisible on the front panel.  Right?
 
Roy
0 Kudos
Message 3 of 4
(2,833 Views)
Nope, the creation of the control is just to give you a means to get the original constant's info into the control editor. Once you have made and saved the type def (and "updated the original control)  you can create the constant from it and delete the control. Now copies of the constant will have the attributes of the type def and when you want to add or subtract one of the entries right click on any of them and select "Open Type Def". After you make changes, you can "Apply Changes" which will update all the controls, indicators or constants that "Auto update from type def". Mike Porter showed me type defs about 9 years ago and I use them continuously.

P.M.


Time flies like an arrow, fruit flies like a banana.
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



Message 4 of 4
(2,817 Views)