Jump to content

Virtual Instrument

From LabVIEW Wiki

The VI, or Virtual Instrument, is the basic building block of programs written in the G Language. It is similar to a function or subroutine in other programming languages. It includes the Front Panel (containing Controls and Indicators), the Block Diagram (containing Control Terminals, Wires, and Structures and various other GObject nodes), the VI's Icon and its Connector Pane (as well as compiled executable code which is hidden behind the scenes).

The term Virtual Instrument is a play off of the fact that LabVIEW applications are designed for writing software that simulates the functionality of instruments -- rather than being a physical instrument on a laboratory bench, they are virtual and exist in software.

Content of a VI file

By default, a VI contains two kinds of code: the graphical source code that you edit and a compiled version of this code that LabVIEW uses to run the VI.

The graphical source code includes the:

The compiled version includes the:

When you edit the source code of the VI, LabVIEW automatically recompiles the VI to reflect your changes in the compiled version of the code. LabVIEW also automatically recompiles all VIs that call the changed VI, resulting in unsaved changes to the calling VIs. If the calling VIs are stored in source code control, these pending unsaved changes force you to check out the VIs when you update their subVIs.

To avoid this problem, Starting in LabVIEW 2010, LabVIEW allows you to separate compiled code from the graphical source code of a VI, thereby creating source-only VIs. After you separate the compiled code from a VI, LabVIEW still compiles the VI when you modify subVIs. However, LabVIEW stores the recompiled version of the code in a compiled object cache rather than in the VI in source code control. Because the VI in source code control does not change, you no longer have to check the VI out of source control when you change subVIs.

The VI File Format

VIs are saved as *.vi files, in a proprietary binary format defined by National Instruments, the makers of LabVIEW. The format is strongly inspired by Mac OS Resource Fork format, as LabVIEW was originally created for that platform, and ported to other OSes later, at version 2.5.

The format is a container, storing a group or Resources. Resources have 4-character identifier assigned, and the 4-character identifier for the whole container is RSRC. Actually, most files used by LabVIEW have that RSRC format, only the specific Resources stored inside are different. The files with that header include *.vi, *.ctl, *.mnu, *.llb, *.dlog, *.ctt, *.vit, *.xctl, *.uir, and many other files created with, or internally used by, LabVIEW.

The resources stored within have their identifiers often identical to those in Resource fork format, but many new ones are also introduced. Some resources have multiple variations, as their structure changed between versions of LabVIEW.

A big change in VI format happened in LV version 8.0 - the place where Type descriptors are defined was changed. Before, TDs were defined in-place where they were needed; with 8.0, a new resource VCTP (VI Consolidated Types) was introduced, and all TDs were moved there. Outside VCTP, TDs are now identified by TypeID - index within the consolidated types table.

Known Resources

Below a few resources are listed. Note that the text names given for them are mostly informed guesses.

Resource ID Long Name Description
MUID Map Unique Identifier
FPSE Front Panel Size Estimate
FPTD Front Panel Type for DataLog
BDSE Block Diagram Size Estimate
FLAG Integer flags
CONP Connector Port Type Map
CPTM Connector Port Type Map
CPC2 Connector Port Content Type v2
CPCT Connector Port Content Type
CPD2 Connector Port DI v2
CPDI Connector Port DI
DLGH Dialog HTML
ERRH Error HTML
HLPT Help Tag
MItm M. Item
NODH NOD HTML
NOEG NOEG String
STRG String description
TITL Title of the file
STR Short String / Input definition?
CPST C. P. Strings
DNm# D. Name Strings List
HDb# Help Database item
LST# Short Strings List
STR# Short Strings List
FDFL FDFL Strings
LIfp LinkObj Refs for Front Panel
LIbd LinkObj Refs for Block diagram
LIds LinkObj Refs for Data Space
LIvi LinkObj Refs for VI
DFDS Default Fill of Data Space
GCDI
BFAL
CGRS Conglomerate Resource
CPMp Connection Points Map
DLDR DL Data Record
DLLP DL Local Path
FTAB Font Table
HIST Changes History
HLPP Help Path
LPTH L. Path
HLPW Help Website URL
SCSR Syntax Checker Digest
DTHP Data Types for Heap
DSTM Data Space Type Map
TM80 Data Space Type Map LV8.0+
LVIN LabView Instrument
LVSR LabView Save Record
vers Version block
PNGI PNG Image Stores a bitmap picture in PNG format.
MNGI MNG Image While PNGs become quite popular, their animated counterpart, MNG format, never really caught on.
ICON Icon 32x32 1bpp
ICN# Icon Large Double 32x64 1bpp Usually used to store one icon in two versions (ie. disabled and active).
ics# Icon Small 16x16 1bpp
CURS Cursor 16x34 1bpp Usually used to store one cursor in two versions (ie. disabled and active).
ics4 Icon Small 16x16 4bpp
icl4 Icon Large 32x32 4bpp
ics8 Icon Small 16x16 8bpp
icl8 Icon Large 32x32 8bpp
BDPW Block Diagram Password
LIBN Library Names
LVzp LabView Zipped Program tree A whole application compressed to ZIP file.
PRT Print settings
BNID B. N. Identifier
CNST Constant Node UID set
LPIN Loop Invariant Node UID set
NUID N. U. Identifier
SUID S. U. Identifier
VPDP VI Primitive Dependency Flags
BDHP Block Diagram Heap
FPHP Front Panel Heap
BDHb Block Diagram Heap ver b
FPHb Front Panel Heap ver b
BDHc Block Diagram Heap ver c
FPHc Front Panel Heap ver c
RTSG Runtime Signature Guid
GCPR Generated Code Profiler settings
UCRF Uncompressed Resource File Used when files are added to RSRC, ie. within *.llb files.
CPRF 'Comp' Compressed Resource File Used when files are added to RSRC; very basic mask based compression.
ZCRF ZLib Compressed Resource File Used when files are added to RSRC; uses compression algorithm from popular Z-Lib library.
DLG3 Dialog Resource File
VCTP VI Consolidated Data Types Introduced in LV 8.0, stores all Type descriptors used within the file.
VICD Virtual Instrument Compiled Data / VI Code Contains the machine code generated by LLVM compiler.
VITS Virtual Instrument Tag Strings

See Also