Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

NIDAQmx: check task state

Solved!
Go to solution

Hello,

 

is there any way to check the state a task is currently in? (I just need to differentiate between started and not started).

In my application I want to create a task, and then a future command will start it if it's not running already.

 

Thanks!

--Cristina.

0 Kudos
Message 1 of 5
(3,484 Views)
Solution
Accepted by acgrama

There is a task property node but the only state information you can get out of it is whether or not it is done running, but there is also a VI that does that for you (Is Task Done.vi).

 

You could also attempt to start the task running and if it already is you will receive an error that you can use to identify that the task is already running.  You can then clear out the error with the Clear Errors.vi so it does not disrupt the rest of your code.

Doug Farrell
Solutions Marketing - Automotive
National Instruments

National Instruments Automotive Solutions
0 Kudos
Message 2 of 5
(3,474 Views)

Thank you for the explanation!

I'm sorry -- I'm afraid I forgot to mention I am working via C++. Could I perhaps apply the approach you mentioned there -- start the task and see if it starts without error? Or will an already running task be restarted if I start it again? (Haven't worked with VIs, so I am not sure if there are differences between their behaviour and the C++ behaviour). The help manual did not mention anything in this direction.

 

(Of course I could use a boolean flag that I set manually to false after task creation and to true after task start and check it later, but I thought it would probably be more elegant/efficient if I used a dedicated NIDAQmx function).

0 Kudos
Message 3 of 5
(3,470 Views)
Yep, the exact same approach should work.  The driver is the same in both LabVIEW and C++.  All of the VI (LabVIEW functions) have equivalent C functions.
Doug Farrell
Solutions Marketing - Automotive
National Instruments

National Instruments Automotive Solutions
0 Kudos
Message 4 of 5
(3,468 Views)

Great, thanks a lot!

--Cristina.

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