The following classes implement different MDF version3 blocks.

Channel Class

class asammdf.blocks.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.

CNBLOCK fields

  • 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
  • component_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

Other 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
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'

ChannelConversion Class

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

CCBLOCK class

ChannelConversion has the following common fields

  • 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 fields

  • 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

Other 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
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

ChannelDependency Class

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

CDBLOCK class

CDBLOCK fields

  • 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

Other attributes * address - int : block address inside mdf file * referenced_channels - list : list of (group index, channel index) pairs

Parameters:
stream : file handle

mdf file handle

address : int

block address inside mdf file

for dynamically created objects :

see the key-value pairs

ChannelExtension Class

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

CEBLOCK class

CEBLOCK has the following common fields

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

CEBLOCK has the following specific fields

  • 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

Other attributes

  • address - int : block address inside mdf file
  • comment - str : extension comment
  • name - str : extension name
  • path - str : extension path
Parameters:
stream : file handle

mdf file handle

address : int

block address inside mdf file

for dynamically created objects :

see the key-value pairs

ChannelGroup Class

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

CGBLOCK class

CGBLOCK fields

  • 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

Other attributes

  • address - int : block address inside mdf file
  • comment - str : channel group comment
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'

DataGroup Class

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

DGBLOCK class

DGBLOCK fields

  • 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

Other attributes

  • address - int : block address inside mdf file
Parameters:
stream : file handle

mdf file handle

address : int

block address inside mdf file

for dynamically created objects :

see the key-value pairs

FileIdentificationBlock Class

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

IDBLOCK class

IDBLOCK fields

  • 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

Other attributes

  • address - int : block address inside mdf file; should be 0 always
Parameters:
stream : file handle

mdf file handle

version : int

mdf version in case of new file (dynamically created)

HeaderBlock Class

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

HDBLOCK class

HDBLOCK fields

  • 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)

Other 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
Parameters:
stream : file handle

mdf file handle

version : int

mdf version in case of new file (dynamically created)

ProgramBlock Class

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

PRBLOCK class

PRBLOCK fields

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

Other attributes * address - int : block address inside mdf file

Parameters:
stream : file handle

mdf file handle

address : int

block address inside mdf file

TextBlock Class

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

TXBLOCK class

TXBLOCK fields

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

Other attributes

  • address - int : block address inside mdf file
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'

TriggerBlock Class

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

TRBLOCK class

TRBLOCK fields

  • 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

Other attributes

  • address - int : block address inside mdf file
  • ``comment `` - str : trigger comment
Parameters:
stream : file handle

mdf file handle

address : int

block address inside mdf file