LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to place event callback components and "main-VI" components in the same Front Panel?

What I'm trying to accomplish:
Place a .NET component, which generates events, and other standard LabVIEW components in the same Front Panel. The standard LabVIEW components should be updated when events are being generated in the .NET component.
How I tried to solve it:
 
Problem:
The event callback code must reside in a separate event callback VI. In order to "pass the event up" to the main VI I tried to use a global variable. The interrupt does occur:
 
but I was hoping that the string indicator would be updated when the event occurred, but it wasn't.
 
Questions:
What's the best way to solve what I try to accomplish? If I want to solve the problem on the picture above, how would I do it (it may not be the best solution, but I'm still curious what's wrong)? Please feel free to be over-explicit when replying as I am novice LabVIEW programmer. Thanks in advance for any help.
0 Kudos
Message 1 of 10
(3,396 Views)
Create a reference to your string (right click String >> Create >> Reference). Now wire that reference into the User Parameter input of the Callback Node. Recreate your Callback VI. Now take the string data in the callback VI and wire it into the Value property node for your string coming from the reference you supplied. Voila... 🙂
Jarrod S.
National Instruments
Message 2 of 10
(3,392 Views)
Many thanks, it works great!
0 Kudos
Message 3 of 10
(3,353 Views)
If I have two String indicators I would like to update in the event code, what do I do then? There is only one input for a User Parameter. I thought I could just use a reference to a cluster, but that obviously didn't work.
0 Kudos
Message 4 of 10
(3,337 Views)
You can pass in a cluster with two references, or an array of references. The array option would work best, because the solution would scale to any number of string controls without changing the callback code. 
Jarrod S.
National Instruments
0 Kudos
Message 5 of 10
(3,330 Views)
How do I create arrays or clusters of references? Usually I create arrays and cluster by dragging controls into them in the Front Panel, but when I create a reference it does not appear in the Front Panel so I cannot drag it.
0 Kudos
Message 6 of 10
(3,327 Views)
You can use the Build Array function in the Array functions palette to build an array of any data type on the block diagram. Here's an example:


Message Edited by Jarrod S. on 10-08-2007 09:23 AM

Jarrod S.
National Instruments
0 Kudos
Message 7 of 10
(3,322 Views)
I want to use a cluster instead of an array and I guess the corresponding function to use would be the Bundle (instead of Build Array). However, the Bundle function takes the cluster type as an input and I don't know how to create it.
0 Kudos
Message 8 of 10
(3,315 Views)

There are two bundle functions for creating clusters. The function simply called Bundle operates almost exactly like the Build Array function I showed. The type of the output cluster depends on whatever you wire in as inputs. You don't have to supply a specific type parameter.

The function called Bundle by Name takes in a specific type of cluster in the top input and allows you to fill in the values of that specific type of cluster. To create the specific type of cluster you want, you need to create a cluster of string references. Here's how to do that:

  1. Go to the Front panel and drop down an empty cluster shell.
  2. Go to the Refnum palette and drop down a Generic Control Refnum. Now here's a cool trick to turn that generic refnum into a string-specific refnum (a so-called strictly-typed refnum). Grab a string from the controls palette and drag it into the Generic Control Refnum. Once you drop it, you'll see the refnum change its icon to display a string picture.
  3. Make copies of this string refnum (as many as you need) and add it to the cluster shell.

Now, if you're making specific types of clusters to work with, now is the absolute best time to learn about typedefs if you haven't already. It will save you hours and hours (if not days) of development time in the future. Trust me! 🙂

 
Jarrod S.
National Instruments
0 Kudos
Message 9 of 10
(3,312 Views)
Again, thanks for your help, it works great now!
0 Kudos
Message 10 of 10
(3,294 Views)