NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Using active x reference in teststand

I make multiple calls to active x dlls in multiple subsequences. Can anyone explain the advantages and disadvatages of creating a new object for each call?
I initially created a new object only on the first call and then used the same local active x variable on subsequent calls within the sequence. However, an error (ACT X Ref = "NULL") occurs in debug mode when that first step is not run.
What is the downside of creating a new object everytime?
Should I create a "dummy" Active X dll call in the sequence setup for ech subsequence to fill the reference variable locally?
How about using a global Act X ref variable? (most calls are within the same dll class)

If it matters, the dlls are Visual Basic Active X dlls.

Thanks in advanc
e for you advice.
0 Kudos
Message 1 of 3
(3,426 Views)
Hi,
what you need to remember, is that you're creating objects from a class, so say you had a class of object called orange. Every time you create an object, and put a reference to it somewhere, it's a whole separate orange. This is fine if every time you create a orange object, you use it up and throw it away afterwards. You can even have lots of these objects open at once, and discard them when you've finished with them.
Now consider a class called apple which has methods that are reliant on each other. If you create an object like this, and call a method (say peel(long strip)), it will have changed something about that object. If you create another object, and call peel again with a different parameter (say peel(6 strips)), it will have performed this action on a wh
ole different object to the first one (- there is an exception to this which is the singleton server).
So it depends on how your server is supposed to work.
Can you create one object, and keep using it, or is there some dependency that requires you to create a new object of that class?
From your question, I don't think you're doing anything multi-threaded, so you could easily make one call to the Action step type, and get a reference to the new ActiveX object without calling any methods (un tick the call method checkbox). This can then repeatedly be used. You can have this as one of the first setup things your sequence does.
Another trick would be to pass the original ActiveX reference down as a parameter, and copy the creation step to the start of the subsequences, using a precondition, that if the Parameters.xxxxx == Nothing, then run the step, and create a new object, otherwise, use the one that's available.

Hope that helps.

S.
// it takes almost no time to rate an answer Smiley Wink
0 Kudos
Message 2 of 3
(3,426 Views)
I also had a problem with the "Act X Ref = NULL" error. I wanted to keep a reference Active X LabView program active even after my sequence stopped running. This way technicians could run individual sequences that made calls to the LV program without having to create a new object each time.

I solved it my storing the reference in a global and setting it's flag to "shared". The reference to the is not discarded when the sequence stops. I think this would work for you.

Not sure if this good TestStand programming practice though. Maybe a pro could comment.
0 Kudos
Message 3 of 3
(3,426 Views)