LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
wiebe@CARYA

Run As SubVI method

Status: New

In LabVIEW we can dynamically run a VI in a few ways:

a) If it's not running Top Level VI or if the VI re-entrant with the Run method.

b) Already running as sub VI, with Call By Reference.

c) Make a new VI and drop the (running) sub VI on the diagram.

 

Downside of a) is we can't always make sub VI's re-entrant, but still want to call it by reference. Downside of b) is we need to know the strict type (connector pane). Downside of c) is we might end up with a lot of VI's just to function as Top Level VI for the sub VI's and it doesn't work in executables.

 

I like to propose a method, so we can dynamically call a sub VI without knowing the strict type.

This is all I want.png

Using it, we enable LV to dynamically run sub VI's while setting\getting it's parameters by name.

 

For sub VI's (already running) this method will act as Top Level VI. For Top Level VI's it will fail unless it's idle.

 

 

 

(Please ignore my first confusing attempt)

6 Comments
AristosQueue (NI)
NI Employee (retired)

This is a viable request.

wiebe@CARYA
Knight of NI

> This is a viable request.

Made my weekend.

avogadro5
Active Participant

This is available through the ActiveX API https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/properties-and-methods/activex/vi/call2.ht... 

 

activeX generic subVI dispatch.gif

Very strange to find a power like this exists but not within LabVIEW's g APIs!

wiebe@CARYA
Knight of NI

>This is available through the ActiveX API https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/properties-and-methods/activex/vi/call2.ht... 

 

Too bad it's AX. I suppose we could try to find out how AX get's it done.


There goes my next 2 days of productivity... 😁

EDIT: Almost everything AX gives error 3005 ("Automation Open: Object specified is not creatable")... I tried _Application (in LabvIEW 24.3.2f2 Type library Version 5.5) in every LabVIEW version, 32 and 64 bit and got this error 3005. Then I selected _Application with "Show creatable Objects Only" on, and it worked...

 

EDIT2: Don't run the AX code in the user thread (VI's execution system). That will hang LabVIEW. Probably will happen at some point if "same as caller" is selected.

wiebe@CARYA
Knight of NI

EDIT 3: The return values are those dreaded OLE variants...

 

EDIT 4: AX opens the VI in a new instance (even if "create new instance" is false). You have to open an application to the current project, or AX VI get's it's own dataspace:.

Open Application.png


Getting there 😁. Next step is to get this running on a LabVIEW exe, pref. through a remote application reference.

avogadro5
Active Participant

I spent a day or 2 myself.

  • Handling different servers (like runtime vs editor) is a serious PITA because the TLB on the exe has to have a different name and LabVIEW considers it an unrelated type (roughly like trying to mix a PPL'd and source lvclass)
    • The C# API for this supports loading a type by name but as far as I can tell LabVIEW does not
  • Some OLE Variants marshal correctly including the primitives you would expect, but NOT LV Objects
  • I have a feeling this is much easier if you stick only with OLE Variants and probably move away from using LabVIEW to do the dispatching since we can't really create OLE Variants directly