LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Checking for existing instrument session

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.

Why do geeks think Halloween and Christmas occur on the same day?
Because 31oct = 25dec!
0 Kudos
Message 1 of 4
(3,177 Views)

Hi Mustang,

 

this calls for an FGV approach: Store the handle in a FGV. In the FGV you could easily store the state of that handle (empty/initialized/in use/any other)...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 4
(3,174 Views)

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.

Why do geeks think Halloween and Christmas occur on the same day?
Because 31oct = 25dec!
0 Kudos
Message 3 of 4
(3,169 Views)

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.

Systems Engineer
SISU
0 Kudos
Message 4 of 4
(3,147 Views)