Dear NI Community,
let me, please, ask you about the following.
I have two HAL classes, which represent DMM and Switch devices. They have methods like Read configuration, Init, Deinit, specific configuration, do some actions (depends on the device, DMM or Switch). These classes are separated, as two different HALs, libraries.
Now, I have device which is Multifunctional Switch/Measure Unit - it has slots, where one can put switch modules, matrix modules, relays modules, etc.; and it has internal DMM which allows to measure current, voltage, resistance, etc.
I can communicate with device, let's say, by VISA. There are drivers for the device, via which I can control it.
And I'm just thinking - can I combine my two HALs for DMM and Switch to one HAL Switch/Measure Unit? B/c indeed, it includes those two devices. But the problem is, that DMM and Switch units are implemented in a way, that they obtain VISA (or some other) reference for communication with device in method Init, and then keep that reference in private data.
With this approach, I can't two times init my Switch/Measure Unit, b/c it's simple COM port, and I'll have error during opening it the second time.
The solutin could be, to create some abstract class/interface, which will allow to pass into DMM HAL and Switch HAL opened reference to the device. And then, my Switch/Measure HAL will have method open reference to device, and pass it to DMM HAL and Switch HAL.
But, this will break DMM HAL and Switch HAL, because as stand-alone devices they don't need this method at all.
Are there some common approaches to this task? Some examples of how to combine several HALs to one, when they indeed share some resource, which is private in their implementation? I've heard about MAL example from Elijah Kerry, but I'm not sure whether this is what I need... Are there some examples for this task?
Or I am doing something wrong, and my HALs are not properly designed then; and I don't need to keep reference to device in private data of HAL implementation, but it should be some abstraction, which will be contained in HAL definition?
Thank you very much in advance!
Sincerely, kosist90
![logos_middle.jpg logos_middle.jpg]()
JKI VI Tester – useful tool for LabVIEW developer