cbLogReadAIChannels()

Reads analog input data from a binary file, and stores the values in an array.

Function Prototype

C/C++

int cbLogReadAIChannels(char* Filename, int StartSample, int Count, float* AIChannels)

Visual Basic

Function cbLogReadAIChannels(ByVal Filename$, ByVal StartSample&, ByVal SampleCount&, ByRef AIChannelData!) As Long

Arguments

FileName

The name of the file to retrieve the information from.

StartSample

The first sample to read from the binary file.

Count

The number of samples to read from the binary file.

AIChannels

Receives the analog input values.

Returns

Notes

Analog array

The user is responsible for allocating the size of the analog array, and ensuring that it is large enough to hold the data that will be returned. You can calculate the array allocation using the sampleCount value from cbLogGetSampleInfo(), and the aiCount value from cbLogGetAIChannelCount():

float* AIChannels = new float[sampleCount * AICount];

The figure below shows the layout of the analog array, and how the elements should be indexed.

analog array

where n is (AICount – 1).

CH0 – CHn refer to the channels in the array, not the input channels of the device.

For example, assume that all of the even number input channels are logged. The analog array channels are mapped as shown here:

Array ChannelDevice Input Channel
00
12
24
36

Use the following code fragment to access the elements of the analog array:

for (i=0; i<numberOfSamples; i++)

{

for (j=0; j<numberOfAIChannels; j++)

{

a = analogArray[(i * numberOfAIChannels) + j];

}

}

where

the numberOfSamples is set by the SampleCount value from cbLogGetSampleInfo().

the numberOfAIChannels is set by the AICount value from cbLogGetAIChannelCount().