Discussion:
How Do I coummunicat with a VI in a Sub panel
(too old to reply)
Jarrod S.
2006-03-27 19:10:09 UTC
Permalink
Hi Dale,
For a newbie you're already using some advanced features, such as event-based designs, subpanels, VI Server, so congrats!
You can indeed trigger an event case in your subpanel from your main VI programmatically. Right now, the only concept I've proven is a Value Change event, but there may well be others. For now, though, I'll walk you through firing a Value Change event registered in the VI in the subpanel from the main VI programmatically, and I'll discuss some ways of making dynamic VI calls easier than using VI methods to set and get control values and run the VI.
First of all, let's assume you have a VI in a subpanel with a Value Change event registered for a control called "Event Fired!". You can programmatically fire Value Change events using the Value (Signaling) property node for that control. The problem here is that we need a reference to that control to wire into a property node from our main VI hosting the subpanel.
To find that reference, we can first get a reference to all the front panel controls of the subVI by wiring its VI reference (which we have for the subpanel) into a property node and selecting the property called Front Panel. This outputs a reference to the VI's front panel which we can then wire into another property node to get an array of all control references using the Controls[ ] property. Finally, wire this array of controls into a While Loop and cycle through them checking the property node Label >> Text for each reference to check its label against the label of the control we want ("Event Fired!"). Once we have that specific control reference, we can wire it into a property node and select the Value (Signaling) property to change its value and fire the Value Changed event.
Obviously, the subVI needs to be running at this time to process the Value Changed event. The best (easiest) way to run a VI dynamically is by using a Call by Reference Node. This node is similar to an invoke node, but it allows access to the VI's inputs and outputs through its connector pane and it runs the VI. To use the Call by Reference Node, however, you need to specify the VI Type Specifier Refnum input on Open VI Reference. This will tell the Call by Reference Node what type of connector pane the VI being called has. If this is confusing, don't worry: I've attached an example below that should make this all much clearer.
Just open the VI called VI with subpanel.vi in the zip file below and examine its block diagram. It has documentation, instructions on running it, etc. Let me know if you have any questions, suggestions, comments, or whatever. Hope this helps!


subpanel_example.zip:
http://forums.ni.com/attachments/ni/170/176053/1/subpanel_example.zip
Matt_S.
2006-09-05 22:10:09 UTC
Permalink
Could you possibly post a small section of your code highlighting this problem?

Regards,
Matt S.
Anderomeda
2006-09-06 07:40:07 UTC
Permalink
Thanks, the problem has been solved and it was due to not opening the front panel of that SubVI. As I was first registering the event and then loading the front panel of the SubVI in the SubPanel.
There are two conditions which are to be followed before registering events related to GUI of some other VI. One is that its Front Panel should be opened and second is that this other VI should be running. So now I first loaded its front panel in subPanel and then brought it in running mode using RunVI method of VI and then registered its events.
Loading...