LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to clear a DAQmx task by task name

Hello,

in my current project I am putting together a DAQmx task dynamically by letting the user choose which DAQmx Global Channels he wants to read out during the measurement procedure. This is working just fine, as can be seen in the attached "chosen_channels2task.vi". To this point I have string constant "WPS_meas" wired to the "DAQmx Create Task" funtion. However it might be better programming style to change this into a control for better scalability later on.

Now the user is currently able to abort the program which means that a programmatic "DAQmx Clear Task" may not always be performed when in fact necessary. As in such a case the DAQmx task remains active it cannot be created again (i.e. restarting the program) and an error will occur. To make sure this cannot happen I wanted to write a small SubVI to read out all existing DAQmx tasks and simply clear them no matter if they are in memory or not. I used the "DAQmx System Node" to accomplish that, see attached "clear_all_tasks.vi".

Unfortunately the dynamically created DAQmx task "WPS_meas" from "chosen_channels2task.vi" is not shown in the list created by the "task"-property of the "DAQmx System Node".

So how can I programmatically clear this task without knowing its name in the first place. Of course I can hard-code the clear task with the exact same string constant wired to the "DAQmx Clear Task" function. But this rather seems to be bad style to me.

Any suggestions? Could possibly the "auto cleanup" switch at "Create DAQmx task" help me out here?
Download All
0 Kudos
Message 1 of 5
(3,946 Views)

Hi,

I could not open your code as it is in 8.0.1. But I guess Auto cleanup is the best way to clean all types of tasks created.

 

If you want to have some default configuration done , you can do the same during initialization of the system.

 

Hope it helps.

 

Regards

CLAD
Using Labview 5.1,6.1,7.1.8.0
0 Kudos
Message 2 of 5
(3,941 Views)
Unfortunately LabVIEW can't save the VIs for v7.1, saying it can't convert VIs from a toolkit to a previous version. Maybe someone else using LV8.0.1 could also take a look at it. I can go and use "auto cleanup", however this leaves me with a code where a potential debugging programmer has to realize by himself that I don't explicitly clear the task on purpose and HAVE TO use auto cleanup.
I believe there should be a way of getting the information about any DAQmx task active in LV, even the ones not registered in MAX.

Message Edited by comrade on 10-26-2006 12:42 AM

0 Kudos
Message 3 of 5
(3,925 Views)

Hello Comrade,

probably the right way to solve your question is to use functional global variables.
I have attached two new vi. Please take a look at it.
The first one is the working application and the second one is the functional global variables.
You can also use this variable to put date into another VI.

I hope this helps.

Regards,

AmirG

Download All
0 Kudos
Message 4 of 5
(3,915 Views)
Thanks, AmirG!
 
In fact this is a good way of not having to draw the DAQmx task wires all through my program in order to clear the task at the (rightmost) end of the block diiagram.
 
However the possibility of cleaning up the task when starting the entire overall program is not featured with this solution. As LV realizes whenever I try to re-create that specific task, there must be a way of getting its name (or at least ALL names of all tasks) currently active.
 
I am now thinking of fetching the error when the task is tried to create and then act respectively:
If no error occurs - the task is already created.
If an error occurs - clear it and re-create it with the currrently chosen channels.
 
If anyone still has a clue how to obtain really ALL active task names in LV, I would appreciate a comment on this. Otherwise I think the error fetch should be it.
 
Thanks for your contributions, people! 🙂
0 Kudos
Message 5 of 5
(3,900 Views)