LabVIEW Framework Design Guide
LabVIEW Framework Design Guide
ni.com
It’s About Saving Time
ni.com 4
“A Framework is an architecture
without the important bits.”- ShaunR on
lavag.org
ni.com
What is a Framework?
Distinguishing Features:
• Inversion of control – The overall program’s flow of control
is not dictated by the caller, but by the framework.
• Default behavior - A framework has a default behavior.
• Extensibility – A framework can be extended by selective
overriding or specialized by user code to provide specific
functionality.
• Non-modifiable framework code - The framework code, in
general, is not allowed to be modified. Users can extend the
framework, but not modify its code.
ni.com 6
The Bookends: QMH and AF
ni.com 7
Roadmap to Owning Your Framework
Learn
from
others Use
Plug-Ins Understand
Messaging Build or
borrow a
framework
Master
QMH
Explore a
Know framework
Domain & Explore
Team another
framework
Design For
Deployment
ni.com 8
Roadmap to Owning Your Framework
Learn
from
others Use
Plug-Ins Understand
Messaging Build or
borrow a
framework
Master
QMH
Explore a
Know framework
Domain & Explore
Team another
framework
Design For
Deployment
ni.com 9
Customer Needs a Sequential Test Solution
ni.com 10
The Bright
Shiny Object
ni.com 11
Customer Hired a Consultant to Write a Basic, Three
Process Monitoring Application
However…
ni.com 12
Becoming an Architect
ni.com 13
Challenges for the Architects
X
application. Avoid shoving an application into a
framework
ni.com 14
Roadmap to Owning Your Framework
Learn
from
others Use
Plug-Ins Understand
Messaging Build or
borrow a
framework
Master
QMH
Explore a
Know framework
Domain & Explore
Team another
framework
Design For
Deployment
ni.com 15
So Now Where Do I Begin?
ni.com
Begin With the Deployed Application
How will the application be deployed? One monolithic
exe?
Main
Application - exe
UI Which components of the code
will need to scale?
Component Measure
How often will new components
Analyze be released?
ni.com 17
What if only small changes will occur?
What if no component requires extensive scaling?
Continuous Measurement and Logging Sample Project
Main
UI
Measure
Analyze
Report
Display
What sample project
comes to mind?
ni.com 18
A customized Continuous Measurement
Logging application, with implementation
details removed, can be a very robust
framework and newer programmers can
immediately be successful.
ni.com
Scaling and Updating Components of an Application
However, what if most of the code remains the same, but
engineers will spend significant time modifying the analysis code
and potentially pushing out new versions of the analysis
modules.
Main
Analyze1
UI
Analyze2
Message
Measure
Call Analyze
Main remains an exe
and Analyze is deployed
Report as plug-ins that are
called by Main
Display
ni.com 20
Framework Overview
After further consideration, a high-level overview emerges...
???
Customized QMH Modular
Main.vi Analyze1
UI Analyze2
Message
???
Display1
Call Report TDMS Report
ni.com 21
Roadmap to Owning Your Framework
Learn
from
others Use
Plug-Ins Understand
Messaging Build or
borrow a
framework
Master
QMH
Explore a
Know framework
Domain & Explore
Team another
framework
Design For
Deployment
ni.com 22
Plug Ins – Where Do We Start?
Implementation
• static, VI Server, OO,
other
ni.com 23
Using and Deploying Modules with Packed
Project Libraries (.lvlibp)
• Develop .lvlib.
• Set access scope of subVIs as private
• Compile to PPL through build specifications
• Use the PPL from the project, just like project library
ni.com 24
Build Specifications for Application
• Main.vi is built into an exe and does not change.
• The Math.lvlibp is located in a support directory
ni.com 25
Update Without Recompiling exe
• Update the source in Math.lvlib
• Recompile the plug in to a new Math.lvlibp
• Copy compiled PPL into the support directory
ni.com 26
What are Plug-Ins?
Square.vi
ni.com 27
Calling Plug Ins with VI Server Call by Reference
ni.com 28
Plug In Libraries with OO
• Dynamically launch a series of functions
• TXT Report Library, XML Report Library, etc
Dynamic
Dispatch (or
polymorphism at
Class wire is self run time)
aware and
knows what type
of report it is.
ni.com 29
Plug In Libraries with OO
• Report Class is abstract and never instantiated
• TXT and XML Report are concrete child classes
• Easily extensible with no change to the Main.exe
Many Other
Report Types
ni.com 30
Development Process & Deployment
ni.com 32
Roadmap to Owning Your Framework
Characterize Messages &
Learn Understand Messaging
from Challenges
others Use
Plug-Ins Understand
Messaging Build or
borrow a
framework
Master
QMH
Explore a
Know framework
Domain & Explore
Team another
framework
Design For
Deployment
ni.com 33
Extending the Framework – Messaging
The use case has changed, and the Measurement
component will reside in another application instance or on
another target.
Main
??? Analyze1
Measure UI
Message Analyze2
ni.com 34
Data Communication: Different Categories of
Sharing Data Across Processes
ni.com 35
Specific Inter-process Communication Methods
Same target Same target, different application
Same application instance instances OR
Different targets on network
ni.com 36
Data Value Reference (DVR)
• Methodology to create a reference for any data type
• Provides a pointer to a common memory location
• Functions as global data modification and storage
When the wire This is a blocking call
forks, LabVIEW
makes a copy of
the reference,
not the data
In Place Element
Structure (IPE)
Encapsulate for
scalability and usability
ni.com 38
DVR - Storing Data or Sending a Message?
Could I modify to
create a transport?
(Data item remains
in memory until
read by receiver)
ni.com 39
Demo
Messaging: Master the Native LabVIEW Data
Communication APIs
• Consider User
Events
• What happens when
you fork a Register
for Events?
ni.com 40
Messaging: Design a Clean Shutdown
ni.com 41
Messaging: Ensure that External Messages Do Not
Interrupt Process Flow
External.vi Main.vi
ni.com 43
Dataflow Safe
ni.com 44
Attend the year Certified LabVIEW
Architect Summit to learn the latest
innovations in LabVIEW programming - a
free community-driven event, open to all current CLAs
ni.com
Roadmap to Owning Your Framework
Learn
from
others Use
Plug-Ins Understand
Messaging Build or
borrow a
framework
Master
QMH
Explore a
Know framework
Domain & Explore
Team another
framework
Design For
Deployment
ni.com 46
Other Frameworks (We Hope To See More Soon!)
• AF
• ALOHA We will cover a couple of frameworks that have
• Rex been presented at recent CLA Summits
• Extended Sessions Framework (Reference Designs on NI Community)
• Named Pipes (Mike Bailey, UK)
• LapDog (lavag.org)
• JAMA (lavag.org)
• Yet Another Messaging System (lavag.org)
• JKI - Beyond State Machines
• Message Pump (lavag.org)
• epimedia.com/products.php
• PTP Sequencer (NI Community)
• AQ Character Lineator (ni.com or NI Community)
• AMC (Reference Designs on NI Community)
• CVT (Reference Designs on NI Community)
• TLB/TLB’ (lavag.org)
• Featherweight
ni.com 47
Characterizing a Framework
ni.com 48
Actor Framework
ni.com 49
REx: Remote Exports – Architect Norm Kirchner
http://lavag.org/topic/17024-rex-remote-export-framework-and-remote-events/
ni.com 50
Demo
REx
• S - Same instance or across network
• C - Many to one messaging with a response
Like any well crafted framework, REx hides tremendous complexity. Deep
under-the-hood of the Remote Obtain, you will find VI server at work
ni.com 52
REx Messaging: Step 2
Listener receives message.
ni.com 53
REx Messaging: Step 3
Listener processes message and sends
reply.
ni.com 54
REx: Tool for Creating New Command
ni.com 55
Roadmap to Owning Your Framework
Learn
from
others Use
Plug-Ins Understand
Messaging Build or
borrow a
framework
Master
QMH
Explore a
Know framework
Domain & Explore
Team another
framework
Design For
Deployment
ni.com 56
ALOHA: Architect Craig Bedward
Goal: Develop
a framework
Agent 1 Agent 2
that defines
QMH communication
QMH
between QMHs
and facilitates
team
Broadcast Messaging development.
Agent 3 Agent 4
QMH QMH
ni.com 57
ALOHA: Each Component is a QMH
ni.com 58
Demo
SmartCom Messaging
Even directed messages are broadcast, but the recipient
knows who he is because the message is translated to
"this".
ni.com 59
ALOHA – Agent QMH Producer
ni.com 60
ALOHA - Agent QMH Consumer
ni.com 61
ALOHA Features
http://www.s5solutions.com
for download
ni.com 62
ALOHA – Framework Characteristics
• S - Same instance or across network
• C – Broadcast. Agents filter incoming messages.
ni.com 63
Wirebird Labs in Q4 2014
ni.com 65
Roadmap to Owning Your Framework
Learn
from
others Use
Plug-Ins Understand
Messaging Build or
borrow a
framework
Master
QMH
Explore a
Know framework
Domain & Explore
Team another
framework
Design For
Deployment
ni.com 66
Owning Your Framework – Documentation
Deliverables to Your Team
ni.com 67
Borrowed or Built - Own Your Framework
ni.com 68
One Last Thought… Critique Your Framework
ni.com 69
New ideas pass through three periods: 1)
It can’t be done. 2) It probably can be
done, but it’s not worth doing. 3) I knew it
was a good idea all along! – Arthur C Clark
ni.com
Certification Path
SW
1 Hour 4 Hour Engineering 4 Hour
Multiple Practical in LabVIEW Practical
Choice Exam Exam
LabVIEW
Real Time
LabVIEW
Data Aq. &
Signal Cond.
LabVIEW
Instrument
Control
LabVIEW
Machine
Vision
LabVIEW
Modular
Instruments
ni.com 71
Missed the CLA Summit this year?
Get certified for next year!
The Certified LabVIEW Architect (CLA) Summit brings
together some of the world’s best NI LabVIEW programmers
to discuss architectures, preview new features, and network
with other CLAs and members of NI R&D.
ni.com 72
Thank You!
Nancy.Hollenback@ni.com
ni.com