The following classes implement different MDF version3 blocks.
asammdf.v2_v3_blocks.
Channel
(**kargs)[source]¶CNBLOCK class derived from dict
The Channel object can be created in two modes:
The keys have the following meaning:
id - Block type identifier, always “CN”
block_len - Block size of this block in bytes (entire CNBLOCK)
group (NIL allowed)
signal (NIL allowed)
of this signal (NIL allowed)
(NIL allowed)
(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.
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)
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.
data record
data_type - Signal data type
range_flag - Value range valid flag
(raw value)
(raw value)
sampling_rate - Sampling rate for a virtual time channel. Unit [s]
signal name
name (NIL allowed)
record (default value: 0).
Parameters: | stream : file handle
address : int
|
---|
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 |
asammdf.v2_v3_blocks.
ChannelConversion
(**kargs)[source]¶CCBLOCK class derived from dict
The ChannelConversion object can be created in two modes:
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
address : int
|
---|
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 |
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
the N-dimensional dependencies:
Parameters: | stream : file handle
address : int
|
---|
Attributes
address | (int) block address inside mdf file |
asammdf.v2_v3_blocks.
ChannelExtension
(**kargs)[source]¶CEBLOCK class derived from dict
The ChannelExtension object can be created in two modes:
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
address : int
|
---|
Attributes
address | (int) block address inside mdf file |
asammdf.v2_v3_blocks.
ChannelGroup
(**kargs)[source]¶CGBLOCK class derived from dict
The ChannelGroup object can be created in two modes:
The keys have the following meaning:
Parameters: | stream : file handle
address : int
|
---|
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 |
asammdf.v2_v3_blocks.
DataGroup
(**kargs)[source]¶DGBLOCK class derived from dict
The DataGroup object can be created in two modes:
The keys have the following meaning:
Parameters: | stream : file handle
address : int
|
---|
Attributes
address | (int) block address inside mdf file |
asammdf.v2_v3_blocks.
FileIdentificationBlock
(**kargs)[source]¶IDBLOCK class derived from dict
The TriggerBlock object can be created in two modes:
The keys have the following meaning:
Parameters: | stream : file handle
version : int
|
---|
Attributes
address | (int) block address inside mdf file; should be 0 always |
asammdf.v2_v3_blocks.
HeaderBlock
(**kargs)[source]¶HDBLOCK class derived from dict
The TriggerBlock object can be created in two modes:
The keys have the following meaning:
Since version 3.2 the following extra keys were added:
Parameters: | stream : file handle
|
---|
Attributes
address | (int) block address inside mdf file; should be 64 always |
asammdf.v2_v3_blocks.
ProgramBlock
(**kargs)[source]¶PRBLOCK class derived from dict
The ProgramBlock object can be created in two modes:
The keys have the following meaning:
Parameters: | stream : file handle
address : int
|
---|
Attributes
address | (int) block address inside mdf file |
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:
Parameters: | stream : file handle
address : int
|
---|
Attributes
address | (int) block address inside mdf file |
asammdf.v2_v3_blocks.
TextBlock
(**kargs)[source]¶TXBLOCK class derived from dict
The ProgramBlock object can be created in two modes:
The keys have the following meaning:
Parameters: | stream : file handle
address : int
text : bytes
|
---|
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 |
asammdf.v2_v3_blocks.
TriggerBlock
(**kargs)[source]¶TRBLOCK class derived from dict
The TriggerBlock object can be created in two modes:
The keys have the following meaning:
Parameters: | stream : file handle
address : int
|
---|
Attributes
address | (int) block address inside mdf file |