developing user interfaces with event-driven programming
Post on 17-Dec-2015
274 Views
Preview:
TRANSCRIPT
Developing User Interfaces with Event-driven Programming
www.ni.com/labviewzone
2
Session Focus• Improve application performance
for UI-intensive applications• Modularize code making it easier to
read
3
Overview
• What are effective user interfaces • Developing user interfaces• LabVIEW Event Structure• Event programming tips
LabVIEW Event Structure
4
Effective 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
5
Elements of Interactive Interfaces
• Reacting to button clicks• Entering data and reacting to it• Drag and drop• Right-click menus
6
Developing 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
7
User Interfaces with Polling Demonstration
8
UI Development with Event-driven Programming
• Increases application responsiveness• Easier to read and manager your code
9
Event-driven Programming Demonstration
10
What 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
11
What is an Event Handler?
• Mechanism for communicating with Operating System
• Interprets low-level registry information for each event
• Asynchronous callback routine
12
The LabVIEW Event Structure
Placed on the Block Diagram like all other LabVIEW Structures
13
Configuring an Event Demonstration
18
Types of Events
Control This VI Application
19
Notify and Filter EventsNotify Events
Notifies LabVIEW that a user action has already occurred; available only in the Event Data Node
Filter EventsValidates 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
20
Additional 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
21
Additional Events Demonstration
22
LabVIEW 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
23
Use 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
24
Event-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
25
Other 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
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
Skills learned:• Modular application development• Structured design and
development practices• Inter-application communication
and connectivity techniques
New User
LabVIEW Basics I
LabVIEW Basics II
Experienced User
LabVIEW Intermediate I
LabVIEW Intermediate II
Advanced User
LabVIEW Advanced I
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
Courses
27
Connect with the LabVIEW Community
Questions?
Thank You
top related