Skip to content

model.base: add method for adding objects to namespaces

This MR implements this feature by adding a method to each relevant namespace, that iterates over the respective NamespaceSets and adds the object to the first NamespaceSet with a matching attribute_name, such as id_short, type or name.

The SubmodelElement collections SubmodelElementCollectionOrderedUniqueSemanticId and SubmodelElementCollectionUnorderedUniqueSemanticId both inherit from SubmodelElementCollectionOrdered and SubmodelElementCollectionUnordered respectively. Both __init__ methods call super().__init__ (e.g. SubmodelElementCollectionOrdered.__init__), which creates a NamespaceSet for self.value. self.value is then overwritten by a new NamespaceSet for the unique semantic_id functionality, leaving an unused NamespaceSet in self.namespace_element_sets.

The functionality implemented in this MR would add new Referable objects to the first NamespaceSet in self.namespace_element_sets, that has id_short in its attribute_name_list. For the SubmodelElementCollections with a UniqueSemanticId namespace, this would be the unused NamespaceSet. Thus, this unused NamespaceSet has to be removed first in the respective __init__ function.

Alongside, this MR also fixes some docstrings and shortens some code.

Edited by Leon Mauritz Möller

Merge request reports

Loading