From 80ab01d1f10f8bfefadd549f54f769b5f20d5666 Mon Sep 17 00:00:00 2001 From: Ahmed Osman <ah_osman@yahoo.com> Date: Wed, 27 Sep 2023 07:06:35 +0200 Subject: [PATCH] Update file README.md --- demos/demo2/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/demos/demo2/README.md b/demos/demo2/README.md index 8c1fb0c..756ff8b 100644 --- a/demos/demo2/README.md +++ b/demos/demo2/README.md @@ -4,14 +4,14 @@ demo2_dzwald.py uses the S3IBServer Component from broker_api.py to expose an un Interaction becomes possible using the S3IBAsyncClient Component and its get-, setValue and invokeOperation methods. Specific elements of the AAS are addressed through a path which has the following form: /aas/submodels/<submodel_id_base64_encoded>/submodel/submodelELements/<id_short_path_encoded> for example: -` +``` submodel_id = "https://www.company.com/holzliste/1" submodel_id_encoded = base64.urlsafe_b64encode(submodel_id.encode()).decode() id_short_path_encoded = quote("Preismatrix[0].Preis") preis: model.Property = provider.getValue( f"/aas/submodels/{submodel_id_encoded}/submodel/submodelElements/{id_short_path_encoded}" ) -` +``` Note: Both the S3IBServer and S3IAsyncClient are actually AMQP Clients that exchange messages through the S3I-Broker. S3IBServer is instantiated with: @@ -20,7 +20,7 @@ Set the last boolean to True to enable authorization. This requires a running op Events can be subscribed to and awaited using S3IBAsyncClient's awaitEvent method. This will block until the event has been triggered (and the event message received). For example: -` +``` # listen on event "Auftragsstatus_Updated" events_submodel_id = "https://www.company.com/submodels/events" events_submodel_id_encoded = base64.urlsafe_b64encode(events_submodel_id.encode()).decode() @@ -28,7 +28,7 @@ event: model.BasicEventElement = await client.getValue(dzwald_id, dzwald_endpoin f"/aas/submodels/{events_submodel_id_encoded} \ /submodel/submodelElements/Auftragsstatus_Updated") auftragsstatus_updated = await client.awaitEvent(event.message_topic) -` +``` To await specific messages, S3IBAsyncClient's awaitMessage method can be used. This takes the message's attributes as parameter. In the following, demo2_forestmanager.py awaits a UserMessage with text "Authorized" that signals that access has been granted before proceeding with rest of the code. `await client.awaitMessage({"text": "Authorized"})` -- GitLab