beyond state machines: building modular applications in labview using public & private events

45
Justin Goeres Senior Engineer & Product Marketing Manager JKI Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Upload: jki

Post on 24-May-2015

1.425 views

Category:

Technology


7 download

TRANSCRIPT

Page 1: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Justin GoeresSenior Engineer & Product Marketing ManagerJKI

Beyond State Machines:Building Modular Applications in LabVIEW Using Public & Private Events

Page 2: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Let’s Get This Straight

User Events are a very easy-to-use feature with a lot of cool functionality.

They form the basis of JKIʼs primary application frameworks & templates.

If we could get a couple things fixed/added to LabVIEW, we could do even better.

Page 3: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

A Public & Private Events Framework

Page 4: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

A Public & Private Events Framework

Page 5: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Agenda

!What is it?

Page 6: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Agenda

!What is it?!How does it work?

Page 7: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Agenda

!What is it?!How does it work?!Whatʼs it good for?

Page 8: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Agenda

!What is it?!How does it work?!Whatʼs it good for?!Whatʼs it bad at?

Page 9: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Agenda

!What is it?!How does it work?!Whatʼs it good for?!Whatʼs it bad at?!How can you use it in your projects?

Page 10: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

What is it?

!Statefulness / private data!Asynchronous process(es)!Public API!Public Events

Page 11: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Key Benefits

!Module knows nothing about whoʼs consuming the data it produces

!Lightweight & easy to use!Compatible with by-ref and by-val architectures!(Probably) scriptable

Page 12: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

How Does it Work?

Page 13: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

How Does it Work?

Page 14: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Process VI & Public Events

Page 15: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Process VI & Public Events

Shift register for private module data

Page 16: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Process VI & Public Events

Shift register for private module data

Generate a “Public Event” when “something happens”

Page 17: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Public Events: Sending Information OUT

Page 18: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Public Events: Sending Information OUT

Process VI generates a Public Event...

Page 19: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Public Events: Sending Information OUT

Process VI generates a Public Event...

...which is received by any other Event Structure that’s registered for it.

Page 20: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Public Events: One to Many

Process VI generates a Public Event...

Page 21: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Public Events: One to Many

Process VI generates a Public Event...

...that can be received by any number of consumers!

Page 22: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Private Events: Getting Information IN

Page 23: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Private Events: Getting Information IN

Process VI receives “Private Events” from outside the module

Page 24: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Private Events Are Just Piping

Public API VIs...

...generate Private Events...

...that are handled by the asynchronous Process VI

Page 25: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Private Events Are Just Piping

Public API VIs...

...generate Private Events...

...that are handled by the asynchronous Process VI

Page 26: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Public API / Private Events

Page 27: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Public API / Private Events

Page 28: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Public API / Private Events

Page 29: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Public API / Private Events

Only our Process VI can receive this event

Page 30: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Putting it All Together

Page 31: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Putting it All Together

Client code registers for Public Events

Page 32: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Putting it All Together

Client code invokes Public API

Client code registers for Public Events

Page 33: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Putting it All Together

Start Process & register for Public

Events

Invoke Public API as needed

Exit Module when done

Page 34: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Everything is a Module

AnalogInput

Page 35: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Everything is a Module

AnalogInput

LeakDetection

Page 36: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Everything is a Module

AnalogInput

MotorController

LeakDetection

Page 37: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Everything is a Module

AnalogInput

MotorController

LeakDetection

EKGAnalysis

Page 38: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

MainApp

Everything is a Module

AnalogInput

MotorController

LeakDetection

EKGAnalysis

Page 39: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

MainApp

Everything is a Module

AnalogInput

MotorController

LeakDetection

EKGAnalysis

Page 40: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

MainApp

Everything is a Module

AnalogInput

MotorController

LeakDetection

EKGAnalysis

MainApp UI

Page 41: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Extensions & Tweaks

!Use with by-value & by-ref objects!Community & Protected Events!Dynamically unregister / reregister!Synchronous communication

Page 42: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Things That Suck

!Most annoying bug ever.Fixed in LV2011!!No Event queue management or introspection!No Notifier-like behavior (“ignore previous”)!Memory leaks in Events for large / variable-sized data?

Page 43: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Take Home Point

User Events are a very easy-to-use feature with a lot of cool functionality.

They form the basis of JKIʼs primary application frameworks & templates.

If we could get a couple things fixed/added to LabVIEW, we could do even better.

Page 44: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

Now You Try It!

Download the Templatehttp://tinyurl.com/jki-public-private

Discuss ithttp://forums.jki.net

Page 45: Beyond State Machines: Building Modular Applications in LabVIEW Using Public & Private Events

The End!

Discussion!