Jump to content

Custom Driver Design


Recommended Posts

I am developing a PXI chassis as an instrument and I was hoping to get some feedback on some design ideas I had. The PXI chassis will need to interface via both GPIB and Ethernet. The chassis has simple command and respond functionality (no synchronization or complex interaction). To accommodate for this dual form of communication, I thought of the following solutions.

1. Have a functional global. Initialize the FG to be communicating either GPIB or Ethernet, then keep that decision inside the FG. Make all calls to the PXI via this FG.

2. Have a series of VIs similar to DAQmx. The different functions of the PXI (Start, Stop, Setup, etc.) would each be handled in a separate VI. These VIs would be wired together with some sort of handle.

2a. Have a custom "handle" that contains whether we are talking GPIB or Ethernet and the appropriate refnum and VISA name.

2b. Have two separate versions of the VIs, one for GPIB and one for Ethernet. (I don't like the code duplication on this one...)

Does anyone have any opinion of implementing #1 or #2? Or is there some other method that I should consider? GOOPy ideas are welcome.

David

Link to comment

QUOTE(dsaunders @ Feb 15 2007, 08:03 PM)

I would still appreciate if someone has an opinion about which choice is *better*.

I suppose that depends on what you want to do with the code.

The first type is much easier to use. For instance, I use that for communicating with a database, where I can simply have a function "List XXX.vi" which will return a list of whatever and I don't have to wire the connection refnum all over my code, because each of the functions which communicate with the DB starts by calling a functional global which is responsible for managing the connection (opening, closing, getting, checking validity).

If I wanted to have more than one DB, however, then I would either need to duplicate all the code (bad), give a name to each function (not very efficient) or pass a reference to my instance (what's done by basically every implementation and can make you pass wires all over your code).

I would say that if there is a chance that you could have more than one instance of this, then you should use one of the GOOP frameworks and create a class for this. If you don't, going the FG way is more fun, but just be sure to mind your reentrancy (if you're calling the VIs in parallel).

Link to comment
Link to comment

QUOTE(dsaunders @ Feb 15 2007, 10:37 PM)

I guess at this point I have a related question - For a collection of related functions where no storage is needed (or is provided by an internally called FG) is it advantageous to have a single FG with multiple operations, or to have multiple VIs clearly showing their function?

Personally, I prefer multiple VIs.

Yes, it means that there is some code duplication (in my case, all the VIs call the manager VI and pass the reference coming out of it into the SQL query generating VI and those two could probably be outside the case structure if this was a single VI), but that is minimal and you avoid having a single huge VI and avoid having to select the value from an enum with many values. Instead, I can split my VIs into directories based on functionality.

For a small number of functions, however, the single VI approach might be more convenient.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.