NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Engine Handle to LabWindows CVI

Hi All,
 
I have run into a situation in test stand where I want to use it in conjunction with a DLL that I have developed in CVI.  In order have them interact properly, I wanted to pass the current TestStand Engine handle into my CVI DLL.  Afterwards, the plan is to use that engine handle along with the tsapicvi activeX control to do what I need to do.

However, I cannot seem to get this working correctly, as I keep getting an invalid handle error from my CVI activeX controls with the handle I have passed into it from teststand.  Here is what I have so far.
 
In TestStand Sequence A calls the CVI DLL:
Sequence A has a single parameter called Engine.
Parameter Engine has the teststand Category TSObject with type TS::IEngine passed By Value.
The value passed into the parameter Engine is RunState.Engine
 
The CVI DLL has a single function GetHandle
GetHandle has a single parameter which is TSObj_Engine *ts_engine.
This function calls TS_EngineGetLicenseDescription (*ts_engine, NULL, 0, &desc); (just a random function that I use to test it).
 
Any suggestions on where I might have gone wrong with this?
 
CVI 7.0
TestStand 3.1
0 Kudos
Message 1 of 5
(3,346 Views)

Hi,

Do you actually set the parameter Engine to anything when you call your sequence.

In your DLL function call, just pass an obj handle "RunState.Engine".

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 2 of 5
(3,339 Views)

Hi Ray,

Thanks for the quick response! 

To answer your question, yes, I do set the Engine parameter in TestStand to RunState.Engine.

 However, all I know about the TS:IEngine containter is that it has one (or more) data fields that get passed to my DLL.  I don't know what those fields are, so on the DLL end I am not sure what I should be getting.  i.e. the function prototype in my DLL should probably contain some struct, but I don't know what the struct is.  The only guess I can make is that teststand is passing me a TS_IID_Engine type struct (defined in tsapicvi.h).  However there are 4 data fields in this struct convienently labeled Data1 - Data4, all of which i tried using as a handle, and none of which worked.

0 Kudos
Message 3 of 5
(3,334 Views)

Hi DaveC,

I dont know why you are passing that struct, but all you need is a CAObjHandle and link either the SequenceContext or the RunState.Engine in the DLL Adapter specification.

Have a look at the Using LabWindows/CVI with TestStand manual 4-3,4,5,6&7 for calling code modules with Struct Parameters, if thats what you really need to pass.

Regards

Ray Farmer

Regards
Ray Farmer
Message 4 of 5
(3,330 Views)
Ahh, I see more clearly now.  I was using the C/C++ DLL adaptor and passing a TSObject to my DLL when I should have been using a CVI Adaptor and passing a CVI ActiveX Automation Handle Object to my DLL.  This is where I was getting myself confused, but you have helped me see the light.  Thanks Ray!
0 Kudos
Message 5 of 5
(3,327 Views)