DTaylor Posted March 16, 2017 Report Share Posted March 16, 2017 (edited) I always loved this idea exchange idea to add sum types to LabVIEW: https://forums.ni.com/t5/LabVIEW-Idea-Exchange/New-Enum-Class-Primitive-quot-The-Defined-Enum-quot-with/idi-p/1904525 I was sad to see that it was dismissed as being classes. I think there are differences, and that having these kinds of types in LabVIEW could be nice, so I jank implemented them using XNodes: LV-Define-Tagged-Union.xnode takes an enumeration and a cluster as inputs. If certain enum values have data associated with them, the cluster should contain an element with the appropriate type and the same name as the corresponding enum selection. The output of this node is an enum & variant cluster or "tagged union". This output can be bound to an existing typedef by right-clicking on the node. LV-Construct-Tagged-Union.xnode takes a tagged union created by the define node at the top input and gives you a drop down menu. The input type adapts appropriately. LV-Case-Tagged-Union.xnode goes inside a case structure. It's output type adapts based on the frame it is in. Source code can be found here: https://github.com/erdosmiller/lv-tagged-union I've attached a VI package that will add these XNodes to your palette, along with a package that will install a scripting library that this depends on. I wrote this awhile ago, so I don't remember all the details, but some types like .NET references may not be supported yet. LV-Tagged-Union requires LabVIEW 2015 or later. Let me know what you think! lv_tagged_union-0.0.0.7.vip lv_scripting-0.7.0.6.vip Edited March 16, 2017 by DTaylor 1 Quote Link to comment
infinitenothing Posted March 16, 2017 Report Share Posted March 16, 2017 I'm not sure why the idea exchange mods didn't understand how powerful it is to be able to generate a case structure from a "class". The primary advantage being that you can put terminals,locals, and front panel linked property nodes in a case structure but not directly in a subVI. That can make things easier to debug because, from the front panel or from a terminal, you can "find all.." for those. I feel like they are stuck on OOP as a one size fits all solution. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.