While cleaning the code up behind the dependency viewer I was able to improve its performance by about a factor of 100. I will tell you how I did that and also give you some detail on how this thing works in this post. You can download the Class Dependency Viewer as a VIP at the bottom of this page.
So how did I get 100x gains in efficiency? Sadly, it had nothing to do with my abilities as a programmer. It turns out that there is no way to get a list of a dependencies for a class using public VI Server calls. Since the whole point of the tool is to visualize how classes depend upon one another I had to brute force a solution. I was using VI Server to open a *.lvproj in the background and adding one class to it at a time, using the project API to scrape the dependencies from the class, removing that class from the project and repeating. Yikes, right?
I was complaining about this to fellow LabVIEW Champion Chris Relf and he recommended pinging NI to see if they could help. NI was great and got back to me right away with a solution, an internal method capable of taking in a path to a LabVIEW file and returning all of its dependencies. Thanks NI!
So with access to the internal method I refactored the code behind the Dependency Viewer and built a Tools menu plugin for it and a VI package to distribute it. Here is a demo of the new version:
As you saw in the demo the code is pretty simple, we are using the internal method that NI gave us to find dependencies of each class in a project, and then we build up a dependency matrix. Once we have the dependency matrix in hand we can do anything we want with the data.
If you do end up making any updates or finding any bugs please let me know. Also, if you have any question you can ask them in the comments section below and I will get back to you as quickly as I can.
Jon McBee is a Principal Software Engineer at Cambridge NanoTech and is a Certified LabVIEW Architect, Certified LabVIEW Embedded Developer, Certified TestStand Developer, an NI Certified Professional Instructor, and a LabVIEW Champion
VIP download moved to the tools page.