LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop/abort an event case once started without stopping the main while loop?

Hi,
My problem is once I start an event case - for e.g "start, value change", I have to wait till it's completed, only then I have user control again. This is troublesome if the event take hours to complete, I do not have the option of pressing any buttons while the event is running. Is there a way I can use a control button to abort or quit the current running event? I'm only looking to stop/abort the running event and reinitialize it back to default without having to stop the entire main while loop. Any suggestions would be much appreciated.
 
Jega
0 Kudos
Message 1 of 8
(3,973 Views)
You should not be performing actions which take a long time in the actual event case. You can either spin off that process as a dynamic VI, or, as a better solution, set up a producer-consumer structure. The event structure becomes your producer loop which sends messages to the consumer loop via the use of queues. This is a very fundamental program architecture and well worth spending the time to learn it. You can take a look at this KB article for more information: Application Design Patterns: Producer/Consumer.
0 Kudos
Message 2 of 8
(3,967 Views)

Jega

This can be achieved by adding a state machine after the event structure and using the event structure to drive the state machine in the require state. I am knind of doing it in a similar way in one of my applications.

Hope it helps......

Ankit

0 Kudos
Message 3 of 8
(3,955 Views)
hi

 as already mentioned, using event structure for actions that take long time is not suggestible.

using  state meachine is a good option. have the event structure in one of the cases in the state machine.
perform the code before your 'start' is enabled in different cases. call the case with 'event strcuture' when you are sure 'start' is enabled. call the cases which you need to execute after the event structure.

this might be easier! even producer-consumer is a good option.
0 Kudos
Message 4 of 8
(3,915 Views)


MScap wrote:
hi

 as already mentioned, using event structure for actions that take long time is not suggestible.

using  state meachine is a good option. have the event structure in one of the cases in the state machine.
perform the code before your 'start' is enabled in different cases. call the case with 'event strcuture' when you are sure 'start' is enabled. call the cases which you need to execute after the event structure.

this might be easier! even producer-consumer is a good option.



This won't eliminate his inability to perform any actions while his hour long process is happening.  If his event structure is in a user input state and calls an execution state, he's still locked within the same structure.  I think the producer consumer is the only feasible option here.
0 Kudos
Message 5 of 8
(3,900 Views)

Thanks all, but will the master-slave loop apply in this scenario?

Jega

0 Kudos
Message 6 of 8
(3,869 Views)
master slave is another name for producer consumer.  the consumer loop does (basically) nothing while it waits for input from the producer, which is akin to the slave loop not being able to execute any code without direction from the master.
0 Kudos
Message 7 of 8
(3,856 Views)

Thanks All.

Your advice/suggestions helped.

Jega 

0 Kudos
Message 8 of 8
(3,841 Views)