DataConstraint¶
| XML tag | <DATA-CONSTR> |
| Module | autosar.datatype |
| Inherits | autosar.element.Element |
A DataConstraint is used to decorate other data types with one or more constraints. Use the dataConstraintRef property of the ApplicationDataType or ImplementationDataType classes to access the reference string.
Usage¶
import autosar
def setup():
ws = autosar.workspace(version="4.2.2")
package=ws.createPackage('ApplicationTypes', role='DataType')
package.createSubPackage('DataConstrs', role='DataConstraint')
return ws
ws = setup()
package = ws.findRolePackage('DataConstraint')
package.createInternalDataConstraint('uint8_DataConstraint', 0, 255)
ws.saveXML('DataTypes.arxml', filters=['/ApplicationTypes'])
Constructor¶
-
datatype.DataConstraint(name, rules[, constraintLevel = None][, parent = None][, adminData = None])¶ Parameters: The rule parameter should either be a dictionary or a list of dictionaries. Each dictionary in rules is expected to have three keys:
- type: (‘internalConstraint’ or ‘physicalConstraint’).
- lowerLimit: Lower limit of the constraint (int, float).
- upperLimit: Lower limit of the constraint (int, float).
- lowerLimitType: Type of lower limit (
'OPEN','CLOSED'). - upperLimitType: Type of lower limit (
'OPEN','CLOSED').
Attributes¶
For inherited attributes see autosar.element.Element.
| Name | Type | Description |
|---|---|---|
| level | None, int | <CONSTR-LEVEL> |
| rules | list of InternalConstraint or PhysicalConstraint | <DATA-CONSTR-RULE> |
Public Properties¶
All properties are limited to situations where the constraint only has one internal rule. Multi-rule support will be added in a future release.
| Name | Type | Access Type |
|---|---|---|
| constraintLevel | int | Get |
| lowerLimit | int, float | Get |
| upperLimit | int, float | Get |
| lowerLimitType | str | Get |
| upperLimitType | str | Get |
Public Methods¶
Most methods are currently limited to situations where the constraint only has one internal rule. Multi-rule support will be added in a future release.