230 likes | 482 Views
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
E N D
St. Louis LabVIEW User Group How to Choose an Architecture June 21st 2011
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 QDSM QDSM QDSM QDSM Error.vi Report.vi
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.
How might the application change? You cannot account for every potential change
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. Initialize Get TCP Msg Handle Error Action 2 TCP Init Send TCP Msg Handle 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
Functional Global Variables – Benefits • Provideglobal 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 moduleswhich 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 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
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.org More Than A Message Board A Community of Avid LabVIEW Programmers A Place to Learn About New Technologies A Place to Shape the Future of LabVIEW