10-06-2006 06:37 AM
10-06-2006 02:30 PM
I would definitely NOT keep configuring and clearing (I think that's what you mean by open and close) the same task over and over. I would configure once, read many times in my main app, then stop & clear once.
I typically like to package such data acq into an "Action Engine" that keeps track of its own DAQmx task id so I don't need to sling that task id wire around into multiple parallel loops / vi's. Attached is a very stripped-down example for Digital Input.
I would typically do more with error testing and would make the "Action" enum into a typedef custom control, but this gives you the basic idea. The action engine approach works very nicely when there's a small # of different kinds of input parameters and output info needed to support all the necessary action cases. When you start needing a large number of differnent kinds of inputs and outputs to support the desired actions, then you start having difficulty with (1) having enough terminals to wire and (2) remembering which inputs and outputs are meaningful for which actions.
-Kevin P.
10-07-2006 02:45 AM
Hi Kevin,
Yes that sums up my methodology, I am using CVI and posted into LV by mistake however parallels are there and your thoughts are applicable.
The reason that the question came up is that there seems to be a swing to keeping tasks open only for the duration of the task related activities and not for the program run time. I am trying to get a broader understanding of why this is done. The views of other programmers is something I lack working from home as a 'one man band' so to speak.
In the past once I had opened a task be it a file, comms port or a vi session etc I would leave it open for the entire duration of the application. I am now begining to see some advantages to closing and re-opening these tasks, especially with regard to error handling. When I look at the NI samples they seem to echo this method though that could be because they are very small pieces of code.
Anyway, thanks for you considered input which is appreciated. Thats one in support of my existing approach.
Regards
Paul.