DataTypeMappingSet

XML tag

<DATA-TYPE-MAPPING-SET>

Module

autosar.datatype

Inherits

autosar.element.Element

This class contains type mappings between ApplicationDataTypes and ImplementationDataTypes. In addition, it can contain type mappings between ModeDeclarationGroups and ImplementationDataTypes.

Usage

import autosar

def setup():
    ws = autosar.workspace(version="4.2.2")
    #Application Types
    dataTypePackage=ws.createPackage('ApplicationTypes', role='DataType')
    dataConstraintPackage = dataTypePackage.createSubPackage('DataConstrs', role='DataConstraint')
    compuMethodPackage = dataTypePackage.createSubPackage('CompuMethods', role='CompuMethod')
    onOffDataConstraint = dataConstraintPackage.createInternalDataConstraint('OnOff_DataConstraint', 0, 3)
    onOffCompuMethod = compuMethodPackage.createCompuMethodConst('OnOff_CompuMethod',
        ['OnOff_Off', 'OnOff_On', 'OnOff_Error', 'OnOff_NotAvailable'],
        defaultValue='OnOff_NotAvailable')
    dataTypePackage.createApplicationPrimitiveDataType('OnOff_T',
    dataConstraint = onOffDataConstraint.ref,  compuMethod=onOffCompuMethod.ref)
    #Base Types
    baseTypes=ws.createPackage('BaseTypes')
    baseTypeUint8 = baseTypes.createSwBaseType('uint8', 8, nativeDeclaration='uint8')
    #Implementation Types
    dataTypePackage = ws.createPackage('ImplementationTypes', role = 'DataType')
    dataTypePackage.createSubPackage('DataConstrs', role='DataConstraint')
    dataTypePackage.createSubPackage('CompuMethods', role='CompuMethod')
    dataTypePackage.createImplementationDataType('OnOff_T', baseTypeUint8.ref,
        valueTable = ['OnOff_Off', 'OnOff_On', 'OnOff_Error', 'OnOff_NotAvailable'])
    return ws

ws = setup()
package = ws.createPackage('DataTypeMappingSets')
mappingSet = package.createDataTypeMappingSet('MappingSet')
appType = ws.find('/ApplicationTypes/OnOff_T')
implType = ws.find('/ImplementationTypes/OnOff_T')
mappingSet.createDataTypeMapping(appType.ref, implType.ref)
ws.saveXML('DataTypes.arxml')

Factory Methods

Constructor

datatype.DataTypeMappingSet(name[, parent = None][, adminData = None])
参数
  • name (str) – Short name.

  • parent (None, Package) – Parent package.

  • adminData (None, AdminData) – Admin data.

Attributes

For inherited attributes see autosar.element.Element.

Name

Type

Description

applicationTypeMap

dict

Application data type mappings

modeRequestMap

dict

Mode request mappings

The ARXML definition uses lists containing mappings while Python uses dictionaries. For the applicationTypeMap dictionary, each key is a reference to an application data type and each value is a reference to an implementation data type. Likewise for the modeRequestMap dictionary, each key is a reference to a mode declaration group and each value is a reference to an implementation data type.

Public Methods

Method Description

createDataTypeMapping

DataTypeMappingSet.createDataTypeMapping(applicationDataTypeRef, implementationDataTypeRef)

Creates a new type mapping between an application type (reference) and implementation data type (reference). The created mapping is added to the internal applicationTypeMap dictionary.

参数

createModeRequestMapping

DataTypeMappingSet.createModeRequestMapping(modeDeclarationGroupRef, implementationDataTypeRef)

Creates a new type mapping between a mode declaration group (reference) and implementation data type (reference). The created mapping is added to the internal modeRequestMap dictionary.

参数

add

DataTypeMappingSet.add(item)

Adds a user-created mapping to this mapping set. If the item is of type DataTypeMap it gets inserted into to the applicationTypeMap dictionary. Likewise, if the item is of type ModeRequestTypeMap it gets inserted into to the modeRequestMap dictionary.

参数

item (DataTypeMap or ModeRequestTypeMap) – Reference to ApplicationDataType

getDataTypeMapping

DataTypeMappingSet.getDataTypeMapping(applicationDataTypeRef)

Returns the mapping object that is currently associated with the given application data type reference. If the reference string is not found in the internal applicationTypeMap dictionary, None is returned.

参数

applicationDataTypeRef (str) – Reference to ApplicationDataType

返回类型

DataTypeMap or None

getModeRequestMapping

DataTypeMappingSet.getModeRequestMapping(modeDeclarationGroupRef)

Returns the mapping object that is currently associated with the given mode declaration group reference. If the reference string is not found in the internal modeRequestMap dictionary, None is returned.

参数

modeDeclarationGroupRef (str) – Reference to ModeDeclarationGroup

返回类型

ModeRequestTypeMap or None

findMappedDataTypeRef

DataTypeMappingSet.findMappedDataTypeRef(applicationDataTypeRef)

Same as getDataTypeMapping but instead returns the reference to the mapped implementation data type. Returns None in case the application data type reference is not part of the internal applicationTypeMap dictionary.

参数

applicationDataTypeRef (str) – Reference to ApplicationDataType

返回类型

str

findMappedModeRequestRef

DataTypeMappingSet.findMappedModeRequestRef(modeDeclarationGroupRef)

Same as getModeRequestMapping but instead returns the reference to the mapped implementation data type. Returns None in case the mode declaration group reference is not part of the internal modeRequestMap dictionary.

参数

modeDeclarationGroupRef (str) – Reference to ModeDeclarationGroup

返回类型

str

findMappedDataType

DataTypeMappingSet.findMappedDataType(applicationDataTypeRef)

Same as findMappedDataTypeRef but instead returns the referenced to ImplementationDataType object.

参数

applicationDataTypeRef (str) – Reference to ApplicationDataType

返回类型

ImplementationDataType

findMappedModeRequest

DataTypeMappingSet.findMappedModeRequest(modeDeclarationGroupRef)

Same as findMappedModeRequestRef but instead returns the referenced to ImplementationDataType object.

参数

modeDeclarationGroupRef (str) – Reference to ModeDeclarationGroup

返回类型

ImplementationDataType