10-09-2009 11:49 AM
I have an app where the number of AI DAQmx tasks I create are specified in a config file. I have a monitor task that periodically looks at the latest values from all DAQ tasks. I've been doing this with a set of global variables because it was the simplest way to do it. But to do this, I have to explicitly create a separate AI task that uses the hard-coded global variable name for the DAQmx samples. I would prefer to only write one VI for the DAQ loop that writes to a global variable that I programmatically create based on the config file. The only solution I can think of is to use a global variable "pool" that is sized bigger than I expect to need, and then have a big switch case to select which one I want based on the task index. But this sounds pretty silly.
10-09-2009 11:55 AM
Sorry but I refuse to help anyone to use Global varibles. Doing so would be like teaching someone how to play Rusian Roulette!
Instead create an Action Engine that stores an arrays of teh refs you want. Add actions and controls to index out the one you want. Since it willbe an array you can add or delete as required.
Ben
10-09-2009 11:56 AM
10-09-2009 12:06 PM
Wow, what a jerk! I don't see how an "action engine" is any different from a global variable other than being more VI code to manage. In spite of what your old software teacher told you, global variables are not all evil and they still have valid uses. People try to call them different things like singletons or whatever to make themselves feel better, but when you need to represent a global resource to all your threads, there needs to be a variable that has global scope.
10-09-2009 12:25 PM - edited 10-09-2009 12:26 PM
knicewar wrote:Wow, what a jerk!
Gee, that's such a professional response. I'll have to remember your login name for next time.
Both suggestions provided have their merit. Perhaps you should spend a little more time to look into the suggestions and see why they were given by others who clearly have more experience than you do, and less time disparaging those of us who are VOLUNTEERS and try to help those WITHOUT BEING PAID BY NI.
10-09-2009 12:31 PM
Ben wrote:Sorry but I refuse to help anyone to use Global varibles. Doing so would be like teaching someone how to play Rusian Roulette!
Instead create an Action Engine that stores an arrays of teh refs you want. Add actions and controls to index out the one you want. Since it willbe an array you can add or delete as required.
Hey, hey ,hey... In some cases Globals ("as is") also may be fully acceptable! Why to develop you own super-puper bike, while you have already "ready-for-use" bicycle?!
But especially in described case - Functional Globals exactly what he needed.
Andrey.
10-09-2009 12:45 PM
"Gee, that's such a professional response" -- hey, I was asking for help and I get "I refuse to help someone who uses global variables". Who's being unprofessional?
10-09-2009
12:47 PM
- last edited on
10-09-2009
01:11 PM
by
Support
10-09-2009 12:50 PM
10-09-2009 01:02 PM
Hi knicewar,
you ask for something impossible ("programmatically create and use globals"), but don't accept ideas to solve your problem?
I suggested using an (global) array to hold all values and suggested to go one step further in using an AE/FGV to handle the index assigning (you would have to do this anyway). So why not get back to real discussion?