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 sizenext_ch_addr- int : next CNBLOCK addressconversion_addr- int : address of channel conversion blocksource_addr- int : address of channel source blockcomponent_addr- int : address of dependency block (CDBLOCK) of this channelcomment_addr- int : address of TXBLOCK that contains the channel commentchannel_type- int : integer code for channel typeshort_name- bytes : short signal namedescription- bytes : signal descriptionstart_offset- int : start offset in bits to determine the first bit of the signal in the data recordbit_count- int : channel bit countdata_type- int : integer code for channel data typerange_flag- int : value range valid flagmin_raw_value- float : min raw value of all samplesmax_raw_value- float : max raw value of all samplessampling_rate- float : sampling rate in ‘s’ for a virtual time channellong_name_addr- int : address of TXBLOCK that contains the channel’s namedisplay_name_addr- int : address of TXBLOCK that contains the channel’s display nameaditional_byte_offset- int : additional Byte offset of the channel in the data recor
Other attributes
address- int : block address inside mdf filecomment- str : channel commentconversion- ChannelConversion : channel conversion; None if the channel has no conversiondisplay_name- str : channel display namename- str : full channel namesource- 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 sizerange_flag- int : value range valid flagmin_phy_value- float : min raw value of all samplesmax_phy_value- float : max raw value of all samplesunit- bytes : physical unitconversion_type- int : integer code for conversion typeref_param_nr- int : number of referenced parameters
ChannelConversion has the following specific fields
linear conversion
a- float : factorb- float : offsetCANapeHiddenExtra- bytes : sometimes CANape appends extra information; not compliant with MDF specs
algebraic conversion
formula- bytes : ecuation as string
polynomial or rational conversion
P1toP6- float : parameters
exponential or logarithmic conversion
P1toP7- 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 valuedefault_upper- float : default upper raw valuedefault_addr- int : address of default text physical valuelower_<N>- float : N-th lower raw valueupper_<N>- float : N-th upper raw valuetext_<N>- int : address of N-th text physical value
Other attributes
address- int : block address inside mdf fileformula- str : formula string in case of algebraic conversionreferenced_blocks- list : list of CCBLOCK/TXBLOCK referenced by the conversionunit- 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 sizedependency_type- int : integer code for dependency typesd_nr- int : total number of signals dependenciesdg_<N>- address of data group block (DGBLOCK) of N-th signal dependencydg_<N>- address of channel group block (CGBLOCK) of N-th signal dependencydg_<N>- address of channel block (CNBLOCK) of N-th signal dependencydim_<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) pairsParameters: - 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 sizetype- int : extension type identifier
CEBLOCK has the following specific fields
for DIM block
module_nr- int: module numbermodule_address- int : module addressdescription- bytes : module descriptionECU_identification- bytes : identification of ECUreserved0- bytes : reserved bytes
for Vector CAN block
CAN_id- int : CAN message IDCAN_ch_index- int : index of CAN channelmessage_name- bytes : message namesender_name- btyes : sender namereserved0- bytes : reserved bytes
Other attributes
address- int : block address inside mdf filecomment- str : extension commentname- str : extension namepath- 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 sizenext_cg_addr- int : next CGBLOCK addressfirst_ch_addr- int : address of first channel block (CNBLOCK)comment_addr- int : address of TXBLOCK that contains the channel group commentrecord_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 channelssamples_byte_nr- int : size of data record in bytes without record IDcycles_nr- int : number of cycles (records) of this type in the data blocksample_reduction_addr- int : addresss to first sample reduction block
Other attributes
address- int : block address inside mdf filecomment- 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 sizenext_dg_addr- int : next DGBLOCK addressfirst_cg_addr- int : address of first channel group block (CGBLOCK)trigger_addr- int : address of trigger block (TRBLOCK)data_block_addr- addrfss of data blockcg_nr- int : number of channel groupsrecord_id_len- int : number of record IDs in the data blockreserved0- 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 identifierversion_str- bytes : format identifierprogram_identification- bytes : creator program identifierbyte_order- int : integer code for byte order (endiannes)float_format- int : integer code for floating-point formatmdf_version- int : version number of MDF formatcode_page- int : unicode code page numberreserved0- bytes : reserved bytesreserved1- bytes : reserved bytesunfinalized_standard_flags- int : standard flags for unfinalized MDFunfinalized_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 sizefirst_dg_addr- int : address of first data group block (DGBLOCK)comment_addr- int : address of TXBLOCK taht contains the measurement file commentprogram_addr- int : address of program block (PRBLOCK)dg_nr- int : number of data groupsdate- bytes : date at which the recording was started in “DD:MM:YYYY” formattime- btyes : time at which the recording was started in “HH:MM:SS” formatauthor- btyes : author nameorganization- bytes : organization nameproject- bytes : project namesubject- 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 classtimer_identification- bytes : timer identification (time source)
Other attributes
address- int : block address inside mdf file; should be 64 alwayscomment- int : file comment- ``program `` - ProgramBlock : program block
author- str : measurement authordepartment- str : author’s departmentproject- 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 sizedata- btyes : creator program free format data
Other attributes *
address- int : block address inside mdf fileParameters: - 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 sizetext- 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 sizetext_addr- int : address of TXBLOCK that contains the trigger comment texttrigger_events_nr- int : number of trigger eventstrigger_<N>_time- float : trigger time [s] of trigger’s N-th eventtrigger_<N>_pretime- float : pre trigger time [s] of trigger’s N-th eventtrigger_<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