Skip to content

Commit e1d0e05

Browse files
committed
Check AASd-022
1 parent a72e5f2 commit e1d0e05

File tree

1 file changed

+27
-5
lines changed
  • aas_test_engines/test_cases/v3_0

1 file changed

+27
-5
lines changed

aas_test_engines/test_cases/v3_0/model.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from aas_test_engines.reflect import reflect, StringFormattedValue, abstract
66

77
from dataclasses import dataclass, field
8-
from typing import List, Optional, Set, Iterator, Union
8+
from typing import List, Optional, Set, Iterator, Union, Iterable
99
from enum import Enum
1010
from aas_test_engines.data_types import (
1111
_is_bounded_integer,
@@ -20,7 +20,6 @@
2020
import re
2121

2222
# TODO: AASd-021
23-
# TODO: AASd-022
2423
# TODO: AASd-077
2524

2625

@@ -771,6 +770,23 @@ def check_aasd_116(self):
771770
# 5.3.6 Submodel Element
772771

773772

773+
def ensure_unique_id_shorts(value: Optional[Iterable[Referable]], path: IdShortPath):
774+
"""
775+
Constraint AASd-022: idShort of non-identifiable referables within the same name space shall be unique
776+
(case-sensitive).
777+
"""
778+
if value is None:
779+
return
780+
seen: Set[str] = set()
781+
for i in value:
782+
if i.id_short is None:
783+
continue
784+
if i.id_short.raw_value in seen:
785+
raise CheckConstraintException(f"AASd-022 violated: Duplicate idShort '{i.id_short}'")
786+
else:
787+
seen.add(i.id_short.raw_value)
788+
789+
774790
@dataclass
775791
@abstract
776792
class SubmodelElement(Referable, HasSemantics, Qualifiable, HasDataSpecification):
@@ -1069,6 +1085,9 @@ def _set_path(self, path):
10691085
for el in self.value:
10701086
el._set_path(path + el.id_short)
10711087

1088+
def check_aasd_022(self):
1089+
ensure_unique_id_shorts(self.value, self.id_short_path)
1090+
10721091
def check_aasd_117(self):
10731092
ensure_have_id_shorts(self.value, self.id_short_path)
10741093

@@ -1185,8 +1204,8 @@ def check_aasd_109(self):
11851204

11861205
def check_aasd_120(self):
11871206
"""
1188-
Constraint AASd-117: idShort of non-identifiable Referables not being a direct child of a
1189-
SubmodelElementList shall be specified.
1207+
Constraint AASd-120: idShort of submodel elements being a direct child of a SubmodelElementList shall not
1208+
be specified.
11901209
"""
11911210
if not self.value:
11921211
return
@@ -1243,10 +1262,13 @@ def elements(self) -> Iterator[SubmodelElement]:
12431262
for element in self.submodel_elements:
12441263
yield from element.elements()
12451264

1265+
def check_aasd_022(self):
1266+
ensure_unique_id_shorts(self.submodel_elements, IdShortPath(self))
1267+
12461268
def check_aasd_117(self):
12471269
ensure_have_id_shorts(self.submodel_elements)
12481270

1249-
def check_aasd119(self):
1271+
def check_aasd_119(self):
12501272
"""
12511273
Constraint AASd-119: If any Qualifier/kind value of a Qualifiable/qualifier is equal to TemplateQualifier and
12521274
the qualified element inherits from "hasKind", the qualified element shall be of kind Template (HasKind/kind =

0 commit comments

Comments
 (0)