Skip to content

Commit

Permalink
add todo
Browse files Browse the repository at this point in the history
  • Loading branch information
shenchenruwo committed Sep 18, 2024
1 parent 6c49d7b commit 1a424ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion basyx/aas/model/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def _get_endpoint_metadata(self, aid_element: model.SubmodelElement) -> Optional
return aid_element.parent.parent.parent.get_referable('EndpointMetadata')
except AttributeError:
return self._find_parent_by_id_short(aid_element, 'EndpointMetadata')
# TODO: Adapt the function to search for the EndpointMetadata element from the "InterfaceProtocol" element

def _extract_common_parameters(self, endpoint_metadata: model.SubmodelElementCollection) -> Dict[str, Any]:
params = {}
Expand Down Expand Up @@ -173,7 +174,8 @@ def _extract_modbus_parameters(self, forms_element: model.SubmodelElementCollect

return params

def _find_parent_by_id_short(self, element: model.SubmodelElement, id_short: str) -> Optional[model.SubmodelElementCollection]:
def _find_parent_by_id_short(self, element: model.SubmodelElement, id_short: str) \
-> Optional[model.SubmodelElementCollection]:
current = element
while current.parent:
if current.parent.id_short == id_short:
Expand Down
4 changes: 4 additions & 0 deletions basyx/aas/model/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def _process_mapping_configuration(self, config: model.SubmodelElementCollection
"""
Process a single MappingConfiguration.
"""
# TODO: Adapt the function to work without InterfaceReference
interface_reference = next((sme for sme in config.value if sme.id_short == "InterfaceReference"), None)
if not interface_reference or not isinstance(interface_reference, model.ReferenceElement):
print("InterfaceReference not found or not of type ReferenceElement")
Expand All @@ -167,6 +168,7 @@ def _process_relationship_element(self, relation: model.RelationshipElement, int
"""
Process a single RelationshipElement and update _mapping.
"""
# TODO: adapt the function to work without interface_reference
if relation.second:
second_hash = self.generate_model_reference_hash(relation.second)
if second_hash not in self._mapping:
Expand All @@ -184,6 +186,7 @@ def _process_relationship_element(self, relation: model.RelationshipElement, int
print(f"Failed to extract AID parameters for relationship: {relation.id_short}")

def extract_aid_parameters(self, aid_reference: model.ModelReference, interface_reference: model.ModelReference) -> Dict[str, Any]:
# TODO: adapt the function to work without interface_reference
try:
aid_element = aid_reference.resolve(self)
interface_element = interface_reference.resolve(self)
Expand Down Expand Up @@ -226,6 +229,7 @@ def _remove_mapping_for_configuration(self, config: model.SubmodelElementCollect
"""
Remove mappings for a single MappingConfiguration.
"""
# TODO: check if only should remove the configuration of related protocols
mapping_relations = next((sme for sme in config.value if sme.id_short == "MappingSourceSinkRelations"), None)
if mapping_relations and isinstance(mapping_relations, model.SubmodelElementList):
for relation in mapping_relations.value:
Expand Down

0 comments on commit 1a424ee

Please sign in to comment.