From 904e74718e6b6765de827ac121dc08db0860ee36 Mon Sep 17 00:00:00 2001 From: Julian Vogel Date: Thu, 21 Nov 2024 17:11:43 +0100 Subject: [PATCH] aas.adapter: check semantic ids have same model reference type --- sdk/basyx/aas/examples/data/_helper.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sdk/basyx/aas/examples/data/_helper.py b/sdk/basyx/aas/examples/data/_helper.py index 890f9d80f..5b23a898a 100644 --- a/sdk/basyx/aas/examples/data/_helper.py +++ b/sdk/basyx/aas/examples/data/_helper.py @@ -212,7 +212,13 @@ def _check_has_semantics_equal(self, object_: model.HasSemantics, expected_objec :param expected_object: The expected HasSemantic object :return: The value of expression to be used in control statements """ - self.check_attribute_equal(object_, "semantic_id", expected_object.semantic_id) + if self.check_attribute_equal(object_, "semantic_id", expected_object.semantic_id) and \ + isinstance(expected_object.semantic_id, model.ModelReference): + if self.check(isinstance(object_.semantic_id, model.ModelReference), + '{} must be a ModelReference'.format(repr(object_))): # type: ignore + self.check(object_.semantic_id.type == expected_object.semantic_id.type, # type: ignore + 'ModelReference type {} of {} must be equal to {}'.format( + object_.semantic_id.type, repr(object_), expected_object.semantic_id.type)) # type: ignore for suppl_semantic_id in expected_object.supplemental_semantic_id: given_semantic_id = self._find_reference(suppl_semantic_id, object_.supplemental_semantic_id) self.check(given_semantic_id is not None, f"{object_!r} must have supplementalSemanticId",