08-29-2006 10:36 AM - edited 08-29-2006 10:36 AM
Message Edited by LukeW on 08-29-2006 10:37 AM
08-30-2006 09:57 AM
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
08-31-2006 01:38 AM
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
08-31-2006 09:36 AM
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
09-06-2006 04:22 AM