aas-standard-parser 0.2.0__py3-none-any.whl → 0.2.2__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.
- aas_standard_parser/aimc_parser.py +5 -69
- aas_standard_parser/classes/aimc_parser_classes.py +52 -0
- {aas_standard_parser-0.2.0.dist-info → aas_standard_parser-0.2.2.dist-info}/METADATA +1 -1
- {aas_standard_parser-0.2.0.dist-info → aas_standard_parser-0.2.2.dist-info}/RECORD +7 -6
- {aas_standard_parser-0.2.0.dist-info → aas_standard_parser-0.2.2.dist-info}/WHEEL +0 -0
- {aas_standard_parser-0.2.0.dist-info → aas_standard_parser-0.2.2.dist-info}/licenses/LICENSE +0 -0
- {aas_standard_parser-0.2.0.dist-info → aas_standard_parser-0.2.2.dist-info}/top_level.txt +0 -0
|
@@ -1,69 +1,15 @@
|
|
|
1
1
|
"""Parser for Mapping Configurations in AIMC Submodel."""
|
|
2
2
|
|
|
3
|
-
import json
|
|
4
3
|
import logging
|
|
5
|
-
from dataclasses import field
|
|
6
4
|
|
|
7
|
-
import basyx.aas.adapter.json
|
|
8
5
|
from basyx.aas import model
|
|
9
6
|
|
|
10
7
|
import aas_standard_parser.collection_helpers as ch
|
|
8
|
+
from aas_standard_parser.classes.aimc_parser_classes import MappingConfiguration, MappingConfigurations, ReferenceProperties, SourceSinkRelation
|
|
11
9
|
|
|
12
10
|
logger = logging.getLogger(__name__)
|
|
13
11
|
|
|
14
12
|
|
|
15
|
-
class ReferenceProperties:
|
|
16
|
-
"""Class representing properties of a reference in the mapping configuration."""
|
|
17
|
-
|
|
18
|
-
submodel_id: str = field(metadata={"description": "Identifier of the submodel used by the reference."})
|
|
19
|
-
property_name: str = field(metadata={"description": "Name of the mapped property."})
|
|
20
|
-
parent_path: list[str] = field(metadata={"description": "List of idShorts representing the parent path of the reference."})
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class SourceSinkRelation:
|
|
24
|
-
"""Class representing a source-sink relation in the mapping configuration."""
|
|
25
|
-
|
|
26
|
-
source_submodel_id: str = field(metadata={"description": "Identifier of the source (AID) submodel used by the source reference."})
|
|
27
|
-
sink_submodel_id: str = field(metadata={"description": "Identifier of the target submodel used by the sink reference."})
|
|
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."})
|
|
34
|
-
|
|
35
|
-
def source_as_dict(self) -> dict:
|
|
36
|
-
"""Convert the source reference to a dictionary.
|
|
37
|
-
|
|
38
|
-
:return: The source reference as a dictionary.
|
|
39
|
-
"""
|
|
40
|
-
dict_string = json.dumps(self.source, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
41
|
-
dict_string = dict_string.replace("GlobalReference", "Submodel").replace("FragmentReference", "SubmodelElementCollection")
|
|
42
|
-
return json.loads(dict_string)
|
|
43
|
-
|
|
44
|
-
def sink_as_dict(self) -> dict:
|
|
45
|
-
"""Convert the sink reference to a dictionary.
|
|
46
|
-
|
|
47
|
-
:return: The sink reference as a dictionary.
|
|
48
|
-
"""
|
|
49
|
-
return json.loads(json.dumps(self.sink, cls=basyx.aas.adapter.json.AASToJsonEncoder))
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
class MappingConfiguration:
|
|
53
|
-
"""Class representing a mapping configuration."""
|
|
54
|
-
|
|
55
|
-
interface_reference: model.ReferenceElement = field(metadata={"description": "Reference to the interface in the AID submodel."})
|
|
56
|
-
aid_submodel_id: str = field(metadata={"description": "Identifier of the AID submodel used by the interface reference."})
|
|
57
|
-
source_sink_relations: list[SourceSinkRelation] = field(metadata={"description": "List of source-sink relations in the mapping configuration."})
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
class MappingConfigurations:
|
|
61
|
-
"""Class representing mapping configurations from AIMC submodel."""
|
|
62
|
-
|
|
63
|
-
configurations: list[MappingConfiguration] = field(metadata={"description": "List of mapping configurations."})
|
|
64
|
-
aid_submodel_ids: list[str] = field(metadata={"description": "List of AID submodel IDs used in the mapping configurations."})
|
|
65
|
-
|
|
66
|
-
|
|
67
13
|
def get_mapping_configuration_root_element(aimc_submodel: model.Submodel) -> model.SubmodelElementCollection | None:
|
|
68
14
|
"""Get the mapping configuration root submodel element collection from the AIMC submodel.
|
|
69
15
|
|
|
@@ -168,7 +114,7 @@ def parse_mapping_configuration_element(
|
|
|
168
114
|
return None
|
|
169
115
|
|
|
170
116
|
# check if all relations have the same AID submodel
|
|
171
|
-
aid_submodel_ids = list({source_sink_relation.
|
|
117
|
+
aid_submodel_ids = list({source_sink_relation.source_properties.submodel_id for source_sink_relation in source_sink_relations})
|
|
172
118
|
|
|
173
119
|
if len(aid_submodel_ids) != 1:
|
|
174
120
|
logger.error(
|
|
@@ -237,20 +183,9 @@ def _generate_source_sink_relations(mapping_configuration_element: model.Submode
|
|
|
237
183
|
logger.warning(f"'second' reference is missing in RelationshipElement '{source_sink_relation.id_short}'")
|
|
238
184
|
continue
|
|
239
185
|
|
|
240
|
-
source_ref_properties = _get_reference_properties(source_sink_relation.first)
|
|
241
|
-
sink_ref_properties = _get_reference_properties(source_sink_relation.second)
|
|
242
|
-
|
|
243
186
|
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
|
|
187
|
+
relation.source_properties = _get_reference_properties(source_sink_relation.first)
|
|
188
|
+
relation.sink_properties = _get_reference_properties(source_sink_relation.second)
|
|
254
189
|
|
|
255
190
|
source_sink_relations.append(relation)
|
|
256
191
|
|
|
@@ -276,6 +211,7 @@ def _get_reference_properties(reference: model.ExternalReference) -> ReferencePr
|
|
|
276
211
|
ref_properties.submodel_id = global_ref.value
|
|
277
212
|
ref_properties.property_name = last_fragment_ref.value
|
|
278
213
|
ref_properties.parent_path = parent_path
|
|
214
|
+
ref_properties.reference = reference
|
|
279
215
|
|
|
280
216
|
return ref_properties
|
|
281
217
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from dataclasses import field
|
|
3
|
+
|
|
4
|
+
import basyx.aas.adapter.json
|
|
5
|
+
from basyx.aas import model
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ReferenceProperties:
|
|
9
|
+
"""Class representing properties of a reference in the mapping configuration."""
|
|
10
|
+
|
|
11
|
+
reference: model.ExternalReference = field(metadata={"description": "Reference to the property in the submodel."})
|
|
12
|
+
submodel_id: str = field(metadata={"description": "Identifier of the submodel used by the reference."})
|
|
13
|
+
property_name: str = field(metadata={"description": "Name of the mapped property."})
|
|
14
|
+
parent_path: list[str] = field(metadata={"description": "List of idShorts representing the parent path of the reference."})
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class SourceSinkRelation:
|
|
18
|
+
"""Class representing a source-sink relation in the mapping configuration."""
|
|
19
|
+
|
|
20
|
+
source_properties: ReferenceProperties = field(metadata={"description": "Properties of the source reference."})
|
|
21
|
+
sink_properties: ReferenceProperties = field(metadata={"description": "Properties of the sink reference."})
|
|
22
|
+
|
|
23
|
+
def source_reference_as_dict(self) -> dict:
|
|
24
|
+
"""Convert the source reference to a dictionary.
|
|
25
|
+
|
|
26
|
+
:return: The source reference as a dictionary.
|
|
27
|
+
"""
|
|
28
|
+
dict_string = json.dumps(self.source_properties.reference, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
29
|
+
dict_string = dict_string.replace("GlobalReference", "Submodel").replace("FragmentReference", "SubmodelElementCollection")
|
|
30
|
+
return json.loads(dict_string)
|
|
31
|
+
|
|
32
|
+
def sink_reference_as_dict(self) -> dict:
|
|
33
|
+
"""Convert the sink reference to a dictionary.
|
|
34
|
+
|
|
35
|
+
:return: The sink reference as a dictionary.
|
|
36
|
+
"""
|
|
37
|
+
return json.dumps(self.sink_properties.reference, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class MappingConfiguration:
|
|
41
|
+
"""Class representing a mapping configuration."""
|
|
42
|
+
|
|
43
|
+
interface_reference: model.ReferenceElement = field(metadata={"description": "Reference to the interface in the AID submodel."})
|
|
44
|
+
aid_submodel_id: str = field(metadata={"description": "Identifier of the AID submodel used by the interface reference."})
|
|
45
|
+
source_sink_relations: list[SourceSinkRelation] = field(metadata={"description": "List of source-sink relations in the mapping configuration."})
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class MappingConfigurations:
|
|
49
|
+
"""Class representing mapping configurations from AIMC submodel."""
|
|
50
|
+
|
|
51
|
+
configurations: list[MappingConfiguration] = field(metadata={"description": "List of mapping configurations."})
|
|
52
|
+
aid_submodel_ids: list[str] = field(metadata={"description": "List of AID submodel IDs used in the mapping configurations."})
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
aas_standard_parser/__init__.py,sha256=3iBTUUlJ97ImkAHdss_GP970BANEU1uNeg0HlRzzois,599
|
|
2
2
|
aas_standard_parser/aid_parser.py,sha256=9vp8_kJRfExTmw8tjmO32n1eHFAE5ItmfPlZ2ORLZMs,14314
|
|
3
|
-
aas_standard_parser/aimc_parser.py,sha256=
|
|
3
|
+
aas_standard_parser/aimc_parser.py,sha256=3GSM-jBj-9OqNDnL7CssqogNOZEd7_fjRtxwzRZi-iA,9972
|
|
4
4
|
aas_standard_parser/collection_helpers.py,sha256=fTQGQiC-bGD41Qx0FDDBtWhvkeZtEe6Sh-aT93ePwro,4153
|
|
5
5
|
aas_standard_parser/reference_helpers.py,sha256=UbqXaub5PTvt_W3VPntSSFcTS59PUwlTpoujny8rIRI,377
|
|
6
6
|
aas_standard_parser/submodel_parser.py,sha256=XH-XTBB3a0MB1NR5nAzG9C6f9hT_qG42f-ABruN3MzE,3169
|
|
7
7
|
aas_standard_parser/utils.py,sha256=5iIPpM_ob2V9MwFL_vTbXd23doYKot30xenRmTPAquo,723
|
|
8
|
+
aas_standard_parser/classes/aimc_parser_classes.py,sha256=lnZ6zBWttnNJxuZdbq6zXQ3tZXjsESw-i3KAGnbw98g,2569
|
|
8
9
|
aas_standard_parser/demo/demo_process.py,sha256=Xn9uD0xLoNx0ZvB3Lk0oYkGBRHaEfUbfqv5_SpPWYck,530
|
|
9
10
|
aas_standard_parser/demo/logging_handler.py,sha256=x-eX4XDU3sZTJE22rzJSiaWQ8wRMbtaFpFBAeAcbIzI,5752
|
|
10
|
-
aas_standard_parser-0.2.
|
|
11
|
-
aas_standard_parser-0.2.
|
|
12
|
-
aas_standard_parser-0.2.
|
|
13
|
-
aas_standard_parser-0.2.
|
|
14
|
-
aas_standard_parser-0.2.
|
|
11
|
+
aas_standard_parser-0.2.2.dist-info/licenses/LICENSE,sha256=simqYMD2P9Ikm0Kh9n7VGNpaVcm2TMVVQmECYZ_xVZ8,1065
|
|
12
|
+
aas_standard_parser-0.2.2.dist-info/METADATA,sha256=YhmjO4kI9H2VGKOPTFXgRmi5i5oFsVc4dMLeIk6ScyU,1718
|
|
13
|
+
aas_standard_parser-0.2.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
14
|
+
aas_standard_parser-0.2.2.dist-info/top_level.txt,sha256=OQaK6cwYttR1-eKTz5u4M0jbwSfp4HqJ56chaf0nHnw,20
|
|
15
|
+
aas_standard_parser-0.2.2.dist-info/RECORD,,
|
|
File without changes
|
{aas_standard_parser-0.2.0.dist-info → aas_standard_parser-0.2.2.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|