Package
XML tag |
<AR-PACKAGE> |
Module |
autosar.package |
Inherits |
An AUTOSAR package is a container for elements. Elements are almost everything else that are not packages. In addition to elements each package can also contain zero or more sub-packages.
Usage
import autosar
ws = autosar.workspace("4.2.2")
package = ws.createPackage('ComponentTypes', role = 'ComponentType')
Attributes
Name |
Type |
Description |
---|---|---|
name |
str |
Name of the package |
elements |
list[Elements] |
List of elements |
subPackages |
list[Package] |
List of sub-packages |
role |
str |
Package role |
Package Roles
Constant |
Main container for Constants |
ComponentType |
Main container for Components |
CompuMethod |
Main container for Computational Methods |
DataConstraint |
Main container for Data Constraints |
DataType |
Main container for Data Types |
ModeDclrGroup |
Main container for Mode Declaration Groups |
PortInterface |
Main container for Port Interfaces |
Unit |
Main container for Units |
Public Methods
ComponentType
CompuMethod
Constant
DataConstraint
DataType
Mode
PortInterface
SubPackage
SoftwareAddressMethod
Unit
DataTypeMapping
Method Description
createApplicationSoftwareComponent
- Package.createApplicationSoftwareComponent(swcName[, behaviorName = None][, implementationName = None][, multipleInstance = False])
Creates a new ApplicationSoftwareComponent and adds it to the package.
- 参数
swcName (str) – ShortName of the component type
behaviorName (str) – ShortName of the associated Behavior object. If not set an automatic name is selected.
implementationName (str) – ShortName of the associated Implementation object. If not set an automatic name is selected.
multipleInstance (bool) – Set to True if this component prototype needs to support multiple instances
autoCreatePortAPIOptions (bool) – Set to True to automatically create port API options.
- 返回类型
Example
import autosar
ws = autosar.workspace("4.2.2")
components = ws.createPackage("ComponentTypes")
swc = components.createApplicationSoftwareComponent("MyApp")
print(swc.name)
createComplexDeviceDriverComponent
- Package.createComplexDeviceDriverComponent(swcName[, behaviorName = None][, implementationName = None][, multipleInstance = False])
Creates a new ComplexDeviceDriverComponent and adds it to the package.
- 参数
swcName (str) – ShortName of the component type
behaviorName (str) – ShortName of the associated Behavior object. If not set an automatic name is selected.
implementationName (str) – ShortName of the associated Implementation object. If not set an automatic name is selected.
multipleInstance (bool) – Set to True if this component prototype needs to support multiple instances
autoCreatePortAPIOptions (bool) – Set to True to automatically create port API options.
- 返回类型
createCompositionComponent
- Package.createCompositionComponent(componentName[, adminData = None])
Creates a new CompositionComponent and adds it to the package.
- 参数
componentName (str) – ShortName of the component type
adminData (None, AdminData.) – Optional AdminData.
- 返回类型
Example
import autosar
ws = autosar.workspace("4.2.2")
components = ws.createPackage("ComponentTypes")
swc = components.createCompositionComponent("MyComposition")
print(swc.name)
createNvBlockComponent
- Package.createNvBlockComponent(swcName[, behaviorName = None][, implementationName = None][, multipleInstance = False])
Creates a new NvBlockComponent and adds it to the package.
- 参数
swcName (str) – ShortName of the component type
behaviorName (str) – ShortName of the associated Behavior object. If not set an automatic name is selected.
implementationName (str) – ShortName of the associated Implementation object. If not set an automatic name is selected.
multipleInstance (bool) – Set to True if this component prototype needs to support multiple instances
autoCreatePortAPIOptions (bool) – Set to True to automatically create port API options.
- 返回类型
NvBlockComponent
createServiceComponent
- Package.createServiceComponent(swcName[, behaviorName = None][, implementationName = None][, multipleInstance = False])
Creates a new ServiceComponent and adds it to the package.
- 参数
swcName (str) – ShortName of the component type.
behaviorName (str) – ShortName of the associated Behavior object. If not set an automatic name is selected.
implementationName (str) – ShortName of the associated Implementation object. If not set an automatic name is selected.
multipleInstance (bool) – Set to True if this component prototype needs to support multiple instances.
autoCreatePortAPIOptions (bool) – Set to True to automatically create port API options.
- 返回类型
Example
import autosar
ws = autosar.workspace("4.2.2")
components = ws.createPackage("ComponentTypes")
swc = components.createServiceComponent("MyService")
print(swc.name)
createCompuMethodConst
- Package.createCompuMethodConst(name, valueTable[, unit = None][, defaultValue = None][, category = 'TEXTTABLE'][, adminData = None])
Creates a new CompuMethod based on a value-table (better known as enumeration) and adds it to the package.
- 参数
name (str) – shortName of the new CompuMethod.
valueTable (list) – List of strings containing enumeration values. See below for more advanced options.
unit (str) – Optional unit name (requires package role ‘Unit’ to be setup).
defaultValue (str) – Optional default value.
category (str) – Category string used for the new CompuMethod.
adminData (None, AdminData.) – Optional AdminData.
- 返回类型
CompuMethod
createCompuMethodLinear
Alias for createCompuMethodRational.
createCompuMethodRational
- Package.createCompuMethodRational(name, offset, scaling[, lowerLimit = None][, upperLimit = None][, lowerLimitType = 'CLOSED'][, upperLimitType = 'CLOSED'][, unit = None][, defaultValue = None][, label = 'SCALING'][, forceFloat = False][, useIntToPhys=True][, usePhysToInt = False][, category = 'LINEAR'][, adminData = None])
Creates a new CompuMethod containing a CompuScaleElement (offset+scaling) and adds it to the package.
- 参数
name (str) – ShortName of the new CompuMethod.
offset (int,float) – Offset.
scaling (int, float, rational number) – Scaling factor.
lowerLimit (int) – Lower limit of the CompuScaleElement.
upperLimit (int) – Upper limit of the CompuScaleElement.
lowerLimitType (str) – Interval type of lowerLimit (“OPEN” or “CLOSED”). Only applies when lowerLimit is not None.
upperLimitType (str) – Interval type of upperLimit (“OPEN” or “CLOSED”). Only applies when upperLimit is not None.
unit (str) – Optional unit name (requires package role ‘Unit’ to be setup).
defaultValue (None, int, float, str) – Optional default value.
label (str) – Label of the CompuScaleElement
forceFloat (bool) – When False it sets the scaling numerator/denominator to closest possible rational number. When True it forces numerator to float and sets denominator to 1.
useIntToPhys (bool) – When True, creates an internal to physical Computation. Cannot be True when usePhysToInt is also True.
usePhysToInt (bool) – When True, creates a physical to internal Computation. Cannot be True when useIntToPhys is also True.
category (str) – Category string used for the new CompuMethod.
adminData (None, AdminData.) – Optional AdminData.
- 返回类型
CompuMethod
This method by default creates an internal to physical computation, use the method createCompuMethodRationalPhys to create a physical to internal computation. Some AUTOSAR toolchains does not work when numerator and denominator is a rational number. Use the option forceFloat to force the scaling factor to be stored as a floating point number.
createCompuMethodRationalPhys
Convenience method that calls createCompuMethodRational but creates physical to internal computation instead.
createApplicationValueConstant
- Package.createApplicationValueConstant(name[, swValueCont = None][, swAxisCont = None][, valueCategory = None][, valueLabel = None])
Creates an application value constant and adds it to the package.
- 参数
name (str) – ShortName of the new constant
swValueCont (SwValueCont) – Value container
swAxisCont (SwValueCont) – Axis container
valueCategory (str) – Optional category for (inner) value
valueLabel (str) – Optional label for (inner) value
- 返回类型
createConstant
- Package.createConstant(name, typeRef, initValue, adminData=None)
Creates a new constant (based on a type reference) and adds it to the package.
createNumericalValueConstant
createInternalDataConstraint
- Package.createInternalDataConstraint(name, lowerLimit, upperLimit, lowerLimitType='CLOSED', upperLimitType='CLOSED', adminData=None)
Creates a new internal data constraint and adds it the package.
- 参数
name (str) – ShortName of the new DataConstraint.
lowerLimit (int, float.) – Lower limit.
upperLimit (int, float.) – Upper limit.
lowerLimitType (str) – Interval type of lowerLimit (“OPEN”/”CLOSED”).
upperLimitType (str) – Interval type of upperLimit (“OPEN”/”CLOSED”).
- 返回类型
createPhysicalDataConstraint
- Package.createPhysicalDataConstraint(name, lowerLimit, upperLimit, lowerLimitType='CLOSED', upperLimitType='CLOSED', adminData=None)
Creates a new physical data constraint and adds it the package.
- 参数
name (str) – ShortName of the new DataConstraint.
lowerLimit (int, float.) – Lower limit.
upperLimit (int, float.) – Upper limit.
lowerLimitType (str) – Interval type of lowerLimit (“OPEN”/”CLOSED”).
upperLimitType (str) – Interval type of upperLimit (“OPEN”/”CLOSED”).
- 返回类型
createApplicationArrayDataType
- Package.createApplicationArrayDataType(name, element[, swCalibrationAccess = None][, category = 'ARRAY'][, adminData = None])
Creates a new ApplicationArrayDataType and appends it to the package.
- 参数
name (str) – ShortName of the new datatype
element (ApplicationArrayElement) – An ApplicationArrayElement object
swCalibrationAccess (None, str) – Optional calibration access
category (None, str) – Optional category string.
adminData (None, AdminData) – Optional AdminData.
- 返回类型
createApplicationPrimitiveDataType
- Package.createApplicationPrimitiveDataType(name[, dataConstraint = ""][, compuMethod = None][, unit = None][, swCalibrationAccess = None][, category = None][, adminData = None])
Creates a new ApplicationPrimitiveDataType and appends it to this package.
- 参数
name (str) – ShortName of the new datatype
dataConstraint (str) – Optional name or reference to a DataConstraint object. Empty string means that an automatic data constraint will be created. Set to None to disable.
compuMethod (str) – Optional name or reference to a CompuMethod object
unit (str) – Optional name or reference to a Unit object
swCalibrationAccess (None, str) – Optional calibration access
category (None, str) – Category string.
adminData (None, AdminData) – AdminData
- 返回类型
ApplicationPrimitiveDataType
createApplicationRecordDataType
- Package.createApplicationRecordDataType(name[, elements = None][, swCalibrationAccess = None][, category = "STRUCTURE"][, adminData = None])
Creates a new ApplicationRecordDataType and appends it to the package.
- 参数
name (str) – ShortName.
elements – List containing tuples. First tuple element is the record name (string), second tuple element is a type reference (string).
swCalibrationAccess (None, str) – Optional calibration access
category (None, str) – Category string.
adminData (None, AdminData) – AdminData
- 返回类型
ApplicationRecordDataType
createBaseType
Alias for createSwBaseType.
createImplementationArrayDataType
- Package.createImplementationArrayDataType(name, implementationTypeRef, arraySize[, elementName = None][, swCalibrationAccess = ''][, typeEmitter = None][, category = 'ARRAY'][, targetCategory = 'TYPE_REFERENCE'][, adminData = None])
Creates an implementation array data type and adds it to the package.
- 参数
name (str) – ShortName of the new data type
implementationTypeRef (str) – Reference to (existing) ImplementationDataType
arraySize (int) – Number of elements in array
elementName (str) – Optional (inner) element name.
swCalibrationAccess (None, str) – Optional calibration access
typeEmitter (str) – Optional type emitter
category (None, str) – Category for the (outer) array data type
targetCategory (None, str) – Category for the (inner) array element
adminData (None, AdminData) – AdminData
- 返回类型
createImplementationDataType
- Package.createImplementationDataType(name, baseTypeRef[, lowerLimit = None][, upperLimit = None][, valueTable = None][, bitmask = None][, offset = None][, scaling = None][, unit = None][, forceFloat = False][, dataConstraint = ''][, swCalibrationAccess = ''][, typeEmitter = None][, lowerLimitType = None][, upperLimitType = None][, category='VALUE'][, adminData = None])
Creates a new implementation data type that is tied directly to a base type.
- 参数
name (str) – ShortName of the datatype
baseTypeRef (str) – Reference to existing base type
lowerLimit (int) – Optional lower limit.
upperLimit (int) – Optional upper limit.
valueTable – Optional valueTable. See valueTable for details.
bitmask – Optional bitmask. See bitmask for details.
offset (int) – Optional offset (for CompuMethod). When this is used, scaling also has to be set.
scaling (int or float) – Optional scaling factor (for CompuMethod).
unit (str) – Optional unit.
forceFloat (bool) – When False it sets the scaling numerator/denominator to closest possible rational number. When True it forces numerator to float type and sets denominator to 1.
dataConstraint (str) – Optional name or reference to existing DataConstraint element. Value None prevents dataConstraint from being created while empty-string automatically attempts to create a DataConstraint element.
swCalibrationAccess (str) – Optional calibration access
typeEmitter (str) – Optional type emitter string.
lowerLimitType (str) – Selects lowerLimitType (“OPEN” or “CLOSED”) if lowerLimit is used. Value None defaults to “CLOSED”.
upperLimitType (str) – Selects upperLimitType (“OPEN” or “CLOSED”) if upperLimit is used. Value None defaults to “CLOSED”.
category (str) – Category string.
adminData (None, AdminData.) – Optional AdminData.
- 返回类型
Example
import autosar
#Setup
ws = autosar.workspace(version="4.2.2")
package=ws.createPackage('DataTypes', role='DataType')
package.createSubPackage('CompuMethods', role='CompuMethod')
package.createSubPackage('DataConstrs', role='DataConstraint')
baseTypes=package.createSubPackage('BaseTypes')
baseTypes.createSwBaseType('uint8', 8, nativeDeclaration='uint8')
baseTypes.createSwBaseType('uint16', 16, nativeDeclaration='uint16')
baseTypes.createSwBaseType('uint32', 32, nativeDeclaration='uint32')
implTypes = package.createSubPackage('ImplementationTypes')
implTypes.createImplementationDataType('uint8', lowerLimit=0, upperLimit=255, baseTypeRef='/DataTypes/BaseTypes/uint8', typeEmitter='Platform_Type')
implTypes.createImplementationDataType('uint16', lowerLimit=0, upperLimit=65535, baseTypeRef='/DataTypes/BaseTypes/uint16', typeEmitter='Platform_Type')
implTypes.createImplementationDataType('uint32', lowerLimit=0, upperLimit=4294967295, baseTypeRef='/DataTypes/BaseTypes/uint32', typeEmitter='Platform_Type')
#Export as XML
ws.saveXML('DataTypes.arxml')
createImplementationDataTypeRef
- Package.createImplementationDataTypeRef(name, implementationTypeRef[, lowerLimit = None][, upperLimit = None][, valueTable = None][, bitmask = None][, offset = None][, scaling = None][, unit = None][, forceFloat = False][, dataConstraint = ''][, swCalibrationAccess = ''][, typeEmitter = None][, lowerLimitType = None][, upperLimitType = None][, category = 'TYPE_REFERENCE'][, adminData = None])
Creates a new implementation data type that is a reference to another implementation type. This is similar in concept to a typedef in the C programming language
- 参数
name (str) – ShortName of the datatype
implementationTypeRef (str) – Reference to existing ImplementationDataType
lowerLimit (int) – Optional lower limit.
upperLimit (int) – Optional upper limit.
valueTable – Optional valueTable. See valueTable for details.
bitmask – Optional bitmask. See bitmask for details.
offset (int) – Optional offset (for CompuMethod). When this is used, scaling also has to be set.
scaling (int or float) – Optional scaling factor (for CompuMethod).
unit (str) – Optional unit.
forceFloat (bool) – When False it sets the scaling numerator/denominator to closest possible rational number. When True it forces numerator to float type and sets denominator to 1.
dataConstraint (str) – Optional name or reference to existing DataConstraint element. Value None prevents dataConstraint from being created while empty-string automatically attempts to create a DataConstraint element.
swCalibrationAccess (str) – Optional calibration access
typeEmitter (str) – Optional type emitter string.
lowerLimitType (str) – Selects lowerLimitType (“OPEN” or “CLOSED”) if lowerLimit is used. Value None defaults to “CLOSED”.
upperLimitType (str) – Selects upperLimitType (“OPEN” or “CLOSED”) if upperLimit is used. Value None defaults to “CLOSED”.
category (str) – Category string.
adminData (None, AdminData.) – Optional AdminData.
- 返回类型
Example
import autosar
#Setup
ws = autosar.workspace(version="4.2.2")
package=ws.createPackage('DataTypes', role='DataType')
package.createSubPackage('CompuMethods', role='CompuMethod')
package.createSubPackage('DataConstrs', role='DataConstraint')
baseTypes=package.createSubPackage('BaseTypes')
baseTypes.createSwBaseType('uint8', 8, nativeDeclaration='uint8')
baseTypes.createSwBaseType('uint16', 16, nativeDeclaration='uint16')
implTypes = package.createSubPackage('ImplementationTypes')
implTypes.createImplementationDataType('uint8', lowerLimit=0, upperLimit=255, baseTypeRef='/DataTypes/BaseTypes/uint8', typeEmitter='Platform_Type')
implTypes.createImplementationDataType('uint16', lowerLimit=0, upperLimit=65535, baseTypeRef='/DataTypes/BaseTypes/uint16', typeEmitter='Platform_Type')
#Create implementation data type with offset and scaling
implTypes.createImplementationDataTypeRef('VehicleSpeed_T',
implementationTypeRef = '/DataTypes/ImplementationTypes/uint16',
lowerLimit = 0,
upperLimit = 65535,
offset = 0,
scaling = 1/64,
forceFloat = True)
#Create implementation data type with enumeration table (also known as value table)
implTypes.createImplementationDataTypeRef('OffOn_T', implementationTypeRef = '/DataTypes/ImplementationTypes/uint8',
valueTable = ['OffOn_Off',
'OffOn_On',
'OffOn_Error',
'OffOn_NotAvailable'
])
#Export as XML
ws.saveXML('DataTypes.arxml')
createImplementationDataTypePtr
- Package.createImplementationDataTypePtr(name, baseTypeRef, [swImplPolicy=None], [category='DATA_REFERENCE', [targetCategory=VALUE], [adminData=None])
Creates a new implementation data type that is a pointer to a base data type. This is similar to a pointer type definition in C.
- 参数
name (str) – ShortName of the datatype.
baseTypeRef (str) – Reference to (existing) base type object.
swImplPolicy (str) – Optional swImplPolicy.
category (str) – Optional category string (for the datatype)
targetCategory (str) – Optional category string for the inner target property.
adminData (None, AdminData.) – Optional AdminData.
- 返回类型
Example
import autosar
#Setup
ws = autosar.workspace(version="4.2.2")
package=ws.createPackage('DataTypes', role='DataType')
baseTypes=package.createSubPackage('BaseTypes')
baseTypes.createSwBaseType('uint8', 8, nativeDeclaration='uint8')
implTypes = package.createSubPackage('ImplementationTypes')
#Create implementation data type that is a pointer to uint8
implTypes.createImplementationDataTypePtr('ByteBuffer_T', baseTypeRef = '/DataTypes/BaseTypes/uint8')
#Export as XML
ws.saveXML('DataTypes.arxml')
createImplementationRecordDataType
- Package.createImplementationRecordDataType(name, elements[, swCalibrationAccess = ''][, category = 'STRUCTURE'][, adminData = None])
Creates an implementation record data type and adds it to the package.
- 参数
name (str) – ShortName of the new data type
elements (str) – List containing tuples. First tuple element is the record name (string), second tuple element is a type reference (string).
swCalibrationAccess (str) – Optional calibration access
category (str) – Category for the (outer) array data type
targetCategory (str) – Category for the (inner) array element
adminData (None, AdminData.) – Optional AdminData.
- 返回类型
createSwBaseType
- Package.createSwBaseType(name[, size=None][, encoding=None][, nativeDeclaration=None][, category='FIXED_LENGTH'][, adminData=None])
Creates a new SwBaseType and adds it to the package.
- 参数
name (str) – ShortName of the new datatype
size (int) – Size of type in bits
encoding (str) – Encoding string
nativeDeclaration (str) – Used to map this base type to one of the native types known to the RTE
category (str) – Category string
adminData (None, AdminData.) – Optional AdminData.
Example
import autosar
ws = autosar.workspace("4.2.2")
platform = ws.createPackage('AUTOSAR_Platform')
basetypes = platform.createSubPackage('BaseTypes')
basetypes.createSwBaseType('boolean', 1, encoding = 'BOOLEAN', nativeDeclaration='boolean')
basetypes.createSwBaseType('float32', 32, encoding = 'IEEE754', nativeDeclaration = 'float32')
basetypes.createSwBaseType('float64', 64, encoding = 'IEEE754', nativeDeclaration = 'float64')
basetypes.createSwBaseType('sint8', 8, nativeDeclaration='sint8')
basetypes.createSwBaseType('sint16', 16, nativeDeclaration='uint16')
basetypes.createSwBaseType('sint32', 32, nativeDeclaration='sint32')
basetypes.createSwBaseType('uint8', 8, nativeDeclaration='uint8')
basetypes.createSwBaseType('uint16', 16, nativeDeclaration='uint16')
basetypes.createSwBaseType('uint32', 32, nativeDeclaration='uint32')
ws.saveXML('PlatformTypes_AR4.arxml')
createModeDeclarationGroup
- Package.createModeDeclarationGroup(name[, modeDeclarations=None][, initialMode=None][, category=None][, adminData=None])
Creates a new ModeDeclarationGroup and adds it to the package.
- 参数
name (str) – ShortName of the object
modeDeclarations (list(str)) – List of mode declaration names
initialMode (str) – Initial mode value (must be one of strings from modeDeclarations list)
category (str) – Optional category
adminData (None, AdminData.) – Optional AdminData.
- 返回类型
createClientServerInterface
- Package.createClientServerInterface(name, operations[, errors=None][, isService=False][, serviceKind = None][, adminData=None])
Creates a new ClientServerInterface and adds it to the package.
- 参数
name (str) – ShortName of the port interface
operations (list(str)) – List of names to be created as of Operation
errors (ApplicationError or list(ApplicationError)) – Possible errors that can be returned. Errors must be assigned here first, before you can use them in individual operations.
isService (bool) – Set this to True for service interfaces
serviceKind (str) – Optional serviceKind string
adminData (None, AdminData.) – Optional AdminData.
- 返回类型
Example
import autosar
def create_packages(ws):
package=ws.createPackage('DataTypes', role='DataType')
package.createSubPackage('CompuMethods', role='CompuMethod')
package.createSubPackage('DataConstrs', role='DataConstraint')
package.createSubPackage('BaseTypes')
ws.createPackage('PortInterfaces', role="PortInterface")
def create_data_types(ws):
basetypes = ws.find('/DataTypes/BaseTypes')
basetypes.createSwBaseType('boolean', 1, 'BOOLEAN')
basetypes.createSwBaseType('uint32', 32, nativeDeclaration='uint32')
package = ws.find('DataTypes')
package.createImplementationDataType('boolean', valueTable=['FALSE','TRUE'], baseTypeRef='/DataTypes/BaseTypes/boolean', typeEmitter='Platform_Type')
package.createImplementationDataType('uint32', lowerLimit=0, upperLimit=4294967295, baseTypeRef='/DataTypes/BaseTypes/uint32', typeEmitter='Platform_Type')
def setup_ws():
ws = autosar.workspace(version='4.2.2')
create_packages(ws)
create_data_types(ws)
return ws
ws = setup_ws()
package = ws.find('/PortInterfaces')
#Creates new port interface with two operations
portInterface=package.createClientServerInterface('FreeRunningTimer_I', ['GetTime', 'IsTimerElapsed'])
#Individually create arguments for each operation using the returned object
portInterface['GetTime'].createOutArgument('value', '/DataTypes/uint32')
portInterface["IsTimerElapsed"].createInArgument("startTime", '/DataTypes/uint32')
portInterface["IsTimerElapsed"].createInArgument("duration", '/DataTypes/uint32')
portInterface["IsTimerElapsed"].createOutArgument("result", '/DataTypes/boolean')
#Save ARXML ...
ws.saveXML('PortInterfaces.arxml', filters=['/PortInterfaces'])
#... or generate DaVinci project
autosar.util.createDcf(ws).save('davinci', 'Example', force=True)
createModeSwitchInterface
- Package.createModeSwitchInterface(name[, modeGroup = None][, isService=False][, adminData=None])
Creates a new ModeSwitchInterface and adds it to the package.
- 参数
- 返回类型
createNvDataInterface
- Package.createNvDataInterface(name[, nvDatas=None][, isService=False][, serviceKind = None][, adminData=None])
Creates a new NvDataInterface and adds it to the package.
- 参数
name (str) – ShortName of the port interface
nvDatas (DataElement or list(DataElement)) – data element(s)
isService (bool) – Set this to True for service interfaces
adminData (None, AdminData.) – Optional AdminData.
- 返回类型
NvDataInterface
createParameterInterface
- Package.createParameterInterface(name, parameters=None, isService=False, adminData=None)
Creates a new ParameterInterface and adds it to the package.
- 参数
name (str) – ShortName of the port interface
parameters (ParameterDataPrototype or list(ParameterDataPrototype)) – Parameter or parameters
isService (bool) – Enables the isService attribute
adminData (None, AdminData.) – Optional AdminData.
- 返回类型
createSenderReceiverInterface
- Package.createSenderReceiverInterface(name[, dataElements=None][, isService=False][, serviceKind = None][, adminData=None])
Creates a new SenderReceiverInterface and adds it to the package.
- 参数
name (str) – ShortName of the port interface
dataElements (list(DataElement) or DataElement) – Data element(s) in this port interface
isService (bool) – Sets the isService attribute
serviceKind (str) – Optional serviceKind string
adminData (None, AdminData.) – Optional AdminData.
- 返回类型
Examples
Port interface with single data element
import autosar
def create_workspace_and_datatypes():
ws = autosar.workspace(version="4.2.2")
package = ws.createPackage('DataTypes', role='DataType')
package.createSubPackage('CompuMethods', role='CompuMethod')
package.createSubPackage('DataConstrs', role='DataConstraint')
baseTypes = package.createSubPackage('BaseTypes')
baseTypes.createSwBaseType('uint8', 8, nativeDeclaration='uint8')
implTypes = package.createSubPackage('ImplementationTypes')
implTypes.createImplementationDataType('uint8', lowerLimit=0, upperLimit=255,
baseTypeRef='/DataTypes/BaseTypes/uint8', typeEmitter='Platform_Type')
implTypes.createImplementationDataTypeRef('OffOn_T', implementationTypeRef = '/DataTypes/ImplementationTypes/uint8',
valueTable = ['OffOn_Off',
'OffOn_On',
'OffOn_Error',
'OffOn_NotAvailable'
])
package = ws.createPackage('PortInterfaces', role='PortInterface')
return ws
#Create SenderReceiver interface with single data element
ws = create_workspace_and_datatypes()
package = ws.find('PortInterfaces')
package.createSenderReceiverInterface('HeaterPwrStat_I', autosar.element.DataElement('HeaterPwrStat', '/DataTypes/ImplementationTypes/OffOn_T'))
#Save only the port interfaces portion to XML
ws.saveXML('PortInterfaces.arxml', filters=['/PortInterfaces'])
createSubPackage
- Package.createPackage(name[, role=None])
Creates a new Package and appends it to this Package as a sub-package.
- 参数
name (str) – ShortName of the new package
role (str) – Optional package role
- 返回类型
Example
import autosar
ws = autosar.workspace("4.2.2")
datatypes = ws.createPackage('DataTypes')
datatypes.createSubPackage('BaseTypes')
datatypes.createSubPackage('ImplementationTypes', role='DataType')
createSoftwareAddressMethod
- Package.createSoftwareAddressMethod(name)
Creates a new SoftwareAddressMethod and adds it to the package.
- 参数
name (str) – ShortName of the address method
- 返回类型
createUnit
- Package.createUnit(shortName[, displayName = None][, offset = None][, scaling = None])
Creates a new Unit and adds it to the package.
- 参数
name (str) – ShortName of the new unit.
displayName (str) – Optional Display name (Will default to shortName if not set)
offset (None, int, float) – Optional offset
factor (None, int, float) – Optional scaling factor
- 返回类型
createDataTypeMappingSet
Parameter Details
swCalibrationAccess
Value |
Description |
---|---|
|
No calibration access set |
|
Create default calibration access value as set by Workspace.profile.swCalibrationAccessDefault |
|
The element will not be accessible by external tools |
|
Read only access |
|
Read-write access |
valueTable
The valueTable parameter accepts three different formats:
List of strings
List of 2-tuples
List of 3-tuples
List of strings
List of text values. LowerLimit starts at 0 and is automatically incremented by 1 for each element in the list. The UpperLimit follows LowerLimit for each element.
List of 2-tuples
The first element of the tuple is used as both lowerLimit and upperLimit (int). The second element is the text value (str).
List of 3-tuples
The first element of the tuple is lowerLimit (int). The Second element is the upperLimit (int). The third element is the text value (str).
bitmask
The bitmask parameter is a list of 2-tuples. The first element of the tuple is the bitmask (int). The second elementof is the symbol (str).