LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Embedd different functions in a SubVi via Pointer

Hello, 

i have a state machine that does some general stuff (setting up the process etc, it contains a while loop). I want to use this "framwork" multiple times - but with different actions at the different states. I do not just want to copy it and make different versions as this would then require me to do future changes in all of them - which i dont want. Thats why i would like to pass my SubVis that shall be called at the different states into this Vi - sort of like a function pointer in c. The atteched screenshot is the State machine - the comment in the center shows where i would like to programmatically execute a subvi that is passed into this vi (I do NOT want to drop the subvi here, it shall be an INPUT!)

 

alphaNOVA_0-1701099346353.png

 Is this possible / how would i do that in Labview? 

 

Kind regards, 

Marc 

 

 

0 Kudos
Message 1 of 2
(502 Views)

Never shrink a Labview screenshot, it becomes impossible to decipher.

 

The general way to programmatically load/run subvis is to open a vi reference and then call the vi by reference (all necessary functions are in the application control menu). This way you can load/run/unload vis by their file path (also within vi libraries) during runtime. There's a normal call which waits for the vi to complete, and also an asynchronous call which runs the vi without blocking your main program and lets you collect the output (if necessary) at a later time. The built-in help explains all the details you need to know. In any case you need to be aware that the connector pane layout is always static (like a data type) and has to be known/defined in your source code because it can't be changed at runtime. That means, if you want to call interchangeable vis from the same place in your state machine (e.g. like loading different "plugins" into a main program), they all must have the same connector pane, so you kind of have to standardize the inputs/outputs of the vis you can load (use variants if the data types vary significantly) or make explicit cases for different connector pane types.

Message 2 of 2
(483 Views)