Jump to content

Virtual Instrument: Difference between revisions

From LabVIEW Wiki
m Category reorg
file format chapter to really discuss the format
Line 3: Line 3:
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.
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.


==The VI File Format==
==Content of a VI file==
VIs are saved as ''*.vi'' files in a proprietary binary format defined by [[National Instruments]], the makers of [[LabVIEW]]. 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.
 
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 graphical source code includes the:
*[[Front Panel]]
*[[Front Panel]]
*[[Block Diagram]]
*[[Block Diagram]]
*[[Data Space]]
*[[Connector Pane]]
*[[Connector Pane]]
*[[VI_Icons|Icon]]
*[[VI_Icons|Icon]]
Line 19: Line 21:


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|compiled object cache]] rather than in the VI in [[Source Code Control|source code control]]. Because the VI in [[Source Code Control|source code control]] does not change, you no longer have to check the VI out of source control when you change 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|compiled object cache]] rather than in the VI in [[Source Code Control|source code control]]. Because the VI in [[Source Code Control|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 [https://en.wikipedia.org/wiki/Resource_fork 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'', ''*.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 introduces. 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, '''TD'''s were defined in-place where they were needed; with 8.0, a new resource ''VCTP'' (''VI Consolidated Types'') was introduced, and all '''TD'''s were moved there. Outside ''VCTP'', '''TD'''s are now identified by ''TypeID'' - index within the consolidated types table.


==See Also==
==See Also==

Revision as of 09:42, 31 May 2020

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, *.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 introduces. 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.

See Also