-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement NvDataInterface and ParameterInterface
- Loading branch information
Showing
14 changed files
with
1,032 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<AUTOSAR xsi:schemaLocation="http://autosar.org/schema/r4.0 AUTOSAR_00051.xsd" xmlns="http://autosar.org/schema/r4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<AR-PACKAGES> | ||
<AR-PACKAGE> | ||
<SHORT-NAME>DataTypes</SHORT-NAME> | ||
<AR-PACKAGES> | ||
<AR-PACKAGE> | ||
<SHORT-NAME>ImplementationDataTypes</SHORT-NAME> | ||
<ELEMENTS> | ||
<IMPLEMENTATION-DATA-TYPE> | ||
<SHORT-NAME>InactiveActive_T</SHORT-NAME> | ||
<CATEGORY>VALUE</CATEGORY> | ||
<SW-DATA-DEF-PROPS> | ||
<SW-DATA-DEF-PROPS-VARIANTS> | ||
<SW-DATA-DEF-PROPS-CONDITIONAL> | ||
<BASE-TYPE-REF DEST="SW-BASE-TYPE">AUTOSAR_Platform/BaseTypes/uint8</BASE-TYPE-REF> | ||
</SW-DATA-DEF-PROPS-CONDITIONAL> | ||
</SW-DATA-DEF-PROPS-VARIANTS> | ||
</SW-DATA-DEF-PROPS> | ||
</IMPLEMENTATION-DATA-TYPE> | ||
</ELEMENTS> | ||
</AR-PACKAGE> | ||
</AR-PACKAGES> | ||
</AR-PACKAGE> | ||
</AR-PACKAGES> | ||
</AUTOSAR> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<AUTOSAR xsi:schemaLocation="http://autosar.org/schema/r4.0 AUTOSAR_00051.xsd" xmlns="http://autosar.org/schema/r4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<AR-PACKAGES> | ||
<AR-PACKAGE> | ||
<SHORT-NAME>PortInterfaces</SHORT-NAME> | ||
<ELEMENTS> | ||
<NV-DATA-INTERFACE> | ||
<SHORT-NAME>DataInterface1</SHORT-NAME> | ||
<NV-DATAS> | ||
<VARIABLE-DATA-PROTOTYPE> | ||
<SHORT-NAME>Data1</SHORT-NAME> | ||
<TYPE-TREF DEST="IMPLEMENTATION-DATA-TYPE">/AUTOSAR_Platform/ImplementationDataTypes/uint8</TYPE-TREF> | ||
</VARIABLE-DATA-PROTOTYPE> | ||
</NV-DATAS> | ||
</NV-DATA-INTERFACE> | ||
<NV-DATA-INTERFACE> | ||
<SHORT-NAME>DataInterface2</SHORT-NAME> | ||
<NV-DATAS> | ||
<VARIABLE-DATA-PROTOTYPE> | ||
<SHORT-NAME>Data1</SHORT-NAME> | ||
<TYPE-TREF DEST="IMPLEMENTATION-DATA-TYPE">/AUTOSAR_Platform/ImplementationDataTypes/uint8</TYPE-TREF> | ||
</VARIABLE-DATA-PROTOTYPE> | ||
<VARIABLE-DATA-PROTOTYPE> | ||
<SHORT-NAME>Data2</SHORT-NAME> | ||
<TYPE-TREF DEST="IMPLEMENTATION-DATA-TYPE">/AUTOSAR_Platform/ImplementationDataTypes/uint8</TYPE-TREF> | ||
</VARIABLE-DATA-PROTOTYPE> | ||
</NV-DATAS> | ||
</NV-DATA-INTERFACE> | ||
</ELEMENTS> | ||
</AR-PACKAGE> | ||
</AR-PACKAGES> | ||
</AUTOSAR> |
32 changes: 32 additions & 0 deletions
32
examples/xml/port_interface/data/parameter_interface.arxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<AUTOSAR xsi:schemaLocation="http://autosar.org/schema/r4.0 AUTOSAR_00051.xsd" xmlns="http://autosar.org/schema/r4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<AR-PACKAGES> | ||
<AR-PACKAGE> | ||
<SHORT-NAME>PortInterfaces</SHORT-NAME> | ||
<ELEMENTS> | ||
<PARAMETER-INTERFACE> | ||
<SHORT-NAME>ParameterInterface1</SHORT-NAME> | ||
<PARAMETERS> | ||
<PARAMETER-DATA-PROTOTYPE> | ||
<SHORT-NAME>Param1</SHORT-NAME> | ||
<TYPE-TREF DEST="IMPLEMENTATION-DATA-TYPE">/AUTOSAR_Platform/ImplementationDataTypes/uint8</TYPE-TREF> | ||
</PARAMETER-DATA-PROTOTYPE> | ||
</PARAMETERS> | ||
</PARAMETER-INTERFACE> | ||
<PARAMETER-INTERFACE> | ||
<SHORT-NAME>ParameterInterface2</SHORT-NAME> | ||
<PARAMETERS> | ||
<PARAMETER-DATA-PROTOTYPE> | ||
<SHORT-NAME>Param1</SHORT-NAME> | ||
<TYPE-TREF DEST="IMPLEMENTATION-DATA-TYPE">/AUTOSAR_Platform/ImplementationDataTypes/uint8</TYPE-TREF> | ||
</PARAMETER-DATA-PROTOTYPE> | ||
<PARAMETER-DATA-PROTOTYPE> | ||
<SHORT-NAME>Param2</SHORT-NAME> | ||
<TYPE-TREF DEST="IMPLEMENTATION-DATA-TYPE">/AUTOSAR_Platform/ImplementationDataTypes/uint8</TYPE-TREF> | ||
</PARAMETER-DATA-PROTOTYPE> | ||
</PARAMETERS> | ||
</PARAMETER-INTERFACE> | ||
</ELEMENTS> | ||
</AR-PACKAGE> | ||
</AR-PACKAGES> | ||
</AUTOSAR> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<AUTOSAR xsi:schemaLocation="http://autosar.org/schema/r4.0 AUTOSAR_00051.xsd" xmlns="http://autosar.org/schema/r4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<AR-PACKAGES> | ||
<AR-PACKAGE> | ||
<SHORT-NAME>AUTOSAR_Platform</SHORT-NAME> | ||
<AR-PACKAGES> | ||
<AR-PACKAGE> | ||
<SHORT-NAME>BaseTypes</SHORT-NAME> | ||
<ELEMENTS> | ||
<SW-BASE-TYPE> | ||
<SHORT-NAME>uint8</SHORT-NAME> | ||
<BASE-TYPE-SIZE>8</BASE-TYPE-SIZE> | ||
</SW-BASE-TYPE> | ||
</ELEMENTS> | ||
</AR-PACKAGE> | ||
<AR-PACKAGE> | ||
<SHORT-NAME>ImplementationDataTypes</SHORT-NAME> | ||
<ELEMENTS> | ||
<IMPLEMENTATION-DATA-TYPE> | ||
<SHORT-NAME>uint8</SHORT-NAME> | ||
<CATEGORY>VALUE</CATEGORY> | ||
<SW-DATA-DEF-PROPS> | ||
<SW-DATA-DEF-PROPS-VARIANTS> | ||
<SW-DATA-DEF-PROPS-CONDITIONAL> | ||
<BASE-TYPE-REF DEST="SW-BASE-TYPE">/AUTOSAR_Platform/BaseTypes/uint8</BASE-TYPE-REF> | ||
</SW-DATA-DEF-PROPS-CONDITIONAL> | ||
</SW-DATA-DEF-PROPS-VARIANTS> | ||
</SW-DATA-DEF-PROPS> | ||
</IMPLEMENTATION-DATA-TYPE> | ||
</ELEMENTS> | ||
</AR-PACKAGE> | ||
</AR-PACKAGES> | ||
</AR-PACKAGE> | ||
</AR-PACKAGES> | ||
</AUTOSAR> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
""" | ||
Sender-receiver port interface examples | ||
""" | ||
import os | ||
import autosar | ||
import autosar.xml.element as ar_element | ||
|
||
|
||
def create_platform_types(packages: dict[str, ar_element.Package]): | ||
""" | ||
Creates necessary platform types | ||
""" | ||
uint8_base_type = ar_element.SwBaseType('uint8', size=8) | ||
packages["PlatformBaseTypes"].append(uint8_base_type) | ||
sw_data_def_props = ar_element.SwDataDefPropsConditional(base_type_ref=uint8_base_type.ref()) | ||
uint8_impl_type = ar_element.ImplementationDataType("uint8", | ||
category="VALUE", | ||
sw_data_def_props=sw_data_def_props) | ||
packages["PlatformImplementationDataTypes"].append(uint8_impl_type) | ||
|
||
|
||
def create_nv_data_interface_with_one_element(packages: dict[str, ar_element.Package]): | ||
""" | ||
Creates interface with one element | ||
""" | ||
uint8_type: ar_element.ImplementationDataType = packages["PlatformImplementationDataTypes"].find("uint8") | ||
portinterface = ar_element.NvDataInterface("DataInterface1") | ||
portinterface.make_data_element("Data1", type_ref=uint8_type.ref()) | ||
packages["PortInterfaces"].append(portinterface) | ||
|
||
|
||
def create_nv_data_interface_with_two_elements(packages: dict[str, ar_element.Package]): | ||
""" | ||
Creates interface with two elements | ||
""" | ||
uint8_type: ar_element.ImplementationDataType = packages["PlatformImplementationDataTypes"].find("uint8") | ||
portinterface = ar_element.NvDataInterface("DataInterface2") | ||
portinterface.make_data_element("Data1", type_ref=uint8_type.ref()) | ||
portinterface.make_data_element("Data2", type_ref=uint8_type.ref()) | ||
packages["PortInterfaces"].append(portinterface) | ||
|
||
|
||
def save_xml_files(workspace: autosar.xml.Workspace): | ||
""" | ||
Saves workspace as XML documents | ||
""" | ||
interface_document_path = os.path.abspath(os.path.join(os.path.dirname( | ||
__file__), 'data', 'nv_data_interface.arxml')) | ||
platform_document_path = os.path.abspath(os.path.join(os.path.dirname( | ||
__file__), 'data', 'platform.arxml')) | ||
workspace.create_document(interface_document_path, packages="/PortInterfaces") | ||
workspace.create_document(platform_document_path, packages="/AUTOSAR_Platform") | ||
workspace.write_documents() | ||
|
||
|
||
def main(): | ||
""" | ||
Main | ||
""" | ||
workspace = autosar.xml.Workspace() | ||
packages = dict(zip(["PlatformBaseTypes", | ||
"PlatformImplementationDataTypes", | ||
"PortInterfaces"], | ||
workspace.make_packages("AUTOSAR_Platform/BaseTypes", | ||
"AUTOSAR_Platform/ImplementationDataTypes", | ||
"PortInterfaces"))) | ||
create_platform_types(packages) | ||
create_nv_data_interface_with_one_element(packages) | ||
create_nv_data_interface_with_two_elements(packages) | ||
save_xml_files(workspace) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
""" | ||
Sender-receiver port interface examples | ||
""" | ||
import os | ||
import autosar | ||
import autosar.xml.element as ar_element | ||
|
||
|
||
def create_platform_types(packages: dict[str, ar_element.Package]): | ||
""" | ||
Creates necessary platform types | ||
""" | ||
uint8_base_type = ar_element.SwBaseType('uint8', size=8) | ||
packages["PlatformBaseTypes"].append(uint8_base_type) | ||
sw_data_def_props = ar_element.SwDataDefPropsConditional(base_type_ref=uint8_base_type.ref()) | ||
uint8_impl_type = ar_element.ImplementationDataType("uint8", | ||
category="VALUE", | ||
sw_data_def_props=sw_data_def_props) | ||
packages["PlatformImplementationDataTypes"].append(uint8_impl_type) | ||
|
||
|
||
def create_parameter_interface_with_one_parameter(packages: dict[str, ar_element.Package]): | ||
""" | ||
Creates interface with one parameter | ||
""" | ||
uint8_type: ar_element.ImplementationDataType = packages["PlatformImplementationDataTypes"].find("uint8") | ||
portinterface = ar_element.ParameterInterface("ParameterInterface1") | ||
portinterface.make_parameter("Param1", type_ref=uint8_type.ref()) | ||
packages["PortInterfaces"].append(portinterface) | ||
|
||
|
||
def create_parameter_interface_with_two_parameters(packages: dict[str, ar_element.Package]): | ||
""" | ||
Creates interface with two parameters | ||
""" | ||
uint8_type: ar_element.ImplementationDataType = packages["PlatformImplementationDataTypes"].find("uint8") | ||
portinterface = ar_element.ParameterInterface("ParameterInterface2") | ||
portinterface.make_parameter("Param1", type_ref=uint8_type.ref()) | ||
portinterface.make_parameter("Param2", type_ref=uint8_type.ref()) | ||
packages["PortInterfaces"].append(portinterface) | ||
|
||
|
||
def save_xml_files(workspace: autosar.xml.Workspace): | ||
""" | ||
Saves workspace as XML documents | ||
""" | ||
interface_document_path = os.path.abspath(os.path.join(os.path.dirname( | ||
__file__), 'data', 'parameter_interface.arxml')) | ||
platform_document_path = os.path.abspath(os.path.join(os.path.dirname( | ||
__file__), 'data', 'platform.arxml')) | ||
workspace.create_document(interface_document_path, packages="/PortInterfaces") | ||
workspace.create_document(platform_document_path, packages="/AUTOSAR_Platform") | ||
workspace.write_documents() | ||
|
||
|
||
def main(): | ||
""" | ||
Main | ||
""" | ||
workspace = autosar.xml.Workspace() | ||
packages = dict(zip(["PlatformBaseTypes", | ||
"PlatformImplementationDataTypes", | ||
"PortInterfaces"], | ||
workspace.make_packages("AUTOSAR_Platform/BaseTypes", | ||
"AUTOSAR_Platform/ImplementationDataTypes", | ||
"PortInterfaces"))) | ||
create_platform_types(packages) | ||
create_parameter_interface_with_one_parameter(packages) | ||
create_parameter_interface_with_two_parameters(packages) | ||
save_xml_files(workspace) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.