armodel 1.2.0__py3-none-any.whl → 1.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- armodel/cli/arxml_dump_cli.py +8 -8
- armodel/cli/swc_list_cli.py +81 -0
- armodel/lib/__init__.py +3 -0
- armodel/lib/cli_args_parser.py +36 -0
- armodel/lib/data_analyzer.py +34 -0
- armodel/models/ar_object.py +1 -1
- armodel/models/sw_component.py +2 -0
- armodel/parser/arxml_parser.py +43 -31
- {armodel-1.2.0.dist-info → armodel-1.3.0.dist-info}/METADATA +35 -4
- {armodel-1.2.0.dist-info → armodel-1.3.0.dist-info}/RECORD +14 -10
- {armodel-1.2.0.dist-info → armodel-1.3.0.dist-info}/entry_points.txt +1 -0
- {armodel-1.2.0.dist-info → armodel-1.3.0.dist-info}/LICENSE +0 -0
- {armodel-1.2.0.dist-info → armodel-1.3.0.dist-info}/WHEEL +0 -0
- {armodel-1.2.0.dist-info → armodel-1.3.0.dist-info}/top_level.txt +0 -0
armodel/cli/arxml_dump_cli.py
CHANGED
|
@@ -17,16 +17,16 @@ def show_variable_access(indent:int, variable_access: VariableAccess):
|
|
|
17
17
|
print("%s: %s" % (" " * indent, autosar_variable_in_impl_datatype.port_prototype.value))
|
|
18
18
|
print("%s: %s" % (" " * indent, autosar_variable_in_impl_datatype.target_data_prototype.value))
|
|
19
19
|
|
|
20
|
-
def show_port(indent:int,
|
|
21
|
-
if (isinstance(
|
|
22
|
-
print("%s-RPort: %s (%s)" % (" " * indent,
|
|
23
|
-
for client_com_spec in
|
|
20
|
+
def show_port(indent:int, port_prototype: PortPrototype):
|
|
21
|
+
if (isinstance(port_prototype, RPortPrototype)):
|
|
22
|
+
print("%s-RPort: %s (%s)" % (" " * indent, port_prototype.short_name, port_prototype.required_interface_tref.value))
|
|
23
|
+
for client_com_spec in port_prototype.getClientComSpecs():
|
|
24
24
|
print("%s : %s (ClientComSpec)" % (" " * (indent + 2), client_com_spec.operation_ref.value))
|
|
25
|
-
for com_spec in
|
|
25
|
+
for com_spec in port_prototype.getNonqueuedReceiverComSpecs():
|
|
26
26
|
print("%s : %s (NonqueuedReceiverComSpec)" % (" " * (indent + 2), com_spec.data_element_ref.value))
|
|
27
|
-
elif (isinstance(
|
|
28
|
-
print("%s-PPort: %s (%s)" % (" " * indent,
|
|
29
|
-
for com_spec in
|
|
27
|
+
elif (isinstance(port_prototype, PPortPrototype)):
|
|
28
|
+
print("%s-PPort: %s (%s)" % (" " * indent, port_prototype.short_name, port_prototype.provided_interface_tref.value))
|
|
29
|
+
for com_spec in port_prototype.getNonqueuedSenderComSpecs():
|
|
30
30
|
print("%s : %s (NonqueuedSenderComSpec)" % (" " * (indent + 2), com_spec.data_element_ref.value))
|
|
31
31
|
else:
|
|
32
32
|
raise ValueError("Unsupported Port prototype")
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import pkg_resources
|
|
3
|
+
import logging
|
|
4
|
+
import sys
|
|
5
|
+
import os.path
|
|
6
|
+
|
|
7
|
+
from armodel import AUTOSAR, ARPackage
|
|
8
|
+
from armodel.parser import ARXMLParser
|
|
9
|
+
|
|
10
|
+
from ..lib import InputFileParser, SwComponentAnalyzer
|
|
11
|
+
|
|
12
|
+
def main():
|
|
13
|
+
version = pkg_resources.require("armodel")[0].version
|
|
14
|
+
|
|
15
|
+
ap = argparse.ArgumentParser()
|
|
16
|
+
ap.add_argument("-v", "--verbose", required= False, help= "Print debug information", action= "store_true")
|
|
17
|
+
ap.add_argument("-f", "--format", required= False, help= "Specify the short or long name of Sw-C. [short|long]")
|
|
18
|
+
ap.add_argument("--filter", required= False, help = "Set the filter condition. [CompositionSwComponent]")
|
|
19
|
+
ap.add_argument("Input", help = "The path of AUTOSAR XML", nargs='+')
|
|
20
|
+
|
|
21
|
+
args = ap.parse_args()
|
|
22
|
+
|
|
23
|
+
logger = logging.getLogger()
|
|
24
|
+
|
|
25
|
+
formatter = logging.Formatter('[%(levelname)s] : %(message)s')
|
|
26
|
+
|
|
27
|
+
stdout_handler = logging.StreamHandler(sys.stderr)
|
|
28
|
+
stdout_handler.setFormatter(formatter)
|
|
29
|
+
|
|
30
|
+
#base_path = os.path.dirname(args.Output)
|
|
31
|
+
log_file = os.path.join(".", 'swc-list.log')
|
|
32
|
+
|
|
33
|
+
if os.path.exists(log_file):
|
|
34
|
+
os.remove(log_file)
|
|
35
|
+
|
|
36
|
+
file_handler = logging.FileHandler(log_file)
|
|
37
|
+
file_handler.setFormatter(formatter)
|
|
38
|
+
|
|
39
|
+
logger.setLevel(logging.DEBUG)
|
|
40
|
+
file_handler.setLevel(logging.DEBUG)
|
|
41
|
+
|
|
42
|
+
if args.verbose:
|
|
43
|
+
stdout_handler.setLevel(logging.DEBUG)
|
|
44
|
+
|
|
45
|
+
else:
|
|
46
|
+
stdout_handler.setLevel(logging.INFO)
|
|
47
|
+
|
|
48
|
+
logger.addHandler(file_handler)
|
|
49
|
+
logger.addHandler(stdout_handler)
|
|
50
|
+
|
|
51
|
+
try:
|
|
52
|
+
parser = InputFileParser(args.Input)
|
|
53
|
+
filenames = parser.parse()
|
|
54
|
+
|
|
55
|
+
document = AUTOSAR().getInstance()
|
|
56
|
+
parser = ARXMLParser({'warning': True})
|
|
57
|
+
|
|
58
|
+
format = "short"
|
|
59
|
+
if args.format is not None and args.format.lower() == "long":
|
|
60
|
+
format = "long"
|
|
61
|
+
|
|
62
|
+
for filename in filenames:
|
|
63
|
+
parser.load(filename, document)
|
|
64
|
+
|
|
65
|
+
filter = ""
|
|
66
|
+
if args.filter is not None and args.filter.lower() == "compositionswcomponent":
|
|
67
|
+
filter = "CompositionSwComponent"
|
|
68
|
+
|
|
69
|
+
analyzer = SwComponentAnalyzer()
|
|
70
|
+
analyzer.import_data(document)
|
|
71
|
+
analyzer.print_out({
|
|
72
|
+
'format': format,
|
|
73
|
+
'filter': filter,
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
except Exception as e:
|
|
77
|
+
#print(e)
|
|
78
|
+
raise e
|
|
79
|
+
|
|
80
|
+
if __name__ == "__main__":
|
|
81
|
+
main()
|
armodel/lib/__init__.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
import os, re
|
|
5
|
+
|
|
6
|
+
class InputFileParser:
|
|
7
|
+
def __init__(self, args: List[str]) -> None:
|
|
8
|
+
self._args = args
|
|
9
|
+
self._filenames = [] # type: List[str]
|
|
10
|
+
self._logger = logging.getLogger()
|
|
11
|
+
|
|
12
|
+
def _parse_file_list(self, file):
|
|
13
|
+
with open(file) as f_in:
|
|
14
|
+
for line in f_in:
|
|
15
|
+
self._filenames.append(line.strip())
|
|
16
|
+
|
|
17
|
+
def _parse_dir_files(self, dir_name):
|
|
18
|
+
for (root, _, files) in os.walk(dir_name, topdown=False):
|
|
19
|
+
for file in files:
|
|
20
|
+
m = re.match(r'.*\.arxml$', file, re.I)
|
|
21
|
+
|
|
22
|
+
if m:
|
|
23
|
+
self._filenames.append(os.path.join(root, file))
|
|
24
|
+
|
|
25
|
+
def parse(self) -> List[str]:
|
|
26
|
+
for input_file in self._args:
|
|
27
|
+
if os.path.isdir(input_file):
|
|
28
|
+
self._parse_dir_files(input_file)
|
|
29
|
+
else:
|
|
30
|
+
if input_file[0] == "@":
|
|
31
|
+
self._logger.debug("Parse ARXML list file %s " % input_file)
|
|
32
|
+
self._parse_file_list(input_file[1:])
|
|
33
|
+
else:
|
|
34
|
+
self._filenames.append(input_file)
|
|
35
|
+
|
|
36
|
+
return self._filenames
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from typing import List
|
|
4
|
+
from ..models import AUTOSAR, ARPackage, AtomicSwComponentType, CompositionSwComponentType
|
|
5
|
+
|
|
6
|
+
class SwComponentAnalyzer:
|
|
7
|
+
def __init__(self) -> None:
|
|
8
|
+
self.swcs = [] # type: List[AtomicSwComponentType]
|
|
9
|
+
|
|
10
|
+
def parse_pkg(self, parent: ARPackage):
|
|
11
|
+
for pkg in parent.getARPackages():
|
|
12
|
+
self.parse_pkg(pkg)
|
|
13
|
+
for swc in parent.getSwComponentTypes():
|
|
14
|
+
self.swcs.append(swc)
|
|
15
|
+
|
|
16
|
+
def import_data(self, document: AUTOSAR):
|
|
17
|
+
for pkg in document.getARPackages():
|
|
18
|
+
self.parse_pkg(pkg)
|
|
19
|
+
|
|
20
|
+
def print_out(self, option = {}):
|
|
21
|
+
logger = logging.getLogger()
|
|
22
|
+
|
|
23
|
+
logger.info("== SW-C LIST ==")
|
|
24
|
+
|
|
25
|
+
if option['filter'] == 'CompositionSwComponent':
|
|
26
|
+
swc_list = filter(lambda o: isinstance(o, CompositionSwComponentType), self.swcs)
|
|
27
|
+
else:
|
|
28
|
+
swc_list = self.swcs
|
|
29
|
+
|
|
30
|
+
for swc in sorted(swc_list, key = lambda o: o.short_name):
|
|
31
|
+
if option['format'] == 'long':
|
|
32
|
+
logger.info("%s" % swc.full_name)
|
|
33
|
+
else:
|
|
34
|
+
logger.info("%s" % swc.short_name)
|
armodel/models/ar_object.py
CHANGED
armodel/models/sw_component.py
CHANGED
|
@@ -11,6 +11,8 @@ class VariableAccess(Identifiable):
|
|
|
11
11
|
def __init__(self, parent: ARObject, short_name):
|
|
12
12
|
super().__init__(parent, short_name)
|
|
13
13
|
self.accessed_variable_ref = AutosarVariableRef()
|
|
14
|
+
self.accessed_variable_ref.parent = self
|
|
15
|
+
self.parent = parent
|
|
14
16
|
self.local_variable_ref = None # type: RefType
|
|
15
17
|
|
|
16
18
|
class ExecutableEntity(Identifiable):
|
armodel/parser/arxml_parser.py
CHANGED
|
@@ -15,6 +15,7 @@ from ..models import Implementation, Code, AutosarEngineeringObject, ResourceCon
|
|
|
15
15
|
from ..models import BswImplementation, BswModuleDescription, BswInternalBehavior, BswCalledEntity, BswModuleEntity, BswScheduleEvent, SwcBswMapping, SwcBswRunnableMapping
|
|
16
16
|
|
|
17
17
|
from typing import List
|
|
18
|
+
from colorama import Fore
|
|
18
19
|
import xml.etree.ElementTree as ET
|
|
19
20
|
import re
|
|
20
21
|
import logging
|
|
@@ -24,6 +25,7 @@ class ARXMLParser:
|
|
|
24
25
|
self.nsmap = {"xmlns": "http://autosar.org/schema/r4.0"}
|
|
25
26
|
self.options = {}
|
|
26
27
|
self.options['warning'] = False
|
|
28
|
+
self.logger = logging.getLogger()
|
|
27
29
|
|
|
28
30
|
self._processOptions(options=options)
|
|
29
31
|
|
|
@@ -35,7 +37,7 @@ class ARXMLParser:
|
|
|
35
37
|
|
|
36
38
|
def _raiseError(self, error_msg):
|
|
37
39
|
if (self.options['warning'] == True):
|
|
38
|
-
|
|
40
|
+
self.logger.error(Fore.RED + error_msg + Fore.WHITE)
|
|
39
41
|
else:
|
|
40
42
|
raise ValueError(error_msg)
|
|
41
43
|
|
|
@@ -134,12 +136,16 @@ class ARXMLParser:
|
|
|
134
136
|
results.append(ref)
|
|
135
137
|
return results
|
|
136
138
|
|
|
137
|
-
def readAutosarVariableInImplDatatype(self, element, accessed_variable_ref: AutosarVariableRef):
|
|
139
|
+
def readAutosarVariableInImplDatatype(self, element: ET.Element, accessed_variable_ref: AutosarVariableRef):
|
|
138
140
|
child_element = element.find("./xmlns:ACCESSED-VARIABLE/xmlns:AUTOSAR-VARIABLE-IREF", self.nsmap)
|
|
139
141
|
if (child_element != None):
|
|
140
142
|
autosar_variable_in_impl_datatype = ArVariableInImplementationDataInstanceRef()
|
|
141
143
|
autosar_variable_in_impl_datatype.port_prototype_ref = self.readChildOptionalRefElement(child_element, "PORT-PROTOTYPE-REF")
|
|
142
|
-
autosar_variable_in_impl_datatype.
|
|
144
|
+
if autosar_variable_in_impl_datatype.port_prototype_ref is None:
|
|
145
|
+
self._raiseError("PORT-PROTOTYPE-REF of <%s> is empty." % accessed_variable_ref.parent.short_name)
|
|
146
|
+
autosar_variable_in_impl_datatype.target_data_prototype_ref = self.readChildOptionalRefElement(child_element, "TARGET-DATA-PROTOTYPE-REF")
|
|
147
|
+
if autosar_variable_in_impl_datatype.target_data_prototype_ref is None:
|
|
148
|
+
self._raiseError("TARGET-DATA-PROTOTYPE-REF of <%s> is empty." % accessed_variable_ref.parent.short_name)
|
|
143
149
|
accessed_variable_ref.autosar_variable_in_impl_datatype = autosar_variable_in_impl_datatype
|
|
144
150
|
|
|
145
151
|
def readLocalVariableRef(self, element, accessed_variable_ref: AutosarVariableRef):
|
|
@@ -150,6 +156,8 @@ class ARXMLParser:
|
|
|
150
156
|
def _readVariableAccesses(self, element, parent: RunnableEntity, key: str):
|
|
151
157
|
for child_element in element.findall("./xmlns:%s/xmlns:VARIABLE-ACCESS" % key, self.nsmap):
|
|
152
158
|
short_name = self.readShortName(child_element)
|
|
159
|
+
self.logger.debug("readVariableAccesses %s" % short_name)
|
|
160
|
+
|
|
153
161
|
if (key == "DATA-RECEIVE-POINT-BY-ARGUMENTS"):
|
|
154
162
|
variable_access = parent.createDataReceivePointByArgument(short_name)
|
|
155
163
|
self.readAutosarVariableInImplDatatype(child_element, variable_access.accessed_variable_ref)
|
|
@@ -176,12 +184,12 @@ class ARXMLParser:
|
|
|
176
184
|
ref = self.readChildOptionalRefElement(child_element, "BSW-MODULE-ENTRY-REF")
|
|
177
185
|
if (ref != None):
|
|
178
186
|
parent.implemented_entry_refs.append(ref)
|
|
179
|
-
|
|
187
|
+
self.logger.debug("ImplementedEntry <%s> of BswModuleDescription <%s> has been added", ref.value, parent.short_name)
|
|
180
188
|
|
|
181
189
|
def readProvidedModeGroup(self, element, parent: BswModuleDescription):
|
|
182
190
|
for child_element in element.findall("./xmlns:PROVIDED-MODE-GROUPS/xmlns:MODE-DECLARATION-GROUP-PROTOTYPE", self.nsmap):
|
|
183
191
|
short_name = self.readShortName(child_element)
|
|
184
|
-
|
|
192
|
+
self.logger.debug("readProvidedModeGroup %s" % short_name)
|
|
185
193
|
|
|
186
194
|
mode_group = parent.createProvidedModeGroup(short_name)
|
|
187
195
|
mode_group.type_tref = self.readChildRefElement(parent.short_name, child_element, "TYPE-TREF")
|
|
@@ -189,7 +197,7 @@ class ARXMLParser:
|
|
|
189
197
|
def readRequiredModeGroup(self, element, parent: BswModuleDescription):
|
|
190
198
|
for child_element in element.findall("./xmlns:REQUIRED-MODE-GROUPS/xmlns:MODE-DECLARATION-GROUP-PROTOTYPE", self.nsmap):
|
|
191
199
|
short_name = self.readShortName(child_element)
|
|
192
|
-
|
|
200
|
+
self.logger.debug("readRequiredModeGroup %s" % short_name)
|
|
193
201
|
mode_group = parent.createProvidedModeGroup(short_name)
|
|
194
202
|
mode_group.type_tref = self.readChildRefElement(parent.short_name, child_element, "TYPE-TREF")
|
|
195
203
|
|
|
@@ -210,7 +218,7 @@ class ARXMLParser:
|
|
|
210
218
|
def readBswCalledEntity(self, element, parent: BswInternalBehavior):
|
|
211
219
|
for child_element in element.findall("./xmlns:ENTITYS/xmlns:BSW-CALLED-ENTITY", self.nsmap):
|
|
212
220
|
short_name = self.readShortName(child_element)
|
|
213
|
-
|
|
221
|
+
self.logger.debug("readBswCalledEntity %s" % short_name)
|
|
214
222
|
entity = parent.createBswCalledEntity(short_name)
|
|
215
223
|
|
|
216
224
|
self.readBswModuleEntity(child_element, entity)
|
|
@@ -218,7 +226,7 @@ class ARXMLParser:
|
|
|
218
226
|
def readBswSchedulableEntity(self, element, parent: BswInternalBehavior):
|
|
219
227
|
for child_element in element.findall("./xmlns:ENTITYS/xmlns:BSW-SCHEDULABLE-ENTITY", self.nsmap):
|
|
220
228
|
short_name = self.readShortName(child_element)
|
|
221
|
-
|
|
229
|
+
self.logger.debug("readBswSchedulableEntity %s" % short_name)
|
|
222
230
|
entity = parent.createBswSchedulableEntity(short_name)
|
|
223
231
|
|
|
224
232
|
self.readBswModuleEntity(child_element, entity)
|
|
@@ -232,7 +240,7 @@ class ARXMLParser:
|
|
|
232
240
|
def readBswModeSwitchEvent(self, element, parent: BswInternalBehavior):
|
|
233
241
|
for child_element in element.findall("./xmlns:EVENTS/xmlns:BSW-MODE-SWITCH-EVENT", self.nsmap):
|
|
234
242
|
short_name = self.readShortName(child_element)
|
|
235
|
-
|
|
243
|
+
self.logger.debug("readBswModeSwitchEvent %s" % short_name)
|
|
236
244
|
event = parent.createBswModeSwitchEvent(short_name)
|
|
237
245
|
|
|
238
246
|
self.readBswScheduleEvent(child_element, event)
|
|
@@ -240,7 +248,7 @@ class ARXMLParser:
|
|
|
240
248
|
def readBswTimingEvent(self, element, parent: BswInternalBehavior):
|
|
241
249
|
for child_element in element.findall("./xmlns:EVENTS/xmlns:BSW-TIMING-EVENT", self.nsmap):
|
|
242
250
|
short_name = self.readShortName(child_element)
|
|
243
|
-
|
|
251
|
+
self.logger.debug("readBswTimingEvent %s" % short_name)
|
|
244
252
|
event = parent.createBswTimingEvent(short_name)
|
|
245
253
|
event.period = self.readChildElementFloatValue(short_name, child_element, "PERIOD")
|
|
246
254
|
|
|
@@ -249,7 +257,7 @@ class ARXMLParser:
|
|
|
249
257
|
def readBswDataReceivedEvent(self, element, parent: BswInternalBehavior):
|
|
250
258
|
for child_element in element.findall("./xmlns:EVENTS/xmlns:BSW-DATA-RECEIVED-EVENT", self.nsmap):
|
|
251
259
|
short_name = self.readShortName(child_element)
|
|
252
|
-
|
|
260
|
+
self.logger.debug("readBswDataReceivedEvent %s" % short_name)
|
|
253
261
|
event = parent.createBswDataReceivedEvent(short_name)
|
|
254
262
|
event.data_ref = self.readChildRefElement(parent.short_name, child_element, "DATA-REF")
|
|
255
263
|
|
|
@@ -258,7 +266,7 @@ class ARXMLParser:
|
|
|
258
266
|
def readBswInternalTriggerOccurredEvent(self, element, parent: BswInternalBehavior):
|
|
259
267
|
for child_element in element.findall("./xmlns:EVENTS/xmlns:BSW-INTERNAL-TRIGGER-OCCURRED-EVENT", self.nsmap):
|
|
260
268
|
short_name = self.readShortName(child_element)
|
|
261
|
-
|
|
269
|
+
self.logger.debug("readBswInternalTriggerOccurredEvent %s" % short_name)
|
|
262
270
|
event = parent.createBswInternalTriggerOccurredEvent(short_name)
|
|
263
271
|
event.event_source_ref = self.readChildRefElement(parent.short_name, child_element, "EVENT-SOURCE-REF")
|
|
264
272
|
|
|
@@ -281,7 +289,7 @@ class ARXMLParser:
|
|
|
281
289
|
for child_element in element.findall("./xmlns:INTERNAL-BEHAVIORS/xmlns:SWC-INTERNAL-BEHAVIOR", self.nsmap):
|
|
282
290
|
short_name = self.readShortName(child_element)
|
|
283
291
|
behavior = parent.createSwcInternalBehavior(short_name)
|
|
284
|
-
|
|
292
|
+
self.logger.debug("readSwInternalBehavior %s" % behavior.full_name)
|
|
285
293
|
|
|
286
294
|
# read the internal behavior
|
|
287
295
|
self.readInternalBehavior(child_element, behavior)
|
|
@@ -296,7 +304,7 @@ class ARXMLParser:
|
|
|
296
304
|
for child_element in element.findall("./xmlns:INTERNAL-BEHAVIORS/xmlns:BSW-INTERNAL-BEHAVIOR", self.nsmap):
|
|
297
305
|
short_name = self.readShortName(child_element)
|
|
298
306
|
behavior = parent.createBswInternalBehavior(short_name)
|
|
299
|
-
|
|
307
|
+
self.logger.debug("readBswInternalBehavior %s" % behavior.full_name)
|
|
300
308
|
|
|
301
309
|
# read the internal behavior
|
|
302
310
|
self.readInternalBehavior(child_element, behavior)
|
|
@@ -314,7 +322,7 @@ class ARXMLParser:
|
|
|
314
322
|
bsw_module_description = parent.createBswModuleDescription(short_name)
|
|
315
323
|
bsw_module_description.module_id = self.readChildElementNumberValue(short_name, child_element, "MODULE-ID")
|
|
316
324
|
|
|
317
|
-
|
|
325
|
+
self.logger.debug("readBswModuleDescription %s" % bsw_module_description.full_name)
|
|
318
326
|
|
|
319
327
|
self.readBswModuleDescriptionImplementedEntry(child_element, bsw_module_description)
|
|
320
328
|
self.readProvidedModeGroup(child_element, bsw_module_description)
|
|
@@ -332,8 +340,8 @@ class ARXMLParser:
|
|
|
332
340
|
entry.execution_context = self.readChildOptionalElement(child_element, "EXECUTION-CONTEXT")
|
|
333
341
|
entry.sw_service_impl_policy = self.readChildOptionalElement(child_element, "SW-SERVICE-IMPL-POLICY")
|
|
334
342
|
|
|
335
|
-
#
|
|
336
|
-
|
|
343
|
+
#self.logger.debug("readBswModuleEntry \n%s" % entry)
|
|
344
|
+
self.logger.debug("readBswModuleEntry %s" % entry.short_name)
|
|
337
345
|
|
|
338
346
|
def readArtifactDescriptor(self, element, code_desc: Code):
|
|
339
347
|
for child_element in element.findall("./xmlns:ARTIFACT-DESCRIPTORS/xmlns:AUTOSAR-ENGINEERING-OBJECT", self.nsmap):
|
|
@@ -342,12 +350,12 @@ class ARXMLParser:
|
|
|
342
350
|
artifact_desc.category = self.readChildElement(code_desc.short_name, child_element, "CATEGORY")
|
|
343
351
|
code_desc.addArtifactDescriptor(artifact_desc)
|
|
344
352
|
|
|
345
|
-
|
|
353
|
+
self.logger.debug("readArtifactDescriptor %s", artifact_desc.short_label)
|
|
346
354
|
|
|
347
355
|
def readCodeDescriptor(self, element, impl: Implementation):
|
|
348
356
|
for child_element in element.findall("./xmlns:CODE-DESCRIPTORS/xmlns:CODE", self.nsmap):
|
|
349
357
|
short_name = self.readShortName(child_element)
|
|
350
|
-
|
|
358
|
+
self.logger.debug("readCodeDescriptor %s" % short_name)
|
|
351
359
|
code_desc = impl.createCodeDescriptor(short_name)
|
|
352
360
|
self.readArtifactDescriptor(child_element, code_desc)
|
|
353
361
|
|
|
@@ -359,7 +367,7 @@ class ARXMLParser:
|
|
|
359
367
|
if (alignment != None):
|
|
360
368
|
memory_section.alignment = alignment
|
|
361
369
|
memory_section.sw_addr_method_ref = self.readChildRefElement(consumption.short_name, child_element, "SW-ADDRMETHOD-REF")
|
|
362
|
-
|
|
370
|
+
self.logger.debug("readMemorySections %s" % memory_section.short_name)
|
|
363
371
|
|
|
364
372
|
def readResourceConsumption(self, element, impl: Implementation):
|
|
365
373
|
child_element = element.find("./xmlns:RESOURCE-CONSUMPTION", self.nsmap)
|
|
@@ -382,7 +390,7 @@ class ARXMLParser:
|
|
|
382
390
|
for child_element in element.findall("./xmlns:ELEMENTS/xmlns:BSW-IMPLEMENTATION", self.nsmap):
|
|
383
391
|
short_name = self.readShortName(child_element)
|
|
384
392
|
impl = parent.createBswImplementation(short_name)
|
|
385
|
-
|
|
393
|
+
self.logger.debug("readBswImplementation %s" % impl.short_name)
|
|
386
394
|
|
|
387
395
|
self.readImplementation(child_element, impl)
|
|
388
396
|
|
|
@@ -393,7 +401,7 @@ class ARXMLParser:
|
|
|
393
401
|
for child_element in element.findall("./xmlns:ELEMENTS/xmlns:SWC-IMPLEMENTATION", self.nsmap):
|
|
394
402
|
short_name = self.readShortName(child_element)
|
|
395
403
|
impl = parent.createSwcImplementation(short_name)
|
|
396
|
-
|
|
404
|
+
self.logger.debug("readSwcImplementation %s" % impl.short_name)
|
|
397
405
|
|
|
398
406
|
self.readImplementation(child_element, impl)
|
|
399
407
|
|
|
@@ -468,6 +476,8 @@ class ARXMLParser:
|
|
|
468
476
|
runnable.can_be_invoked_concurrently = self.readChildOptionalElement(child_element, "CAN-BE-INVOKED-CONCURRENTLY")
|
|
469
477
|
runnable.symbol = self.readChildElement(short_name, child_element, "SYMBOL")
|
|
470
478
|
|
|
479
|
+
self.logger.debug("readRunnableEntities %s" % short_name)
|
|
480
|
+
|
|
471
481
|
self.readDataReceivePointByArguments(child_element, runnable)
|
|
472
482
|
self.readDataReceivePointByValues(child_element, runnable)
|
|
473
483
|
self.readDataReadAccesses(child_element, runnable)
|
|
@@ -624,7 +634,7 @@ class ARXMLParser:
|
|
|
624
634
|
com_spec.operation_ref = self.readChildRefElement(parent.short_name, child_element, "OPERATION-REF")
|
|
625
635
|
parent.addRequiredComSpec(com_spec)
|
|
626
636
|
except ValueError as err:
|
|
627
|
-
|
|
637
|
+
self.logger.error(parent.short_name + ": " + str(err))
|
|
628
638
|
|
|
629
639
|
def readReceiverComSpec(self, element, com_spec: ReceiverComSpec):
|
|
630
640
|
#FIXME: readchildElement
|
|
@@ -644,14 +654,14 @@ class ARXMLParser:
|
|
|
644
654
|
com_spec.handle_never_received = self.readChildElementBooleanValue("", child_element, "HANDLE-NEVER-RECEIVED")
|
|
645
655
|
com_spec.handel_timeout_type = self.readChildElement("", child_element, "HANDLE-TIMEOUT-TYPE")
|
|
646
656
|
except ValueError as err:
|
|
647
|
-
|
|
657
|
+
self.logger.error(parent.short_name + ": " + str(err))
|
|
648
658
|
|
|
649
659
|
parent.addRequiredComSpec(com_spec)
|
|
650
660
|
|
|
651
661
|
def readRPortPrototype(self, element, parent: AtomicSwComponentType):
|
|
652
662
|
for child_element in element.findall("./xmlns:PORTS/xmlns:R-PORT-PROTOTYPE", self.nsmap):
|
|
653
663
|
short_name = self.readShortName(child_element)
|
|
654
|
-
|
|
664
|
+
self.logger.debug("readRPortPrototype %s" % short_name)
|
|
655
665
|
|
|
656
666
|
prototype = parent.createRPortPrototype(short_name)
|
|
657
667
|
prototype.required_interface_tref = self.readChildOptionalRefElement(child_element, "REQUIRED-INTERFACE-TREF")
|
|
@@ -674,7 +684,7 @@ class ARXMLParser:
|
|
|
674
684
|
def readPPortPrototype(self, element, parent: AtomicSwComponentType):
|
|
675
685
|
for child_element in element.findall("./xmlns:PORTS/xmlns:P-PORT-PROTOTYPE", self.nsmap):
|
|
676
686
|
short_name = self.readShortName(child_element)
|
|
677
|
-
|
|
687
|
+
self.logger.debug("readPPortPrototype %s" % short_name)
|
|
678
688
|
|
|
679
689
|
prototype = parent.createPPortPrototype(short_name)
|
|
680
690
|
prototype.provided_interface_tref = self.readChildOptionalRefElement(child_element, "PROVIDED-INTERFACE-TREF")
|
|
@@ -738,7 +748,7 @@ class ARXMLParser:
|
|
|
738
748
|
def readAssemblySwConnectors(self, element, parent: CompositionSwComponentType):
|
|
739
749
|
for child_element in element.findall("./xmlns:CONNECTORS/xmlns:ASSEMBLY-SW-CONNECTOR", self.nsmap):
|
|
740
750
|
short_name = self.readShortName(child_element)
|
|
741
|
-
|
|
751
|
+
self.logger.debug("readAssemblySwConnectors %s" % short_name)
|
|
742
752
|
|
|
743
753
|
connector = parent.createAssemblySwConnector(short_name)
|
|
744
754
|
self.readAssemblySwConnectorProviderIRef(child_element, connector)
|
|
@@ -747,7 +757,7 @@ class ARXMLParser:
|
|
|
747
757
|
def readSwComponentPrototypes(self, element, parent: CompositionSwComponentType):
|
|
748
758
|
for child_element in element.findall("./xmlns:COMPONENTS/xmlns:SW-COMPONENT-PROTOTYPE", self.nsmap):
|
|
749
759
|
short_name = self.readShortName(child_element)
|
|
750
|
-
|
|
760
|
+
self.logger.debug("readSwComponentPrototypes %s" % short_name)
|
|
751
761
|
|
|
752
762
|
prototype = parent.createSwComponentPrototype(short_name)
|
|
753
763
|
prototype.type_tref = self.readChildOptionalRefElement(child_element, "TYPE-TREF")
|
|
@@ -755,7 +765,7 @@ class ARXMLParser:
|
|
|
755
765
|
def readCompositionSwComponentTypes(self, element, parent: ARPackage):
|
|
756
766
|
for child_element in element.findall("./xmlns:ELEMENTS/xmlns:COMPOSITION-SW-COMPONENT-TYPE", self.nsmap):
|
|
757
767
|
short_name = self.readShortName(child_element)
|
|
758
|
-
|
|
768
|
+
self.logger.debug("readCompositionSwComponentTypes: <%s>" % short_name)
|
|
759
769
|
|
|
760
770
|
sw_component = parent.createCompositionSwComponentType(short_name)
|
|
761
771
|
self.readSwComponentType(child_element, sw_component)
|
|
@@ -874,7 +884,7 @@ class ARXMLParser:
|
|
|
874
884
|
short_name = self.readShortName(child_element)
|
|
875
885
|
ar_package = parent.createARPackage(short_name)
|
|
876
886
|
|
|
877
|
-
|
|
887
|
+
self.logger.debug("readARPackages %s" % ar_package.full_name)
|
|
878
888
|
|
|
879
889
|
self.readSenderReceiverInterfaces(child_element, ar_package)
|
|
880
890
|
self.readClientServerInterfaces(child_element, ar_package)
|
|
@@ -898,11 +908,13 @@ class ARXMLParser:
|
|
|
898
908
|
self.readSwcImplementation(child_element, ar_package)
|
|
899
909
|
|
|
900
910
|
def load(self, filename, document: AUTOSAR):
|
|
911
|
+
self.logger.info("Load %s ..." % filename)
|
|
912
|
+
|
|
901
913
|
tree = ET.parse(filename)
|
|
902
914
|
root = tree.getroot()
|
|
903
915
|
if (self.getPureTagName(root.tag) != "AUTOSAR"):
|
|
904
916
|
self._raiseError("Invalid ARXML file <%s>" % filename)
|
|
905
917
|
|
|
906
|
-
|
|
918
|
+
|
|
907
919
|
|
|
908
920
|
self.readARPackages(root, document)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: armodel
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: the python arxml parser
|
|
5
5
|
Home-page: http://github.com/melodypapa/py-armodel
|
|
6
6
|
Author: melodypapa
|
|
@@ -15,6 +15,7 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
15
15
|
Classifier: Operating System :: OS Independent
|
|
16
16
|
Requires-Python: >=3.5
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
|
+
Requires-Dist: colorama
|
|
18
19
|
Provides-Extra: pytest
|
|
19
20
|
Requires-Dist: pytest-cov ; extra == 'pytest'
|
|
20
21
|
|
|
@@ -95,17 +96,47 @@ And more details can be found at https://packaging.python.org/
|
|
|
95
96
|
|
|
96
97
|
**Dump all the arxml data to screen**
|
|
97
98
|
|
|
99
|
+
|
|
98
100
|
`arxml-dump --arxml arg -h`
|
|
99
101
|
|
|
100
102
|
--arxml arg The file name of arxml data
|
|
101
|
-
|
|
102
103
|
-h show the help information
|
|
103
104
|
|
|
104
|
-
|
|
105
|
+
#### 1.8.1.1. arxml-dump usage
|
|
105
106
|
|
|
106
107
|
**Dump the arxml data from test1.arxml and test2.arxml**
|
|
107
108
|
|
|
108
|
-
|
|
109
|
+
```
|
|
110
|
+
$arxml-dump --arxml test1.arxml --arxml test2.arxml
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 1.8.2. swc-list
|
|
114
|
+
|
|
115
|
+
**List all the SwComponentType in the autosar model**
|
|
116
|
+
|
|
117
|
+
usage: swc-list [-h] [-v] [-f FORMAT] [--filter FILTER] Input [Input ...]
|
|
118
|
+
|
|
119
|
+
-h, --help show the help message and exit
|
|
120
|
+
-v, --verbose Print debug information
|
|
121
|
+
-f FORMAT, --format FORMAT
|
|
122
|
+
Specify the short or long name of Sw-C.
|
|
123
|
+
*short* : only print the short name of SWComponentType
|
|
124
|
+
*long* : print the SWComponentType with ARPackage names
|
|
125
|
+
--filter FILTER Set the filter condition.
|
|
126
|
+
*CompositionSwComponent* : Print the CompositionSwComponent only.
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
#### 1.8.2.1. List all the SW-Components in the specific path
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
$swc-list <arxml_folder>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
#### 1.8.2.2. List all the CompositionSwComponent with the long name
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
$swc-list --format long --filter CompositionSwComponent <arxml_folder>
|
|
139
|
+
```
|
|
109
140
|
|
|
110
141
|
## 1.9. API
|
|
111
142
|
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
armodel/__init__.py,sha256=K_KHb3O2T21uteIe0wac-tb3kI2xWHTnwV9ShaXesAU,54
|
|
2
2
|
armodel/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
armodel/cli/arxml_dump_cli.py,sha256=
|
|
3
|
+
armodel/cli/arxml_dump_cli.py,sha256=SELbIKJMN65Lzfuze-q_XPBme-KTPrpb2yDl3fLctc8,9932
|
|
4
|
+
armodel/cli/swc_list_cli.py,sha256=9dgW-5Gn1TFqbq5wQd_EFpe9IDLJhPBlYcWRi3m5x84,2414
|
|
5
|
+
armodel/lib/__init__.py,sha256=1i7vjCwcVMUrTrN7mRgQsIN6eP-8gsIKSLDh6YXjNe8,94
|
|
6
|
+
armodel/lib/cli_args_parser.py,sha256=WiTC3wy_fZYloA1AjPqCvvOA_26V_y5toun0qfV51cw,1207
|
|
7
|
+
armodel/lib/data_analyzer.py,sha256=y4ViEGPi_xRKD7hw1ptkGl0_UfhnNdgNzf2YjbOhpjM,1159
|
|
4
8
|
armodel/models/__init__.py,sha256=ijDu-Ra2ZjEJNy88Y5ZsPqxAt05_reQsQti-_X4gD3o,402
|
|
5
|
-
armodel/models/ar_object.py,sha256
|
|
9
|
+
armodel/models/ar_object.py,sha256=-XM0LFxXJovY7ANh-enGmAFu8yhkj9YzFFyCY7ffO8U,371
|
|
6
10
|
armodel/models/ar_package.py,sha256=OPoNGaAhTBf30elxc1dvJMyU6CpMUmvs0SUwaYoEtVs,13275
|
|
7
11
|
armodel/models/ar_ref.py,sha256=RZT6URQ91YgmRk1oUTC-0UPnwn61MgEzmII7UKwQXUM,3548
|
|
8
12
|
armodel/models/bsw_module_template.py,sha256=k_CZWtTipKtVFjIx08uRqadSubVtBJ-NhUlocfoA0a0,11778
|
|
@@ -16,12 +20,12 @@ armodel/models/implementation.py,sha256=jfatA90Ww51kMqnUsbx6q4JRRRIRFCQXVg88J44R
|
|
|
16
20
|
armodel/models/m2_msr.py,sha256=Gk-h-4jSnOkWlfJJcI1-1YvSQvBqkUJZxlzikwgAsec,2165
|
|
17
21
|
armodel/models/port_interface.py,sha256=UDCvj78k3sfG4IJX4FWQj6LUV2mWw6Nt0plMnLsQfZk,6026
|
|
18
22
|
armodel/models/port_prototype.py,sha256=Pqp5euv_RDfTlsEqvBkpAreBFMJlovuU49cJsYD4d3Q,7215
|
|
19
|
-
armodel/models/sw_component.py,sha256=
|
|
23
|
+
armodel/models/sw_component.py,sha256=ix6LP1-TLN1r7YEl3CrUoo_ZGfvNGj5q8p3XNPUbabU,20583
|
|
20
24
|
armodel/parser/__init__.py,sha256=whzCLvAstuSlm6scgcCId7AUxSX8z8PV8AIKSNWMkGo,37
|
|
21
|
-
armodel/parser/arxml_parser.py,sha256=
|
|
22
|
-
armodel-1.
|
|
23
|
-
armodel-1.
|
|
24
|
-
armodel-1.
|
|
25
|
-
armodel-1.
|
|
26
|
-
armodel-1.
|
|
27
|
-
armodel-1.
|
|
25
|
+
armodel/parser/arxml_parser.py,sha256=LPSj4BxO9fV9pIXVhzMjJmOIC4YUSbDi3H6I11McXOM,56759
|
|
26
|
+
armodel-1.3.0.dist-info/LICENSE,sha256=rceTpGhsmmN1M0k1KO0HRS11iCjen-2y56ZEqgo43wo,1088
|
|
27
|
+
armodel-1.3.0.dist-info/METADATA,sha256=eael0JbJhlKXRebYA2EHb83ccoqjtCd-Z6zVzx51SJk,5932
|
|
28
|
+
armodel-1.3.0.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
29
|
+
armodel-1.3.0.dist-info/entry_points.txt,sha256=U-GD6do9I0ZRKENiIdmJMbsLHbtBX2Q7CWIldbNFrc0,109
|
|
30
|
+
armodel-1.3.0.dist-info/top_level.txt,sha256=AEATYsqAuRpr0XGa_ThW7-o4WLlA5e3PEgD0QJhzmoA,8
|
|
31
|
+
armodel-1.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|