LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use a VI to find the node count of a VI in C++.

Solved!
Go to solution

I have created a VI that finds how many nodes a VI has. You pass in the file path as a string, and it counts the nodes. This works great in dev; however, when I build it into a dll and run it in my C++ program it gives an error because the compiled code is not saved with the source code (It can't make a vi reference). This can be solved by unchecking the property in the VI I am trying to dynamically call to not save the compiled code; however, This is going to be checking the node count for hundreds of VIs in separate projects and I don't want to have to change that setting everywhere. Am I missing something, or is there a better way to do this?

ChrisWoodard_0-1767818545709.png

Essentially I want to find the node count of a VI without altering the VI using the VI's path. 

 

0 Kudos
Message 1 of 12
(654 Views)

oops you already count the nodes.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 12
(630 Views)

Yea, my issue is just that when I run this in my C++ program I get an error when trying to create a VI ref, because the VI is not apart of the project. Essentially I'm asking if there is a way to analyze a VI to find the node count programmatically when the VI was not built in the dll.

0 Kudos
Message 3 of 12
(605 Views)

I don't think you can traverse the BD at all in RTE

avogadro5_0-1767822975320.png

 

Your calls to Traverse for GObjects.vi are very likely returning error 1043 "LabVIEW: (Hex 0x413) The property or method is not supported in this version of LabVIEW." You should wire the error clusters through so you don't have strange problems you can't diagnose. have fewer strange problems you can't diagnose.

0 Kudos
Message 4 of 12
(601 Views)

Ah ok, I was getting my error before then when trying to create a VI reference. Just so, I understand correctly the RTE is what VI's run on when built correct? Which would explain why it works in LabVIEW but not when it's a dll.

0 Kudos
Message 5 of 12
(590 Views)

I normally receive this error 59 from the Open VI Ref.

 

ChrisWoodard_0-1767824010323.png

 

 

If I fix that by making the VI I am trying to open save the compile code with the source file (Which I don't want to do) I get this error from the TRef Traverse VI. If this VI won't work I do not mind writing my own recursive VI to count nodes. I just need to be able to pull a VI reference to do that.

 

ChrisWoodard_1-1767824144157.png

 

0 Kudos
Message 6 of 12
(579 Views)
Solution
Accepted by topic author ChrisWoodard

@ChrisWoodard wrote:

Ah ok, I was getting my error before then when trying to create a VI reference. Just so, I understand correctly the RTE is what VI's run on when built correct? Which would explain why it works in LabVIEW but not when it's a dll.


Yes. I'm not an expert but generally what happens is when the caller loads the DLL you built, first the DLL loads the runtime engine and then the runtime engine loads the actual VI you're trying to run. Traverse for GObjects.vi will only work on block diagrams in the development environment, meaning when called by LabVIEW.exe. As a rule, RTE cannot view or interact with the BD in any way.

 

Depending on what you're doing, you have some options besides the DLL. If you do have access to LabVIEW development you can use VI server over TCP/IP to connect to LabVIEW and run VIs in the development context: this is how VI package manager works. LabVIEWCLI also uses VI server to provide a CLI for LabVIEW development.

 

If you do not have access to LabVIEW development where this tool is running, pylabview can extract a bunch of info about the block diagram without requiring LabVIEW.

 

Message 7 of 12
(558 Views)

OK, that sounds like what I'm looking for thanks a lot. I will look into it.

0 Kudos
Message 8 of 12
(533 Views)

This worked great. When researching this I also found XActive, which seemed to be a bit more simpler. Therefore, I set it up using XActive. This requires that the bittness of the C++ and LabVIEW match, so watch out for that. Also, it requires whatever is running the C++ code also has LabVIEW installed

0 Kudos
Message 9 of 12
(474 Views)

Fair warning, I have used the ActiveX API in C# (here) and find it buggy especially with multiple LabVIEW versions installed. It also seems to stop working related to suspending the PC. NI has pretty much abandoned it because Microsoft has deprecated the whole framework.

 

There are distinct advantages though, for instance it will launch LabVIEW for you if it isn't running when you go to connect, and the API is extremely lightweight and loads in milliseconds vs seconds for loading the runtime engine to perform VI server ops for you.

 

I would like to see NI create a lightweight .NET replacement API but don't see it happening soon.

0 Kudos
Message 10 of 12
(251 Views)