NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Mulitple Instances of DLL

Is there any way in any of the Windows variants to load and call more
than one instance of a DLL?

I have a piece of hardware that is controlled from a serial port
through a DLL (via TestStand). I'd like to contol two of these
devices but the DLL only can be loaded once and refer to one device.
Is there any way either through a program or utility that I could load
and call two different instances of the DLL?

I supose the intent of DLLs are to only be loaded once and the code
shared between applications but I can't control both devices with one
DLL since it remains connected to the same comport.

Any help or re-direction to another newsgroup would be appreciated.
0 Kudos
Message 1 of 11
(4,275 Views)
Hi,

this probably best aimed at http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=2&UCATEGORY_0=_13&UCATEGORY_S=0

Do you need to keep the port open all the time. You could try just open it when you need. Then have a flag that notifies other processes that the port is in use and to wait. If you have Teststand 2, then look at using one of the synchronization steps.

regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 2 of 11
(4,275 Views)
On Tue, 20 Nov 2001 14:04:27 -0800 (PST), Ray Farmer
wrote:

>Hi,
>
>this probably best aimed at
>http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=2&UCATEGORY_0=_13&UCATEGORY_S=0
>
>Do you need to keep the port open all the time. You could try just
>open it when you need. Then have a flag that notifies other processes
>that the port is in use and to wait. If you have Teststand 2, then
>look at using one of the synchronization steps.
>
>regards
>Ray Farmer

Yes, I do need the port open. I am trying to create two sequences
using separate hardware to test two units at one time:

seq1 -> DLL1 -> Com X -> Test Hardware 1 -> UUT1
seq2 -> DLL2 -> Com Y -> Test Hardware 2 -> UUT2

I have 2 other pieces of test hardware connected to s
eparte ports (not
through any DLL), and this works fine. My problem is the DLL can't be
run twice independantly, nor can one DLL instance connect to two Com
ports.

I've never done anything like this before. Please let me know if this
is not possible, (or reasonably easy)
0 Kudos
Message 5 of 11
(4,275 Views)
You can only load one dll with a given base file name in a Windows process. You could use multiple processes by wrapping the DLL in a multi-instance out-of-process ActiveX server and call the server methods from TestStand using the ActiveX adapter.

A much simpler thing you might try first is to copy the dll to a different name. However, if the single serial port restriction is tied to a global variable in a subsidiary dll, this won't help.
0 Kudos
Message 3 of 11
(4,275 Views)
On Tue, 20 Nov 2001 14:10:20 -0800 (PST), James Grey
wrote:

>You can only load one dll with a given base file name in a Windows
>process. You could use multiple processes by wrapping the DLL in a
>multi-instance out-of-process ActiveX server and call the server
>methods from TestStand using the ActiveX adapter.
>
>A much simpler thing you might try first is to copy the dll to a
>different name. However, if the single serial port restriction is tied
>to a global variable in a subsidiary dll, this won't help.

Of course I tried the simple thing first, renaming the dll. This did
work to some extent, I used a process monitoring shareware program,
and both DLL's were loaded separately. However, when a call was made
to the 2nd DLL, it still con
nected to the first instance. I could
tell this was happening since the device on the first com port (DLL1)
responded, not the device on the 2nd com port (DLL2).

As for creating an ActiveX server, this is not something I've done
before. Any suggestions on where to start to develop something like
this?
0 Kudos
Message 4 of 11
(4,274 Views)
1) How are you linking-to/calling-functions-in your copied dll? Are you using a .lib or have you tried LoadLibrary/GetProcAddress? If not, you should try LoadLibrary/GetProcAddress.

2) I have only created such servers in VC++ using ATL. For this approach, your best reference is probably the MSDN/Microsoft-samples and the plethora of ATL books. It might be easier to create the server in VB6 or CVI6. However, I have yet to try that. For CVI questions, there is a MeasurementStudio\LabWindows-CVI forum on NI developer zone. You could probably post there to find out whether CVI6 could create the server. Also, you might find VB experts in the MeasurementStudio\ForVisualBasic forum.
0 Kudos
Message 6 of 11
(4,274 Views)
1) How are you linking-to/calling-functions-in your copied dll? Are you using a .lib or have you tried LoadLibrary/GetProcAddress? If not, you should try LoadLibrary/GetProcAddress.

2) I have only created such servers in VC++ using ATL. For this approach, your best reference is probably the MSDN/Microsoft-samples and the plethora of ATL books. It might be easier to create the server in VB6 or CVI6. However, I have yet to try that. For CVI questions, there is a MeasurementStudio\LabWindows-CVI forum on NI developer zone. You could probably post there to find out whether CVI6 could create the server. Also, you might find VB experts in the MeasurementStudio\ForVisualBasic forum.
0 Kudos
Message 7 of 11
(4,274 Views)
On Wed, 21 Nov 2001 11:02:06 -0800 (PST), James Grey
wrote:

>1) How are you linking-to/calling-functions-in your copied dll? Are
>you using a .lib or have you tried LoadLibrary/GetProcAddress? If not,
>you should try LoadLibrary/GetProcAddress.
>

I am linking to the DLL through a LabView VI with the "Call Library
Function". I specify the copied DLL in the Library Name Field.

>2) I have only created such servers in VC++ using ATL. For this
>approach, your best reference is probably the MSDN/Microsoft-samples
>and the plethora of ATL books. It might be easier to create the
>server in VB6 or CVI6. However, I have yet to try that. For CVI
>questions, there is a MeasurementStudio\LabWindows-CVI forum on NI
>developer zone.
You could probably post there to find out whether CVI6
>could create the server. Also, you might find VB experts in the
>MeasurementStudio\ForVisualBasic forum.

Document ID DIRECT-3S8RMN indicates that the LabVIEW Application
Builder can create executables that function as Active X servers.
This is what I am trying now, creating the above mentioned VI as an
executable Active X server. Will this work?
0 Kudos
Message 8 of 11
(4,274 Views)
Yes, that should work. I think LV EXE servers are single instance. If so, that means you need a separate exe for each new process you want to launch.

LV Servers don't let you define the server API methods. Instead you use the LV provided methods to execute VIs. If you are calling your server directly from TestStand using the ActiveX adapter, you can't construct the variant arrays required by the Call and Call2 methods. Therefore, you must use the Run method in conjuction with the SetControlValue and GetControlValue methods.
0 Kudos
Message 9 of 11
(4,274 Views)
On Wed, 21 Nov 2001 15:39:27 -0800 (PST), James Grey
wrote:

>Yes, that should work. I think LV EXE servers are single instance. If
>so, that means you need a separate exe for each new process you want
>to launch.
>
>LV Servers don't let you define the server API methods. Instead you
>use the LV provided methods to execute VIs. If you are calling your
>server directly from TestStand using the ActiveX adapter, you can't
>construct the variant arrays required by the Call and Call2 methods.
>Therefore, you must use the Run method in conjuction with the
>SetControlValue and GetControlValue methods.

I've created an ActiveX exeutable using the Build Application tool in
LabView. I then register the server with
a TestStand Executable call.


The actual running of the server and passing parameters has me
stumped.

I created an ActiveX reference with the TestStand ActiveX Automation
Adapter by creating a new application object and assigning the
reference to a Local Variable. In the next sequence step, I am
trying to pass some parameters to the Server. But if the Object Class
is an executable I don't see the "SetControlValue" method in the
bottom "Call Method or Access Property". I have to make the Object
Class a Virtual Instrument to see that property. But if I do that the
reference from the previous step does not work.

On the other hand if I select the Virtual Instrument class, I am
unable to create an object an assign it to an ActiveX reference.

How do you create an Active-X reference to the executable Labview
server, then pass parameters to the "Get Poperty Value" subVI in the
server?


If select the Object Class as a Virtual Instrument, the option to
create an Object does not appea
r.
0 Kudos
Message 10 of 11
(4,273 Views)