Skip to content

Commit 823780d

Browse files
committed
Improved API documentation for mode and datatype
1 parent 996b1d2 commit 823780d

16 files changed

+453
-56
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
.. _ar4_datatype_ApplicationDataType:
2+
3+
ApplicationDataType
4+
======================
5+
6+
.. table::
7+
:align: left
8+
9+
+--------------------+------------------------------------------------------+
10+
| XML tag | - |
11+
+--------------------+------------------------------------------------------+
12+
| Module | autosar.datatype |
13+
+--------------------+------------------------------------------------------+
14+
| Inherits | :ref:`autosar.element.Element <ar4_element_Element>` |
15+
+--------------------+------------------------------------------------------+
16+
17+
Base class for AUTOSAR application data types.
18+
19+
20+
Attributes
21+
----------
22+
23+
For inherited attributes see :ref:`autosar.element.Element <ar4_element_Element>`.
24+
25+
.. table::
26+
:align: left
27+
28+
+-----------------------------+---------------------+-----------------------------+
29+
| Name | Type | Description |
30+
+=============================+=====================+=============================+
31+
| **variantProps** | list | list of type properties |
32+
+-----------------------------+---------------------+-----------------------------+
33+
34+
Properties
35+
----------
36+
37+
Properties
38+
----------
39+
40+
.. table::
41+
:align: left
42+
43+
+--------------------------+---------------------------+----------+------------------------------------------------------------------------+
44+
| Name | Type | Access | Description |
45+
+==========================+===========================+==========+========================================================================+
46+
| **compuMethodRef** | *str* | Get | Returns compu-method reference from first item in variantProps list |
47+
+--------------------------+---------------------------+----------+------------------------------------------------------------------------+
48+
| **dataConstraintRef** | *str* | Get | Returns data constraint reference from first item in variantProps list |
49+
+--------------------------+---------------------------+----------+------------------------------------------------------------------------+
50+
| **unitRef** | *str* | Get | Returns unit reference from first item in variantProps list |
51+
+--------------------------+---------------------------+----------+------------------------------------------------------------------------+
52+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
.. _ar4_datatype_DataTypeMap:
2+
3+
DataTypeMap
4+
===========
5+
6+
.. table::
7+
:align: left
8+
9+
+--------------------+------------------------------------------------------+
10+
| XML tag | <DATA-TYPE-MAP> |
11+
+--------------------+------------------------------------------------------+
12+
| Module | autosar.datatype |
13+
+--------------------+------------------------------------------------------+
14+
| Inherits | :ref:`autosar.element.Element <ar4_element_Element>` |
15+
+--------------------+------------------------------------------------------+
16+
17+
Mapping from ApplicationDataType to ImplementationDataType.
18+
19+
20+
Factory Methods
21+
---------------
22+
23+
* :ref:`DataTypeMappingSet.createDataTypeMapping <ar4_datatype_DataTypeMappingSet_createDataTypeMapping>`
24+
25+
26+
Attributes
27+
----------
28+
29+
For inherited attributes see :ref:`autosar.element.Element <ar4_element_Element>`.
30+
31+
.. table::
32+
:align: left
33+
34+
+-------------------------------+-------------------+---------------------------------------------------------+
35+
| Name | Type | Description |
36+
+===============================+===================+=========================================================+
37+
| **applicationDataTypeRef** | str | Reference to :ref:`ar4_datatype_ApplicationDataType` |
38+
+-------------------------------+-------------------+---------------------------------------------------------+
39+
| **implementationDataTypeRef** | str | Reference to :ref:`ar4_datatype_ImplementationDataType` |
40+
+-------------------------------+-------------------+---------------------------------------------------------+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
.. _ar4_datatype_DataTypeMappingSet:
2+
3+
DataTypeMappingSet
4+
==================
5+
6+
.. table::
7+
:align: left
8+
9+
+--------------------+------------------------------------------------------+
10+
| XML tag | <DATA-TYPE-MAPPING-SET> |
11+
+--------------------+------------------------------------------------------+
12+
| Module | autosar.datatype |
13+
+--------------------+------------------------------------------------------+
14+
| Inherits | :ref:`autosar.element.Element <ar4_element_Element>` |
15+
+--------------------+------------------------------------------------------+
16+
17+
This class contains type mappings between ApplicationDataTypes and ImplementationDataTypes.
18+
In addition, it can contain type mappings between ModeDeclarationGroups and ImplementationDataTypes.
19+
20+
Factory Methods
21+
---------------
22+
23+
* :ref:`Package.createDataTypeMappingSet <ar4_package_Package_createDataTypeMappingSet>`
24+
25+
26+
Attributes
27+
----------
28+
29+
For inherited attributes see :ref:`autosar.element.Element <ar4_element_Element>`.
30+
31+
.. table::
32+
:align: left
33+
34+
+--------------------------+-------------------+-----------------------------------------------------+
35+
| Name | Type | Description |
36+
+==========================+===================+=====================================================+
37+
| **applicationTypeMap** | dict | Application data type mappings |
38+
+--------------------------+-------------------+-----------------------------------------------------+
39+
| **modeRequestMap** | dict | Mode request mappings |
40+
+--------------------------+-------------------+-----------------------------------------------------+
41+
42+
The ARXML definition uses lists containing mappings while Python uses dictionaries.
43+
For the **applicationTypeMap** dictionary, each key is a reference to an application data type and each value
44+
is a reference to an implementation data type.
45+
Likewise for the *modeRequestMap* dictionary, each key is a reference to a mode declaration group and each value
46+
is a reference to an implementation data type.
47+
48+
Public Methods
49+
--------------
50+
51+
* :ref:`ar4_datatype_DataTypeMappingSet_createDataTypeMapping`
52+
* :ref:`ar4_datatype_DataTypeMappingSet_createModeRequestMapping`
53+
* :ref:`ar4_datatype_DataTypeMappingSet_add`
54+
* :ref:`ar4_datatype_DataTypeMappingSet_getDataTypeMapping`
55+
* :ref:`ar4_datatype_DataTypeMappingSet_getModeRequestMapping`
56+
* :ref:`ar4_datatype_DataTypeMappingSet_findMappedDataTypeRef`
57+
* :ref:`ar4_datatype_DataTypeMappingSet_findMappedModeRequestRef`
58+
* :ref:`ar4_datatype_DataTypeMappingSet_findMappedDataType`
59+
* :ref:`ar4_datatype_DataTypeMappingSet_findMappedModeRequest`
60+
61+
Method Description
62+
--------------------
63+
64+
.. _ar4_datatype_DataTypeMappingSet_createDataTypeMapping:
65+
66+
createDataTypeMapping
67+
~~~~~~~~~~~~~~~~~~~~~
68+
69+
.. method:: DataTypeMappingSet.createDataTypeMapping(applicationDataTypeRef : str, implementationDataTypeRef : str)
70+
71+
Creates a new type mapping between an application type (reference) and implementation data type (reference).
72+
The created mapping is added to the internal applicationTypeMap dictionary.
73+
74+
:param str applicationDataTypeRef: Reference to an ApplicationDataType
75+
:param str implementationDataTypeRef: Reference to an :ref:`ar4_datatype_ImplementationDataType`
76+
77+
.. _ar4_datatype_DataTypeMappingSet_createModeRequestMapping:
78+
79+
createModeRequestMapping
80+
~~~~~~~~~~~~~~~~~~~~~~~~
81+
82+
.. method:: DataTypeMappingSet.createModeRequestMapping(modeDeclarationGroupRef : str, implementationDataTypeRef : str)
83+
84+
Creates a new type mapping between a mode declaration group (reference) and implementation data type (reference).
85+
The created mapping is added to the internal modeRequestMap dictionary.
86+
87+
:param str modeDeclarationGroupRef: Reference to a :ref:`ar4_mode_ModeDeclarationGroup`
88+
:param str implementationDataTypeRef: Reference to an :ref:`ar4_datatype_ImplementationDataType`
89+
90+
.. _ar4_datatype_DataTypeMappingSet_add:
91+
92+
add
93+
~~~
94+
95+
.. method:: DataTypeMappingSet.add(item)
96+
97+
Adds a user-created mapping to this mapping set.
98+
If the item is of type :ref:`ar4_datatype_DataTypeMap` it gets inserted into to the applicationTypeMap dictionary.
99+
Likewise, if the item is of type :ref:`ar4_datatype_ModeRequestTypeMap` it gets inserted into to the modeRequestMap dictionary.
100+
101+
:param item: Reference to an ApplicationDataType
102+
:type item: :ref:`ar4_datatype_DataTypeMap` or :ref:`ar4_datatype_ModeRequestTypeMap`
103+
104+
.. _ar4_datatype_DataTypeMappingSet_getDataTypeMapping:
105+
106+
getDataTypeMapping
107+
~~~~~~~~~~~~~~~~~~
108+
109+
.. method:: DataTypeMappingSet.getDataTypeMapping(applicationDataTypeRef : str)
110+
111+
Returns the mapping object that is currently associated with the given application data type reference.
112+
If the reference string is not found in the internal applicationTypeMap dictionary, None is returned.
113+
114+
:param str applicationDataTypeRef: Reference to an :ref:`ar4_datatype_ApplicationDataType`
115+
:rtype: :ref:`ar4_datatype_DataTypeMappingSet` or None
116+
117+
.. _ar4_datatype_DataTypeMappingSet_getModeRequestMapping:
118+
119+
getModeRequestMapping
120+
~~~~~~~~~~~~~~~~~~~~~
121+
122+
.. method:: DataTypeMappingSet.getModeRequestMapping(modeDeclarationGroupRef : str)
123+
124+
Returns the mapping object that is currently associated with the given mode declaration group reference.
125+
If the reference string is not found in the internal modeRequestMap dictionary, None is returned.
126+
127+
:param str modeDeclarationGroupRef: Reference to a
128+
:rtype: :ref:`ar4_mode_ModeDeclarationGroup` or None
129+
130+
.. _ar4_datatype_DataTypeMappingSet_findMappedDataTypeRef:
131+
132+
findMappedDataTypeRef
133+
~~~~~~~~~~~~~~~~~~~~~
134+
135+
.. method:: DataTypeMappingSet.findMappedDataTypeRef(applicationDataTypeRef : str)
136+
137+
Same as :ref:`ar4_datatype_DataTypeMappingSet_getDataTypeMapping` but instead returns the reference to the mapped implementation data type.
138+
Returns None in case the application data type reference is not part of the internal applicationTypeMap dictionary.
139+
140+
:param str applicationDataTypeRef: Reference to an :ref:`ar4_datatype_ApplicationDataType`
141+
:rtype: str
142+
143+
.. _ar4_datatype_DataTypeMappingSet_findMappedModeRequestRef:
144+
145+
findMappedModeRequestRef
146+
~~~~~~~~~~~~~~~~~~~~~~~~
147+
148+
.. method:: DataTypeMappingSet.findMappedModeRequestRef(modeDeclarationGroupRef : str)
149+
150+
Same as :ref:`ar4_datatype_DataTypeMappingSet_getModeRequestMapping` but instead returns the reference to the mapped implementation data type.
151+
Returns None in case the mode declaration group reference is not part of the internal modeRequestMap dictionary.
152+
153+
:param str applicationDataTypeRef: :ref:`ar4_mode_ModeDeclarationGroup`
154+
:rtype: str
155+
156+
.. _ar4_datatype_DataTypeMappingSet_findMappedDataType:
157+
158+
findMappedDataType
159+
~~~~~~~~~~~~~~~~~~~~~
160+
161+
.. method:: DataTypeMappingSet.findMappedDataType(applicationDataTypeRef : str)
162+
163+
Same as :ref:`ar4_datatype_DataTypeMappingSet_findMappedDataTypeRef` but instead returns the
164+
referenced to :ref:`ar4_datatype_ImplementationDataType` object.
165+
166+
:param str applicationDataTypeRef: Reference to a :ref:`ar4_datatype_ApplicationDataType`
167+
:rtype: :ref:`ar4_datatype_ImplementationDataType`
168+
169+
.. _ar4_datatype_DataTypeMappingSet_findMappedModeRequest:
170+
171+
findMappedModeRequest
172+
~~~~~~~~~~~~~~~~~~~~~
173+
174+
.. method:: DataTypeMappingSet.findMappedModeRequest(modeDeclarationGroupRef : str)
175+
176+
Same as :ref:`ar4_datatype_DataTypeMappingSet_findMappedModeRequestRef` but instead returns the
177+
referenced to :ref:`ar4_datatype_ImplementationDataType` object.
178+
179+
:param str modeDeclarationGroupRef: Reference to a :ref:`ar4_mode_ModeDeclarationGroup`
180+
:rtype: :ref:`ar4_datatype_ImplementationDataType`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import autosar
2+
3+
ws = autosar.workspace("4.2.2")
4+
package = ws.createPackage('AUTOSAR_Platform')
5+
baseTypes = package.createSubPackage('BaseTypes')
6+
baseTypes.createSwBaseType('dtRef_const_VOID', 1, encoding = 'VOID', nativeDeclaration = 'void')
7+
baseTypes.createSwBaseType('dtRef_VOID', 1, encoding = 'VOID', nativeDeclaration = 'void')
8+
baseTypes.createSwBaseType('boolean', 8, encoding = 'BOOLEAN', nativeDeclaration='boolean')
9+
baseTypes.createSwBaseType('float32', 32, encoding = 'IEEE754', nativeDeclaration = 'float32')
10+
baseTypes.createSwBaseType('float64', 64, encoding = 'IEEE754', nativeDeclaration = 'float64')
11+
baseTypes.createSwBaseType('sint8', 8, encoding = '2C', nativeDeclaration='sint8')
12+
baseTypes.createSwBaseType('sint16', 16, encoding = '2C', nativeDeclaration='uint16')
13+
baseTypes.createSwBaseType('sint32', 32, encoding = '2C', nativeDeclaration='sint32')
14+
baseTypes.createSwBaseType('uint8', 8, nativeDeclaration='uint8')
15+
baseTypes.createSwBaseType('uint16', 16, nativeDeclaration='uint16')
16+
baseTypes.createSwBaseType('uint32', 32, nativeDeclaration='uint32')
17+
print(ws.toXML())

doc/autosar4_api/datatype/index.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ DataType
66
:glob:
77

88
swbase
9-
implementation_type
9+
implementation_data_type
10+
application_data_type
11+
datatype_mapping_set
12+
data_type_map
13+
mode_request_type_map
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
.. _ar4_datatype_ModeRequestTypeMap:
2+
3+
ModeRequestTypeMap
4+
==================
5+
6+
.. table::
7+
:align: left
8+
9+
+--------------------+------------------------------------------------------+
10+
| XML tag | <MODE-REQUEST-TYPE-MAP> |
11+
+--------------------+------------------------------------------------------+
12+
| Module | autosar.datatype |
13+
+--------------------+------------------------------------------------------+
14+
| Inherits | :ref:`autosar.element.Element <ar4_element_Element>` |
15+
+--------------------+------------------------------------------------------+
16+
17+
Mapping from ModeGroupDeclaration to ImplementationDataType.
18+
19+
20+
Factory Methods
21+
---------------
22+
23+
* :ref:`DataTypeMappingSet.createModeRequestMapping <ar4_datatype_DataTypeMappingSet_createModeRequestMapping>`
24+
25+
26+
Attributes
27+
----------
28+
29+
For inherited attributes see :ref:`autosar.element.Element <ar4_element_Element>`.
30+
31+
.. table::
32+
:align: left
33+
34+
+-------------------------------+-------------------+---------------------------------------------------------+
35+
| Name | Type | Description |
36+
+===============================+===================+=========================================================+
37+
| **modeDeclarationGroupRef** | str | Reference to :ref:`ar4_mode_ModeDeclarationGroup` |
38+
+-------------------------------+-------------------+---------------------------------------------------------+
39+
| **implementationDataTypeRef** | str | Reference to :ref:`ar4_datatype_ImplementationDataType` |
40+
+-------------------------------+-------------------+---------------------------------------------------------+

0 commit comments

Comments
 (0)