DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Differentiating multiple instances of DiaDem

I am using the toCommand interface to connect to two different instances of DiaDem. I would like to somehow differentiate between the two instances. For example, have one DAC running in one, a different running in the other, and run two different scripts on each. I need a way to know which instance I am connecting to. Is this possible? Is it possible to select which instance you connect to using the toCommand interface?

edit: I am using DiaDem 10.

Thank you for your help,
Luke

Message Edited by LukeW on 08-29-2006 10:37 AM

0 Kudos
Message 1 of 5
(3,925 Views)

Hi Luke,

If you don't already have a version of DIAdem launched when you open the first ToCommand reference, then a new "dependent" DIAdem instace will be created.  This "dependent" instance will not close until the calling program ends or releases the reference, and it will end automatically as soon as the calling program ends.  In this case the second reference you open will create a second "dependent" DIAdem instance.  By keeping these two references active in the calling program, you should be able to manipulate the two DIAdem instances separately.  In LabVIEW this would be a reference wire, and in VB or C this would be an object variable returned from the ToCommand server.  You would simply use the first reference wire or object variable to control the first instance and the second reference wire or object variable to control the second instance.

If instead you have a version of DIAdem already launched when you open the first ToCommand reference, then the reference wire or object variable returned will operate on the existing "independent" DIAdem instance, and no new instance will be created.  In this case the second attempt to open a new reference would simply trump the first, so that both point to the same pre-existing DIAdem instance.  The "independent" DIAdem instance does not close when the reference is released.  This is a feature, because with this approach you do not have to launch DIAdem every time you want to remote control it.  There is a registry key you can tweak to cause every reference request to create a new instance, if you prefer.

Clear as mud?
Brad Turpin
DIAdem Product Support Engineer
National Instruments

Message 2 of 5
(3,898 Views)

Clear as crystal. I've been playing around with this setup for a while and your clearer description matches the idea that was already forming in my head.

In our current setup, we have a completely separate script calling an outside program, which in turn creates the ToCommand objects runs a script in each DiaDem, then is closed. This is called multiple times, each time creating and destroying the ToCommand objects. It is of course not optimal, but it is what we have to deal with at the moment.

Now the odd thing, I have found that the COM connection works....the first time, then on subsequent openings it creates entirely new instances of DiaDem. Here is how things occur.

1)Open two instances of DiaDem (v10)
2)Open my test program which creates two ToCommand objects
3)Play around, assuring it has properly connected to both instances (yay, it must work)
4)Close my program (both independent DiaDem instances are still open)
5)Reopen my program, examine results (nope, doesn't work)

At this point, there are actually four instances of DiaDem open, two independent, and two dependent. Currently, the "instances" flag in the registry is set to "1" as I have found that with it set to "0", it will never connect to more than one instance of DiaDem.

So I guess to reiterate. Is there any way to target specific instances of DiaDem with the ToCommand object, or even at least to tell instances apart after connecting to them (with some kind of ID). It seems that our current setup may be impossible to use with two different instances. Perhaps I could open a program which held the objects, and then create a second program which send the first program the commands which I would like to execute. Certainly not an optimal solution, but it would probably work.

Whew. Sorry about the long post. Thanks again for any help.

-Luke

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

Hi Luke,

There is no way to "target" a particular open DIAdem instance.  You either create a new "dependent" DIAdem instance (1) each time or target the most recently launched "independent" DIAdem instance (0).

The only way I know of for you to get what you want is to start with NO DIAdem instances launched, then have a new DIAdem instance (0) created each time you open a reference.

Try the below again WITHOUT step 1),
Brad Turpin
DIAdem Product Support Engineer
National Instruments

 

0 Kudos
Message 4 of 5
(3,871 Views)
Hi Brad,

Thanks for the help.

In the end I created two programs, one that stays open throughout the duration of the measurement keeping both instances of the ToCommand object alive, and a second command line program that sends Windows messages to the other, indicating which script to run. It is a seemingly convoluted solution, but works pretty well. One simply opens the first program, and then runs the second with command line arguments indicating which scripts one wants run.

If people are interested I could post the source. It is written in VB.net 2.0.

-Luke
0 Kudos
Message 5 of 5
(3,800 Views)