03-06-2009 06:55 AM
Hi,
We are designing an Instrument Driver for our devices. We do have VI's that does the same operation but with different Inputs and this Input is a cluster of references.
I would like to gain knowledge if all this VI's can be clubbed together by making those clusters as global variables. Through this way I hope we will significantly optimizie our code.
We are also looking for the drivers to get certified by the NI so looking for any sort of solution if making global won't be a good solution for achieving optimization.
Thanks In Advance,
VIvek
Solved! Go to Solution.
03-06-2009 09:04 AM
I don't quite understand what you mean by "clubbed together". Using global variables will not magically make your code more efficient. There's uses for global variable, and there are places where they should not be used. A reasonable use is to hold data used by muliple processes, though a queue is in most cases a better way to go.
The best way to see how to write an instrument driver is to download recent instrument drivers from the NI Instrument Driver Network. Look for the ones that are project-based as these are done in 8.x and are quite recent. Don't bother with the old drivers - they're a mess. You should be able to find something that's similar to your instrument and use it as a template. There's also an Instrument Driver Wizard that comes with LabVIEW. Another source of information is the NI Knowledge Base. Do a search, and you'll find lots of information. Like this: Developing LabVIEW Plug and Play Instrument Drivers.
You should also read over Ben's nugget on Action Engines.
03-09-2009 02:16 AM
Hi,
By clubbing together mean i want to create a generic VI. Now this VI will work with different different control Input but the logic for all of them is same. Hence I am looking for something like a global variable that will hold the appropriate Cluster and hence want to know whether the usage of global variable in the instrument drivers are accepted or not.
Thanks in Advance,
Vivek
03-09-2009 08:05 AM - edited 03-09-2009 08:11 AM
teststand wrote:...and hence want to know whether the usage of global variable in the instrument drivers are accepted or not.
Thanks in Advance,
Vivek
I view "with a jaundice eye"* any code that uses a global variable.
I suggest you do a search on "globals evil" to get a feel for how globals are viewed.
Ben
* Shakespeare, Hamlet Act I Scene 2 (?)
03-09-2009 09:22 AM