05-11-2023 07:12 AM
I was wondering about the Run VI invoke node. Does it exclusively run isolated SubVIs that do not depend on incoming information? Because usually SubVIs run when there is fresh data available. So what is if I have a SubVI that is wired to incoming information but I want to start it with the invoke node? I don't have a VI at hand, I was just wondering.
05-11-2023 08:25 AM
Wrongly posted to the CVI board. Notified the moderators to move it to the correct board.
05-11-2023 09:57 AM
@mikoborn wrote:
I was wondering about the Run VI invoke node. Does it exclusively run isolated SubVIs that do not depend on incoming information? Because usually SubVIs run when there is fresh data available. So what is if I have a SubVI that is wired to incoming information but I want to start it with the invoke node? I don't have a VI at hand, I was just wondering.
You can use SetCtlValue or a Run Asychronos (instead of runvi) to set control values before starting it. With the latter it's very similar to a normal subvi. A common use case is to send in a queue or event ref that that vi can use to communicate with the main vi.
05-11-2023 10:26 AM
@mikoborn wrote:
I was wondering about the Run VI invoke node. Does it exclusively run isolated SubVIs that do not depend on incoming information? Because usually SubVIs run when there is fresh data available. So what is if I have a SubVI that is wired to incoming information but I want to start it with the invoke node? I don't have a VI at hand, I was just wondering.
Your question is way too vague. It would help to tell us what you are trying to do, not how you are trying to do it.
How can it depend in wired information if it does not depend in incoming information? Seems like a contradiction.
You can run any subVI, and if terminals are not wired like in a regular call, it will operate with the default values of these controls. If the subVI is not reentrant, the next call instance cannot start until the previous call has completed. So what does the subVI do? Does it quickly return on it's own? Is it interactive? What is its purpose?
05-11-2023 11:08 AM
If you want to call a SubVI dynamically and actually use its connection pane to send information to it, you need to use a Call By Reference node.
Looks something like this:
05-11-2023 11:44 AM
@Kyle97330 wrote:
Looks something like this:
That code only make sense if the subVI returns quickly on its own. Unfortunately we have insufficient information to really tell what the OP wants.
05-12-2023 04:19 AM - edited 05-12-2023 04:27 AM
Also note that the Run VI method will need an idle root loop.
Call VI Reference doesn't.
This means that a Run VI method in a loop will stop executing when the user selects any menu (context, toolbar, build in or custom) anywhere in LabVIEW. (Pardon the boldness, but this usually only gets noticed far in the development process, and then it can be a huge problem).
You can simply check this. See the iteration stop when you select any menu (even a diagram menu):
(The Static VI ref is a new VI).
Call VI Reference (or ASync variants) call the VI much more like a SubVI is called, but you do need a prototype of the connector pane.
Another difference is that Run VI can only be called on an idle (instance of a) VI, where Call VI Reference can be called on a VI that isn't being executed. Even if you clone the VI, the instance can only execute once at the time, subsequent calls will have to wait. However, Run VI will simply return an error that the state is not compatible. Call VI Reference will act like it was a subVI.
See Run As SubVI method - NI Community for a 'run' variation that is now simply not possible: run like a sub VI, without the need for a connector pane.