LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Abort events to execute those with higher priority

Hello Friends,

 

I have 5 buttons on front panel (Start, Stop, Home, Back, Forward). I am using an event structure to execute code whenever the value changes on either of these buttons. When Start Button is pressed, the main code starts executing which takes some time to execute. Currently if any of other four buttons are pressed, their code is not executed since Start button event is not complete.

 

Is there any way to abort the execution of the rest of code for the start event and execute code for the other buttons? Is there any way to prioirtize certain events over another? Any tips, example code would be appreciated.

 

Thanks

0 Kudos
Message 1 of 8
(2,297 Views)

You need to ensure that events execute very quickly. Use an appropriate desing pattern to ensure that the UI is decoupled from the processing.

 

Can you show us some code?

Message 2 of 8
(2,295 Views)

I think you are correct about choosing an appropriate design pattern since I can't get the execute the low priority event (Start in my case) very fast. Please see the attached MainVI. I have removed the details in the VI to convey the basic idea. Let me know it you have any suggestions. Also I would like to add, this VI is a part of the project (Evident from Back, Home and Forward Buttons). So this is called as a subVI.

0 Kudos
Message 3 of 8
(2,291 Views)

You also have an event structure inside of an event structure.  That can cause all kinds of problems.

Message 4 of 8
(2,285 Views)

I thought that too. But currently that's working perfectly fine. I mean the Start Event

0 Kudos
Message 5 of 8
(2,282 Views)

Any suggestions where I can start looking to improve my approach?

0 Kudos
Message 6 of 8
(2,265 Views)

Sorry, I am on a laptop, so inspecting that way oversized diagram is not really possible. Keep it compact.

 

Some things:

Use one event sutrucure in an independent loop for all user interaction.

Make your butons lacth action and place them inside their respective events. No need for local variables.

Using proper dataflow, you can eliminate all your sequence structures.

Use a second independent loop (consumer) that processes queue entries produced by the UI loop above.

 

Here's just the tip of the iceberg. Let's look at one of your code segments (Sorry, I don't have IMAQ, so certain things look broken):

 

  • You are hammering the blinking property with every iteration of the loop, while it only needs to be set when it changes.
  • All sequences can be eliminated by using proper dataflow.
  • you need to build the path only once, right?

A 30 second rewrite could look like the code shown below. Much more readable, simpler, clearer, and smaller!

 

Message 7 of 8
(2,262 Views)

Also you only need to check for the existence of the file inside the true case of the outer structure. Move it there.

0 Kudos
Message 8 of 8
(2,254 Views)