St. Louis LabVIEW User Group

Post on 11-Jan-2016

80 views 6 download

Tags:

description

St. Louis LabVIEW User Group. How to Choose an Architecture June 21 st 2011. Terminology. C. So what is a design pattern in LabVIEW?. Basic design patterns that ship with LabVIEW Advanced design patterns Object oriented design patterns New design patterns that emerge over time - PowerPoint PPT Presentation

Transcript of St. Louis LabVIEW User Group

St. Louis LabVIEW User Group

How to Choose an ArchitectureJune 21st 2011

TerminologyDesign Patterns – “You know you don’t want to reinvent the wheel (or worse, a flat tire), so you look to Design Patterns – the lessons learned by those who’ve faced the same problems.” – Head First Design Patterns by Freeman, Robson, Sierra & Bates

Design – A process of problem-solving and planning for a software solution

Software Architecture – “structure or structures of the system, which comprise software components, the externally visible properties of those components, and the relationships among them”– Software Architecture in Practice – 1st ed.

C. So what is a design pattern in LabVIEW?

– Basic design patterns that ship with LabVIEW– Advanced design patterns– Object oriented design patterns– New design patterns that emerge over time

• So why do we need advanced design patterns?

A. Use Cases – Laboratory

– Can range from very simple to very complex– Are sequential in nature or process oriented– Are more likely to leverage express VIs– Can require a basic framework that is easily

modified for a variety of similar tests

B. Use Cases – Test

– Are often sequential in nature– Typically have a very simple and intuitive user interface– Need high level executive code (perhaps Test Stand) to

coordinate test execution– Necessitate flexibility for exchanging instrumentation– Use a methodology to set and modify limits and other

configuration information– Could require several vehicles for logging data (file,

database, Web)– Can require extra design effort when the use case

demands parallel testing

C. Use Cases – Process/Distributed

– Include many asynchronous processes– Require a clearly defined messaging system– Involve processes or services which provide data

to multitudes of clients– Are potentially distributed across a network

What is the big picture?

UI.vi DAQ.vi

Report.vi Error.vi

QDSMQDSM

QDSMQDSM

A. Introduction

Let’s see, should I use functional global variables or single element queues? I used functional globals before, so I’ll use them again.

Get the right tool for the right job!

What happens to data?

• Fundamentally, five things happen to data in LabVIEW.

Modify

Move

StoreDisplay

Protect

How might the application change?

You cannot account for every potential change

Other Important Considerations

Performance

Locking

Buffering

State Machine• Actions may be invoked by a person, a remote

system across TCP/IP, a database, another VI, or some other mechanism. We are architecting for multiple processes.

InitializeGet TCP MsgHandle Error

Action 2

TCP InitSend TCP MsgHandle Error

Enum or String?• Enums

– Seamlessly connect to the case structure such that there are no typos.– Facilitate adding cases.– The architect can distribute the type def enum and QDSM to the developer.

• String – The QDSM template can have a case in the structure that handles potential

typos.– Strings facilitate integration with other functions that use strings such as Run

Time Menu Tags and TCP/IP VIs.– Strings are a universal data type that is recognizable outside the LabVIEW

environment.– Strings can be used on the connector pane of subVIs that form part of the

reuse library associated with the QDSM.– Can be used to append data with a state change.

One Cluster Shift Register or Many?

If you use many:• Easy to view all of the

data without having to unbundle or show context help• Important to group

them in one location, at the top or the bottom• Now possible to

automatically wire the unwired cases

Consider doing both!!

Architecture

• JKI State Machine• Design your own• FGV / DVR• Obj Oriented

Queue Driven Message Handler – Reusable Components

Functional Global Variables – Benefits

– Provide global access to data while minimizing potential race conditions introduced by global variables

– Encapsulate data so that debugging and maintenance is easier

– Facilitate the creation of reusable modules which simplifies writing and maintenance of code

– Can pass any kind of data and can enhance a variety of advanced design patterns (such as user events)

Sidebar: Creating and Registering User Events (Review)

Note: The label for the User Event Data Type input becomes the name for the user event in the event structure

Sidebar: Improve Flexibility of User Events

Pro• Are custom events• Can pass data with the

event• Can move data across the

block diagram• Are buffered• Are ideal for shutdown and

other high priority or global actions

Con• Can be confusing to a

novice user• Cannot be renamed like

queues• Must have a mechanism to

pass the reference to multiple locations

Being able to pass the reference through a FGV adds flexibility!

Advantages of XControls

– Encapsulates UI code into an abstract component• Reduces complexity and increases readability of main

block diagram • Removes UI-based restraints from the architecture of

the main VI• Abstracts complex code away from standard developers

– Creates reusable and distributable UI components• Easily distributable• Updates control instances to new versions while

maintaining integrity

Consistencyof SubVIs

Organizationof Libraires

Usabilityof APIs

• Connector Panes• Front Panels• Data Types• Planning for Change

• Layered API Design• Palette Menu Structure

• Documentation• Naming• Icons

B. Design Techniques

Where Can You Go for More Code and Ideas?

– Asynchronous Message Communication (AMC)– Specific Error Handler (SEH)– Current Value Table (CVT)– Buffered Variable Table (BVT)– Generic Configuration Editor (xCE)– Multi-Process Engine (MPE)

Where Can You Go for More Code and Ideas?

www.lavag.orgMore Than A Message

BoardA Community of Avid

LabVIEW ProgrammersA Place to Learn About

New TechnologiesA Place to Shape the Future of LabVIEW