armodel 1.7.6__py3-none-any.whl → 1.7.8__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 (69) hide show
  1. armodel/cli/arxml_dump_cli.py +33 -22
  2. armodel/cli/arxml_format_cli.py +25 -13
  3. armodel/models/M2/AUTOSARTemplates/AutosarTopLevelStructure.py +95 -21
  4. armodel/models/M2/AUTOSARTemplates/BswModuleTemplate/BswBehavior.py +359 -59
  5. armodel/models/M2/AUTOSARTemplates/BswModuleTemplate/BswOverview.py +134 -35
  6. armodel/models/M2/AUTOSARTemplates/CommonStructure/Filter.py +17 -7
  7. armodel/models/M2/AUTOSARTemplates/CommonStructure/InternalBehavior.py +10 -1
  8. armodel/models/M2/AUTOSARTemplates/CommonStructure/TriggerDeclaration.py +18 -2
  9. armodel/models/M2/AUTOSARTemplates/ECUCDescriptionTemplate.py +20 -19
  10. armodel/models/M2/AUTOSARTemplates/EcuResourceTemplate/HwElementCategory.py +59 -0
  11. armodel/models/M2/AUTOSARTemplates/EcuResourceTemplate/__init__.py +145 -0
  12. armodel/models/M2/AUTOSARTemplates/GenericStructure/GeneralTemplateClasses/ARPackage.py +215 -157
  13. armodel/models/M2/AUTOSARTemplates/GenericStructure/GeneralTemplateClasses/Identifiable.py +69 -35
  14. armodel/models/M2/AUTOSARTemplates/GenericStructure/GeneralTemplateClasses/PrimitiveTypes.py +17 -1
  15. armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/Communication.py +19 -5
  16. armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/Components/__init__.py +113 -39
  17. armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/Composition/__init__.py +3 -2
  18. armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/Datatype/DataPrototypes.py +41 -16
  19. armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/Datatype/Datatypes.py +10 -3
  20. armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/EndToEndProtection.py +13 -6
  21. armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/PortInterface/__init__.py +111 -38
  22. armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/SwcInternalBehavior/AccessCount.py +9 -1
  23. armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/SwcInternalBehavior/ModeDeclarationGroup.py +5 -4
  24. armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/SwcInternalBehavior/RTEEvents.py +26 -8
  25. armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/SwcInternalBehavior/__init__.py +28 -6
  26. armodel/models/M2/AUTOSARTemplates/SystemTemplate/DataMapping.py +167 -5
  27. armodel/models/M2/AUTOSARTemplates/SystemTemplate/DoIp.py +29 -0
  28. armodel/models/M2/AUTOSARTemplates/SystemTemplate/EcuResourceMapping.py +45 -0
  29. armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/Fibex4Can/CanTopology.py +31 -21
  30. armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/Fibex4Ethernet/EthernetFrame.py +5 -3
  31. armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/Fibex4Ethernet/EthernetTopology.py +9 -0
  32. armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/Fibex4Flexray/FlexrayCommunication.py +76 -0
  33. armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/Fibex4Flexray/FlexrayTopology.py +654 -0
  34. armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/Fibex4Flexray/__init__.py +0 -0
  35. armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/FibexCore/CoreCommunication.py +539 -77
  36. armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/FibexCore/CoreTopology.py +158 -40
  37. armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/FibexCore/EcuInstance.py +28 -6
  38. armodel/models/M2/AUTOSARTemplates/SystemTemplate/InstanceRefs.py +2 -0
  39. armodel/models/M2/AUTOSARTemplates/SystemTemplate/NetworkManagement.py +245 -130
  40. armodel/models/M2/AUTOSARTemplates/SystemTemplate/SWmapping.py +27 -0
  41. armodel/models/M2/AUTOSARTemplates/SystemTemplate/Transformer/__init__.py +524 -0
  42. armodel/models/M2/AUTOSARTemplates/SystemTemplate/TransportProtocols.py +592 -17
  43. armodel/models/M2/AUTOSARTemplates/SystemTemplate/__init__.py +33 -21
  44. armodel/models/M2/MSR/AsamHdo/AdminData.py +1 -2
  45. armodel/models/M2/MSR/AsamHdo/ComputationMethod.py +3 -1
  46. armodel/models/M2/MSR/AsamHdo/SpecialData.py +35 -8
  47. armodel/models/M2/MSR/DataDictionary/RecordLayout.py +0 -3
  48. armodel/models/__init__.py +8 -0
  49. armodel/parser/abstract_arxml_parser.py +34 -27
  50. armodel/parser/arxml_parser.py +1778 -616
  51. armodel/parser/file_parser.py +5 -3
  52. armodel/tests/test_armodel/models/test_ar_package.py +6 -11
  53. armodel/tests/test_armodel/models/test_bsw_module_template.py +5 -3
  54. armodel/tests/test_armodel/models/test_datatype.py +1 -1
  55. armodel/tests/test_armodel/models/test_port_interface.py +116 -117
  56. armodel/tests/test_armodel/parser/test_bsw_module_descriiption.py +218 -0
  57. armodel/tests/test_armodel/parser/test_sw_components.py +54 -22
  58. armodel/tests/test_armodel/parser/test_system.py +2 -8
  59. armodel/transformer/__init__.py +0 -0
  60. armodel/transformer/abstract.py +6 -0
  61. armodel/transformer/admin_data.py +31 -0
  62. armodel/writer/abstract_arxml_writer.py +27 -33
  63. armodel/writer/arxml_writer.py +1875 -599
  64. {armodel-1.7.6.dist-info → armodel-1.7.8.dist-info}/METADATA +81 -3
  65. {armodel-1.7.6.dist-info → armodel-1.7.8.dist-info}/RECORD +69 -56
  66. {armodel-1.7.6.dist-info → armodel-1.7.8.dist-info}/LICENSE +0 -0
  67. {armodel-1.7.6.dist-info → armodel-1.7.8.dist-info}/WHEEL +0 -0
  68. {armodel-1.7.6.dist-info → armodel-1.7.8.dist-info}/entry_points.txt +0 -0
  69. {armodel-1.7.6.dist-info → armodel-1.7.8.dist-info}/top_level.txt +0 -0
@@ -3,6 +3,8 @@ import os
3
3
  import re
4
4
  from typing import List
5
5
 
6
+ from colorama import Fore
7
+
6
8
 
7
9
  class FileListParser:
8
10
  '''
@@ -22,8 +24,8 @@ class FileListParser:
22
24
  for line in f_in:
23
25
  if not line.startswith('#'):
24
26
  self.file_list.append(line.strip())
25
- except:
26
- self.logger.error("No such file or directory: %s" % os.path.realpath(file))
27
+ except IOError:
28
+ self.logger.error(Fore.RED + "No such file or directory: %s" % os.path.realpath(file) + Fore.WHITE)
27
29
 
28
30
  def parse_dir_files(self, dir_name):
29
31
  for (root, _, files) in os.walk(dir_name, topdown=False):
@@ -41,4 +43,4 @@ class FileListParser:
41
43
  logging.debug("Parse ARXML list file %s " % input_file)
42
44
  self.parse_text_file(input_file[1:])
43
45
  else:
44
- self.file_list.append(input_file)
46
+ self.file_list.append(input_file)
@@ -2,17 +2,11 @@
2
2
  import pytest
3
3
 
4
4
  from ....models.M2.AUTOSARTemplates.SWComponentTemplate.Datatype.Datatypes import ApplicationPrimitiveDataType, ApplicationRecordDataType
5
-
6
5
  from ....models.M2.MSR.AsamHdo.BaseTypes import SwBaseType
7
-
8
6
  from ....models.M2.AUTOSARTemplates.GenericStructure.GeneralTemplateClasses.Identifiable import PackageableElement
9
-
10
7
  from ....models.M2.AUTOSARTemplates.GenericStructure.GeneralTemplateClasses.Identifiable import CollectableElement
11
-
12
8
  from ....models.M2.AUTOSARTemplates.GenericStructure.GeneralTemplateClasses.Identifiable import Identifiable, MultilanguageReferrable, Referrable
13
-
14
9
  from ....models.M2.AUTOSARTemplates.GenericStructure.GeneralTemplateClasses.ArObject import ARObject
15
-
16
10
  from ....models.M2.AUTOSARTemplates.CommonStructure.ImplementationDataTypes import ImplementationDataType
17
11
  from ....models.M2.AUTOSARTemplates.SWComponentTemplate.Components import ApplicationSwComponentType, AtomicSwComponentType, EcuAbstractionSwComponentType, SwComponentType
18
12
  from ....models.M2.AUTOSARTemplates.AutosarTopLevelStructure import AUTOSAR
@@ -23,28 +17,29 @@ from ....models.M2.AUTOSARTemplates.SWComponentTemplate.PortInterface import Cli
23
17
  from ....models.M2.AUTOSARTemplates.SWComponentTemplate.Components import ServiceSwComponentType
24
18
  from ....models.M2.AUTOSARTemplates.SWComponentTemplate.Components import CompositionSwComponentType
25
19
 
20
+
26
21
  class TestAUTOSAR:
27
22
 
28
23
  def test_autosar_singleton_exception(self):
29
24
  AUTOSAR.getInstance()
30
25
  with pytest.raises(Exception) as err:
31
26
  AUTOSAR()
32
- assert(str(err.value) == "The AUTOSAR is singleton!")
27
+ assert (str(err.value) == "The AUTOSAR is singleton!")
33
28
 
34
29
  def test_cannot_find_element(self):
35
30
  document = AUTOSAR.getInstance()
36
- #with pytest.raises(Exception) as err:
31
+ # with pytest.raises(Exception) as err:
37
32
  # document.find("/sw_package/not_found")
38
- #assert(str(err.value) ==
33
+ # assert(str(err.value) ==
39
34
  # "The sw_package of reference </sw_package/not_found> does not exist.")
40
- assert(document.find("/sw_package/not_found") == None)
35
+ assert (document.find("/sw_package/not_found") is None)
41
36
 
42
37
  def test_autosar(self):
43
38
  document = AUTOSAR.getInstance()
44
39
  assert (isinstance(document, CollectableElement))
45
40
  assert (isinstance(document, AUTOSAR))
46
41
  assert (len(document.getARPackages()) == 0)
47
- assert (document.schema_location == "")
42
+ assert (document.schema_location is None)
48
43
  assert (document.full_name == "")
49
44
 
50
45
  def test_create_autosar_package(self):
@@ -1,10 +1,9 @@
1
1
  import pytest
2
2
 
3
3
  from ....models.M2.AUTOSARTemplates.BswModuleTemplate.BswOverview import BswModuleDescription
4
-
5
4
  from ....models.M2.AUTOSARTemplates.BswModuleTemplate.BswBehavior import BswCalledEntity, BswModuleEntity
6
-
7
5
  from ....models.M2.AUTOSARTemplates.BswModuleTemplate.BswInterfaces import BswModuleEntry
6
+ from ....models.M2.AUTOSARTemplates.GenericStructure.GeneralTemplateClasses.PrimitiveTypes import CategoryString
8
7
  from .... import AUTOSAR
9
8
 
10
9
  class TestBswModuleDescription:
@@ -24,7 +23,10 @@ class TestBswModuleDescription:
24
23
  #assert(str(err.value) == "Invalid category <invalid> of BswModuleDescription <bsw_module>")
25
24
 
26
25
  bsw_module_description.setCategory("BSW_MODULE")
27
- assert(bsw_module_description.getCategory() == "BSW_MODULE")
26
+ assert(bsw_module_description.getCategory().getValue() == "BSW_MODULE")
27
+
28
+ bsw_module_description.setCategory(CategoryString().setValue("BSW_MODULE"))
29
+ assert(bsw_module_description.getCategory().getValue() == "BSW_MODULE")
28
30
 
29
31
  class Test_M2_AUTOSARTemplates_BswModuleTemplate_BswInterfaces:
30
32
  def test_BswModuleEntry(self):
@@ -144,7 +144,7 @@ class Test_M2_AUTOSARTemplates_SWComponentTemplate_Datatype_Datatypes:
144
144
 
145
145
  assert(data_type.parent == ar_root)
146
146
  assert(data_type.short_name == "ApplicationArrayDataType")
147
- assert(data_type.dynamic_array_size_profile == None)
147
+ assert(data_type.dynamicArraySizeProfile == None)
148
148
  assert(data_type.element == None)
149
149
 
150
150
  def test_ApplicationRecordDataType(self):
@@ -23,186 +23,185 @@ class Test_M2_AUTOSARTemplates_SWComponentTemplate_PortInterface:
23
23
  def test_PortInterface(self):
24
24
  with pytest.raises(NotImplementedError) as err:
25
25
  PortInterface(AUTOSAR.getInstance(), "PortInterface")
26
- assert(str(err.value) == "PortInterface is an abstract class.")
26
+ assert (str(err.value) == "PortInterface is an abstract class.")
27
27
 
28
28
  def test_DataInterface(self):
29
29
  with pytest.raises(NotImplementedError) as err:
30
30
  DataInterface(AUTOSAR.getInstance(), "DataInterface")
31
- assert(str(err.value) == "DataInterface is an abstract class.")
31
+ assert (str(err.value) == "DataInterface is an abstract class.")
32
32
 
33
33
  def test_NvDataInterface(self):
34
34
  document = AUTOSAR.getInstance()
35
35
  ar_root = document.createARPackage("AUTOSAR")
36
36
  data_if = NvDataInterface(ar_root, "NvDataInterface")
37
37
 
38
- assert(isinstance(data_if, ARElement))
39
- assert(isinstance(data_if, ARObject))
40
- # assert(isinstance(sr, AtpBlueprint))
41
- # assert(isinstance(sr, AtpBlueprintable))
42
- # assert(isinstance(sr, AtpClassifier))
43
- assert(isinstance(data_if, AtpType))
44
- assert(isinstance(data_if, CollectableElement))
45
- assert(isinstance(data_if, DataInterface))
46
- assert(isinstance(data_if, Identifiable))
47
- assert(isinstance(data_if, MultilanguageReferrable))
48
- assert(isinstance(data_if, PackageableElement))
49
- assert(isinstance(data_if, PortInterface))
50
- assert(isinstance(data_if, Referrable))
51
- assert(isinstance(data_if, NvDataInterface))
52
-
53
- assert(data_if.parent == ar_root)
54
- assert(data_if.short_name == "NvDataInterface")
38
+ assert (isinstance(data_if, ARElement))
39
+ assert (isinstance(data_if, ARObject))
40
+ # assert (isinstance(sr, AtpBlueprint))
41
+ # assert (isinstance(sr, AtpBlueprintable))
42
+ # assert (isinstance(sr, AtpClassifier))
43
+ assert (isinstance(data_if, AtpType))
44
+ assert (isinstance(data_if, CollectableElement))
45
+ assert (isinstance(data_if, DataInterface))
46
+ assert (isinstance(data_if, Identifiable))
47
+ assert (isinstance(data_if, MultilanguageReferrable))
48
+ assert (isinstance(data_if, PackageableElement))
49
+ assert (isinstance(data_if, PortInterface))
50
+ assert (isinstance(data_if, Referrable))
51
+ assert (isinstance(data_if, NvDataInterface))
52
+
53
+ assert (data_if.parent == ar_root)
54
+ assert (data_if.short_name == "NvDataInterface")
55
55
 
56
56
  def test_ParameterInterface(self):
57
57
  document = AUTOSAR.getInstance()
58
58
  ar_root = document.createARPackage("AUTOSAR")
59
59
  data_if = ParameterInterface(ar_root, "ParameterInterface")
60
60
 
61
- assert(isinstance(data_if, ARElement))
62
- assert(isinstance(data_if, ARObject))
63
- # assert(isinstance(sr, AtpBlueprint))
64
- # assert(isinstance(sr, AtpBlueprintable))
65
- # assert(isinstance(sr, AtpClassifier))
66
- assert(isinstance(data_if, AtpType))
67
- assert(isinstance(data_if, CollectableElement))
68
- assert(isinstance(data_if, DataInterface))
69
- assert(isinstance(data_if, Identifiable))
70
- assert(isinstance(data_if, MultilanguageReferrable))
71
- assert(isinstance(data_if, PackageableElement))
72
- assert(isinstance(data_if, PortInterface))
73
- assert(isinstance(data_if, Referrable))
74
- assert(isinstance(data_if, ParameterInterface))
75
-
76
- assert(data_if.parent == ar_root)
77
- assert(data_if.short_name == "ParameterInterface")
61
+ assert (isinstance(data_if, ARElement))
62
+ assert (isinstance(data_if, ARObject))
63
+ # assert (isinstance(sr, AtpBlueprint))
64
+ # assert (isinstance(sr, AtpBlueprintable))
65
+ # assert (isinstance(sr, AtpClassifier))
66
+ assert (isinstance(data_if, AtpType))
67
+ assert (isinstance(data_if, CollectableElement))
68
+ assert (isinstance(data_if, DataInterface))
69
+ assert (isinstance(data_if, Identifiable))
70
+ assert (isinstance(data_if, MultilanguageReferrable))
71
+ assert (isinstance(data_if, PackageableElement))
72
+ assert (isinstance(data_if, PortInterface))
73
+ assert (isinstance(data_if, Referrable))
74
+ assert (isinstance(data_if, ParameterInterface))
75
+
76
+ assert (data_if.parent == ar_root)
77
+ assert (data_if.short_name == "ParameterInterface")
78
78
 
79
79
  def test_SenderReceiverInterface(self):
80
80
  document = AUTOSAR.getInstance()
81
81
  ar_root = document.createARPackage("AUTOSAR")
82
82
  sr_if = SenderReceiverInterface(ar_root, "sr_if")
83
83
 
84
- assert(isinstance(sr_if, ARElement))
85
- assert(isinstance(sr_if, ARObject))
86
- # assert(isinstance(sr, AtpBlueprint))
87
- # assert(isinstance(sr, AtpBlueprintable))
88
- # assert(isinstance(sr, AtpClassifier))
89
- assert(isinstance(sr_if, AtpType))
90
- assert(isinstance(sr_if, CollectableElement))
91
- assert(isinstance(sr_if, DataInterface))
92
- assert(isinstance(sr_if, Identifiable))
93
- assert(isinstance(sr_if, MultilanguageReferrable))
94
- assert(isinstance(sr_if, PackageableElement))
95
- assert(isinstance(sr_if, PortInterface))
96
- assert(isinstance(sr_if, Referrable))
97
- assert(isinstance(sr_if, SenderReceiverInterface))
98
-
99
- assert(sr_if.short_name == "sr_if")
100
- assert(sr_if.parent == ar_root)
101
- assert(len(sr_if.getDataElements()) == 0)
84
+ assert (isinstance(sr_if, ARElement))
85
+ assert (isinstance(sr_if, ARObject))
86
+ # assert (isinstance(sr, AtpBlueprint))
87
+ # assert (isinstance(sr, AtpBlueprintable))
88
+ # assert (isinstance(sr, AtpClassifier))
89
+ assert (isinstance(sr_if, AtpType))
90
+ assert (isinstance(sr_if, CollectableElement))
91
+ assert (isinstance(sr_if, DataInterface))
92
+ assert (isinstance(sr_if, Identifiable))
93
+ assert (isinstance(sr_if, MultilanguageReferrable))
94
+ assert (isinstance(sr_if, PackageableElement))
95
+ assert (isinstance(sr_if, PortInterface))
96
+ assert (isinstance(sr_if, Referrable))
97
+ assert (isinstance(sr_if, SenderReceiverInterface))
98
+
99
+ assert (sr_if.short_name == "sr_if")
100
+ assert (sr_if.parent == ar_root)
101
+ assert (len(sr_if.getDataElements()) == 0)
102
102
 
103
103
  element = sr_if.createDataElement("element")
104
- assert(isinstance(element, VariableDataPrototype))
105
- assert(element.short_name == "element")
106
- assert(len(sr_if.getDataElements()) == 1)
104
+ assert (isinstance(element, VariableDataPrototype))
105
+ assert (element.short_name == "element")
106
+ assert (len(sr_if.getDataElements()) == 1)
107
107
 
108
108
  element2 = sr_if.getDataElement("element")
109
- assert(element == element2)
109
+ assert (element == element2)
110
110
 
111
111
  with pytest.raises(IndexError) as err:
112
112
  sr_if.getDataElement("non_exist_element")
113
- assert(str(err.value) == "data element <non_exist_element> can not be found.")
113
+ assert (str(err.value) == "data element <non_exist_element> can not be found.")
114
114
 
115
115
  def test_ArgumentDataPrototype(self):
116
116
  document = AUTOSAR.getInstance()
117
117
  ar_root = document.createARPackage("AUTOSAR")
118
118
  prototype = ArgumentDataPrototype(ar_root, "ArgumentDataPrototype")
119
119
 
120
- assert(isinstance(prototype, ARObject))
121
- assert(isinstance(prototype, AtpFeature))
122
- assert(isinstance(prototype, AtpPrototype))
123
- assert(isinstance(prototype, AutosarDataPrototype))
124
- assert(isinstance(prototype, DataPrototype))
125
- assert(isinstance(prototype, Identifiable))
126
- assert(isinstance(prototype, MultilanguageReferrable))
127
- assert(isinstance(prototype, Referrable))
128
- assert(isinstance(prototype, ArgumentDataPrototype))
129
-
130
- assert(prototype.getParent() == ar_root)
131
- assert(prototype.getShortName() == "ArgumentDataPrototype")
132
- assert(prototype.getDirection() == None)
133
- assert(prototype.getServerArgumentImplPolicy() == None)
120
+ assert (isinstance(prototype, ARObject))
121
+ assert (isinstance(prototype, AtpFeature))
122
+ assert (isinstance(prototype, AtpPrototype))
123
+ assert (isinstance(prototype, AutosarDataPrototype))
124
+ assert (isinstance(prototype, DataPrototype))
125
+ assert (isinstance(prototype, Identifiable))
126
+ assert (isinstance(prototype, MultilanguageReferrable))
127
+ assert (isinstance(prototype, Referrable))
128
+ assert (isinstance(prototype, ArgumentDataPrototype))
129
+
130
+ assert (prototype.getParent() == ar_root)
131
+ assert (prototype.getShortName() == "ArgumentDataPrototype")
132
+ assert (prototype.getDirection() == None)
133
+ assert (prototype.getServerArgumentImplPolicy() == None)
134
134
 
135
135
  def test_ApplicationError(self):
136
136
  document = AUTOSAR.getInstance()
137
137
  ar_root = document.createARPackage("AUTOSAR")
138
138
  app_error = ApplicationError(ar_root, "ApplicationError")
139
139
 
140
- assert(isinstance(app_error, ARObject))
141
- assert(isinstance(app_error, Identifiable))
142
- assert(isinstance(app_error, MultilanguageReferrable))
143
- assert(isinstance(app_error, Referrable))
144
- assert(isinstance(app_error, ApplicationError))
140
+ assert (isinstance(app_error, ARObject))
141
+ assert (isinstance(app_error, Identifiable))
142
+ assert (isinstance(app_error, MultilanguageReferrable))
143
+ assert (isinstance(app_error, Referrable))
144
+ assert (isinstance(app_error, ApplicationError))
145
145
 
146
- assert(app_error.parent == ar_root)
147
- assert(app_error.short_name == "ApplicationError")
146
+ assert (app_error.parent == ar_root)
147
+ assert (app_error.short_name == "ApplicationError")
148
148
 
149
149
  def test_ClientServerOperation(self):
150
150
  document = AUTOSAR.getInstance()
151
151
  ar_root = document.createARPackage("AUTOSAR")
152
152
  operation = ClientServerOperation(ar_root, "client_server_operation")
153
- assert(isinstance(operation, ARObject))
154
- # assert(isinstance(operation, AtpClassifier))
155
- assert(isinstance(operation, AtpFeature))
156
- assert(isinstance(operation, Identifiable))
157
- assert(isinstance(operation, MultilanguageReferrable))
158
- assert(isinstance(operation, Referrable))
159
- assert(isinstance(operation, ClientServerOperation))
160
- assert(operation.short_name == "client_server_operation")
161
-
162
- prototype = ArgumentDataPrototype(ar_root, "argument_data_prototype1")
163
- operation.addArgumentDataPrototype(prototype)
164
- assert(prototype.short_name == "argument_data_prototype1")
165
-
166
- assert(len(operation.getArgumentDataPrototypes()) == 1)
167
- assert(operation.getArgumentDataPrototypes()[0] == prototype)
153
+ assert (isinstance(operation, ARObject))
154
+ # assert (isinstance(operation, AtpClassifier))
155
+ assert (isinstance(operation, AtpFeature))
156
+ assert (isinstance(operation, Identifiable))
157
+ assert (isinstance(operation, MultilanguageReferrable))
158
+ assert (isinstance(operation, Referrable))
159
+ assert (isinstance(operation, ClientServerOperation))
160
+ assert (operation.short_name == "client_server_operation")
161
+
162
+ prototype = operation.createArgumentDataPrototype("argument_data_prototype1")
163
+ assert (prototype.short_name == "argument_data_prototype1")
164
+
165
+ assert (len(operation.getArguments()) == 1)
166
+ assert (operation.getArguments()[0] == prototype)
168
167
 
169
168
  refType = RefType()
170
169
  refType.dest = "APPLICATION-ERROR"
171
170
  refType.value = "/AUTOSAR_NvM/PortInterfaces/NvMService/E_NOT_OK"
172
171
  operation.addPossibleErrorRef(refType)
173
172
 
174
- assert(len(operation.getPossbileErrorRefs()) == 1)
175
- assert(operation.getPossbileErrorRefs()[0] == refType)
173
+ assert (len(operation.getPossibleErrorRefs()) == 1)
174
+ assert (operation.getPossibleErrorRefs()[0] == refType)
176
175
 
177
176
  def test_ClientServerInterface(self):
178
177
  document = AUTOSAR.getInstance()
179
178
  ar_root = document.createARPackage("AUTOSAR")
180
179
  cs_if = ClientServerInterface(ar_root, "client_server_interface")
181
- assert(isinstance(cs_if, ARObject))
182
- assert(isinstance(cs_if, ARElement))
183
- # assert(isinstance(operation, AtpBlueprint))
184
- # assert(isinstance(operation, AtpBlueprintable))
185
- # assert(isinstance(operation, AtpClassifier))
186
- assert(isinstance(cs_if, AtpType))
187
- assert(isinstance(cs_if, CollectableElement))
188
- assert(isinstance(cs_if, Identifiable))
189
- assert(isinstance(cs_if, MultilanguageReferrable))
190
- assert(isinstance(cs_if, PackageableElement))
191
- assert(isinstance(cs_if, PortInterface))
192
- assert(isinstance(cs_if, Referrable))
180
+ assert (isinstance(cs_if, ARObject))
181
+ assert (isinstance(cs_if, ARElement))
182
+ # assert (isinstance(operation, AtpBlueprint))
183
+ # assert (isinstance(operation, AtpBlueprintable))
184
+ # assert (isinstance(operation, AtpClassifier))
185
+ assert (isinstance(cs_if, AtpType))
186
+ assert (isinstance(cs_if, CollectableElement))
187
+ assert (isinstance(cs_if, Identifiable))
188
+ assert (isinstance(cs_if, MultilanguageReferrable))
189
+ assert (isinstance(cs_if, PackageableElement))
190
+ assert (isinstance(cs_if, PortInterface))
191
+ assert (isinstance(cs_if, Referrable))
193
192
 
194
193
  element = cs_if.createOperation("operation")
195
- assert(isinstance(element, ClientServerOperation))
196
- assert(element.short_name == "operation")
197
- assert(len(cs_if.getOperations()) == 1)
194
+ assert (isinstance(element, ClientServerOperation))
195
+ assert (element.short_name == "operation")
196
+ assert (len(cs_if.getOperations()) == 1)
198
197
 
199
198
  element2 = cs_if.getOperations()[0]
200
- assert(element == element2)
199
+ assert (element == element2)
201
200
 
202
201
  element = cs_if.createApplicationError("error")
203
- assert(isinstance(element, ApplicationError))
204
- assert(element.short_name == "error")
205
- assert(len(cs_if.getPossibleErrors()) == 1)
202
+ assert (isinstance(element, ApplicationError))
203
+ assert (element.short_name == "error")
204
+ assert (len(cs_if.getPossibleErrors()) == 1)
206
205
 
207
206
  element2 = cs_if.getPossibleErrors()[0]
208
- assert(element == element2)
207
+ assert (element == element2)
@@ -0,0 +1,218 @@
1
+ import filecmp
2
+ from typing import List
3
+
4
+ from ....models.M2.AUTOSARTemplates.BswModuleTemplate.BswBehavior import BswInternalBehavior
5
+ from ....models.M2.AUTOSARTemplates.BswModuleTemplate.BswImplementation import BswImplementation
6
+ from ....models.M2.AUTOSARTemplates.GenericStructure.GeneralTemplateClasses.EngineeringObject import AutosarEngineeringObject
7
+ from ....models.M2.AUTOSARTemplates.GenericStructure.GeneralTemplateClasses.ARPackage import ARPackage
8
+
9
+ from .... import AUTOSAR
10
+ from .... import ARXMLParser, ARXMLWriter
11
+
12
+ import logging
13
+
14
+
15
+ class TestBswMD:
16
+ def setup_method(self):
17
+ logger = logging.getLogger()
18
+ formatter = logging.Formatter('[%(levelname)s] : %(message)s')
19
+ logging.basicConfig(format='[%(levelname)s] : %(message)s', level=logging.DEBUG)
20
+ log_file = 'pytest_armodel.log'
21
+
22
+ file_handler = logging.FileHandler(log_file)
23
+ file_handler.setFormatter(formatter)
24
+ file_handler.setLevel(logging.DEBUG)
25
+ logger.addHandler(file_handler)
26
+
27
+ document = AUTOSAR.getInstance()
28
+ document.clear()
29
+ parser = ARXMLParser()
30
+ parser.load("src/armodel/tests/test_files/BswM_Bswmd.arxml", document)
31
+
32
+ def test_ar_packages(self):
33
+ document = AUTOSAR.getInstance()
34
+ root_pkgs = sorted(document.getARPackages(), key=lambda pkg: pkg.short_name)
35
+ assert (len(root_pkgs) == 2)
36
+ assert (root_pkgs[0].getShortName() == "AUTOSAR_BswM")
37
+ assert (root_pkgs[1].getShortName() == "EB_BswM_TxDxM1I14R0")
38
+
39
+ root_pkg_0_pkgs = sorted(root_pkgs[0].getARPackages(), key=lambda pkg: pkg.short_name)
40
+ assert (len(root_pkg_0_pkgs) == 3)
41
+
42
+ bsw_module_desc_pkg = root_pkg_0_pkgs[0] # type:ARPackage
43
+ assert (bsw_module_desc_pkg.getShortName() == "BswModuleDescriptions")
44
+
45
+ root_pkg_1_pkgs = root_pkgs[1].getARPackages()
46
+ assert (len(root_pkg_1_pkgs) == 1)
47
+
48
+ def test_bsw_module_description(self):
49
+ document = AUTOSAR.getInstance()
50
+
51
+ pkg = document.find("/AUTOSAR_BswM/BswModuleDescriptions") # type: ARPackage
52
+ bsw_module_descs = pkg.getBswModuleDescriptions()
53
+ assert (len(bsw_module_descs) == 1)
54
+
55
+ bsw_module_desc = bsw_module_descs[0]
56
+ assert (bsw_module_desc.getShortName() == "BswM")
57
+ assert (bsw_module_desc.moduleId.getText() == "34")
58
+ assert (bsw_module_desc.moduleId.getValue() == 34)
59
+
60
+ # verify the provided entries
61
+ assert (len(bsw_module_desc.implementedEntryRefs) == 2)
62
+ assert (bsw_module_desc.implementedEntryRefs[0].getDest() == "BSW-MODULE-ENTRY")
63
+ assert (bsw_module_desc.implementedEntryRefs[0].getValue() == "/AUTOSAR_BswM/BswModuleEntrys/BswM_Init")
64
+ assert (bsw_module_desc.implementedEntryRefs[1].getDest() == "BSW-MODULE-ENTRY")
65
+ assert (bsw_module_desc.implementedEntryRefs[1].getValue() == "/AUTOSAR_BswM/BswModuleEntrys/BswM_MainFunction")
66
+
67
+ assert (len(bsw_module_desc.getInternalBehaviors()) == 1)
68
+ behavior = bsw_module_desc.getInternalBehaviors()[0]
69
+ assert (behavior.short_name == "InternalBehavior_0")
70
+
71
+ assert (len(behavior.getDataTypeMappingRefs()) == 1)
72
+ data_type_mapping_ref = behavior.getDataTypeMappingRefs()[0]
73
+ assert (data_type_mapping_ref.getDest() == "DATA-TYPE-MAPPING-SET")
74
+ assert (data_type_mapping_ref.getValue() == "/BswMMode/DataTypeMappingSets/BswMModeMapping")
75
+
76
+ assert (len(behavior.getExclusiveAreas()) == 1)
77
+ assert (behavior.getExclusiveAreas()[0].short_name == "SCHM_BSWM_EXCLUSIVE_AREA")
78
+
79
+ assert (len(behavior.getBswSchedulableEntities()) == 1)
80
+ entity = behavior.getBswSchedulableEntities()[0]
81
+ assert (entity.short_name == "BswM_MainFunction")
82
+ assert (entity.minimumStartInterval is not None)
83
+ assert (entity.minimumStartIntervalMs is not None)
84
+ assert (len(entity.getCanEnterExclusiveAreaRefs()) == 1)
85
+ assert (entity.getCanEnterExclusiveAreaRefs()[0].getDest() == "EXCLUSIVE-AREA")
86
+ assert (entity.getCanEnterExclusiveAreaRefs()[0].getValue() == "/AUTOSAR_BswM/BswModuleDescriptions/BswM/InternalBehavior_0/SCHM_BSWM_EXCLUSIVE_AREA") # noqa E501
87
+ assert (entity.implementedEntryRef.getDest() == "BSW-MODULE-ENTRY")
88
+ assert (entity.implementedEntryRef.getValue() == "/AUTOSAR_BswM/BswModuleEntrys/BswM_MainFunction")
89
+
90
+ assert (len(behavior.getBswTimingEvents()) == 1)
91
+ event = behavior.getBswTimingEvents()[0]
92
+ assert (event.short_name == "TimingEvent_MainFunction")
93
+ assert (event.startsOnEventRef.getDest() == "BSW-SCHEDULABLE-ENTITY")
94
+ assert (event.startsOnEventRef.getValue() == "/AUTOSAR_BswM/BswModuleDescriptions/BswM/InternalBehavior_0/BswM_MainFunction")
95
+ assert (event.period.getValue() == 0.02)
96
+ assert (event.period.getText() == "0.02")
97
+ assert (event.periodMs == 20)
98
+
99
+ def test_bsw_module_entries(self):
100
+ document = AUTOSAR.getInstance()
101
+
102
+ pkg = document.find("/AUTOSAR_BswM/BswModuleEntrys") # type: ARPackage
103
+ entries = sorted(pkg.getBswModuleEntries(), key=lambda entry: entry.short_name)
104
+ assert (len(entries) == 2)
105
+
106
+ assert (entries[0].getShortName() == "BswM_Init")
107
+ assert (entries[0].getServiceId().getValue() == 0)
108
+ assert (entries[0].getIsReentrant().getValue() is False)
109
+ assert (entries[0].getIsSynchronous().getValue() is True)
110
+ assert (entries[0].getCallType().getText() == "REGULAR")
111
+ assert (entries[0].getExecutionContext().getText() == "UNSPECIFIED")
112
+ assert (entries[0].getSwServiceImplPolicy().getText() == "STANDARD")
113
+
114
+ assert (entries[1].getShortName() == "BswM_MainFunction")
115
+ assert (entries[1].getServiceId().getValue() == 3)
116
+ assert (entries[1].getIsReentrant().getValue() is False)
117
+ assert (entries[1].getIsSynchronous().getValue() is True)
118
+ assert (entries[1].getCallType().getText() == "SCHEDULED")
119
+ assert (entries[1].getExecutionContext().getText() == "TASK")
120
+ assert (entries[1].getSwServiceImplPolicy().getText() == "STANDARD")
121
+
122
+ def test_bsw_module_swc_bsw_mapping(self):
123
+ document = AUTOSAR.getInstance()
124
+
125
+ pkg = document.find("/AUTOSAR_BswM/SwcBswMappings") # type: ARPackage
126
+ mappings = pkg.getSwcBswMappings()
127
+ assert (len(mappings) == 1)
128
+
129
+ assert (mappings[0].bswBehaviorRef.getDest() == "BSW-INTERNAL-BEHAVIOR")
130
+ assert (mappings[0].bswBehaviorRef.getValue() == "/AUTOSAR_BswM/BswModuleDescriptions/BswM/InternalBehavior_0")
131
+
132
+ assert (len(mappings[0].getRunnableMappings()) == 1)
133
+ runnable_mapping = mappings[0].getRunnableMappings()[0]
134
+ assert (runnable_mapping.getBswEntityRef().getDest() == "BSW-SCHEDULABLE-ENTITY")
135
+ assert (runnable_mapping.getBswEntityRef().getValue() == "/AUTOSAR_BswM/BswModuleDescriptions/BswM/InternalBehavior_0/BswM_MainFunction")
136
+ assert (runnable_mapping.getSwcRunnableRef().getDest() == "RUNNABLE-ENTITY")
137
+ assert (runnable_mapping.getSwcRunnableRef().getValue() == "/AUTOSAR_BswM/SwComponentTypes/BswM/BswMInternalBehavior/RES_MainFunction")
138
+
139
+ def test_bsw_module_implementation(self):
140
+ document = AUTOSAR.getInstance()
141
+
142
+ pkg = document.find("/EB_BswM_TxDxM1I14R0/Implementations") # type: ARPackage
143
+ assert (len(pkg.getBswImplementations()) == 1)
144
+ impl = pkg.getBswImplementations()[0]
145
+ assert (impl.short_name == "BswImplementation_0")
146
+ assert (len(impl.getCodeDescriptors()) == 1)
147
+
148
+ code_desc = impl.getCodeDescriptors()[0]
149
+ assert (code_desc.short_name == "Files")
150
+ assert (len(code_desc.getArtifactDescriptors()) == 21)
151
+ assert (len(code_desc.getArtifactDescriptors("SWSRC")) == 4)
152
+ assert (len(code_desc.getArtifactDescriptors("SWHDR")) == 15)
153
+ assert (len(code_desc.getArtifactDescriptors("SWMAKE")) == 2)
154
+
155
+ artifact_descs = sorted(code_desc.getArtifactDescriptors("SWMAKE"), key=lambda o: o.getShortLabel().getValue()) # type: List[AutosarEngineeringObject] # noqa E501
156
+ assert (artifact_descs[0].getShortLabel().getValue() == "make::BswM_defs.mak")
157
+ assert (artifact_descs[0].getCategory().getValue() == "SWMAKE")
158
+ assert (artifact_descs[1].getShortLabel().getValue() == "make::BswM_rules.mak")
159
+ assert (artifact_descs[1].getCategory().getValue() == "SWMAKE")
160
+
161
+ assert (impl.programmingLanguage.getValue() == "C")
162
+
163
+ assert (impl.resourceConsumption.short_name == "ResourceConsumption")
164
+ assert (len(impl.resourceConsumption.getMemorySections()) == 8)
165
+
166
+ section = impl.resourceConsumption.getMemorySection("CODE")
167
+ assert (section.short_name == "CODE")
168
+ assert (section.alignment is None)
169
+ assert (section.swAddrMethodRef.getDest() == "SW-ADDR-METHOD")
170
+ assert (section.swAddrMethodRef.getValue() == "/AUTOSAR_MemMap/SwAddrMethods/CODE")
171
+
172
+ section = impl.resourceConsumption.getMemorySection("VAR_NO_INIT_UNSPECIFIED")
173
+ assert (section.short_name == "VAR_NO_INIT_UNSPECIFIED")
174
+ assert (section.alignment.getText() == "UNSPECIFIED")
175
+ assert (section.swAddrMethodRef.getDest() == "SW-ADDR-METHOD")
176
+ assert (section.swAddrMethodRef.getValue() == "/AUTOSAR_MemMap/SwAddrMethods/VAR_NOINIT")
177
+
178
+ assert (impl.vendorId.getValue() == 1)
179
+ assert (impl.swVersion.getValue() == "1.14.1")
180
+ assert (impl.swcBswMappingRef.getDest() == "SWC-BSW-MAPPING")
181
+ assert (impl.swcBswMappingRef.getValue() == "/AUTOSAR_BswM/SwcBswMappings/SwcBswMapping_0")
182
+ assert (impl.arReleaseVersion.getValue() == "4.0.3")
183
+ assert (impl.behaviorRef.getDest() == "BSW-INTERNAL-BEHAVIOR")
184
+ assert (impl.behaviorRef.getValue() == "/AUTOSAR_BswM/BswModuleDescriptions/BswM/InternalBehavior_0")
185
+
186
+ def test_get_implementation(self):
187
+ document = AUTOSAR.getInstance()
188
+ impl = document.getImplementation("/AUTOSAR_BswM/BswModuleDescriptions/BswM/InternalBehavior_0")
189
+ assert (impl.getFullName() == "/EB_BswM_TxDxM1I14R0/Implementations/BswImplementation_0")
190
+ assert (isinstance(impl, BswImplementation))
191
+
192
+ def test_get_behavior(self):
193
+ document = AUTOSAR.getInstance()
194
+ behavior = document.getBehavior("/EB_BswM_TxDxM1I14R0/Implementations/BswImplementation_0")
195
+ assert (behavior.getFullName() == "/AUTOSAR_BswM/BswModuleDescriptions/BswM/InternalBehavior_0")
196
+ assert (isinstance(behavior, BswInternalBehavior))
197
+
198
+ def test_load_save(self):
199
+ document = AUTOSAR.getInstance()
200
+ document.clear()
201
+ parser = ARXMLParser()
202
+ parser.load("src/armodel/tests/test_files/SoftwareComponents.arxml", document)
203
+
204
+ writer = ARXMLWriter()
205
+ writer.save("data/generated.arxml", document)
206
+
207
+ assert (filecmp.cmp("src/armodel/tests/test_files/SoftwareComponents.arxml", "data/generated.arxml", shallow=False) is True)
208
+
209
+ def test_bswm_bswmd_arxml_loading_and_saving(self):
210
+ document = AUTOSAR.getInstance()
211
+ document.clear()
212
+ parser = ARXMLParser()
213
+ parser.load("src/armodel/tests/test_files/BswM_Bswmd.arxml", document)
214
+
215
+ writer = ARXMLWriter()
216
+ writer.save("data/generated_BswM_Bswmd.arxml", document)
217
+
218
+ assert (filecmp.cmp("src/armodel/tests/test_files/BswM_Bswmd.arxml", "data/generated_BswM_Bswmd.arxml", shallow=False) is True)