LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create a Callback VI from an existing VI

Solved!
Go to solution

The Callback VI documentation has a note stating:

 You can use an existing VI as a callback VI as long as the connector pane of the VI you intend to use matches the connector pane of the event data. The callback VI must be reentrant, and the reference to the callback VI must be strictly typed.

 

I believe I have created a VI that satisfies most of these conditions.

However, the callback VI needs to be connected to the the Register Event Callback via a VI Ref terminal.

How do I create this VI Ref line in my Callback VI so it can be connected to the Register Event Callback?Callback VI.jpg

0 Kudos
Message 1 of 5
(2,317 Views)
Solution
Accepted by topic author JohnW242424

Add a static vi reference on the block diagram from the application control palette. Double left click it and choose your vi. You can thin right click to to choose strictly typed. 

Is this what you were looking for?

Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 2 of 5
(2,296 Views)

Thanks.

Yeah, that does create the the Callback VI with a ref terminal. But that is the only terminal.

I guess I assumed I could implement my existing VI as a callback with all it's existing pins and simply add a reference terminal. Clearly that is not the case.

I will need to go back to investigating how to get data in and out of the callback VI using a queue or some other mechanism, which was my real issue. The LabVIEW implementation for handling callbacks is very clunky and limited.

0 Kudos
Message 3 of 5
(2,252 Views)

Maybe feed that strict vi reference into a call by reference node located in the application control palette which will give you access to all of the inputs and outputs?

Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 4 of 5
(2,239 Views)

Nah, that didn't work. It overrides all the parameters passed in when the callback is called.

But, I figured out how to do it. 

You need to create references to the items in the main VI you want to use and pass the references in as a cluster to the User Parameter terminal.

Then, in the callback VI, unbundle the references and connect them to property nodes of the main VI items.

PassRefsToCallback.jpg

0 Kudos
Message 5 of 5
(2,225 Views)