From 3326e0cbf0aa76b147386352881d24d066f2805f Mon Sep 17 00:00:00 2001 From: Ahmed Osman <ah_osman@yahoo.com> Date: Wed, 27 Sep 2023 23:18:06 +0200 Subject: [PATCH] Update file README.md --- demos/demo2/README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/demos/demo2/README.md b/demos/demo2/README.md index e6c5d9b..242e50f 100644 --- a/demos/demo2/README.md +++ b/demos/demo2/README.md @@ -1,3 +1,5 @@ +### General + The latest version of the demo consists mainly of three communication partners: demo2_dzwald.py, demo2_forestmanager.py (which represents the Dienstleister) and demo2_forestmanager_waldbesitzer.py (which as the name implies represents the forest owner). demo2_dzwald.py uses the S3IBServer Component from broker_api.py to expose an underlying AAS through the AAS-Interface. @@ -95,6 +97,46 @@ event: model.BasicEventElement = await client.getValue(dzwald_id, dzwald_endpoin /submodel/submodelElements/Auftragsstatus_Updated") auftragsstatus_updated = await client.awaitEvent(event.message_topic) ``` +### Operations + +Operation Submodelelements can be thought of operation descriptions. The actual callable/invokable is added to the S3IBServer (alongside the operation path for authorization purposes): + +``` +getHolzpreisbereich_op = model.Operation( + id_short="getHolzpreisbereich", + input_variable=[model.OperationVariable(model.Property( + id_short="HolzlisteId", + value_type=model.datatypes.String + ))] + ) +holzliste.add_referable(getHolzpreisbereich_op) + +... + +def getHolzpreisbereich(provider: api.ModelProvider, HolzlisteId: str): + ... + return reply + +... + +callable = lambda **kwargs : getHolzpreisbereich(provider, **kwargs) +operation_path = f"/aas/submodels/{helpers.encode_id(HolzlisteId)}/submodel/submodelElements/getHolzpreisbereich" +server.add_callable(operation_path, callable) + +``` + +Invoke the Operation using S3IBAsyncClient's invokeOperation method: + +``` +HolzlisteId = "https://www.company.com/holzliste/1" +reply4 = await client.invokeOperation( + dzwald_id, + dzwald_endpoint, + f"/aas/submodels/{helpers.encode_id(HolzlisteId)}/submodel/submodelElements/getHolzpreisbereich", + {"HolzlisteId": HolzlisteId} +) +print(f"result of operation 'getHolzpreisbereich': {reply4}") +``` -- GitLab