Labview Intermediate I: Successful Development Practices Course Manual
Labview Intermediate I: Successful Development Practices Course Manual
Labview Intermediate I: Successful Development Practices Course Manual
Successful Development
Practices Course Manual
Course Software Version 8.6
October 2008 Edition
Part Number 323756D-01
LabVIEW Intermediate I Course Manual
Copyright
© 2004–2008 National Instruments Corporation. All rights reserved.
Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including
photocopying, recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent
of National Instruments Corporation.
National Instruments respects the intellectual property of others, and we ask our users to do the same. NI software is protected by
copyright and other intellectual property laws. Where NI software may be used to reproduce software or other materials belonging to
others, you may use NI software only to reproduce materials that you may reproduce in accordance with the terms of any applicable
license or other legal restriction.
The following notices relate to certain components used in USI (Xerces C++, ICU, HDF5, Citadel 5, b64 library, and Stingray). For a
listing of the conditions and disclaimers regarding these components, refer to the USICopyrights.chm.
Xerces C++. This product includes software developed by the Apache Software Foundation (http://www.apache.org/).
Copyright 1999 The Apache Software Foundation. All rights reserved.
ICU. Copyright 1995–2003 International Business Machines Corporation and others. All rights reserved.
HDF5. NCSA HDF5 (Hierarchical Data Format 5) Software Library and Utilities
Copyright 1998, 1999, 2000, 2001, 2003 by the Board of Trustees of the University of Illinois. All rights reserved.
Citadel 5. In regards to components that use Citadel 5, the following copyright applies. Copyright © 1994 Hewlett-Packard Company.
b64 library. Copyright © 2004–2006, Matthew Wilson and Synesis Software. All Rights Reserved.
Stingray. This software includes Stingray software developed by the Rogue Wave Software division of Quovadx, Inc.
Copyright 1995–2006, Quovadx, Inc. All Rights Reserved.
Trademarks
National Instruments, NI, ni.com, and LabVIEW are trademarks of National Instruments Corporation. Refer to the Terms of Use section
on ni.com/legal for more information about National Instruments trademarks.
Other product and company names mentioned herein are trademarks or trade names of their respective companies.
Members of the National Instruments Alliance Partner Program are business entities independent from National Instruments and have
no agency, partnership, or joint-venture relationship with National Instruments.
Patents
For patents covering National Instruments products/technology, refer to the appropriate location: Help»Patents in your software,
the patents.txt file on your media, or the National Instruments Patent Notice at ni.com/legal/patents.
Worldwide Technical Support and Product Information
ni.com
Worldwide Offices
Australia 1800 300 800, Austria 43 662 457990-0, Belgium 32 (0) 2 757 0020, Brazil 55 11 3262 3599, Canada 800 433 3488,
China 86 21 5050 9800, Czech Republic 420 224 235 774, Denmark 45 45 76 26 00, Finland 358 (0) 9 725 72511,
France 01 57 66 24 24, Germany 49 89 7413130, India 91 80 41190000, Israel 972 3 6393737, Italy 39 02 41309277,
Japan 0120-527196, Korea 82 02 3451 3400, Lebanon 961 (0) 1 33 28 28, Malaysia 1800 887710, Mexico 01 800 010 0793,
Netherlands 31 (0) 348 433 466, New Zealand 0800 553 322, Norway 47 (0) 66 90 76 60, Poland 48 22 3390150,
Portugal 351 210 311 210, Russia 7 495 783 6851, Singapore 1800 226 5886, Slovenia 386 3 425 42 00,
South Africa 27 0 11 805 8197, Spain 34 91 640 0085, Sweden 46 (0) 8 587 895 00, Switzerland 41 56 2005151,
Taiwan 886 02 2377 2222, Thailand 662 278 6777, Turkey 90 212 279 3031, United Kingdom 44 (0) 1635 523545
For further support information, refer to the Additional Information and Resources appendix. To comment on National Instruments
documentation, refer to the National Instruments Web site at ni.com/info and enter the info code feedback.
Contents
Student Guide
A. NI Certification .....................................................................................................vii
B. Course Description ...............................................................................................viii
C. What You Need to Get Started .............................................................................viii
D. Installing the Course Software..............................................................................ix
E. Course Goals.........................................................................................................ix
F. Course Conventions ..............................................................................................x
Lesson 1
Successful Development Practices
A. Scalable, Readable, and Maintainable VIs ...........................................................1-2
B. Successful Development Practices .......................................................................1-3
C. Course Project Overview ......................................................................................1-11
Lesson 2
Analyzing the Project
A. Evaluating the Needs of the Customer .................................................................2-2
B. Communicating with the Customer ......................................................................2-4
C. Developing the Requirements Document .............................................................2-6
Exercise 2-1 Analyze a Requirements Document .................................................2-8
D. Defining the Application ......................................................................................2-15
Lesson 3
Designing the User Interface
A. User Interface Design Issues.................................................................................3-2
B. User Interface Layout Issues.................................................................................3-4
C. Front Panel Prototyping ........................................................................................3-15
D. User Interface Examples .......................................................................................3-16
E. Localizing User Interfaces ....................................................................................3-17
Exercise 3-1 User-Interface Design Techniques ...................................................3-20
Lesson 4
Designing the Project
A. Design Patterns .....................................................................................................4-2
B. Event-Based Design Patterns................................................................................4-11
C. Advanced Event-Based Design Patterns...............................................................4-14
Exercise 4-1 User Event Techniques.....................................................................4-17
D. Creating a Hierarchical Architecture ....................................................................4-25
E. Using the LabVIEW Project and Project Libraries ..............................................4-27
Exercise 4-2 Using the LabVIEW Project.............................................................4-41
Exercise 4-3 File and Project Management with Project Explorer Tools .............4-45
Lesson 5
Implementing the User Interface
A. Implementing User Interface-Based Data Types..................................................5-2
Exercise 5-1 Implement User Interface-Based Data Types...................................5-7
B. Implementing Meaningful Icons...........................................................................5-11
Exercise 5-2 Implement a Meaningful Icon ..........................................................5-13
C. Implementing Appropriate Connector Panes........................................................5-15
Exercise 5-3 Implement an Appropriate Connector Pane .....................................5-18
Lesson 6
Implementing Code
A. Configuration Management ..................................................................................6-2
B. Implementing a Design Pattern.............................................................................6-7
Exercise 6-1 Implement the Design Pattern ..........................................................6-13
C. Implementing Code...............................................................................................6-26
Exercise 6-2 Timing ..............................................................................................6-49
D. Develop Scalable and Maintainable Modules ......................................................6-53
Exercise 6-3 Implement Code ...............................................................................6-60
E. Implement an Error Handling Strategy.................................................................6-68
Exercise 6-4 Implement Error Handling Strategy .................................................6-69
Lesson 7
Implementing a Test Plan
A. Verifying the Code................................................................................................7-2
B. Implementing a Test Plan for Individual VIs .......................................................7-3
C. Implementing a Test Plan for Integrating VIs ......................................................7-5
Exercise 7-1 Integrate Initialize and Shutdown Functions....................................7-11
Exercise 7-2 Integrate Display Module .................................................................7-16
Exercise 7-3 Integrate Record Function ................................................................7-22
Exercise 7-4 Integrate Play Function.....................................................................7-27
Exercise 7-5 Integrate Stop Function ....................................................................7-34
Exercise 7-6 Integrate Save and Load Functions ..................................................7-36
Exercise 7-7 Integrate Error Module .....................................................................7-42
D. Implementing a Test Plan for the System .............................................................7-47
Exercise 7-8 Stress and Load Testing....................................................................7-53
Lesson 8
Evaluating VI Performance
A. Steps to Improving Performance ..........................................................................8-2
B. Using VI Metrics to Identify VI Issues.................................................................8-2
Exercise 8-1 Identify VI Issues with VI Metrics...................................................8-4
C. Identifying VI Issues with VI Analyzer (Optional) ..............................................8-5
Exercise 8-2 Identify VI Issues with VI Analyzer (Optional)...............................8-12
D. Identifying Performance Problems .......................................................................8-13
E. Fixing Performance Problems ..............................................................................8-14
Exercise 8-3 Methods of Updating Indicators.......................................................8-24
Lesson 9
Implementing Documentation
A. Designing Documentation ....................................................................................9-2
B. Developing User Documentation..........................................................................9-2
C. Describing VIs, Controls, and Indicators..............................................................9-5
Exercise 9-1 Document User Interface..................................................................9-7
D. Creating Help Files ...............................................................................................9-9
Exercise 9-2 Implement Documentation ...............................................................9-10
Lesson 10
Deploying the Application
A. Implementing Code for Stand-Alone Applications ..............................................10-2
Exercise 10-1 Implementing Code for Stand-Alone Applications..........................10-8
B. Building a Stand-Alone Application.....................................................................10-12
Exercise 10-2 Create a Stand-Alone Application....................................................10-16
C. Building an Installer..............................................................................................10-18
Exercise 10-3 Create an Installer.............................................................................10-22
Appendix A
IEEE Requirements Documents
A. Institute of Electrical and Electronic Engineers (IEEE) Standards ......................A-2
B. IEEE Requirements Document .............................................................................A-3
Appendix B
Additional Information and Resources
Glossary
Index
Course Evaluation
You can apply the full purchase of this course kit toward the corresponding
course registration fee if you register within 90 days of purchasing the kit.
Visit ni.com/training for online course schedules, syllabi, training
centers, and class registration.
Note For course manual updates and corrections, refer to ni.com/info and enter the
info code rdcelv1.
A. NI Certification
The LabVIEW Intermediate I: Successful Development Practices course is
part of a series of courses designed to build your proficiency with LabVIEW
and help you prepare for NI LabVIEW certification exams. The following
illustration shows the courses that are part of the LabVIEW training series.
Refer to ni.com/training for more information about NI Certification.
Courses
Hardware-Based Courses:
• Data Acquisition and Signal Conditioning • Modular Instruments • Instrument Control • Machine Vision
• Motion Control • LabVIEW Real-Time • Compact RIO
*Core courses are strongly recommended to realize maximum productivity gains when using LabVIEW.
B. Course Description
The LabVIEW Intermediate I: Successful Development Practices course
teaches you four fundamental areas of software development in
LabVIEW—design, implement, test, and deploy. By the end of the
LabVIEW Intermediate I: Successful Development Practices course, you
will be able to produce a LabVIEW application that uses good programming
practices and is easy to scale, easy to read, and easy to maintain. As a result,
you should be able to more effectively develop software with LabVIEW.
This course assumes that you have taken the LabVIEW Basics I:
Introduction and LabVIEW Basics II: Development courses or have
equivalent experience.
Note The exercises in this course are cumulative and lead toward developing a final
application at the end of the course. If you skip an exercise, use the solution VI for that
exercise, available in the <Solutions>\LabVIEW Intermediate I directory, in later
exercises.
• A quiz that reviews the important concepts and skills in the lesson
Filename Description
Exercises Folder containing VIs and other files used in the course
Solutions Folder containing completed course exercises
Tip Folder names in angle brackets, such as <Exercises>, refer to folders in the root
directory of your computer.
E. Course Goals
After completing the course, you will be able to:
• Analyze the requirements of an application and choose appropriate
design patterns and data structures
• Implement good programming style to create efficient VIs
• Develop techniques to test and validate VIs
F. Course Conventions
The following conventions are used in this course manual:
» The » symbol leads you through nested menu items and dialog box options
to a final action. The sequence File»Page Setup»Options directs you to pull
down the File menu, select the Page Setup item, and select Options from
the last dialog box.
bold Bold text denotes items that you must select or click in the software, such as
menu items and dialog box options. Bold text also denotes parameter names,
controls and buttons on the front panel, dialog boxes, sections of dialog
boxes, menu names, and palette names.
italic Italic text denotes variables, emphasis, a cross-reference, or an introduction
to a key concept. Italic text also denotes text that is a placeholder for a word
or value that you must supply.
monospace Text in this font denotes text or characters that you enter from the keyboard,
sections of code, programming examples, and syntax examples. This font
also is used for the proper names of disk drives, paths, directories, programs,
subprograms, subroutines, device names, functions, operations, variables,
filenames, and extensions.
Platform Text in this font denotes a specific platform and indicates that the text
following it applies only to that platform.
Design
the Code
Topics
A. Scalable, Readable, and Maintainable VIs
B. Successful Development Practices
C. Course Project Overview
When you program with LabVIEW you encounter many of the same design
issues that you encounter when you program in text-based languages.
However, LabVIEW provides many powerful features and allows for
programming techniques that enable you to focus on producing a solution to
a problem rather than focusing on syntax or memory issues.
Scalable
In order to create a scalable VI, begin thinking about the design of the
application early in the design process. A well-designed scalable VI allows
you to easily modify and add additional functionality to the original design.
For example, consider a data acquisition VI that acquires data from three
thermocouples. If the requirements of the application change and you need
to acquire data from hundreds of thermocouples, extending the VI to acquire
data from hundreds of thermocouples is easier than designing a new VI if
the original VI is designed to be scalable. When you design any application,
consider the purpose of the application and how to manage changes when
the scale of the application goes beyond the original specification.
Readable
In your experience working with LabVIEW, you may have seen block
diagrams that were unstructured, difficult to read, and difficult to
understand. Confusing and unmaintainable code sometimes is called
spaghetti code. Unreadable code can make it impossible to decipher the
functionality of a block diagram. Figure 1-2 shows poorly designed block
diagram and a well-designed block diagram.
1 2
Maintainable
When you develop an application, keep in mind that another programmer
might need to use and modify the VI in the future. By using forethought in
designing and creating an application, you can create VIs that are more
maintainable. A VI written using good program design and architecture
allows you as well as other programmers to add new features without
completely rewriting the application.
Many industries around the world use LabVIEW to perform a wide range of
measurement and automation tasks, in many environments, including those
where safety is critical. For example, a LabVIEW application might
measure the size of medical stents that are placed into human arteries. If the
programmer fails to correctly design, implement, test, and deploy the
application, he could place the patient who receives the stent in a
life-threatening position.
Software Lifecycles
Software development projects are complex. To deal with these
complexities, many developers adhere to a core set of development
principles. These principles define the field of software engineering. A
major component of this field is the lifecycle model. The lifecycle model
describes steps to follow when developing software—from the initial
concept stage to the release, maintenance, and subsequent upgrading of the
software.
Many different lifecycle models currently exist. Each has advantages and
disadvantages in terms of time-to-release, quality, and risk management.
This topic describes some of the most common models used in software
engineering. Many hybrids of these models exist, so you can customize
these models to fit the requirements of a project.
1. United States, United States Government Accounting Office, Medical Device Recalls Examination of Selected Cases GAO/PEMD-90-6
(Washington: GAO, 1989) 40.
2. National Instruments tools are not designed for operating life critical support systems and should not be used in such applications.
Code and fix is a tempting choice when you are faced with a tight
development schedule because you begin developing code right away and
see immediate results.
The code and fix model is appropriate only for small projects that are not
intended to serve as the basis for future development.
Waterfall Model
The waterfall model is the classic model of software engineering. This
model is one of the oldest models and is widely used in government projects
and in many major companies. Because the model emphasizes planning in
the early stages, it catches design flaws before they develop. Also, because
the model is document and planning intensive, it works well for projects in
which quality control is a major concern.
System
Requirements
Software
Requirements
Architectural
Design
Detailed
Design
Coding
Testing
Maintenance
The following list details the steps for using the waterfall model:
1. System requirements—Establishes the components for building the
system, including the hardware requirements, software tools, and other
necessary components. Examples include decisions on hardware, such
as plug-in boards (number of channels, acquisition speed, and so on),
and decisions on external pieces of software, such as databases or
libraries.
2. Software requirements—Establishes the expectations for software
functionality and identifies which system requirements the software
affects. Requirements analysis includes determining interaction needed
with other applications and databases, performance requirements, user
interface requirements, and so on.
3. Architectural design—Determines the software framework of a system
to meet the specified requirements. The design defines the major
components and the interaction of those components, but the design
does not define the structure of each component. You also determine the
external interfaces and tools to use in the project.
4. Detailed design—Examines the software components defined in the
architectural design stage and produces a specification for how each
component is implemented.
5. Coding—Implements the detailed design specification.
6. Testing—Determines whether the software meets the specified
requirements and finds any errors present in the code.
7. Maintenance—Addresses problems and enhancement requests after
the software releases.
In some organizations, a change control board maintains the quality of
the product by reviewing each change made in the maintenance stage.
Consider applying the full waterfall development cycle model when
correcting problems or implementing these enhancement requests.
In each stage, you create documents that explain the objectives and describe
the requirements for that phase. At the end of each stage, you hold a review
to determine whether the project can proceed to the next stage. You also can
incorporate prototyping into any stage from the architectural design and
after.
Many people believe you cannot apply this model to all situations. For
example, with the pure waterfall model, you must state the requirements
before you begin the design, and you must state the complete design before
you begin coding. There is no overlap between stages. In real-world
development, however, you can discover issues during the design or coding
stages that point out errors or gaps in the requirements.
The waterfall model does not prohibit returning to an earlier phase, for
example, from the design phase to the requirements phase. However, this
involves costly rework. Each completed phase requires formal review and
extensive documentation development. Thus, oversights made in the
requirements phase are expensive to correct later.
Because the actual development comes late in the process, you do not see
results for a long time. This delay can be disconcerting to management and
to customers. Many people also think the amount of documentation is
excessive and inflexible.
Overlapping stages, such as the requirements stage and the design stage,
make it possible to integrate feedback from the design phase into the
requirements. However, overlapping stages can make it difficult to know
when you are finished with a given stage. Consequently, progress is more
difficult to track. Without distinct stages, problems can cause you to defer
important decisions until later in the process when they are more expensive
to correct.
Prototyping
One of the main problems with the waterfall model is that the requirements
often are not completely understood in the early development stages. When
you reach the design or coding stages, you begin to see how everything
works together, and you can discover that you need to adjust the
requirements.
The pure waterfall model allows for prototyping in the later architectural
design stage and subsequent stages but not in the early requirements stages.
However, prototyping has its drawbacks. Because it appears that you have a
working system, customers might expect a complete system sooner than is
possible. In most cases, a prototype is built on compromises that allow it to
come together quickly but prevent the prototype from being an effective
basis for future development. You need to decide early if you want to use the
prototype as a basis for future development. All parties need to agree with
this decision before development begins.
Be careful that prototyping does not become a disguise for a code and fix
development cycle. Before you begin prototyping, gather clear requirements
and create a design plan. Limit the amount of time you spend prototyping
before you begin. Time limits help to avoid overdoing the prototyping
phase. As you incorporate changes, update the requirements and the current
design. After you finish prototyping, consider returning to one of the other
development models. For example, consider prototyping as part of the
requirements or design phases of the waterfall model.
Systems with many user interface requirements are perfect for prototyping.
Determining the method you use to display data or prompt the user for
settings is difficult on paper. Instead, consider designing VI front panels
with the controls and indicators you need. Leave the block diagram empty
and figure out how the controls work and how various actions require other
front panels. For more extensive prototypes, tie the front panels together.
However, do not get carried away with this process.
If you are bidding on a project for a client, using front panel prototypes is an
extremely effective way to discuss with the client how you can satisfy his or
her requirements. Because you can add and remove controls quickly,
especially if the block diagrams are empty, you help customers clarify
requirements.
Spiral Model
The spiral model is a popular alternative to the waterfall model. It
emphasizes risk management so you find major problems earlier in the
development cycle. In the waterfall model, you have to complete the design
before you begin coding. With the spiral model, you break up the project
into a set of risks that you need to deal with. You then begin a series of
iterations in which you analyze the most important risk, evaluate options for
resolving the risk, deal with the risk, assess the results, and plan for the next
iteration. The following illustration shows the spiral lifecycle model.
Risk
Analysis Cumulative Cost
Prototype
Commit to
Next Cycle
Risks are any issues that are not clearly defined or have the potential to
affect the project adversely. For each risk, consider the following two things:
1. The likelihood of the risk occurring (probability)
2. The severity of the effect of the risk on the project (loss)
You can use a scale of 1 to 10 for each of these items, where 1 represents the
lowest probability or loss and 10 represents the highest. Risk exposure is the
product of these two rankings.
Use something such as the following table to keep track of the top risk items
of the project.
In general, deal with the risks that have the highest risk exposure first. In this
example, the first spiral deals with the potential of the data acquisition rates
being too high. If after the first spiral, you demonstrate that the rates are
high, you can change to a different hardware configuration to meet the
acquisition requirements. Each iteration can identify new risks. In this
example, using more powerful hardware can introduce higher costs as a new
risk.
For example, assume you are designing a data acquisition system with a
plug-in data acquisition card. In this case, the risk is whether the system can
acquire, analyze, and display data quickly enough. Some of the constraints
in this case are system cost and requirements for a specific sampling rate and
precision.
After determining the options and constraints, you evaluate the risks. In this
example, create a prototype or benchmark to test acquisition rates. After you
see the results, you can evaluate whether to continue with the approach or
choose a different option. You do this by reassessing the risks based on the
new knowledge you gained from building the prototype.
In the final phase, you evaluate the results with the customer. Based on
customer input, you can reassess the situation, decide on the next highest
risk, and start the cycle over. This process continues until the software is
finished or you decide the risks are too great and terminate development. It
is possible that none of the options are viable because the options are too
expensive, time-consuming, or do not meet the requirements.
The advantage of the spiral model over the waterfall model is that you can
evaluate which risks to handle with each cycle. Because you can evaluate
risks with prototypes much earlier than in the waterfall model, you can deal
with major obstacles and select alternatives in the earlier stages, which is
less expensive. With a standard waterfall model, assumptions about the
risky components can spread throughout the design, and when you discover
the problems, the rework involved can be very expensive.
This course refers to both the programmer and customer. This course defines
the programmer as the individual or group who uses LabVIEW to create a
solution for a particular project. The customer is the end user who uses the
solution developed by the programmer. Solutions in LabVIEW can be a
stand-alone application that consists of the solution or a set of VIs that are
used as a library. This course focuses on using good programming practices
to create a scalable, readable, and maintainable stand-alone application as a
solution to a particular project.
Summary – Quiz
1. Match each software lifecycle to its description:
Notes
Topics
A. Evaluating the Needs of the Customer
B. Communicating with the Customer
C. Developing the Requirements Document
D. Defining the Application
The customer does not always produce the specification document. Often,
you must gather the specifications based on the information the customer
provides. The specifications document should provide a good understanding
of the software to produce. However, the specifications document is not
necessarily the architecture of the software.
The customer might not have a complete understanding of the problem they
want you to solve. In this case, you must determine those details. A good
design always begins with a good understanding of the software
specifications. In order to understand the specifications, read the
specifications carefully and develop questions for the customer if the intent
of any specification is unclear.
The specification phase of the design process also allows you to identify any
areas of the specifications document that are lacking. This is the first step in
producing a requirements document.
The specifications define what the customer wants to achieve with the
software or what functions the application should perform. A thorough
specifications analysis sorts out the needs from the wants. Many times
a specifications document becomes a wish list rather than a well-defined
document. Removing the non-essential specifications from the
specifications document helps prevent feature creep.
You can sort out the needs from the wants by analyzing the key words in the
specification. Words such as shall, must, and will define specifications that
the system needs to implement. Words such as should, can, may, might, and
could indicate specifications that the customer wants but may not need. You
can organize specifications that are wants into a wish list that you can use in
the future.
Job Aid
Use the following checklist to identify areas of concern with a specifications
document. Not all items in the checklist pertain to every project
specification.
For a complete and thorough specifications document, you can check off all
applicable items in the checklist. Any items that you cannot check off are
questions for your customer.
You must interact with the customer closely to make sure the specifications
document contains all the necessary information. If information is missing,
you must determine what is missing and add it to the specifications
document.
The expectations of the customer and the programmer are different. You
must determine what expectations the customer has and how to relate to
them.
1. Jon Conway and Steve Watts, A Software Engineering Approach to LabVIEW (Upper Saddle River: Prentice Hall, 2003) 113.
It also is important to make sure that you are communicating with the right
individual. Always communicate with the individual who has design
authority.1 To save yourself frustration, formalize the decision making
process so that the person who has the final say on the project is identified
and aware of the project requirements.
In order to communicate effectively with your customer, first make sure that
you can check off each applicable item in the Specifications Content
Checklist. Any items that you cannot check off are questions for your
customer.
Job Aid
Use the following checklist when you communicate with your customer to
help make sure that you both agree on the specification items.
❑ Are all the functions that the software should perform defined?
Job Aid
Use the following requirements checklist to make sure that the requirements
document is complete and adequate. This is not a complete checklist, but it
provides a starting place to determine if the requirements document is
appropriate.
❑ Can be tested.
Scenario
You work with a Certified LabVIEW Architect to develop a requirements
document. You develop the requirements document after researching
commercially available theatre light control software and analyzing the
specifications document. You must analyze the requirements document to
ensure that it is complete and accurate.
Implementation
Analyze the requirements document for the Theatre Light Control Software.
Requirements Document
ABC Theatre Inc.
• Respond to front panel controls within 100 ms and not utilize 100% of
CPU time.
Definitions
This section defines the terminology for the project.
• Channel—The most basic element of the Theatre Light Control
Application. Each channel corresponds to a physical light.
• Intensity—Attribute of the channel that defines the intensity of the
physical light.
• Color—Attribute of the channel that defines the color of the channel as
a combination of red, green, and blue.
• Cue—A cue contains any number of independent channels with timing
attributes for the channels.
• Wait time—A cue timing attribute that defines the amount of time to
wait, in multiples of one second, before the cue fires.
• Fade time—A cue timing attribute that defines the time it takes, in
multiples of one second, before a channel reaches its particular intensity
and color.
• Follow time—A cue timing attribute that defines the amount of time to
wait, in multiples of one second, before the cue finishes.
Task
Design, implement, test, and deploy a theatre light control system that
allows a theatre lighting engineer to easily control and program the theatre
lights for any production.
General Operation
Controls on the front panel control the operation of the theatre light control
software. Indicators on the front panel indicate the current status of the
theatre light control software.
The controller will store the channel intensity, channel color, channel wait
time, channel fade time, channel follow time, and name for the cue when the
user clicks the Record button. When the user clicks the Play button, the
controller services each cue in the Cue Control by cycling through the
recorded cues starting with the first cue in the Cue Control. A cue that is
playing will wait for the specified wait time, then fade the channels to the
desired color and intensity within the specified fade time, and then wait for
the specified follow time. The next cue in the Cue Control loads and the
process repeats, until all of the Cues play. The user can stop a currently
playing cue by clicking the Stop button. The controller exits when the user
selects File»Exit.
Sequence of Operation
Application Run
When the application starts, all of the controls must initialize to the default
states as shown on the front panel. The Cue Control must be cleared to
remove all of the recorded Cues. The channels must be initialized with their
corresponding channel number, zero intensity, and the zero color.
Record
Click the Record button to activate the cue recording functionality. A
custom panel must open that allows the lighting engineer to set the channel
intensity and color for the channels. The panel must provide for the
capability to name the cue, and specify the wait time, fade time, and the
follow time. The minimum time for the wait time and follow time is zero
seconds. The minimum time for the fade time is one second. The minimum
increment for the wait time, fade time, and follow time is one second.
After a cue is recorded, the cue name is placed into the Cue Control.
Play
Click the Play button to play the recorded cues. When the play begins, the
controller should disable the Record button and the Cue List on the front
panel. The values of the first cue in the cue list is loaded into memory. The
controller waits based on the number of seconds specified for the wait time
for the current cue. The controller then fades the channel up or down based
on the current channel intensity and the desired channel intensity. The
software writes the color and intensity to the theatre lighting hardware
control system, and updates the front panel channels. The controller must
finish fading within the specified fade time. The controller will finish
processing the cue by waiting for the number of seconds specified for the
follow time of the current cue. When the play is complete, the controller
should enable the Record button and the Cue List on the front panel.
Stop
Click the Stop button to stop a currently playing cue. The operation is
ignored if a cue is not playing.
Save
Click File»Save to save all of the recorded cues in a file for later playback.
The user specifies the filename.
Open
Click File»Open to open a file that contains recorded cues. The user
specifies the filename.
Exit
Click File»Exit to exit the application. If an error has occurred in the
application, the application reports the errors.
Scalability
Many of the newer theatre lights systems provide motor control to move the
light around the stage. The Theatre Light Control Software should provide
for the ability to easily implement channel pan and tilt. The software should
be easily scalable to control any number of channels.
Documentation
The application documentation should address the needs of the end user and
a programmer who might modify the application in the future.
Deliverables
The project includes the following deliverables:
• Documented source code
• Documentation that describes the system
Timeline
The project has the following timeline for completion:
• Day 1—User Interface prototype completed
• Day 2—Application modules completed
• Day 3—Fully functional application
Before you develop a detailed design of a system, define the goals clearly.
Begin by making a list of requirements. Some requirements are specific,
such as the types of I/O, sampling rates, or the need for real-time analysis.
Do some research at this early stage to be sure you can meet the
specifications. Other requirements depend on user preferences, such as file
formats or graph styles.
You can take the list of requirements directly from the specifications. Try to
distinguish between absolute requirements and desires. While you can try to
satisfy all requests, it is best to have an idea about which features you can
sacrifice if you run out of time.
Be careful that the requirements are not so detailed that they constrain the
design. For example, when you design an I/O system, the customer probably
has certain sampling rate and precision requirements. However, cost is also
a constraint. Include all these issues in the requirements. If you can avoid
specifying the hardware, you can adjust the design after you begin
prototyping and benchmarking various components. As long as the costs are
within the specified budget and the timing and precision issues are met, the
customer might not care whether the system uses a particular type of plug-in
card or other hardware.
One way to limit the amount of information you have to write when
analyzing a project is to draw a diagram of the application. Creating a
diagram helps improve your ability to design the application and convey
ideas to your customer. The first step in creating a diagram is to determine
the abstract components of each requirement.
Procedural Abstraction
Procedural abstraction separates what a procedure accomplishes from how
the procedure is implemented. For example, consider the following
application outline.
Procedure Implementation
Open datalog file.
Data Abstraction
Data abstraction separates the data you want to store from the physical
means of storing the data. Data abstraction provides a more logical view of
the data rather than the bits and bytes that create the data. An example of
data abstraction is a cluster. A cluster can represent data with a more logical
view without requiring the user to be concerned with the details of its
implementation.
1. Jeri R. Hanly and Elliot B. Koffman, Problem Solving and Program Design in C (Reading:Addison-Wesley, 1996) 622.
2. Martin Ward, A Definition of Abstraction, 2003, www.dur.ac.uk/martin.ward/martin/papers/abstraction-t.pdf, Science.
Task
Design, implement, test, and deploy a theatre light control system that
allows a theatre lighting engineer to easily control and program the theatre
lights for any production.
Controls on the front panel control the operation of the theatre light control
software. Indicators on the front panel indicate the current status of the
theatre light control software.
General Operation
The controller will store the channel intensity, channel color, channel wait
time, channel fade time, channel follow time, and name for the cue when the
user clicks the Record button. When the user clicks the Play button, the
controller services each cue in the Cue Control by cycling through the
recorded cues starting with the first cue in the Cue Control. A cue that is
playing will wait for the specified wait time, then fade the channels to the
desired color and intensity within the specified fade time, and then wait for
the specified follow time. The user can stop a currently playing cue by
clicking the Stop button. The controller exits when the user selects File»
Exit.
The following list shows the nouns from the previous requirements
document.
Status Controller
Cue User
Selected Cue
After you have a set of nouns, you can group the nouns into actual
components of your system. The following table organizes the components
into more abstract components.
Note The abstract components are one set of components that allow you to modularize
the system. You can abstract an infinite number of components. Experience and
understanding the problem help you to abstract the best set of components for the
application.
Play
Click the Play button to play the recorded cues. When the play begins, the
controller should disable the Record button and the Cue List on the front
panel. The values of the first cue in the cue list is loaded into memory. The
controller waits based on the number of seconds specified for the wait time
for the current cue. The controller then fades the channel up or down based
on the current channel intensity and the desired channel intensity. The
software writes the color and intensity to the theatre lighting hardware
control system and updates the front panel channels. The controller must
finish the fading within the specified fade time. The controller will finish
processing the cue by waiting for the number of seconds specified for the
follow time of the current cue. When the play is complete, the controller
should enable the Record button and the Cue List on the front panel.
Extract the verbs from the excerpt of the requirements document. Consider
the context of the verbs to establish what functions the abstract components
perform.
The following list shows the verbs from the previous requirements
document excerpt.
click disable
loaded waits
fades writes
enable update
After you have a set of verbs, you can organize the verbs to determine what
functions the abstract components perform. You can ignore verbs that do not
improve your understanding of the system, such as click in the previous list.
You must also try to remember the context of the verbs. The following table
organizes the verbs into the abstract components.
Creating a phrase for each verb improves readability and provides the
following function list.
Module Actions
Hardware Write Color and Intensity
Display Initialize Front Panel
Update Front Panel
Select Cue
Enable/Disable Front Panel
Update Cue List
Cue Add Cue
Get Cue Values
Set Cue Values
Get Number of Cues
Get Empty Cue
Timing Wait Time
Fade Time
Follow Time
Error Report Errors
Handle Errors
File Save Cues
Read Cues
After you identify the high-level actions for each module, you can break
each action into smaller actions. This technique helps you to further analyze
the application and guarantee each individual module accomplishes only
one goal. When a module accomplishes more than one goal, it is difficult to
test the module and determine that it works correctly.
If you determine that a module performs more than one goal, break the
module into more modules. With this design, each module performs one
specific goal. Creating a software design with this level of detail helps you
develop VIs that are scalable, readable, and that consist of reusable code.
Coupling
A module rarely stands by itself. A VI is called by other VIs. Top-level VIs
can become plug-ins to other VIs or utilities for the operating system.
Coupling refers to the connections that exist between modules. Any module
that relies on another module to perform some function is coupled to that
module. If one module does not function correctly, other modules to which
it is coupled do not function correctly. The more connections among
modules, the harder it is to determine what module causes a problem.
Coupling measures how many dependencies a system of modules contains.
The fewer outputs a module exposes, the more you can change the code
inside the module without breaking other modules. Low coupling also helps
make bug tracking more efficient. For example, a data acquisition bug
cannot occur in a VI that performs only GPIB instrument control. If a data
acquisition bug appears in a GPIB VI, you know the code is probably too
tightly coupled.
Cohesion
In a well-designed VI, each module fulfills one goal and thus is strongly
cohesive. If a single module tries to fulfill more than one goal, you should
probably break it into modules. When a module tries to accomplish multiple
goals, the block diagram becomes harder to read, and the code for one goal
can affect how the code for another goal works. In this case, fixing a bug in
one goal might break the code of another goal.
A VI with strong cohesion has one goal per module. Strong cohesion
decreases overall development time. You can more easily understand a
single module if it focuses on one task. You can read a clean, uncomplicated
block diagram quickly and make deliberate changes with confidence.
The Mathematics VIs and functions that ship with LabVIEW demonstrate
strong cohesion. For example, the Sine function performs a single goal, and
performs it well. It is a perfect example of a function that has strong
cohesion. The name of the function clearly indicates what the function
accomplishes. Other VIs that have strong cohesion are the File I/O VIs and
functions. The File I/O VIs and functions perform sequential cohesion
because one module must execute before another module can execute. The
Open File, Read File, Write File, and Close File functions each perform a
single goal within each module.
After you have abstracted the components, you can produce a diagram that
helps to visualize the abstracted components. Use the diagram to start
designing the individual modules in the application. Each abstracted
component corresponds to a module within the application. At the top level,
you define the actions for each abstracted component. Defining the actions
allows you to determine the specific goal of each individual module.
Flowcharts
Flowcharts are a powerful way to organize ideas related to a piece of
software. Flowcharts should provide a good understanding of the
application flow. The block diagram programming paradigm used in
LabVIEW is easy to understand and similar to a flowchart. Many engineers
already use flowcharts to describe systems. The flowchart makes it easier to
convert the design into executable code.
Load
Cue
Wait
Wait Time No
Elapsed
Yes
No Fade Time
Elapsed
Yes
Wait
Follow Time No
Elapsed
Yes
End
Figure 2-1. Flowchart of Play Function in the Theatre Light Control System
Dataflow Diagrams
Dataflow diagrams follow the paradigm of LabVIEW in that they represent
the flow of data through an application. Figure 2-2 shows the common
symbols used in dataflow diagrams.
1 2 3 4
Figure 2-3 shows a dataflow diagram for the Play functionality in the
Theatre Light Control System. Notice that the focus of a dataflow diagram
is the data. A dataflow diagram conceptualizes the system based on the flow
of data through the system, similar to the dataflow paradigm of LabVIEW.
Even though LabVIEW is a dataflow programming language, it is important
to spend time away from LabVIEW to design an appropriate system.
Light Control
System
Update Handle
Display Error Error
Channel Intensity
and Color Data
Follow Time
Fade Time
Wait Time
As you can see by the differences in the flowchart and the dataflow diagram
of the Play function in the Theatre Light Controller, the processes are
different. Nodes in the flowchart represent the functions to perform. Nodes
in the dataflow diagram represent the processes and the focus is on the flow
of data through the system. You can translate a dataflow diagram into a
LabVIEW block diagram.
Summary – Quiz
1. Match the document to its purpose:
Notes
At the end of this lesson, you design a user interface for a software project
that you analyzed.
Topics
A. User Interface Design Issues
B. User Interface Layout Issues
C. Front Panel Prototyping
D. User Interface Examples
E. Localizing User Interfaces
Refer to the Text Characteristics topic in the LabVIEW Help for more
information about setting the default font, using custom fonts, and changing
the font style.
The actual font used for the three standard fonts (application, system, and
dialog) varies depending on the platform. For example, when working on
Windows, preferences and video driver settings affect the size of the fonts.
Text might appear larger or smaller on different systems, depending on these
factors. To compensate for this, allow extra space for larger fonts and enable
the Size to Text option on the shortcut menu.
For example, if a label is to the left of an object, justify the label to the right
and leave some space to the left of the text. If you center a label over or under
an object, center the text of that label as well. Fonts are the least portable
aspect of the front panel so always test them on all target platforms.
Colors
Color can distract the user from important information. For instance, a
yellow, green, or bright orange background makes it difficult to see a red
danger light. Another problem is that some platforms do not have as many
colors available. Use a minimal number of colors, emphasizing black, white,
and gray. The following are some simple guidelines for using color:
• Never use color as the sole indicator of device state. People with some
degree of color-blindness can have problems detecting the change. Also,
multiplot graphs and charts can lose meaning when displayed in black
and white. Use lines for plot styles in addition to color.
• Consider coloring the pane backgrounds on the front panel background
and objects of user interface VIs with the system colors, or symbolic
colors, in the color picker. System colors adapt the appearance of the
front panel to the system colors of any computer that runs the VI.
• Use light gray, white, or pastel colors for backgrounds. The first row of
colors in the color picker contains less harsh colors suitable for front
panel backgrounds and normal controls. The second row of colors in the
color picker contains brighter colors you can use to highlight important
controls. Select bright, highlighting colors only when the item is
important, such as an error notification.
• Always check the VI for consistency on other platforms.
The top of the color picker contains a grayscale spectrum and a box you
can use to create transparent objects. The second spectrum contains
muted colors that are well suited to backgrounds and front panel objects.
The third spectrum contains colors that are well suited to highlights.
Figure 3-1 shows the color picker in LabVIEW.
1 2
Keep these things in mind when designing a front panel. For most objects,
use complimentary neutral colors that vary primarily in their brightness. Use
highlight colors sparingly for objects such as plots, meter needles, company
logo, and so on.
Graphics
You can import graphics and text objects to use as front panel backgrounds,
items in picture rings, and parts of custom controls and indicators.
Check how the imported graphics look when you load the VI on another
platform. For example, a Macintosh PICT file that has an irregular shape
might convert to a rectangular bitmap with a white background on Windows
or Linux.
One disadvantage of using imported graphics is that they slow down screen
updates. Make sure you do not place indicators and controls on top of a
graphic object so that LabVIEW does not have to redraw the object each
time the indicator updates. If you must use a large background picture with
controls on top of it, divide the picture into several smaller objects and
import them separately because large graphics usually take longer to draw
than small ones.
Keep inputs on the left and outputs on the right whenever possible to
minimize confusion on the part of the user. Use the Align Objects,
Distribute Objects, and Reorder Objects pull-down menus to create a
uniform layout.
Consider using the following tools and techniques to improve the layout of
user interface front panels.
Run-Time Menus
To help reduce clutter, use menus. You can create custom menus for every
VI you build, and you can configure VIs to show or hide menu bars.
You can build custom menus or modify the default LabVIEW menus
statically when you edit the VI or programmatically when you run the VI.
Static Menus
To add a custom menu bar to a VI rather than the default menu bar, select
Edit»Run-Time Menu and create a menu in the Menu Editor dialog box.
LabVIEW creates a run-time menu (.rtm) file. After you create and save
the .rtm file, you must maintain the same relative path between the VI and
the .rtm file. You also can create a custom run-time shortcut menu by
right-clicking a control and selecting Advanced»Run-Time Shortcut
Menu»Edit. This option opens the Shortcut Menu Editor. When the VI
runs, it loads the menu from the .rtm file.
Click the blue + button, shown at left, on the toolbar to add more items to
the custom menu. Click the red X button, shown at left, to delete items. You
can arrange the menu hierarchy in the Menu Editor dialog box by clicking
the arrow buttons on the toolbar, using the hierarchy manipulation options
in the Edit menu, or by dragging and dropping.
When you create a custom menu, you assign each menu item a unique,
case-insensitive string identifier called a tag. When the user selects a menu
item, you retrieve its tag programmatically using the Get Menu Selection
function. LabVIEW provides a handler on the block diagram for each menu
item based on the tag value of each menu item. The handler is a While Loop
and Case structure combination that allows you to determine which, if any,
menu is selected and to execute the appropriate code.
After you build a custom menu, build a Case structure on the block diagram
that executes, or handles, each item in the custom menu. This process is
called menu selection handling. LabVIEW handles all application items
implicitly.
Use the Get Menu Selection and Enable Menu Tracking functions to define
what actions to take when users select each menu item.
You also can add shortcut menus to front panels. To add a shortcut menu to
the front panel, use the Shortcut Menu Activation and Shortcut Menu
Selection pane events.
Note Custom run-time shortcut menus appear only while the VI runs.
Decorations
Use decorations, such as a Raised Box or Horizontal Smooth Box, to
visually group objects with related functions.
.
2
1
Tab Controls
Use tab controls to overlap front panel controls and indicators in a smaller
area. A tab control consists of pages and tabs. Place front panel objects on
each page of a tab control and use the tab as the selector for displaying
different pages.
Tab controls are useful when you have several front panel objects that are
used together or during a specific phase of operation. For example, you
might have a VI that requires the user to first configure several settings
before a test can start, then allows the user to modify aspects of the test as it
progresses, and finally allows the user to display and store only pertinent
data.
The NI Example Finder, shown in Figure 3-3, is a VI that uses tab controls
to organize the user interface.
Subpanel Controls
Use the subpanel control to display the front panel of another VI on the front
panel of the current VI. For example, you can use a subpanel control to
design a user interface that behaves like a wizard. Place the Back and Next
buttons on the front panel of the top-level VI and use a subpanel control to
load different front panels for each step of the wizard.
Note You can create and edit subpanel controls only in the LabVIEW Full and
Professional Development Systems. If a VI contains a subpanel control, you can run the
VI in all LabVIEW packages, but you cannot configure the control in the Base Package.
Refer to the Front Panel Controls and Indicators topic in the LabVIEW
Help for more information about subpanel controls.
Tree Controls
Use the tree control to give users a hierarchical list of items from which to
select. You organize the items you enter in the tree control into groups of
items, or nodes. Click the expand symbol next to a node to expand it and
display all the items in that node. You also click the symbol next to the node
to collapse the node.
Note You can create and edit tree controls only in the LabVIEW Full and Professional
Development Systems. If a VI contains a tree control, you can run the VI in all LabVIEW
packages, but you cannot configure the control in the Base Package.
Refer to the Front Panel Controls and Indicators topic in the LabVIEW
Help for more information about tree controls.
Refer to the Front Panel Controls and Indicators topic in the LabVIEW
Help for more information about scroll bar controls.
you can scroll each pane individually. Each pane has its own set of controls
and indicators on it. The splitter bar separates the controls on one pane from
those on another pane, yet the terminals for all controls are on the same
block diagram.
Refer to the Creating Splitter Bars and Panes topic in LabVIEW Help for
more information about split pane containers. Refer to the Creating Custom
Toolbars section of Exercise 3-1 for an example that uses the split pane
container to create a toolbar.
Front panels should open in the upper-left corner of the screen for the
convenience of users with small screens. Place sets of VIs that are often
opened together so the user can see at least a small part of each. Place front
panels that open automatically in the center of the screen. Centering the
front panels makes the VI easier to read for users on monitors of various
sizes. Use the VI Properties dialog box to customize the window appearance
and size.
Labels
The name of a control or indicator should describe its function. If the control
is visible to the user, use captions to display a long description and add a
short label to prevent using valuable space on the block diagram. For
example, when you label a ring control or slide control that has options for
volts, ohms, or amperes, select an intuitive name for the control. A caption
such as “Select units for display” is a better choice than “V/O/A”. Use
Property Nodes to change captions programmatically.
For Boolean controls, use the name to give an indication of which state
(TRUE or FALSE) corresponds to the function (for example, ON) and
indicate the default state in parenthesis. For checkboxes and radio buttons,
the user can click the Boolean text of the control and the value of the
Boolean control changes. Free labels next to a Boolean control can help
clarify the meaning of each position on a switch. For example, use free
labels like Cancel, Reset, and Initialize that describe the action taken.
The Context Help window displays labels as part of the connector pane. If
the default value is essential information, place the value in parentheses next
to the name in the label. Include the units of the value if applicable.
Give each control a reasonable default value, which allows the example to
run without the user modifying its value whenever possible. All default
values and/or units should be added to the label in parentheses, if
appropriate, as shown in Figure 3-6.
Captions
Front panel objects also can have captions. Right-click the object and select
Visible Items»Caption from the shortcut menu to display the caption. You
can use captions instead of labels to localize a VI without breaking the VI.
Unlike a label, a caption does not affect the name of the object, and you can
use it as a more descriptive object label. The caption appears only on the
front panel.
If you assign the object to a connector pane terminal, the caption appears in
a tip strip when you use the Wiring tool to move the cursor over the terminal
on the block diagram. The caption also appears next to the terminal in the
Context Help window if you move the cursor over the connector pane or VI
icon.
Captions are useful for providing detailed descriptions when the label text
needs to be concise or for providing concise descriptions when the label text
needs to be more detailed. Captions also are useful when creating localized
versions of an application.
Use a path constant and the path data type to supply a constant path value to
the block diagram. The path constant and data type use the platform-specific
notation for paths, unlike the string constant and data type.
A VI should not fail when run with default values. Do not set default values
of indicators like graphs, arrays, and strings without a good reason because
that wastes disk space when saving the VI.
Use default values intelligently. In the case of many File I/O VIs and
functions, such as the Write to Spreadsheet File VI, the default is an empty
path that forces the VI to display a file dialog box. This can save the use of
a Boolean switch in many cases.
Key Navigation
Some users prefer to use the keyboard instead of a mouse. In some
environments, such as a manufacturing plant, only a keyboard is available.
Consider including keyboard shortcuts for VIs even if the use of a mouse is
available because keyboard shortcuts add convenience to a VI.
Pay attention to the key navigation options for objects on the front panel and
set the tabbing order for the objects to read left to right and top to bottom.
Set the <Enter> key as the keyboard shortcut for the front panel default
control, which is usually the OK button. However, if you have a multiline
string control on the front panel, you might not want to use the <Enter> key
as a shortcut.
If the front panel has a Cancel button, set the <Esc> key to be the keyboard
shortcut. You also can use function keys as navigation buttons to move from
screen to screen. If you do this, be sure to use the shortcuts consistently.
Select Edit»Set Tabbing Order to arrange controls in a logical sequence
when the user needs to tab between the controls. For controls that are
offscreen, use the Key Navigation tab of the Properties dialog box to skip
over the controls when tabbing or to hide the controls.
Also consider using the key focus property to set the focus
programmatically to a specific control when the front panel opens.
Front panel controls and indicators can appear in modern, classic, or system
style.
Many front panel objects have a high-color appearance. Set the monitor to
display at least 16-bit color for optimal appearance of the objects.
The controls and indicators located on the Modern palette also have
corresponding low-color objects. Use the controls and indicators located on
the Classic palette to create VIs for 256-color and 16-color monitor settings.
The first example in Figure 3-7 uses controls from the Modern palette. The
second example in Figure 3-7 uses controls from the Classic palette. You
also can use Classic controls for VIs that require an efficient user interface.
1 2 3
1 User Interface Built Using Modern Controls 3 User Interface Built Using System Controls
2 User Interface Built Using Classic Controls
Use the system controls and indicators located on the System palette in
dialog boxes you create. The system controls and indicators are designed
specifically for use in dialog boxes and include ring and spin controls,
numeric slides, progress bars, scroll bars, listboxes, tables, string and path
controls, tab controls, tree controls, buttons, checkboxes, radio buttons, and
an opaque label that automatically matches the background color of its
parent. These controls differ from those that appear on the front panel only
in terms of appearance. These controls appear in the colors you have set up
for the system.
Use the System controls palette to create user interfaces that look more
professional, as shown in the third example in Figure 3-7.
If new options are presented, follow those ideas by creating new front panels
to illustrate the results. This kind of prototyping helps to define the
requirements for a project and gives you a better idea of its scope.
Systems with many user interface requirements are perfect for prototyping.
Determining the method you use to display data or prompt the user for
settings is difficult on paper. Instead, consider designing VI front panels
with the controls and indicators you need. Leave the block diagram empty
and figure out how the controls work and how various actions require other
front panels. For more extensive prototypes, tie the front panels together.
However, do not get carried away with this process.
If you are bidding on a project for a client, using front panel prototypes is an
extremely effective way to discuss with the client how you can satisfy his or
her requirements. Because you can add and remove controls quickly,
especially if the block diagrams are empty, you help customers clarify
requirements.
Limit the amount of time you spend prototyping before you begin. Time
limits help to avoid overdoing the prototyping phase. As you incorporate
changes, update the requirements and the current design.
Figure 3-9 shows the same user interface with several improvements, such
as reduced use of color, regrouped controls, fewer labels, knobs instead of
sliders, and rearranged objects.
Refer to the Porting and Localizing VIs topic in the LabVIEW Help for more
information about localizing VIs.
Job Aid
Use the following checklist to ensure that your user interface follows good
user interface design principles.
❑ Use Size to Text for all text for portability and add carriage returns if
necessary.
❑ Write descriptions and create tip strips for controls and indicators,
including array, cluster, and refnum elements.
❑ Remember that if you copy the object to another VI, you also copy the
description. You might need to change the description for the new
object.
❑ Do not overlap controls with other controls, with their label, digital
display, or other objects unless you want to achieve a special effect.
Overlapped controls slow down screen updates and can make the control
or indicator flicker.
❑ Provide a stop button if necessary. Do not use the Abort button to stop
a VI. Hide the Abort button.
❑ Make sure all the controls on the front panel are of the same style. For
example, do not use both classic and modern controls on the same front
panel.
Description
LabVIEW includes features that allow you to create professional user
interfaces. Learn techniques to remove borders from clusters, create custom
cursors, create custom toolbars, and use the transparency property to
enhance the user’s experience with your application.
Implementation
Removing Cluster Borders
Clusters group data elements of mixed types. However, sometimes you do
not want the user to know that you have organized the data into a cluster. The
clusters on the Modern palette visually indicate that the data is stored in a
container, while it is relatively easy to set up clusters on the Classic palette
to hide that data is organized in a cluster.
2. Create a cluster from the Classic palette and make the borders of the
cluster transparent.
Tip If the Controls palette is not visible on the front panel, select View»Controls
Palette to display the palette.
Tip You can use the Search button to find controls, VIs or functions. On the Controls
or Functions palette, click the Search button on the palette toolbar. In the text field at the
top of the search dialog, start typing the name of the control, VI, or function you want to
find. As you type, the listbox shows all possible matches. When you find the control, VI,
or function you are looking for, double-click its name. This opens the palette where the
control, VI, or function is located and flashes the icon whose name you just
double-clicked.
❑ Click a blank area of the front panel with the Get Color tool to copy
the color of the front panel to the foreground and background colors
used by the Set Color tool.
Tip If the Tools palette is not visible on the front panel, select View»Tools Palette to
display the palette.
❑ Select the Set Color tool. In the bottom box, select the color block
that is appears to be laying on top of the other. This is the foreground
color block. Clicking it opens the color picker.
❑ Click the T in the upper right corner of the color picker to change the
foreground color to transparent.
❑ Click the border of the cluster with the Set Color tool as shown in
Figure 3-10. Notice that the cluster border disappears.
You also can use this technique with other Classic controls. The
Classic controls are easier to modify and customize than Modern
controls.
1. Create a VI that contains a While Loop and the Set Cursor VI to change
the appearance of the cursor as shown in Figure 3-11.
❑ Create a Stop button on the front panel and wire it to the loop
conditional terminal of the While Loop.
❑ Place a Wait (ms) function inside the While Loop, and set the Wait
(ms) function to a reasonable wait amount, such as 100 ms.
❑ Place the Set Cursor VI from the Cursor palette inside the While
Loop.
❑ Right-click the icon input of the Set Cursor VI and select Create»
Control from the shortcut menu.
To create a toolbar at the top of your VI, place a horizontal splitter bar on
the front panel and place a set of controls in the upper pane. When you use
a splitter bar to create a toolbar, lock the splitter bar in position and turn off
scrollbars for the upper pane. To configure the splitter bar, set the splitter to
Splitter Sticks Top and set the scrollbars of the upper pane to Always Off.
You also can paint the pane and resize the splitter so that it blends seamlessly
with the menu bar. You can scroll the scrollbars of the lower pane or split the
lower pane further without affecting the controls on the toolbar.
2. Place a Horizontal Splitter Bar from the Containers palette on the front
panel. Position the splitter bar near the top of the VI. Leave enough
space above the bar to place the menu controls.
3. To turn off the scrollbars, right-click the splitter bar and select Always
Off from the Upper Pane»Horizontal Scrollbar and Upper Pane»
Vertical Scrollbar shortcut menus.
4. To change the style of the splitter bar to system, right-click the splitter
bar and select Splitter Style»System from the shortcut menu.
5. To add controls to the pane above the splitter bar, place the toolbar
controls located in the <Exercises>\LabVIEW Intermediate I\
User Interface Design Techniques\Toolbar Controls
directory in the upper pane created by the splitter bar.
6. Rearrange the controls and color the splitter bar to look like a toolbar.
❑ Color the background of the pane to blend the controls into the
panel.
– Click the background color block of the Set Color tool to open
the color picker.
– Click the More Colors button in the bottom right corner of the
color picker to open the Color dialog box.
– Enter the following values and click OK to set the background
color:
Red: 231
Green: 223
Blue: 231
7. To lock the splitter bar so that the user cannot move it, right-click the
splitter bar and make sure Locked is checked in the shortcut menu.
❑ Place a Flat Square button from the Classic palette on top of the
Tank, and resize the control to fit completely on top of the Tank.
❑ Change the True and False color of the button to transparent by using
the Set Color tool.
❑ Click the button with the Operate Value tool to verify that the button
is transparent whether it is True or False.
3. Insert a Case structure into the While Loop so the Tank Value indicator
updates only when the button on top of the tank is True, as shown in
Figure 3-14.
❑ Place a Case structure inside the While Loop to enclose the Tank
Value indicator.
❑ Wire the Boolean control to the case selector terminal of the Case
structure.
4. Run the VI and test the behavior of the VI when you click the Tank
indicator.
Summary – Quiz
1. Which of the following control types is NOT suited to improving
organization on the front panel?
a. Subpanel control
b. Tab control
c. Boolean button
Notes
Topics
A. Design Patterns
B. Event-Based Design Patterns
C. Advanced Event-Based Design Patterns
D. Creating a Hierarchical Architecture
E. Using the LabVIEW Project and Project Libraries
F. Choosing Data Types
G. Information Hiding
H. Designing Error Handling Strategies
A. Design Patterns
To take the first step in choosing a scalable architecture, explore the
architectures that exist within LabVIEW. Architectures are essential for
creating a successful software. The most common architectures are usually
grouped into design patterns.
There are many design patterns available for LabVIEW. Most applications
use at least one design pattern. Select File»New to open the New dialog box
and access VI templates based on common design patterns. The LabVIEW
Basics II: Development Practices course explores some of the basic design
patterns you can use in LabVIEW, which are summarized in the following
sections.
Figure 4-1 shows the block diagram of the Determine Warnings VI from the
LabVIEW Basics I: Introduction course. This VI performs a single task: it
determines what warning to output dependent on a set of inputs. You can use
this VI as a subVI whenever you want to determine the warning level instead
of rebuilding the block diagram every time you perform the conversion.
The error clusters control the execution order of the three sections. The Wait
function prevents the loop from running continuously, especially if the loop
monitors user input on the front panel. Continuous loops can use all of the
computer system resources. The Wait function forces the loop to run
asynchronously even if you specify a wait of 0 milliseconds. If
the operations inside the main loop react to user inputs, increase the wait to
100–200 ms because most users do not detect that amount of delay between
clicking a button on the front panel and the resulting action.
In a user interface state machine, different user actions send the user
interface into different processing segments. Each processing segment acts
as a state in the state machine and can lead to another segment or wait for
another user action.
For a process test state machine, each state represents a segment of the
process. The test result of a state determines the next state. State transitions
can occur continually, providing an in-depth analysis of a process.
The While Loop implements the flow of the state transition diagram. Cases
in the Case structure represent individual states. A shift register on the While
Loop keeps track of the current state and communicates the current state to
the Case structure input.
For each message that might be sent, the Case structure contains one case
with appropriate code to handle the message. The Case structure also can
have a default case that queues new events if the queue is empty.
Each iteration of the While Loop removes the top message from the queue
and runs the proper handling subdiagram in the Case structure. Handlers
that have a Default or No Event case execute this code when the queue is
empty. The While Loop terminates when the Exit message reaches the top
of the queue.
Remember the following key points when using the queued message
handler design pattern:
• Always terminate the While Loop by checking the latest message rather
than by polling a control. Checking the latest message allows you to
execute any necessary cleanup code before shutting down the main
While Loop.
• Although you can generate new messages inside the handler code for a
message, it is possible to generate an infinite cascade of messages,
which would effectively hang the user interface. A good guideline is to
require that messages generated by handler code never generate new
messages of their own.
Use the parallel loop design pattern for simple menu VIs where you expect
a user to select from one of several buttons that perform different actions.
You can handle multiple, simultaneous, independent processes and
responding to one action does not prevent the VI from responding to another
action. For example, if a user clicks a button that displays a dialog box,
parallel loops can continue to respond to I/O tasks.
The master/slave design pattern separates the data flow of the block diagram
into independent processes and uses globally available shared data to
synchronize data transfer among loops. However, using a global variable to
transfer data among the master and slave loops breaks the LabVIEW
dataflow paradigm, allows for race conditions, and incurs more overhead
than passing the data by wire.
Use a notifier to pass data from the master to the slave to remove any issues
with race conditions. Using notifiers improves synchronization because the
master and slave are timed when data is available. Figure 4-7 shows the
master/slave design pattern using notifiers.
With a master/slave design pattern, make sure that no two While Loops
write to the same shared data.
The slave loop should not take too long to respond to the master. If the slave
is processing a signal from the master and the master sends more than one
message to the slave, the slave only receives the latest message. Use a
master/slave design pattern only if you are certain that each slave task
executes faster than the master loop.
The consumer loop processes the data at its own pace, while the producer
loop continues to queue additional data. You also can use the
producer/consumer (data) design pattern to create a VI to analyze network
communication where two processes operate at the same time and at
different speeds. The first process constantly polls the network line and
retrieves packets. The second process analyzes the packets retrieved by the
first process. The first process acts as the producer because it supplies data
to the second process, which acts as the consumer. The parallel producer and
consumer loops handle the retrieval and analysis of data off the network, and
the queued communication between the two loops allows buffering of the
network packets retrieved.
Because the event handler loop wakes up precisely when an event occurs
and sleeps in between events, you do not have to poll or read control values
repeatedly in order to detect when a user clicks a button. The user interface
event handler allows you to minimize processor use without sacrificing
interactivity.
A common problem when using the user interface event handler is that it
computes the While Loop termination before the Event structure executes.
This can cause the While Loop to iterate one more time than desired. To
avoid this situation, compute the While Loop termination within all your
event handling code.
The event handler code must execute quickly, generally within 200 ms.
Anything slower can seem like the user interface is locked up. Also, if the
event handler code takes a long time to execute, the Event structure might
lock. By default, the front panel locks while an event is handled. You can
disable front panel locking for each event case to make the user interface
more responsive. However, any new events that are generated while an event
is being handled will not be handled immediately. So, the user interface will
still be unresponsive.
Any code that is in an event case cannot be shared with another Event
structure. You must utilize good code design when using the Event structure.
Modularize code that will be shared between multiple Event structure cases.
Figure 4-10 shows how you can use Synchronization VIs and functions to
add functionality to the design pattern. Queues have the ability to transfer
any data type. The data type transferred in Figure 4-10 is a string. A string
is not the most efficient data type for passing data in design patterns. A more
efficient data type for passing data in design patterns is a cluster consisting
of an enumerated type control and a variant.
Producer
User
Queue
Event
Consumer
This section describes user events and how to use them to create advanced
event-based design patterns.
User Events
You programmatically can create and name your own events, called user
events, to carry user-defined data. Like queues and notifiers, user events
allow different parts of an application to communicate asynchronously. You
can handle both user interface and programmatically generated user events
in the same Event structure.
The user event out output of the Create User Event function is a strictly
typed refnum that carries the name and data type of the user event. Wire the
user event out output of the Create User Event function to an event source
input of the Register For Events function.
You cannot register for a user event statically. Handle a user event the same
way you handle a dynamically registered user interface event. Wire the
event registration refnum output of the Register For Events function to the
dynamic event terminal on the left side of the Event structure. Use the Edit
Events dialog box to configure a case in the Event structure to handle the
event. The name of the user event appears under the Dynamic subheading
in the Event Sources section of the dialog box.
The user event data items appear in the Event Data Node on the left border
of the Event structure. User events are notify events and can share the same
event case of an Event structure as user interface events or other user events.
You can wire a combination of user events and user interface events to the
Register For Events function.
If the user event is not registered, the Generate User Event function has no
effect. If the user event is registered but no Event structure is waiting on it,
LabVIEW queues the user event and data until an Event structure executes
to handle the event. You can register for the same user event multiple times
by using separate Register For Event functions, in which case each queue
associated with an event registration refnum receives its own copy of the
user event and associated event data each time the Generate User Event
function executes.
Note To simulate user interaction with a front panel, you can create a user event that has
event data items with the same names and data types as an existing user interface event.
For example, you can create a user event called MyValChg by using a cluster of two
Boolean fields named OldVal and NewVal, which are the same event data items the
Value Change user interface event associates with a Boolean control. You can share the
same Event structure case for the simulated MyValChg user event and a real Boolean
Value Change event. The Event structure executes the event case if a Generate User Event
function generates the user event or if a user changes the value of the control.
Scenario
This VI contains the Fire Event Boolean control that causes an LED to light
when the user clicks the control. In addition, the block diagram contains a
countdown that displays on the slider on the front panel. When the
countdown reaches zero, a programmatic event fires that lights the LED.
Design
1. Modify the block diagram to create and generate a user event for the
LED.
2. Configure the Fire Event event case to handle both the Value Change
event on the Fire Event Boolean control and the User event.
Implementation
1. Open User Event.vi located in the <Exercises>\LabVIEW
Intermediate I\User Event Techniques directory. Figure 4-12
and Figure 4-13 show the front panel and block diagram.
❑ Generate the event within the True case of the programmatic loop.
– Place a Generate User Event function, located on the Events
palette, on the block diagram.
– Place a True constant on the block diagram and wire it to the
event data input on the Generate User Event function.
– Complete wiring the Generate User Event function as shown in
Figure 4-14. The True case executes only when the countdown
reaches zero.
Configure Events
3. Place an Event structure, located on the Structures palette, inside the
user interface loop.
❑ Wire the Event Registration Refnum from the Register For Events
node to the dynamic event terminal of the Event structure.
Tip If the dynamic event terminal is not visible, right-click on the border of the Event
structure and select Show Dynamic Event Terminals from the shortcut menu.
❑ Wire the error and Event Count shift registers from the left border of
the User Interface Loop to the left border of the Event structure.
4. Complete the following steps to configure the Fire Event event case to
handle both the Value Change event on the Fire Event Boolean control
and the User event, as shown in Figure 4-15.
❑ Move the Fire Event Boolean control into Event Case 0 so the VI
reads the value of the control when the event executes.
5. Create and configure the Stop event case to handle the Value Change
event on the Stop Boolean control as shown in Figure 4-16.
❑ Right-click the Event structure and select Add Event Case from the
shortcut menu to open the Edit Events dialog box.
❑ Select Stop from the Event Sources list and Value Change from
the Events list.
❑ Move the Stop Boolean control into Event Case 1 and wire the
control to the right border of the Event structure.
6. Complete the block diagram as shown in Figure 4-17 to stop the User
Interface Loop, release the user event resources, and handle any errors
that have occurred. You will use the following items:
Testing
1. Run the VI. Try to generate a user interface event at the same time as a
programmatic event. Does the VI record both events?
2. Stop the VI and move the Fire Event Boolean control from the event
case to outside the While Loop. Try running the VI again. What
happens? Because the Boolean control is a latch, the VI must read the
control to reset it. When the control is outside the While Loop, the VI
reads it only once during the execution of the VI.
Job Aid
Use Table 4-1 to determine the best uses for the design patterns described in
this lesson.
Use Figure 4-19 as a guide to help in determining the best design pattern to
use for an application.
Pre-store Queued
Contains a Yes Yes
Sequence Message
Sequence?
Execution? Handler
No No
State Machine
Intensive Producer/
Responds to Yes Yes
Processing Consumer with
User Interface?
Needed? Events
No No User Interface
Event Handler
Relation Is Timing
Parallel Yes Yes Yes
Between the Loop Master/Slave
Operations?
Loops? Relation?
No No No Producer/
Consumer
Hierarchy
It is good development style to create a good module hierarchy in
LabVIEW. A good module hierarchy has high cohesion and low coupling.
You can graph the VIs that are coupled to other VIs within a hierarchy.
Graphing the hierarchy helps you visualize the coupling among modules.
Modules within an application should appear near each other in the
hierarchy. Select View»VI Hierarchy to display the VI Hierarchy
window. The module hierarchy should have independent sections that are
shaped somewhat like a diamond, as shown in Figure 4-20.
Plan your application before you build it. Think about what operations are
necessary. A complex application includes major tasks, such as network
communication or data acquisition, and minor tasks, such as user login or
dialog box display. Most of the smallest tasks, such as string concatenation
and basic mathematics, have existing VIs or functions in LabVIEW. Try to
build modules that have only one goal and accomplish that goal well.
If you are editing an existing VI, understand what function each part of the
block diagram performs before you insert new functionality. Strive to
achieve strong cohesion. Mimic existing organization patterns. If all
existing waveform calculations occur in one module, make sure that you add
any new waveform calculations to the same module.
Job Aid
Use the following checklist to create a hierarchical architecture and
determine if each VI uses the correct level of detail.
You must use a project to build applications and shared libraries. You also
must use a project to work with an RT, FPGA, Mobile, Touch Panel, DSP,
or embedded target. Refer to the specific module documentation for more
information about using projects with these targets.
If you are using a project with an NI device driver, refer to the specific driver
documentation for more information about using projects with drivers.
The Project Explorer window includes two pages, the Items page and the
Files page. The Items page displays the project items as they exist in the
project tree. The Files page displays the project items that have a
corresponding file on disk. You can organize filenames and folders on this
page. Project operations on the Files page both reflect and update the
contents on disk. You can switch from one page to the other by
Note The LabVIEW Real-Time, FPGA, PDA, Touch Panel, and DSP Modules add
functionality to the LabVIEW development system and must be purchased separately.
An item can appear only once under a target. For example, if you add a file
from a directory on disk to the My Computer target and then add the entire
directory to the My Computer target, LabVIEW does not include the file
again.
From the Items page in the Project Explorer window, you can add items
under a target in a project in the following ways.
• Right-click a target and select New»VI from the shortcut menu to add a
new, blank VI. You also can select File»New VI or Project»Add To
Project»New VI to add a new, blank VI. You also can add a VI to the
project by selecting the VI icon in the upper right corner of a front panel
or block diagram window and dragging the icon to the target. When you
add a VI to the project, LabVIEW automatically adds its entire hierarchy
to the Project Explorer window under Dependencies.
• Right-click a target and select New from the shortcut menu then select
Control, Library, Variable, I/O Server, Class, or XControl from the list
to add one of these items to the project.
• Right-click a target and select New»Virtual Folder from the shortcut
menu to add a virtual folder under a target. A virtual folder is a folder in
the project that organizes project items and does not represent files on
disk. You also can create subfolders by right-clicking a virtual folder and
selecting New»Virtual Folder from the shortcut menu.
• Right-click a target or a folder under the target, select Add»File from the
shortcut menu, and select the file you want to add from the dialog box.
You also can select the target, select Project»Add To Project»File, and
select the file you want to add from the dialog box.
• Right-click a target or a folder under the target, select Add»Folder
(Snapshot) from the shortcut menu, and select the file(s) you want to
add from the dialog box. You also can select the target, select Project»
Add To Project»Folder (Snapshot), and select the file(s) you want to
add from the dialog box.
• Right-click a target or a folder under a target and select Add»Folder
(Auto-populating) from the shortcut menu to display a file dialog box.
You also can select a target and then select Project»Add To Project»
Folder (Auto-populating).
• Right-click a target, or a folder or library under a target, and select Add»
Hyperlink from the shortcut menu. The Hyperlink Properties dialog
box appears. You also can select the target and select Project»Add to
Project»Hyperlink to display the Hyperlink Properties dialog box.
• Use the Add File, Add Item, or Add Item From Memory method to add
items to a project programmatically. Use the HyperLink Address
property to set the address of a hyperlink item.
• (Windows and Mac OS) Select an item or directory on disk and drag it to
the target.
Note You cannot drag and drop items in the Project Explorer window to the file
system.
You also can add new LabVIEW files to a project from the New dialog box.
Select File»New or Project»Add To Project»New to display the New
dialog box. In the New dialog box, select the item you want to add and place
a checkmark in the Add to project checkbox. If you have multiple projects
open, select the project to which you want to add the item from the Projects
list.
Items you add to the Project Explorer window can include icons.
Auto-populating folders are visible only on the Items page of the Project
Explorer window. You can view the disk contents of an auto-populating
folder but you cannot perform disk operations such as renaming,
reorganizing, and removing project items. To perform disk operations of
items in an auto-populating folder, use the Files page of the Project
Explorer window. The Files page displays the location of project folders on
disk. Project operations on the Files page both update and reflect the
contents of the folder on disk. Likewise, LabVIEW automatically updates
the auto-populating folder in the project if you make changes to the folder
on disk outside of LabVIEW.
Note Auto-populating folders can contain virtual items such as variables and hyperlinks
because these items do not have a corresponding item on disk. You can rearrange virtual
items such as variables and hyperlinks within an auto-populating folder because the
movement does not result in a movement on disk. You also can move virtual items into
and out of auto-populating folders.
Project Dependencies
Use Dependencies to view items that VIs under a target require. Each target
in a LabVIEW project includes Dependencies. Dependencies lists the VI
hierarchies of all VIs in the project. LabVIEW organizes Dependencies into
three folders: vi.lib, user.lib, and Items in Memory.
Note If you previously hid Dependencies in the Project Explorer window, you must
display the item again to access it in the Project Explorer window.
Note Items that a VI calls dynamically do not appear under Dependencies. You must
add these items under a target to manage them in a project.
You cannot create new items under Dependencies. You cannot drag items
from other places in the Project Explorer window to Dependencies.
Note Items in the project may refer to other items. For example, if you remove a subVI
from the project that another VI in the project calls, the subVI will move to
Dependencies.
Project libraries are useful if you want to organize files into a single
hierarchy of items, avoid potential VI name duplication, limit public access
to certain files, limit editing permission for a collection of files, and set a
default palette file for a group of VIs. You can drag items that a project
library owns from the Project Explorer window to the block diagram or front
panel.
You can view the structure of a project library from the Project Explorer
window or in a stand-alone project library window. If you are not in the
Project Explorer window, right-click a project library file and select Open
from the shortcut menu to open it in the project library window.
Note If the project library file you select is not the top-level project library file, the
stand-alone window that opens is the project library window of the top-level project
library. The project library file you select is in the contents tree of the top-level project
library window.
Use project libraries to qualify the names of VIs and other LabVIEW files.
LabVIEW identifies VIs by filename, so LabVIEW unintentionally might
load and reference a VI because the VI has the same filename as another VI,
a problem known as cross-linking. When a VI is part of a project library,
LabVIEW qualifies the VI name with the project library name to avoid
cross-linking. A qualified name includes the filename and the qualified
name of the owning project library.
Note Only one project library can own a specific VI. However, you can associate a file
not specific to LabVIEW, such as a text file or HTML file, with multiple project libraries.
Caution You must right-click the project library and select Save As or Rename from the
shortcut menu to display the Save As dialog box and rename project libraries. If you
rename a project library outside LabVIEW, you might break the project library.
Use project libraries to limit access to certain types of files. You can
configure access to items and folders in a project library as public or private
to prevent users from accessing certain items. When you set access for a
folder as private, all VIs in that folder also have private access.
Note When you enter a password for a library in a LabVIEW project that does not have
a valid license specific to the version of LabVIEW you purchased, you cannot drag and
drop items into or out of the library.
Note Adding password protection to a project library does not add password protection
to the VIs it owns. You must assign password protection to individual VIs.
You can create project libraries from project folders. You also can convert
LLBs to project libraries. LLBs have different features and advantages than
project libraries, so consider the ways in which you might use an LLB
before you decide whether to convert it to a project library. You can include
project library files in an LLB.
If you include a palette file (.mnu) in a project library, you can set it as the
default palette file for all VIs that the project library owns. The default
palette file for a project library is the palette available in the shortcut menu
when you right-click a sub-VI call to any VI that the project library owns,
just as source palettes are available in the shortcut menus for many VIs and
functions placed on the block diagram from the Functions palette.
However, unlike source palettes, the default palette file for a project library
does not have to contain any VIs from the project library it belongs to. From
the General Settings page of the Project Library Properties dialog box,
select the palette file in the Default Palette ring control. You also can set the
default palette file from the Item Settings page. Select the .mnu file in the
Contents tree and place a checkmark in the Default Palette checkbox.
Project Sublibraries
Project sublibraries are project libraries that another project library owns.
The settings in the owning project library do not affect access settings and
editing permission for items within the project sublibrary. You can set the
access of a project sublibrary file (.lvlib) as private within the owning
project library, but when you edit the project sublibrary itself, items the
sublibrary owns retain public or private access settings.
Project sublibraries are useful if you want to create a project library that
includes separate areas of functionality. For example, if you are creating a
project library of graphics tools, you might divide the two-dimensional and
three-dimensional drawing tools into separate sublibraries. Each project
sublibrary can include private and public access items and folders.
Note If you add a VI that is not in memory to a project library, a dialog box appears that
prompts you to save changes to the VI. Save changes to the VI so it will link correctly to
the owning project library.
3. Select File»Save All or right-click the project library icon and select
Save»Save As from the shortcut menu to name and save the project
library file.
4. Right-click the project library icon and select Properties from the
shortcut menu to display the Project Library Properties dialog box.
5. From the General Settings page, set the version number, create or select
an icon, and assign security settings to the project library.
Note The icon you select becomes the default icon for any VIs you create from within
the project library. You can create a template icon to edit and use in all VIs that a project
library owns.
6. From the Documentation page, enter information for context help for
the project library.
7. From the Item Settings page, set access options for files in the project
library.
8. Click OK to update the project library with the edited settings and close
the dialog box.
From the Project Explorer window, right-click the virtual folder to convert
and select Convert To Library from the shortcut menu. LabVIEW converts
the folder to a project library, which appears in the Project Explorer
window with the items it owns listed under it.
You can name the new project library file when you save it. Right-click the
project library and select Save from the shortcut menu.
Determine which items in the project library you want to set as public and
which as private. Public items might include palette VIs, XControls,
instrument drivers, and other tools you want users to find and use. Private
items might include support VIs, copyrighted files, or items you might want
to edit later without taking the risk of breaking users' code.
You can set the access of a project sublibrary file (.lvlib) as private within
the owning project library, but when you edit the project sublibrary itself,
items the sublibrary owns retain public or private access settings.
Note If you specify access options for a folder, the access setting applies to all items in
the folder and overrides access options for individual items in the folder.
Note You can set individual instances of a polymorphic VI as private and set the primary
polymorphic VI as public. The polymorphic VI does not break even though instance VIs
are private. Setting instance VIs as private is useful if you want users to access instances
only through the polymorphic VI selector, so you can edit instance order without causing
user problems.
3. Click OK to incorporate the changes into the project library and close
the dialog box.
Items set as private appear in the Project Explorer window with a private
icon. If you lock the project library, private items do not appear in the
Project Explorer window.
Note Adding password protection to a project library does not add password protection
to the VIs it owns. You must assign password protection to individual VIs.
Complete the following steps to set levels of protection for a project library.
1. Right-click the project library icon in the Project Explorer or
stand-alone project library window and select Properties from the
shortcut menu to display the Project Library Properties dialog box.
2. From the General Settings page, select one of the following options to
apply to the project library.
• Unlocked (no password)—Users can view public and private items
that the project library owns and can edit the project library and its
properties.
• Locked (no password)—Users cannot add or remove items from
the project library, edit project library properties, or view private
items that the project library owns. For example, if you are
developing a project library and do not want anyone to view private
files, you should lock the project library.
• Password-protected—Users cannot add or remove items from the
project library, edit project library properties, or view private items
that the project library owns. Users must enter a password to edit the
project library. For example, if you are developing a project library
and want only a few people on the development team to have editing
permission, set a password for the project library and give the
password to those people.
3. If you select Password-protected, click the Enter Password button to
enter the password.
4. Enter a password in the Authentication dialog box and click Verify.
5. Click OK to incorporate the changes into the project library and close
the dialog box.
Note Applying a password for a project library automatically stores the password in the
LabVIEW password cache, which gives you access to make changes to the project library
as if you had entered the password to unlock the library. You can remove the password
from the cache by restarting LabVIEW or by clearing the password cache from the
Environment page of the Options dialog box.
– Assume that all project library files that are not in the private
folder are public. You do not need to create a folder for public files.
– You also can organize public and private items in a project library by
creating folders for each functionality group within a project library
and adding a private subfolder within each functionality group
folder.
• Adding password protection to a project library does not add password
protection to the VIs it owns. You must assign password protection to
individual VIs if you want to limit edits to the block diagrams and front
panels. Consider using the same password for the project library and for
the VIs the project library owns to avoid confusion.
Scenario
Every large LabVIEW development needs to use a project to control naming
and project hierarchy. Using the LabVIEW Project simplifies the
development of larger applications.
Design
Create a LabVIEW project that includes folders for modules and controls.
Save the project as in the <Exercises>\LabVIEW Intermediate I\
Course Project directory.
Implementation
1. Launch LabVIEW.
3. Create a virtual folder for modules and a virtual folder for controls in the
My Computer hierarchy. You use these virtual folders later in the
course.
Tip Change the qualified name of a conflicting item by adding it to a LabVIEW project
library. When a VI is part of a project library, LabVIEW qualifies the VI name with the
project library name to avoid cross-linking. A qualified name includes the filename and
the qualified name of the owning project library filename. The qualified name changes
without changing the path or filename.
The best way to determine if cross-linking exists is to view the full path to
the item. Right-click the project root and select View»Full Paths from the
shortcut menu to display the Paths column and view the file paths that
correspond to the project items. You either must rename or remove all but
one item with the same qualified name from the project. To view detailed
information about existing conflicts, click the Resolve Conflicts button to
display the Resolve Project Conflicts dialog box. You also can select
Project»Resolve Conflicts from the project menu to display this dialog box
or right-click a conflicting item and select Resolve Conflicts from the
shortcut menu.
You can right-click a specific conflicting item on the Items page and select
Find»Conflicts to view all conflicting items in the Find Conflicts dialog
box. If the item only conflicts with one other item, LabVIEW highlights the
item in the Project Explorer window. You also can use the Find:Conflicts
property to find conflicts in the project programmatically.
When two or more items have the same qualified name, and only one item
exists on disk, you can right-click a conflicting item and select Replace
with Item Found by Project from the shortcut menu. LabVIEW updates
the callers of the incorrect item to reference the item found on disk. If you
do not want to remove the conflicting item and you detect it has the same
qualified name as another item in the project, you can rename the item or
add the item to a project library. Renaming the item loads the callers that
reference the incorrect item path, renames the item, and saves the item and
all callers. The callers reference the new name. If you do not save the callers,
the original item appears under Dependencies because callers still reference
the item.
If you detect that one or more VIs incorrectly refers to the wrong subVI,
redirect all callers to reference a subVI with a different path. Right-click a
conflicting VI in the Project Explorer window and select Replace with
from the shortcut menu to choose the correct subVI on disk. Select a
replacement file from the file dialog that appears. LabVIEW automatically
updates all items that reference the incorrect path to reference the
replacement. You also can load each VI that refers to a conflicting item. The
Resolve Load Conflict dialog box appears. You can choose a specific caller
VI to load.
Note LabVIEW dims Replace with Item Found by Project and Replace with if the
item is a project library or a member of a project library.
If you think that one or more VIs incorrectly refers to an item that LabVIEW
cannot find, right-click the project root and select Find Missing Items from
the shortcut menu. The Find Missing Items dialog box appears. This dialog
box lists all items in the project that reference an item on disk that LabVIEW
cannot find.
You can remove caller VIs from the project to resolve conflicts when a
hierarchy of VIs conflicts with the hierarchy of other contents in the project.
Right-click a VI or type definition and select Find»Callers or Find»
SubVIs from the shortcut menu to highlight the caller or subVI the item
references in the Project Explorer window. If more than one caller or
subVI exists in the project, the Find Callers or Find SubVIs dialog box
appears. Right-click a project root or target and select Find Items with No
Callers from the shortcut menu to display the Find Items with No Callers
dialog box and find all top-level items. If no callers reference a conflicting
subVI, remove the subVI from the project. You also can use the
Find:Callers, Find:SubVIs, or Find:Items with No Callers properties to find
callers, subVIs, and items with no callers programmatically.
LabVIEW also scans the VI hierarchy when you open the block diagram of
a VI and add a new subVI. The subVI does not load if any members of its
hierarchy have the same qualified name but different paths as an item
already in the project. The Add to Project and Update Dependencies
dialog box appears. You can add the hierarchy or cancel the load and choose
another subVI.
Note Deleting an item that has callers from the project moves the item to Dependencies.
The item is a conflicting item until you remove all callers that call the conflicting item
from the project.
Scenario
Conflicts can arise within a LabVIEW project if top-level VIs are calling
incorrect versions of nested code. Applications that are saved in multiple
locations as a result of archiving, backup or division of work can lead to the
use of incorrect code and broken applications.
Design
The project in this exercise contains two conflicts:
• Two VIs within the project have the same name, Generate
Signal.vi.
• A VI in the project calls a subVI, Log to File.vi, outside the project
that has the same name as a VI within the project.
Implementation
❑ Expand the Sine Wave, Square Wave, File IO, and Dependencies
items in the Project Explorer as shown in Figure 4-21.
Note Viewing filepaths is often the first step when attempting to resolve conflicts that
are caused by cross-linking. You can attempt to rename or move files as needed, but first
you must determine which file is the correct file. Enabling Show Item Paths displays the
file locations in a second column.
Note You can resolve the project conflicts from the Resolve Project Conflicts dialog
window, but you will resolve the conflicts with various techniques throughout this
exercise.
❑ LabVIEW prompts you to save the changes made to the calling VI,
Create and Save Signal.vi, to preserve the links. Click Save.
❑ LabVIEW prompts you to save the changes made to the calling VI,
Create and Save Signal.vi, to preserve the links. Click Save.
❑ In the Resolve Load Conflict window, select the Log to File VI in the
Working Directory directory and click Load with Selected.
❑ A warning dialog appears informing you that the Log to File subVI
was loaded from a different location. Click Show Details.
❑ Examine the Load and Save Warning List window. Click Close.
All conflicts in the project should now be resolved.
Note In Auto-populate mode, the contents of the project folder reflect the hierarchy of
the specified folder on disk, as well as any changes that are made outside of the
development environment.
❑ Select Sine Wave - Generate Signal.vi and click Go To. This item
should now be highlighted in the Project Explorer window.
Scalars
Scalar data is the most basic data structure in LabVIEW. Scalar data can be
a number or a Boolean value. Use scalar data in your VIs for items that
contain only a single value. For example, if your software requirements
specify the use of a stop button in a VI, design a data structure that uses a
single Boolean stop button. If the VI requires that you use a device number
to specify the hardware to access, design a data structure that contains an
integer numeric to contain the device number. Examine all aspects of a
software requirements document and identify all data elements that are
appropriately represented as scalar data.
Arrays
Arrays group data elements of the same type. Arrays are powerful data
structures for storing sets of the same data type where each data element is
associated with the others. Use arrays to contain data that includes more
than one element of the same data type and each element is associated with
one another. For example, if you need to contain data that streams from a
hardware device, such as a DAQ device, design a data structure that includes
an array to handle that data. Storing the streaming data into individual scalar
elements is impractical and results in a VI that is difficult to debug and use.
Clusters
Clusters enable you to create data structures that contain any type of data.
A cluster is useful for storing data about objects. When you create software,
you might need to model real-world items. For example, you might need to
Job Aid
Use the following checklist to help identify appropriate data structures.
❑ Use scalars for data items that are associated with single, non-related
items.
❑ Make sure all scalar data would never need to be a more advanced data
structure.
❑ Use arrays for items of the same type that should be grouped together.
❑ Use clusters for items of different or similar types that can be grouped
to form a single, coherent data item.
Scenario
When you develop a VI, you must identify and design the data types that you
need to use in the application.
Design
Design a cluster called Cue for the cue information that contains the
following data elements:
• Cue Name (string)
• Wait Time (32-bit unsigned integer)
• Fade Time (32-bit unsigned integer)
• Follow Time (32-bit unsigned integer)
• Channels (2D array of channel.ctl)
The final cluster should resemble Figure 4-24. Use controls from the
System palette where appropriate, so your application will look like the
native operating system when moved to different locations.
Implementation
1. Open the TLC project if it is not already open.
❑ Right-click the Controls virtual folder in the TLC project tree and
select Add»File from the shortcut menu.
4. Create the Cue Name, Wait Time, Fade Time, and Follow Time controls.
Use the System palette to create the controls. Place the controls inside
the cluster.
❑ Place a system string control in the cluster and label the control Cue
Name.
❑ Place a system numeric control in the cluster and label the numeric
Wait Time (s).
❑ Place two copies of the Wait Time (s) control inside the cluster.
Name one Fade Time (s) and name one Follow Time (s).
5. Create the Channels 2D array shell. Turn off index display for the array.
❑ Place an array from the Modern palette inside the cluster. Change
the label of the array to Channels.
❑ Right-click the array shell and select Add Dimension from the
shortcut menu to make the array 2D.
7. Click and drag channel.ctl from the Project Explorer window into
the Channel array shell that you created in step 5.
G. Information Hiding
When you design a data structure, consider whether you need to limit
interaction among components. When you develop a VI, it is important to
protect the data so that other modules or applications can not modify the
data. In academia, protecting the data is often referred to as data
encapsulation or information hiding. In this course, information hiding
refers to preventing or limiting other components from accessing data items
in a module except through some predetermined method. Use information
hiding to create VIs that are highly reliable and easy to maintain.
Consider a VI that accesses data using a global variable. It is possible for any
module to access that same global variable and change its value without any
other module knowing that the global variable has changed, as shown in
Figure 4-25.
1 2
1 VI1 Accesses Data in a Global Variable 2 VI2 Accesses the Same Data in a Global Variable
The advantage to using information hiding is that you alleviate the details
from the program. All the work that needs to happen to read from and write
to a data item occurs in a lower-level VI. You can modify the functionality
of the data without breaking the code that calls the VI that hides the
information. The only thing you need to modify is the VI that operates on
the data. This improves reliability when you are working with data in a VI.
Whenever you are working with data in LabVIEW, make sure that you
create an interface that can interact with the data in the system. This
interface is a VI that can read from and/or write to the data.
Figure 4-28 shows a simple functional global variable with set and get
functionality.
Figure 4-28. Functional Global Variable with Set and Get Functionality
In this example, data passes into the VI and is stored in the shift register if
the enumerated data type is configured to Set. Data is retrieved from the
shift register if the enumerated data type is configured to Get.
Tip Before you use a local or global variable, make sure a functional global variable
would not have worked instead.
The Elapsed Time case gets the current date and time in seconds and
subtracts it from the time that is stored in the shift register. The Reset Time
case initializes the functional global variable with a known time value.
Job Aid
In order to achieve information hiding, ensure that all data items have an
interface to read from and/or write to the data.
Scenario
Build a VI that uses a functional global variable to provide an interface to
the Cue data type you created in Exercise 4-4. The functional global
variable provides a safe way to access the data that the application needs.
Design
To provide an interface to the data in the Cue data type, you need to create
a VI that can access the Cue data type. Create a functional global variable to
access the data.
Implementation
1. Open the TLC project if it is not already open.
2. Create a Cue virtual folder in the Modules virtual folder of the TLC
project.
5. Set the default value of the Fade Time (s) input to 1 second.
❑ Right-click the Fade Time (s) control and select Data Operations»
Make Current Value Default from the shortcut menu.
6. Complete the Add Cue case as shown in Figure 4-30 using the following
items. This case is used whenever a new cue is being recorded.
Note A True constant is wired to the loop condition terminal so that the loop iterates
only once every time it is called.
7. Complete the Get Cue Values case as shown in Figure 4-31 using the
following item. This case is used to load the next cue from the Cue List.
❑ Index Array
8. Complete the Set Cue Values case as shown in Figure 4-32 using the
following item. This case is called whenever an existing cue is being
modified.
9. Complete the Get Number of Cues case as shown in Figure 4-33 using
the following item. This case is used to retrieve the recorded cues and to
update the cue list on the user interface.
10. Complete the Initialize case as shown in Figure 4-34 using the following
item. This case is called when the Theatre Light Control software is
started.
Tip To create the cluster constant, right-click the right array tunnel and select Create»
Constant from the shortcut menu.
❑ Unbundle By Name
11. Complete the Get Empty Cue case, as shown in Figure 4-35 using the
following items.
This case is called whenever a blank cue is needed, such as initialization
of the front panel and when recording a new cue. A blank cue consists
of an intensity of zero, a color of black, and the appropriate channel
number.
Tip Create more working space on the front panel or block diagram by pressing the
<Ctrl> key and using the Positioning tool to drag out a rectangle where you want more
space.
Tip To create a local variable, right-click the outside border of the Cue Output indicator
on the front panel and select Create»Local Variable.
This VI provides controlled access to the data stored in the cue. With this
type of VI, the data is protected.
Testing
Test the VI to verify its operation.
❑ Command = Initialize
❑ Rows = 4
❑ Columns = 8
Verify that there are 4 rows by increasing the Row Index from
0 to 3. Verify that there are 8 rows by increasing the Column Index
from 0 to 7. The element in row 3, column 7 should be Channel 31.
❑ Cue Input = Place dummy data in the Wait Time(s), Fade Time(s),
and Follow Time(s) controls.
❑ Cue Index = 0
13. Verify that the Cue Output matches the information that you placed in
step 6.
During the software design process, you must define a strategy for handling
errors. There are three primary strategies you can use to handle errors in
LabVIEW.
• You can design a proactive system that catches potential errors. For
example, you might need to catch any problems in a configuration
before the system passes the configuration to a data acquisition driver.
The system can prevent the data acquisition driver from executing if
there are errors in the configuration.
• You can design corrective error processing that tries to determine the
error and fix the error. This allows each module to implement error
correcting code. For example, you could develop a Read File I/O VI to
fix errors that occur in the Open/Create/Replace File VI.
• You can design a system that reports errors to the user. If an error occurs,
the individual modules do not execute, and the system notifies the user
what error occurred.
When creating software, you should develop separate error handling code
for two phases of the process—development and deployment. During
development, the error handling code should be noticeable and should
clearly indicate where errors occur. This helps you determine where any
bugs might exist in a VI. During deployment, however, you want the error
handling system to be unobtrusive to the user. This error handling system
should allow a clean exit and provide clear prompts to the user.
When you design the error handling strategy, consider how the system
should respond based on the severity of the error. If the error is only a
warning, it is not necessary to completely stop the system when the error
occurs. For example, consider a File dialog box that contains a Cancel
button the user can click to cancel the selection of a file. If the user clicks
the Cancel button, the entire software system should not stop. It is
preferable to log this type of error as a warning. An exception error indicates
that something drastic has occurred in the system, such as a file logging
system that runs out of storage space. Exception errors should prevent the
rest of the system from operating.
Error Handling
You can choose other error handling methods. For example, if an I/O VI on
the block diagram times out, you might not want the entire application to
stop and display an error dialog box. You also might want the VI to retry for
a certain period of time. In LabVIEW, you can make these error handling
decisions on the block diagram of the VI.
Use the LabVIEW error handling VIs and functions on the Dialog & User
Interface palette and the error in and error out parameters of most VIs and
functions to manage errors. For example, if LabVIEW encounters an error,
you can display the error message in different kinds of dialog boxes. Use
error handling in conjunction with the debugging tools to find and manage
errors.
VIs and functions return errors in one of two ways—with numeric error
codes or with an error cluster. Typically, functions use numeric error codes,
and VIs use an error cluster, usually with error inputs and outputs.
Error handling in LabVIEW follows the dataflow model. Just as data values
flow through a VI, so can error information. Wire the error information from
the beginning of the VI to the end. Include an error handler VI at the end of
the VI to determine if the VI ran without errors. Use the error in and error
out clusters in each VI you use or build to pass the error information through
the VI.
Error Clusters
The error in and error out clusters include the following components of
information:
• status is a Boolean value that reports TRUE if an error occurred.
• code is a 32-bit signed integer that identifies the error numerically. A
nonzero error code coupled with a status of FALSE signals a warning
rather than a error.
• source is a string that identifies where the error occurred.
Error Codes
You can create custom error messages that are meaningful for your own VIs.
Determine where possible errors can occur in the VI, and define error codes
and messages for those errors. National Instruments recommends that you
use the General Error Handler VI to define custom error codes in the range
of 5000 to 9999 and –8999 to –8000. However, you also can define
custom error codes in the same range using the Error Code File Editor
dialog box. Use this method if you want to use the same custom error codes
with several VIs or if you want to distribute custom error codes with an
application or shared library. If you want to distribute the custom error codes
with an application or shared library, you must distribute the error code text
files.
Complete the following steps to define custom error codes using the Error
Code File Editor.
1. Select Tools»Advanced»Edit Error Codes to launch the Error Code
File Editor.
2. In the prompt that appears, click the New button to create a new error
codes file or click the Open button to browse to an existing error codes
file.
3. Enter comments about the error codes file in the Comments about this
file text box.
4. Click the Add button to add an error code and description to the error
codes file.
5. After you create new error codes, you can select and edit the error code
descriptions using the Error code and Error text controls.
6. When you are done editing the error codes file, select File»Save to save
the error codes file in the labview\user.lib\errors directory. You
must save the error codes file in the format xxx-errors.txt, where
xxx is a name that you supply.
You also can define custom error codes in the same range by creating an
XML-based text file. You must name the text file xxx-errors.txt, where
xxx is a name that you supply. The xxx-errors.txt file must use the
following syntax exactly, including capitalization, spacing, and so on. You
supply the italic text:
<?xml version="1.0"?>
<nidocument>
<nicomment>
This file describes custom errors for my VI.
</nicomment>
<nierror code="5000">
Memory full.
Add more memory.
</nierror>
<nierror code="5001">
Invalid name. Enter a new name.
</nierror>
</nidocument>
Changes to error code text files take effect the next time you start LabVIEW.
Job Aid
Use the following checklist to determine the critical sections of a VI that
require an error handling strategy.
Scenario
Creating an error code that is custom to the application is easy in the
LabVIEW environment. Using the error code in the application provides a
detailed description of the error that occurred. You can use this information
to diagnose the error and where the error occurred. Every application that
contains multiple states must provide a method and strategy for handling
errors.
Design
Use the LabVIEW Error Code File Editor to create the following error code,
based on a possible error that can occur in the application.
Implementation
Part A: Edit the Error Code File
1. Open the TLC project if it is not already open.
❑ Create the error code as specified in the Design section. Click the
Add button to open the Add Error Code dialog box.
Note LabVIEW automatically sets the New Code value to 5000 and increments it each
time you click the Add button.
❑ Enter the description from the table in the Design section in the New
Description text box. Click OK to add the error code.
❑ Open the block diagram and place a Case structure around the While
Loop.
❑ Wire the error in and error out clusters to the Case structure and the
While Loop.
2. Modify the Get Cue Values case to determine if the desired cue exists
before attempting to obtain its value. Figure 4-36 shows the True and
False cases for the Get Cue Values case. To build the Get Cue Values
case, use the following items:
❑ Case Structure
❑ Error Cluster From Error Code VI—Place this cluster in the False
case of the Get Cue Values Case structure.
Note Error Cluster From Error Code VI converts an error or warning code to an error
cluster. This VI is useful when you receive a return value from a DLL call or when you
return user-defined error codes.
3. Modify the Set Cue Values case to determine if the desired cue exists
before attempting to change its value. Figure 4-37 shows the True and
False cases for the Set Cue Values case. To build this case, you use the
same items that you used for Step 2.
Testing
1. Restart LabVIEW to load the error code file.
❑ Enter an invalid Cue Index with Command set to Get Cue Values.
3. Verify that the error explanation matches what you specified when you
created the error code file.
❑ Right-click the error cluster and select Explain Error from the
shortcut menu.
4. Verify that the same error is generated if you enter an invalid Cue Index
with Command set to Set Cue Values.
Summary – Quiz
1. Which of the following describes good module hierarchy?
a. High cohesion and high coupling
b. High cohesion and low coupling
c. Low cohesion and high coupling
d. Low cohesion and low coupling
Notes
Topics
A. Implementing User Interface-Based Data Types
B. Implementing Meaningful Icons
C. Implementing Appropriate Connector Panes
Scalar Data
As described in Lesson 3, Designing the User Interface, an example of a
scalar value can be a numeric value or a Boolean value. There are many
ways to organize scalar data to improve the user interface and the usability
of the application. The preferred method for organizing scalar data is to use
a ring control or enumerated type control. These controls associate a
numeric value with a text string that the user sees on the front panel or user
interface.
Ring Controls
Ring controls are numeric objects that associate numeric values with strings
or pictures. Ring controls appear as pull-down menus that users can cycle
through to make selections.
Ring controls are useful for selecting mutually exclusive items, such as
trigger modes. For example, use a ring control for users to select from
continuous, single, and external triggering.
When you configure the list of items for a ring control, you can assign a
specific numeric value to each item. If you do not assign specific numeric
values to the items, LabVIEW assigns sequential values that correspond to
the order of the items in the list, starting with a value of 0 for the first item.
ring control instead of a Boolean control because if you decide to change the
control to include more than two options, you can add options easily to a
ring control.
Enumerated type controls are useful for making block diagram code easier
to read because when you wire an enumerated type control to a Case
structure, the string labels appear in the selector label of the Case structure.
Bits of
Storage
Terminal Numeric Data Type on Disk Approximate Range on Disk
Extended-precision, 128 Minimum positive number: 6.48e–4966
floating-point
Maximum positive number: 1.19e+4932
Minimum negative number: –6.48e–4966
Maximum negative number: –1.19e+4932
Double-precision, 64 Minimum positive number: 4.94e–324
floating point
Maximum positive number: 1.79e+308
Minimum negative number: –4.94e–324
Maximum negative number: –1.79e+308
Bits of
Storage
Terminal Numeric Data Type on Disk Approximate Range on Disk
Single-precision, 32 Minimum positive number: 1.40e–45
floating point
Maximum positive number: 3.40e+38
Minimum negative number: –1.40e–45
Maximum negative number: –3.40e+38
long signed integer 32 –2,147,483,648 to 2,147,483,647
Arrays
Arrays group data elements of the same type. You can build arrays of
numeric, Boolean, path, string, waveform, and cluster data types. Consider
using arrays when you work with a collection of similar data and when you
perform repetitive computations. Arrays are ideal for storing data you
collect from waveforms or data generated in loops, where each iteration of
a loop produces one element of the array.
Users can view the data stored in the array using the index display. However,
the best method for displaying the data stored in an array is to output the data
to a graph rather than placing an array on the front panel of a VI. It is much
easier for a user to view the array data in a graph rather than in an array.
Keep in mind the following rules when you work with arrays:
Note You can use a multidimensional array or the Build Cluster Array function to create
an array of clusters where each cluster contains one or more arrays.
Clusters
Clusters group data elements of mixed types. An example of a cluster is the
LabVIEW error cluster, which combines a Boolean value, a numeric value,
and a string. Using clusters to store data provides the following advantages:
• Clusters eliminate wire clutter on the block diagram and reduce the
number of connector pane terminals a subVI uses.
• Clusters allow you to create specific, organized data objects.
Clusters are valuable tools for creating readable, maintainable VIs. You can
create clusters that include any data type you choose. When you create a
cluster, you should always create a type definition of the cluster so you can
add new data elements to the cluster. Creating a cluster with a type definition
helps make your data structures and your VIs more scalable, readable, and
maintainable.
Always use the Bundle By Name and Unbundle By Name functions with
clusters in your VIs. The Bundle By Name and Unbundle By Name
functions help make your block diagram more readable because you can
identify the data that you are placing in or using from the cluster. Also, these
functions do not require you to maintain cluster order. By contrast, the
Bundle and Unbundle functions are dependent on the order of items in the
cluster, which can cause problems if you have similar data types in a cluster
and you do not know the cluster order. The Bundle By Name and Unbundle
By Name functions display the owned labels of the items in the cluster on
the function terminals.
Job Aid
Use the following checklist to help develop user interface-based data
structures.
❑ Use arrays to store data of the same type, but use a graph to display array
data.
❑ Use clusters to eliminate wire clutter and create your own custom data
types.
❑ Always use the Unbundle By Name and Bundle By Name functions for
programmatic control of cluster data.
Scenario
Implement the user interface for the application. The specification from the
customer and the requirements document define the user interface for the
project.
Design
Figure 5-1 shows the user interface from the requirements document.
Inputs
• Play button—Input by the user
• Record button—Input by the user
• Stop button—Input by the user
Outputs
• Cue List listbox—Displays a list of all of the recorded cues
• Cue Name string—Displays the name of the currently playing cue
• Wait Time (s) numeric—Displays the wait time for the currently
playing cue
• Fade Time (s) numeric—Displays the fade time for the currently
playing cue
• Follow Time (s) numeric—Displays the follow time for the currently
playing cue
• Channel cluster—Displays the channel number, channel intensity, and
channel color for each channel
Implementation
Create a front panel similar to the user interface shown in Figure 5-1.
❑ Close the Control Editor. When prompted, click Yes to replace the
original control with the custom control.
Tip Hold the <Ctrl> key down while clicking on the file names to select multiple files.
❑ Click and drag the custom controls from the Project Explorer
window to the front panel.
7. Place the typedef that contains the Cue Name, Wait Time, Fade Time,
Follow Time, and array of Channels on the front panel.
❑ Create a free label above the Listbox that says Cue Control.
❑ Create a free label above the Array that says Cue Information.
Tip Use the System Recessed Frame decoration to create a professional-looking user
interface.
9. Place error in and error out clusters on the front panel to pass error data
through the VI.
Note The Run button is broken because you deleted the Queue Event button and the
Stop button. You resolve the broken run button in a later exercise.
Icons
Create a meaningful icon for every VI. The icon represents the VI on a
palette and a block diagram. When subVIs have well-designed icons,
developers can gain a better understanding of the subVI without the need for
excessive documentation.
Refer to the Creating an Icon topic of the LabVIEW Help for more
information about creating icons.
Tip You can use the graphics available in the NI Icon Art Glossary to create icons. To
access the Icon Art Glossary, visit ni.com/info and enter the info code rdglos. Each
graphic in the glossary corresponds to an operation, such as aborting an I/O session or
controlling the mode of an instrument.
The Report Generation VIs use images of a disk, a printer, a pencil, and a
trashcan to represent what the VIs do. The image of a piece of paper with
text on it represents a report and is a common element in the icons. This
consistency unifies the icon designs. Notice that none of the icons are
language dependent, thus they are suitable for speakers of any language.
You also can create non-square icons that are similar to the built-in
LabVIEW functions, such as the Numeric and Comparison functions. This
style of icon can improve readability of the block diagram. For example, you
can implement non-square icons to represent control theory functions, such
as a summer. To create a non-square icon, create the image in the icon editor,
then remove the border in each color mode of the icon. It is necessary to
remove the border because LabVIEW treats any non-enclosed white space
in the icon as transparent. Keeping the border creates enclosed white space
and results in a square VI icon.
Scenario
Follow the suggestions for creating an icon to develop an icon that describes
the purpose of TLC Main VI.
Design
Create an icon for the TLC Main VI that resembles the icon shown at left.
Implementation
1. Open the front panel of TLC Main VI.
2. Right-click the VI icon in the upper right corner of the front panel and
select Edit Icon from the shortcut menu to open the Icon Editor.
3. Create the 256 Colors icon. You can use bitmap images to create a
meaningful icon.
❑ Click the 256 Colors Icon. Select Edit»Paste to place the image in
the Icon Editor.
❑ Using the dotted rectangle, select the region in the icon where you
want to paste the picture.
❑ Click the 256 Colors button under Copy from: to copy the image
from the 256 Colors Icon into a 16 color version for 16 Colors Icon.
5. Follow similar steps from Step 4 to create a Black and White Icon.
Wire inputs on the left and outputs on the right to follow the standard
left-to-right data flow.
When assigning terminals, keep in mind how the VIs will be wired together.
If you create a group of subVIs that you use together often, give the subVIs
a consistent connector pane with common inputs in the same location to
help you remember where to locate each input. If you create a subVI that
produces an output another subVI uses as the input, such as references, task
IDs, and error clusters, align the input and output connections to simplify
the wiring patterns.
When assigning terminals as inputs and outputs, make sure to split the
terminals of the connector pane consistently. If you need to use the middle
four terminals of the 4 × 2 × 2 × 4, divide them either horizontally or
vertically. For example, assign the inputs to the top two terminals and the
outputs to the bottom two terminals or assign the inputs to the left two
terminals and the outputs to the right two terminals.
• An example of the 4 × 2 × 2 × 4 wiring pattern with terminals assigned
is shown at left.
• Avoid using connector panes with more than 16 terminals.
• Although connector pane patterns with more terminals might seem
useful, they are very difficult to wire. If you need to pass more data, use
clusters.
• The Required, Recommended, Optional setting for connector pane
terminals affects the appearance of the inputs and outputs in the Context
Help window, and prevents users from forgetting to wire subVI
connections. Use the Required setting for inputs that users must wire
for the subVI to run properly. Use the Optional setting for inputs that
have default values that are appropriate for the subVI most of the time.
• Include error in and error out clusters in all subVIs, even if the subVI
does not process errors. error in and error out clusters are helpful for
controlling execution flow. If a subVI has an incoming error, you can use
a Case structure to send the error through the VI without executing any
of the subVI code.
Figure 5-3 shows the recommended style for assigning inputs and outputs to
a connector pane, with the inputs on the left and the outputs on the right,
following the flow of data from left to right.
1 2
1 Inputs 2 Outputs
When you develop VIs that are loosely coupled, it is easier to create an
appropriate connector pane. The 4 × 2 × 2 × 4 connector pane should work
for every loosely coupled VI. The VI shown in Figure 5-4 is not loosely
coupled because it performs work on more than one function.
In fact, the VI shown in Figure 5-5 uses an enumerated type control to pass
the function that the VI performs. A VI that uses a standard 4 × 2 × 2 × 4
connector pane provides for scalability.
Scenario
Build every VI with the 4 × 2 × 2 × 4 connector pane. This connector pane
pattern provides for scalability, maintainability, and readability. The
4 × 2 × 2 × 4 connector pane is very easy to wire on a block diagram.
Design
Modify the TLC Main VI by following the connector pane guidelines in this
lesson to create a 4 × 2 × 2 × 4 connector pane, as shown at left. Connect
the error in and error out clusters on the front panel to the connector pane.
Implementation
1. Open the front panel of TLC Main VI.
2. Right-click the VI icon in the upper right corner of the front panel and
select Show Connector from the shortcut menu to display the connector
pane for the VI.
3. Right-click the connector pane and select Patterns from the shortcut
menu. Verify that the connector pane uses the 4 × 2 × 2 × 4 pattern.
4. Use the Wiring tool to connect the error in and error out clusters on the
front panel to the connector pane.
❑ Click the input on the connector pane you want to connect to the
error in cluster. Notice that your pointer becomes the wiring tool.
❑ Click the error in cluster on the front panel. That input on the
connector pane is now assigned to error in.
❑ Click the output on the connector pane you want to connect to the
error out cluster. Notice that your pointer once again becomes the
wiring tool.
❑ Click the error out cluster on the front panel. That output on the
connector pane is now assigned to error out.
5. Right-click the connector pane and select Show Icon from the shortcut
menu to display the icon for the VI.
6. Save and close the VI.
Summary – Quiz
1. Which of the following is a constraint of working with arrays?
a. You cannot create an array of arrays.
b. You cannot create an array of charts.
c. You cannot create an array of tab controls.
d. All of the above are constraints.
2. True or False? You should create a unified icon style for related VIs.
3. Which connector pane terminal setting should be used for inputs that
users must wire for a calling VI to run properly?
a. Required
b. Recommended
c. Optional
d. None of the above
2. True or False? You should create a unified icon style for related VIs.
True. This helps users quickly identify which subVI calls are
associated with the top-level VI.
3. Which connector pane terminal setting should be used for inputs that
users must wire for a calling VI to run properly?
a. Required
b. Recommended
c. Optional
d. None of the above
Notes
Topics
A. Configuration Management
B. Implementing a Design Pattern
C. Implementing Code
D. Develop Scalable and Maintainable Modules
E. Implement an Error Handling Strategy
A. Configuration Management
Configuration management is the process of controlling changes and
ensuring they are reviewed before they are made. A central focus of the
development models described in Lesson 1, Successful Development
Practices, is to convert software development from a chaotic, unplanned
activity to a controlled process. These models improve software
development by establishing specific, measurable goals at each stage of
development.
Source Control
After you set the project quality requirements, develop a process to deal with
changes. This process is important for projects with multiple developers. As
developers work on VIs, they need a method to collect and share their work.
A simple method to deal with this is to establish a central source repository.
If all the development computers are on the network, you can create a shared
location that serves as a central source for development. When developers
need to modify files, they can retrieve the files from this location. When
developers complete their changes, they can return the files to this location.
Common files and areas of overlap introduce the potential for accidental
loss of work. If two developers decide to work on the same VI at the same
time, only one developer can work on the master copy. The other developer
must compare the VIs to determine the differences and incorporate the
changes into a new version. Avoid this situation by ensuring good
communication among the developers. If each developer notifies the others
when he needs to work on a specific VI, the others know not to work on that
VI.
test the changes, and check the file back into source control. After you check
in the file, the latest version is available to the development team. Another
developer can check out the file to make further modifications.
Note Source control integration in LabVIEW is available only with the Professional
Development System.
You must select, install, and configure a source control provider in order to
use source control in a software project.
Refer to the KnowledgeBase for the most current list of third-party source
control providers that work with LabVIEW.
Source control provides a way to check in new versions of a file and access
previous versions. Depending on how you configure the source control
provider, the tools can store multiple versions of a file.
Tracking Changes
If you are managing a software project, it is important to monitor changes
and track progress toward specific milestone objectives. You can use this
information to determine problem areas of a project by identifying which
components required many changes.
Source control providers maintain a log of all changes made to files and
projects. When checking in a file, the provider prompts the developer to
write a summary of the changes made. The provider adds this summary
information to the log for that file.
You can view the history information for a file or for the system and
generate reports that contain the summary information.
In addition, if you back up files at specific checkpoints, you can compare the
latest version of a file with another version to verify changes.
Change Control
Large software projects can require a formal process for evaluation and
approval each time a developer asks to make changes. A formal process can
be too restrictive, so be selective when selecting the control mechanisms you
introduce into the system.
Source control gives you a degree of control when making changes. You can
track all changes, and you can configure a source control provider to
maintain previous versions so you can undo changes if necessary. Some
source control providers give you more options for controlling software
change. For example, with Microsoft Visual SourceSafe, IBM Rational
ClearCase, or Perforce, you can control which users can modify certain files
and which users can only access those files. You also can control access so
a user has privileges to modify a file only with the approval of the change
request.
In some cases, you might decide to use a specific source control provider
because your company has standardized on that application. If not, you must
decide which provider you want to use for managing your files. Consult the
source control administrator at your company to find out if you should use
a specific provider.
After you select and install a source control provider, you must configure
LabVIEW to work with that provider. You can configure LabVIEW to work
with only one source control provider at a time.
Note The LabVIEW Perforce Command Line offers additional source control
functionality such as VI compare.
Note Currently, ionForge Evolution version 2.8 and greater works with LabVIEW.
Refer to the KnowledgeBase for the most current list of third-party source
control providers that work with LabVIEW.
use a different source control project than the one you specify for the
LabVIEW environment, or if you do not want to use source control with a
LabVIEW project. LabVIEW projects use the source control configuration
you specify for the LabVIEW environment by default. Select Project»
Properties or right-click the project root and select Properties from the
shortcut menu to display the Project Properties dialog box. Select Source
Control from the Category list to display the Source Control page.
Caution Be careful when you remove files from source control. Some source control
providers delete the local directory copy of the file, all previous versions of the file that
the provider maintains, and the history log for the file.
Note If LabVIEW and the third-party source control provider are not compatible,
LabVIEW launches the default comparison tool of the third-party source control
provider. Perforce SCM and Rational ClearCase are not compatible with the procedure
LabVIEW uses to complete a graphical differencing of VIs. Refer to the
KnowledgeBase for more information about comparing VIs using Rational ClearCase.
local variables. In Figure 6-1, the Timing Control local variable must
initialize to 0 before the producer/consumer design pattern can execute.
If the Timing Control local variable was not enclosed in a structure, you
could not guarantee when the local variable would execute.
register, the loop retains the last value written to the register when the loop
last executed or the default value for the data type if the loop has not
executed. The easiest way to initialize a shift register is to right-click the
shift register and select Create»Constant from the shortcut menu. When
you initialize a shift register that contains strings, use a string constant to
perform the initialization.
Variant Data
Sometimes you may need a VI to handle data of many different types in a
generic way. You could write a different VI for each specific data type, but
having copies of your VI is hard to maintain, since if you change one you
have to remember to change all of them. LabVIEW provides the variant data
type as one solution for these situations. The variant data type is a generic
container for all other types of data in LabVIEW. When you convert other
data to a variant, the variant stores the data and the original data type of the
data, which allows LabVIEW to correctly convert the variant data back to
the original data at a later time. For example, if you convert string data to a
variant, the variant stores the text of the string and an indicator that says that
this data was originally a string (as opposed to a path or an array of bytes, or
other possible LabVIEW types).
Use the Variant functions to create and manipulate variant data. You can
convert any LabVIEW data type to the variant data type to use variant data
in other VIs and functions. Several polymorphic functions return the variant
data type.
Note If you are using the Real-Time platform, replace the variant data type with a string
data type.
Job Aid
Use the following checklist to implement scalable architectures.
Scenario
Using a design pattern for the architecture makes the application readable,
scalable, and maintainable. Implementing the producer/consumer (events)
design pattern makes the user interface more responsive. Using a variant
data type makes the architecture scalable for future needs.
Design
1. Create a type definition for the functions that the application performs.
2. Use the type definition as the data type to pass data from the producer to
the consumer.
4. In the consumer loop of the design pattern, verify that a case exists to
process each function in the enumerated data type.
6. Create a custom run-time menu to perform the Load, Save, and Exit
functions.
8. Create user events that allow the consumer loop to send error data to the
producer loop to stop the producer
Implementation
Implement the architecture for the Producer/Consumer (Events) design
pattern, as shown in Figure 6-5.
3. Create a scalable data type to pass data from the producer loop to the
consumer loop. This data type is a cluster that includes the
tlc_Functions.ctl control and a variant.
❑ Drag the control from the Project Window to the block diagram to
place it as a constant.
❑ Set the value of the enumerated type constant within the cluster to
Initialize.
❑ Delete the empty string constant that is wired to the Obtain Queue
function.
❑ Place the Enqueue Element function on the block diagram. Wire the
cluster constant to the Enqueue Element function to initialize the
design pattern.
❑ Delete the error cluster wires connected to the case selector and to
the loop conditional for the consumer loop.
Note You are deleting the initial error handling wiring in preparation for more complex
structures in later exercises. In Exercise 6-4 you build a functional global variable to handle
errors in the application and in Exercise 7-7 you implement it in the main application.
❑ Right-click the border of the Case structure and select Add Case
For Every Value from the shortcut menu to populate the Case
structure with the items in the enumerated type control.
❑ Right-click the error cluster tunnel on the consumer loop and select
Replace with Shift Register from the shortcut menu. Place the
other side of the shift register on the right side of the consumer loop.
Repeat this step for the queue reference tunnel.
❑ Wire the queue reference and error cluster through each case of the
consumer loop.
9. Create an event case in the producer loop to respond to the Value Change
event for the Play button.
❑ Right-click the Event structure and select Add Event Case from the
shortcut menu to open the Edit Events dialog box.
❑ Select the Play button from the Event Sources list and select Value
Change from the Events list.
10. Modify the Play event case to send a message to the consumer loop to
execute Play, as shown in Figure 6-6. Delete the Unbundle By Name and
Or functions that are connected to the loop conditional terminal. Add the
following items:
❑ tlc_Consumer Control.ctl
❑ Bundle By Name
Tip After you wire the tlc_Consumer Control to the Bundle by Name function, you can
create the tlc_Functions.ctl. Right-click the Command element of the Bundle By
Name function and selecting Create»Constant from the shortcut menu.
❑ Enqueue Element
❑ False constant
11. Create a Value Change event case for the following controls: Record
and Stop.
❑ Right-click the Play event case, and select Duplicate Event Case
from the shortcut menu.
❑ Select the Record button and the Value Change event and click the
OK button.
❑ Repeat the previous step for the Stop control, changing the
command the producer sends to the consumer to correspond to the
appropriate function.
Table 6-1 shows the appropriate enumerated type control item to place
in the queue when each control receives a value change event.
12. Place the Record, Play and Stop control terminals in the corresponding
event cases to ensure that the control is read when the control generates
an event. If you duplicate an event case with the terminal in the event
case, you also duplicate the terminal. Placing a terminal in the
corresponding event case is good programming style because it ensures
that LabVIEW reads the terminal when the event occurs.
13. Create a custom run-time menu to perform the Load, Save, and Exit
functions. Figure 6-7 shows the completed menu.
Tip In the Item Name textbox, enter an underscore (_) before the letter you want to
associate with the <Alt> key for that menu. This creates a shortcut so the user can press
the <Alt> key and the associated key to access the menu.
❑ Change the Item Tag to File. Place your cursor in Shortcut and
press <Ctrl-F>. LabVIEW records the shortcut key combination for
you.
❑ Click the blue + button on the Menu Editor toolbar to add a new item
under the File item.
❑ Click the right arrow button on the toolbar to make the new item a
subitem of the File menu.
❑ Change the Item Tag to Open. Place your cursor in Shortcut and
press <Ctrl-O>.
Note The Item Tag is passed to LabVIEW so that you can create decision making code
to respond to the selected menu item.
❑ Click the blue + button on the Menu Editor toolbar to add a new item
under the File item.
❑ Change the Item Tag to Save. Place your cursor in Shortcut and
press <Ctrl-S>.
❑ Click the blue + button on the Menu Editor toolbar to add a new item
under the File»Save item.
❑ Click the blue + button on the Menu Editor toolbar to add a new item
under the File item.
❑ Enter E_xit in the Item Name textbox to create a menu item for Exit.
❑ Change Item Tag to Exit. Place your cursor in Shortcut and press
<Ctrl-Q>.
❑ Select File in the Preview section to preview the menu and verify
that it matches Figure 6-7.
❑ Close the Menu Editor. When prompted, click the Yes button to
change the run-time menu to the custom menu.
14. Add a case to the Event structure in the producer loop to respond to
menu selections.
❑ Right-click the Event structure border and select Add Event Case
from the shortcut menu to open the Edit Events dialog box.
❑ Select <This VI> from the Event Sources list and Menu Selection
(User) from the Events list to create the Menu Selection (User)
event case. Click the OK button.
❑ Place a Case structure in the Menu Selection (User) event case. Wire
the ItemTag event data node to the case selector terminal.
❑ Create four cases for the Case structure in the Menu Selection (User)
event case to process the ItemTag strings—Open, Save, Exit, and
Default. Be sure the spelling for the case selector matches the
spelling you used for the Item Tag in the Menu Editor.
❑ Modify the Exit case to stop the VI when the user selects File»Exit,
as shown in Figure 6-8. You use the same items that you used for
Step 10.
❑ Wire a True constant to the loop conditional terminal in the Exit case
and a False constant for every other case. Set the Command element
to Exit. These values will result in the Exit case stopping both the
producer and the consumer loops.
❑ Wire the queue reference and error cluster wires through the
remaining cases in the Case structure. You build the remaining cases
in later exercises.
Tip To quickly wire through remaining cases, right-click an empty tunnel and select
Linked Input Tunnel»Create and Wire Unwired Cases, then click the opposite
tunnel.
15. Complete the block diagram as shown in Figure 6-9 to create user events
that allow the consumer loop to send error data to the producer loop to
stop the producer.
❑ Place the Create User Event function on the block diagram. This
function creates a user event based on the data type passed to it.
Create an error constant from the error in input and wire it to the
user event data type input. Label the error constant error.
❑ Place the Register for Events node on the block diagram. This
function dynamically registers the user event. Wire the event
registration refnum output of the Register for Events node to the
dynamic terminal of the Event structure.
❑ Wire the Create User Event function to the Register for Events node.
Note The name of the dynamic event is the same as the owned label for the data
structure that is wired to the Create User Event function.
❑ Wire status output from the event data node to the loop condition
terminal.
❑ Place the Merge Errors function on the block diagram. This function
combines multiple error cluster inputs into a single error cluster
output.
❑ Place the Unregister for Events function on the block diagram. This
function unregisters the dynamic event.
❑ Place the Destroy User Event function on the block diagram. This
function destroys the reference to the user event.
17. Delete the event cases on the Event structure that are left over from the
design pattern.
18. Wire the Release Queue, Unregister for Events, and Destroy User
Events functions, and the Merge Error VIs as shown in Figure 6-9.
19. Connect the error in and error out clusters to the design pattern as
shown in Figure 6-9.
Testing
1. Place a One Button Dialog function in each case of the consumer loop.
Wire a string constant to the message input of the One Button Dialog
function to open a dialog box indicating that the case executes when the
front panel receives events.
Tip You can use the following code to easily wire the name of the executing case to the
One Button Dialog function. You also can use this technique to convert an enum to a
string.
3. Run the VI to verify that all the functions listed in step 2 of the
Implementation section work correctly.
You can test the functionality by clicking a button on the front panel to
cause the Event structure to execute. When the Event structure executes,
it places a message in the queue to cause the consumer to execute.
The only cases that are not functional at this time are the Load, Save, and
Select Cue cases. You implement this functionality in a later exercise.
4. Verify that you can exit the application from the run-time menu.
C. Implementing Code
Developing code and interfaces is the process of implementing the
actual VI. Good software design techniques ensure that you create
VIs that are scalable, readable, and maintainable. When you implement
code, you also must provide a timing mechanism and document the VI.
The following good wiring tips also help keep the block diagram clean:
• Avoid placing any wires under block diagram objects because
LabVIEW can hide some segments of the resulting wire. Draw wires so
that you can clearly see if a wire correctly connects to a terminal. Delete
any extraneous wires. Do not wire through structures if the data in the
wire is not used in the structure.
• Add as few bends in the wires as possible and keep the wires short.
Avoid creating wires with long complicated paths because long wires
are confusing to follow.
• Avoid using local variables when you can use a wire to transfer data.
Every local variable that reads the data makes a copy of the data. Use
global and local variables as sparingly as possible.
Make sure data flows from left to right and wires enter from the left and
exit to the right.
You can use the information that is located in the Context Help window to
create a free label comment on the block diagram that documents the
configuration of Express VIs, as shown in Figure 6-13.
Data binding is another tool that hides its functionality in a VI. The VIs in
Figure 6-14 and Figure 6-15 communicate with one another using shared
variables, but there is no indication of that functionality on either block
diagram.
The VI in Figure 6-15 reads data from the VI in Figure 6-14. There is
nothing on the block diagram to indicate that this VI reads data through a
shared variable. Looking at the VI in Figure 6-15, you would not expect the
waveform graph to update. But, when you run the VI, it receives data. You
should always clearly document VIs that receive data through data binding.
You can use free labels to indicate the behavior and functionality of the VIs,
as shown in Figure 6-16 and Figure 6-17.
When you use the tools that are included with LabVIEW, always provide
block diagram comments to indicate the functions they perform.
Eliminate Constants
Block diagrams that contain numerous constants can become
unmanageable. It also can be difficult to maintain code when numerous
constants are used throughout the application. An alternative to using
constants is to place the values of the constants into configuration files.
Note The standard extension for Windows configuration settings files is .ini, but the
Configuration File VIs work with files with any extension, provided the content is in the
correct format.
You can use the Configuration File VIs to read this data, as shown in the
following block diagram. This VI uses the Read Key VI to read the key
named Value from the section called Data. This VI works regardless of how
the file changes, provided the file remains in the Windows configuration
settings file format.
Use the following data types with Configuration File VIs for the value
portion of the key parameter:
• String
• Path
• Boolean
• 64-bit double-precision floating-point numeric
• 32-bit signed integer
• 32-bit unsigned integer
The Configuration File VIs can read and write raw or escaped string data.
The VIs read and write raw data byte-for-byte, without converting the data
to ASCII. In converted, or escaped, strings LabVIEW stores any
non-displayable text characters in the configuration settings file with the
equivalent hexadecimal escape codes, such as \0D for a carriage return. In
addition, LabVIEW stores backslash characters in the configuration settings
file as double backslashes, such as \\ for \. Set the read raw string? or
write raw string? inputs of the Configuration File VIs to TRUE for raw
data and to FALSE for escaped data.
When VIs write to a configuration file, they place quotation marks around
any string or path data that contain a space character. If a string contains
quotation marks, LabVIEW stores them as \". If you read and/or write to
configuration files using a text editor, you might notice that LabVIEW
replaced quotation marks with \".
Create a directory for all the VIs for one application and give it a meaningful
name. Save the main VIs in this directory and the subVIs in a subdirectory.
If the subVIs have subVIs, continue the directory hierarchy downward.
When you create the directory, organize the VIs and subVIs modularly
according to the functionality of the subVIs.
When naming VIs, LLBs, and directories, avoid using characters not all file
systems accept, such as backslash (\), slash (/), colon (:), and tilde (~).
Most operating systems accept long descriptive filenames up to 255
characters.
Avoid creating files with the same name anywhere within the hierarchy.
Only one VI of a given name can be in memory at a time. If you have a VI
with a specific name in memory and you attempt to load another VI that
references a subVI of the same name, the VI links to the VI in memory. If
you make backup copies of files, be sure to save them into a directory
outside the normal search hierarchy so that LabVIEW does not mistakenly
load them into memory when you open development VIs.
Refer to the Creating VIs and subVIs topic of the LabVIEW Help for more
information about saving VIs individually and in VI libraries.
Execution Timing
You can explicitly time a design pattern or time it based on events that occur
within the VI.
Use explicit timing for design patterns that perform some type of polling while
they execute. The master/slave, producer/consumer (data), queued message
handler, and standard state machine design patterns execute continuously and
monitor external inputs to control the execution of the design pattern. For
example, the master/slave design pattern shown in Figure 6-22 uses a While
Loop and a Case structure to implement the master loop.
The master loop executes continuously and polls for an event to send a
message to the slave loop. You need to time the master loop so it does not
take over the execution of the processor. In this case, you typically use the
Wait (ms) function to regulate how frequently the master loop polls.
Tip Always use a timing function such as the Wait (ms) function or the Wait Until Next
ms Multiple function in any design pattern that continually executes and requires
regulation.
Notice that the slave loop does not contain any form of timing. The use of
Synchronization functions to pass messages provides an inherent form of
timing in the slave loop. The slave loop waits for the Notifier function to
receive a message. After the notifier receives a message, the slave loop
executes on the message. This creates an efficient block diagram that does
not waste processor cycles by needlessly polling for messages.
When you implement design patterns where the timing is based on the
occurrence of events, you do not have to determine the correct timing
frequency because the design pattern executes only when an event occurs.
In other words, the design pattern executes only when it receives an event.
For example, the producer/consumer (events) VI shown in Figure 6-1 does
not require any timing functions. The Event structure in the producer loop
controls when the producer loop executes. The Dequeue Element function
in the consumer loop waits until an item is placed in the queue, thus
controlling the execution of the consumer loop. Design patterns such as the
producer/consumer (events) and the user interface event handler do not
require any timing because external events control their timing.
If you use the Wait (ms) function or the Wait Until Next ms Multiple
function to perform software timing, the execution of the VI only occurs
after the wait functions finish. These functions are not the preferred method
for performing software control timing, especially for VIs where the system
must continually execute.
For software control timing, it is important that the design pattern run
continuously without stopping. If the design pattern stops executing, certain
events cannot be captured, such as stopping the VI. The methods for
software control timing are Get Date/Time in Seconds, Event structure
timeout, and the Timed Structures.
Figure 6-23. Software Timing Using the Get Date/Time In Seconds Function
The Get Date/Time In Seconds function, connected to the left terminal of the
shift register, initializes the shift register with the current system time. Each
state uses another Get Date/Time In Seconds function and compares the
current time to the start time. If the difference in these two times is greater
or equal to the wait time, the state finishes executing and the rest of the
application executes. Always use the Get Date/Time In Seconds function
instead of the Tick Count function for this type of comparison because the
value of the Tick Count function can rollover to 0 during execution.
To make the timing functionality modular and reusable, use the functional
global variable design pattern to build a timing VI as shown in Figure 6-24.
In this example, the Initialize case retrieves the current time using the Get
Date/Time In Seconds function and places the value into a shift register that
recirculates the time through the functional global variable. The Check Time
case subtracts the current time from the Recirculate Time shift register and
compares that value to the Time to Wait value to determine if the expected
time has elapsed. If the expected time has not elapsed, the Recirculate Time
value passes back into the shift register, otherwise the current time passes to
the shift register and the Time Elapsed Boolean value returns True.
By replacing the timing code in Figure 6-23 with the Timing functional
global variable in Figure 6-24, the VI becomes more readable and easier to
understand, as shown in Figure 6-25.
Synchronization Timeout
All of the synchronization VIs can timeout after a specified number of
milliseconds have elapsed. For example, the Dequeue Element function can
timeout after a specified number of milliseconds. This can help if you want
to execute a function in a queued state machine, or a queue based design
pattern every specified number of milliseconds. Figure 6-26 shows an
example of a synchronization timeout.
Timed Structures
Use a Timed Loop or Timed Sequence structure on the block diagram to
execute code with time bounds and delays. A Timed Loop repeatedly
executes code until a stop condition is met. A Timed Sequence structure
executes code once in a specific order. To execute code repeatedly in a
specific order with time bounds and delays, use a Timed Loop with frames.
You can wire values to the inputs of the Input node to configure a Timed
Sequence structure, or you can right-click the Input node and select
Configure Input Node from the shortcut menu to display the Configure
Timed Sequence dialog box and enter values for the options.
Note The Right Data node of the last frame of a Timed Sequence structure does not
include configuration options because you do not have to configure another frame or
iteration.
The Output node returns error information received in the Error input of the
Input node, error information generated by the structure during execution,
or error information from any subdiagram that executes within a frame of
the Timed Sequence structure. The Output node also returns timing and
status information for the final frame.
Note Adding a VI set to time-critical priority and a Timed Sequence on the same block
diagram can lead to unexpected timing behavior.
Timed Loop
A Timed Loop executes a subdiagram, or frame, at a period you specify for
each iteration. Use a Timed Loop when you want to develop VIs that execute
repeatedly with multirate timing capabilities, precise timing, feedback on
loop execution, timing characteristics that change dynamically, or several
levels of execution priority. Unlike in a While Loop, you do not have to wire
the conditional terminal in a Timed Loop. However, if you do not wire
anything to the conditional terminal in a Timed Loop, the loop runs
interminably.
A Timed Loop executes in the data flow of a block diagram ahead of any VI
not configured to run at a time-critical priority. You can change the priority
of a Timed Loop to change the order in which it executes relative to other
timed structures on the block diagram.
Note Adding a VI configured to run at time-critical priority and a Timed Loop on the
same block diagram can lead to unexpected timing behavior.
You can wire values to the inputs of the Input node to configure a Timed
Loop, or you can right-click the Input node and select Configure Input
Node from the shortcut menu to display the Configure Timed Loop dialog
box and enter values for the options.
The Output node returns error information received in the Error input of the
Input node, error information generated by the structure during execution,
and error information from the subdiagram that executes within the Timed
Loop. For example, if an external source aborts the execution of the Timed
Loop or if more than 128 Timed Loops run at one time, the Output node
returns an error. The Output node also returns timing and status information
for the loop.
To convert a Timed Loop to a While Loop, right-click the Timed Loop and
select Replace with While Loop from the shortcut menu.
Each frame of the Timed Loop with frames includes a set of nodes, as shown
in the following illustration. By default, nodes of the Timed Loop do not
display all of the available input and output terminals. You can resize nodes
or right-click a node and use the shortcut menu to display hidden terminals.
You can wire values to the inputs of the Input node to configure a Timed
Loop with frames, or you can right-click the Input node and select
Configure Input Node from the shortcut menu to display the Configure
Timed Loop with Frames dialog box and enter values for the options.
The Left Data node of a Timed Loop frame returns configuration option
values and provides timing and status information about the previous loop
iteration or frame. You can use the Configure Next Frame Timing dialog
box, available by right-clicking the Right Data node and selecting
Configure Input node from the shortcut menu to enter values for the
options. You also can wire data to the Right Data node of a frame to
configure the next frame dynamically.
The Output node returns error information received in the Error input of the
Input node, error information generated by the structure during execution,
and error information from the subdiagrams that execute within the Timed
Loop frames. The Output node also returns timing and status information
for the final frame.
You also can assign a priority for each frame of a Timed Sequence or Timed
Loop with frames. LabVIEW checks the priority of any frame ready to
execute and starts the frame with the highest priority.
The following block diagram contains a Timed Loop and a Timed Sequence
with two frames. The Priority value of the first frame of the Timed Sequence
(200) is higher than the priority of the Timed Loop (100). Because the first
frame of the Timed Sequence has a higher priority, it executes first.
After the first frame of the Timed Sequence executes, LabVIEW checks the
priority of other structures or frames that are ready to execute. The priority
of the Timed Loop is higher than the priority of the second frame of the
Timed Sequence. LabVIEW executes an iteration of the Timed Loop and
then checks the priority of the structures or frames that are ready to execute.
The Timed Loop priority (100) is higher than the second frame of the Timed
Sequence (50). In this example, the Timed Loop executes completely before
the second frame of the Timed Sequence executes.
Use the Source listbox in the Configure Timed Loop or Configure Timed
Sequence dialog boxes to select an internal timing source or use the Create
Timing Source VI to programmatically select an internal or external timing
source.
Use the VIs and functions on the Timed Structures and DAQmx palettes
to create external timing sources to control a Timed Structure.
Setting a Timeout
A timeout specifies the maximum amount of time, relative to the timing
source, a Timed Loop or an individual frame can wait to begin execution.
Use the Input Node of a timed structure to set the timeout value for the start
of the timed frame. If the execution of the subdiagram does not begin before
the timing source reaches the specified timeout value, the Timed Loop
returns Timeout in the Wake-up Reason output of the Left Data node.
In the following example, the first frame of the Timed Sequence takes 60 ms
to complete. The second frame is configured to start 50 ms after the start of
the loop and therefore must wait 10 ms. The second frame is configured with
a timeout value of 5 ms before timing out and returns Timeout in the
Wakeup Reason output of the Left Data node for the frame.
The default Timeout value for the Input Node is –1, which indicates to wait
indefinitely for the start of the subdiagram or frame. The default Timeout
value in the Left Data nodes of a frame is 0, which indicates that the timeout
is unchanged and equal to the timeout of the previous frame or iteration.
Refer to the Timed Structures topic of the LabVIEW Help for more
information about configuring Timed Structures.
Job Aid
Use the following checklist when determining the timing mechanism to use
for an application.
Scenario
The Theatre Light Controller requires accurate timing to control the cue
wait, fade, and follow time. The requirements for the Theatre Light
Controller require that the application respond within 100 ms when any
operation is running. So when choosing a method to accurately time the
Theatre Light Controller, the timing method cannot interfere with the
application response. You will develop a functional global variable that will
be used in a later exercise to implement software control timing.
Design
Build a functional global variable that you can use to control the timing of
the Theatre Light Controller. You will use the functional global variable to
control the timing for the wait, fade, and follow times of the Theatre Light
Controller. Use the Get Date/Time In Seconds function to control the
timing.
Implementation
1. In the project, create a new virtual folder in the Modules virtual folder
called Timing.
❑ Right-click the border of the While Loop and select Add Shift
Register.
❑ Place the Timer Command control in the No Error case and wire it
to the Case Selector input of the Case Structure inside the While
Loop. The Case Structure should now have a Check Time case and
a Start case.
6. Modify the Start case to store the start time of the VI using the following
items as shown in Figure 6-30.
❑ False constant
7. Modify the Check Time case to output the elapsed time since a Start
command has been sent to the tlc_Timing Module VI using the
following items as shown Figure 6-31.
❑ Subtract function
❑ Greater Or Equal?
8. Save the VI.
Testing
A unit test VI is provided to verify the functionality of the Timing module.
The Unit Test VI repetitively calls the Timing module and displays the
elapsed time to show how long the execution of the Timing module takes.
1. Use the Unit Test VI to test that the Timing module returns the values
you specify in the Cue control.
❑ Specify a value for the wait time, fade time, and follow time in the
Cue Input control.
❑ Run the VI and verify that the times returned match in the Measured
Test Values what you specified in the Cue Input control.
General Techniques
Use the techniques and ideas described in this course to create the VIs that
function as modules or subVIs in a larger VI hierarchy. Develop with loose
coupling and strong cohesion to make your implemented VI modules more
scalable and maintainable.
Before a module generates outputs, the module should check the output data
for correctness. This process ensures that the module functioned as
expected. For example, consider a module that logs data to a database, but
has no inherent verification that the data was logged correctly. You must
explicitly create a mechanism to determine that the module correctly stored
the data in the database, such as reading the value back from the database
and checking it against the original value.
Handling Errors
Whenever possible, correct any errors that occur in a module within the
module where the error occurs. When you cannot correct an error within the
module, return the error to the calling VI so that the calling VI can correct,
ignore, or display the error to the user. When you implement a module, make
sure the module handles any errors that it can. Include error clusters to pass
error information into and out of the module.
Using Libraries
LabVIEW Libraries are a powerful tool for organizing your modules. If you
are using libraries, include each module in its own library. Using a library
provides a number of benefits. First, a library allows you to clearly
differentiate between top-level VIs, which should be called by external
code, and low-level VIs, which the module uses as subVIs. The ability to
mark VIs in a library as public and private allows you to specify that no VI
outside of the module can call one of the low-level VIs, preventing
confusion for programmers using the module. Marking VIs as public or
private also allows you to make assumptions or requirements about the use
of a private VI that might not otherwise be safe. Libraries also create a
namespace for your module, thereby preventing difficulties if VIs in your
module have the same name as other VIs in memory. This feature is
particularly useful when distributing modules for use in an unknown
environment. Finally, libraries abstract your module from other VIs and
allow you to easily organize your modules within the project space.
Note Remember that a VI remains in memory until all references to the VI are closed.
delete the case that implements the functionality without deleting the item
in the enumerated type control that corresponds to that case. This allows you
to verify that external VIs that call the module no longer need that state.
Job Aid
Use the following checklist when you implement your code.
❑ Make sure data flows from left to right and wires enter from the left and
exit to the right.
❑ Use free labels to document algorithms that you use on the block
diagrams. If you use an algorithm from a book or other reference,
provide the reference information.
❑ Make sure the program can deal with error conditions and invalid values.
❑ Show name of source code or include source code for any CINs.
❑ Make sure the subVI icon, rather than the connector pane, is visible on
the block diagram.
❑ Use a type definition when you use the same unique control in more than
one location or when you have a very large data structure passing
between several subVIs.
❑ Make sure the Name Format for Property Nodes and Invoke Nodes is
set to Short Names to ensure the best readability of the block diagram.
❑ Make sure control and indicator terminals on the connector pane are not
inside structures on the block diagram.
Scenario
When you carefully plan and design an application, your implementation of
the system creates scalable, readable, and maintainable VIs. Implement the
Display, File, and Hardware modules. These are the major modules that you
identified for the Theatre Light Control Software application. You have
already implemented the Cue and Timing modules.
Design
The functional global variable approach you used to implement the cue and
timing modules provides for a very scalable, readable, and maintainable
method to build VIs. Continue to use a functional global variable to
implement the remaining modules for the application.
Display
The tight coupling that exists between the front panel and block diagram in
a VI requires that you update the front panel using terminals on the VI block
diagram, or use references from a subVI. Each of these methods has its
advantages and disadvantages. Updating a front panel directly using a
terminal is a very fast and efficient method of updating front panel controls
and indicators. However, you must have a way to get subVI data to the
top-level VI to update the front panel. You can loosen the tight coupling that
exists between the front panel and the block diagram by sending a message
from subVIs to the top-level VI that contains that control and indicator. An
ideal implementation for this is a functional global variable.
The display module uses a functional global variable to store the reference
for the display queue. This allows the module to be called from anywhere in
the application to control the separate display loop.
File
The file module calls the File I/O VIs. The file module provides the
functionality to initialize, load cues from a file, save cues to a file, and
shutdown. Implement the file module using the functional global variable
architecture.
Hardware
The hardware module calls the Theatre Light Control API. The hardware
module provides the functionality to initialize, write, and shutdown the
hardware.
Implementation
Display
The Display module provides a method to update the front panel controls
and indicators from anywhere in the application. This module populates a
queue that contains both the commands the display module performs and the
data needed to perform these tasks. The display module performs the
Initialize Front Panel, Update Front Panel Channels, Select Cue in Cue List,
Enable/Disable Front Panel Controls, and Update Cue List functions.
To build a system that can perform these functions, you first must modify
the design pattern in TLC Main VI to have a third loop, and then create a
display module that is a functional global variable to send messages to the
third loop.
A queue that is specifically for the display loop controls the third loop. The
third loop only updates the user interface in the top-level VI.
❑ While Loop—Place this below the consumer loop. This will be the
display loop.
3. Create a queue to control the display loop, as shown in Figure 6-34. Use
the following items and wiring:
❑ Obtain Queue
❑ Enqueue Element
❑ Wire the Data Type element from the Unbundle By Name to the case
selector terminal.
❑ Right-click the Case structure and select Add Case for Every Value
from the shortcut menu.
❑ Boolean constants
– Place a False constant inside each case of the Case structures.
Wire these constants to a single tunnel connected to the
conditional terminal for the display loop.
– Set the constant to True in the Stop case.
❑ Wire the queue reference and error cluster through each case on the
case structure.
Display Module
Create a module that stores which function to perform on the display. As the
application runs, update the display. Complete the following steps to create
the Display module.
Open the tlc_Display Module.vi that you just added into the
LabVIEW project.
4. Wire the shift register through the other cases. Verify that all of the
tunnels are wired in the module.
5. Modify the Update UI Case to call the Enqueue Element function to pass
the command and data to the display loop in the top-level VI as shown
in Figure 6-36. Use the following items to complete this case:
❑ Bundle By Name
❑ Enqueue Element
File
The File module saves and loads a file from the application. The File module
accepts an array of cues, a file path, and a command, and returns an array of
cues. The File module performs the Save Cues and Load Cues functions.
4. Observe the architecture and design of the File module. Notice that
standard File I/O VIs are used to perform the reading and writing of the
data.
Testing
Test the functionality of the VI with simple hand tests.
2. Use the Browse button on the Path control to set the name and save
location for your new save file. The Path control has been set to browse
for new or existing files.
7. Verify that the Cue Array Output matches the data you placed in the
Cue Array Input.
Hardware
The Hardware module interacts with the Theatre Light Control API. The
Hardware module performs the Write Color and Intensity function.
4. Observe the architecture and design of the hardware module. Notice that
the VI calls the Theatre Light Control API.
Passing an error outside the VI can be ineffective for code with loose
coupling because an external routine handles the error. Use this error
handling strategy for VIs that are part of an API. Many of the built-in
LabVIEW VIs and functions pass the error information out of the VI or
function when an error occurs. For example, if an error occurs in a File I/O
VIs, LabVIEW passes the error out of the VI. It is impractical for an API VI
to display a dialog box when an error occurs unless displaying a dialog box
is a specific feature of that API function. For a set of API VIs, you can create
specific error handling code that filters out expected errors or loops until a
specific error is resolved.
When you implement an API VI, place an error handling Case structure
around the API code. Wire an error cluster to the selector terminal of a Case
structure to create two cases, Error and No Error. The border of the Case
structure is red for Error and green for No Error. If an error occurs, the Case
structure executes the Error subdiagram. This is an effective error handling
strategy for VIs that function as APIs, as shown in Figure 6-33.
Scenario
Handling errors is an important part of developing applications in
LabVIEW. When you are developing the application, you can use error
handling to help find bugs in the applications.
A good error handling strategy is to call a module that stores the error
information and safely stops the application if an error occurs.
Design
Using a functional global variable, store the error information in an
uninitialized shift register. If an error occurs, the VI sends a stop message to
the producer to shut the program down.
Implementation
1. Create a Error virtual folder in the Modules project hierarchy.
❑ tlc_Error Module.vi
4. Modify the block diagram to stop the producer, consumer, and display
loops if an error occurs. Use the following items to complete the case
where the structures are set to Handle Errors, Error, and True, as shown
in Figure 6-38:
Create constants for the element input of each instance. For the
consumer loop, set the first enum to Stop and set the second enum
to Exit. For the display loop, set the enum to Stop.
❑ Merge Errors VI
5. Complete all structures by wiring the User Event Reference and Queue
references through all remaining cases.
Summary – Quiz
1. Which of the following should be considered when you have selected a
design pattern for an application?
a. How should the VI be initialized?
b. How should the timing mechanism be implemented?
c. How should the VI be documented?
d. All of the above
Notes
Topics
A. Verifying the Code
B. Implementing a Test Plan for Individual VIs
C. Implementing a Test Plan for Integrating VIs
D. Implementing a Test Plan for the System
Code Reviews
A code review is similar to a design review except that it analyzes the code
instead of the design. To perform a code review, give one or more developers
printouts of the VIs to review. You also can perform the review online
because VIs are easier to read and navigate online. Talk through the design
and compare the description to the actual implementation. Consider many
of the same issues included in a design review. During a code review, ask
and answer some of the following questions:
1. What happens if a specific VI or function returns an error? Are errors
dealt with and/or reported correctly?
2. Are there any race conditions? A race condition occurs when two or
more pieces of code that execute in parallel change the value of the same
shared resource. Because the outcome of the VI depends on which
action executes on the shared resource first, race conditions cause
unpredictable outcomes. Race conditions often occur with the use of
local and global variables or an external file, although race conditions
can exist any time more than one action updates the value of the same
stored data.
3. Is the block diagram implemented well? Are the algorithms efficient in
terms of speed and/or memory usage?
4. Is the block diagram easy to maintain? Does the developer make good
use of hierarchy, or is he placing too much functionality in a single VI?
Does the developer adhere to established guidelines?
There are a number of other features you can look for in a code review. Take
notes on the problems you encounter and add them to a list you can use as a
guideline for other walkthroughs.
To develop a test plan, you must determine what you need to test. Use the
following list to help identify what you need to test.
• Test all requirements in the requirements document
• Identify areas that need usability testing, such as the user interface
• Test the error handling and reporting capabilities of the VI
• Test areas of the VI that have performance requirements
Functional Tests
Functional tests focus on the most important aspects of a VI. Use functional
tests to determine if a VI works and functions as expected. A functional test
involves more than passing simple test data to a VI and checking that the VI
returns the expected data. Although this is one way to test a VI, you should
develop a more robust test.
Hand Checking
Another common form of functional testing is simple hand checking. This
type of testing occurs during the development of the VI but can help during
the testing phase. If you know the value that a VI should return when a
certain set of inputs are used, use those values as a test. For example, if you
build a VI that calculates the trigonometric sine function, you could pass an
input of 0 to the VI and expect the VI to generate a result of 0. Hand
checking works well to test that a VI functions.
Be careful that hand checks do not become too difficult to work with. For
example, if you pass the value 253.4569090 to the sine function, it would be
difficult to determine if the VI generated the correct results. You increase the
possibility of incorrectly determining the expected value of a VI when you
hand check with values that appear to add complexity to the test. In general,
passing more complex numbers to a VI does not provide better test results
than passing values such as 0 or 3.14. Make sure to pass data that is of the
same data type but do not complicate the test plan by using numbers that
make it difficult for you to calculate the expected result.
Error Tests
Error tests help you determine if the error handling strategy you designed
works correctly and make sure the error handling code performs as you
expect. Test the error handling code by creating test plans that force errors.
The error test should verify that the proper errors are reported and recovered.
The error test plan also should verify that the error handling code handles
errors gracefully.
Job Aid
Use the following checklist to help generate a test plan for a VI.
The individual component VI you want to test is referred to as the unit under
test (UUT). You must perform unit testing before you perform system
integration testing. System integration testing evaluates how your VIs
perform with devices and software external to LabVIEW. The output of unit
testing is useful in performing system integration because it provides
structure information about the LabVIEW code. Use unit testing as one of
the many tools, methods, and activities to help ensure quality software.
Integration Testing
You perform integration testing on a combination of units. Unit testing
usually finds most bugs, but integration testing can reveal unanticipated
problems. Modules might not work together as expected. They can interact
in unexpected ways because of the way they manipulate shared data.
Note You can perform integration testing only in the LabVIEW Full and Professional
Development Systems.
You also can perform integration testing in earlier stages before you put the
whole system together. For example, if a developer creates a set of VIs that
communicates with an instrument, he can develop unit tests to verify that
each subVI correctly sends the appropriate commands. He also can develop
integration tests that use several of the subVIs in conjunction with each
other to verify that there are no unexpected interactions.
This form of testing is called big-bang testing because you put the system
together and click the Run button to begin testing the components. Big-bang
testing is dangerous because it is difficult to determine and locate where
errors occur in the system. Also, there is no way to test the system until all
the components are complete. This form of testing can be effective for small
projects, but for most projects, this form of testing is not practical.
Sandwich Testing
Sandwich testing is a combination of bottom-up and top-down integration
testing. This method uses top-down tests to test the upper-level control.
Bottom-up tests are used to test the low-level hardware and system
functionality. This method takes advantage of the benefits that both
integration testing methods use, while minimizing their disadvantages.
Figure 7-3 shows an example of sandwich testing.
Regardless of the approach you take, you must perform regression testing at
each step to verify that the previously tested features still work. Regression
testing consists of repeating some or all previous tests. If you need to
perform the same tests numerous times, consider developing representative
subsets of tests to use for frequent regression tests. You can run these subsets
of tests at each stage. You can run the more detailed tests to test an individual
set of modules if problems arise or as part of a more detailed regression test
that periodically occurs during development.
Job Aid
Each of the integration testing methods except the big-bang method
emphasizes that units should be tested before they are integrated. Also, each
of the methods encourages you to test with incremental integration and to
test the system as components are added. Incremental integration enables
you to quickly identify and isolate which VIs generate errors. There is no
single incremental testing method that is best for testing a VI. However,
incremental integration saves time and helps you create more reliable
applications. Use the following checklist to determine if the incremental
testing strategy you use is adequate.
Scenario
The Initialize function places the application into a stable mode by
initializing all of the modules and clearing the user interface.
When the user selects the File»Exit menu, the application should safely
shutdown. Safely shutting down an application requires closing all open
memory references.
Design
The Initialize function outlined in the requirements document performs the
following actions:
Because you design the modules to close open memory references, the
Shutdown VI accesses the function on the module to shutdown the module.
Also, Shutdown needs to send a Stop message to the display loop. Sending
a Stop message to the display loop causes that loop to finish executing. The
following modules need to shutdown: Display, Hardware, and File. You can
re-initialize the Cue module to delete any Cues that are stored in the
persistent shift register.
Implementation
The implementation of the Initialize VI involves calling the modules that
you built and wiring the correct data type to them. There is not a specific
order in which you must call the VIs. Follow the order in the Design section
to be complete.
Initialize
1. Create an Integration folder in the My Computer project hierarchy.
Note In later instances the Data input of tlc_Display Module.vi will be set to 2,
which corresponds to disabling the front panel controls.
5. Modify the connector pane for the VI, as shown in Figure 7-5.
Note As you integrate each function into the application, delete the One Button Dialog
function in the corresponding case of the Case structure.
Note The labels for the cluster constants in Figure 7-6 have been made visible to
differentiate between the parameters in each cluster.
9. Wire the Initialize case of the consumer loop as shown in Figure 7-6.
❑ Wire the user event out output of the Create User Event function
outside the while loops to the tlc_User Event Reference.ctl input of
the tlc_Initialize.vi.
❑ Wire the queue out output of the Obtain Queue function outside the
Display loop to tlc_Display Queue Reference.ctl input of the
tlc_Initialize.vi.
❑ Wire the queue out output of the Dequeue Element function inside
of the consumer loop to the tlc_Consumer Queue Reference.ctl
input of the tlc_Initialize.vi.
Shutdown
1. Add tlc_Shutdown.vi located in the <Exercises>\LabVIEW
Intermediate I\Course Project\Integration directory to the
Integration folder.
3. The Cue module is set to Initialize, which causes the shift register in the
Cue module to reinitialize with an empty Cue array.
5. Open TLC Main VI and place the tlc_Shutdown.vi in the Exit case
of the consumer loop. Run the error wire through tlc_Shutdown.vi.
Testing
1. Run the TLC Main VI and select File»Exit. Verify that the Shutdown
function causes the application to end. After you integrate the Display
functionality, you also can verify that the Initialize function executes.
Scenario
The design of this application splits the functionality into three separate
loops. The producer loop uses an Event structure to monitor changes to the
front panel. The consumer loop handles all of the processing for the
application. The display loop updates the user interface. The advantage of
this three loop architecture is that functionality is contained within
individual parallel processes. This increases performance and stability of
the application. Using the three loops also improves the maintainability and
scalability of the application.
Implement the code in the display loop to update the user interface.
Design
In order to perform the functions specified in the requirements document,
you need to have the following display functions: Initialize Front Panel,
Update Front Panel Channels, Select Cue in Cue List, Enable/Disable Front
Panel Controls, and Update Cue List. Implement these functions in the
display loop of the top-level VI. The advantage to implementing this code
on the top-level VI is that you have direct access to the terminals on the front
panel.
Implementation
Open the TLC Main VI block diagram and edit the display loop. Modify the
following cases in the Case structure.
1. Modify the Initialize Front Panel case as shown in Figure 7-8 using the
following items.
1. Modify the Select Cue in Cue List case of the display loop as shown in
Figure 7-9 using the following items.
❑ Variant to Data
1. Modify the Update Cue List case of the display loop as shown in
Figure 7-11. To do this, use the following items:
❑ For Loop
❑ First tlc_Cue_Module.vi
– Place the VI inside the while loop and outside the For Loop.
– Wire the Number of Cues output to the count terminal of the For
Loop. Wiring the count terminal this way executes the loop once
for each cue in the list.
– Right-click the command input of the Cue Module. Select
Create Constant and set its value to Get Number of Cues.
This value results in the Cue Module returning the number of
cues in the current Cue List.
❑ Second tlc_Cue_Module.vi
– Place the VI inside the For Loop.
– Right-click the Cue Module and select Create Constant. Set
this enum constant’s value to Get Cue Values. This value
results in the Cue Module returning a cluster containing the
name of the cue, its wait time, fade time, follow time, and the 2D
array of channels associated with that cue.
1. Modify the block diagram for the Update Front Panel Channels
case of the display loop as shown in Figure 7-12 using the following
items.
❑ Variant To Data
Testing
1. Run the VI.
2. The VI calls the Initialize function. The function initializes the front
panel. All of the channels on the front panel should initialize with the
correct channel numbers.
End of Exercise 7-2
Scenario
The record function needs to prompt the user for the Cue Name, Wait Time,
Fade Time, Follow Time, and the settings for the channels. Prompt the user
with a modal dialog box where the user can enter values. After the user
enters the values, the values are placed into the Cue module, and the user
interface updates.
Design
A Record dialog box has been created, based upon the Dialog Based Events
framework. This framework uses an Event structure to monitor events on the
user interface. Complete the functionality to retrieve the inputs from the
user. Pass a Cue Data type that was created from the producer loop into the
consumer loop to store the recorded cue in the application. Using a variant
for the design pattern makes it easier to perform this functionality.
Implementation
1. Add tlc_Record Dialog Box.vi located in the <Exercises>\
LabVIEW Intermediate I\Course Project\Integration
directory to the Integration folder. This VI will be used to obtain
information about the cue recorded by the user.
2. Open the tlc_Record Dialog Box.vi. Open the front panel of the
VI and expand the input cluster, align the interface items, and hide the
error clusters to improve the usability of the VI. When complete, it
should be similar to Figure 7-13.
When this dialog box displays, the user enters values for Cue Name,
Wait Time (s), Fade Time (s), and Follow Time (s). The user
then configures the channel array for the intensities and colors for the
cue.
3. Set the minimum value for Fade Time (s) to be one second.
❑ Click OK.
4. Open the block diagram and create a constant from the command input
of the Cue module. Set the command to Get Empty Cue, as shown in
Figure 7-14.
5. Modify the Connector Pane to pass the Cue indicator that you created on
the tunnel of the While Loop, as shown in Figure 7-15.
❑ Resize the front panel to show only the buttons and the
tlc_Cue_Information.ctl.
❑ In the True case, wire the queue refnum and error wires across the
Case structure.
9. Test the TLC Main VI. Verify that the Record Dialog Box appears when
you click on the Record button. After clicking OK in the Record Dialog
Box, a One Button Dialog should appear indicating that you are in the
Record case of the consumer loop. Click OK and stop the VI.
11. Open the tlc_Record.vi and examine the block diagram. The VI first
uses the Display Module to update the 2D array of channels on the user
interface. Next, it calls the Cue Module to add the new cue to the
functional global variable cue array. Finally, it calls the Display Module
again to update the cue list on the user interface.
13. Modify the consumer loop to call the Record VI and convert the variant
data into data that the Record VI can accept. Figure 7-17 shows the
completed Record case in the consumer loop. Use the following items to
modify this case:
❑ Variant To Data
❑ tlc_Cue_Information.ctl constant
❑ tlc_Record.vi
Testing
1. Run the TLC Main VI.
3. If the application is running correctly, you should see that the front panel
channels update with the Cue you recorded, and the Cue List updates
with the name of the cue that you entered in the Record Dialog Box.
Scenario
The Play functionality for the Theatre Light Controller is best implemented
as a state machine. Figure 7-18 shows the states of the Play function.
Start
Cue
Exists
Initialize Begin Play Load Cue Wait Time
Cue
Does Not
Exist Check for
End Follow Time Fade Time
Next Cue
Design
The Play function uses the Timing module to implement the wait, fade, and
follow timing requirements.
After you develop the Play module, integrate the Play function into the TLC
Main VI. At this point in the exercise, you see how you can implement a
state machine in a producer/consumer design pattern.
Implementation
Build the play functionality to place in the consumer loop. Start by
examining the play VIs.
❑ Notice that the VI calls the Light Color Controller VI, which
calculates a color based on desired color, desired intensity, elapsed
time, and target time.
❑ Notice also how the VI sends a message to the Hardware module and
Display module.
3. Examine the state machine tlc_Play.vi that will perform the Wait,
Fade, and Follow timing requirements for the application.
Open the tlc_Play.vi and notice that the VI is implemented using the
state machine design pattern. Also notice that the VI has a True constant
wired to the loop conditional terminal. This VI is designed to be called
repeatedly in order to move from one state to the next. In order to control the
VI, the state machine returns a Boolean indicating whether it is done.
Examine how the Initialize, Begin Play, and Load Cue states operate.
❑ tlc_Timing Module.vi
– Place two Timing Module VIs inside the Wait Time state.
– Right-click each Timing Module VI and select Create»
Constant. Set each constant as shown in Figure 7-19.
❑ Case structure
– Place the Case structure around the second tlc_Timing Module
VI and ensure that this VI is in the True case.
– Wire the Done? terminal of tlc_Timing Module.vi to the
case selector terminal. If the tlc_Timing Module VI outputs True
from the Done terminal, then the Case structure will send the
tlc_Timing module a Start command to set a new start time.
– In the False case, pass the error wire through the Case structure.
❑ tlc_Timing Module.vi
– Place two copies of this VI inside the Fade Time state.
– Right-click each Timing Module VI and select Create»
Constant. Set each constant as shown in Figure 7-20.
❑ Case structure
– Place the Case structure around the second tlc_Timing Module
VI, and ensure that this VI is in the True case.
– Wire the Done? terminal of tlc_Timing Module.vi to the
case selector terminal. If the tlc_Timing Module VI outputs True
from the Done terminal, then the Case structure will send the
tlc_Timing module a Start command to set a new start time.
– In the False case, wire the error wire across the Case structure.
7. Open TLC Main.vi and modify the Play state in the consumer loop to
call tlc_Play.vi, and add the functionality to repeatedly call
tlc_Play.vi, as shown in Figure 7-22. Use the following items to
modify this case:
❑ Enqueue Element
Testing
At this point, you can run the VI, record a cue, and play back the cue.
1. Run the VI.
2. Record a cue with a single channel that contains a color other than black,
and an intensity of 100. Set the Wait time to 0, Fade time to 10, and
follow time to 0.
4. The channel that you recorded should begin to fade from 0% intensity to
100% intensity within 10 seconds.
5. Try recording another cue and observe the response of the system.
Scenario
The requirements for the application state that the user can stop a playing
cue by clicking the Stop button on the front panel. This exercise implements
that capability.
Design
When the user clicks the Stop button, the Event structure generates an event
to process the Stop button. To guarantee that the application responds to the
Stop button, flush the queue that controls the consumer to remove any
messages stored in the queue. Also, stop the Timed Loops.
To do this, you must make the following changes to the TLC Main VI:
• In the producer loop, modify the Stop event case to flush the queue and
call the tlc_Timing Stop Module.vi.
• In the consumer loop, modify the Stop case to enable the front panel
controls.
Implementation
1. Open the TLC Main VI.
2. In the producer loop, modify the Stop event case to flush the queue as
shown in Figure 7-23. Use the following items to complete this event
case:
❑ Flush Queue
Because the consumer loop runs in parallel with the producer loop, it is
possible that the Play case of the consumer loop could enqueue a play
command after the user clicks on the Stop button and the queue is
flushed in the producer loop.
4. In the consumer loop, modify the Stop case as shown in Figure 7-24.
This case should stop execution of the cue list and enable the user
interface controls. Use the following items to modify the case:
Testing
1. Run the TLC Main VI.
2. Record a cue, and play the cue. Verify that the stop functionality works
by clicking the Stop button during play.
Scenario
The file save and load functionality are important for the lighting designers
who use the software. Most theatres orchestrate a lighting scene during
dress rehearsals, and the lighting designer re-uses the lighting design from
dress rehearsal for opening night and beyond. Save and load functionality is
important for any large scale application.
Design
Modify the producer loop in the TLC Main VI to prompt the user for the file
name. Several checks need to occur to determine if the user cancels the file
operation or tries to open a file that does not exist.
Modify the Save case in the consumer loop to get the values stored in the
Cue module and pass the recorded Cues to the File module.
Modify the Load case in the consumer loop to open the file and extract the
saved cues, while populating the Cue module with the saved cues.
Implementation
Modify the Save case in the consumer loop to get the values stored in the
Cue module and pass the recorded Cues to the File module.
Save
1. Add Clear Specific Error.vi located in the <Exercises>\
LabVIEW Intermediate I\Course Project\Shared directory
to the Shared virtual folder.
3. Modify the Save case in the Menu Selection event of the producer loop,
as shown in Figure 7-25. Use the following items:
❑ Compound Arithmetic
– Set the function to OR the two inputs.
– Invert the bottom terminal.
– Using the Compound Arithmetic function returns a True if the
user replaces the file or does not cancel the file save operation.
❑ Case structure
❑ Variant to Data
❑ For Loop—This loop is used to iterate through all the cues in the Cue
List.
❑ tlc_Cue Module.vi
– Place the first instance of this VI outside the For Loop and set it
to Get Number of Cues.
– Wire the Number of cues output to the count terminal of the For
Loop to determine the number of iterations needed to save all the
Cue List data.
❑ tlc_Cue Module.vi
– Place the second instance inside the For Loop and set the
command to Get Cue Values.
– Wire the iteration terminal to the Cue Index on the Cue module
so that each cue in the list is retrieved.
❑ Wire the Cue Output output of the Cue Module to the Cue Array
Input of the File module. Verify that indexing is enabled on the For
Loop tunnel.
Load
Modify the Load case in the consumer loop to open the file and extract the
saved cues, while populating the Cue module with the saved cues.
1. Create the Open case in the Producer Menu Selection event as shown in
Figure 7-28. To do this, we will duplicate the Save case and modify the
File Dialog Express VI.
❑ Right-click the Save case, and select Duplicate Case from the
shortcut menu.
❑ Delete the Open case that you created earlier in the course to test the
menu handling capability of the application.
❑ Place the Variant to Data function in the Load case and complete the
wiring of the case.
Testing
1. Run the TLC Main VI.
7. Load the file you just saved by selecting File»Open and navigating to
File Test.dat in the <Exercises>\LabVIEW Intermediate I
directory. Play the loaded cue list and verify that the cues are the ones
you saved earlier.
Scenario
The Error module that you built is designed to safely shutdown the
application if an error occurs. Shutting down the producer loop requires
sending a user event to the producer loop. Shutting down the consumer loop
requires placing a Exit message in the queue. Shutting down the display
loop requires placing a Stop message in the queue.
If an error occurs, the Timed Loops inside the Timing module should also
be stopped by calling the tlc_Timing Stop Module.vi.
Design
Modify the TLC Main VI to call the Error module after each computation in
the producer, consumer, and display loop.
Implementation
1. Modify the TLC Main VI to call the Error module after each
computation in the producer, consumer, and display loop as shown in
Figure 7-30. Use the following items:
Testing
1. Test the error handling capability by placing a Diagram Disable
Structure over the Clear Specific Error VI in the producer loop.
You can use the Diagram Disable Structure to comment out code on the
Block Diagram. It is a useful tool for testing functionality or for trying
to isolate problem areas on the block diagram.
Figure 7-32. Enabled Case of Producer Loop with Diagram Disable Structure
4. Enable the case of the Diagram Disable structure that contains the Clear
Specific Error VI.
Challenge
Integrate the Select Cue function to update the user interface with the values
in a selected recorded cue. There are two primary tasks that must be
implemented to build the Select Cue functionality. The Select Cue function
must acquire the cue values for the selected cue and update the front panel
with the cue values.
Note Every individual or company has its own method for testing a system. The
guidelines described in this section are suggestions for system testing, not requirements.
Do not change your existing testing strategy unless it is deficient.
Configuration Tests
Use configuration tests to test variations in system and software
configurations. Include testing on multiple operating systems unless the
requirements document clearly specifies the operating system for the VI.
Configuration testing also includes running the VI on different screen
resolutions. Make sure the VI can display the required information on the
minimum screen resolution stated in the requirements document. Also, test
the VI on higher screen resolutions to ensure that the user interface items
remain proportional and are not distorted.
Performance Tests
Performance tests define and verify performance benchmarks on the
features that exist in the VI. Performance tests include tests for execution
time, memory usage, and file sizes. The requirements document should
indicate any performance requirements for the VI. Make sure you test each
performance requirement in the requirements document.
Stress/Load Tests
The stress/load tests define ways to push a VI beyond the required limits in
the specification. Typical stress/load tests include large quantities of data,
extended time testing, and running a large number of applications
concurrently with the VI. Stress/load testing helps guarantee that a VI
performs as required when it is deployed.
Functional Tests
The final implementation of a system must be functional to the level stated
in the requirements document. The easiest way to test for functionality is to
refer to the original requirements document. Check that there is a functional
implementation of each requirement listed in the requirements document.
Functional testing also must involve the customer at some point to guarantee
that the software functions at the level stated in the requirements. After you
complete functional testing and the software passes the software test, you
can verify the software as functional.
Reliability Tests
Testing the reliability of the system often involves using pilot testing to test
the system in a non-development environment. There are two forms of pilot
testing—alpha and beta testing. Schedule alpha testing to begin when the
software first reaches a stage where it can run as a system. Alpha testing
typically involves a developer running the system on another computer. Beta
testing begins when most of the system is operational and implemented and
ready for user feedback. Pilot testing provides a good indication of how
reliable the software is when it is deployed on computers other than the
development computer. Pilot testing helps identify issues with hardware and
operating system compatibility.
You can complete this testing with alpha and beta testing. Alpha and beta
testing serve to catch test cases that developers did not consider or complete.
During alpha testing, test a functionally complete product in-house to see if
any problems arise. Beta testing occurs after alpha testing is complete.
During beta testing, the customers in the field test the product.
Alpha and beta testing are the only testing mechanisms for some companies.
Unfortunately, alpha and beta testing actually can be inexact and are not a
substitute for other forms of testing that rigorously test each component to
verify that the component meets stated objectives. When this type of testing
is done late in the development process, it is difficult and costly to
incorporate changes suggested as a result.
Alpha Tests
The main focus of alpha testing is to execute system tests, fix errors, and
produce beta-quality software. Beta-quality software is defined as software
ready for external customer use.
Beta Tests
Beta testing involves sending a beta version of the software to a select list of
customers for testing. Include a test plan that asks the users to test certain
aspects of the software.
Write additional systems tests to execute during the beta phase. Include
performance and usability tests. The tests executed during the alpha phase
should be executed again as part of beta testing. Also include time to test the
product by freely developing applications like users do. Consider that you
might need to create more test cases or update existing tests.
Usability
Usability measures the potential of a system to accomplish the goals of the
user. Some factors that determine system usability are ease-of-use, visual
consistency, and a clear, defined process for evolution.
Systems that are usable enable users to concentrate on their tasks and do real
work rather than focusing on the tools they use to perform tasks.
Usability Heuristics
Use the following usability heuristics1 when evaluating the usability of
software. Not meeting one or more of these guidelines may result in a
usability issue.
• Visibility of system status—The system should always keep users
informed about what is going on, through appropriate feedback within a
reasonable time.
• Match between system and the real world—The system should speak
the users’ language, with words, phrases, and concepts familiar to the
user, rather than system-oriented terms. Follow real-world conventions,
making information appear in a natural and logical order.
• User control and freedom—Users often choose system functions by
mistake and need a clearly marked “emergency exit” to leave the
unwanted state without having to go through an extended dialogue.
Support undo and redo.
• Consistency and standards—Users should not have to wonder whether
different words, situations, or actions mean the same thing. Follow
platform conventions.
• Error prevention—Even better than good error messages is a careful
design which prevents a problem from occurring in the first place.
• Recognition rather than recall—Make objects, actions, and options
visible. The user should not have to remember information from one part
of the dialog to another. Instructions for use of the system should be
visible or easily retrievable whenever appropriate.
Usability Testing
Usability testing is a cyclic process, resulting in several iterations of design
and test. A typical usability study includes three iterations and a final
meeting. Each iteration includes three steps—meeting, testing, and report.
• Meeting—Gather information, consider the different issues
encountered, and determine guidelines. Set goals and purposes during
this step.
• Testing—Test, analyze, or evaluate the product. Depending on the
iteration of usability testing, conduct a usability evaluation, cognitive
walkthrough, or formal study of the software.
• Report—Present the test results. Issues are typically listed by priority.
Reports increase in detail and complexity with each stage.
There are many techniques you can apply to the usability process. No single
technique can ensure the usability of a product. Usability is an iterative
Scenario
Before releasing an application, a set of system level tests must take place.
These tests can consist of usability testing, performance testing, stress, and
load testing.
Design
Create a large set of cues stored in a file that contain random wait times, fade
times, follow times, and channel colors and intensities. The VI used to
create the large set of cues requests from the user the maximum times to use
for the wait, fade, and follow so that it is easier to analyze the functionality
of the application.
Implementation
1. Open the System Testing Driver.vi located in the
<Exercises>\LabVIEW Intermediate I\Course Project\
System Testing folder.
2. Open the block diagram and examine how this VI uses the modules that
you created to create a large set of Cues.
3. Switch to the front panel and set the following front panel controls:
• Wait Time = 0
• Fade Time = 5
• Follow Time = 0
9. Open the Windows Task Manager and monitor the memory usage and
performance of the Theatre Light Controller. Running TLC Main VI
with a large number of cues can indicate if there is a memory or
performance issue with the application.
Summary – Quiz
1. Top-Down, bottom-up, big-bang, and sandwich are all methods of
performing what kind of test?
a. Regression
b. Integration
c. Performance
d. Usability
Notes
As you develop your VI, you might want to focus on its performance;
however, during development, it is more effective for you to focus on using
good design principles. Wait to identify and improve performance issues
after you have a stable, working application. Consider that the rapid rate of
improvement in computer technology can compensate for some
performance issues. This lesson describes methods to evaluate and improve
VI performance.
Topics
A. Steps to Improving Performance
B. Using VI Metrics to Identify VI Issues
C. Identifying VI Issues with VI Analyzer (Optional)
D. Identifying Performance Problems
E. Fixing Performance Problems
Developing VIs that are scalable, readable, and maintainable helps you
create VIs that are correct, thus saving costs over time. However, there are
times when VIs are too slow, and purchasing a newer computer to run the
VI might not be an option. In this case, there are techniques you can use to
identify areas of the code that are causing performance problems. Minimize
the time you spend identifying and correcting performance problems
because processor technology advances so rapidly that by the time you fix
performance problems, a faster computer may be available that compensates
for slow VI performance.
and writing VIs to parse the results, combining fields to produce a new
measurement of the complexity of a VI.
Scenario
Using VI Metrics can determine the complexity of the VI to help in being
able to identify issues with the application.
Design
Run the VI Metrics tool to determine the complexity of the VI.
Implementation
1. Open the TLC Main VI.
5. When you finish viewing the VI Metrics, click the Done button.
The toolkit organizes the tests into the following main categories:
• Block Diagram—Tests analyze VI performance and style related to the
block diagram.
• Documentation—Tests check for documentation issues within VIs.
• Front Panel—Tests analyze front panel design and style.
• General—Tests analyze aspects of VIs not covered in the Block
Diagram, Documentation, or Front Panel categories.
Performance
The tests in the following list analyze coding conventions that affect VI
performance.
• Arrays and Strings in Loops—Checks loops to see if they contain
Build Array or Concatenate Strings functions. Avoid using these
functions in loops because each call to them requires a dynamic resizing
of the array or string, which can affect memory and processor time. This
test does not check timed loops.
• Coercion Dots—Checks the total number of coercion dots on the block
diagram and the number of coercion dots on individual wires and
compares them to user-specified limits.
• Enabled Debugging—Checks whether debugging is enabled or
disabled. Disabling debugging improves VI performance.
• Wait in While Loop—Checks While Loops with front panel control
terminals for structures or functions other than I/O functions that
regulate the speed of the While Loop.
• Wired Terminals in Subdiagrams—Checks to see if any control or
indicator that is wired on the connector pane does not reside within the
top-level diagram. In order to avoid unnecessary memory copies, place
control and indicator terminals that are wired on the connector pane
should be placed on the top-level diagram.
Style
The tests in the following list analyze block diagrams for issues related to
LabVIEW style. Refer to the LabVIEW Style Checklist for information
about LabVIEW style.
• Backwards Wires—Checks whether wires flow from left to right.
• Control Terminal Label Visible—Checks if labels of block diagram
control terminals are visible. To easily identify control terminals on the
block diagram, always make labels visible.
• Control Terminal Wiring—Checks whether wires exit control
terminals from the right side and enter indicator terminals on the left
side.
• Sequence Structure Usage—Checks whether the block diagram
includes Stacked Sequence structures that contain more than the
user-specified maximum number of frames. The test does not check Flat
Sequence structures.
• String Constant Style—Checks the style of string constants on the
block diagram. String constants containing no characters fail the test.
Replace them with an empty string constant. String constants set to
Normal Display that contain only white space—such as spaces, tabs, or
line feeds—fail the test. Set the constants to '\' Codes Display to
improve block diagram readability.
• Unused Code—Checks for unnecessary code on the block diagram.
• Wire Bends—Compares the total number of bends on a wire and wire
segments and compares them to user-specified limits.
• Wires Under Objects—Checks for wires that run under objects or
other wires.
Warnings
The tests in the following list analyze block diagrams for potential design
problems.
• Adding Array Size Elements—Checks whether the Add Array
Elements function connects to the output of the Array Size function to
determine the size of a multidimensional array. Wire the Multiply Array
Elements function to the size(s) output of the Array Size function to
determine whether a multidimensional array is empty.
• Breakpoint Detection—Checks for breakpoints on the block diagram,
including breakpoints on wires, nodes, and subdiagrams.
• Bundling Duplicate Names—Checks element names in the Bundle By
Name and Unbundle By Name functions for duplicates. Duplicate
elements can cause confusing and sometimes incorrect block diagram
behavior.
Documentation Tests
The VI Analyzer groups the Documentation tests into the Developer and
User subcategories.
Developer
The tests in the following list ensure that VIs contain documentation that
benefits other developers.
• Comment Usage—Checks whether the block diagram contains a
minimum user-specified number of comments. The test also can check
whether all subdiagrams of multiframe structures, such as Case, Event,
and sequence structures, contain at least one comment.
• Label Call Library Nodes—Checks Call Library Function Nodes on
the block diagram for labels. You can improve the readability of a VI by
using the label of a Call Library Function Node to describe the function
you are calling in a shared library. The test fails if a Call Library
Function Node has no label or the default label.
• Revision History—Checks for revision history comments. Clear the
revision history when you complete a VI so users cannot see developer
comments.
User
The tests in the following list ensure that VIs contain documentation that
benefits users.
• Spell Check—Spell checks VIs, front panels, and block diagrams.
• VI Documentation—Checks for text in the VI description, control
description, and/or tip strip fields on all controls.
SubVI
The tests in the following list check the appearance and arrangement of front
panel controls on VIs used as subVIs.
• Array Default Values—Checks charts, graphs, and arrays on a front
panel for empty default values. Saving non-empty default values inside
charts, graphs, or arrays uses memory unnecessarily. When the VI runs,
it overwrites values wired to indicators on the block diagram. If the VI
is used as a subVI, the VI overwrites values wired to controls connected
to the connector pane.
• Cluster Sized to Fit—Checks that front panel clusters are set to Size to
Fit, Arrange Horizontally, or Arrange Vertically. If you do not select one
of these autosizing options, cluster objects might not be visible to the
user.
• Control Alignment—Checks that the alignment of controls on the front
panel roughly matches the alignment of controls on the connector pane.
User Interface
The tests in the following list analyze user interface design.
• Clipped Text—Checks that any visible text on the front panel is not cut
off. This includes text in control labels, control captions, free labels, and
text controls such as strings and paths. The test cannot check the text
inside listboxes, tables, tree controls, and tab controls.
• Dialog Controls—Checks that the front panel controls are on the
System palette. The test ignores controls that do not have a dialog
counterpart.
• Duplicate Control Labels—Checks that controls on the front panel do
not share the same label.
• Empty List Items—Checks listbox, multicolumn listbox, table, and
tree controls to ensure that they are empty. LabVIEW populates the
contents of these controls when a VI runs, so saving a with these controls
populated wastes memory.
• Font Usage—Checks that front panel controls, indicators, and free
labels use user-specified symbolic fonts, such as application, system, or
dialog fonts. The test cannot check fonts for text within listboxes, tables,
tree controls, and tab controls.
• Overlapping Controls—Checks that front panel controls do not
overlap. The test does not analyze front panel decorations.
• Panel Size and Position—Checks that a front panel completely resides
within the bounds of the screen. The test also checks whether the front
panel is larger than the maximum specified width and height. If you are
using a multi-monitor system, the test fails if the panel does not reside
entirely within the bounds of the primary monitor. This test works only
on standard, control, and global VIs.
• Transparent Labels—Checks that free labels, control labels, and
control captions all have transparent backgrounds.
General Tests
The VI Analyzer groups the General tests into three subcategories: File
Properties, Icon and Connector Pane, and VI Properties.
File Properties
The tests in the following list analyze properties of the VI as a file, such as
filename and size.
• SubVI and TypeDef Locations—Checks that subVIs and TypeDefs
reside in one of an arbitrary number of user-specified locations (paths
and LLBs). If you do not specify a location, the VI passes the test. The
test does not check Express VIs on a block diagram.
VI Properties
The tests in the following list analyze the overall setup of a VI.
• Broken VI—Checks for broken VIs.
• Driver Usage—Checks for subVIs, functions, or Property Nodes that
are part of National Instruments driver software packages.
• Platform Portability—Checks for potential problems that might occur
when you attempt to port a VI from one operating system to another.
• Removed Diagram—Checks whether the block diagram is present. Do
not remove a block diagram from a VI because you cannot recover it.
You can password protect a VI if you do not want users to view the block
diagram.
• Toolkit Usage—Checks whether subVIs are National Instrument
toolkit VIs. When you distribute a VI that includes toolkit VIs as subVIs,
each computer that runs the VI must have the toolkit VIs installed or the
VI does not run correctly.
• VI Lock State—Checks the lock state of a VI. The test fails if the lock
state matches the user-specified lock state(s).
Scenario
Before deploying an application, it is important to verify that the code is
scalable, readable, and maintainable. Using the VI Analyzer can automate
this verification process.
Design
Run the VI Analyzer on the TLC Main VI.
Implementation
1. Open the TLC Main VI.
3. Select the Analyze the VI you are currently editing option. Click
Next.
4. Configure options for the tests. Click Analyze. Review your results.
Click Done when you are finished. Click Yes to restart the Analyzer or
click No to close the Analyzer.
5. Identify style issues that are of a concern in the application with the
VI Analyzer.
VI Performance Profiling
Use the VI Profile Window to identify the location of performance problems
in the VI. The Profile Performance and Memory window is a powerful
tool for determining where your application is spending its time and how it
is using memory. The Profile Performance and Memory window has an
interactive tabular display of time and memory usage for each VI in your
system. Each row of the table contains information for a specific VI. The
time spent by each VI is divided into several categories and summarized.
The Profile Performance and Memory window calculates the minimum,
maximum, and average time spent per run of a VI.
You can use the interactive tabular display to view all or part of this
information, sort it by different categories, and look at the performance
data of subVIs when called from a specific VI. Select Tools»Advanced»
Profile VIs to display the Profile window.
Memory
In text-based programming languages, memory allocation, reallocation, and
deallocation cause many bugs and performance bottlenecks. In text-based
languages, you must allocate memory before you use it and deallocate
memory when you finish using it. Bounds checking does not occur when
you write to this memory, so you have to create your own tests to make sure
you do not corrupt memory.
Memory allocation still occurs, but it is not explicit on the block diagram.
This allows you to focus on developing the code to solve a problem rather
than allocating and deallocating memory. But, it is important to understand
how LabVIEW handles memory. Memory reallocation buffers and coercion
can affect memory in LabVIEW.
Consider the block diagram shown in Figure 8-1, which is used to create an
array of data. This block diagram creates an array in a loop by constantly
calling Build Array to concatenate a new element. The input array is reused
by Build Array. The VI continually resizes the buffer in each iteration to
make room for the new array and appends the new element. The resulting
execution speed is slow, especially if the loop is executed many times.
Note When you manipulate arrays, clusters, waveforms, and variants, you can use the
In Place Element structure to improve memory usage in VIs.
If you want to add a value to the array with every iteration of the loop, you
can see the best performance by using auto-indexing on the edge of a loop.
With For Loops, the VI can predetermine the size of the array (based on the
value wired to N), and resize the buffer only once.
With While Loops, auto-indexing is not quite as efficient, because the end
size of the array is not known. However, While Loop auto-indexing avoids
resizing the output array with every iteration by increasing the output array
size in large increments. When the loop is finished, the output array is
resized to the correct size. The performance of While Loop auto-indexing is
nearly identical to For Loop auto-indexing.
Auto-indexing assumes you are going to add a value to the resulting array
with each iteration of the loop. If you must conditionally add values to an
array but can determine an upper limit on the array size, you might consider
preallocating the array and using Replace Array Subset to fill the array.
When you finish filling the array values, you can resize the array to the
correct size. The array is created only once, and Replace Array Subset can
reuse the input buffer for the output buffer. The performance of this is very
similar to the performance of loops using auto-indexing. If you use this
technique, be careful the array in which you are replacing values is large
enough to hold the resulting data, because Replace Array Subset does not
resize arrays for you.
Coercion
Minor changes in data types can dramatically affect memory allocation for
a VI. The VI in Figure 8-5 allocates a memory buffer for the output tunnel
on the For Loop and for the array indicator. In total, the VI allocates 160 KB
to store the array.
Note The number of bytes for extended-precision values varies for each platform.
You can coerce values in a VI, but the effects of coercion on memory can be
extreme. To improve memory use of a VI, minimize coercion, or eliminate
coercion entirely.
VI Execution Speed
Although LabVIEW compiles VIs and produces code that generally
executes very quickly, you want to obtain the best performance possible
when working on time-critical VIs. This section discusses factors that affect
execution speed and suggests some programming techniques to help you
obtain the best performance possible.
Other factors, such as execution overhead and subVI call overhead, usually
have minimal effects on execution speed.
Input/Output
Input/Output (I/O) calls generally incur a large amount of overhead. They
often take much more time than a computational operation. For example, a
simple serial port read operation might have an associated overhead of
several milliseconds. This overhead occurs in any application that uses
serial ports because an I/O call involves transferring information through
several layers of an operating system.
The best way to address too much overhead is to minimize the number of
I/O calls you make. Performance improves if you can structure the VI so that
you transfer a large amount of data with each call, instead of making
multiple I/O calls that transfer smaller amounts of data.
Screen Display
Frequently updating controls on a front panel can be one of the most
time-consuming operations in an application. This is especially true if you
use some of the more complicated displays, such as graphs and charts.
Although most indicators do not redraw when they receive new data that is
the same as the old data, graphs and charts always redraw. If redraw rate
becomes a problem, the best solutions are to reduce the number of front
panel objects and keep the front panel displays as simple as possible. In the
case of graphs and charts, you can turn off autoscaling, scale markers,
anti-aliased line drawing, and grids to speed up displays.
As with other kinds of I/O, there is a certain amount of fixed overhead in the
display of a control. You can pass multiple points to an indicator at one time
using certain controls, such as charts. You can minimize the number of chart
updates you make by passing more data to the chart each time. You can see
much higher data display rates if you collect your chart data into arrays to
display multiple points at a time, instead of displaying each point as it comes in.
When you design subVIs whose front panels are closed during execution, do
not be concerned about display overhead. If the front panel is closed, you do
not have the drawing overhead for controls, so graphs are no more expensive
than arrays.
Note Turn on synchronous display only when it is necessary to display every data value.
Using synchronous display results in a large performance penalty on multithreaded
systems.
You also can use the Defer Panel Updates property to defer all new requests
for front panel updates.
When you interactively open a reentrant subVI from the block diagram,
LabVIEW opens a clone of the VI instead of the source VI. The title bar of
the VI contains (clone) to indicate that it is a clone of the source VI.
Note Because you cannot perform source control operations on the clone of a source VI,
LabVIEW dims the source control operation items in the Tools»Source Control menu
of the clone VI.
You can use the front panels of reentrant VIs the same way you can use the
front panels of other VIs. To view the original front panel of a reentrant VI
from a clone of the reentrant VI, select View»Browse Relationships»
Reentrant Original. Each instance of a reentrant VI has a front panel. You
can use the VI Properties dialog box to set a reentrant VI to open the front
panel during execution and optionally reclose it after the reentrant VI runs.
You also can configure an Event structure case to handle events for front
panel objects of a reentrant VI. The front panel of a reentrant VI also can be
a subpanel.
You can use the VI Server to programmatically control the front panel
controls and indicators on a reentrant VI at run time; however, you cannot
edit the controls and indicators at run time. You also can use the VI Server
to create a new reentrant instance of the front panel of a reentrant VI at run
time. To open a new instance of the front panel of a reentrant VI, use the
Open VI Reference function by wiring a strictly typed VI reference to the
type specifier input. Use the Run VI method to prepare a VI for reentrant
run by wiring 0x08 to the options input.
Select the Share clones between instances option to reduce the memory
usage associated with preallocating a large amount of clone VIs. Sharing
clone VIs reduces memory usage because LabVIEW does not preallocate a
clone for each call to the reentrant VI. When you select the Share clones
between instances option, LabVIEW does not create the clone VI until a VI
makes a call to the reentrant VI. With this option, LabVIEW creates the
clone VIs on demand, potentially introducing jitter into the execution of the
VI. LabVIEW does not preserve state information across calls to the
reentrant VI. Sharing clone VIs can reduce VI execution speed.
The following table explains the memory usage and execution speed effects
to consider when you select a reentrant VI type.
Description
There are three primary methods of updating a value on a user interface:
• Wire data directly to an indicator—Fastest and preferred method of
passing data to the user interface.
• Wire data to a local variable—Creating a local variable for the indicator
and wiring data to the local variable is a good method for initializing
data that is in a control.
• Wire data to a Value Property Node of the indicator—Use this method
when you update the control or indicator through a control reference.
Implementation
1. Open Methods of Updating Indicators.vi located in the
<Exercises>\LabVIEW Intermediate I\Methods of
Updating Indicators directory.
3. Run the VI for each of the methods by setting the Method enum, and
running the VI. Observe how long the VI takes to run for each method.
Job Aid
Use the following checklist to identify and fix performance issues.
Summary – Quiz
1. Which tool is best suited to identifying performance problems?
a. Profile Window
b. VI Metrics
c. VI Analyzer
d. None of the above
Notes
Topics
A. Designing Documentation
B. Developing User Documentation
C. Creating Help Files
D. Describing VIs, Controls, and Indicators
A. Designing Documentation
The quality goals of the project determine the format and detail level of the
documentation you develop for requirements, specifications, and other
design-related documentation. If the project must meet a quality standard
such as the ISO 9000, the format and detail level of the documentation is
different from the format and detail level of an internal project.
For each subVI, include information such as the VI name and description, a
picture of the connector pane, and a picture of the data type description for
each control and indicator on the connector pane.
To generate most of the documentation for VIs and controls, select File»VI
Properties and select Documentation from the Category pull-down menu.
Documenting an Application
If you are developing an application for users who are unfamiliar with
LabVIEW, the documentation requires more introductory material. Create a
document that provides system requirements, basic installation instructions,
and an overview about how the package works. If the package uses I/O,
include hardware requirements and any configuration instructions the user
must complete before using the application.
For each front panel with which the user interacts, provide a picture of the
front panel and a description of the major controls and indicators. Organize
the front panel descriptions in a top-down fashion, with the front panel the
user sees first documented first. You also can use the Print dialog box to
create this documentation.
Start
User
Configure Interface
System
Error
Configuration
Error? Handler
Error?
Configure Error?
Hardware
Error?
Acquire
Data
You can set options for, add comments to, view, and reset the revision
history.
Revision Numbers
The revision number is an easy way to track changes to a VI. The revision
number starts at zero and increases incrementally every time you save the
VI. To display the current revision number in the title bar of the VI and the
title bar of the History window, select Tools»Options, select Revision
History from the Category list, and place a checkmark in the Show
revision number in titlebar checkbox.
The number LabVIEW displays in the History window is the next revision
number, which is the current revision number plus one. When you add a
comment to the history, the header of the comment includes the next
revision number. The revision number does not increase when you save a VI
if you change only the history.
Creating VI Descriptions
Create and edit VI descriptions by selecting File»VI Properties and
selecting Documentation from the Category pull-down menu. The VI
description is often the only source of information about a VI available to
the user. The VI description appears in the Context Help window when you
move the cursor over the VI icon and in any VI documentation you generate.
You also can link from the VI to an HTML file or compiled help file.
If a text block takes up too much space on the front panel, add a Help button
to the front panel instead. Include the instruction string in the help window
that appears when the user clicks the Help button. Use the Window
Appearance page in the VI Properties dialog box to configure this help
window as either a dialog box that requires the user to click an OK button
to close it and continue, or as a window the user can move anywhere and
close anytime.
You also can use a Help button to open an entry in an online help file. Use
the Help functions to open the Context Help window or to open a help file
and link to a specific topic.
Unless every object has a description, the user looking at a new VI has no
choice but to guess the function of each control and indicator. Remember to
enter a description when you create the object.
Note If you copy the object to another VI, you also copy the description. You might need
to change the description for the new object.
Every control and indicator needs a description that includes the following
information:
• Functionality
• Data type
• Valid range (for inputs)
• Default value (for inputs)—You also can list the default value in
parentheses as part of the control or indicator name.
• Behavior for special values (0, empty array, empty string, and so on)
• Additional information, such as if the user must set this value always,
often, or rarely
Note For dynamic dispatch member VIs, you can select Dynamic Dispatch Input
(Required) or Dynamic Dispatch Output (Recommended).
Scenario
Document the user interface. You must document the front panel of every
VI that you create.
Design
Document the TLC Main VI. Documentation needs to include a VI
description, and each control and indicator needs a meaningful description
and tip.
Implementation
1. Open the TLC Main VI.
❑ Functionality
❑ Data type
You also can list the default value in parentheses as part of the
control or indicator label.
❑ Behavior for special values (0, empty array, empty string, and so on)
Use the Print dialog box to help you create the source material for the help
documents.
After creating the source documents, use a help compiler to create the help
document. If you need help files on multiple platforms, use a help compiler
for the specific platform for which you want to generate help files.
You also can link to the help files directly from a VI.
Link VIs to the Help menu using the Documentation page of the VI
Properties dialog box. You also can use the Help functions to link to topics
in specific help files programmatically.
Scenario
Documentation is an important part of developing applications that are
scalable, readable, and maintainable. Also, the end user of the application
requires documentation in order to use the system. LabVIEW assists in
developing documentation. LabVIEW can automatically generate HTML,
or RTF documents that document the functionality of the application. After
LabVIEW generates the documentation, the developer can edit and expand
on the documentation for other developers who maintain the application,
and for the end user.
Design
Use the Print dialog box to generate an HTML document that you can link
to the VI Properties of the TLC Main VI.
Implementation
1. Open the TLC Main VI.
Testing
1. Open the Context Help window.
2. Idle your mouse over the icon/connector pane of the TLC Main VI.
3. Click the Detailed help link in the Context Help window to load the
documentation for the application.
Summary – Quiz
1. Which type of information should be included in descriptions of
controls and indicators?
a. Functionality
b. Data type
c. Valid range
d. Default value
e. All of the above
Notes
Topics
A. Implementing Code for Stand-Alone Applications
B. Building a Stand-Alone Application
C. Building an Installer
With these differences in mind, this section describes techniques you can
use when you create stand-alone applications to improve the application and
and conform to licensing requirements.
The Current VI’s Path function returns the path to the file of the current VI.
If the VI never has been saved, this function returns <Not A Path>. This
function always returns the current location of the VI. If you move the VI,
the value returned changes. If you build the VI into an application, this
function returns the path to the VI in the application file and treats the
application file as a VI library. Figure 10-1 shows the output of the
Current VI’s Path function for each of the different locations where a
VI can reside.
If a VI uses the Current VI’s Path function, make sure the function works as
expected in the application or shared library. In an application or shared
library, the Current VI’s Path function returns the path to the VI in the
application file and treats the application file as an LLB. For example, if you
build foo.vi into an application, the function returns a path of
C:\..\Application.exe\foo.vi, where C:\..\Application.exe
represents the path to the application and its filename.
You must build code that has a relative file path independent of where the
VI resides so that LabVIEW can access the necessary support and data files.
One method to do this is to use the VI Server to return information about the
properties of the LabVIEW application as shown in Figure 10-2.
You can have only one About VI per application. If you do not supply an
About VI, LabVIEW displays a default dialog box similar to the dialog box
that appears in the LabVIEW development system when you select Help»
About.
Note The front panel window must include a National Instruments copyright notice.
Refer to the National Instruments Software License Agreement located on the LabVIEW
DVD or CD for more information about the requirements for any About dialog box you
create for a LabVIEW application.
2. Build the block diagram of the About VI. For example, if you want the
About dialog box to appear until the user clicks a button, use a While
Loop on the block diagram.
3. Save the VI. The name of the VI must start with About.
4. Add the VI to the project from which you are building the application.
5. When you configure the application build settings, add the About VI to
the Always Included list on the Source Files page of the Application
Properties dialog box.
6. From the Source File Settings page, select the About VI in the Project
Files tree. In the Use default save settings section, make sure a
checkmark does not appear in the Remove front panel checkbox and
that the destination is the application.
7. Configure the remaining application build settings and build the
application.
Figure 10-3 shows an example of an About dialog box that would satisfy the
National Instruments Software License Agreement.
Figure 10-4 shows one method for implementing an About VI. The block
diagram uses an Event structure with one event case set to capture the
Mouse Down event. When the user clicks the About dialog box with the
mouse, the VI stops and closes.
Distributing Builds
• Consider creating an About dialog box to display general information
about an application.
• Consider distributing a configuration file, also called a preference file,
that contains LabVIEW work environment settings with an application,
such as the labview.ini file on Windows.
• Consider distributing documentation with an application or shared
library so users have the information they need to use the application or
shared library.
Note Do not distribute the LabVIEW product documentation. The LabVIEW product
documentation is copyrighted material.
Scenario
Most applications have an About dialog box that displays general
information about the application and the user or company that designed it.
You can create a VI that LabVIEW runs when a user selects Help»About to
display information about the stand-alone application you create.
Design
1. Implement a dialog box VI that uses an Event structure to create an
About dialog box.
• Create a dialog box VI that allows the user to click the mouse
anywhere on the VI panel to close the VI.
Implementation
About Dialog Box
1. Create a dialog box VI that allows the user to click the mouse button
anywhere on the VI panel to close the VI.
❑ Place any free text or images you want on the front panel.
3. Switch to the block diagram and build the code that allows the user to
click the mouse button anywhere on the VI, as shown in Figure 10-5.
❑ Wire the error clusters through the Event structure on the block
diagram.
5. Open the TLC Project. Add an About folder below the Modules folder
in the Project Explorer window. Place the About.vi in the About
folder in the Project Explorer window. Close the VI.
6. Open and modify the TLC Main VI so that the Run-Time Menu contains
Help»About LabVIEW. This displays the About dialog box in the
stand-alone application when the user selects Help»About. Figure 10-6
shows the completed Run-Time Menu Editor.
❑ Open the TLC Main VI. Open the Menu Editor by selecting Edit»
Run-Time Menu.
❑ Add the Help menu item by adding a User Item for Help, with the
Item Name set to _Help and the Item Tag set to Help. Use the
down arrow to move to a position beneath all the other entries, as
shown in Figure 10-6. Be sure to place the entry in line with File.
Figure 10-7. Conditional Disable Structure Enclosing the Quit LabVIEW Function
2. Select Conditional Disable Symbols from the Category list, add a new
symbol with the Symbol name DEPLOY and the Value TRUE. Click Add
and click OK.
3. Modify the TLC Main VI by placing the Quit LabVIEW function on the
block diagram. The Quit LabVIEW function must be the last function
that executes with the application as shown in Figure 10-7.
8. Remove the checkmark from the Make Default? checkbox and click
OK.
12. Place a checkmark in the Make Default? checkbox and click OK.
Window Appearance
1. Select File»VI Properties and select Window Appearance from the
Category list.
Note You can duplicate build specifications in the Project Explorer window.
Right-click the build specification item you want to duplicate and select Duplicate from
the shortcut menu to create a copy of the Build Specification item. You also can drag and
drop build specification items to rearrange the build order within the same Build
Specification.
Application Builder
You can use the Application Builder to create a build specification for and
build a stand-alone application. You can configure settings for specified VIs
to add passwords, remove block diagrams, or apply other settings. You also
can select different destination directories for VIs without breaking the links
between VIs and subVIs. Before you create a build specification or start the
build process, review the caveats and recommendations for LabVIEW build
specifications.
Note If you plan to distribute a stand-alone application that uses shared variables, do not
include the .lvlib file in an LLB or in the executable. Change the Destination of the
.lvlib file to a destination outside the executable or LLB.
8. From the Icon page, select the icon file to associate with the application.
You also can view the icon using the Icon Image pull-down menu.
9. From the Advanced page, configure advanced settings for the
application.
10. From the Additional Exclusions page, configure settings to disconnect
type definitions, remove unused polymorphic VI instances, and remove
unused members of project libraries to reduce the size of the application.
11. From the Version Information page, configure the version number and
other application information.
12. From the Run-Time Languages page, set the language preferences for
the application.
Note The LabVIEW Run-Time Engine must be installed on any computer on which
users run the application or shared library. You can distribute the LabVIEW Run-Time
Engine with the application or shared library. (Windows) You also can include the
LabVIEW Run-Time Engine in an installer.
13. From the Preview page, click the Generate Preview button to review
the generated files for the application.
14. Click the OK button to update the build specification settings in the
project and close the dialog box. The build specification name appears
in the project under Build Specifications. Creating or updating the build
specification does not build the application. You must complete the next
step to build the application.
Note When you update the build specification settings, the settings become part of the
project. However, you must save the project if you want to save the settings.
15. Right-click the application build specification name and select Build
from the shortcut menu. You can find the resulting application in the
directory specified in the Destination path on the Destinations page.
You also can click the Build button in the Application Properties
dialog box to update the build specification and build the application.
For more information on the application builder and setting its options, refer
to Building a Stand-Alone Application in the LabVIEW Help.
Scenario
Creating a stand-alone application is important for distributing and
deploying your application. It is also a step in the creation of a professional
installer.
Design
Use the Application (EXE) Build Specifications to create a stand-alone
application for the Theatre Light Controller.
Implementation
1. Create a stand-alone application of the Theatre Light Controller.
❑ Select the Source Files page and select TLC Main.vi in the
Project Files listbox. Click the right arrow to place the VI in the
Startup VIs listbox.
❑ Select the Icon page and use the Icon Editor to create a 16 color icon
for both the 32 × 32 and 16 × 16 icons. Save the new icon in the
<Exercises>\LabVIEW Intermediate I\Course
Project\Icons directory. Deselect Use the default LabVIEW
Icon file and browse to the .ico file you just created.
❑ Select the Preview page and click the Generate Preview button to
preview the output of the Build Specification.
❑ Select the Advanced page and check Copy error code files to
include the custom error code that you developed.
2. Right-click the build specification that you just created and select Build
from the shortcut menu.
Testing
Navigate to the directory you specified for the destination directory and run
the executable.
C. Building an Installer
You can use the Application Builder to build an installer for files in a
LabVIEW project or for a stand-alone application you created with a build
specification. Use installers to distribute stand-alone applications, shared
libraries, and source distributions that you create with the Application
Builder. Installers that include the LabVIEW Run-Time Engine are useful if
you want users to be able to run applications or use shared libraries without
installing LabVIEW.
Before you create a build specification or start the build process, review the
Caveats and Recommendations for Building Installers.
• Use the [LVDIR] folder in the Destination View directory to add files
to install in the directory of the latest version of LabVIEW that the user
has installed.
• The folders in the Destination View directory that do not have an LV
prefix correspond to Microsoft Installer (MSI) properties that install
files in the following locations.
– [DesktopFolder]—Files you include in this folder install to the
Windows desktop of the current Windows user.
– [PersonalFolder]—Files you include in this folder install to the
personal folder, such as My Documents, of the current Windows
user.
– [ProgramFilesFolder]—Files you include in this folder install
to the Program Files folder.
– [TempFolder]—Files you include in this folder install to the Temp
folder of the current Windows user.
– [WindowsFolder]—Files you include in this folder install to the
Windows folder.
– [SystemFolder]—Files you include in this folder install to the
system32 folder on Windows.
– [WindowsVolume]—Files you include in this folder install to the
root of the drive where Windows is installed, such as C:\.
Refer to the Microsoft Installer documentation on the Microsoft Web site for
more information about using these folders.
If you want to remove files from the Destination View tree, select the
files to delete and click the Delete button or press the <Delete> key.
5. From the Source File Settings page, place checkmarks in the checkboxes
in the File Attributes section to configure the file attributes at
installation. If the installer build includes a stand-alone application in
which you enabled the ActiveX server, place a checkmark in the
Register COM checkbox for the application file.
6. From the Shortcuts page, configure any shortcuts you want to create to
files in the installer.
7. From the Additional Installers page, add installers for any National
Instruments products or drivers to include in the installer build. For
example, if you build an installer for an application or shared library that
uses the Storage VIs, you must add the NI USI installer.
8. From the Dialog Information page, set the dialog boxes, user interface
text, and error messages that appear when you run the installer.
9. From the Registry page, create registry keys and values for the installer.
10. From the Hardware Configuration page, specify the hardware
configuration information to include in the installer build.
Note Include the LabVIEW Run-Time Engine if you are distributing applications and
shared libraries to computers on which LabVIEW is not installed.
11. From the Advanced page, configure advanced settings for the installer.
12. Click the OK button to update the build specification settings in the
project and close the dialog box. The build specification name appears
in the project under Build Specifications.
Note When you update the build specification settings, the settings become part of the
project. However, you must save the project if you want to save the settings.
13. Right-click the installer build specification name and select Build from
the shortcut menu. You can find the resulting installer files in the
directory specified in the Installer destination text box on the Product
Information page of the build specification.
Note You also can build an installer programmatically from a build specification.You do
not need additional license files when using LabVIEW distribution components with
LabVIEW-built applications.
Scenario
A professional application should always have an installer to deploy the
application. Providing an installer improves the end user experience with the
application.
Design
Create an installer build specification for the executable you created.
Implementation
Create an installer for the Theatre Light Controller.
1. Open TLC.lvproj.
5. Select the Source Files page and verify that a folder that matches your
project name exists under ProgramFilesFolder. If no folder exists for
your project, add a folder and provide a meaningful name for the folder.
9. Click OK.
10. Right-click the installer build specification and select Build from the
shortcut menu.
Testing
Navigate to the installer destination directory you specified and run the
installer. After the installer runs, verify the installation of the Theatre Light
Controller.
Note These are the ideal conditions for testing an installer. For a more accurate test, try
your installer on another computer that does not have LabVIEW installed.
Summary – Quiz
1. Which of the following are code changes that should be considered
before building a VI into an executable?
a. Removal of absolute file paths
b. Creating an About dialog box
c. Adding code to quit LabVIEW upon code completion
d. All of the above
Notes
Topics
A. Institute of Electrical and Electronic Engineers (IEEE) Standards
B. IEEE Requirements Document
As with the ISO standards, IEEE 730 is fairly short. It does not dictate how
to meet the requirements but requires documentation for these practices to a
specified minimum level of detail.
Your projects may be required to meet some or all these standards. Even if
you are not required to develop to any of these specifications, they can be
helpful in developing your own requirements, specifications, and quality
plans.
Section 1: Introduction
This section provides an overview of the software requirements document.
Purpose
The purpose of this document is to provide a detailed, precise, and easy to
understand set of software requirements. Software developers use this
document as a reference to design, implement, and test the software. This
document serves as a basis to begin implementation of the software.
Scope
The scope of this document is to describe the software requirements for the
Theatre Light Control Software. The deliverables for the Theatre Light
Control Software will consist of the software system and software
documentation.
References
IEEE Recommended Practice for Software Requirements Specifications,
IEEE Std. 830-1998.
Document Overview
This document contains three sections. The first section is an introduction
and overview of the requirements document. The second section provides an
overall description of the software that will be produced. The third section
addresses the specific requirements of the Theatre Light Control Software.
Product Perspective
The Theatre Light Control Software will perform as part of a theatre lighting
system as described by the specifications provided by ABC Theatre
Lighting Inc. The Theatre Light Control Software will provide the necessary
control for the theatre lighting system to operate.
Product Functions
The Theatre Light Control Software will perform the following functions:
• Initialize
• Record
• Load
• Save
• Play
• Move Cue Up
• Move Cue Down
• Select Cue
• Delete
• Stop
• Close
User Characteristics
The users of the Theatre Light Control Software will have a deep
understanding of how theatre light systems operate. Also, the users will be
able to understand how to install and integrate the Theatre Light Control
Software into their system.
Constraints
The following are general design constraints for the Theatre Light Control
Software:
• The Theatre Light Control Software will be written in LabVIEW.
• The software must be able to control at least 16 channels.
• All minimum user-defined software times are one second.
• The minimum wait time and follow time is zero seconds.
• The minimum fade time is one second.
• The software must conform to the guidelines outlined in the customer
specification.
Apportioning of Requirements
Many theatre lighting hardware devices provide for lights that have motor
control to move the light around the stage. The Theatre Light Control
Software shall provide for the ability to easily implement channel pan and
tilt in a future version of the software. The Theatre Light Control Software
will only interface to theatre lighting hardware devices that do not contain
motor control capability for this version of the software.
User Interfaces
The main user interface shall clearly display to the user the current status of
the channel and recorded cues. The following figure shows the main user
interface.
The Cue Control and Cue Information sections are the primary visible
components on the user interface. Cue Control contains a Cue Number and
Cue Name and controls for manipulating cues. Cue Information displays
all 16 channels of the system and particular information about a selected
cue. Each channel displays the user intensity settings and color information
for that channel.
The main user interface shall contain a menu to control the operation of the
application. The menu shall contain File»Open, File»Close, and File»Exit.
Hardware Interfaces
The Theatre Light Control Software interfaces to the Theatre Lighting
Hardware Device, which is physically connected to the lights. The Theatre
Lighting Hardware Device controls light intensity and color. The following
illustration shows a high-level system diagram of the theatre lighting
system.
32
The Theatre Write VI, shown, shown in the following figure, writes the
intensity and color information to a specific channel.
The Theatre Close VI, shown in the following figure, closes the Theatre
Lighting Hardware Device.
Functions
This section describes each of the product functions in detail.
Initialize
Introduction
“Initialize” shall set all the channels to a default state of an intensity of 0%
and a color combination of 0% red, 0% green, and 0% blue. Initialize must
initialize all aspects of the user interface, and application.
Processing
Initialize Block Diagram code
Initialize Front Panel
Record
Introduction
“Record” shall take the current settings specified for the channels and create
a cue. This function prompts the user for the cue attributes, which are wait
time, fade time, and follow time.
Processing
Prompt the user for the channel color, channel
intensity, cue name, wait time, fade time, and follow
time
Store the attributes for the cue
Load
Introduction
“Load” shall prompt the user for a LabVIEW datalog file that contains a
saved set of Cues.
Inputs
LabVIEW Datalog file
Processing
Prompt the user for a filename
Check that the file exists
If the file exists
Load cues from file
Store the cue names in the cue control
Save
Introduction
“Save Cues” shall store all attributes that relate to the cues in a LabVIEW
datalog file.
Processing
Prompt the user for a filename
Check that file exists
If the file exists
Prompt the user that file exists
Suspend processing
Save all recorded cues in memory
Outputs
LabVIEW Datalog file Prompts
Play
Introduction
“Play” shall start at the top of the Cue List and execute the cue in real time.
This function updates the front panel channel array by displaying what the
Theatre Lighting Hardware Device is being commanded to do. The
information displayed to the user on the front panel will correspond to the
information that is being communicated to the Theatre Lighting Hardware
Device using the LabVIEW API.
Processing
Disable the following controls: Record, Play, Up, Down,
Delete
Repeat the following for each cue:
Wait for the number of seconds specified by wait time
Fade the channels in the cue to the desired level
within the specified number of fade time seconds
Wait for the number of seconds specified by the follow
time
Enable the following controls: Record, Play, Up, Down,
Delete
Outputs
Theatre Lighting Hardware Device Display
Move Cue Up
Introduction
“Move Cue Up” shall move the currently selected Cue up one level.
Processing
Check if currently selected cue is the first cue in the
list
If the selected cue is not the first cue in the list
Swap Selected Cue with Selected Cue - 1
Processing
Check if currently selected cue is the last cue in the
list
If the selected cue is not the last cue in the list
Swap Selected Cue with Selected Cue + 1
Select Cue
Introduction
“Select Cue” shall display the Cue Name, Fade Time, Wait Time, and
Follow Time for the Cue in the Cue Information display when a Cue is
selected in the Cue List. This function also enables the Move Cue Up, Move
Cue Down, and Delete functions to operate as expected.
Processing
Get Cue Values for Selected Cue
Update Front Panel Channels
Delete
Introduction
“Delete” shall delete a cue and all information regarding the cue that is
stored in memory.
Processing
Delete Selected Cue
Update Cue List
Stop
Introduction
“Stop” shall cause any playing cue to stop when the button is clicked.
Processing
Send a stop message to stop playing cues
Close
Introduction
“Exit” shall close all open references and cleanly stop the application. This
function also initializes all channels to an intensity of 0% with a color
combination of 0% red, 0% green, and 0% blue.
Processing
Shutdown all modules
Shutdown all open references
Outputs
Theatre Lighting Hardware Device Channel array
Performance Requirements
• The software must respond to user commands within 100 ms.
• The software must not use 100% of the CPU time.
Design Constraints
The software will be tested with 32 channels.
Reliability
The Theatre Light Control Software will have been thoroughly tested at time
of delivery so that computational errors will not occur.
Availability
The Theatre Light Control Software will not require any operating service
intervals for preventive maintenance.
Security
Because of the nature of the Theatre Light Control Software, no data or files
will be encrypted. Therefore, no security controls will be built into the
application.
Maintainability
The LabVIEW Automation Company will maintain the Theatre Light
Control Software and provide software documentation.
Other Requirements
No other requirements exist for the application.
If you searched ni.com and could not find the answers you need, contact
your local office or NI corporate headquarters. Phone numbers for our
worldwide offices are listed at the front of this manual. You also can visit the
LabVIEW Resources
This section describes how you can receive more information regarding
LabVIEW.
LabVIEW Publications
Many books have been written about LabVIEW programming and
applications. The National Instruments Web site contains a list of all the
LabVIEW books and links to places to purchase these books. Publisher
information is also included so you can directly contact the publisher for
more information on the contents and ordering information for LabVIEW
and related computer-based measurement and automation books.
info-labview Listserve
info-labview is an email group of users from around the world who
discuss LabVIEW issues. The list members can answer questions about
building LabVIEW systems for particular applications, where to get
instrument drivers or help with a device, and problems that appear.
Numbers
1D One-dimensional.
2D Two-dimensional.
A
A Amperes.
absolute path File or directory path that describes the location relative to the top level
of the file system.
active window Window that is currently set to accept user input, usually the frontmost
window. The title bar of an active window is highlighted. Make a
window active by clicking it or by selecting it from the Windows
menu.
application software Application created using the LabVIEW Development System and
executed in the LabVIEW Run-Time System environment.
array shell Front panel object that houses an array. An array shell consists of an
index display, a data object window, and an optional label. It can accept
various data types.
B
black box testing Form of testing where a module is tested without knowing how the
module is implemented. The module is treated as if it were a black box
that you cannot look inside. Instead, you generate tests to verify the
module behaves the way it is supposed to according to the
requirements specification.
Boolean controls Front panel objects to manipulate and display Boolean (TRUE or
and indicators FALSE) data.
Bundle node Function that creates clusters from various types of elements.
C
Capability Maturity Model for judging the maturity of the processes of an organization and
Model (CMM) for identifying the key practices required to increase the maturity of
these processes. The Software CMM (SW-CMM) is a de facto
standard for assessing and improving software processes. Through the
SW-CMM, the Software Engineering Institute and software
development community have put in place an effective means for
modeling, defining, and measuring the maturity of the processes
software professionals use.
caption label Label on a front panel object used to name the object in the user
interface. You can translate this label to other languages without
affecting the block diagram source code. See also Name Label.
Case structure Conditional branching control structure, that executes one of its
subdiagrams based on the input to the Case structure. It is the
combination of the IF, THEN, ELSE, and CASE statements in control
flow languages.
checkbox Small square box in a dialog box you can select or clear. Checkboxes
generally are associated with multiple options that you can set. You
can select more than one checkbox.
cluster A set of ordered, unindexed data elements of any data type, including
numeric, Boolean, string, array, or cluster. The elements must be all
controls or all indicators.
cluster shell Front panel object that contains the elements of a cluster.
code and fix model Lifecycle model that involves developing code with little or no
planning and fixing problems as they arise.
Code Interface Node Special block diagram node through which you can link text-based
(CIN) code to a VI.
coercion dot Appears on a block diagram node to alert you that you have wired data
of two different numeric data types together. Also appears when you
wire any data type to a variant data type.
Color Copying tool Copies colors for pasting with the Coloring tool.
connector Part of the VI or function node that contains input and output
terminals. Data pass to and from the node through a connector.
connector pane Region in the upper right corner of a front panel or block diagram
window that displays the VI terminal pattern. It defines the inputs and
outputs you can wire to a VI.
Context Help window Window that displays basic information about LabVIEW objects when
you move the cursor over each object. Objects with context help
information include VIs, functions, constants, structures, palettes,
properties, methods, events, and dialog box components.
count terminal Terminal of a For Loop whose value determines the number of times
the For Loop executes its subdiagram.
current VI VI whose front panel, block diagram, or Icon Editor is the active
window.
D
D Delta; Difference. Δx denotes the value by which x changes from one
index to the next.
data acquisition DAQ. Process of acquiring data, typically from A/D or digital input
plug-in devices.
data flow Programming system that consists of executable nodes that execute
only when they receive all required input data and produce output
automatically when they execute. LabVIEW is a dataflow system.
data type Format for information. In LabVIEW, acceptable data types for most
VIs and functions are numeric, array, string, Boolean, path, refnum,
enumeration, waveform, and cluster.
data type descriptor Code that identifies data types; used in data storage and representation.
datalog file File that stores data as a sequence of records of a single, arbitrary data
type that you specify when you create the file. Although all the records
in a datalog file must be a single type, that type can be complex. For
example, you can specify that each record is a cluster that contains a
string, a number, and an array.
default Preset value. Many VI inputs use a default value if you do not specify
a value.
design patterns Techniques that have proved themselves useful for developing
software. Design patterns typically evolve through the efforts of many
developers and are fine-tuned for simplicity, maintainability, and
readability.
dialog box Window that appears when an application needs further information to
carry out a command.
E
empty array Array that has zero elements but has a defined data type. For example,
an array that has a numeric control in its data display window but has
no defined values for any element is an empty numeric array.
error structure Consists of a Boolean status indicator, a numeric code indicator, and a
string source indicator.
F
file refnum See refnum.
Flat Sequence structure Program control structure that executes its subdiagrams in numeric
order. Use this structure to force nodes that are not data dependent to
execute in the order you want. The Flat Sequence structure displays all
the frames simultaneously and executes the frames from left to right
until the last frame executes.
For Loop Iterative loop structure that executes its subdiagram a set number of
times. Equivalent to text-based code: For i = 0 to n – 1, do....
free label Label on the front panel or block diagram that does not belong to any
other object.
front panel Interactive user interface of a VI. Front panel appearance imitates
physical instruments, such as oscilloscopes and multimeters.
G
General Purpose GPIB—synonymous with HP-IB. The standard bus used for
Interface Bus controlling electronic instruments with a computer. Also called
IEEE 488 bus because it is defined by ANSI/IEEE Standards
488-1978, 488.1-1987, and 488.2-1992.
global variable Accesses and passes data among several VIs on a block diagram.
H
heuristic A recognized usability principle.
Hierarchy window Window that graphically displays the hierarchy of VIs and subVIs.
I
I/O Input/Output. The transfer of data to or from a computer system
involving communications channels, operator input devices, and/or
data acquisition and control interfaces.
Icon Editor Interface similar to that of a graphics program for creating VI icons.
indicator Front panel object that displays output, such as a graph or LED.
information hiding Preventing or limiting other components from accessing data items in
a module except through some predetermined method.
inplace The condition in which two or more terminals, such as error I/O
terminals or shift registers, use the same memory space.
integration testing Integration testing assures that individual components work together
correctly. Such testing may uncover, for example, a misunderstanding
of the interface between modules.
iteration terminal Terminal of a For Loop or While Loop that contains the current
number of completed iterations.
L
label Text object used to name or describe objects or regions on the front
panel or block diagram.
Labeling tool Tool to create labels and enter text into text windows.
lifecycle model Model for software development, including steps to follow from the
initial concept through the release, maintenance, and upgrading of the
software.
listbox Box within a dialog box that lists all available choices for a command.
For example, a list of filenames on a disk.
LLB VI Library.
local variable Variable that enables you to read or write to one of the controls or
indicators on the front panel of a VI.
M
memory buffer See buffer.
menu bar Horizontal bar that lists the names of the main menus of an application.
The menu bar appears below the title bar of a window. Each
application has a menu bar that is distinct for that application, although
some menus and commands are common to many applications.
N
Name Label Label of a front panel object used to name the object and as distinguish
it from other objects. The label also appears on the block diagram
terminal, local variables, and property nodes that are part of the object.
See also caption label.
numeric controls Front panel objects to manipulate and display numeric data.
and indicators
O
object Generic term for any item on the front panel or block diagram,
including controls, indicators, nodes, wires, and imported pictures.
P
palette Display of icons that represent possible options.
panel window VI window that contains the front panel, the toolbar, and the icon and
connector panes.
pull-down menus Menus accessed from a menu bar. Pull-down menu items are usually
general in nature.
R
race condition Occurs when two or more pieces of code that execute in parallel
change the value of the same shared resource, typically a global
or local variable.
representation Subtype of the numeric data type, of which there are 8-, 16-, and 32-bit
signed and unsigned integers, as well as single-, double-, and
extended-precision floating-point numbers.
ring control Special numeric control that associates 32-bit integers, starting at 0 and
increasing sequentially, with a series of text labels or graphics.
S
scalar Number that a point on a scale can represent. A single value as opposed
to an array. Scalar Booleans and clusters are explicitly singular
instances of their respective data types.
shared library A file containing executable program modules that any number of
different programs can use to perform some function. Shared libraries
are useful when you want to share the functionality of the VIs you
build with other developers.
shift register Optional mechanism in loop structures to pass the value of a variable
from one iteration of a loop to a subsequent iteration. Shift registers are
similar to static variables in text-based programming languages.
shortcut menu Menu accessed by right-clicking an object. Menu items pertain to that
object specifically.
software configuration Mechanism for controlling changes to source code, documents, and
management (SCM) other material that make up a product. During software development,
source code control is a form of configuration management. Changes
occur only through the source code control mechanism. It also is
common to implement release configuration management to ensure
you can rebuild a particular release of software, if necessary.
Configuration management implies archival development of tools,
source code, and so on.
Software Engineering Federally funded research and development center to study software
Institute (SEI) engineering technology. The SEI is located at Carnegie Mellon
University and is sponsored by the Defense Advanced Research
Projects Agency. Refer to the Software Engineering Institute Web site
at www.sei.cmu.edu for more information about the institute.
source lines of code Measure of the number of lines of code that make up a text-based
project. It is used in some organizations to measure the complexity
and cost of a project. How the lines are counted depends on the
organization. For example, some organizations do not count blank
lines and comment lines. Some count C lines, and some count only the
final assembly language lines.
spaghetti code Code that contains program constructs that do not form an easy to
understand, logical flow.
specifications document Document that lists the individual tasks that define the function of the
application that is produced by the customer.
spiral model Lifecycle model that emphasizes risk management through a series of
iterations in which risks are identified, evaluated, and resolved.
Stacked Sequence Program control structure that executes its subdiagrams in numeric
structure order. Use this structure to force nodes that are not data dependent to
execute in the order you want. The Stacked Sequence structure
displays each frame so you see only one frame at a time and executes
the frames in order until the last frame executes.
string controls and Front panel objects to manipulate and display text.
indicators
T
terminal Object or region on a node through which data pass.
tip strip Small yellow text banners that identify the terminal name and make it
easier to identify terminals for wiring.
top-level VI VI at the top of the VI hierarchy. This term distinguishes the VI from
its subVIs.
type definition Master copy of a custom object that several VIs can use.
U
unit testing Testing only a single component of a system in isolation from the rest
of the system. Unit testing occurs before the module is incorporated
into the rest of the system.
universal constant Uneditable block diagram object that emits a particular ASCII
character or standard numeric constant, for example, π.
user-defined constant Block diagram object that emits a value you set.
V
Variant Data type that includes the control or indicator name, information
about the data type from which you converted, and the data itself,
which allows LabVIEW to correctly convert the variant data type to
the data type you want.
VI library Special file that contains a collection of related VIs for a specific use.
virtual instrument (VI) Program in LabVIEW that models the appearance and function of a
physical instrument.
W
waterfall model Lifecycle model that consists of several non-overlapping stages,
beginning with the software concept and continuing through testing
and maintenance.
While Loop Loop structure that repeats a section of code until a condition is met.
white box testing Unlike black box testing, white box testing creates tests that take into
account the particular implementation of the module. For example, use
white box testing to verify all the paths of execution of the module have
been exercised.
wire branch Section of wire that contains all the wire segments from junction to
junction, terminal to junction, or terminal to terminal if there are no
junctions between.
wire stubs Truncated wires that appear next to unwired terminals when you move
the Wiring tool over a VI or function node.
A sizing, 6-26
about dialog box, 10-3 style considerations, 6-26
abstract components variant data, 6-10
data abstraction, 2-16 wiring techniques, 6-26
drawing boundary conditions, testing, 7-4
dataflow diagrams, 2-25 build specifications, 10-12
flowcharts, 2-23 building
procedural abstraction, 2-16 applications, 10-12
access options shared libraries, 10-12
setting in project libraries, 4-36 stand-alone applications, 10-12
adding
items to projects, 4-28 C
alpha testing, 7-49
captions, 3-12
application
certification (NI resources), vii, B-2
analyzing an, 2-1
checklist
build specifications, 10-12
code implementation, 6-58
building, 10-1
customer communication, 2-6
caveats and recommendations, 10-5
data structures, 4-52
designing an, 4-1
error handling strategy, 4-70
documenting, 9-1
error handling strategies, 4-67 front panel style, 3-18
evaluating performance, 8-1 hierarchical architecture, 4-27
hierarchical architecture, 4-25 performance issues, 8-25
implementing requirements document, 2-7
code, 6-1, 10-2 scalable architecture, 6-12
scalable architecture, 6-7 specifications content, 2-3
user interface, 5-1 test plan, 7-5
menu items, 3-5 testing strategy, 7-10
test plan, 7-1 user interface-based data, 5-6
user interface, 3-2 classic controls and indicators, 3-14
Application Builder, 10-12 clone, 8-21
applications clusters, 4-51
documentation, 9-3 error, 4-68
arrays, 4-51 removing borders, 3-20
auto-populating folders, 4-30 code
developing, 6-26
B documenting, 6-27
implementing, 6-1, 6-26, 10-2
beta testing, 7-49
about dialog box, 10-3
block diagram
checklist, 6-58
comments, 6-27
relative file path handling, 10-2
left-to-right layouts, 6-27
O
M
objects
maintainable captions on front panel, 3-12
modules, 6-53 overlapping on front panel, 3-7
VIs, creating, 1-3 organizing
master/slave design pattern, 4-8 project libraries, 4-38
notifiers, 4-9 organizing documentation, 9-2
memory overlapping front panel objects, 3-7
allocation, 8-14
allocation (example), 8-14
developing for, 6-58 P
reallocation buffers, 8-14 palettes, 3-14
variant data, 6-10 parallel loop design pattern, 4-7
menus password protection
custom, 3-4 setting for project libraries, 4-37
handling selections, 3-5 paths
ring controls, 5-2 See also relative file path handling
run-time, 3-4 front panels, 3-12
run-time shortcut, 3-6 Perforce
static menus, 3-4 using with LabVIEW source control, 6-4
Microsoft Team System performance
using with LabVIEW source control, 6-4 checklist, 8-25
Microsoft Visual SourceSafe coercion and memory, 8-18
using with LabVIEW source control, 6-4 developing for, 6-58
viewing W
dependencies in projects, 4-31 waterfall model, 1-5
virtual folders, 4-30 modified, 1-7
VIs Web resources, B-1
describing, 9-5 wiring techniques, 6-26
hierarchical organization, 6-34
linking to help files, 9-5
maintainable, 6-53
Z
naming, 6-34 zip files, 10-12
scalable, 6-53
Visual SourceSafe
using with LabVIEW source control, 6-4
Instructor
Please evaluate the instructor by checking the appropriate circle. Unsatisfactory Poor Satisfactory Good Excellent
Instructor’s ability to communicate course concepts ❍ ❍ ❍ ❍ ❍
Instructor’s knowledge of the subject matter ❍ ❍ ❍ ❍ ❍
Instructor’s presentation skills ❍ ❍ ❍ ❍ ❍
Instructor’s sensitivity to class needs ❍ ❍ ❍ ❍ ❍
Instructor’s preparation for the class ❍ ❍ ❍ ❍ ❍
Course
Training facility quality ❍ ❍ ❍ ❍ ❍
Training equipment quality ❍ ❍ ❍ ❍ ❍
Was the hardware set up correctly? ❍ Yes ❍ No
The course length was ❍ Too long ❍ Just right ❍ Too short
The detail of topics covered in the course was ❍ Too much ❍ Just right ❍ Not enough
The course material was clear and easy to follow. ❍ Yes ❍ No ❍ Sometimes
Did the course cover material as advertised? ❍ Yes ❍ No
I had the skills or knowledge I needed to attend this course. ❍ Yes ❍ No If no, how could you have been
better prepared for the course? ____________________________________________________________________
_____________________________________________________________________________________________
What were the strong points of the course? __________________________________________________________
_____________________________________________________________________________________________
What topics would you add to the course? ___________________________________________________________
_____________________________________________________________________________________________
What part(s) of the course need to be condensed or removed? ____________________________________________
_____________________________________________________________________________________________
What needs to be added to the course to make it better? ________________________________________________
_____________________________________________________________________________________________
How did you benefit from taking this course? ________________________________________________________
_____________________________________________________________________________________________
Are there others at your company who have training needs? Please list. ____________________________________
_____________________________________________________________________________________________
_____________________________________________________________________________________________
Do you have other training needs that we could assist you with? _________________________________________
_____________________________________________________________________________________________
How did you hear about this course? ❍ NI Web site ❍ NI Sales Representative ❍ Mailing ❍ Co-worker
❍ Other _____________________________________________________________________________________