How to Read Time Data from CI Data Files in C#
Introduction
The ATFX API consists of two DLL files that can be integrated with custom software to directly read and extract data from an ATFX file. This post will show a simple C# code example in extracting and creating a DateTimeNano object that has accuracy in nanoseconds.
The DateTimeNano class is a subclass of the DateTime class from Microsoft with additional properties and functions to extend the accuracy of DateTime to nanoseconds.
For a simple way to open and read a ATFX file, please refer to the ATFX API Reading a ATFX File in C# article.
For more detailed information on how to implement the following code sections and properties in a class, please refer to the ATFX API manual and the provided C# Demo code. The package can be downloaded from our Programming Corner.
Extracting and Creating Time Data with Accuracy in Nanoseconds
To create a DateTimeNano object from the ATFX file, the recording property CreateTime and a class, NVHMeasurement, to access NanoSecondElapsed are needed to put into the constructor.
The below code sample shows the creation process and several of the new properties in the DateTimeNano class, such as ms_us_ns which shows Milisecond, Microsecond and Nanosecond in 000/000/000 format.
RecordingManager.Manager.OpenRecording(recordingPath, out IRecording rec); // Create several ATFX API classes to extract specific data to be used in creating the DateTimeNano // Create a DateTimeNano object with UTC Time Format // DateTimeNano object properties // Math in extracting exact Millisecond, Microsecond and Nanosecond data |
The following screenshot is an example of the displayed ATFX file’s DateTimeNano in UTC format: