Title: Developing User Interfaces with Event-driven Programming
1Developing User Interfaces with Event-driven
Programming
2Session Focus
- Improve application performance for UI-intensive
applications - Modularize code making it easier to read
3Overview
- What are effective user interfaces
- Developing user interfaces
- LabVIEW Event Structure
- Event programming tips
LabVIEW Event Structure
4Effective User Interfaces
- Display information intuitively and
professionally - Descriptive labels on controls
- Limit your VI to 3 standard fonts
- Provides easy control of the user interface
- Enter values
- Change parameters
- Drag-n-drop
NI Style Guide
5Elements of Interactive Interfaces
- Reacting to button clicks
- Entering data and reacting to it
- Drag and drop
- Right-click menus
6Developing Interactive Interfaces with Polling
- While loop checks the value of controls
- Code executes based on the control value
- Drawbacks of polling
- Processor intensive
- Code must process the control value each loop
- Application can appear unresponsive or sluggish
- Can miss user actions
- Reaction of the code is dependent on data flow
7User Interfaces with Polling Demonstration
8UI Development with Event-driven Programming
- Increases application responsiveness
- Easier to read and manager your code
9Event-driven Programming Demonstration
10What is an Event?
- An event is an action that triggers a change in
state - User initiated
- button press
- mouse click
- OS initiated
- timeout
- Software initiated
- message from another program
- variable reaches a specific value
11What is an Event Handler?
- Mechanism for communicating with Operating System
- Interprets low-level registry information for
each event - Asynchronous callback routine
12The LabVIEW Event Structure
Placed on the Block Diagram like all other
LabVIEW Structures
13Configuring an Event Demonstration
14Parts of an Event Structure
Event Selector Label identifies currently shown
event case
Timeout - value in milliseconds to wait for
eventsdefault value is 1 (indefinite)
15Parts of an Event Structure
Event Filter Node - allows you to change or
discard event data for a Filter event before the
event is completely processed
Event Data Node - data unique to each event case
16Configuring an Event
Right-click
17Event Specifiers
Front Panel Controlsand Indicators
Available Events
18Types of Events
Control
This VI
Application
19Notify and Filter Events
- Notify Events
- Notifies LabVIEW that a user action has already
occurred available only in the Event Data Node - Filter Events
- Validates or changes the event data before the
user interface can process it preventing the
change from affecting the VI available in the
Event Filter Node and Event Data Node
20Additional Events
- Right-click Menus
- Registers events based on right-click menu
activation or selection - Works with user-defined right-click menus or the
default application menu - Drag and Drop
- Drag and drop data between controls and
indicators - Useful alternative to copy and paste
21Additional Events Demonstration
22LabVIEW Event Structure Review
- Sleeps until an event occurs
- Executes the appropriate event case
- Does not implicitly loop
- Queues all events
- Executes events in order of occurrence
23Use Templates for the Event Structure
- User Interface Event Handler
- Producer/Consumer (Events)
- State Machine
- Parallel Loop VI Architecture
- Queued Message Handler
- Producer/Consumer (Data)
- Combine or Expand Architectures as Needed
24Event-driven Programming Tips
- Make sure Event Structures are always in loops to
handle events - Put Latched Booleans inside of the event case
handling it - Programmatic changes DO NOT generate events
- An event-handling loop is not a state machine
- Use a Stop event when in a loop
- Never place an event structure inside of another
event structure
25Other Resources
- Event Driven Programming in LabVIEW
- LabVIEW Help - Caveats and Recommendations when
Using Events in LabVIEW - NI Style Guide
- www.ni.com/info - eventdriven
26 Experienced User LabVIEW Intermediate I LabVIEW
Intermediate II
Advanced User LabVIEW Advanced I
Courses
New User LabVIEW Basics I LabVIEW Basics II
- Skills learned
- Modular application development
- Structured design and development practices
- Inter-application communication and connectivity
techniques
- Skills learned
- LabVIEW environment navigation
- Basics application creation using LabVIEW
- Basics of data acquisition and instrument control
- Skills learned
- Large application design
- Advanced development techniques
- Implementing multideveloper projects
- Certified LabVIEW Architect Exam
- Skills tested
- LabVIEW application development mastery
- Certified LabVIEW Developer Exam
- Skills tested
- LabVIEW application development expertise
- Certifications
- Certified LV Associate Developer Exam
- Skills tested
- LabVIEW environment knowledge
27Connect with the LabVIEW Community
28Questions?Thank You