Jump to content

Stopping an Event Structure


Recommended Posts

Is there a way to stop a VI within an event structure once the Event structure is activated, or are you forced to wait untill the script within the event structure terminates itself. I have been trying to use event structures to initiate code, but I also need to be able to terminate the code based on user interface. But everytime I try to code the program the script will intiate and run correctly but I cannot interupt/stop it once the code begins. The buttons on the front panel will not respond. Is there a way to interrupt the code in an event structure?

Link to comment
Is there a way to stop a VI within an event structure once the Event structure is activated, or are you forced to wait untill the script within the event structure terminates itself. I have been trying to use event structures to initiate code, but I also need to be able to terminate the code based on user interface. But everytime I try to code the program the script will intiate and run correctly but I cannot interupt/stop it once the code begins. The buttons on the front panel will not respond. Is there a way to interrupt the code in an event structure?

You will need 2 seperate loops in order to achieve your goal. I suggest you look at the different templates/framework available in LabVIEW via the starting dialog "VI From Template". Depending on your needs, select one of the design patterns. Producer/Consumer or Master/Slave

Is there a way to interrupt the code in an event structure?

I don't believe so...

Link to comment
Is there a way to stop a VI within an event structure once the Event structure is activated, or are you forced to wait untill the script within the event structure terminates itself. I have been trying to use event structures to initiate code, but I also need to be able to terminate the code based on user interface. But everytime I try to code the program the script will intiate and run correctly but I cannot interupt/stop it once the code begins. The buttons on the front panel will not respond. Is there a way to interrupt the code in an event structure?

As a general rule you may not want to put much inside an event structure, or you may get the behavior you have noticed. At least avoid putting while loops inside or vi's that have while loops. The event won't stop and the loop won't iterate until all the event border outputs are filled. That's dataflow.

Investigate the use of queues. Use the event structure to enqueue integer numbers (or enums) that correspond to cases in an separate loop. For example:

A user event occurs and within the event an enqueue function puts a 1 in the queue, in the other loop is a dequeue function, when the number 1 appears in the queue it is dequeued to run the case called 1.

Within that case you could queue up further numbers, 2, 3, 4 that correspond to other cases. Every time the dequeue and case loop interates another number is dequeued and its case runs. The queue functions as a FIFO in this basic manner.

If at some point another user event occurs it then enqueues another number which waits its turn unitl all the prior queued numbers are dequeued used.

You can queue up most anything that can be in a wire. Whatever you wire to enqueue pops out at the dequeue. A typical use is to have an Enum instead of just an integer to fire a case structure. All the Enum really does us give an verbal map to the numbers that are really the otuput of an enum.

There are other details to using the queue like obtain queue, destroy queue, etc. The most common use for this would probably be the event driven producer consumer design pattern. You will love this once you get the hang of it.

Mike

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.