LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to add a pause button to a application

Hi Friends,

 

Currently i am in a requirement to add a pause button to my applciation.

My application in detail is involved with lot of sub VI's and the entire VI structure is the frame sequence.

 

So i want to provide the user a provision to press a pause button which pauses the entire operations for a while and proceeds once he re-clicks the same.

Please help me in providing any exapmles if u are having the same requirement.

 

waiting for ur reply with examples

 

Regards,

Suneel.V

0 Kudos
Message 1 of 7
(4,511 Views)

Suneel.V

 

It will be difficult to do what you want with your current architecture. A sequence structure will execute each frame in sequence until all are finished.

 

If you convert it to a state machine architecture, then at the completion of any state the pause button could cause the next state to be an Idle state.  There are shipping examples of state machines, although I do not recall whether any have a Pause.  I have written many programs with pause.

 

Lynn 

0 Kudos
Message 2 of 7
(4,504 Views)

John,

 

You are correct,

But i know the entire flow of my operation will be done in a particular frame No:3.

 

So i am planning to add a Case structure with a While loop internally.

The control of the while loop i will give it to the user.

 

Does it works?

 

Add ur comments.

 

Regards,

Suneel.V 

 

0 Kudos
Message 3 of 7
(4,498 Views)
Choosing the flat frame sequence as the base of your architecture will make this more difficult than it has to be.  If you had used a state machine it would be a very straightforward addition.  Without seeing your code, I can't see a way for you to do this without checking to see if pause was pressed each time you enter a new frame.  You could use an Action Engine for this, if you had a seperate loop running that would feed a pause into the action engine which would in turn would be read at some point in each frame of the sequence structure (or subVI depending on how deep your VI hierarchy goes).  For the action of pausing the program you will have to connect a boolean Paused? output of each action engine to a Pause! vi that would contatin something like a while loop with a wait and an action engine read inside that would stop the loop when the play command was sent.  As I said, I recommend using a statechart!  Check this post out for info on action engines.
0 Kudos
Message 4 of 7
(4,496 Views)

Suneel.V,

 

That may work.  Put  a small delay or wait inside the loop so that it does not become a greedy loop and consume all available CPU cycles.  Look closely at the dataflow inside that frame to make sure that the pause will actually stop whatever is going on.  You may need to put everything inside the while loop with a case structure connected to the Pause button.  Whether that will work depends on how the task is configured when not paused.

 

Even if you get it to work now, be aware that the next modification or the one after that will be more difficult to get working.  At some point the time it takes to rewrite it as a state machine will be worth the effort.

 

Lynn 

 

 

Message 5 of 7
(4,489 Views)

Yeah, that worked pretty much; Another thought: What about an OK button?  Could we make it popup a window with a message, and have the program sit idle and wait for me to click OK or something?

0 Kudos
Message 6 of 7
(4,143 Views)

braber,

 

You posted to a thread which is almost two years old.  It might have been better for you to start a new thread and completely describe what you are trying to do and what probelms you are having doing it.  Your comment was not very clear: What worked? And what did not quite work the way you expected?

 

Certainly pop-up subVIs have been used for a long time.

 

Lynn

0 Kudos
Message 7 of 7
(4,131 Views)