LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

progmatically stop vi with producer/consumer architecture

I can't seem to get my VI to fully stop, so that I can go on to do some more things in the program.  I am trying to progmatically stop the vi (pictured below), so that I can return to my main gui (not pictured).  The main gui just consists of a login, exit test system, and run test.  Once the user presses run test, the vi pictured below opens.

I am using a producer/consumer architecture with a state machine.  The problem I run into is that when I press the "Main Menu" button, it should close the pictured vi and return to the main gui.  I tried using the vi server, and when the user presses the Main Menu button, it fires an event and then it goes to the Stop state in the consumer loop, which opens a reference to the vi's (one for the strip chart vi and another for the gage vi), closes the front panel using an invoke node and then closing the reference.  I also tried adding in the abort vi method after the close front panel and it still gave me the same result.

Here is the catch, it does close the vi's, but it does not stop the while loops (producer and consumer), or it stops only one of the loops.  I thought of putting in a constant in the event structure for when the Main Menu event is fired, but that will stop the producer loop before the consumer loop reveices the info to go to the stop state, so the consumer loop does not end.

I also tried a "dummy" control that was connected to the comsumer loop Stop terminal (for the while loop), and then progmatically changed the value in the stop case to true and then read that value in the producer loop to, hopefully, stop both loops, but it did not work either.

I am sure that it is something so stuipidly simple that I cant see it right now

Kenny
Kenny

0 Kudos
Message 1 of 6
(3,011 Views)
Hi Kenny,
I think of two solutions to your problem. First, use the message queue to pass the message "stop" or something from producer to consumer or second (and I think, better), use occurrences. I made a little draft how it could work.

   You have to pass the occurence- Refnum to both VIs, the producer and the consumer, when the producer finishes execution, then use "Set Occurence".

   In the consumer blockdiagram you react on the generated occurrence.

If you set in the VI- properties "Open Frontpanel when called" and "Close if originally..." the VI Frontpanel should disappear itself when execution is stopped.

Hope this helps,
Dave

Message Edited by daveTW on 08-14-2006 04:53 PM

Greets, Dave
Download All
0 Kudos
Message 2 of 6
(2,995 Views)
When Using the producer consumer model I like to use the queue error state to end the consumer loop.  After the producer loop terminates I flush and kill the queue.  The next itteration of the dequeue will terminate the consumer loop.  No extra variables or mechanisms and has a true producer/consumer relationship.
 
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 3 of 6
(2,983 Views)
Thank you both for your input.  I kept getting caught in the Wait for occurance to time out, so the rest of my vi would not execute until there was an occurerance (probably b/c I was doing something wrongSmiley Surprised), so I ended up using the error to kill the vi.
 
Thanks again,
 
Kenny
Kenny

0 Kudos
Message 4 of 6
(2,974 Views)

Hello

 

How can I use a cancel button when using a producer consumewr que to cancel a for loop in a consumer event?

Thanks

Tim C.

1:30 Seconds ARRRGHHH!!!! I want my popcorn NOW! Isn't there anything faster than a microwave!
0 Kudos
Message 5 of 6
(2,565 Views)


Tim C. wrote:

How can I use a cancel button when using a producer consumewr que to cancel a for loop in a consumer event?


Duplicate Post.  This question has been asked and answered here.
0 Kudos
Message 6 of 6
(2,549 Views)