LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How get the execution control back without waiting for child to complete its execution?

Hi,

 

In my application I want to continue the execution in the caller VI without waiting for class method to complete its execution. Please refer the attached screenshot of a simple example, the caller vi calls UI.vi method which will continue execution until a user presses stop button, this halts the For loop in the first iteration. How can I avoid this and make For loop to continue execution ?

 

thank you

Adarsh

0 Kudos
Message 1 of 12
(3,087 Views)

What it seems you are trying to do makes no sense.  You want to have 3 of these UIs open?  What are you actually trying to accomplish?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 12
(3,069 Views)

This is not the end application, I'm trying to demonstrate the requirement with a very simple example.

In the end application I will be creating multiple instances of the method with different properties, for example lets assume I have a Graph display class with Plot graph method, I will dynamically create the multiple instances of the  plot graph method and have multiple graph UIs open as the user requests for multiple plots for multiple analog channels.

 

 

0 Kudos
Message 3 of 12
(3,063 Views)

You'll have to start the VI dynamically somehow.

 

For starters, the VI will not be started more then once if it's not re-entrant. But if it is re-entrant, the for loop will still wait for each execution, unless you program it for parallel execution. Event then, the loop won't return until all parallel executions are finished.

 

To really run a number of instances and "get control back", you need to start them with VI server. So you need to get a reference to the VI, set it's controls and run. This can be done with the Run method, Call and forget\collect and such methods.

 

It's sometimes useful to do things like this, but it's only worth the effort if it can't be avoided. But that is hard to say without more detail...

 

0 Kudos
Message 4 of 12
(3,052 Views)

@Adarsh_HAL wrote:

In the end application I will be creating multiple instances of the method with different properties, for example lets assume I have a Graph display class with Plot graph method, I will dynamically create the multiple instances of the  plot graph method and have multiple graph UIs open as the user requests for multiple plots for multiple analog channels.


From experience, multiple windows makes for a poor user interface.

 

But to do what you want, you will want to use the Start Asynchronous Call with a Open VI Reference inside of the FOR loop.  Your VIs will have to be set to be reentrant (VI properties setting).  Look in the Example Finder (Help->Find Examples) for an example of how this works.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 12
(3,040 Views)

Thank you for your response!

Multiple windows is my requirement in the application. I know I need set the VI to be reentrant.

Please don't gauge the example program and the way it has been designed. It's only for demo purpose and I'm simulating the issue in that.

 

Is there any way I can achieve this without having VI dynamic calling? I have used dynamic calling in multiple projects.

 

In this particular application one of the requirement is I need to call the UI method and let it run without waiting for it to complete the execution. Requesting your ideas here.

 

Thank you

 

 

Adarsh
CLA - Certified LabVIEW

Architect
https://www.youracclaim.com/badges/4871da75-1b8b-422a-a881-9ab206d2d36d/public_url
0 Kudos
Message 6 of 12
(3,001 Views)

Adarsh wrote:

Is there any way I can achieve this without having VI dynamic calling? I have used dynamic calling in multiple projects.

 

In this particular application one of the requirement is I need to call the UI method and let it run without waiting for it to complete the execution. Requesting your ideas here.


If you don't want to wait for execution, you have to run dynamically.

 

But you can continue execution, even when the VI is running. For instance, if you have 4 dialogs, you can simply put them somewhere parallel to your main loop. They won't block execution, even though they are running. They run as normal VI's in parallel. Send them an event, and they could show, hide or stop.

 

They only reason you need to call dynamically, is because you specify "don't wait for execution". So you're forcing the answer to "call dynamically" by over specifying your requirements.

 

If you want to start 4 dialogs, and can stall execution until all for dialogs stopped, you can also configure your for loop for parallel loop execution. This will effectively start the 4 dialogs, and the loop will continue when all 4 dialogs are finished.

 

Theoretically, you only really need dynamic calling when a) the number of instances is undefined\unlimited, or b) the instance to start is not known at compile time. Even in those situations, there could be workarounds. And there are situations where it's not strictly needed, but convenient. 

 

0 Kudos
Message 7 of 12
(2,988 Views)

Number of instances and the instance to start is unknown and random. It is based on a user events in the main UI. 

My application is LVOOP based design, so I would like to use dynamic class instance creation and call the method(in this case it launches a UI to display graph for a particular analog signal)  than launching the VI using dynamic calling.

 

Thank you

Adarsh
CLA - Certified LabVIEW

Architect
https://www.youracclaim.com/badges/4871da75-1b8b-422a-a881-9ab206d2d36d/public_url
0 Kudos
Message 8 of 12
(2,984 Views)

@Adarsh wrote:

Number of instances and the instance to start is unknown and random. It is based on a user events in the main UI. 

My application is LVOOP based design, so I would like to use dynamic class instance creation and call the method(in this case it launches a UI to display graph for a particular analog signal)  than launching the VI using dynamic calling.


So the easiest way to do that is to give the parent a method (or two, start and stop) that manages the dynamic call. And give each child a protected override of a VI that returns the (static) VI reference. That way the parent will be able to call all child implementations. Dynamically resolving the child method to call dynamically is a pain.

 

0 Kudos
Message 9 of 12
(2,973 Views)

In this method how does the parent method give the control back to top level caller vi?

0 Kudos
Message 10 of 12
(2,932 Views)