08-17-2012 07:59 AM
Our system contains numerous NI instruments, as well as some GPIB controlled instruments. I know the correct way managing resources when using an instrument is to first initialize it, use that resource/handle to do measurements, then close it when you're finished; we usually initialize a session at the start of our application, and close it when the application exits. I have a need to check for an existing session that may or many not have been created before my vi attempts to access an instrument.
I'm specifically working with the niDMM drivers. I'd like to be able to check for an existing session to an instrument and use that handle if it exists. If it doesn't exist I'll then call the initialize vi for that instrument.
I have LV 2011 but am currently developing in LV 2009 since that is what the target machine is running.
08-17-2012 08:03 AM
08-17-2012 08:23 AM
Gerd,
I haven't thought of using a FGV for handles and like the possibilities that using that method can provide. I may use that when building this very project. There are about 20 different test programs on this particular machine and it's possible that other code may leave the handle open. I can see this on the front panel by looking at the ivi logical name/visa resource name before running a VI (it shows two small computers to the left of the logical name in the combo box). Opening and closing a new session to the instrument works, but I'd like to use the existing session if one exists.
I'm not the one creating the session so I can't put the existing session into a FGV. I'm aware that the other code leaving the handle open needs to be fixed, and plan on approaching that in the future.
08-20-2012 11:10 AM
There is no programatic way to access a list of open IVI sessions, but you can access the list statically by wiring a constant to the "Instrument Handle" of the "niDMM Close.vi". I've attached an image of what I'm referring to.