3from aas_standard_parser
import AIDParser
4from aas_standard_parser.aid_parser
import IAuthenticationDetails
5from basyx.aas.model
import ModelReference, SubmodelElementCollection
7logger = logging.getLogger(__name__)
11 """Interface for asset connectors.
12 It serves as the base class for any protocol-specific implementations and provides common functionality.
15 def __init__(self, aid_id: str, interface_smc: SubmodelElementCollection):
16 """Initialize the AssetConnector with AID ID and interface submodel collection.
18 :param aid_id: The ID of the AID submodel.
19 :param interface_smc: A SubmodelElementCollection inside the AID submodel specifying the asset interface.
26 raise ValueError(
"Failed to parse AID interface.")
29 """Parse the asset interface definition.
30 Extracts authentication details, base address, and property endpoints for connecting to the asset.
31 Stores the extracted information in self._auth, `self.base`, and `self._parsed_properties`."""
33 aid_parser = AIDParser()
37 self._auth: IAuthenticationDetails = aid_parser.parse_security(self.
_interface)
38 except ValueError
as e:
39 logger.error(f
"Error parsing aid interface: {e}")
45 """Connect to the asset."""
47 async def get_value(self, endpoint_reference: ModelReference) -> str |
None:
48 """Get value from the asset for the specified endpoint reference.
50 :param endpoint_reference: A reference pointing to an endpoint inside the AID interface specification.
53 async def set_value(self, endpoint_reference: ModelReference, *args):
54 """Set a value on the asset via the specified endpoint.
56 :param endpoint_reference: A reference pointing to an endpoint inside the AID interface specification.
57 :param args: Key-value pairs to be written to the endpoint.
60 async def do_action(self, endpoint_reference: ModelReference, *args):
61 """Invoke action on the asset for the specified endpoint reference.
64 :param endpoint_reference: A reference pointing to an endpoint inside the AID interface specification.
65 :param args: Key-value pairs as parameters to the invoked action.
Interface for asset connectors.
do_action(self, ModelReference endpoint_reference, *args)
Invoke action on the asset for the specified endpoint reference.
set_value(self, ModelReference endpoint_reference, *args)
Set a value on the asset via the specified endpoint.
connect(self)
Connect to the asset.
__init__(self, str aid_id, SubmodelElementCollection interface_smc)
Initialize the AssetConnector with AID ID and interface submodel collection.
bool _parse_aid_interface(self)
Parse the asset interface definition.
str|None get_value(self, ModelReference endpoint_reference)
Get value from the asset for the specified endpoint reference.