LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

When to use event structures

Solved!
Go to solution

I have written several applications using state machine architecture.  These applications typically have two buttons (I created), a run, and abort.  The abort button halts the programand and jumps to an idle state which loops until the run button is selected.  One thing I don't like, my programs end up with one or more local variable for the abort button. 

 

1) Should I be using event structures for these types of programs ?

 

2) Is an event structure program also a state machine ?

0 Kudos
Message 1 of 3
(2,410 Views)
Solution
Accepted by ggress1

 

Why would you need local varables for the abort button? Simply make it latch action so it will reset automatically.

 

If your loop is spinning anyway (e.g. to update displays) you migh as well poll the controls. No event structure needed.

 


ggress1 wrote:

1) Should I be using event structures for these types of programs ?

2) Is an event structure program also a state machine ?


Event structures are primarily for handling user interaction on the front panel. I encourage you to learn about event structures so you can make an informed decision on the best code architecture for any given programming problem. Maybe you should show us some of your code so we can decide in using event structures would improve things.

 

A program with event structures is typically much less forgiving of beginner mistakes. Used incorrectly, they can easily lock up your program.

 

0 Kudos
Message 2 of 3
(2,387 Views)

@ggress1 wrote:

2) Is an event structure program also a state machine ?



You can create an event driven state machine, in which case e.g. the idle case has an event structure waiting for input and if timeout or event happens it sends out a State to act on.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 3
(2,331 Views)