LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic dispatch VISA and net

Solved!
Go to solution

Hi,

 

I am learning to use LVOOP. I want to have hardware abstraction layer (HAL) for my test program so it works for different instruments.

 

Most of the instruments are connected to the computer using GPIB so I can use VISA.Therefore, I created a hardware abstraction class called "meter" with a VISA as its property. So I have a dynamical dispatch VI called write VISA. This can work if all the child instruments are communicated with VISA.

 

However, one instrument is connected using USB and the vendor's instrument driver is .Net. So this one instrument won't work with dynamical dispatch because I can't using write VISA.

 

What is the best way to handle this situation?

 

Thanks,

Joseph

0 Kudos
Message 1 of 11
(3,744 Views)

You can almost always communicate with equipment using VISA.  That said, you may have to break out the equipment programeer guide and write your own driver.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 11
(3,741 Views)

The instrument I was talking about is Newport 1918-C power meter. I think Newport only provides a dll.

 

http://forums.ni.com/t5/Instrument-Control-GPIB-Serial/can-t-connect-to-Newport-1918-c-power-meter/t...

 

Joseph

0 Kudos
Message 3 of 11
(3,737 Views)

This would be an idication of a poor OOP design. What would be a prefered design would be to define a base class which contains the common methods for the device family you are abstracting. Rather than having a generic write you are better off to define methods interms of functionality , such as set power. You could make these methods be pure virtual which means chilredn classes must provide an implementation for that method. With this design you cannot create an instance of your base class but would create the correct child instance which is specific to the particular meter you are using. Also, having a method called "writeVISA" implies th eimplementation. Which as you found out makes it difficult for your to create USB or TCP implementations. If you want to provide a generic write methos simply call it write. Again, force the child classes to provide an implementation pof the method and they will provide the correct code necessary to communicate with the device. it may uise VISA, the native TCP or can and string methods. It doesn['t really matter. It is up to the child class ro provide the specific implementation.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 11
(3,736 Views)

Thanks for your response.

 

I think I didn't express myself clearly. I have all the members of my parent meter class, such as read power, being abstract. The child classes implement the detail communication with individual instruments.Then the main app only uses the dynamic dispatched parent VIs.

 

The only problem is the "write VISA", which I meant is write the private class property VISA refnum. I should say "write VISA property", to be more clear. I need to provide a VISA refnum to this dynamic dispatched VI, but one instrument does not use VISA :(.

 

I could using another connector to provide .net refnum, but I would like to see if there is a more elegent way to handle this problem.

 

Thanks,

Joseph

 

0 Kudos
Message 5 of 11
(3,725 Views)

The .NET refnum should be an element of the private data for the class that uses it. The VISA refnum should also be part of the class private data, although if nearly all your classes use it I could understand if you make it part of the parent class data and leave it unused for the class that uses .NET.

0 Kudos
Message 6 of 11
(3,718 Views)

Thanks for your response.

 

Yes, I think VISA refnum can be either in the parent or child classes.

 

My difficulty is how to pass the instrument refnum, either VISA or .net, to the corresponding instrument class through a dynamic dispatched parent class VI from the main app. You must chose something that can be either VISA or .net, or you use two connectors....

 

Thanks,

Joseph

 

 

 

0 Kudos
Message 7 of 11
(3,714 Views)

Again, the VISA or .NET refnum should be part of the private class data, so it will be passed automatically through the dynamic dispatch system. When the VI is called through dynamic dispatch, it will have access to its class private data, which will contain the appropriate refnum. You need an accessor VI to set that refnum initially, when you first select which instrument type to use (or, you might have an initialize function for the instrument that creates the refnum itself, especially in the .NET case).

0 Kudos
Message 8 of 11
(3,709 Views)

Thanks for your reponse.

 

I have some codes in my main program to scan all the instruments connected to the computer and pop-up to a menu ring control. When the user selects or changes the instrument, the corresponding child instrument class will be use. But the main program must write to the child private class what the instrument ref is, either VISA or .net. Once this step is done, the child class implements the parent members, such as initialize, reads power, and close, etc.

 

So the real problem is how I can write the VISA or .NET instrument refnum from my main app using dynamic dispatch terminal to the child class.

 

It seems that the connector must be the same type. So I cannot write VISA or .net refnum using the same dynamic dispatched terminal...

 

Thanks,

Joseph

0 Kudos
Message 9 of 11
(3,704 Views)
Solution
Accepted by topic author joezhang

Why do you need to use dynamic dispatch to write the refnum? Somewhere in your code you must select a specific instrument instance, maybe using a case structure. At that point you could also include initialization code for the specific instrument. In the VISA case you might write the refnum, and in the .NET case you could call the constructor (that is, create the refnum inside the class, don't pass it in from the outside).

0 Kudos
Message 10 of 11
(3,700 Views)