LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect Front Panel ToolBar Abort Button?

How can I detect the Abort Button being press on the Front Panel Toolbar and set up a graceful exit to a Labview Program with sub Vis? 1st subvi is running a while loop. The sib vi below that is a process consumer loop using queues.

 

Thanks,

Greg

Greg
0 Kudos
Message 1 of 8
(4,839 Views)

The abort button is a last resort and shouldn't be used to stop your application. The only time your application should be force stopped is if the nuclear power plant is about to blow.

 

You should create a Stop button on your front panel that you use to trigger the exit of the application. You can stop a producer consumer architecture by closing the queue reference after the producer loop ends and then handling the error that the consumer loop generates as a stop command.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 8
(4,834 Views)

You can remove that abort button while your VI is running so that your user is unable to press it.  Then, they're forced to either use a stop button or the red X to close out.  You can detect both of these easily with the event structure and transition to your safe closing code.

0 Kudos
Message 3 of 8
(4,825 Views)

@natasftw wrote:

or the red X to close out.


Darn, I was trying to not bring up a slightly more complicated event trigger. I swear half of the people who ask about that Close Panel event end up not using the "?" event or not Discarding the event properly when they have an Exit case.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 4 of 8
(4,795 Views)

True, it is the slightly more complicated example but how many commercial/professional applications do you use that have a stop button? I'd gather not very many - you close applications using the red X in the corner so even though it's a little more complicated it provides a better user experience and you should always handle the panel close? event anyway!

 

As a basic instruction on how to handle the window close...

1) Create an event structure in a while loop (assuming you don't already have events...if you do, use the existing event structure)

2) Create an event case for the Panel Close? filter event

3) In the event case, use some sort of messaging (e.g. a queue in a producer/consumer) to send a message to your main application loop to exit and wire a true to the Discard terminal (so it doesn't close the panel)

4) Exit the event structure by either...a) wiring a true to the stop terminal in the panel close? event or, more preferably, b) create a boolean 'exit' user event and fire that back to the event structure to 'stop' the event handling loop

5) Call the Front Panel.Close method on your VI to close the panel after everything else has finished (e.g. shutdown routine etc.)

6) Modify your VI properties to hide the toolbar when running to hide the 'Abort' button

 


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 5 of 8
(4,751 Views)

Due to the Labview Code Structure, and the High Power involved, I was trying to improved the program abort function. I am considering "hiding" the Abort Function and creating a event for Panel Close.  This would be similar to my current "Stop" Function.

 

It seems it takes longer to abort  than it should or does not seem to be stopping the while loops has it should. The Main program "STOP" button feeds a global variable that should exit all sub vi while loops. I would like to see it react in a under 2 seconds. I found the Front Panel Property for Abort. I feel that is will not give an orderly shutdown. The lower vi is runnng the measurement and control system  and its sub vi is running the CanBus Communication  Processor Consumer Loop to monitor the communication.

 

I am using event structures. The Stop Button has its own event that feeds the global variables.  The global variable is "OR" gated into each while loop.  The Or Gate is for the test timer time  out or "stop".

I tried adding a Error/No Error to the consumer loop to prevent Queue Error from being displayed. That seems to be where I had the new issues developed.

 

Greg
0 Kudos
Message 6 of 8
(4,737 Views)

Shep_Ametek wrote:

It seems it takes longer to abort  than it should or does not seem to be stopping the while loops has it should. The Main program "STOP" button feeds a global variable that should exit all sub vi while loops. I would like to see it react in a under 2 seconds. I found the Front Panel Property for Abort. I feel that is will not give an orderly shutdown. The lower vi is runnng the measurement and control system  and its sub vi is running the CanBus Communication  Processor Consumer Loop to monitor the communication.


Hard to debug that without code.  But it sounds like you have a loop waiting for a command or loops that take more than 2 seconds to iterate.

 

In my opinion, the global variable for Stop should never be used.  Each loop you have should be recieving data/commands via a notifier, queue, user event, etc.  One of those commands for each loop should be a Stop command.  This will then allow for a proper shutdown with each loop taking care of their own stuff.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 8
(4,728 Views)

You are implying that you can use different function to notify the sub vis of the "Abort".   What are you implying is the best way to implement this "Abort"? 

 

I could switch queue at the upper level from emunerator based loop control as improvement. I have not used notifiers or semophores.

 

Code is A350 SCx 10854 10855 ESS 31 Aug 2015.vi found in the attached.  Due to NDA restrictions,  I can not post the Canbus communication vi.

 

 

Greg
0 Kudos
Message 8 of 8
(4,719 Views)