MDF Lib 2.2
Interface against MDF 3/4 files
Loading...
Searching...
No Matches
mdf Namespace Reference

Main namespace for the MDF library. More...

Namespaces

namespace  CaFlag
 Channel array (CA) block flags.
 
namespace  CcFlag
 Channel conversion flags.
 
namespace  CgFlag
 Channel group flags.
 
namespace  CnFlag
 Channel flags. See also IChannel::Flags().
 
namespace  SiFlag
 Source information flags.
 

Classes

class  CanMessage
 Helper class when logging CAN and CAN FD messages. More...
 
struct  CaTripleReference
 Structure that defines the channel array (CA) blocks references. More...
 
struct  ElementLink
 Support structure that holds a DG/CG/CN relation. More...
 
class  ETag
 Helper class for meta data items in an MDF file. More...
 
class  IAttachment
 Interface against an attached file. More...
 
class  IBlock
 Base class for all MDF blocks. More...
 
class  IChannel
 Defines a MDF channel (CN) block. More...
 
class  IChannelArray
 Defines an interface against an array (CA) block. More...
 
class  IChannelConversion
 Defines a channel conversion (CC) block. More...
 
class  IChannelGroup
 Interface against a channel group (CG) block. More...
 
class  IChannelHierarchy
 Channel hierarchy (CH) block. More...
 
class  IChannelObserver
 The channel observer object shall hold all samples for a channel. More...
 
class  IDataGroup
 Interface to a data group (DG) block. More...
 
class  IEvent
 Interface against an event block. More...
 
class  IFileHistory
 Interface class against an MDF FH block. More...
 
class  IHeader
 Interface class against an MDF HD block. More...
 
class  IMdfTimestamp
 Interface for MDF timestamp handling. More...
 
class  IMetaData
 Interface against an meta data block (MD) in a MDF4 file. More...
 
class  ISampleObserver
 Interface to a sample observer that handle incoming samples events. More...
 
class  ISampleReduction
 Defines an interface to a sample reduction (SR) block. More...
 
class  ISourceInformation
 Interface to a source information (SI) block. More...
 
class  ITimestamp
 Interface for timestamp handling in MDF files. More...
 
class  LocalTimestamp
 Class representing a local timestamp, with timezone and DST offset. More...
 
class  MdfFactory
 MDF factory class. More...
 
class  MdfFile
 Implements an user interface against a MDF file. More...
 
class  MdfHelper
 Support class for the MDF library. More...
 
class  MdfLogStream
 MDF log stream interface. More...
 
class  MdfReader
 Reader interface to an MDF file. More...
 
class  MdfWriter
 Interface against an MDF writer object. More...
 
struct  SampleRecord
 Simple record buffer structure. More...
 
struct  SrValue
 Template class that is used to handle reduction sample. More...
 
struct  TextConversion
 MDF 3 text conversion structure. Not used in MDF 4. Key to text conversion. More...
 
struct  TextRangeConversion
 MDF 3 range conversion structure. Not used in MDF 4. Key min/max to text conversion. More...
 
class  TimezoneTimestamp
 Class representing a timestamp with timezone information. More...
 
class  UtcTimestamp
 Class representing a UTC timestamp. More...
 

Typedefs

using MdfLogFunction2
 MDF logging function definition.
 
using AttachmentList = std::vector<const IAttachment*>
 List of pointers to attachments.
 
using DataGroupList = std::vector<IDataGroup*>
 List of pointers to measurements (DG block).
 
using MdfLogFunction1
 MDF log function definition.
 
using ChannelObserverPtr = std::unique_ptr<IChannelObserver>
 Smart pointer to an observer.
 
using ChannelObserverList = std::vector<ChannelObserverPtr>
 List of observer.
 
using ByteArray = std::vector<uint8_t>
 Defines a dynamic byte array.
 

Enumerations

enum class  CanErrorType : uint8_t {
  UNKNOWN_ERROR = 0 , BIT_ERROR = 1 , FORM_ERROR = 2 , BIT_STUFFING_ERROR = 3 ,
  CRC_ERROR = 4 , ACK_ERROR = 5
}
 Enumerate yhat defines type of CAN bus error. More...
 
enum class  MessageType : int { CAN_DataFrame , CAN_RemoteFrame , CAN_ErrorFrame , CAN_OverloadFrame }
 Enumerate that defines type of CAN messages. More...
 
enum class  ETagDataType : uint8_t {
  StringType = 0 , DecimalType = 1 , IntegerType = 2 , FloatType = 3 ,
  BooleanType = 4 , DateType = 5 , TimeType = 6 , DateTimeType = 7
}
 The e-tag may optional have a data type below. The value in the XML file is of course string but the data type may be used for interpretation of the value. Note that unit property can also be added. More...
 
enum class  ChannelType : uint8_t {
  FixedLength = 0 , VariableLength = 1 , Master = 2 , VirtualMaster = 3 ,
  Sync = 4 , MaxLength = 5 , VirtualData = 6
}
 Channel functional type. More...
 
enum class  ChannelSyncType : uint8_t {
  None = 0 , Time = 1 , Angle = 2 , Distance = 3 ,
  Index = 4
}
 Synchronization type. More...
 
enum class  ChannelDataType : uint8_t {
  UnsignedIntegerLe = 0 , UnsignedIntegerBe = 1 , SignedIntegerLe = 2 , SignedIntegerBe = 3 ,
  FloatLe = 4 , FloatBe = 5 , StringAscii = 6 , StringUTF8 = 7 ,
  StringUTF16Le = 8 , StringUTF16Be = 9 , ByteArray = 10 , MimeSample = 11 ,
  MimeStream = 12 , CanOpenDate = 13 , CanOpenTime = 14 , ComplexLe = 15 ,
  ComplexBe = 16
}
 Channel data type. More...
 
enum class  ArrayType : uint8_t {
  Array = 0 , ScalingAxis = 1 , LookUp = 2 , IntervalAxis = 3 ,
  ClassificationResult = 4
}
 Type of array. More...
 
enum class  ArrayStorage : uint8_t { CnTemplate = 0 , CgTemplate = 1 , DgTemplate = 2 }
 Type of storage. More...
 
enum class  ConversionType : uint8_t {
  NoConversion = 0 , Linear = 1 , Rational = 2 , Algebraic = 3 ,
  ValueToValueInterpolation = 4 , ValueToValue = 5 , ValueRangeToValue = 6 , ValueToText = 7 ,
  ValueRangeToText = 8 , TextToValue = 9 , TextToTranslation = 10 , BitfieldToText = 11 ,
  Polynomial = 30 , Exponential = 31 , Logarithmic = 32 , DateConversion = 33 ,
  TimeConversion = 34
}
 Type of conversion formula. More...
 
enum class  ChType : uint8_t {
  Group = 0 , Function = 1 , Structure = 2 , MapList = 3 ,
  InputVariable = 4 , OutputVariable = 5 , LocalVariable = 6 , CalibrationDefinition = 7 ,
  CalibrationObject = 8
}
 Block type. More...
 
enum class  EventType : uint8_t {
  RecordingPeriod = 0 , RecordingInterrupt = 1 , AcquisitionInterrupt = 2 , StartRecording = 3 ,
  StopRecording = 4 , Trigger = 5 , Marker = 6
}
 Type of event. More...
 
enum class  SyncType : uint8_t { SyncTime = 1 , SyncAngle = 2 , SyncDistance = 3 , SyncIndex = 4 }
 Type of synchronization value (default time) More...
 
enum class  RangeType : uint8_t { RangePoint = 0 , RangeStart = 1 , RangeEnd = 2 }
 Type of range. More...
 
enum class  EventCause : uint8_t {
  CauseOther = 0 , CauseError = 1 , CauseTool = 2 , CauseScript = 3 ,
  CauseUser = 4
}
 Type of cause. More...
 
enum class  SrSyncType : uint8_t {
  Undefined = 0 , Time = 1 , Angle = 2 , Distance = 3 ,
  Index = 4
}
 Type of master for a sample reduction (SR) block.
 
enum class  SourceType : uint8_t {
  Other = 0 , Ecu = 1 , Bus = 2 , IoDevice = 3 ,
  Tool = 4 , User = 5
}
 Type of source information. More...
 
enum class  BusType : uint8_t {
  None = 0 , Other = 1 , Can = 2 , Lin = 3 ,
  Most = 4 , FlexRay = 5 , Kline = 6 , Ethernet = 7 ,
  Usb = 8
}
 Type of bus. More...
 
enum class  MdfWriterType : int { Mdf3Basic = 0 , Mdf4Basic = 1 , MdfBusLogger = 2 , MdfConverter = 3 }
 MDF writer types. More...
 
enum class  MdfFileType : int { Mdf3FileType = 0 , Mdf4FileType = 1 }
 MDF file type. More...
 
enum class  MdfLogSeverity : uint8_t {
  kTrace = 0 , kDebug , kInfo , kNotice ,
  kWarning , kError , kCritical , kAlert ,
  kEmergency
}
 Defines the log severity level. More...
 
enum class  MdfBusType : int {
  CAN , LIN , FlexRay , MOST ,
  Ethernet , UNKNOWN
}
 Enumerate that defines type of bus. Only relevant for bus logging. More...
 
enum class  MdfStorageType : int { FixedLengthStorage , VlsdStorage , MlsdStorage }
 Enumerate that defines how the raw data is stored. By default the fixed length record is stored. Only used when doing bus logging. More...
 

Functions

std::string CreateMd5FileString (const std::string &file)
 Generates an MD5 file checksum (32 character) string.
 
bool CreateMd5FileChecksum (const std::string &file, std::vector< uint8_t > &md5)
 Create a file hash byte array according to MD5.
 
bool IsMdfFile (const std::string &filename)
 Returns true if the file is an MDF file.
 
ChannelObserverPtr CreateChannelObserver (const IDataGroup &data_group, const IChannelGroup &group, const IChannel &channel)
 Creates and attaches a channel sample observer.
 
ChannelObserverPtr CreateChannelObserver (const IDataGroup &dg_group, const std::string &channel_name)
 
void CreateChannelObserverForChannelGroup (const IDataGroup &data_group, const IChannelGroup &group, ChannelObserverList &dest)
 Creates a channel observer.
 
void CreateChannelObserverForDataGroup (const IDataGroup &data_group, ChannelObserverList &dest_list)
 Creates channel observers for all channels within a data group.
 
bool Deflate (std::FILE *in, std::FILE *out)
 Compress file to file.
 
bool Deflate (const ByteArray &buf_in, ByteArray &buf_out)
 Compress array to array.
 
bool Deflate (const std::string &filename, ByteArray &buf_out)
 Compress array to array.
 
bool Inflate (std::FILE *in, std::FILE *out)
 Decompress file to file.
 
bool Inflate (std::FILE *in, std::FILE *out, uint64_t nof_bytes)
 Decompress part of file to file.
 
bool Inflate (const ByteArray &in, ByteArray &out)
 Decompress array to array.
 
bool Inflate (const ByteArray &in, std::FILE *out)
 Decompress array to file.
 
void Transpose (ByteArray &data, size_t record_size)
 Transpose of an array.
 
void InvTranspose (ByteArray &data, size_t record_size)
 Invert transpose of an array.
 

Detailed Description

Main namespace for all MDF library classes and functions.

Typedef Documentation

◆ MdfLogFunction1

Initial value:
std::function<void(const MdfLocation &location,
MdfLogSeverity severity, const std::string &text)>
This is a replacement for the std::source_location library. The standard source_location library cann...
Definition mdflogstream.h:20

◆ MdfLogFunction2

Initial value:
std::function<void(MdfLogSeverity severity,
const std::string& function, const std::string& text)>

Enumeration Type Documentation

◆ ArrayStorage

enum class mdf::ArrayStorage : uint8_t
strong
Enumerator
CnTemplate 

Channel template.

CgTemplate 

Channel group template.

DgTemplate 

Data group template.

◆ ArrayType

enum class mdf::ArrayType : uint8_t
strong
Enumerator
Array 

Simple array without attributes.

ScalingAxis 

Scaling axis.

LookUp 

Lookup array.

IntervalAxis 

Interval axis.

ClassificationResult 

Classification result.

◆ BusType

enum class mdf::BusType : uint8_t
strong
Enumerator
None 

No bus (default).

Other 

Unknown bus type.

Can 

CAN bus.

Lin 

LIN bus.

Most 

MOST bus.

FlexRay 

FlexRay bus.

Kline 

KLINE bus.

Ethernet 

EtherNet bus.

Usb 

USB bus.

◆ CanErrorType

enum class mdf::CanErrorType : uint8_t
strong
Enumerator
UNKNOWN_ERROR 

Unspecified error.

BIT_ERROR 

CAN bit error.

FORM_ERROR 

CAN format error.

BIT_STUFFING_ERROR 

Bit stuffing error.

CRC_ERROR 

Checksum error.

ACK_ERROR 

Acknowledgement error.

◆ ChannelDataType

enum class mdf::ChannelDataType : uint8_t
strong

Defines the channel data type. Avoid defining value sizes that doesn't align to a byte size.

The Le and Be extension is related to byte order. Little endian (Intel byte order) while big endian (Motorola byte order).

Enumerator
UnsignedIntegerLe 

Unsigned integer, little endian.

UnsignedIntegerBe 

Unsigned integer, big endian.

SignedIntegerLe 

Signed integer, little endian.

SignedIntegerBe 

Signed integer, big endian.

FloatLe 

Float, little endian.

FloatBe 

Float, big endian.

StringAscii 

Text, ISO-8859-1 coded.

StringUTF8 

Text, UTF8 coded.

StringUTF16Le 

Text, UTF16 coded little endian.

StringUTF16Be 

Text, UTF16 coded big endian.

ByteArray 

Byte array.

MimeSample 

MIME sample byte array.

MimeStream 

MIME stream byte array.

CanOpenDate 

7-byte CANOpen date.

CanOpenTime 

6-byte CANOpen time.

ComplexLe 

Complex value, little endian.

ComplexBe 

Complex value, big endian.

◆ ChannelSyncType

enum class mdf::ChannelSyncType : uint8_t
strong

Defines the synchronization type. The type is 'None' for fixed length channel but should be set for master and synchronization channels.

Enumerator
None 

No synchronization (default value)

Time 

Time type.

Angle 

Angle type.

Distance 

Distance type.

Index 

Sample number.

◆ ChannelType

enum class mdf::ChannelType : uint8_t
strong

Most channels are marked as 'FixedLength' which means that its size in a record is fixed. This works well with most data types but byte arrays and strings may change its size. Instead are these data types marked as 'Variable Length'. Avoid writing variable length data as it may allocate a lot of memory as it flush at the end of the measurement.

One channel in channel group (IChannelGroup), should be marked as a master channel. This channel is typical relative sample time with seconds as unit. The master channel is typical used on the X-axis when plotting data.

The 'VirtualMaster' channel can be used if the sample number is linear related to the sample time. The channel conversion (CC) block should define the sample number to time conversion.

The 'Sync' channel is used to synchronize an attachment block (file).

The 'MaxLength' type is typical used when storing CAN byte array where another channel stores actual bytes stored in a sample. For CAN the size in the max record size is 8 bytes.

The 'VirtualData' is similar to the 'VirtualMaster' channel but related to data. Good luck to find a use of this type.

Enumerator
FixedLength 

Fixed length data (default type)

VariableLength 

Variable length data.

Master 

Master channel.

VirtualMaster 

Virtual master channel.

Sync 

Synchronize channel.

MaxLength 

Max length channel.

VirtualData 

Virtual data channel.

◆ ChType

enum class mdf::ChType : uint8_t
strong
Enumerator
Group 

Define a group.

Function 

Define a function.

Structure 

Define a structure.

MapList 

Define a map list.

InputVariable 

Define input variables.

OutputVariable 

Define output variables.

LocalVariable 

Define local variables.

CalibrationDefinition 

Define calibration define objects.

CalibrationObject 

Define calibration reference objects.

◆ ConversionType

enum class mdf::ConversionType : uint8_t
strong

The type together with the Parameter() function defines the conversion between channel and engineering value.

Enumerator
NoConversion 

1:1 conversion. No parameters needed.

Linear 

Linear conversion. 2 parameters. Eng = Ch * Par(1) + Par(0).

Rational 

Rational function conversion. 6 parameters. Eng = (Par(0)*Ch^2 + Par(1)*Ch + Par(2)) / (Par(3)*Ch^2 + Par(4)*Ch + Par(5))

Algebraic 

Text formula.

ValueToValueInterpolation 

Value to value conversion with interpolation. Defined by a list of Key value pairs. Par(n) = key and Par(n+1) value.

ValueToValue 

Value to value conversion without interpolation. Defined by a list of Key value pairs. Par(n) = key and Par(n+1) value.

ValueRangeToValue 

Value range to value conversion without interpolation. Defined by a list of Key min/max value triplets. Par(3*n) = key min, Par(3*(n+1)) = key max and Par(3*(n+2)) value. Add a default value last, after all the triplets.

ValueToText 

Value to text conversion. Defined by a list of key values to text string conversions. This is normally used for enumerated channels. Par(n) value to Ref(n) text. Add a default referenced text last.

ValueRangeToText 

Value range to text conversion. Defined by a list of key min/max values to text string conversions. This is normally used for enumerated channels. Par(2*n) min key, Par(2(n+1)) max key to Ref(n) value. Add a default referenced text last.

TextToValue 

Text to value conversion. Defines a list of text string to value conversion. Ref(n) key to Par(n) value. Add a default value last to the parameter list.

TextToTranslation 

Text to text conversion. Defines a list of text string to text conversion. Ref(2*n) key to Ref(2*(n+1)) value. Add a text value last to the parameter list.

BitfieldToText 

Bitfield to text conversion Currently unsupported conversion.

Polynomial 

MDF 3 polynomial conversion.

Exponential 

MDF 3 exponential conversion.

Logarithmic 

MDF 3 logarithmic conversion.

DateConversion 

MDF 3 Date conversion.

TimeConversion 

MDF 3 Time conversion.

◆ ETagDataType

enum class mdf::ETagDataType : uint8_t
strong

Use ISO UTC date and time formats or avoid these data types if possible as they just causing problem at presentation.

Enumerator
StringType 

Text value.

DecimalType 

Decimal value (use float instead)

IntegerType 

Integer value.

FloatType 

Floating point value.

BooleanType 

Boolean tru/false value.

DateType 

Date value according to ISO (YYYY-MM-DD).

TimeType 

Time value ISO.

DateTimeType 

Date and Time ISO string (YYYY-MM-DD hh:mm:ss)

◆ EventCause

enum class mdf::EventCause : uint8_t
strong
Enumerator
CauseOther 

Unknown source.

CauseError 

An error generated this event.

CauseTool 

The tool generated this event.

CauseScript 

A script generated this event.

CauseUser 

A user generated this event.

◆ EventType

enum class mdf::EventType : uint8_t
strong
Enumerator
RecordingPeriod 

Specifies a recording period (range).

RecordingInterrupt 

The recording was interrupted.

AcquisitionInterrupt 

The data acquisition was interrupted.

StartRecording 

Start recording event.

StopRecording 

Stop recording event.

Trigger 

Generic event (no range).

Marker 

Another generic event (maybe range).

◆ MdfBusType

enum class mdf::MdfBusType : int
strong

Enumerate that is used when doing bus logging. The enumerate is used when creating default channel and channel group names.

Enumerator
CAN 

CAN or CAN-FD bus.

LIN 

LIN bus.

FlexRay 

FlexRay bus.

MOST 

MOST bus.

Ethernet 

Ethernet bus.

UNKNOWN 

Unknown bus type (Default)

◆ MdfFileType

enum class mdf::MdfFileType : int
strong
Enumerator
Mdf3FileType 

MDF version 3 file.

Mdf4FileType 

MDF version 4 file.

◆ MdfLogSeverity

enum class mdf::MdfLogSeverity : uint8_t
strong
Enumerator
kTrace 

Trace or listen message.

kDebug 

Debug message.

kInfo 

Informational message.

kNotice 

Notice message. Notify the user.

kWarning 

Warning message.

kError 

Error message.

kCritical 

Critical message (device error)

kAlert 

Alert or alarm message.

kEmergency 

Fatal error message.

◆ MdfStorageType

enum class mdf::MdfStorageType : int
strong

The fixed length storage is using one SD-block per byte array. The SD block is temporary stored in primary memory instead of store it on disc. This storage type is not recommended for bus logging.

The variable length storage uses an extra CG-record for byte array data. The storage type is used for bus logging where payload data is more than 8 byte.

The maximum length storage shall be used when payload data is 8 bytes or less. It is typically used when logging CAN messages which have 0-8 data payload.

Enumerator
FixedLengthStorage 

The default is to use fixed length records.

VlsdStorage 

Using variable length storage.

MlsdStorage 

Using maximum length storage.

◆ MdfWriterType

enum class mdf::MdfWriterType : int
strong
Enumerator
Mdf3Basic 

Basic MDF version 3 writer.

Mdf4Basic 

Basic MDF version 4 writer.

MdfBusLogger 

Specialized bus logger writer.

MdfConverter 

MDF writer for MDF 4 conversion applications.

◆ MessageType

enum class mdf::MessageType : int
strong
Enumerator
CAN_DataFrame 

Normal CAN message.

CAN_RemoteFrame 

Remote frame message.

CAN_ErrorFrame 

Error message.

CAN_OverloadFrame 

Overload frame message.

◆ RangeType

enum class mdf::RangeType : uint8_t
strong
Enumerator
RangePoint 

Defines a point.

RangeStart 

First in a range.

RangeEnd 

Last in a range.

◆ SourceType

enum class mdf::SourceType : uint8_t
strong
Enumerator
Other 

Unknown source type.

Ecu 

ECU.

Bus 

Bus.

IoDevice 

I/O device.

Tool 

Tool.

User 

User.

◆ SyncType

enum class mdf::SyncType : uint8_t
strong
Enumerator
SyncTime 

Sync value represent time (s).

SyncAngle 

Sync value represent angle (rad).

SyncDistance 

Sync value represent distance (m).

SyncIndex 

Sync value represent sample index.

Function Documentation

◆ CreateChannelObserver()

ChannelObserverPtr mdf::CreateChannelObserver ( const IDataGroup & dg_group,
const std::string & channel_name )
nodiscard

Function that creates a channel observer by searching the channel name. In case that the channel exist in many channel groups, it selects the group with the largest number of samples.

Parameters
dg_groupThe data group with the channel.
channel_nameThe channel name
Returns
A smart pointer to a channel observer.

◆ CreateChannelObserverForDataGroup()

void mdf::CreateChannelObserverForDataGroup ( const IDataGroup & data_group,
ChannelObserverList & dest_list )

This function generates channel observers for all channels within the a data group. This function may a little but dangerous as it may allocate a lot of primary memory. An hint is to check how many bytes there are in the DG/DT blocks. If there is more than 1GByte, maybe you should do some partial read instead.

Note that channel groups without samples or data, are skipped.

Parameters
data_groupReference to the data group.
dest_listThe subscriber list which is appended with channel observers.

◆ CreateMd5FileChecksum()

bool mdf::CreateMd5FileChecksum ( const std::string & file,
std::vector< uint8_t > & md5 )

Generates a file hash MD5 checksum. The output is a byte array.

Parameters
[in]fileFull path to the file name.
[out]md5Returns a byte array. The vector size is set by the function.
Returns
True on success.

◆ CreateMd5FileString()

std::string mdf::CreateMd5FileString ( const std::string & file)

Creates an MD5 file checksum. The output is a hexadecimal string.

Parameters
[in]fileFull path to the file name.
Returns
A 32 (hex) character string on success else an empty string.

◆ Deflate() [1/3]

bool mdf::Deflate ( const ByteArray & buf_in,
ByteArray & buf_out )

Compress a byte array directly to another array.

The input buffer data is compressed and sent to the output array. The output array needs be sized to a size so the compressed data fits. Normally it should be preset to the same size as the input. The output array is resized to the new compressed size.

The compress method is deflate according to ZLIB.

Parameters
buf_inInput byte array with data.
buf_outOutput array.
Returns
True on success.

◆ Deflate() [2/3]

bool mdf::Deflate ( const std::string & filename,
ByteArray & buf_out )

Compress a file directly to an array.

The file data is compressed and sent to an output array. Unlike the other Deflate() functions, the output buffer doesn't need to be sized before calling this function. The compress method is deflate according to ZLIB.

Parameters
filenameFull name of the file to compress.
buf_outOutput byte array. The function resize the buffer
Returns
True on success.

◆ Deflate() [3/3]

bool mdf::Deflate ( std::FILE * in,
std::FILE * out )

Compress a file directly to another file. This is an efficient way of compressing a file. The compress method is deflate according to ZLIB.

Parameters
inPointer to the input file stream.
outPointer to the output file stream.
Returns
True on success.