How to Read CI Data Files in C#

Introduction
The CI Data File Reader consists of two DLL files that can be integrated with custom software to directly read and extract data from an CI Measurement Data file. This post will show simple C# code examples in opening and reading a CI Measurement Data file.

For more detailed information on how to implement the following code sections and properties in a class, please refer to the CI Data File Reader manual and the provided C# Demo code. The package can be downloaded from our Programming Corner.

Importing C# DLL Files
To import the C# DLL files, the 2 DLL files must be referenced in the project and the following namespaces used to reference the various classes and properties in the CI Data File Reader.

 
using EDM.RecordingInterface;
using EDM.Recording;
using ASAM.ODS.NVH;
using Common;
using Common.Spider;
using EDM.Utils;
using ASAM.ODS.ATFXML;
 

Opening a CI Measurement Data File
To open a CI Measurement Data file, use the RecordingManager class to call OpenRecording, which takes in a filename and outputs a IRecording object that contains the recording properties and a list of signals.

 
using EDM.RecordingInterface;
using EDM.Recording;

var recordingPath = "C:\Sig001.atfx";
// Open the ATFX file and get a IRecording object
RecordingManager.Manager.OpenRecording(recordingPath, out IRecording rec);
 

Extracting Recording Properties
With the IRecording created from the CI Measurement Data file extraction, it can be used to access the recording properties by calling IRecording.RecordingProperty.

 
RecordingManager.Manager.OpenRecording(recordingPath, out IRecording rec);

RecordingProperty recordingProperties = rec.RecordingProperty;

// A couple of properties in IRecording.RecordingProperty
DateTime createTime = recordingProperties.CreateTime;
string instrument = recordingProperties.Instruments;
MeasurementConfigType measurementType = recordingProperties.MeasurementType;
string name = recordingProperties.RecordingName;
 

The following screenshot displays an example of the displayed recording properties:

Extracting Signal Data
The IRecording can also be used to access the list of signals, which are a type ISignal that contains their own properties and data values, via IRecording.Signals that returns a List<ISignal>.

 
RecordingManager.Manager.OpenRecording(recordingPath, out IRecording rec);

// Get the list of signals from the recording
List<ISignal> signals = rec.Signals;

// To get the Channel 4 signal, select the signal whose name is ‘Block(CH4)’
ISignal signalCh4 = signals.Where(sig => sig.Name == 'Block(CH4)').First();

// Get the frame, which is formatted like [[x1, x2, x3…], [y1, y2, y3…],…]
double[][] frame = signalCh4.GetFrame(0);
double[] xValues = frame[0];
double[] yValues = frame[1];

// If applicable
double[] zValues = frame[2];

// Size of the frame
int size = signalCh4.FrameSize;
 

The following screenshot displays an example of the displayed signal properties and frame data: