The following classes implement different MDF version 3 blocks.
Channel Class¶
- class asammdf.blocks.v2_v3_blocks.Channel(**kwargs: Unpack[ChannelKwargs])[source]¶
CNBLOCK class.
If the
load_metadatakeyword 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 nameadditional_byte_offset- int : additional Byte offset of the channel in the data record
Other attributes:
address- int : block address inside MDF filecomment- str : channel commentconversion- ChannelConversion : channel conversion; None if the channel has no conversiondisplay_names- dict : channel display namesChanged in version 7.0.0: Changed from str to dict.
name- str : full channel namesource- SourceInformation : channel source information; None if the channel has no source information
- Parameters:
- addressint
Block address; to be used for objects created from file.
- streamhandle
File handle; to be used for objects created from file.
- load_metadatabool
Option to load conversion, source and display_names; default is 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: Unpack[ChannelConversionKwargs])[source]¶
CCBLOCK class.
ChannelConversionhas 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
ChannelConversionhas 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 : equation 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:
- addressint
Block address inside MDF file.
- raw_bytesbytes
Complete block read from disk.
- streamfile 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: Unpack[ChannelDependencyKwargs])[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 filereferenced_channels- list : list of (group index, channel index) pairs
- Parameters:
- streamfile handle
MDF file handle.
- addressint
Block address inside MDF file.
- for dynamically created objects
See the key-value pairs.
ChannelExtension Class¶
- class asammdf.blocks.v2_v3_blocks.ChannelExtension(**kwargs: Unpack[ChannelExtensionKwargs])[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- bytes : sender namereserved0- bytes : reserved bytes
Other attributes:
address- int : block address inside MDF filecomment- str : extension commentname- str : extension namepath- str : extension path
- Parameters:
- streamfile handle
MDF file handle.
- addressint
Block address inside MDF file.
- for dynamically created objects
See the key-value pairs.
ChannelGroup Class¶
- class asammdf.blocks.v2_v3_blocks.ChannelGroup(**kwargs: Unpack[ChannelGroupKwargs])[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 : address to first sample reduction block
Other attributes:
address- int : block address inside MDF filecomment- str : channel group comment
- Parameters:
- streamfile handle
MDF file handle.
- addressint
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: Unpack[DataGroupKwargs])[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- address 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:
- streamfile handle
MDF file handle.
- addressint
Block address inside MDF file.
- for dynamically created objects
See the key-value pairs.
FileIdentificationBlock Class¶
- class asammdf.blocks.v2_v3_blocks.FileIdentificationBlock(**kwargs: Unpack[FileIdentificationBlockKwargs])[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 (endianness)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:
- streamfile handle
MDF file handle.
- versionint
MDF version in case of new file (dynamically created).
HeaderBlock Class¶
- class asammdf.blocks.v2_v3_blocks.HeaderBlock(**kwargs: Unpack[HeaderBlockKwargs])[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 that 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- bytes : time at which the recording was started in “HH:MM:SS” formatauthor_field- bytes : author nameorganization_field`- bytes : organization nameproject_field`- bytes : project namesubject_field`- bytes : subject
Since version 3.2 the following extra keys were added:
abs_time- int : timestamp 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 always be 64comment- int : file commentprogram- ProgramBlock : program blockauthor- str : measurement authordepartment- str : author departmentproject- str : working projectsubject- str : measurement subject
- Parameters:
- streamfile handle
MDF file handle.
- versionint
MDF version in case of new file (dynamically created).
ProgramBlock Class¶
- class asammdf.blocks.v2_v3_blocks.ProgramBlock(**kwargs: Unpack[ProgramBlockKwargs])[source]¶
PRBLOCK class.
PRBLOCK fields:
id- bytes : block ID; always b’PR’block_len- int : block bytes sizedata- bytes : creator program free format data
Other attributes:
address- int : block address inside MDF file
- Parameters:
- streamfile handle
MDF file handle.
- addressint
Block address inside MDF file.
TextBlock Class¶
- class asammdf.blocks.v2_v3_blocks.TextBlock(**kwargs: Unpack[TextBlockKwargs])[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:
- streamfile handle
MDF file handle.
- addressint
Block address inside MDF file.
- textbytes | str
Bytes or str for creating a new TextBlock.
Examples
>>> tx1 = TextBlock(text='VehicleSpeed') >>> tx1['text'] b'VehicleSpeed\x00'
TriggerBlock Class¶
- class asammdf.blocks.v2_v3_blocks.TriggerBlock(**kwargs: Unpack[BlockKwargs])[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 filecomment- str : trigger comment
- Parameters:
- streamfile handle
MDF file handle.
- addressint
Block address inside MDF file.