LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to interrupt a task in producer consumer loop

Hello,

I actually work on a program to control a power supply and read datas from a current sensor with a DAQ (Ni-USB 6009 from NI). For this, i use a producer/consumer template and I would like to create an emergency stop button. I arlready create a button that allows to delete the queue and add a STOP task to it.  My problem is that with this emergency button i want to kill the actual task because some task can last 1minute. And with an emergency i want to stop the actual task and launch the stop sequence to switch off the power supply. I don't know i to stop my task and after launch a sequence.

 

You can find the file with VI and SUB-VI, The right Vi is "Software banc d'essai V20" 

 

Thank

Hugo

Download All
0 Kudos
Message 1 of 4
(784 Views)

Hello,

 

if you want to abort the code currently running in the consumer loop, you'll have to use another means of communication between the two loops besides the queue.

This could be as simple as polling the state of the button inside the task.

 

Best regrads,

Florian

0 Kudos
Message 2 of 4
(774 Views)

By using a FGV you can set a value (Stop boolean) into an event in your producer loop and it will be read into your sub vi from the consumer loop.

That stop action can kill your running sub vi and then you can clean the queue, or put in first position of the queue a specific action.

 

Be sure to init the FGV and also to set it only in one place to prevent race issues.

0 Kudos
Message 3 of 4
(765 Views)

As an aside, I would pull the error wire out of the lower loop and merge it with the one on the top and destroy the queue after it.  Dataflow would then avoid a potential issue with the queue being destroyed before the bottom loop has finished working on the remaining elements in the queue.  Since both inputs to the merge error need to be satisfied before it executes, it would have to wait for the input to arrive from the lower loop, and the only way that happens is if the bottom loop has exited, meaning it is done processing the queue.  The code then continues and destroys the queue.  (This could be especially concerning if it destroyed the queue before you could do a cleanup or an exit.)

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 4
(733 Views)