Jump to content

Event case interruption


Recommended Posts

Hello all,

i am trying to find the best way of interrupting a timeout event case, in order to provide priority to other event cases

within the same Event structure.

The timeout runs at 1000msec and within it i perform some actions, that i would like to interrupt when another event is triggered

in the same Event structure.

Any suggestions?

Best regards

Link to comment

Interesting question!

If you put code inside the TimeOut case, you are screwed.

post-941-125106736037_thumb.png

There are many different approaches here, but the easiest one I use is by using a state machine like this:

post-941-12510673597_thumb.png

If the TimeOutCounter is zero, I wait for 1000ms before going to the TimeOut case,

else a 0 or 1 ms is wired to the TimeOut on the Event Structure, so it goes directly to the TimeOut case if no other events are in the queue.

post-941-1251067444_thumb.png

Event2.vi

//Mikael

  • Like 1
Link to comment

The timeout event is intrinsically not having priority. Every time one other event occur, the time out value is reload with the maximum value (for exempl 1000 in your case)and not fire.

It's for this reason it's call TimeOut and not Timer (I think). It's easy simple to lock it definitively when one event occur by loading -1 inplace of 1000. Look my exempl to see how.

post-5178-125110233417_thumb.jpg

Link to comment

i am trying to find the best way of interrupting a timeout event case, in order to provide priority to other event cases

within the same Event structure.

Is there a requirement that it run in the same Event Structure? Could you use a second loop with another one?

The timeout runs at 1000msec and within it i perform some actions, that i would like to interrupt when another event is triggered

in the same Event structure.

Do you need to prevent the actions in the Timeout event from completing or do you just want to stop them in order to handle the new event right away?

A second event structure will let the Timeout code finish while the first one handles the new event.

Another thought: the Caveats and Recommendations When Using Events in LabVIEW page says

If you need to generate or handle other events while handling the current event, consider using the Register Event Callback function.
.

Jim

Link to comment

Is there a requirement that it run in the same Event Structure? Could you use a second loop with another one?

Do you need to prevent the actions in the Timeout event from completing or do you just want to stop them in order to handle the new event right away?

Thanks for your replies.

The thing is that all the event cases within the same event structures (including the timeout) handle RS232 interactions. That's why i used the timeout in the same structure. So lets say that an event is triggered while the timeout is running, then the event will have to wait some time for the timeout case code to finish in order to serve it.

The possibility of using another loop with a timeout in it, must be carried out with some piece of synchronization i suppose. Do you think that this could be done using the synchronization functions?

Best regards

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
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.