From f8b232ac220334c8cefecac7207092f2897c4df4 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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sdk/basyx/aas/examples/data/_helper.py b/sdk/basyx/aas/examples/data/_helper.py index 231ba2ad..6e0170ac 100644 --- a/sdk/basyx/aas/examples/data/_helper.py +++ b/sdk/basyx/aas/examples/data/_helper.py @@ -212,7 +212,15 @@ 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, # type: ignore + repr(object_), + expected_object.semantic_id.type)) 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",