The following classes implement different MDF version3 blocks.

Channel Class

class asammdf.v2_v3_blocks.Channel(**kwargs)[source]

CNBLOCK class

If the load_metadata keyword argument is not provided or is False, then the conversion, source and display name information is not processed.

Channel has the following key-value pairs

  • id - bytes : block ID; always b’CN’
  • block_len - int : block bytes size
  • next_ch_addr - int : next CNBLOCK address
  • conversion_addr - int : address of channel conversion block
  • source_addr - int : address of channel source block
  • ch_depend_addr - int : address of dependency block (CDBLOCK) of this channel
  • comment_addr - int : address of TXBLOCK that contains the channel comment
  • channel_type - int : integer code for channel type
  • short_name - bytes : short signal name
  • description - bytes : signal description
  • start_offset - int : start offset in bits to determine the first bit of the signal in the data record
  • bit_count - int : channel bit count
  • data_type - int : integer code for channel data type
  • range_flag - int : value range valid flag
  • min_raw_value - float : min raw value of all samples
  • max_raw_value - float : max raw value of all samples
  • sampling_rate - float : sampling rate in ‘s’ for a virtual time channel
  • long_name_addr - int : address of TXBLOCK that contains the channel’s name
  • display_name_addr - int : address of TXBLOCK that contains the channel’s display name
  • aditional_byte_offset - int : additional Byte offset of the channel in the data recor
Parameters:
address : int

block address; to be used for objects created from file

stream : handle

file handle; to be used for objects created from file

load_metadata : bool

option to load conversion, source and display_name; default True

for dynamically created objects :

see the key-value pairs

Examples

>>> with open('test.mdf', 'rb') as mdf:
...     ch1 = Channel(stream=mdf, address=0xBA52)
>>> ch2 = Channel()
>>> ch1.name
'VehicleSpeed'
>>> ch1['id']
b'CN'
Attributes:
address : int

block address inside mdf file

comment : str

channel comment

conversion : ChannelConversion

channel conversion; None if the channel has no conversion

display_name : str

channel display name

name : str

full channel name

source : SourceInformation

channel source information; None if the channel has no source information

ChannelConversion Class

class asammdf.v2_v3_blocks.ChannelConversion(**kwargs)[source]

CCBLOCK class

The ChannelConversion object can be created in two modes:

ChannelConversion has the following common key-value pairs

  • id - bytes : block ID; always b’CC’
  • block_len - int : block bytes size
  • range_flag - int : value range valid flag
  • min_phy_value - float : min raw value of all samples
  • max_phy_value - float : max raw value of all samples
  • unit - bytes : physical unit
  • conversion_type - int : integer code for conversion type
  • ref_param_nr - int : number of referenced parameters

ChannelConversion has the following specific key-value pairs

  • linear conversion

    • a - float : factor
    • b - float : offset
    • CANapeHiddenExtra - bytes : sometimes CANape appends extra information; not compliant with MDF specs
  • algebraic conversion

    • formula - bytes : ecuation as string
  • polynomial or rational conversion

    • P1 to P6 - float : parameters
  • exponential or logarithmic conversion

    • P1 to P7 - float : parameters
  • tabular with or without interpolation (grouped by index)

    • raw_<N> - int : N-th raw value (X axis)
    • phys_<N> - float : N-th physical value (Y axis)
  • text table conversion

    • param_val_<N> - int : N-th raw value (X axis)
    • text_<N> - N-th text physical value (Y axis)
  • text range table conversion

    • default_lower - float : default lower raw value
    • default_upper - float : default upper raw value
    • default_addr - int : address of default text physical value
    • lower_<N> - float : N-th lower raw value
    • upper_<N> - float : N-th upper raw value
    • text_<N> - int : address of N-th text physical value
Parameters:
address : int

block address inside mdf file

raw_bytes : bytes

complete block read from disk

stream : file handle

mdf file handle

for dynamically created objects :

see the key-value pairs

Examples

>>> with open('test.mdf', 'rb') as mdf:
...     cc1 = ChannelConversion(stream=mdf, address=0xBA52)
>>> cc2 = ChannelConversion(conversion_type=0)
>>> cc1['b'], cc1['a']
0, 100.0
Attributes:
address : int

block address inside mdf file

formula : str

formula string in case of algebraic conversion

referenced_blocks : list

list of CCBLOCK/TXBLOCK referenced by the conversion

unit : str

physical unit

ChannelDependency Class

class asammdf.v2_v3_blocks.ChannelDependency(**kwargs)[source]

CDBLOCK class

ChannelDependency has the following key-value pairs

  • id - bytes : block ID; always b’CD’
  • block_len - int : block bytes size
  • dependency_type - int : integer code for dependency type
  • sd_nr - int : total number of signals dependencies
  • dg_<N> - address of data group block (DGBLOCK) of N-th signal dependency
  • dg_<N> - address of channel group block (CGBLOCK) of N-th signal dependency
  • dg_<N> - address of channel block (CNBLOCK) of N-th signal dependency
  • dim_<K> - int : Optional size of dimension K for N-dimensional dependency
Parameters:
stream : file handle

mdf file handle

address : int

block address inside mdf file

for dynamically created objects :

see the key-value pairs

Attributes:
address : int

block address inside mdf file

referenced_channels : list

list of (group index, channel index) pairs

ChannelExtension Class

class asammdf.v2_v3_blocks.ChannelExtension(**kwargs)[source]

CEBLOCK class

Channel has the following common key-value pairs

  • id - bytes : block ID; always b’CE’
  • block_len - int : block bytes size
  • type - int : extension type identifier

Channel has the following specific key-value pairs

  • for DIM block

    • module_nr - int: module number
    • module_address - int : module address
    • description - bytes : module description
    • ECU_identification - bytes : identification of ECU
    • reserved0 - bytes : reserved bytes
  • for Vector CAN block

    • CAN_id - int : CAN message ID
    • CAN_ch_index - int : index of CAN channel
    • message_name - bytes : message name
    • sender_name - btyes : sender name
    • reserved0 - bytes : reserved bytes
Parameters:
stream : file handle

mdf file handle

address : int

block address inside mdf file

for dynamically created objects :

see the key-value pairs

Attributes:
address : int

block address inside mdf file

comment : str

extension comment

name : str

extension name

path : str

extension path

ChannelGroup Class

class asammdf.v2_v3_blocks.ChannelGroup(**kwargs)[source]

CGBLOCK class

ChannelGroup has the following key-value pairs

  • id - bytes : block ID; always b’CG’
  • block_len - int : block bytes size
  • next_cg_addr - int : next CGBLOCK address
  • first_ch_addr - int : address of first channel block (CNBLOCK)
  • comment_addr - int : address of TXBLOCK that contains the channel group comment
  • record_id - int : record ID used as identifier for a record if the DGBLOCK defines a number of record IDs > 0 (unsorted group)
  • ch_nr - int : number of channels
  • samples_byte_nr - int : size of data record in bytes without record ID
  • cycles_nr - int : number of cycles (records) of this type in the data block
  • sample_reduction_addr - int : addresss to first sample reduction block
Parameters:
stream : file handle

mdf file handle

address : int

block address inside mdf file

for dynamically created objects :

see the key-value pairs

Examples

>>> with open('test.mdf', 'rb') as mdf:
...     cg1 = ChannelGroup(stream=mdf, address=0xBA52)
>>> cg2 = ChannelGroup(sample_bytes_nr=32)
>>> hex(cg1.address)
0xBA52
>>> cg1['id']
b'CG'
Attributes:
address : int

block address inside mdf file

comment : str

channel group comment

DataGroup Class

class asammdf.v2_v3_blocks.DataGroup(**kwargs)[source]

DGBLOCK class

Channel has the following key-value pairs

  • id - bytes : block ID; always b’DG’
  • block_len - int : block bytes size
  • next_dg_addr - int : next DGBLOCK address
  • first_cg_addr - int : address of first channel group block (CGBLOCK)
  • trigger_addr - int : address of trigger block (TRBLOCK)
  • data_block_addr - addrfss of data block
  • cg_nr - int : number of channel groups
  • record_id_len - int : number of record IDs in the data block
  • reserved0 - bytes : reserved bytes
Parameters:
stream : file handle

mdf file handle

address : int

block address inside mdf file

for dynamically created objects :

see the key-value pairs

Attributes:
address : int

block address inside mdf file

FileIdentificationBlock Class

class asammdf.v2_v3_blocks.FileIdentificationBlock(**kwargs)[source]

IDBLOCK class

FileIdentificationBlock has the following key-value pairs

  • file_identification - bytes : file identifier
  • version_str - bytes : format identifier
  • program_identification - bytes : creator program identifier
  • byte_order - int : integer code for byte order (endiannes)
  • float_format - int : integer code for floating-point format
  • mdf_version - int : version number of MDF format
  • code_page - int : unicode code page number
  • reserved0 - bytes : reserved bytes
  • reserved1 - bytes : reserved bytes
  • unfinalized_standard_flags - int : standard flags for unfinalized MDF
  • unfinalized_custom_flags - int : custom flags for unfinalized MDF
Parameters:
stream : file handle

mdf file handle

version : int

mdf version in case of new file (dynamically created)

Attributes:
address : int

block address inside mdf file; should be 0 always

HeaderBlock Class

class asammdf.v2_v3_blocks.HeaderBlock(**kwargs)[source]

HDBLOCK class

HeaderBlock has the following key-value pairs

  • id - bytes : block ID; always b’HD’
  • block_len - int : block bytes size
  • first_dg_addr - int : address of first data group block (DGBLOCK)
  • comment_addr - int : address of TXBLOCK taht contains the measurement file comment
  • program_addr - int : address of program block (PRBLOCK)
  • dg_nr - int : number of data groups
  • date - bytes : date at which the recording was started in “DD:MM:YYYY” format
  • time - btyes : time at which the recording was started in “HH:MM:SS” format
  • author - btyes : author name
  • organization - bytes : organization name
  • project - bytes : project name
  • subject - bytes : subject

Since version 3.2 the following extra keys were added:

  • abs_time - int : time stamp at which recording was started in nanoseconds.
  • tz_offset - int : UTC time offset in hours (= GMT time zone)
  • time_quality - int : time quality class
  • timer_identification - bytes : timer identification (time source)
Parameters:
stream : file handle

mdf file handle

version : int

mdf version in case of new file (dynamically created)

Attributes:
address : int

block address inside mdf file; should be 64 always

comment : int

file comment

program : ProgramBlock

program block

author : str

measurement author

department : str

author’s department

project : str

working project

subject : str

measurement subject

ProgramBlock Class

class asammdf.v2_v3_blocks.ProgramBlock(**kwargs)[source]

PRBLOCK class

ProgramBlock has the following key-value pairs

  • id - bytes : block ID; always b’PR’
  • block_len - int : block bytes size
  • data - btyes : creator program free format data
Parameters:
stream : file handle

mdf file handle

address : int

block address inside mdf file

Attributes:
address : int

block address inside mdf file

SampleReduction Class

class asammdf.v2_v3_blocks.SampleReduction(**kwargs)[source]

SRBLOCK class

SampleReduction has the following key-value pairs

  • id - bytes : block ID; always b’SR’
  • block_len - int : block bytes size
  • next_sr_addr - int : next SRBLOCK address
  • data_block_addr - int : address of data block for this sample reduction
  • cycles_nr - int : number of reduced samples in the data block
  • time_interval - float : length of time interval [s] used to calculate
    the reduced samples
Parameters:
stream : file handle

mdf file handle

address : int

block address inside mdf file

Attributes:
address : int

block address inside mdf file

TextBlock Class

class asammdf.v2_v3_blocks.TextBlock(**kwargs)[source]

TXBLOCK class

TextBlock has the following key-value pairs

  • id - bytes : block ID; always b’TX’
  • block_len - int : block bytes size
  • text - bytes : text content
Parameters:
stream : file handle

mdf file handle

address : int

block address inside mdf file

text : bytes | str

bytes or str for creating a new TextBlock

Examples

>>> tx1 = TextBlock(text='VehicleSpeed')
>>> tx1.text_str
'VehicleSpeed'
>>> tx1['text']
b'VehicleSpeed'
Attributes:
address : int

block address inside mdf file

TriggerBlock Class

class asammdf.v2_v3_blocks.TriggerBlock(**kwargs)[source]

TRBLOCK class

Channel has the following key-value pairs

  • id - bytes : block ID; always b’TR’
  • block_len - int : block bytes size
  • text_addr - int : address of TXBLOCK that contains the trigger comment text
  • trigger_events_nr - int : number of trigger events
  • trigger_<N>_time - float : trigger time [s] of trigger’s N-th event
  • trigger_<N>_pretime - float : pre trigger time [s] of trigger’s N-th event
  • trigger_<N>_posttime - float : post trigger time [s] of trigger’s N-th event
Parameters:
stream : file handle

mdf file handle

address : int

block address inside mdf file

Attributes:
address : int

block address inside mdf file

comment : str

trigger comment