Commit d4466fa7 authored by Jiahang Chen's avatar Jiahang Chen
Browse files

add documentation for the permanent digital twin

parent 19069960
Pipeline #367707 passed with stages
in 35 seconds
......@@ -17,6 +17,7 @@ Table of Contents
md/preliminaries.md
dt_factory
tools
md/permanent_dt.md
Indices and tables
==================
......
# Permanent Digital Twin
With the fml40-python-lib, we have developed a Digital Twin, which is modeled based on the language FML40 and runs permanent. The Digital Twin is implemented using fog approach, which means it is composed of the part of edge DT, which lives in our internal server, and the part of cloud DT, which runs at the S³I Repository. The S³I Interface is enabled in the DT. To communicate with the DT, we provided a python script named `hmi.py` in the folder `demo`. Just run the hmi.py to speak with the DT after installing the corresponding python virtual environment. This documentation introduces the main features of the Digital Twin and JSON entries in the S³I Directory and Repository.
## S³I Directory entry
S³I Directory entry describes a thing at the layer of the metadata, which can be mapped to a JSON file. In order to query the JSON file, you can send a HTTP Request to the S³I Directory. Regarding how to send a HTTP Request, refer to [the S³I Document](https://kwh40.pages.rwth-aachen.de/-/s3i/-/jobs/1095388/artifacts/public/html/md/communication.html). The Digital Twin has a directory entry shown below:
```
{
"thingId": "s3i:b6d1cc6d-896c-40fe-9403-b5b7682b1d03",
"policyId": "s3i:b6d1cc6d-896c-40fe-9403-b5b7682b1d03",
"attributes": {
"owner": "318b5bc4-7479-4d8d-b347-1019ca194d81",
"class": "ml40::Thing",
"allEndpoints": [
"s3ib://s3i:b6d1cc6d-896c-40fe-9403-b5b7682b1d03",
"https://ditto.s3i.vswf.dev/api/2/things/s3i:b6d1cc6d-896c-40fe-9403-b5b7682b1d03/"
],
"type": "component",
"name": "mmi_fog_harvester",
"location": {
"longitude": 6.45435,
"latitude": 52.543534
},
"dataModel": "fml40",
"thingStructure": {
"class": "ml40::Thing",
"links": [
{
"association": "roles",
"target": {
"class": "fml40::Harvester",
"identifier": "s3i:e1b8b3d6-65a6-4733-876a-dbde9ff72afd"
}
},
{
"association": "features",
"target": {
"class": "fml40::ProvidesProductionData",
"identifier": "s3i:3cece6c6-5e94-448d-b95d-9e3b3c02e6da"
}
},
{
"association": "features",
"target": {
"class": "ml40::ProductionData",
"identifier": "s3i:30b9325f-ce4f-4c55-89f7-663eb4b76273"
}
},
{
"association": "features",
"target": {
"class": "fml40::AcceptsFellingJobs",
"identifier": "s3i:2ce793d4-0b6f-472e-abcb-c0e1e9b084af"
}
},
{
"association": "features",
"target": {
"class": "fml40::Harvests",
"identifier": "s3i:94f8c4d1-9d6c-45e8-a137-3bb33b1004b6"
}
},
{
"association": "features",
"target": {
"class": "ml40::JobList",
"identifier": "s3i:3ba16ab9-a472-42b7-af97-c19acef55196"
}
},
{
"association": "features",
"target": {
"class": "ml40::Composite",
"identifier": "s3i:316f0140-8ce2-440b-badd-3ece563c167c",
"links": [
{
"class": "ml40::Thing",
"identifier": "s3i:a57543fb-2b03-43d8-ac4b-f3ba24a545c4",
"links": [
{
"association": "roles",
"target": {
"class": "ml40::Engine",
"identifier": "s3i:2fb281c8-180f-41fb-a333-7b83d83cfae0"
}
},
{
"association": "features",
"target": {
"class": "ml40::RotationalSpeed",
"identifier": "s3i:209eb6e3-4a16-458c-952b-dcf3569d062b"
}
}
]
},
{
"class": "ml40::Thing",
"identifier": "s3i:97453feb-e15d-463c-9a45-ec4c59b4c8c8",
"links": [
{
"association": "roles",
"target": {
"class": "ml40::Crane",
"identifier": "s3i:8f480a94-7b0a-4293-96a9-08ddb0360af6"
}
},
{
"association": "features",
"target": {
"class": "ml40::Shared",
"identifier": "s3i:5cba3433-051b-4e22-9245-30e4c6a45200"
}
}
]
}
]
}
}
]
}
}
}
```
## S³I Repository entry
In a run time environment like edge device or S³I Repository, a conceptual fml40 data model can be directly mapped to a JSON file which describes the thing itself. The Repository entry can be queried via HTTP REST Request, refer to [S³I Documentation](https://kwh40.pages.rwth-aachen.de/-/s3i/-/jobs/1095388/artifacts/public/html/md/communication.html). The permanent Digital Twin has a repository entry which is shown in the following:
```
{
"thingId": "s3i:b6d1cc6d-896c-40fe-9403-b5b7682b1d03",
"policyId": "s3i:b6d1cc6d-896c-40fe-9403-b5b7682b1d03",
"attributes": {
"class": "ml40::Thing",
"name": "mmi_fog_harvester",
"roles": [
{
"class": "fml40::Harvester",
"identifier": "s3i:e1b8b3d6-65a6-4733-876a-dbde9ff72afd"
}
],
"features": [
{
"class": "fml40::ProvidesProductionData",
"identifier": "s3i:3cece6c6-5e94-448d-b95d-9e3b3c02e6da"
},
{
"class": "ml40::ProductionData",
"identifier": "s3i:30b9325f-ce4f-4c55-89f7-663eb4b76273",
"subFeatures": [
{
"class": "ml40::Composite",
"identifier": "s3i:78309618-f796-4132-92c9-a3e923506463",
"targets": [
{
"class": "ml40::Thing",
"identifier": "s3i:70e808e0-0e0c-4bca-bbaf-23a350c3cf91",
"name": "Stammsegment 4711",
"roles": [
{
"class": "fml40::StemSegment",
"identifier": "s3i:1cbe9e8d-cc80-47fb-baab-20878043348a"
}
],
"features": [
{
"class": "ml40::Location",
"identifier": "s3i:6cdbd9a5-95e2-4539-bd5d-c5238a9d952f",
"latitude": 50.1231,
"longitude": 6.1231
},
{
"class": "fml40::StemSegmentProperties",
"identifier": "s3i:ddeb1e34-1a74-4f6e-a806-75d1cfe98d68",
"diameter": 0.4,
"length": 2,
"woodType": "Spruce"
}
]
},
{
"class": "ml40::Thing",
"identifier": "s3i:55d6793c-37e3-4433-a214-89513bd1cfe0",
"name": "Stammsegment 4712",
"roles": [
{
"class": "fml40::StemSegment",
"identifier": "s3i:0c24170c-e122-454d-b803-a94af462c554"
}
],
"features": [
{
"class": "ml40::Location",
"identifier": "s3i:d1b80ca5-df18-4ed9-b9a9-129e18cb8b76",
"latitude": 50.1231,
"longitude": 6.1231
},
{
"class": "fml40::StemSegmentProperties",
"identifier": "s3i:57d09fc1-4218-4fc6-9e80-c6d2fc44c2f4",
"diameter": 0.6,
"length": 3,
"woodType": "Spruce"
}
]
}
]
}
]
},
{
"class": "fml40::AcceptsFellingJobs",
"identifier": "s3i:2ce793d4-0b6f-472e-abcb-c0e1e9b084af"
},
{
"class": "fml40::Harvests",
"identifier": "s3i:94f8c4d1-9d6c-45e8-a137-3bb33b1004b6"
},
{
"class": "ml40::JobList",
"identifier": "s3i:3ba16ab9-a472-42b7-af97-c19acef55196"
},
{
"class": "ml40::Composite",
"identifier": "s3i:316f0140-8ce2-440b-badd-3ece563c167c",
"targets": [
{
"class": "ml40::Thing",
"identifier": "s3i:a57543fb-2b03-43d8-ac4b-f3ba24a545c4",
"name": "Motor",
"roles": [
{
"class": "ml40::Engine",
"identifier": "s3i:2fb281c8-180f-41fb-a333-7b83d83cfae0"
}
],
"features": [
{
"class": "ml40::RotationalSpeed",
"identifier": "s3i:209eb6e3-4a16-458c-952b-dcf3569d062b",
"rpm": 2331
}
]
},
{
"class": "ml40::Thing",
"identifier": "s3i:97453feb-e15d-463c-9a45-ec4c59b4c8c8",
"name": "Kran",
"roles": [
{
"class": "ml40::Crane",
"identifier": "s3i:8f480a94-7b0a-4293-96a9-08ddb0360af6"
}
],
"features": [
{
"class": "ml40::Shared",
"identifier": "s3i:5cba3433-051b-4e22-9245-30e4c6a45200",
"targets": [
{
"class": "ml40::Thing",
"identifier": "s3i:efbc9eef-82a1-4ed1-86d0-b06170cae3cd",
"name": "Harvesterkopf",
"roles": [
{
"class": "fml40::HarvestingHead",
"identifier": "s3i:f338cd4d-ca21-46db-8b3b-a17c7c026b6d"
}
],
"features": [
{
"class": "fml40::Cuts",
"identifier": "s3i:83d8e549-0d07-49f4-9906-6a729b3e6e9b"
},
{
"class": "fml40::Grabs",
"identifier": "s3i:cf6ad395-69d2-493f-838e-82bbc74c4273"
}
]
}
]
}
]
}
]
}
]
},
"features": {}
}
```
## Service Call
As shown in the directory entry, the DT provided diverse service functions. A list containing all embedded service functions can be found below:
```
class: fml40::AcceptsFellingJobs
methods:
- acceptJob(job)
- queryJobStatus(identifier)
- removeJob(identifier)
class: fml40::ProvidesProductionData
methods:
- getProductionData(name)
```
In order to call those functions remotely, we need to send a S³I-B ServiceRequest to the Digital Twin via the S³I Broker. The class/method name and parameters need to be declared within the message.
The following example shows how to call `removeJob` of the class `fml40::AcceptsFellingJob`
```
{
"identifier": "s3i:94f8c4d1-9d6c-45e8-a137-3bb33b1004b6" # message ID
"sender": "s3i:7f46a255-3245-439e-84f0-090f0b221965", # ID of my private HMI
"receivers": ["s3i:b6d1cc6d-896c-40fe-9403-b5b7682b1d03"], # ID of the Digital Twin
"serviceType": "fml40::AcceptsFellingJob/removeJob", # specifies the method and class, which should be called
"parameters": {"identifier": "s3i:3ba16ab9-a472-42b7-af97-c19acef55196"}, # specifies the input
"messageType": "ServiceRequest", # message type
"replyToEndpoint": "s3ib://s3i:7f46a255-3245-439e-84f0-090f0b221965" # Endpoint of my private HMI,
}
```
The message can be sent directly via [the S³I Broker API](https://broker.s3i.vswf.dev/apidoc) or using [S³I Python Lib](https://kwh40.pages.rwth-aachen.de/-/s3i/-/jobs/1095388/artifacts/public/html/S3I-Package.html), An example can be found [here](https://git.rwth-aachen.de/kwh40/s3i/-/blob/master/demo/demo2_sender_hmi.py)
## Query Value
A service is implemented in the DT with the purpose of handling S³I GetValueRequest, so we can send a getValueRequest message to query a specified value of the original JSON model in the edge DT. In the following, we provide also an example to query the current motor rpm value.
```
{
'sender': 's3i:7f46a255-3245-439e-84f0-090f0b221965', # ID of my private HMI
'identifier': 's3i:23c99920-c369-4074-83b9-17beb84bb2d2', # message ID
'receivers': ['s3i:b6d1cc6d-896c-40fe-9403-b5b7682b1d03'], # ID of the digital Twin
'messageType': 'getValueRequest', # message Type
'replyToEndpoint': 's3ibs://s3i:7f46a255-3245-439e-84f0-090f0b221965', # Endpoint of my private HMI
'attributePath': 'attributes/features/ml40::Composite/targets/ml40::Engine/features/ml40::RotationalSpeed/rpm' # the path of rpm value
}
```
The message can be sent via the S³I Broker API or using S³I Python lib as well.
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment