LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Asynchronous Dynamic Dispatch Subpanel

Solved!
Go to solution

Hi,

 

I have a bit of an issue with using class member VIs in a subpanel.  Take a look at the project I've attached to the VI for an example of what I'm trying to do (in LV 2011).

 

Basically I want to decide based on a user's selection which viewer I will run and launch in a subpanel.  The user can change this during program operation.  I've decided to make the different viewers all members of a class so that I can add new viewers and be sure that all will be compatible.

 

Here's the issue.  If I want to use the run asynchronous VI function, I cannot do this with dynamic dispatch terminals (limitation in LabVIEW).  So I made a launcher that has static dispatch terminals.  I call this launcher using the run asynch function, and then within the launcher I run the specific instances via dynamic dispatch.  This works, and I can verify that the VIs are running by having the VIs open their front panels when they run.  But, I cannot seem to get a reference to this VI that is launched via the launcher to put into the subpanel on my main VI.

 

I have a workaround, which you can see in the other method used to launch VIs in the example.  This selects the class member directly by using the name.  Data is passed to the VI using the set control value method.

 

As I said, I have a workaround to the problem.  But, I'm wondering if there is a better way to do this.  So, if anyone knows how I can launch a VI asynchronously and place its front panel into a subpanel I would love to hear about it.  Thanks LabVIEW gurus.

0 Kudos
Message 1 of 13
(5,112 Views)

Gerry_Ford, 

 

I believe you may have forgotten the attachment. 

 

Do you have specific issues with the workaround? 

Will M.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 13
(5,074 Views)

Hi Will,

 

I'm not sure what happened to the attachment.  I attached a zip file with the project, but for some reason it didn't post.  I won't be able to post the code again until Monday, but I will do that.

 

As far as the workaround goes, no I don't have any specific problem with it.  It just seems that it's not the best way to solve the problem.  I'd be interested in seeing how other people would go about solving the same issue.

0 Kudos
Message 3 of 13
(5,066 Views)

I use static-dispatch "launchers" to called Dynamic-dispatch VIs in this way.  My VIs have message handlers, though, so I just ask them for their reference by message.   

0 Kudos
Message 4 of 13
(5,060 Views)

Here are the files.  It's a zipped project.

 

Drjdpowell, how do you get the reference to the VI?  Do you pass a reference back to the caller through a queue (like the actor framework)?  Do you return it via dynamic events?  Do you have the VI place a reference to itself in a functional global?  This is my main question.  What is the best way to get the reference to the VI that you are calling?

0 Kudos
Message 5 of 13
(5,016 Views)

What if you make all the viewers a subclass of a general viewer instead? Then insert the General viewer in the subpanel through the code, and voila!

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 13
(5,013 Views)

The viewers are subclasses of a general viewer.  The problem arises when you try to launch the specific instance of the child viewer.  It's not possible to use dynamic dispatch with the start asynchronous call function, so you have to create a static dispatch launcher VI.

 

When you start the launcher using the start asynchronous call you get a reference to the launcher, not the VI you actually want to run.  With this reference you will actually place the launcher's front panel in the subpanel on your main VI.  This is, in my case, a blank front panel.  What I need is the reference to the VI that the launcher starts.

 

There are ways to get the reference you want back to the caller...queues, functional globals, dynamic events, etc.  I'm really just looking for some input on what the best way to do this is.

0 Kudos
Message 7 of 13
(4,994 Views)

@Gerry_Ford wrote:

Here are the files.  It's a zipped project.

 

Drjdpowell, how do you get the reference to the VI?  Do you pass a reference back to the caller through a queue (like the actor framework)?  Do you return it via dynamic events?  Do you have the VI place a reference to itself in a functional global?  This is my main question.  What is the best way to get the reference to the VI that you are calling?


I have a Messaging package that I developed which includes Return Addresses on messages, so I can call "Reply" on a "What is your Front Panel ref" message and send the VI reference back to the calling code.**  Usually the calling code just calls a "Query" subVI that sends the message and waits for the reply.   

 

**BTW, an alternate method is to pass the subpanel ref to the VI (at startup or in a message) and have the VI put itself in the subpanel.   

0 Kudos
Message 8 of 13
(4,981 Views)
Solution
Accepted by topic author Gerry_Ford

BTW, the simplest way you can solve your problem is to create a temporary Queue, pass it in to the ACBR call (with the Static VI passing it into the Dynamic one), then have the dynamic VI post its own ref to the Queue.  The calling code would wait on the Queue for the reference, then destroy the Queue.

0 Kudos
Message 9 of 13
(4,979 Views)

Gerry_Ford wrote:

 

The viewers are subclasses of a general viewer.  The problem arises when you try to launch the specific instance of the child viewer.  It's not possible to use dynamic dispatch with the start asynchronous call function, so you have to create a static dispatch launcher VI.

 



I see. Wouldn't it work to have a "Start method and insert" as a class function and feed it the subpanel ref, then the class can start and insert itself?

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 13
(4,972 Views)