Using Source Code Control with LabVIEW and Perforce
Overview
Using a source code control (SCC) system on a software project is very beneficial. You can use an SCC system to share files among multiple developers, improve security and quality, and track changes to shared projects.
LabVIEW can interface with several SCC systems, including Microsoft Visual Source Safe and Perforce. Perforce is a great choice for use with LabVIEW, as it shares multi-operating system support and other key characteristics. This tutorial explains the setup and use of Perforce in LabVIEW 7.x on a Windows XP computer. For help with setting up SCC in LabVIEW 8.0 and later, see the last section titled "LabVIEW 8.x and SCC".
Table of Contents
Downloading and Installing Perforce
The first step is to download the evaluation software from the Perforce Web site. There are documents on their site called The Ten Minute Demo, which take you through the basic installation process for the software: When installing, remember the following items:
- Select Administrator - Typical as the installation type.
- The evaluation copy is limited to two users and two client workspaces. If you want to have more, you must purchase a license. However, all the features are available for use in the evaluation copy.
See Also:
Perforce
Configuring Perforce
Note: The following information in this section is from The Ten Minute Demo - Windows1
Setting up a Client Workspace
To work with files in Perforce, you need to create a client workspace.
- Create a folder called C:\p4client
- Put some test files and folders in C:\p4client
- Start up P4Win from the Windows Start menu by selecting Programs»Perforce»P4Win.
- Click OK in the pop-up that tells you you need a client workspace.
- Pull down ClientSpec»Edit from the menu bar to bring up the Perforce Client Specification dialog box.
- Enter C:\p4client in the Root field.
- Click Update. If you get a warning dialog saying "You have changed the root for this client...", click OK to proceed.
Perforce Basics
To Add Files to the Perforce Depot
- In P4Win, click the View Pending Changelists button to display the Pending Changelists pane.
- Open the Windows Explorer and drag the C:\p4client folder to P4Win's Pending Changelists pane.
- Select the Open files for add only radio button, and then click OK in the dialog box that comes up.
- In the Pending Changelists pane, double-click on Pending Changelists to show your pending changelists.
- Right-click on Default and select Submit.
- In the dialog box that appears, replace <enter description here> with text of your own.
- Click Submit. The files you added are now under Perforce's control. You'll find them under the icon in the Client View of Perforce Depot pane.
To Edit Files
- Click + to expand the icon, then select the files you want to change.
- Right-click and select Open for Edit.
- Right-click and select Edit using the editor of your choice.
To Delete Files
- Click + to expand the icon and select files.
- Right-click and select Open for Delete.
To Submit These Changes to the Depot
- In the Pending Changelists pane, right-click on Default and select Submit.
- In the dialog box that appears, replace <enter description here> with text of your own.
- Click Submit.
Configuring and Using LabVIEW SCC
Configuring LabVIEW with Perforce
Refer to the LabVIEW Help for step-by-step instructions for configuring Perforce in LabVIEW. Access the LabVIEW Help by selecting Help»VI, Function, & How-To Help.
When a dialog box appears to suggest that you enable the Treat read-only VIs as locked option, click the Change Option button.
After you configure LabVIEW with Perforce as the SCC provider, you can add, check out, and delete files from source code control in LabVIEW.
Adding a VI to Source Code Control
- Open a VI or create a new VI.
- Select File»Save As and save the VI in your Perforce directory, such as C:\P4Client.
- Select Tools»Source Code Control»Add to SCC. If you saved the VI in the Perforce directory, LabVIEW adds it to source code control. Otherwise, an error message appears.
- Click the Submit button to submit the changes to Perforce or click the Cancel button if you want to submit the changes later. If you click the Submit button, LabVIEW adds the VI to SCC, and if you click the Cancel button, LabVIEW adds the VI to the pending changelist in Perforce.
- If you clicked the Submit button, add a description in the Perforce Change Specification window that appears and click the Submit button.
Checking VIs Out from Source Code Control
- In LabVIEW, open the VI you want to check out and edit. The VI opens, but you cannot edit it.
- Select Tools»Source Code Control»Open For Edit.
- After you are done editing the VI, select Tools»Source Code Control»Submit.
- In the Perforce Change Specification window that appears, enter a description of the changes and click the Submit button.
Deleting Files from Source Code Control
- In LabVIEW, open the VI you want to remove from source code control.
- Select Tools»Source Code Control»Open for Delete.
- When a message appears about the deletion, click the OK button to proceed.
Note: LabVIEW removes the local copy of the VI from the computer.
Reverting to a Previous Version of a VI
- Open Perforce for Windows.
- Navigate to the source file you want to revert in the Depot view.
- Right-click the file and select Revision History.
- In the list of revisions for the file, select the version to which you want to revert.
- Click the Sync button.
- In the Pending Changelists pane, right-click the file and select Edit With»Associated Editor.
Note: You can sync to the head revision of a VI by selecting Tools»Source Code Control»Sync to Head Revision.
Additional SCM Tools In LabVIEW
Along with source code control, LabVIEW has two other features that are useful for implementing a software configuration management plan. You can use the revision history settings in LabVIEW to track and document all changes that happen to a particular source file, and you can use the graphical differencing functionality to display differences in files. You can use these features to easily document a project as it develops, thus saving a lot of time during auditing, billing, and delivery.
Revision History
LabVIEW has global settings that can add information to a revision history inside the VI itself. Select Tools»Options to display the Options dialog box and select Revision History from the top pull-down menu to access these options. These options apply to all VIs that you open or create, with the exception of the login options, which require you to restart LabVIEW. If you want to apply any of these options to your project, configure the setting before the project starts and all VIs have the setting(s). You also can override the top four settings for each VI by selecting File»VI Properties and selecting Revision History from the Category pull-down menu.
To display the revision history of a VI, select Tools»VI Revision History. You can add as many comments for each revision as you want. LabVIEW adds the revision number, time and date, and the user before each comment. You also can extract this information from the VI programmatically, making the process of getting revision information easy for audits and code reviews.
Graphical Differencing
Most SCC systems allow you to compare different versions of a text file to see what changes have been made. This is commonly called a diff. LabVIEW's differencing is a similar concept, but instead of the character changes in a file, it displays the graphical differences in VIs. You can select Tools»Compare VI to compare two VIs for changes on both the front panel and block diagram. These changes can range from minor cosmetic changes, such as moving a control or a wire, to new functionality and VI attributes.
You can compare the current VI with the last revision in SCC by selecting Tools»Source Code Control»Compare VI.
Recommendations
If you follow two additional guidelines along with a software configuration management plan, you will develop the project faster, it will have fewer errors, and it will be more profitable.
Hierarchical Design of a VI Application
National Instruments recommends using a hierarchical design for all your VI projects. This normally consists of the top-level VI in a directory with all its subVIs in their own subdirectories. This is the beginning of a tree type structure for the application. You probably also have a folder or folders of subVIs that you share among the applications.

Figure 1. Hierarchical Design
This kind of organization makes for easier application modularity and component merging, parallel development, and source code control organization.
LabVIEW Development Guidelines
Use the LabVIEW Development Guidelines manual (linked below) to learn how to build VIs that are easy to understand, use, and revise. This manual describes project tracking, design, and documentation techniques. This manual also contains recommended style guidelines.
In LabVIEW 8.0 and later, you can acces the most recent development guidelines in the LabVIEW Help (linked below) by selecting Fundamentals»Development Guidelines. In LabVIEW 7.0 and 7.1, you can access the manual in the LabVIEW Help by selecting Help»Search the LabVIEW Bookshelf.
LabVIEW 8.x and SCC
The methodology of using SCC in LabVIEW has changed from 7.x to 8.x. The primary differences are SCC is no longer built into LabVIEW (requires third party software such as Perforce) and now revolves around the project. Common tasks such as adding files, checking in files, and checking out files are preformed using the project. See the topics linked below for a description of how to use SCC in LabVIEW 8.x.
Using Source Control in LabVIEW
Configuring LabVIEW to Use Source Control
Adding Files to Source Control
Checking out Files from Source Control
Checking in Files to Source Control
Getting the Latest Version of Files in Source Control
Perforce Project Options Dialog Box
Source Control Operations Dialog Box
Related Links
Product Manuals: LabVIEW 7.0, 7.1 Development Guidelines (starting on pg 2-2)
References
1. Perforce Downloads. (n.d.). Retrieved Jan., 2004, from http://www.perforce.com/perforce/demo/nt.html
Reader Comments | Submit a comment »
This document is out of date as of
LabVIEW 8.0.
- Aug 22, 2007
There is no information about how to set up
LabVIEw with MS VIsual Source Safe.
- Pawel Pocwiardowski, Reson A/S. pap@reson.dk - Aug 1, 2005
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
