smia.assetconnection.asset_connection module

class smia.assetconnection.asset_connection.AssetConnection[source]

Bases: object

This class is an abstract class for all AssetConnections.

class ArchitectureStyle(value)[source]

Bases: Enum

An enumeration.

PUBSUB = 0
CLIENTSERVER = 1
NOTAPPLICABLE = 2
abstract async configure_connection_by_aas_model(interface_aas_elem)[source]

This method configures the Asset Connection using the interface element defined in the AAS model.

Parameters:

interface_aas_elem (basyx.aas.model.SubmodelElement) – element of the AAS model with the asset interface information.

abstract async check_asset_connection()[source]

This method checks the Asset Connection.

abstract async connect_with_asset()[source]

This method performs the connection process to the Asset Connection.

abstract async execute_asset_service(interaction_metadata, service_input_data=None)[source]

This method sends a message to the asset and returns the response. The connection of the interface of the asset is already configured in ‘configure_connection_by_aas_model’ method, but the interaction metadata is provided in form of a Python object of AAS model (SubmodelElement).

Parameters:
  • interaction_metadata (basyx.aas.model.SubmodelElement) – element of the AAS model with all metadata for the interaction with the asset.

  • service_input_data – object with the input data of the service

Returns:

response information defined in the interaction metadata.

Return type:

object

abstract async receive_msg_from_asset()[source]

This method receives a message from the asset through the Asset Connection.

async classmethod check_interface_element(interface_elem)[source]

This method checks the given interface AAS element from the ‘AssetInterfacesDescription’ submodel. In case of identifying any error it raises an ‘AssetConnectionError’ exception.

Parameters:

interface_elem (basyx.aas.model.SubmodelElementCollection) – SubmodelElement of AAS interface SubmodelElement.

async check_endpoint_metadata()[source]

This method checks if the given endpointMetadata object is valid (if it is within the correct submodel and if it has all required attributes).

async check_interaction_metadata(interaction_metadata)[source]

This method checks if the given interactionMetadata object is valid (if it is within the correct submodel and if it has all required attributes).

Parameters:

interaction_metadata (basyx.aas.model.SubmodelElementCollection) – SubmodelElement of interactionMetadata.

async get_interaction_metadata_content_type(interaction_metadata)[source]

This method gets the content type of the interaction metadata. If it is not defined, the type defined in the EndpointMetadata will be :param interaction_metadata: interactionMetadata Python object. :type interaction_metadata: basyx.aas.model.SubmodelElementCollection

Returns:

Python object of the content type

Return type:

basyx.aas.model.SubmodelElementElement

async classmethod check_submodel_element_exist_by_semantic_id(submodel_elem_col, sm_id_short, semantic_id)[source]

This method checks if a submodelElement with the given semanticID exists within the given SubmodelElementCollection.

Parameters:
  • submodel_elem_col (basyx.aas.model.SubmodelElementCollection) – SubmodelElementCollection where the SubmodelElement has to be found.

  • sm_id_short (str) – idShort of the SubmodelElement to find.

  • semantic_id (str) – semantic ID to find the required SubmodelElement.

async classmethod check_data_query_type(interaction_elem_name, content_type, data_query_elem)[source]

This method checks if the data query of the interaction metadata element is valid. It is valid when the type specified in the data query is the appropriate for the content type of the element.

Parameters:
  • interaction_elem_name (str) – name of the interaction element to show in case of invalid data query.

  • content_type (str) – type of the content of the interaction metadata element.

  • data_query_elem (basyx.aas.model.SubmodelElementCollection) – SubmodelElement of dataQuery.

Returns:

async classmethod get_response_content(interaction_metadata, response_content)[source]

This method gets the required information from the content of the response message from the asset using the interactionMetadata information.

Parameters:
  • interaction_metadata (basyx.aas.model.SubmodelElementCollection) – SubmodelElement of interactionMetadata.

  • response_content (str) – The content of the response message from the asset in string format.

async classmethod extract_information_with_data_query(content_type, content_data, query)[source]

This method extracts the information of the content using the query defined in the interface element.

Parameters:
  • content_type (str) – format of the content.

  • content_data – data of the content.

  • query (str) – query to extract information from the content.

Returns:

extracted information (result of the query in the given data).

Return type:

object

async classmethod transform_data_by_type(content_data, data_type)[source]

This method transforms the data by its type.

Parameters:
  • content_data – data of the content to be transformed.

  • data_type – type of the data.

Returns:

transformed data.

Return type:

object

classmethod extract_from_json(data, query)[source]

This method extracts the required information from a JSON object. It uses the ‘jsonpath-ng’ Python package to perform the extraction.

Parameters:
  • data (dict) – JSON object with the given data.

  • query (str) – query to extract information from the content. In this case, it has to be a JSONPath expression.

Returns:

extracted information (result of the query in the given data).

Return type:

object

classmethod extract_from_xml(data, query)[source]

This method extracts the required information from an XML object. It uses the ‘lxml’ Python package to perform the extraction.

Parameters:
  • data (str) – XML object with the given data in string format.

  • query (str) – query to extract information from the content. In this case, it has to be a XPath expression.

Returns:

extracted information (result of the query in the given data).

Return type:

object

classmethod extract_from_string(data, query)[source]

This method extracts the required information from a string object. It uses the ‘re’ Python package to perform the extraction.

Parameters:
  • data (str) – string object with the given data.

  • query (str) – query to extract information from the content. In this case, it has to be a Regex expression.

Returns:

extracted information (result of the query in the given data).

Return type:

object