Showing results for 
Search instead for 
Did you mean: 

using event structure in LabVIEW classes

Go to solution



I am new in using LabVIEW classes, so don't know that much how I can use them. 


In my main program I have clusters with five elements in each. The elements are two-state controls and in some clusters there are tri-state controls. The user will press the buttons (controls), and different things will happen. In my first program were I weren't using the classes, I had an event structure and the controls were event cases in the structure. 


Is it possible somehow to use an event case in one of the methods that is created in the classes, so as say it is not in the main program?


I attached two pictures: I wanted to have an event structure in servoTouchEvent (in left.tri.lvclass) which is a child. 


Let me know if my explanation is unclear.


Grateful for some help!

Download All
0 Kudos
Message 1 of 5

Had you taken the folder with your Project, compressed it (using right-click Send To, Compressed File), and attached the resulting .ZIP folder to let us "see" your Project and Classes, we could (probably) answer your question and even suggest how to do it.


Bob Schor

0 Kudos
Message 2 of 5
Accepted by topic author 50616d656c61


Yes, you can have an event structure in a SubVI rather in your main top-level UI VI. The trick is to use the "Register for Events" function and passing in the reference(s) to the control(s) you want to have the event structure trigger for. The refnum output from that function is input in the dynamic event terminal of the event structure that could live in a SubVI. You can add event cases where you'll see those control events as dynamic events that you can then do something with. These snippets shows all code in a single diagram, but the stuff in the diagram disable structure could easily made into a SubVI:

Events in SubVI Test Bench Buttons.png Events in SubVI Test Bench Stop.png


All this can be done without classes. What classes will buy you include the ability to encapsulate your VIs and also perform different code based on what object on the parent-child class hierarchy is on a wire. If your code behavior is different between 2-state and 3-state controls (which I'm not sure what 3-state controls you're referring to), you could take advantage of classes.

Feel free. Contact me for anything more,

You too can be LabVIEW Awesome!
Message 3 of 5

Hi Bob, 


Thank you for the advice. I will think of it next time, I agree that it will be easier but this time I didn't do it because it's a bit messy in my folder where I have some old subVI that I don't use anymore after I decided to change it to classes. So I thought, maybe it will be confusing more than helping. 



0 Kudos
Message 4 of 5

Thank you, your code helped a lot. Now I can choose the different controls in the event structure, as I wanted.


As to the three-state control; I did my own control which has numeric values, so 0 means the button is dark, 1 the button is red and 2 means that it is green. 



0 Kudos
Message 5 of 5