labview events

24
Developing User Interfaces with Event- driven Programming www.ni.com/ labviewzone

Upload: timkiemnhanh

Post on 27-Nov-2014

386 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: LabVIEW Events

Developing User Interfaces with Event-driven Programming

www.ni.com/labviewzone

Page 2: LabVIEW Events

2

Session Focus• Improve application performance

for UI-intensive applications• Modularize code making it easier to

read

Page 3: LabVIEW Events

3

Overview

• What are effective user interfaces • Developing user interfaces• LabVIEW Event Structure• Event programming tips

LabVIEW Event Structure

Page 4: LabVIEW Events

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

Page 5: LabVIEW Events

5

Elements of Interactive Interfaces

• Reacting to button clicks• Entering data and reacting to it• Drag and drop• Right-click menus

Page 6: LabVIEW Events

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

Page 7: LabVIEW Events

7

User Interfaces with Polling Demonstration

Page 8: LabVIEW Events

8

UI Development with Event-driven Programming

• Increases application responsiveness• Easier to read and manager your code

Page 9: LabVIEW Events

9

Event-driven Programming Demonstration

Page 10: LabVIEW Events

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

Page 11: LabVIEW Events

11

What is an Event Handler?

• Mechanism for communicating with Operating System

• Interprets low-level registry information for each event

• Asynchronous callback routine

Page 12: LabVIEW Events

12

The LabVIEW Event Structure

Placed on the Block Diagram like all other LabVIEW Structures

Page 13: LabVIEW Events

13

Configuring an Event Demonstration

Page 14: LabVIEW Events

18

Types of Events

Control This VI Application

Page 15: LabVIEW Events

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

Page 16: LabVIEW Events

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

Page 17: LabVIEW Events

21

Additional Events Demonstration

Page 18: LabVIEW Events

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

Page 19: LabVIEW Events

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

Page 20: LabVIEW Events

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

Page 21: LabVIEW Events

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

Page 22: LabVIEW Events

26

Certified LabVIEW Architect Exam

Skills tested:• Làm ch ng d ng LabVIEWủ ứ ụ

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

Page 23: LabVIEW Events

27

Connect with the LabVIEW Community

Page 24: LabVIEW Events

Questions?

Thank You