LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatic VI Metric: Node Count?

Solved!
Go to solution

Is there a way to programmatically perform a node count on a VI?  I've looked around and can't seem to find anything on it.  Would VI scripting do this for me?

 

Thanks,

Dan

0 Kudos
Message 1 of 7
(5,134 Views)
Solution
Accepted by topic author dano142

Assuming we mean the same thing by Node count, scripting could do this for you.  You can return a list of nodes on the BD using the Nodes[] property and take the length to get the number.  This is fraught with peril, since as far as scripting is concerned, every structure (while loop, for loop, etc.) counts as a separate diagram and you would need some recursive procedure to count everything.  Fortunately, a kind soul at NI has done the work for you, and there is a VI to do this job.  In vi.lib/Utility/traverseref.llb there is a VI called TRef Traverse For References.vi, and by typing "Node" as the class name you will get all of the Nodes.  What you would do with this, I don't know.

 

NodeCount.png

Message 2 of 7
(5,125 Views)

If you want to get some metrics from that, there is also some VI in the OpenG collection (I think it was in the Application Control Section) that encapsulated everything the developers could get at this time (the time of secretive scripting in LV 7.1). Maybe this is updated in 8.6. or 2009 where we can access it again.

 

Felix

0 Kudos
Message 3 of 7
(5,113 Views)

For posterity, to match the node count generated by the Profile tool you have to traverse classes from the block diagram:

 

Node

ControlTerminal

Constant

Message 4 of 7
(3,920 Views)

One more alternative...you can use the "Node Count" test in the VI Analyzer Toolkit to return a report of the node count of all your VIs...just change the "Maximum Allowable Number of Nodes" to zero so that every VI tested will return a result:

 

nodecount.png

 

One benefit of using the VI Analyzer Toolkit is the built-in reporting mechanisms, making it easy to generate a text or HTML file report with all the node count values.

0 Kudos
Message 5 of 7
(3,895 Views)

These two options will give very different node counts.  That is because the "Traverse for GObjects" with "Node" as theinput for "Class Name" will only give GObjects that are a "Node" in the Gobjects Class Heirarchy.  The Node Count Test in VI Analyzer will give the GObjects that are a "Node",  "Constant", or "ControlTerminal" in the Gobjects Class Heirarchy.

Quentin "Q" Alldredge

Chief LabVIEW Architect, Testeract | Owner, Q Software Innovations, LLC (QSI)
Director, GCentral | Admin, LabVIEW Wiki | Creator, The QControl Toolkit
Certified LabVIEW Architect | LabVIEW Champion | NI Alliance Partner



0 Kudos
Message 6 of 7
(3,569 Views)

Also, the VI Metrics will count clusters as a single node, but the sctripting VIs enumerate each element, so the numbers can be offset roughly by the number of elements in the cluster (depending on heirarchy).

- Regards,

Beutlich
0 Kudos
Message 7 of 7
(3,438 Views)