07-16-2018 07:28 AM
Scenario:
I have 2 UUTs in a batch model and each UUT has a local object reference to the instance of the corresponding UTT Class.
Class_Animal (sleep.vi)
+---Class_Dog (bark.vi)
+----Class_Cat (purr.vi, sleep.vi)
UUT1: Class_Dog
UUT2: Class_Cat
In the main procedure, I'd like to call the sleep or bark functions depending on the UUT. But it seems that it is impossible because the class path and member name can't be expressed by an expression. Or is there a workaround?
Using if/else to call sleep/bark is not possible because I'm going to have around 2xx type of classes.
Solved! Go to Solution.
07-17-2018 07:12 AM
Hi Aan,
It feels like I am the only one reading your questions ;-).
I have never tried something similar in TestStand, so I don't know what would be the best tactic to accomplish what you want (I am more of a TS guy and not doing a lot of OOP).
In TS you would typically write a separate sequence for every type of UUT (re-using steps you have written before), so it's a bit unusual to built that much flexibility into a testsequence.
I can give you some ideas what I would try out, but no idea how well they would work:
1) writing a LV wrapper VI
This would allow you to call a fixed VI from TestStand which then decides which function to call depending on the UUT.
This is probably the easiest work-around, but it is a little bit against the philosophy of TS controlling the testflow.
2) It is possible to change the class path and member name programmatically using the TS API (you can even generate complete sequences programatically).
Theoretically you could changing the function which is called inside the pre-expression of the step. However, this is quite chunky and can quickly make your whole sequence unreadable.
Creating sequence files is discussed here:
Teststand API Reference poster(best overview of everything what you can access from the API):
http://www.ni.com/pdf/manuals/372844d.pdf
I would probably go for the LV wrapper.
Assuming that the functionality of the step is approximately the same for every UUT, it will stay quite readable and is much easier to program and maintain than modifying every step using the TS API.
Andreas
07-17-2018 11:01 AM
I'm not an expert on the OOP stuff either but... we do something similar using test equipment. This is what I think:
1. Cat and Dog should be child classes of Animal.
2. Animal should have a method "noise"
3. Cat and Dog should overwrite the noise method with their unique noise methods. (Purr and Bark)
4. You call the Animal Class Noise Method in your sequence, which dynammically dispatches to the Cat/Dog methods.
You will need to research the Factory Pattern and the Channel Pattern. This may be a useful reference.