Unit

XML tag

<UNIT>

Module

autosar.datatype

Inherits

autosar.element.Element

Units are used to name physical units.

Usage

import autosar

def setup():
    ws = autosar.workspace(version="4.2.2")
    package=ws.createPackage('ApplicationTypes', role='DataType')
    package.createSubPackage('Units', role='Unit')
    return ws

ws = setup()
package = ws.findRolePackage('Unit')
package.createUnit('Percent', '%')
ws.saveXML('DataTypes.arxml', filters=['/ApplicationTypes'])

Factory Methods

Units can also be created automatically while creating application or implementation data types. For this mechanism to work you must first set the Unit package rols.

Constructor

datatype.Unit(name, displayName[, factor = None][, offset = None][, parent = None])
参数
  • name (str) – Short name.

  • displayName (bool) – Display name.

  • factor (None, int, float) – Scaling factor.

  • offset (None, int, float) – Scaling offset.

  • parent (Package) – Parent package.

Attributes

For inherited attributes see autosar.element.Element.

Name

Type

Description

displayName

str

<DISPLAY-NAME> (Could be the same as shortName)

factor

None, int or float

<FACTOR-SI-TO-UNIT>

offset

None, int or float

<OFFSET-SI-TO-UNIT>