NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I force TestStand to create multiple instance of an activex server instead of share the same reference?

Hi, All:
 
     I am trying to migrate a application coded by VC++ to TestStand+CVI. This application opens multiple serial com ports and send commands to test targets, and get responses from these targets. The VC++ application creates multiple thread, and every thread create an activeX server instance which is responsible for opening serial port,sending test commands ,and getting response. It works fine as every thread has itsown activeX instance, so data and commands can be handled in the right serial port successfully.
 
     Yet when I works on TestStand, I got problems. I choose parallel model as the process model. I create a activeX object reference with AxtiveX/COM Adapter, and store the reference in a sequence local varialbe. If there is only 1 testsocket, It is OK. But if there are multiple test sockets, and communication between the application and test targets will be directly to the last test target. I try to popup a message within a execution to indicate the value of the activeX object reference, and all of them are identical. But this is not the behavior I want.
 
    So, is it possible to force TestStand to create independent instances of an activeX server? How can I make it work?
 
Thanks
 
 
 
0 Kudos
Message 1 of 5
(3,934 Views)
Hi Cipher,

A lot of how instances of a particular ActiveX Server are created depends on the Server itself. Your particular ActiveX Server may be set up to only instantiate one instance of the Server, and point all creation requests to that one reference.

For example, if you ask for an instance of the TestStand Engine from LabVIEW or any other programming environment, you will always get a reference to the same instance no matter how many times you request a "new" instance. My guess would be that your ActiveX Server works the same way.

If this is code that you have written - you can certainly go in and modify this behavior so that it always creates NEW instances, instead of all creation requests referencing the same instance.

Hope this helps Cipher, let me know if you have any questions.
Dan Weiland
0 Kudos
Message 2 of 5
(3,912 Views)

Thanks for your comment, Dan.

      Yet I do get problems as none of us know how to program an activeX server so that it can be forced to be a single-instance or multiple-instance.
As I mentioned earlier, there is existing application which is written by VC++ can create multiple instances of this activeX server, all I have to do is to create multiple threads, and initiate an instance of this server to contrl multiple test targets.
     My colleague said he creates the server with VC++ ATL, and cofigure it to be dual-interface and STA. And in the VC++ application side(client side), I use smart-pointer in threads to create an instance of the server:

 IMySerialServer pIMySerialServer;

  HRESULT hr = pIMySerialServer.CreateInstance("UUTCmd.MySerialServer");
  if(FAILED(hr))
   AfxMessageBox("Fail to create instance.");

And then I got multple instances of the activeX server. Every thread can have itsown com port, can send/receive commands indepently. I have no idea how can I make it work on TestStand. Would you show me some reference documents or sample codes?

Thank you

Cipher

 


 

 

 

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

Here is something to try.

Put two subsequence calls in a parent sequence to two different subsequences. Configure each to run in a separate thread and select that the thread is Apartment Threads. In each thread, create and use your server.

I don't have a concrete theory, but one possible difference between your visual C++ test, and creating your server in TestStand is that TestStand threads are in the multithreaded apartment by default. Doing the above should determine if that is making a difference.

 

 

0 Kudos
Message 4 of 5
(3,884 Views)

Hi, James:

Thank you very much for your enlightment. After strugglig with STA and associated settings for days, finally I can create a workable tiny program which is composed of CVI, teststand and activeX servers .

Thank you, again.

Cipher. 

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