Professional Documents
Culture Documents
Input Output Files Format
Input Output Files Format
• Binary files are machine readable only, unlike text files, which
are human readable.
• They are the most compact and fastest format for storing data.
• Binary files are more efficient because they use less disk space
and because you do not need to convert data to and from a text
representation when you store and retrieve data.
• You can then wire the number of items to the count terminal of the
Read Binary function.
• Each read operation updates the position within the file so that you
read a new item each time the read function is called.
• When using this technique to access data you can check for the End
of File error after calling Read Binary or calculate the number of
reads necessary to reach the end of the file by using Get File Size.
Sequential Access
Random Access
• To randomly access a binary file, use the Set Position
VI to set the read offset to the point in the file you
want to begin reading.
• Notice that the offset is in bytes. Therefore, you must
calculate the offset based upon the layout of the file.
In the following example, the VI returns the array
item with the index specified, assuming that the file
was written as a binary array of double precision
numerics with no header.
Random Access
Datalog Files
• A specific type of binary file, a datalog file is the
easiest method for logging cluster data to file.
• Datalog files store arrays of clusters in a binary
representation.
• Datalog files provide efficient storage and random
access, however, the storage format for datalog files
is complex, and therefore they are difficult to access
in any environment except LabVIEW.
• In order to access the contents of a datalog file, you
must know the contents of the cluster type stored in
the file.
Datalog Files
• Datalog files store a list of records to a file.
• Each record is represented by a cluster, and can contain
multiple pieces of data of any data type. Datalog VIs allow
you to read and write arrays of clusters to and from datalog
files.
• When you open a datalog file, you must specify the record
type used by the file.
• To do this, wire a cluster of the appropriate type to the
Open/Create/Replace Datalog function.
• After the file is open, you program datalog files like any other
binary file.
• Random access is available, although offsets are specified in
records instead of bytes.
Datalog Files
Datalog Files
• The following figure depicts an example of
randomly accessing a datalog file by setting
the read position with the Set Datalog Position
function.
• However, these Express VIs give you little control over your
data grouping and properties and do not allow you to use the
features that make TDM files useful, such as searching for
data based upon conditions.
Using the Data Storage API VIs
• To gain access to the full capabilities of TDM files,
use the Data Storage API.
• The Read From Measurement File function reads data from the logfile. (By
double-clicking the function a dialog window is opened. The parameters in this
window should be self-explanatory.
• The data that are read from the file are converted to a ordnary 2-dimensional array
containing the three columns of data, cf. the logfile1.lvm shown above. The
conversion is made by the Convert from Dynamic Data function which is on the
Express / Signal Manipulation palette. Note that you can configure the Convert
from Dynamic Data function (i.e. selecting the correct data type) by double-
clicking it.
• The three Index Array functions are used to extract each of the columns from the
data and create 1 dimensional arrays, labeled Array t (1D), Array u (1D) and Array
y (1D).
• The Block diagram also contains code for displaying the array in an array indicator
and to display the size of the array on the Front panel.