160 likes | 235 Views
Electronics II Physics 3620 / 6620. Apr 29, 2009 Part 1 Projects, Formula Nodes, Error Handling Application Builder…etc. Project Explorer.
E N D
Electronics IIPhysics 3620 / 6620 Apr 29, 2009 Part 1 Projects, Formula Nodes, Error Handling Application Builder…etc.
Project Explorer • Instead of editing VI’s and sub-VI’s separately and managing them by hand (one drawback is platform-independence), you can package VI’s and sub-VI’s into “projects” • New feature in Labview 8.0 • Project explorer similar to other “integrated development environment” • Start new “project” from start menu Empty Project
Make Simple Project • A “project explorer” window pops up (in the picture shown I have already saved the project as “exa01.lvproj” • Either File Save • Or Project Save Project • Project root—Contains all other items in the Project Explorer window. This label on the project root includes the filename for the project. My Computer—Represents the local computer as a target in the project. • Dependencies—Includes items that VIs under a target require. • Build Specifications—Includes build configurations for source distributions and other types of builds available in LabVIEW toolkits and modules. If you have the LabVIEW Professional Development System or Application Builder installed, you can use Build Specifications to configure stand-alone applications (EXEs), shared libraries (DLLs) , installers, and zip files.
Project Explorer • A “project explorer” window pops up (in the picture shown I have already saved the project as “exa01.lvproj” • Either File Save • Or Project Save Project • To add a “new” VI to the project: • Project Add To Project New VI • This will pop up a front-panel + block diagram pair • If you make a sub-VI remember to link the controls and indicators to the connector panel
Example • subVI that converts Farenheit input temperature to Celsius and Kelvin outputs • We demonstrate the use of a formula node in this case • Note that formula nodes can also have conditionals • Your cannot declare then input the variable • You can but don’t need to declare the output variables
Error Handling • Can add “if (…) { } else { } structure in formula node • Can also use this feature to detect error condition • Use Error Cluster from Error Code.vi • Functions Programming Dialog & User Interface - Error Cluster from Error Code.vi (also see others) • Put both err-in and err-out onto the connector panel
Make “Main VI” • Add main VI that checks for error condition (Farenheit temp below absolute zero…using the “simple error handler” • Stops the program if error condition met • Save and close both
Project File • We now open exa01.lvproj with “Wordpad” (or “Notepad”) • It is an Extensible Markup Language (XML) file • See http://en.wikipedia.org/wiki/XML for a description • Can be edited by hand in an emergency • This is the “GUI” equivalent of the old UNIX “Make” file
Adding Build Specification • We can specify a stand-alone application to be built Notice the five different options
Application Information • Application Information Window pops up: modify/fill in the top three at least
Source Files • Click on “Source Files in the window on left, • Put the startup VI and supporting objects into the containers • Click OK and then DON’T forget to save the Project.
Building the Application • From the project file, a “Test01” target should appear under the Build specifications • Right Click on “Test01” Build will cause Test01.exe to be built • This file can now be run as a stand-alone application • According to NI, neither the base nor the student version of Labview has the standalone applications builder (but projects are supported). Only the Professional Development Version has this built-in.
Other Build Options • Installers Provider -- installs applications, source files, and shared libraries created with the Application Builder. The providers offers new features, such as Media Spanning to span the installer file over multiple disks, setting System Requirements, creating custom Registry Keys, creating shortcuts to files in the installation, specifying file attributes, including End-User license agreements and a Readme File. • Shared Library (DLL) Provider -- creates a Dynamic Linked Library (DLL) allowing LabVIEW code to be called from text-based programming languages. Developers must define the function prototypes for each of the exported VIs. • Source Distribution Provider -- allows the user to organize source files for distribution to another machine. It creates a copy of the project files (including the dependencies) for easy distribution to another computer. This feature is similar to “Save with Options” from previous versions of LabVIEW. • Zip File Provider -- creates a compressed Zip file, containing the selected sources files. It allows you to distribute a large amount of code as a single, portable file.
NI Recommendations and CAVEATS • Create a separate directory of files for each project you create. Include the project file (.lvproj) and any other files that are only used in the project in the same directory. Place any files that are shared with other projects outside of the project directory. Organizing project files into separate directories makes it easier to identify files related to specific projects on disk. • Directories on disk are not required to match the project structure of folders. After you add a directory on disk to a project, LabVIEW does not automatically update the folder in the project if you make changes to the directory on disk. • Try to avoid changing the location on disk of files in a project. If you move a file on disk, you must update the location of the file in the project. • Windows: If you are building an installer, make sure you save the files that are in a project on the same drive as the .lvproj file. If some files are on a different drive, such as a network drive, links can break if you include the project in an installer. • The structure of files in a source distribution does not have to match the structure in the Project Explorer window. You can specify a different structure when you build source distribution. • If you plan to edit files that appear under Dependencies, move the files from Dependencies to under the target. Items that a VI calls dynamically do not appear under Dependencies. If you plan to distribute files, add any items that a VI calls dynamically under a target. When you build an application, you can apply settings to an entire folder, so consider grouping all dynamic items in a folder under the target.
Building a ZIP file for distribution • To build a zip file for distribution, right click build-spec. New ZIP file • Window pops up…you should set the title and the path • Here I put the .zip file in the same folder as the exa01 filder containing the project itself
Building a ZIP file (continued) • Do nothing with “source” files… • Go to “Preview”, click on “Generate Preview” button • You now see a preview of the directory/folder tree that will be generateed • Click OK to exit, and a zip file icon will appear • Right-Click the zip file entry and select build…this will create the zip file • This zip file will be posted along with this representation