11-20-2020 10:14 AM
I want to start learning OOP in LabVIEW but am trying to conceptualize its usefulness when it comes to test engineering type of programs. I mainly use LabVIEW to develop programs to automate hardware testing.
What are some real world examples where OOP would be useful when it comes to hardware testing? The only thing I could think of is maybe making classes/objects for test instruments.
How else could OOP be useful?
Thanks
11-20-2020 12:49 PM
I can tell you a lot of the ones we use at my company:
Test instrument parent, test instrument type as child, specific make/model of instrument type as grandchild
Test data parent, specific type of test data child
Recipe parent, general type of recipe child, specific station's recipe grandchild
Test step parent, specific test step child
DUT information parent, specific implementation of one DUT type child
All of these allow us to write "library" VIs that work with all parent classes, so we can do a lot of code reuse. For those that have grandchildren, we often have library VIs that interact with the "child" level that get reused too.
Also, just in general, having the ability to make classes have their own wire appearance can get helpful if your code is crisscrossed everywhere with pink cluster wires.
Another benefit in general is that if you have one developer making classes and another using them, then you can use the private/protected VIs of the class to prevent using them "wrong".
11-20-2020 07:30 PM
HAL and MAL (Hardware Abstraction Layer and Measurement Abstraction Layer) are the two obvious ones. But generally speaking, if I have a library for something that requires more than one piece of data (ex TCP connection, queue references, etc), keeping it in a class helps protect the data from getting messed up by the user of the class (ie closing the queue outside of the class). Inheritance is optional; protecting data is crucial.
11-26-2020 03:51 AM
As others have said, HAL and MAL.
One word of caution I would make is that object composition is generally preferable over inheritance for a lot of functionality.
Use composition where things "have" other things. Use Inheritance where things "are" other things.