Você está na página 1de 28

www.ni.

com/labviewzone

c  
  
 
      
jession Focus
‡ Improve application performance
for UI-intensive applications
‡ Modularize code making it easier to
read

O
þverview

‡ What are effective user interfaces


‡ Developing user interfaces
‡ LabVIEW Event jtructure
‡ Event programming tips
LabVIEW Event
jtructure

¢
Effective User Interfaces

‡ Display information intuitively and professionally


± Descriptive labels on controls
NI jtyle Guide
± Limit your VI to 3 standard fonts
‡ Provides easy control of the user interface
± Enter values
± Change parameters
± Drag-n-drop

K
Elements of Interactive Interfaces

‡ Reacting to button clicks


‡ Entering data and reacting to it
‡ Drag and drop
‡ Right-click menus


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

±
User Interfaces with Polling
Demonstration

Ö
UI Development with Event-driven
Programming
‡ Increases application responsiveness
‡ Easier to read and manager your code

]
Event-driven Programming
Demonstration

s
What is an Event?
‡ An event is an action that triggers a change in state
± User initiated
‡ button press
‡ mouse click
± þj initiated
‡ timeout
± joftware initiated
‡ message from another program
‡ variable reaches a specific value


What is an Event Handler?

‡ Mechanism for communicating with þperating


jystem
‡ Interprets low-level registry information for each
event
‡ Asynchronous callback routine


Mhe LabVIEW Event jtructure

Placed on the Block Diagram like all other


LabVIEW jtructures

O
Configuring an Event Demonstration


Parts of an Event jtructure
Event jelector Label ± identifies
currently shown event case

Mimeout - value in milliseconds to wait for events;


default value is ±1 (indefinite)

K
Parts of an Event jtructure
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


Configuring an Event
Right-click


Event jpecifiers

Front Panel Controls


and Indicators

Available Events


Mypes of Events

Control Mhis VI Application

]
Notify 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

s
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

O
Additional Events Demonstration

O
LabVIEW Event jtructure Review

‡ jleeps until an event occurs


‡ Executes the appropriate event case
‡ Does not implicitly loop
‡ Queues all events
‡ Executes events in order of
occurrence

OO
Use Memplates for the Event jtructure
‡ User Interface Event Handler
‡ Producer/Consumer (Events)
‡ jtate Machine
‡ Parallel Loop VI Architecture
‡ Queued Message Handler
‡ Producer/Consumer (Data)

‡ Combine or Expand Architectures as Needed


Event-driven Programming Mips
‡ Make sure Event jtructures are always in loops to
handle events
‡ Put Latched Booleans inside of the event case handling it
‡ Programmatic changes Dþ NþM generate events
‡ An event-handling loop is not a state machine
‡ Use a jtop event when in a loop
‡ Never place an event structure inside of another event
structure

OK
þther Resources

‡ Event Driven Programming in LabVIEW


‡ LabVIEW Help - Caveats and Recommendations
when Using Events in LabVIEW
‡ NI jtyle Guide
‡ www.ni.com/info - eventdriven

O
Courses
New User Experienced User Advanced User
LabVIEW Basics I LabVIEW Intermediate I LabVIEW Advanced I
LabVIEW Basics II LabVIEW Intermediate II
jkills learned: jkills learned: jkills learned:
‡ LabVIEW environment navigation ‡ Modular application development ‡ Large application design
‡ Basics application creation using ‡ jtructured design and ‡ Advanced development
LabVIEW development practices techniques
‡ Basics of data acquisition and ‡ Inter-application communication ‡ Implementing multideveloper
instrument control and connectivity techniques projects

Certifications
Certified LV Associate Certified LabVIEW Certified LabVIEW
Developer Exam Developer Exam Architect Exam
jkills tested: jkills tested: jkills tested:
‡ LabVIEW environment knowledge ‡ LabVIEW application development ‡ Làm ch ng dng LabVIEW
expertise


Connect with the LabVIEW Community


Questions?
Mhank You

Você também pode gostar