Engee documentation

Binary File Reader

Page in progress.

Reading data from binary files.

blockType: Binary File Reader

Path in the library:

/Signal Operations/Sources/Binary File Reader

Description

The Binary File Reader block reads multichannel signal data from a binary file. The block reads the header that precedes the data. The File header parameters specify the structure of the header. You can set the type, size, and complexity of the data using the block parameters.

When reading a file for the first time, the block reads the header and then the data. On subsequent calls, the block reads the remaining data. When the end of the file is reached, the block returns zeros of the specified data type, size, and complexity. The block can read data either from the file written by the block Binary File Writer, or from any other binary file.

Ports

Output

# data — binary data
scalar | vector | matrix

Details

The block reads data from the binary file specified in the parameters File name. The output data has the dimension Samples per frame to Number of channels. The block can read floating point and integer data. The input data can be real or complex. If the data is complex, the block reads it as alternating real and imaginary components. The read block assumes the standard by default byte order set on the host machine.

This port has no name as long as Output end-of-file indicator. is unchecked.

Data types

Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64

Complex numbers support

Yes

# EOF — end of file indicator
0 | 1

Details

When the block reaches the end of the file, the port outputs 1. Otherwise, the port outputs 0.

Dependencies

To use this port, select the check box Output end-of-file indicator.

Data types

Bool.

Complex numbers support

Yes

Parameters

Main

# File name — file name

Details

The name of the file from which the block reads data. If the file is not in the current directory, specify the full path to it.

Default value

Untitled.bin

Program usage name

Filename

Tunable

No

Evaluatable

Yes

# File header — file header

Details

If the file does not contain a header, the field should contain empty brackets (). If some header is used, then a named tuple should be entered in the field (field1 = value, …​, fieldN = valueN), values can be strings, numbers, one-dimensional vectors of numbers and two-dimensional matrices of numbers.

Default value

()

Program usage name

HeaderStructure

Tunable

No

Evaluatable

Yes

# Storage data type — file data type
Float64 | Float32 | Int8 | Int16 | Int32 | Int64 | UInt8 | UInt16 | UInt32 | UInt64

Details

The type of data stored in the file. This parameter defines the type of output data on the data port.

Values

Float64 | Float32 | Int8 | Int16 | Int32 | Int64 | UInt8 | UInt16 | UInt32 | UInt64

Default value

Float64

Program usage name

DataType

Tunable

No

Evaluatable

No

# Samples per frame — number of samples in the output signal
Integer

Details

Defines the number of rows of the output matrix. The output matrix has the dimensions Samples per frame by Number of channels. When the end of the file is reached, if the output matrix is not filled, the block fills the matrix with zeros, turning it into a full-size matrix.

Default value

1024

Program usage name

SamplesPerFrame

Tunable

No

Evaluatable

Yes

# Data is complex — data comprehensiveness
Logical

Details

If this checkbox is selected, the read block treats the data from the file as complex. The block reads the data as alternating real and imaginary components and outputs complex values.

For example, if the block is configured to read complex data as a 2 by 2 matrix, the data [1 5 2 6 3 7 4 8] will be read as [1 2; 3 4]+1j*[5 6; 7 8]. If the block is configured to read real data, the block reads it as [1 5; 2 6].

Default value

false (switched off)

Program usage name

isDataComplex

Tunable

No

Evaluatable

No

# Number of channels — number of channels in the output signal
Integer

Details

Specifies the number of columns of the output matrix. This parameter determines the number of consecutive interleaved data samples stored in the file for each point in time. The output matrix has the dimensions Samples per frame by Number of channels. When the end of the file is reached, if the output matrix is not filled, the block fills the matrix with zeros, turning it into a full-size matrix.

Default value

1

Program usage name

NumChannels

Tunable

No

Evaluatable

Yes

# Output end-of-file indicator — end-of-file indicator
Logical

Details

If checked, the block has an additional output port EOF. When the block reaches the end of the file, the port outputs 1. Otherwise, the port outputs 0.

Default value

false (switched off)

Program usage name

OutputEOF

Tunable

No

Evaluatable

No

# SampleTime (s) — sampling period
SampleTime (real number / vector of two real numbers)

Details

Controls the sampling period on the output port of the block. This value is , where is the sampling frequency of the signal data. The sampling period on the output port is equal to the product of the parameters Samples per frame and SampleTime (s).

Default value

1

Program usage name

SampleTime

Tunable

No

Evaluatable

Yes

# Indexing mode — indexing order for reading matrices
Row-major | Column-major

Details

Select how the block will read the data:

  • Row-major - the data is read taking into account that the matrix has been written row by row;

  • Column-major - data reading is performed taking into account that the matrix was written by columns.

Values

Row-major | Column-major

Default value

Row-major

Program usage name

IndexingMode

Tunable

No

Evaluatable

No