From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

IVI session handle in HAL

Solved!
Go to solution

I have a question about the IO handle for instruments in my HAL library

There is a base instrument class with private data of VISA string, VISA reference, IVI session handle. DMM, Power supply classes inherit from Base instrument class. 

 

When a connection to a DMM (niDMM driver) is opened, the instrument handle could not be written to IVI of the base instrument class because of class conflict of IVI handle( IVI session of class IVI and class NiDMM). What is the solution for this

 

1. Should I create a IVI session handle of niDMM class type in Base instrument class? If so, wouldn't thtat break abstraction 

 and if I were to use some other drivers, I have to add its type...

2.  Should I cast the handle (NiDMM to IVI) with in the driver class and write to the generic IVI session handle in the base instrument class.

Suggestions are welcome 

 

0 Kudos
Message 1 of 4
(2,535 Views)

How about using a string as the resource identifier in the base class? Then it's compatible with practically anything. And let the instrument class hold the IVI-reference or whatever type it has.

Certified LabVIEW Architect
0 Kudos
Message 2 of 4
(2,512 Views)

I am already saving the resource identifier in the base class. The problem is, with different drivers for a specific instrument, DMM for example, the IVI handle after opening a connection are of different types. Hence I cannot save it in the Base or instrument classes as they have to be generic...

0 Kudos
Message 3 of 4
(2,509 Views)
Solution
Accepted by topic author StewieRupert
@StewieRupert wrote:

I am already saving the resource identifier in the base class. The problem is, with different drivers for a specific instrument, DMM for example, the IVI handle after opening a connection are of different types. Hence I cannot save it in the Base or instrument classes as they have to be generic...


Thats why I suggested you save the IVI-handle of for a specific instrument class in that class. Then you use it internally in that class only and never need to bother about it, and can have any type of instrument-reference in different instrument classes, while still having the resource string in the base class.

Certified LabVIEW Architect
0 Kudos
Message 4 of 4
(2,505 Views)