08-23-2012 09:45 AM
Hello,
I currently have TestStand code which creates an ActiveX Object reference to a StationGlobal...
Currently the ActiveX Object Reference created is always the same... I'm looking for a way to create a different ActiveX Object reference depending on what instance of TestStand open...
So I guess I'm wondering if there is an easy way to do this? Is there a variable I could use to distinguish different instances of teststand and somehow incorporate this into Create Options?
Thanks for any response.
Solved! Go to Solution.
08-23-2012 10:10 AM
What do you understand with "different instance of TestStand"?
Norbert
08-23-2012 10:18 AM
Not sure i understand the question...
Use case is that I run test using TestStand which use ActiveX to communicate to a CAN port, j1939 protocol. But if i have 2 instances of teststand open, the object reference created in each seperate instance needs to be different to avoid confusing the client on the CAN... If both instances attempt to share the same object reference one ends up getting kicked off and loosing connection to the CAN.
08-24-2012 02:06 AM
OK, you have to know that different instances of TestStand mean that you are running two differen UIs (e.g. Simple UI and the NI Sequence Editor) in parallel, both executing a sequence, which includes your ActiveX CAN Server.
So how does this ActiveX CAN Server determine between different clients who are calling him?
My thought is, that you are having this ActiveX CAN Server in order to make parallel access of different OS processes to the same hardware possible. But if the API of the CAN Server does not supply you with a dedicated ID mechanism for its clients, there is nothing much you can do from the caller side (so from your TS sequence).
Norbert
08-24-2012 07:18 AM
Ok, thanks for clearing that up for me Norbet.
I did not develop the ActiveX servers but was told i could make it work in TestStand. I will speak to the creator to resolve. Appreciated.
08-24-2012 07:54 AM
Well, it obviously works if called from TS. But it seems that it does not supply support for multiple clients in parallel.
So your issue would also be true if running a TS Sequence calling the ActiveX Server in parallel to a pure LV application calling the the Server as well....
Norbert
08-24-2012 07:55 AM
One more question, is there any variable that I could use to distinguish between 2 different instances of TestStand? instances as in to seperate sequence editors open...
08-24-2012 08:08 AM - edited 08-24-2012 08:10 AM
I can imagine that this property of the Engine class could help you:
Engine.AppMainHwnd
Specifies the Window handle of the owner of modal dialog boxes.
TestStand uses this property to make dialog boxes modal to the application. Do not set this property because TestStand sets it automatically when the application creates the TestStand Engine. Setting this property can cause dialog boxes to be modal to the wrong window. This property usually refers to the main window of the application but refers to the window of the dialog box when the application displays a modal dialog box.
If the handles are different, you are using "a different instance of TS".
Norbert
EDIT: Starting the application, closing it and restarting it will likely generate different window handles. So you have to make sure that you shutdown connections to the ActiveX Server properly before actually shutting down the application for good. This, of course, is recommended nevertheless, independent of this "issue".
08-24-2012 08:27 AM
Just what I've been searching for. Thanks!
08-24-2012 10:26 AM
If you just want a unique id per engine instance you should use: Engine.UniqueEngineId
The Hwnd might be NULL in some cases depending on the UI.
-Doug