aas-standard-parser 0.2.0__tar.gz → 0.2.1__tar.gz
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.
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/PKG-INFO +1 -1
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser/aimc_parser.py +9 -24
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser.egg-info/PKG-INFO +1 -1
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/pyproject.toml +1 -1
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/tests/test_aimc_parser.py +26 -28
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/LICENSE +0 -0
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/README.md +0 -0
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser/__init__.py +0 -0
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser/aid_parser.py +0 -0
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser/collection_helpers.py +0 -0
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser/demo/demo_process.py +0 -0
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser/demo/logging_handler.py +0 -0
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser/reference_helpers.py +0 -0
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser/submodel_parser.py +0 -0
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser/utils.py +0 -0
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser.egg-info/SOURCES.txt +0 -0
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser.egg-info/dependency_links.txt +0 -0
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser.egg-info/requires.txt +0 -0
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser.egg-info/top_level.txt +0 -0
- {aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/setup.cfg +0 -0
|
@@ -15,6 +15,7 @@ logger = logging.getLogger(__name__)
|
|
|
15
15
|
class ReferenceProperties:
|
|
16
16
|
"""Class representing properties of a reference in the mapping configuration."""
|
|
17
17
|
|
|
18
|
+
reference: model.ExternalReference = field(metadata={"description": "Reference to the property in the submodel."})
|
|
18
19
|
submodel_id: str = field(metadata={"description": "Identifier of the submodel used by the reference."})
|
|
19
20
|
property_name: str = field(metadata={"description": "Name of the mapped property."})
|
|
20
21
|
parent_path: list[str] = field(metadata={"description": "List of idShorts representing the parent path of the reference."})
|
|
@@ -23,21 +24,15 @@ class ReferenceProperties:
|
|
|
23
24
|
class SourceSinkRelation:
|
|
24
25
|
"""Class representing a source-sink relation in the mapping configuration."""
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
source: model.ExternalReference = field(metadata={"description": "Reference to the source property in the AID submodel."})
|
|
29
|
-
sink: model.ExternalReference = field(metadata={"description": "Reference to the sink property in the target submodel."})
|
|
30
|
-
source_property_name: str = field(metadata={"description": "Name of the mapped property in source."})
|
|
31
|
-
sink_property_name: str = field(metadata={"description": "Name of the mapped property in sink."})
|
|
32
|
-
source_parent_path: list[str] = field(metadata={"description": "List of idShorts representing the parent path of the source reference."})
|
|
33
|
-
sink_parent_path: list[str] = field(metadata={"description": "List of idShorts representing the parent path of the reference."})
|
|
27
|
+
source_properties: ReferenceProperties = field(metadata={"description": "Properties of the source reference."})
|
|
28
|
+
sink_properties: ReferenceProperties = field(metadata={"description": "Properties of the sink reference."})
|
|
34
29
|
|
|
35
30
|
def source_as_dict(self) -> dict:
|
|
36
31
|
"""Convert the source reference to a dictionary.
|
|
37
32
|
|
|
38
33
|
:return: The source reference as a dictionary.
|
|
39
34
|
"""
|
|
40
|
-
dict_string = json.dumps(self.
|
|
35
|
+
dict_string = json.dumps(self.source_properties.reference, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
41
36
|
dict_string = dict_string.replace("GlobalReference", "Submodel").replace("FragmentReference", "SubmodelElementCollection")
|
|
42
37
|
return json.loads(dict_string)
|
|
43
38
|
|
|
@@ -46,7 +41,7 @@ class SourceSinkRelation:
|
|
|
46
41
|
|
|
47
42
|
:return: The sink reference as a dictionary.
|
|
48
43
|
"""
|
|
49
|
-
return json.
|
|
44
|
+
return json.dumps(self.sink_properties.reference, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
50
45
|
|
|
51
46
|
|
|
52
47
|
class MappingConfiguration:
|
|
@@ -168,7 +163,7 @@ def parse_mapping_configuration_element(
|
|
|
168
163
|
return None
|
|
169
164
|
|
|
170
165
|
# check if all relations have the same AID submodel
|
|
171
|
-
aid_submodel_ids = list({source_sink_relation.
|
|
166
|
+
aid_submodel_ids = list({source_sink_relation.source_properties.submodel_id for source_sink_relation in source_sink_relations})
|
|
172
167
|
|
|
173
168
|
if len(aid_submodel_ids) != 1:
|
|
174
169
|
logger.error(
|
|
@@ -237,20 +232,9 @@ def _generate_source_sink_relations(mapping_configuration_element: model.Submode
|
|
|
237
232
|
logger.warning(f"'second' reference is missing in RelationshipElement '{source_sink_relation.id_short}'")
|
|
238
233
|
continue
|
|
239
234
|
|
|
240
|
-
source_ref_properties = _get_reference_properties(source_sink_relation.first)
|
|
241
|
-
sink_ref_properties = _get_reference_properties(source_sink_relation.second)
|
|
242
|
-
|
|
243
235
|
relation = SourceSinkRelation()
|
|
244
|
-
|
|
245
|
-
relation.
|
|
246
|
-
relation.source_submodel_id = source_ref_properties.submodel_id
|
|
247
|
-
relation.source_property_name = source_ref_properties.property_name
|
|
248
|
-
relation.source_parent_path = source_ref_properties.parent_path
|
|
249
|
-
|
|
250
|
-
relation.sink = source_sink_relation.second
|
|
251
|
-
relation.sink_submodel_id = sink_ref_properties.submodel_id
|
|
252
|
-
relation.sink_property_name = sink_ref_properties.property_name
|
|
253
|
-
relation.sink_parent_path = sink_ref_properties.parent_path
|
|
236
|
+
relation.source_properties = _get_reference_properties(source_sink_relation.first)
|
|
237
|
+
relation.sink_properties = _get_reference_properties(source_sink_relation.second)
|
|
254
238
|
|
|
255
239
|
source_sink_relations.append(relation)
|
|
256
240
|
|
|
@@ -276,6 +260,7 @@ def _get_reference_properties(reference: model.ExternalReference) -> ReferencePr
|
|
|
276
260
|
ref_properties.submodel_id = global_ref.value
|
|
277
261
|
ref_properties.property_name = last_fragment_ref.value
|
|
278
262
|
ref_properties.parent_path = parent_path
|
|
263
|
+
ref_properties.reference = reference
|
|
279
264
|
|
|
280
265
|
return ref_properties
|
|
281
266
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
from basyx.aas import model
|
|
3
3
|
|
|
4
|
-
from aas_standard_parser.aimc_parser import MappingConfiguration, SourceSinkRelation
|
|
4
|
+
from aas_standard_parser.aimc_parser import MappingConfiguration, SourceSinkRelation, ReferenceProperties
|
|
5
5
|
import aas_standard_parser.aimc_parser as aimc_parser
|
|
6
6
|
from aas_standard_parser.utils import create_submodel_from_file
|
|
7
7
|
|
|
@@ -41,7 +41,6 @@ def test_003_parse_mapping_configuration_element(aimc_submodel: model.submodel):
|
|
|
41
41
|
assert configuration is not None
|
|
42
42
|
_check_interface_ref(configuration)
|
|
43
43
|
_check_relations(configuration)
|
|
44
|
-
_check_relations(configuration)
|
|
45
44
|
|
|
46
45
|
def test_004_parse_mapping_configurations(aimc_submodel: model.submodel):
|
|
47
46
|
mapping_configurations = aimc_parser.parse_mapping_configurations(aimc_submodel)
|
|
@@ -57,7 +56,6 @@ def test_004_parse_mapping_configurations(aimc_submodel: model.submodel):
|
|
|
57
56
|
|
|
58
57
|
_check_interface_ref(configuration)
|
|
59
58
|
_check_relations(configuration)
|
|
60
|
-
_check_relations(configuration)
|
|
61
59
|
|
|
62
60
|
def _check_interface_ref(configuration: MappingConfiguration):
|
|
63
61
|
assert configuration.interface_reference is not None
|
|
@@ -81,44 +79,44 @@ def _check_relations(configuration: MappingConfiguration):
|
|
|
81
79
|
relation = configuration.source_sink_relations[0]
|
|
82
80
|
assert relation is not None
|
|
83
81
|
|
|
84
|
-
assert relation.
|
|
85
|
-
assert relation.
|
|
82
|
+
assert relation.source_properties is not None
|
|
83
|
+
assert relation.source_properties.submodel_id == configuration.aid_submodel_id
|
|
86
84
|
|
|
87
|
-
assert relation.
|
|
85
|
+
assert relation.sink_properties is not None
|
|
88
86
|
|
|
89
|
-
_check_relations_source(relation)
|
|
90
|
-
_check_relations_sink(relation)
|
|
87
|
+
_check_relations_source(relation.source_properties)
|
|
88
|
+
_check_relations_sink(relation.sink_properties)
|
|
91
89
|
_check_relation_methods(relation)
|
|
92
90
|
|
|
93
|
-
def _check_relations_source(
|
|
94
|
-
assert
|
|
91
|
+
def _check_relations_source(reference_properties: ReferenceProperties):
|
|
92
|
+
assert reference_properties is not None
|
|
95
93
|
|
|
96
|
-
assert isinstance(
|
|
94
|
+
assert isinstance(reference_properties.reference, model.ExternalReference)
|
|
97
95
|
|
|
98
|
-
assert
|
|
99
|
-
assert
|
|
96
|
+
assert reference_properties.property_name is not None
|
|
97
|
+
assert reference_properties.property_name == "HandlingC"
|
|
100
98
|
|
|
101
|
-
assert
|
|
102
|
-
assert len(
|
|
103
|
-
assert
|
|
99
|
+
assert reference_properties.parent_path is not None
|
|
100
|
+
assert len(reference_properties.parent_path) == 5
|
|
101
|
+
assert reference_properties.parent_path[3] == "axes_position"
|
|
104
102
|
|
|
105
|
-
assert
|
|
106
|
-
assert
|
|
103
|
+
assert reference_properties.submodel_id is not None
|
|
104
|
+
assert reference_properties.submodel_id == reference_properties.reference.key[0].value
|
|
107
105
|
|
|
108
|
-
def _check_relations_sink(
|
|
109
|
-
assert
|
|
106
|
+
def _check_relations_sink(reference_properties: ReferenceProperties):
|
|
107
|
+
assert reference_properties is not None
|
|
110
108
|
|
|
111
|
-
assert isinstance(
|
|
109
|
+
assert isinstance(reference_properties.reference, model.ExternalReference)
|
|
112
110
|
|
|
113
|
-
assert
|
|
114
|
-
assert
|
|
111
|
+
assert reference_properties.property_name is not None
|
|
112
|
+
assert reference_properties.property_name == "HandlingC"
|
|
115
113
|
|
|
116
|
-
assert
|
|
117
|
-
assert len(
|
|
118
|
-
assert
|
|
114
|
+
assert reference_properties.parent_path is not None
|
|
115
|
+
assert len(reference_properties.parent_path) == 2
|
|
116
|
+
assert reference_properties.parent_path[1] == "AxesPosition"
|
|
119
117
|
|
|
120
|
-
assert
|
|
121
|
-
assert
|
|
118
|
+
assert reference_properties.submodel_id is not None
|
|
119
|
+
assert reference_properties.submodel_id == reference_properties.reference.key[0].value
|
|
122
120
|
|
|
123
121
|
def _check_relation_methods(relation: SourceSinkRelation):
|
|
124
122
|
# test to_json methods
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser/collection_helpers.py
RENAMED
|
File without changes
|
{aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser/demo/demo_process.py
RENAMED
|
File without changes
|
{aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser/demo/logging_handler.py
RENAMED
|
File without changes
|
{aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser/reference_helpers.py
RENAMED
|
File without changes
|
{aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser/submodel_parser.py
RENAMED
|
File without changes
|
|
File without changes
|
{aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser.egg-info/requires.txt
RENAMED
|
File without changes
|
{aas_standard_parser-0.2.0 → aas_standard_parser-0.2.1}/aas_standard_parser.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|