4
4
import os
5
5
import autosar
6
6
import autosar .xml .element as ar_element
7
- import autosar .xml .enumeration as ar_enum
8
7
9
8
10
9
def create_platform_types (packages : dict [str , ar_element .Package ]):
@@ -50,17 +49,6 @@ def create_platform_types(packages: dict[str, ar_element.Package]):
50
49
packages ["PlatformImplementationDataTypes" ].append (uint32_impl_type )
51
50
52
51
53
- # def create_implementation_data_types(packages: dict[str, ar_element.Package]):
54
- # """
55
- # Creates non-platform implementation data types
56
- # """
57
- # sw_data_def_props = ar_element.SwDataDefPropsConditional(base_type_ref="AUTOSAR_Platform/BaseTypes/uint8")
58
- # inactive_active_t = ar_element.ImplementationDataType("InactiveActive_T",
59
- # category="VALUE",
60
- # sw_data_def_props=sw_data_def_props)
61
- # packages["ImplementationDataTypes"].append(inactive_active_t)
62
-
63
-
64
52
def create_sender_receiver_port_interfaces (packages : dict [str , ar_element .Package ]):
65
53
"""
66
54
Create sender-receiver port interfaces used in example
@@ -69,9 +57,6 @@ def create_sender_receiver_port_interfaces(packages: dict[str, ar_element.Packag
69
57
port_interface = ar_element .SenderReceiverInterface ("VehicleSpeed_I" )
70
58
port_interface .create_data_element ("VehicleSpeed" , type_ref = uint16_impl_t .ref ())
71
59
packages ["PortInterfaces" ].append (port_interface )
72
- port_interface = ar_element .SenderReceiverInterface ("EngineSpeed_I" )
73
- port_interface .create_data_element ("EngineSpeed" , type_ref = uint16_impl_t .ref ())
74
- packages ["PortInterfaces" ].append (port_interface )
75
60
76
61
77
62
def create_client_server_interfaces (packages : dict [str , ar_element .Package ]):
@@ -90,19 +75,37 @@ def create_client_server_interfaces(packages: dict[str, ar_element.Package]):
90
75
packages ["PortInterfaces" ].append (interface )
91
76
92
77
78
+ def create_application_component (packages : dict [str , ar_element .Package ]):
79
+ """
80
+ Creates application component with one sender-receiver port and one
81
+ client-server port
82
+ """
83
+ timer_interface = packages ["PortInterfaces" ].find ("FreeRunningTimer_I" )
84
+ vehicle_speed_interface = packages ["PortInterfaces" ].find ("VehicleSpeed_I" )
85
+ swc = ar_element .ApplicationSoftwareComponentType ("MyApplication" )
86
+ swc .create_require_port ("VehicleSpeed" , vehicle_speed_interface , com_spec = {"init_value" : 65535 ,
87
+ 'alive_timeout' : 0 ,
88
+ 'enable_update' : False ,
89
+ 'uses_end_to_end_protection' : False ,
90
+ 'handle_never_received' : False
91
+ })
92
+ swc .create_require_port ("FreeRunningTimer" , timer_interface )
93
+ packages ["ComponentTypes" ].append (swc )
94
+
95
+
93
96
def save_xml_files (workspace : autosar .xml .Workspace ):
94
97
"""
95
98
Saves workspace as XML documents
96
99
"""
97
100
interface_document_path = os .path .abspath (os .path .join (os .path .dirname (
98
101
__file__ ), 'data' , 'portinterfaces.arxml' ))
99
- datatype_document_path = os .path .abspath (os .path .join (os .path .dirname (
100
- __file__ ), 'data' , 'datatypes.arxml' ))
101
102
platform_document_path = os .path .abspath (os .path .join (os .path .dirname (
102
103
__file__ ), 'data' , 'platform.arxml' ))
104
+ component_document_path = os .path .abspath (os .path .join (os .path .dirname (
105
+ __file__ ), 'data' , 'MyApplication.arxml' ))
103
106
workspace .create_document (interface_document_path , packages = "/PortInterfaces" )
104
- workspace .create_document (datatype_document_path , packages = "/DataTypes" )
105
107
workspace .create_document (platform_document_path , packages = "/AUTOSAR_Platform" )
108
+ workspace .create_document (component_document_path , packages = "/ComponentTypes" )
106
109
workspace .write_documents ()
107
110
108
111
@@ -116,16 +119,19 @@ def main():
116
119
"PlatformDataConstraints" ,
117
120
"PlatformCompuMethods" ,
118
121
"ImplementationDataTypes" ,
119
- "PortInterfaces" ],
122
+ "PortInterfaces" ,
123
+ "ComponentTypes" ],
120
124
workspace .make_packages ("AUTOSAR_Platform/BaseTypes" ,
121
125
"AUTOSAR_Platform/ImplementationDataTypes" ,
122
126
"AUTOSAR_Platform/DataConstraints" ,
123
127
"AUTOSAR_Platform/CompuMethods" ,
124
128
"DataTypes/ImplementationDataTypes" ,
125
- "PortInterfaces" )))
129
+ "PortInterfaces" ,
130
+ "ComponentTypes" )))
126
131
create_platform_types (packages )
127
132
create_sender_receiver_port_interfaces (packages )
128
133
create_client_server_interfaces (packages )
134
+ create_application_component (packages )
129
135
save_xml_files (workspace )
130
136
131
137
0 commit comments