The following classes implement different MDF version3 blocks.
Channel Class¶
-
class
asammdf.v2_v3_blocks.
Channel
(**kargs)[source]¶ CNBLOCK class derived from dict
The Channel object can be created in two modes:
- using the stream and address keyword parameters - when reading
- from file
- using any of the following presented keys - when creating a new Channel
The keys have the following meaning:
id - Block type identifier, always “CN”
block_len - Block size of this block in bytes (entire CNBLOCK)
- next_ch_addr - Pointer to next channel block (CNBLOCK) of this channel
group (NIL allowed)
- conversion_addr - Pointer to the conversion formula (CCBLOCK) of this
signal (NIL allowed)
- source_depend_addr - Pointer to the source-depending extensions (CEBLOCK)
of this signal (NIL allowed)
- ch_depend_addr - Pointer to the dependency block (CDBLOCK) of this signal
(NIL allowed)
- comment_addr - Pointer to the channel comment (TXBLOCK) of this signal
(NIL allowed)
channel_type - Channel type
- 0 = data channel
- 1 = time channel for all signals of this group (in each channel
- group, exactly one channel must be defined as time channel). The time stamps recording in a time channel are always relative to the start time of the measurement defined in HDBLOCK.
- short_name - Short signal name, i.e. the first 31 characters of the
ASAM-MCD name of the signal (end of text should be indicated by 0)
description - Signal description (end of text should be indicated by 0)
- start_offset - Start offset in bits to determine the first bit of the
signal in the data record. The start offset N is divided into two parts: a “Byte offset” (= N div 8) and a “Bit offset” (= N mod 8). The channel block can define an “additional Byte offset” (see below) which must be added to the Byte offset.
- bit_count - Number of bits used to encode the value of this signal in a
data record
data_type - Signal data type
range_flag - Value range valid flag
- min_raw_value - Minimum signal value that occurred for this signal
(raw value)
- max_raw_value - Maximum signal value that occurred for this signal
(raw value)
sampling_rate - Sampling rate for a virtual time channel. Unit [s]
- long_name_addr - Pointer to TXBLOCK that contains the ASAM-MCD long
signal name
- display_name_addr - Pointer to TXBLOCK that contains the signal’s display
name (NIL allowed)
- aditional_byte_offset - Additional Byte offset of the signal in the data
record (default value: 0).
Parameters: - stream : file handle
mdf file handle
- address : int
block address inside mdf file
Examples
>>> with open('test.mdf', 'rb') as mdf: ... ch1 = Channel(stream=mdf, address=0xBA52) >>> ch2 = Channel() >>> ch1.name 'VehicleSpeed' >>> ch1['id'] b'CN'
Attributes: - name : str
full channel name
- address : int
block address inside mdf file
- dependencies : list
lsit of channel dependencies
ChannelConversion Class¶
-
class
asammdf.v2_v3_blocks.
ChannelConversion
(**kargs)[source]¶ CCBLOCK class derived from dict
The ChannelConversion object can be created in two modes:
- using the stream and address keyword parameters - when reading
- from file
- using any of the following presented keys - when creating a new
- ChannelConversion
The first keys are common for all conversion types, and are followed by conversion specific keys. The keys have the following meaning:
common keys
- id - Block type identifier, always “CC”
- block_len - Block size of this block in bytes (entire CCBLOCK)
- range_flag - Physical value range valid flag:
- min_phy_value - Minimum physical signal value that occurred for this
- signal
- max_phy_value - Maximum physical signal value that occurred for this
- signal
- unit - Physical unit (string should be terminated with 0)
- conversion_type - Conversion type (formula identifier)
- ref_param_nr - Size information about additional conversion data
specific keys
linear conversion
- b - offset
- a - factor
- CANapeHiddenExtra - sometimes CANape appends extra information;
- not compliant with MDF specs
ASAM formula conversion
- formula - ecuation as string
polynomial or rational conversion
- P1 .. P6 - factors
exponential or logarithmic conversion
- P1 .. P7 - factors
tabular with or without interpolation (grouped by n)
- raw_{n} - n-th raw integer value (X axis)
- phys_{n} - n-th physical value (Y axis)
text table conversion
- param_val_{n} - n-th integers value (X axis)
- text_{n} - n-th text value (Y axis)
text range table conversion
- lower_{n} - n-th lower raw value
- upper_{n} - n-th upper raw value
- text_{n} - n-th text value
Parameters: - stream : file handle
mdf file handle
- address : int
block address inside mdf file
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
ChannelDependency Class¶
-
class
asammdf.v2_v3_blocks.
ChannelDependency
(**kargs)[source]¶ CDBLOCK class derived from dict
Currently the ChannelDependency object can only be created using the stream and address keyword parameters when reading from file
The keys have the following meaning:
id - Block type identifier, always “CD”
block_len - Block size of this block in bytes (entire CDBLOCK)
dependency_type - Dependency type
sd_nr - Total number of signals dependencies (m)
for each dependency there is a group of three keys:
- dg_{n} - Pointer to the data group block (DGBLOCK) of
- signal dependency n
- cg_{n} - Pointer to the channel group block (DGBLOCK) of
- signal dependency n
- ch_{n} - Pointer to the channel block (DGBLOCK) of
- signal dependency n
- there can also be optional keys which decribe dimensions for
the N-dimensional dependencies:
- dim_{n} - Optional: size of dimension n for N-dimensional
- dependency
Parameters: - stream : file handle
mdf file handle
- address : int
block address inside mdf file
Attributes: - address : int
block address inside mdf file
ChannelExtension Class¶
-
class
asammdf.v2_v3_blocks.
ChannelExtension
(**kargs)[source]¶ CEBLOCK class derived from dict
The ChannelExtension object can be created in two modes:
- using the stream and address keyword parameters - when reading
- from file
- using any of the following presented keys - when creating
- a new ChannelExtension
The first keys are common for all conversion types, and are followed by conversion specific keys. The keys have the following meaning:
common keys
- id - Block type identifier, always “CE”
- block_len - Block size of this block in bytes (entire CEBLOCK)
- type - Extension type identifier
specific keys
for DIM block
- module_nr - Number of module
- module_address - Address
- description - Description
- ECU_identification - Identification of ECU
- reserved0’ - reserved
for Vector CAN block
- CAN_id - Identifier of CAN message
- CAN_ch_index - Index of CAN channel
- message_name - Name of message (string should be terminated by 0)
- sender_name - Name of sender (string should be terminated by 0)
- reserved0 - reserved
Parameters: - stream : file handle
mdf file handle
- address : int
block address inside mdf file
Attributes: - address : int
block address inside mdf file
ChannelGroup Class¶
-
class
asammdf.v2_v3_blocks.
ChannelGroup
(**kargs)[source]¶ CGBLOCK class derived from dict
The ChannelGroup object can be created in two modes:
- using the stream and address keyword parameters - when reading
- from file
- using any of the following presented keys - when creating
- a new ChannelGroup
The keys have the following meaning:
- id - Block type identifier, always “CG”
- block_len - Block size of this block in bytes (entire CGBLOCK)
- next_cg_addr - Pointer to next channel group block (CGBLOCK) (NIL
- allowed)
- first_ch_addr - Pointer to first channel block (CNBLOCK) (NIL allowed)
- comment_addr - Pointer to channel group comment text (TXBLOCK)
- (NIL allowed)
- record_id - Record ID, i.e. value of the identifier for a record if
- the DGBLOCK defines a number of record IDs > 0
- ch_nr - Number of channels (redundant information)
- samples_byte_nr - Size of data record in Bytes (without record ID),
- i.e. size of plain data for a each recorded sample of this channel group
- cycles_nr - Number of records of this type in the data block
- i.e. number of samples for this channel group
- sample_reduction_addr - only since version 3.3. Pointer to
- first sample reduction block (SRBLOCK) (NIL allowed) Default value: NIL
Parameters: - stream : file handle
mdf file handle
- address : int
block address inside mdf file
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
DataGroup Class¶
-
class
asammdf.v2_v3_blocks.
DataGroup
(**kargs)[source]¶ DGBLOCK class derived from dict
The DataGroup object can be created in two modes:
- using the stream and address keyword parameters - when reading
- from file
- using any of the following presented keys - when creating a new DataGroup
The keys have the following meaning:
- id - Block type identifier, always “DG”
- block_len - Block size of this block in bytes (entire DGBLOCK)
- next_dg_addr - Pointer to next data group block (DGBLOCK) (NIL allowed)
- first_cg_addr - Pointer to first channel group block (CGBLOCK)
- (NIL allowed)
- trigger_addr - Pointer to trigger block (TRBLOCK) (NIL allowed)
- data_block_addr - Pointer to the data block (see separate chapter
- on data storage)
- cg_nr - Number of channel groups (redundant information)
- record_id_nr - Number of record IDs in the data block
- reserved0 - since version 3.2; Reserved
Parameters: - stream : file handle
mdf file handle
- address : int
block address inside mdf file
Attributes: - address : int
block address inside mdf file
FileIdentificationBlock Class¶
-
class
asammdf.v2_v3_blocks.
FileIdentificationBlock
(**kargs)[source]¶ IDBLOCK class derived from dict
The TriggerBlock object can be created in two modes:
- using the stream and address keyword parameters - when reading
- from file
- using the classmethod from_text
The keys have the following meaning:
- file_identification - file identifier
- version_str - format identifier
- program_identification - program identifier
- byte_order - default byte order
- float_format - default floating-point format
- mdf_version - version number of MDF format
- code_page - code page number
- reserved0 - reserved
- reserved1 - reserved
- unfinalized_standard_flags - Standard Flags for unfinalized MDF
- unfinalized_custom_flags - Custom Flags for unfinalized MDF
Parameters: - stream : file handle
mdf file handle
- version : int
mdf version in case of new file
Attributes: - address : int
block address inside mdf file; should be 0 always
HeaderBlock Class¶
-
class
asammdf.v2_v3_blocks.
HeaderBlock
(**kargs)[source]¶ HDBLOCK class derived from dict
The TriggerBlock object can be created in two modes:
- using the stream - when reading from file
- using the classmethod from_text
The keys have the following meaning:
- id - Block type identifier, always “HD”
- block_len - Block size of this block in bytes (entire HDBLOCK)
- first_dg_addr - Pointer to the first data group block (DGBLOCK)
- comment_addr - Pointer to the measurement file comment text (TXBLOCK)
- (NIL allowed)
- program_addr - Pointer to program block (PRBLOCK) (NIL allowed)
- dg_nr - Number of data groups (redundant information)
- date - Date at which the recording was started in “DD:MM:YYYY” format
- time - Time at which the recording was started in “HH:MM:SS” format
- author - author name
- organization - organization
- project - project name
- subject - subject
Since version 3.2 the following extra keys were added:
- abs_time - Time stamp at which recording was started in nanoseconds.
- tz_offset - UTC time offset in hours (= GMT time zone)
- time_quality - Time quality class
- timer_identification - Timer identification (time source),
Parameters: - stream : file handle
mdf file handle
Attributes: - address : int
block address inside mdf file; should be 64 always
ProgramBlock Class¶
-
class
asammdf.v2_v3_blocks.
ProgramBlock
(**kargs)[source]¶ PRBLOCK class derived from dict
The ProgramBlock object can be created in two modes:
- using the stream and address keyword parameters - when reading
- from file
- using any of the following presented keys - when creating
- a new ProgramBlock
The keys have the following meaning:
- id - Block type identifier, always “PR”
- block_len - Block size of this block in bytes (entire PRBLOCK)
- data - Program-specific 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
(**kargs)[source]¶ SRBLOCK class derived from dict
Currently the SampleReduction object can only be created by using the stream and address keyword parameters - when reading from file
The keys have the following meaning:
- id - Block type identifier, always “SR”
- block_len - Block size of this block in bytes (entire SRBLOCK)
- next_sr_addr - Pointer to next sample reduction block (SRBLOCK)
- (NIL allowed)
- data_block_addr - Pointer to the data block for this sample reduction
- cycles_nr - Number of reduced samples in the data block.
- time_interval - 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
(**kargs)[source]¶ TXBLOCK class derived from dict
The ProgramBlock object can be created in two modes:
- using the stream and address keyword parameters - when reading
- from file
- using the classmethod from_text
The keys have the following meaning:
- id - Block type identifier, always “TX”
- block_len - Block size of this block in bytes (entire TXBLOCK)
- text - Text (new line indicated by CR and LF; end of text indicated by 0)
Parameters: - stream : file handle
mdf file handle
- address : int
block address inside mdf file
- text : bytes
bytes for creating a new TextBlock
Examples
>>> tx1 = TextBlock.from_text('VehicleSpeed') >>> tx1.text_str 'VehicleSpeed' >>> tx1['text'] b'VehicleSpeed'
Attributes: - address : int
block address inside mdf file
- text_str : str
text data as unicode string
TriggerBlock Class¶
-
class
asammdf.v2_v3_blocks.
TriggerBlock
(**kargs)[source]¶ TRBLOCK class derived from dict
The TriggerBlock object can be created in two modes:
- using the stream and address keyword parameters - when reading
- from file
- using the classmethod from_text
The keys have the following meaning:
- id - Block type identifier, always “TR”
- block_len - Block size of this block in bytes (entire TRBLOCK)
- text_addr - Pointer to trigger comment text (TXBLOCK) (NIL allowed)
- trigger_events_nr - Number of trigger events n (0 allowed)
- trigger_{n}_time - Trigger time [s] of trigger event n
- trigger_{n}_pretime - Pre trigger time [s] of trigger event n
- trigger_{n}_posttime - Post trigger time [s] of trigger event n
Parameters: - stream : file handle
mdf file handle
- address : int
block address inside mdf file
Attributes: - address : int
block address inside mdf file