NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing a ActiveX reference in Teststand from a LABViewVI to another

To get datas through OPC we need in a LABView VI to open the ActiveX reference, connect to the OPC Server, read the OPC Item, disconnect from the Server and close the connection. Creating a sequence in TestStand I decide to create a VI for connect, a VI for read and a VI for disconnect. The sequence always failed. How can I pass the ActiveX object (RefNUm) from LABView to TestStand and back?

Thanks for your help
Erich
Download All
0 Kudos
Message 1 of 2
(3,207 Views)
Moduler,

After creating the ActiveX reference in your VI, you can save it in a TestStand local variable by using the the SetValIDispatch method of the TestStand API. In another VI called by a subsequent step, you can retrieve the ActiveX reference from the TS local variable by using the GetValIDispatch. The reference you retrieve in this VI will be a generic ActiveX reference. You will need to either 1) use the To G Data function to convert it to the required type of reference or 2) type cast it to the required type of reference. The preferred method is 1) because it actually queries the reference to confirm that the interface you have selected is valid for the given reference. The second option blindly converts the reference.

I have modified your
VIs accordingly (see attached).

Another option is to use the Automation Open function in the read VI but enable send in False for the value of the Open New Instance input. I have not tried this technique, but it should work theoretically as long as you are using TestStand 2.0.x. In TestStand 1.0.x the ActiveX reference in your connect VI would have been closed automatically when the VI stopped running, and the instance of the server ref would not exist for subsequent steps. Using this latter technique dose have a risk. If for some reason your connect VI is unloaded, the technique would fail since the ref to your server would automatically be closed by LV.
Download All
Message 2 of 2
(3,207 Views)