VI Analyzer Enthusiasts Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Test for class wire colour scheme

Solved!
Go to solution

I have a requirement to check that the class wires of code generated in house conforms to a specific colour scheme (color scheme for Americans searching this).

I'm not convinced that I can easily do this - But I'm sure that it should be possible.

I just need to get the 4 colours that are defined in the Class wiring palette (and know which is which - foreground & background, edge & centre), then compare them to the limit that I have.

Still hunting for a technique to do this - suspect that it's going to be a private NI one though

Any ideas
(@ Darren???)

Thanks 

James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2022 SP1 installed
0 Kudos
Message 1 of 3
(793 Views)
Solution
Accepted by topic author James_W

Possible, but not easy. Here's some code that, given a wire, will grab the Wire Pens property of the LabVIEW Class that defines that wire type. 

Darren_0-1767814930746.png

Several notes/caveats:
1) In this example, the class wire I was checking was the "Message Dequeuer" class from Actor Framework... that's where the teal and pink colors come from. I think it's the colors for each pen in that array that you'll want to check in your test.
2) The Request Deallocation call is always required when reading the "Data Type" property in scripting code. See the Known Issues section here for more details about this requirement.
3) This code should return an empty array for a non-class wire.
4) This code doesn't close the Owning VI, Owning App, or LV Class references that it opens, but it should.
5) Your VI Analyzer test will need to store its own cache of LV Classes that it has already checked, and not re-check them when it encounters another wire of the same type while analyzing VIs. Otherwise you'll get a jillion duplicate test results, one for each wire of the class that fails the color check. This is one of the disadvantages of the fact that the VI Analyzer can only currently perform an analysis at the VI level, and not the library or project level.
6) Your test will probably also need to ignore LV Classes that aren't part of your project.

Ok, hopefully that's enough to get you started. Good luck in your quest.

Message 2 of 3
(774 Views)
Solution
Accepted by topic author James_W

Thanks Darren,

That's similar to the solution that I found just before you replied ... except that I bounced back up the VI hierarchy to see if the caller was in a class and if it was I took the wire pens of the class. I'm fully happy with that as I'm only running tests on VIs changed in Git, so every time I touch a class in the project it should check for the validity of the class wires to the scheme. (but I can always manually run against the whole project and all VIs in a class will fail).

For others in future (or me when I come back😉)

I found some nice code in

C:\Program Files\National Instruments\LabVIEW 2022\resource\Framework\Providers\LVClassLibrary

 

NewAccessors\VIRetooler\CLSUIP_GetContainingLVClass.vi - for getting the class (I had to copy the code as it was private scope, it'd be lovely if it was publicly accessible, but it's great that it's not locked)
CLSUIP_GetUDClassWireDesign.vi - for getting the wire pens (I think you used that VI) through a property node


Your method does show me the other part of another test I'd like to do - check class terminals follow a specific naming convention, so that's handy too.

Cheers
James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2022 SP1 installed
0 Kudos
Message 3 of 3
(700 Views)