LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best method to pass a resource between classes

Solved!
Go to solution

Hi all,

 

Relatively new to OOP still and have been working on an OOP project.  My basic architecture is an OOP state machine, each class represents a different test.  I have one test that will run through all the tests, so i figured i could just pass a new class into a for loop and have it run through all the tests.  Problem with that of course is i connect to a device and the resource is lost with every new object.  One solution ive come up with for this problem is to have a class that composes of the test class and the device resource and i could bundle a new class every time i switched tests and carry the same resource on the wire.

 

Any comments welcome, if my overall plan for this program is off please say so.

 

Thank you,

 

Matt



-Matt
0 Kudos
Message 1 of 4
(2,897 Views)
Solution
Accepted by Wolleee

Use a shift register to store your device and have each of your Run Test methods have an input for the device object.  You will probably need a couple of tests for Initialize Device and Close Device.  These should be the only two cases that open or close your device.  So no composition is needed.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 4
(2,888 Views)

Hi Crossrulz,

 

That actually makes a lot of sense, i was hoping to be able to carry it on the same wire as the class, but i think it probably just makes more sense to have it in the for loop.  I suppose i should have one parent method for configure and open device and one for close device, beofre and after the loop?

 

Matt



-Matt
0 Kudos
Message 3 of 4
(2,884 Views)

matt198717 wrote: I suppose i should have one parent method for configure and open device and one for close device, beofre and after the loop?

That would make sense to me.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 4
(2,877 Views)