NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Create Object based upon Instance of TestStand

Solved!
Go to solution

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.

0 Kudos
Message 1 of 11
(4,163 Views)

What do you understand with "different instance of TestStand"?

 

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 11
(4,159 Views)

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.

0 Kudos
Message 3 of 11
(4,156 Views)

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 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 11
(4,146 Views)

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.

0 Kudos
Message 5 of 11
(4,143 Views)

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 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 11
(4,138 Views)

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...

0 Kudos
Message 7 of 11
(4,137 Views)
Solution
Accepted by topic author knowledge_is_power

I can imagine that this property of the Engine class could help you:

AppMainHwnd Property

Syntax

Engine.AppMainHwnd

Data Type

Long

Purpose

Specifies the Window handle of the owner of modal dialog boxes.

Remarks

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". 

 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 8 of 11
(4,133 Views)

Just what I've been searching for. Thanks!

0 Kudos
Message 9 of 11
(4,129 Views)

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

Message 10 of 11
(4,121 Views)