[docs]classExtendedQualifier(Qualifier):"""This class contains methods to be added to Qualifier class of Basyx Python SDK model."""
[docs]classExtendedHasSemantics(HasSemantics):"""This class contains methods to be added to HasSemantics class of Basyx Python SDK model."""
[docs]defcheck_semantic_id_exist(self,semantic_id_reference):""" This method checks if a specific semanticID exists in an AAS meta-model element. Args: semantic_id_reference (str): semantic identifier. Returns: bool: result of the check (only True if the semanticID exists). """ifself.semantic_idisNone:returnFalseforreferenceinself.semantic_id.key:ifreference.value==semantic_id_reference:returnTruereturnFalse
[docs]defcheck_suppl_semantic_id_exist(self,suppl_semantic_id_ref):""" This method checks if a specific supplemental semanticID exists in an AAS meta-model element. Args: suppl_semantic_id_ref (str): supplemental semantic identifier. Returns: bool: result of the check (only True if the semanticID exists). """ifself.supplemental_semantic_idisNone:returnFalseforsuppl_semantic_idinself.supplemental_semantic_id:forreferenceinsuppl_semantic_id.key:ifreference.value==suppl_semantic_id_ref:returnTruereturnFalse
[docs]defcheck_if_element_is_structural(self):""" This method checks whether the AAS element is of type structural (Submodel, SubmodelElementCollection or SubmodelElementList). Returns: bool: result of the check """ifisinstance(self,basyx.aas.model.Submodel) \
or(isinstance(self,basyx.aas.model.SubmodelElementCollection)orisinstance(self,basyx.aas.model.SubmodelElementList)):returnTrueelse:returnFalse
[docs]defget_qualifier_value_by_type(self,qualifier_type_value):""" This method gets the value of the qualifier that has a given type. Args: qualifier_type_value (str): type of the qualifier. Returns: str: value of the qualifier with the given type """try:qualifier_object=self.get_qualifier_by_type(qualifier_type_value)ifqualifier_objectisNone:raiseAASModelReadingError("Qualifier type {} not found in the element {}".format(qualifier_type_value,self),self,'KeyError in qualifiers')else:returnqualifier_object.valueexceptKeyErrorase:raiseAASModelReadingError("Qualifier type {} not found in the element {}".format(qualifier_type_value,self),self,'KeyError in qualifiers')
[docs]defget_qualifier_value_by_semantic_id(self,qualifier_semantic_id):""" This method gets the value of the qualifier that has a given semanticID. Args: qualifier_semantic_id (str): semanticID of the qualifier. Returns: str: value of the qualifier with the given type """try:iflen(self.qualifier)==0:raiseAASModelReadingError("Qualifier not found in the element {} because the element has no ""qualifier with semanticID {}.".format(self,qualifier_semantic_id),self,'KeyError in qualifiers')forqualifierinself.qualifier:ifqualifier.check_semantic_id_exist(qualifier_semantic_id)isTrue:returnqualifier.valueelse:raiseAASModelReadingError("Qualifier with semanticID {} not found in the element {}".format(qualifier_semantic_id,self),self,'SemanticIDError in qualifiers')exceptKeyErrorase:raiseAASModelReadingError("Qualifier with semanticID {} not found in the element {}".format(qualifier_semantic_id,self),self,'KeyError in qualifiers')