armodel 1.3.0__py3-none-any.whl → 1.4.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.
Files changed (52) hide show
  1. armodel/cli/connector2xlsx_cli.py +75 -0
  2. armodel/cli/connector_update_cli.py +70 -0
  3. armodel/cli/swc_list_cli.py +2 -2
  4. armodel/lib/__init__.py +1 -1
  5. armodel/lib/data_analyzer.py +1 -1
  6. armodel/lib/sw_component.py +34 -0
  7. armodel/models/__init__.py +6 -1
  8. armodel/models/ar_object.py +39 -0
  9. armodel/models/ar_package.py +35 -1
  10. armodel/models/ar_ref.py +12 -2
  11. armodel/models/bsw_module_template.py +3 -2
  12. armodel/models/calibration.py +16 -0
  13. armodel/models/common_structure.py +92 -0
  14. armodel/models/communication.py +8 -0
  15. armodel/models/datatype.py +23 -5
  16. armodel/models/general_structure.py +48 -3
  17. armodel/models/global_constraints.py +40 -0
  18. armodel/models/m2_msr.py +76 -2
  19. armodel/models/port_prototype.py +21 -16
  20. armodel/models/sw_component.py +47 -18
  21. armodel/models/unit.py +14 -0
  22. armodel/parser/arxml_parser.py +552 -120
  23. armodel/parser/excel_parser.py +0 -0
  24. armodel/report/__init__.py +1 -0
  25. armodel/report/connector_xls_report.py +76 -0
  26. armodel/report/excel_report.py +42 -0
  27. armodel/tests/__init__.py +0 -0
  28. armodel/tests/test_armodel/__init__.py +0 -0
  29. armodel/tests/test_armodel/models/__init__.py +0 -0
  30. armodel/tests/test_armodel/models/test_ar_package.py +294 -0
  31. armodel/tests/test_armodel/models/test_ar_ref.py +74 -0
  32. armodel/tests/test_armodel/models/test_bsw_module_template.py +46 -0
  33. armodel/tests/test_armodel/models/test_common_structure.py +73 -0
  34. armodel/tests/test_armodel/models/test_data_dictionary.py +29 -0
  35. armodel/tests/test_armodel/models/test_data_prototype.py +86 -0
  36. armodel/tests/test_armodel/models/test_datatype.py +239 -0
  37. armodel/tests/test_armodel/models/test_general_structure.py +50 -0
  38. armodel/tests/test_armodel/models/test_m2_msr.py +77 -0
  39. armodel/tests/test_armodel/models/test_port_interface.py +198 -0
  40. armodel/tests/test_armodel/models/test_port_prototype.py +14 -0
  41. armodel/tests/test_armodel/parser/__init__.py +0 -0
  42. armodel/tests/test_armodel/parser/test_parse_bswmd.py +168 -0
  43. armodel/writer/__init__.py +1 -0
  44. armodel/writer/arxml_writer.py +641 -0
  45. {armodel-1.3.0.dist-info → armodel-1.4.0.dist-info}/METADATA +38 -5
  46. armodel-1.4.0.dist-info/RECORD +60 -0
  47. {armodel-1.3.0.dist-info → armodel-1.4.0.dist-info}/WHEEL +1 -1
  48. armodel-1.4.0.dist-info/entry_points.txt +5 -0
  49. armodel-1.3.0.dist-info/RECORD +0 -31
  50. armodel-1.3.0.dist-info/entry_points.txt +0 -4
  51. {armodel-1.3.0.dist-info → armodel-1.4.0.dist-info}/LICENSE +0 -0
  52. {armodel-1.3.0.dist-info → armodel-1.4.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,75 @@
1
+ import argparse
2
+ import pkg_resources
3
+ import logging
4
+ import sys
5
+ import os.path
6
+
7
+ from armodel import AUTOSAR
8
+ from armodel.parser import ARXMLParser
9
+
10
+ from ..lib import InputFileParser
11
+ from ..report import ConnectorXlsReport
12
+
13
+ def main():
14
+ version = pkg_resources.require("armodel")[0].version
15
+
16
+ ap = argparse.ArgumentParser()
17
+ ap.add_argument("-v", "--verbose", required= False, help= "Print debug information", action= "store_true")
18
+ ap.add_argument("-w", "--warning", required= False, help= "Skip the error and report it as warning message", action= "store_true")
19
+ ap.add_argument("INPUT", help = "The path of AUTOSAR XML", nargs='+')
20
+ ap.add_argument("OUTPUT", help = "The path of output excel file")
21
+
22
+ args = ap.parse_args()
23
+
24
+ logger = logging.getLogger()
25
+
26
+ formatter = logging.Formatter('[%(levelname)s] : %(message)s')
27
+
28
+ stdout_handler = logging.StreamHandler(sys.stderr)
29
+ stdout_handler.setFormatter(formatter)
30
+
31
+ base_path = os.path.dirname(args.OUTPUT)
32
+ log_file = os.path.join(base_path, 'connector.log')
33
+
34
+ if os.path.exists(log_file):
35
+ os.remove(log_file)
36
+
37
+ file_handler = logging.FileHandler(log_file)
38
+ file_handler.setFormatter(formatter)
39
+
40
+ logger.setLevel(logging.DEBUG)
41
+ file_handler.setLevel(logging.DEBUG)
42
+
43
+ if args.verbose:
44
+ stdout_handler.setLevel(logging.DEBUG)
45
+
46
+ else:
47
+ stdout_handler.setLevel(logging.INFO)
48
+
49
+ logger.addHandler(file_handler)
50
+ logger.addHandler(stdout_handler)
51
+
52
+ try:
53
+ parser = InputFileParser(args.INPUT)
54
+ filenames = parser.parse()
55
+
56
+ options = {}
57
+ if args.warning:
58
+ options['warning'] = True
59
+
60
+ document = AUTOSAR().getInstance()
61
+ parser = ARXMLParser(options)
62
+
63
+ for filename in filenames:
64
+ parser.load(filename, document)
65
+
66
+ writer = ConnectorXlsReport()
67
+ writer.import_data(document)
68
+ writer.write(args.OUTPUT)
69
+
70
+ except Exception as e:
71
+ #print(e)
72
+ raise e
73
+
74
+ if __name__ == "__main__":
75
+ main()
@@ -0,0 +1,70 @@
1
+ import argparse
2
+ import pkg_resources
3
+ import logging
4
+ import sys
5
+ import os.path
6
+
7
+ from armodel import AUTOSAR
8
+ from armodel.parser import ARXMLParser
9
+
10
+ from ..lib import InputFileParser
11
+ from ..writer import ARXMLWriter
12
+
13
+ def main():
14
+ version = pkg_resources.require("armodel")[0].version
15
+
16
+ ap = argparse.ArgumentParser()
17
+ ap.add_argument("-v", "--verbose", required= False, help= "Print debug information", action= "store_true")
18
+ ap.add_argument("-w", "--warning", required= False, help= "Skip the error and report it as warning message", action= "store_true")
19
+ ap.add_argument("INPUT", help = "The path of AUTOSAR ARXML file")
20
+ ap.add_argument("MAPPING", help = "The path of connector excel file which exports with connector2xlsx")
21
+ ap.add_argument("OUTPUT", help = "The path of output excel file")
22
+
23
+ args = ap.parse_args()
24
+
25
+ logger = logging.getLogger()
26
+
27
+ formatter = logging.Formatter('[%(levelname)s] : %(message)s')
28
+
29
+ stdout_handler = logging.StreamHandler(sys.stderr)
30
+ stdout_handler.setFormatter(formatter)
31
+
32
+ base_path = os.path.dirname(args.OUTPUT)
33
+ log_file = os.path.join(base_path, 'connector_update.log')
34
+
35
+ if os.path.exists(log_file):
36
+ os.remove(log_file)
37
+
38
+ file_handler = logging.FileHandler(log_file)
39
+ file_handler.setFormatter(formatter)
40
+
41
+ logger.setLevel(logging.DEBUG)
42
+ file_handler.setLevel(logging.DEBUG)
43
+
44
+ if args.verbose:
45
+ stdout_handler.setLevel(logging.DEBUG)
46
+
47
+ else:
48
+ stdout_handler.setLevel(logging.INFO)
49
+
50
+ logger.addHandler(file_handler)
51
+ logger.addHandler(stdout_handler)
52
+
53
+ try:
54
+ options = {}
55
+ if args.warning:
56
+ options['warning'] = True
57
+
58
+ document = AUTOSAR().getInstance()
59
+ parser = ARXMLParser(options)
60
+ parser.load(args.INPUT, document)
61
+
62
+ writer = ARXMLWriter()
63
+ writer.save(args.OUTPUT, document)
64
+
65
+ except Exception as e:
66
+ #print(e)
67
+ raise e
68
+
69
+ if __name__ == "__main__":
70
+ main()
@@ -16,7 +16,7 @@ def main():
16
16
  ap.add_argument("-v", "--verbose", required= False, help= "Print debug information", action= "store_true")
17
17
  ap.add_argument("-f", "--format", required= False, help= "Specify the short or long name of Sw-C. [short|long]")
18
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='+')
19
+ ap.add_argument("INPUT", help = "The path of AUTOSAR XML", nargs='+')
20
20
 
21
21
  args = ap.parse_args()
22
22
 
@@ -49,7 +49,7 @@ def main():
49
49
  logger.addHandler(stdout_handler)
50
50
 
51
51
  try:
52
- parser = InputFileParser(args.Input)
52
+ parser = InputFileParser(args.INPUT)
53
53
  filenames = parser.parse()
54
54
 
55
55
  document = AUTOSAR().getInstance()
armodel/lib/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
 
2
2
  from .cli_args_parser import InputFileParser
3
- from .data_analyzer import SwComponentAnalyzer
3
+ from .sw_component import SwComponentAnalyzer
@@ -29,6 +29,6 @@ class SwComponentAnalyzer:
29
29
 
30
30
  for swc in sorted(swc_list, key = lambda o: o.short_name):
31
31
  if option['format'] == 'long':
32
- logger.info("%s" % swc.full_name)
32
+ logger.info("%s (%s)" % (swc.full_name, type(swc)))
33
33
  else:
34
34
  logger.info("%s" % swc.short_name)
@@ -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)
@@ -10,4 +10,9 @@ from .data_dictionary import *
10
10
  from .port_interface import *
11
11
  from .m2_msr import *
12
12
  from .implementation import *
13
- from .bsw_module_template import *
13
+ from .bsw_module_template import *
14
+ from .communication import *
15
+ from .calibration import *
16
+ from .ar_object import *
17
+ from .global_constraints import *
18
+ from .unit import *
@@ -1,4 +1,5 @@
1
1
  from abc import ABCMeta
2
+ from typing import List
2
3
 
3
4
  class ARObject(metaclass=ABCMeta):
4
5
  def __init__(self):
@@ -7,4 +8,42 @@ class ARObject(metaclass=ABCMeta):
7
8
 
8
9
  self.parent = None # type: ARObject
9
10
  self.checksum = None # type: str
11
+
10
12
  self.timestamp = None # type: str
13
+ self.uuid = None # type: str
14
+
15
+
16
+ class ARType(metaclass=ABCMeta):
17
+ def __init__(self) -> None:
18
+ self.timestamp = None # type: str
19
+ self.uuid = None # type: str
20
+
21
+ class ARBoolean(ARType):
22
+ def __init__(self) -> None:
23
+ super().__init__()
24
+
25
+ self.value = "" # type: bool
26
+ class ARLiteral(ARType):
27
+ def __init__(self) -> None:
28
+ super().__init__()
29
+
30
+ self.value = "" # type: str
31
+
32
+ class LLongName(ARObject):
33
+ def __init__(self):
34
+ super().__init__()
35
+
36
+ self.l = ""
37
+ self.value = ""
38
+
39
+ class MultilanguageLongName(ARObject):
40
+ def __init__(self):
41
+ super().__init__()
42
+
43
+ self.l4 = [] # type:List[LLongName]
44
+
45
+ def add_l4(self, l4: LLongName):
46
+ self.l4.append(l4)
47
+
48
+ def get_l4s(self) -> List[LLongName]:
49
+ return self.l4
@@ -1,11 +1,15 @@
1
1
  from typing import List
2
+
3
+ from .unit import Unit
2
4
  from .general_structure import Identifiable, ARObject, Referrable, CollectableElement, SwcBswMapping
3
5
  from .port_interface import SenderReceiverInterface, ClientServerInterface
4
6
  from .sw_component import SwComponentType, EcuAbstractionSwComponentType, AtomicSwComponentType, ApplicationSwComponentType, ServiceSwComponentType, CompositionSwComponentType, SensorActuatorSwComponentType
5
7
  from .datatype import ImplementationDataType, ApplicationDataType, DataTypeMappingSet, DataTypeMap, SwBaseType, ApplicationPrimitiveDataType, ApplicationRecordDataType
6
8
  from .m2_msr import CompuMethod
9
+ from .common_structure import ConstantSpecification
7
10
  from .implementation import BswImplementation, SwcImplementation, Implementation
8
11
  from .bsw_module_template import BswModuleDescription, BswModuleEntry
12
+ from .global_constraints import DataConstr
9
13
 
10
14
  class ARPackage(Identifiable, CollectableElement):
11
15
  def __init__(self, parent: ARObject, short_name: str):
@@ -128,9 +132,30 @@ class ARPackage(Identifiable, CollectableElement):
128
132
  sw_component = SwcBswMapping(self, short_name)
129
133
  self.elements[short_name] = sw_component
130
134
  return self.elements[short_name]
135
+
136
+ def createConstantSpecification(self, short_name: str) -> ConstantSpecification:
137
+ if (short_name not in self.elements):
138
+ spec = ConstantSpecification(self, short_name)
139
+ self.elements[short_name] = spec
140
+ return self.elements[short_name]
141
+
142
+ def createDataConstr(self, short_name: str) -> DataConstr:
143
+ if (short_name not in self.elements):
144
+ spec = DataConstr(self, short_name)
145
+ self.elements[short_name] = spec
146
+ return self.elements[short_name]
147
+
148
+ def createUnit(self, short_name: str) -> Unit:
149
+ if (short_name not in self.elements):
150
+ spec = Unit(self, short_name)
151
+ self.elements[short_name] = spec
152
+ return self.elements[short_name]
131
153
 
132
154
  def getApplicationPrimitiveDataTypes(self) -> List[ApplicationPrimitiveDataType]:
133
155
  return list(filter(lambda a: isinstance(a, ApplicationPrimitiveDataType), self.elements.values()))
156
+
157
+ def getApplicationDataType(self) -> List[ApplicationDataType]:
158
+ return list(sorted(filter(lambda a: isinstance(a, ApplicationDataType), self.elements.values()), key= lambda o:o.short_name))
134
159
 
135
160
  def getImplementationDataTypes(self) -> List[ImplementationDataType]:
136
161
  return list(filter(lambda a: isinstance(a, ImplementationDataType), self.elements.values()))
@@ -179,8 +204,17 @@ class ARPackage(Identifiable, CollectableElement):
179
204
 
180
205
  def getSwcBswMappings(self) -> List[SwcBswMapping]:
181
206
  return list(filter(lambda a: isinstance(a, SwcBswMapping), self.elements.values()))
207
+
208
+ def getConstantSpecifications(self) -> List[ConstantSpecification]:
209
+ return list(filter(lambda a: isinstance(a, ConstantSpecification), self.elements.values()))
210
+
211
+ def getDataConstrs(self) -> List[DataConstr]:
212
+ return list(filter(lambda a: isinstance(a, DataConstr), self.elements.values()))
213
+
214
+ def getUnits(self) -> List[Unit]:
215
+ return list(filter(lambda a: isinstance(a, Unit), self.elements.values()))
182
216
 
183
- class AUTOSAR (ARObject, CollectableElement):
217
+ class AUTOSAR (CollectableElement):
184
218
  __instance = None
185
219
 
186
220
  @staticmethod
armodel/models/ar_ref.py CHANGED
@@ -24,13 +24,23 @@ class AtpInstanceRef(ARObject, metaclass=ABCMeta):
24
24
  raise NotImplementedError("AtpInstanceRef is an abstract class.")
25
25
  super().__init__()
26
26
 
27
- class ProvidedPortPrototypeInstanceRef(AtpInstanceRef):
27
+ class PortInCompositionTypeInstanceRef(AtpInstanceRef, metaclass=ABCMeta):
28
+ def __init__(self):
29
+ if type(self) == PortInCompositionTypeInstanceRef:
30
+ raise NotImplementedError("PortInCompositionTypeInstanceRef is an abstract class.")
31
+ super().__init__()
32
+
33
+ self.abstract_context_component_ref = None # type: RefType
34
+ self.base_ref = None # type: RefType
35
+ self.target_port_ref = None # type: RefType
36
+
37
+ class PPortInCompositionInstanceRef(PortInCompositionTypeInstanceRef):
28
38
  def __init__(self):
29
39
  super().__init__()
30
40
  self.context_component_ref = None # type: RefType
31
41
  self.target_p_port_ref = None # type: RefType
32
42
 
33
- class RequiredPortPrototypeInstanceRef(AtpInstanceRef):
43
+ class RPortInCompositionInstanceRef(PortInCompositionTypeInstanceRef):
34
44
  def __init__(self):
35
45
  super().__init__()
36
46
  self.context_component_ref = None # type: RefType
@@ -1,6 +1,7 @@
1
1
  from abc import ABCMeta
2
2
  from typing import List
3
3
  from .general_structure import AtpStructureElement, ARObject, ARElement
4
+ from .ar_object import ARBoolean
4
5
  from .common_structure import ExecutableEntity, ModeDeclarationGroupPrototype, InternalBehavior, Identifiable
5
6
  from .ar_ref import RefType
6
7
 
@@ -222,8 +223,8 @@ class BswModuleEntry(ARElement):
222
223
  super().__init__(parent, short_name)
223
224
 
224
225
  self.service_id = None # type: int
225
- self.is_reentrant = None # type: bool
226
- self.is_synchronous = None # type: bool
226
+ self.is_reentrant = None # type: ARBoolean
227
+ self.is_synchronous = None # type: ARBoolean
227
228
  self.call_type = None # type: str
228
229
  self._execution_context = None # type: str
229
230
  self._sw_service_impl_policy = None # type: str
@@ -0,0 +1,16 @@
1
+ from .ar_object import ARObject
2
+ from .ar_ref import RefType
3
+
4
+ class SwValues(ARObject):
5
+ def __init__(self):
6
+ super().__init__()
7
+
8
+ self.v = None # type: float
9
+
10
+ class SwValueCont(ARObject):
11
+ def __init__(self):
12
+ super().__init__()
13
+
14
+ self.unit_ref = None # type: RefType
15
+ self.sw_values_phys = None # type: SwValues
16
+
@@ -10,13 +10,105 @@ from .ar_ref import RefType
10
10
  import re
11
11
 
12
12
  class ValueSpecification(ARObject, metaclass=ABCMeta):
13
+ '''
14
+ Base class for expressions leading to a value which can be used to initialize a data object.
15
+
16
+ Base : ARObject
17
+ Subclasses : AbstractRuleBasedValueSpecification, ApplicationValueSpecification, CompositeValueSpecification,
18
+ ConstantReference, NotAvailableValueSpecification, NumericalValueSpecification, ReferenceValueSpecification,
19
+ TextValueSpecification
20
+ '''
13
21
  def __init__(self):
14
22
  if type(self) == ValueSpecification:
15
23
  raise NotImplementedError("ValueSpecification is an abstract class.")
24
+
16
25
  super().__init__()
17
26
 
18
27
  self.short_label = None
19
28
 
29
+ class CompositeRuleBasedValueArgument(ValueSpecification, metaclass=ABCMeta):
30
+ '''
31
+ This meta-class has the ability to serve as the abstract base class for ValueSpecifications that can be
32
+ used for compound primitive data types.
33
+
34
+ Base : ARObject
35
+ Subclasses : ApplicationRuleBasedValueSpecification, ApplicationValueSpecification
36
+ '''
37
+ def __init__(self):
38
+ if type(self) == CompositeRuleBasedValueArgument:
39
+ raise NotImplementedError("CompositeRuleBasedValueArgument is an abstract class.")
40
+
41
+ super().__init__()
42
+
43
+ class CompositeValueSpecification(ValueSpecification, metaclass=ABCMeta):
44
+ '''
45
+ This abstract meta-class acts a base class for ValueSpecifications that have a composite form.
46
+
47
+ Base : ARObject, ValueSpecification
48
+ Subclasses : ArrayValueSpecification, RecordValueSpecification
49
+ '''
50
+ def __init__(self):
51
+ if type(self) == CompositeValueSpecification:
52
+ raise NotImplementedError("CompositeValueSpecification is an abstract class.")
53
+
54
+ super().__init__()
55
+
56
+ class ApplicationValueSpecification(CompositeRuleBasedValueArgument):
57
+ '''
58
+ This meta-class represents values for DataPrototypes typed by ApplicationDataTypes (this includes in
59
+ particular compound primitives).
60
+ For further details refer to ASAM CDF 2.0. This meta-class corresponds to some extent with
61
+ SW-INSTANCE in ASAM CDF 2.0.
62
+
63
+ Base ARObject, CompositeRuleBasedValueArgument, ValueSpecification
64
+ '''
65
+ def __init__(self):
66
+ super().__init__()
67
+
68
+ self.category = None
69
+ self.sw_Axis_cont = []
70
+ self.sw_value_cont = None
71
+
72
+ class RecordValueSpecification(CompositeValueSpecification):
73
+ '''
74
+ Specifies the values for a record.
75
+
76
+ Base : ARObject, CompositeValueSpecification, ValueSpecification
77
+ '''
78
+ def __init__(self):
79
+ super().__init__()
80
+
81
+ self._fields = []
82
+
83
+ def add_field(self, field: ValueSpecification):
84
+ self._fields.append(field)
85
+
86
+ def get_fields(self) -> List[ValueSpecification]:
87
+ return self._fields
88
+
89
+ class TextValueSpecification(ValueSpecification):
90
+ def __init__(self):
91
+ super().__init__()
92
+
93
+ self.value = None # type: str
94
+
95
+ class NumericalValueSpecification(ValueSpecification):
96
+ def __init__(self):
97
+ super().__init__()
98
+
99
+ self.value = None # type: float
100
+
101
+ class ArrayValueSpecification(ValueSpecification):
102
+ def __init__(self):
103
+ super().__init__()
104
+
105
+ self._element = [] # type: List[ValueSpecification]
106
+
107
+ def add_element(self, element: ValueSpecification):
108
+ self._element.append(element)
109
+
110
+ def get_elements(self) -> List[ValueSpecification]:
111
+ return self._element
20
112
 
21
113
  class ConstantSpecification(ARElement):
22
114
  def __init__(self, parent, short_name):
@@ -0,0 +1,8 @@
1
+ from . import ARObject
2
+
3
+ class TransmissionAcknowledgementRequest(ARObject):
4
+ def __init__(self):
5
+ super().__init__()
6
+
7
+ self.timeout = None # type: float
8
+
@@ -1,7 +1,9 @@
1
1
  from abc import ABCMeta
2
2
  from typing import List
3
- from .general_structure import ARElement, Referrable, ARObject
4
- from .data_prototype import ApplicationArrayElement, ApplicationRecordElement
3
+
4
+ from .ar_package import Referrable
5
+ from .general_structure import ARElement, ARObject
6
+ from .data_prototype import ApplicationRecordElement
5
7
  from .data_dictionary import SwDataDefProps
6
8
  from .common_structure import ImplementationDataTypeElement
7
9
 
@@ -14,11 +16,23 @@ class ImplementationProps(Referrable, metaclass=ABCMeta):
14
16
  super().__init__(parent, short_name)
15
17
  self.symbol = ""
16
18
 
17
-
18
19
  class SymbolProps(ImplementationProps):
19
20
  def __init__(self, parent: ARObject, short_name: str):
20
21
  super().__init__(parent, short_name)
21
22
 
23
+ class BaseTypeDefinition(ARObject):
24
+ def __init__(self):
25
+ super().__init__()
26
+
27
+ class BaseTypeDirectDefinition(BaseTypeDefinition):
28
+ def __init__(self):
29
+ super().__init__()
30
+
31
+ self.base_type_encoding = None
32
+ self.base_type_size = None # type: int
33
+ self.byte_order = None # type: str
34
+ self.mem_alignment = None
35
+ self.native_declaration = None
22
36
 
23
37
  class BaseType(ARElement, metaclass=ABCMeta):
24
38
  def __init__(self, parent: ARObject, short_name: str):
@@ -26,14 +40,13 @@ class BaseType(ARElement, metaclass=ABCMeta):
26
40
  raise NotImplementedError("BaseType is an abstract class.")
27
41
 
28
42
  super().__init__(parent, short_name)
29
- self.base_type_definition = None # Type: BaseTypeDefinition
30
43
 
44
+ self.base_type_definition = BaseTypeDirectDefinition()
31
45
 
32
46
  class SwBaseType(BaseType):
33
47
  def __init__(self, parent: ARObject, short_name: str):
34
48
  super().__init__(parent, short_name)
35
49
 
36
-
37
50
  class AtpType(ARElement, metaclass=ABCMeta):
38
51
  def __init__(self, parent: ARObject, short_name: str):
39
52
  if type(self) == AtpType:
@@ -84,12 +97,17 @@ class ApplicationRecordDataType(ApplicationCompositeDataType):
84
97
  def __init__(self, parent: ARObject, short_name: str):
85
98
  super().__init__(parent, short_name)
86
99
 
100
+ self.record_elements = []
101
+
87
102
  def createApplicationRecordElement(self, short_name: str) -> ApplicationRecordElement:
88
103
  if (short_name not in self.elements):
89
104
  record_element = ApplicationRecordElement(self, short_name)
90
105
  self.elements[short_name] = record_element
106
+ self.record_elements.append(self.elements[short_name])
91
107
  return self.elements[short_name]
92
108
 
109
+ def getApplicationRecordElements(self) -> List[ApplicationRecordElement]:
110
+ return self.record_elements
93
111
 
94
112
  class AbstractImplementationDataType(AutosarDataType, metaclass=ABCMeta):
95
113
  def __init__(self, parent: ARObject, short_name: str):
@@ -1,13 +1,52 @@
1
1
  from abc import ABCMeta
2
2
  from typing import List
3
+
3
4
  from .ar_object import ARObject
4
- from .ar_ref import RefType
5
5
 
6
6
 
7
+ class Sd(ARObject):
8
+ def __init__(self):
9
+ super().__init__()
10
+
11
+ self.gid = ""
12
+ self.value = ""
13
+
14
+ class Sdg(ARObject):
15
+ def __init__(self):
16
+ super().__init__()
17
+
18
+ self.gid = ""
19
+ self.sd = [] # type: List[Sd]
20
+ self.sdg_caption = None
21
+ self.sdg_contents_type = None
22
+
23
+ def addSd(self, sd: Sd):
24
+ self.sd.append(sd)
25
+
26
+ def getSds(self) -> List[Sd]:
27
+ return self.sd
28
+
29
+ class AdminData(ARObject):
30
+ def __init__(self):
31
+ super().__init__()
32
+
33
+ self.doc_revision = []
34
+ self.language = None
35
+ self.sdg = []
36
+ self.used_languages = None
37
+
38
+ def addSdg(self, sdg: Sdg):
39
+ self.sdg.append(sdg)
40
+
41
+ def getSdgs(self) -> List[Sdg]:
42
+ return self.sdg
43
+
7
44
  class Referrable(ARObject, metaclass=ABCMeta):
8
45
  def __init__(self, parent: ARObject, short_name: str):
9
46
  if type(self) == Referrable:
10
47
  raise NotImplementedError("Referrable is an abstract class.")
48
+ ARObject.__init__(self)
49
+
11
50
  self.parent = parent
12
51
  self.short_name = short_name
13
52
 
@@ -23,11 +62,15 @@ class MultilanguageReferrable(Referrable, metaclass=ABCMeta):
23
62
  self.parent = parent
24
63
  self.long_name = None
25
64
 
26
- class CollectableElement(metaclass=ABCMeta):
65
+ class CollectableElement(ARObject, metaclass=ABCMeta):
27
66
  def __init__(self):
28
67
  if type(self) == CollectableElement:
29
68
  raise NotImplementedError("CollectableElement is an abstract class.")
30
- self.elements = {} # type: dict(PackageableElement)
69
+ self.elements = {} # type: dict[str, PackageableElement]
70
+
71
+ def getTotalElement(self) -> int:
72
+ #return len(list(filter(lambda a: not isinstance(a, ARPackage) , self.elements.values())))
73
+ return len(self.elements.values())
31
74
 
32
75
  def getElements(self):
33
76
  return self.elements.values()
@@ -44,6 +87,7 @@ class Identifiable(MultilanguageReferrable, CollectableElement, metaclass=ABCMet
44
87
  MultilanguageReferrable.__init__(self, parent, short_name)
45
88
  CollectableElement.__init__(self)
46
89
 
90
+ self.admin_data = None # type: AdminData
47
91
  self._category = None
48
92
  self.desc = None
49
93
 
@@ -102,6 +146,7 @@ class ARElement(PackageableElement, metaclass=ABCMeta):
102
146
  if type(self) == ARElement:
103
147
  raise NotImplementedError("ARElement is an abstract class.")
104
148
  super().__init__(parent, short_name)
149
+
105
150
 
106
151
  class AtpStructureElement(AtpFeature, metaclass=ABCMeta):
107
152
  def __init__(self, parent: ARObject, short_name: str):