LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

disconnecting from a running subvi (i.e., fork)

Is there a way to start a subvi running, but not wait for it to finish?  That is, to fork or disconnect from the subprocess?

For example, my main timing program starts subvi 1 at certain intervals (say, 10 seconds).  This subvi will, based on certain conditions, run subvi 2.  Subvi 2 will take longer than 10 seconds to complete its job, but subvi 1 needs to be completed and ready to run again when the timing program calls it again 10 seconds later.  It will not call subvi 2 this time, knowing it has not completed its job.

Thanks,
Karl.
0 Kudos
Message 1 of 6
(3,123 Views)
Hi Karl,
you can use the "Open VI reference" function and use an invoke node to start your vi.
Mike
0 Kudos
Message 2 of 6
(3,121 Views)
Your SubVI1 needs to open a VI reference for SubVI2. This will load SubVI2 into memory. Normally I do this when starting the application. You have to provide a path to the Open VI Reference primitive and be aware that the path will change from development environment to built application.
 
Use this reference in SubVI1 to start SubVI2 with the invoke node "Run VI". You can set the Invoke node not to wait until completion. This will start the execution of SubVI2. If for any reason SubVI2 is running when calling the node you will get an error in the error out of the Invoke node but SubVI2 will continue running.
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 3 of 6
(3,119 Views)
Thanks, Mike.  I'll read up on invoke nodes.

Karl.
0 Kudos
Message 4 of 6
(3,110 Views)
Thanks, Mike and Waldemar.  I'm mostly there.

First, I discovered you can't pass parameters with the invoke node.  So I was able to first set the controls to the proper values using an invoke node with "Set Control Value."

My invoke node in which I try to run the subvi is set to "Run VI."  This command returns error 1000, "LabVIEW:  The VI is not in a state compatible with this operation."  It appears I can solve this problem by setting the subvi to allow re-entrant execution.  Is the proper fix?  There is no other reason to allow re-entrancy in this subvi.

Thanks,
Karl.


0 Kudos
Message 5 of 6
(3,089 Views)

Does this error occur on the first attempt or only on subsequent runs.

Is the target VI being used elsewheer in your app?

Try watching the VI hiarchy screen while your app is running. Use ctrl-a to see all of the VI's loaded.

It sounds like your VI is either running as part of the app (not top level) or it still running from a previous run.

Trying to help,

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 6
(3,071 Views)