LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event structure and setting an event

Hi All,

I'm using version 7 of LabVIEW, trying to update an app from 6i to 7.
I'm running into some confusion in replacing the classic "cluster of
buttons and case statement" with the new event structure.

My problem is with how to add non-button related events. With the old
case structure, I could have an "Init" state wired so that on startup
it would be called to init my front panel then would revert to calling
the default state for the duration. How can I add an init state to the
event structure? This would be a state that is automatically called
when the vi opens.

A secondary question is how can I force event B to be executed after
event A completes? E.g. I have a situation where if event A
successfully completes, call event B,
otherwise revert to user input
(default). Thanks in advance for any help.

Greg
0 Kudos
Message 1 of 3
(2,861 Views)

This is an excellent question, and it's not really a trivial update of your code. You're moving from an older method to something much more efficient, but still quite different.

The "Init" case you used before was not necessarily an event. Therefore, to move into the Event Strcuture paradigm, you will need to rethink your application. The Event Structure, introduced in 6.1 and improved in 7.0, reacts to actual "events" as they occur. That's why you're running into the "non-button" related events issue. For this, you will need to apply User-Defined Events in LV 7. These are events which are not tied to the User Interface.

To learn more about these, I'd start with this Web Event on Demand: Using the Event Structure for More Than Just the User Interface. It describes User-Defined Events and other new types of event programming in LV 7. After watching that (it's about 35 minutes) you should look at the example programs for User-Defined events in LV 7 and read the Upgrade Notes. They do a good job of explaining how to use it. They're certainly an advanced tool and very powerful. Hope this helps out.

J.R. Allen
0 Kudos
Message 2 of 3
(2,861 Views)

That info was very helpful. Thanks.

A question on my solution. In it I create a user event called Init
(no pun intended). My event structure is inside a while loop with the
timeout event added. On the first timeout (200 ms), I check the value
of i in the loop and if i == zero, generate my Init event.

My question comes here: Inside my Init event handler I make the calls
to unregister and destroy it, assuming this is good housekeeping as I
don't want to run Init for the remainder of this vi's duration. Is it
safe to unregister and destroy an event within it's own code?

It almost seems a cleaner way to accomplish my goal is with the
dreaded sequence structure. Sequence zero: do my initializing,
Sequence 1: go into event processing loop. Any comments?

JRA wrote in message news:<5065000000050000004A320100-1066448259000@exchange.ni.com>...
> This is an excellent question, and it's not really a trivial update of
> your code. You're moving from an older method to something much more
> efficient, but still quite different.
>
> The "Init" case you used before was not necessarily an event.
> Therefore, to move into the Event Strcuture paradigm, you will need to
> rethink your application. The Event Structure, introduced in 6.1 and
> improved in 7.0, reacts to actual "events" as they occur. That's why
> you're running into the "non-button" related events issue. For this,
> you will need to apply User-Defined Events in LV 7. These are events
> which are not tied to the User Interface.> href="http://digital.ni.com/demo.nsf/websearch/A3F870055350CC3286256D9100637EDE?OpenDocument&node=64300_US">Web
> Event on Demand: Using the Event Structure for More Than Just the User
> Interface
> To learn more about these, I'd start with this
. It describes User-Defined Events and other new types
> of event programming in LV 7. After watching that (it's about 35
> minutes) you should look at the example programs for User-Defined
> events in LV 7 and read the Upgrade Notes. They do a good job of
> explaining how to use it. They're certainly an advanced tool and very
> powerful. Hope this helps out.

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