LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to programmatically pause a VI?

How to programmatically pause a VI (pause a VI using a front panel button) as if execute Pause on toolbar

0 Kudos
Message 1 of 12
(809 Views)

paul_cardinale_0-1670365459429.png

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 2 of 12
(788 Views)

This is technically correct, but please note that since it's a blue node you won't see it as an option unless you have VI scripting enabled in your LabVIEW options.

 

Also it won't work when using the Run-time engine (i.e. if compiled into an EXE).

 

So depending on your intended use case for this node you may need an alternate solution.

0 Kudos
Message 3 of 12
(764 Views)

@Brot_Sweet wrote:

How to programmatically pause a VI (pause a VI using a front panel button) as if execute Pause on toolbar


Obviously we probably need a bit more information on what you are actually trying to do.

Do you want a VI to pause itself or control pausing from another VI?

Should there also be a way to programmatically un-pause? (obviously, a VI cannot un-pause itself, because it is paused, i.e. not running. 😄 ).

 

Typically, a pause is implemented as one of the states of a state machine.

0 Kudos
Message 4 of 12
(706 Views)

@altenbach wrote:

 

Typically, a pause is implemented as one of the states of a state machine.


Would it be feasible to do a pause by triggering an event case with while loop in it? And unpause then by terminating that loop?

Or would that mess up all sorts of things because events aren't meant to be executing for that long?

0 Kudos
Message 5 of 12
(688 Views)

@AeroSoul wrote:

@altenbach wrote:

 

Typically, a pause is implemented as one of the states of a state machine.


Would it be feasible to do a pause by triggering an event case with while loop in it? And unpause then by terminating that loop?

Or would that mess up all sorts of things because events aren't meant to be executing for that long?


No, that's a really bad idea! Interactive loops never belong inside an event.

 

One possibility would be to keep the event timeout in a shift register and toggle form finite to infinite (-1) with an event. (example)

Message 6 of 12
(682 Views)

Sorry, where can I find this VI?

0 Kudos
Message 7 of 12
(628 Views)

@altenbach

 

Well, I am programming a QMH, which has many cases (start, load files, run files and so on), the trouble I'm trying to resolve is this:

 

When I get on the case of 'Run Files', I want to implement a 'Pause Button' as if it were the 'Pause' next to 'Abort execution' in the toolbar (I´m not sure about the name of this Front Panel part), to be more specific, the Producer Part of the QMH is the same as all the QMHs examples, now, the Consumer Part of the 'Run Files' case, is conformed by 2 'For Loops', one inside the other, the first For Loop (the bigger), execute a 3 frames sequence structure, in the first frame of said structure is the second 'For Loop' (the smaller), it has another sequence structure to highlight some cells of a Table Indicator, so imagine that you has some spreadsheet and when you execute a code every line highlight at the moment each one was running, it will be yellow, the green; the 2 remaining frames of the BIG For Loop are not too important.

 

0 Kudos
Message 8 of 12
(625 Views)

Hi Brot,

 


@Brot_Sweet wrote:

When I get on the case of 'Run Files', I want to implement a 'Pause Button'


Then you should implement a proper statemachine!

 

Right now there is a pile of loops with a bunch of sequence frames - with no good option to place your "pause" feature anywhere!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO
0 Kudos
Message 9 of 12
(618 Views)

Well your program architecture has to be designed to be paused from the beginning. 

 

IMHO: The simplest architecture for this is an Event Driven State Machine (EDSM) then you could have a "Pause" state triggered by a button press.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 10 of 12
(605 Views)