-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample * Improved seat massager sample
- Loading branch information
Showing
72 changed files
with
1,861 additions
and
656 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -355,3 +355,6 @@ target/ | |
|
||
# VSCodeCounter Extension | ||
.VSCodeCounter/ | ||
|
||
# VS Code | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
DTDL | ||
DTDL's | ||
DTMIs | ||
LD | ||
MaxTempSinceLastReset | ||
Structs | ||
TargetTemperature | ||
com | ||
displayName | ||
dtdl | ||
dtmi | ||
github | ||
hasFloor | ||
json | ||
maxMultiplicity | ||
md | ||
metamodel | ||
minMultiplicity | ||
opendigitaltwins | ||
sdv | ||
src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Digital Twin Model | ||
|
||
## Specifying the Digital Twin Model | ||
|
||
The digital twin model is specified using the Digital Twin Definition Language ([DTDL V3](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v3/DTDL.v3.md)). The DTDL is stored under the `digital-twin-model/dtdl` folder and each file defines a DTDL interface. | ||
|
||
DTDL's behavior is defined by several metamodel classes. Initially, we will only use the Interface, Property, Command and Relationship metamodel classes. | ||
|
||
## DTDL Instance Representation in JSON-LD | ||
|
||
Instances of DTDL models are represented as JSON-LD objects. Each instance is a JSON object that includes the `@context`, `@id`, and `@type` fields, as well as any properties defined in the model. | ||
|
||
The `@context` field provides the context required for interpreting the JSON-LD document. The `@id` field is a unique identifier for the instance, and the `@type` field specifies the DTDL model that the instance is based on. The properties of the instance are represented as key-value pairs in the JSON object. | ||
|
||
Here's an example of a DTDL instance represented in JSON-LD: | ||
|
||
```json | ||
{ | ||
"@context": "dtmi:dtdl:context;3", | ||
"@id": "dtmi:com:example:Thermostat:device1;1", // Unique identifier for the instance | ||
"@type": "dtmi:com:example:Thermostat;1", // The DTDL model that the instance is based on | ||
"Temperature": 20.0, // Property defined in the model | ||
"TargetTemperature": 22.0, // Property defined in the model | ||
"MaxTempSinceLastReset": 25.0 // Property defined in the model | ||
} | ||
``` | ||
|
||
In this example, the `@context` field specifies the version of DTDL being used. For DTDL version 3, the appropriate context specifier is `dtmi:dtdl:context;3`. The `@id` field is a unique identifier for the thermostat device instance, and the `@type` field specifies that the instance is based on the `dtmi:com:example:Thermostat;1` model. The `Temperature`, `TargetTemperature`, and `MaxTempSinceLastReset` fields are properties defined in the model, and their values are set for this specific instance. | ||
|
||
In DTDL, a **Relationship** is a directional link from a source digital twin to a target digital twin. Relationships are used to create and navigate the graph of digital twins. | ||
|
||
Here's an example of how a relationship might be represented in a DTDL model: | ||
|
||
```json | ||
{ | ||
"@context": "dtmi:dtdl:context;3", | ||
"@id": "dtmi:com:example:Building;1", | ||
"@type": "Interface", | ||
"displayName": "Building", | ||
"contents": [ | ||
{ | ||
"@type": "Relationship", | ||
"name": "hasFloor", | ||
"minMultiplicity": 0, | ||
"maxMultiplicity": 100, | ||
"target": "dtmi:com:example:Floor;1" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
In this example, the `hasFloor` relationship represents a link from a `Building` instance to a `Floor` instance. The `minMultiplicity` and `maxMultiplicity` fields specify that a `Building` can have between 0 and 100 `Floor` instances. The `target` field specifies the DTDL model that the target of the relationship is based on. | ||
|
||
Here's an example of how a relationship might be represented in a DTDL instance: | ||
|
||
```json | ||
{ | ||
"@context": "dtmi:dtdl:context;3", | ||
"@id": "dtmi:com:example:Building:building1;1", // Unique identifier for the instance | ||
"@type": "dtmi:com:example:Building;1", // The DTDL model that the instance is based on | ||
"hasFloor": [ | ||
"dtmi:com:example:Floor:floor1;1", | ||
"dtmi:com:example:Floor:floor2;1" | ||
] | ||
} | ||
``` | ||
|
||
In this example, the `hasFloor` field is an array of identifiers for `Floor` instances that are related to the `Building` instance. | ||
|
||
## Using the Digital Twin Model in the Code | ||
|
||
The digital twin providers and consumers need to reference the Digital Twin Model to perform digital twin interactions. They need the following information from the model: | ||
|
||
- the model identifiers (denoted by "@id" in the DTDL) to identify the part of the model that they want to use | ||
- the model names (denoted by "name" in the DTDL) to identify the member of a model part that they want to use | ||
- the property definitions to exchange the associated values | ||
- the command definitions to send and receive the appropriate payloads. | ||
|
||
We need to make the digital twin model accessible as code. Each programming language will need its own variant. In this code repository, we will | ||
provide a Rust variant. We will place all of the code for the model's content in a single file named after the model and its version. In | ||
this code repository, that file will be the 'digital-twin-model/src/sdv_v1.rs' file. | ||
|
||
The 'sdv_v1.rs' file is based on the model content from the DTDL files located under 'digital-twin-model/dtdl/dtmi/sdv'. A legacy version of this file 'sdv_v0.rs' is also present; it remains to support some of the older samples. | ||
|
||
The 'sdv_v1.rs' file will setup namespaces based on the DTMIs used in the DTDL files. These namespaces will allow developers to provide fully | ||
qualified names that look similar to the DTMIs (minus the 'dtmi:sdv:' prefix). | ||
|
||
For each namespace, we will define: | ||
|
||
- Constants for model ids (“ID”), model descriptions (“DESCRIPTION”), and model member names (“NAME”). | ||
- Structs named “TYPE” to define property values, command request payloads, command response payloads, and schema types. |
120 changes: 120 additions & 0 deletions
120
digital-twin-model/dtdl/dtmi/sdv/airbag_seat_massager-1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
{ | ||
"@context": ["dtmi:dtdl:context;3"], | ||
"@type": "Interface", | ||
"@id": "dtmi:sdv:airbag_seat_massager;1", | ||
"description": "Airbag Seat Massager Interface.", | ||
"extends": "dtmi:sdv:seat_massager;1", | ||
"contents": [ | ||
{ | ||
"@type": "Command", | ||
"@id": "dtmi:sdv:airbag_seat_massager:store_sequence;1", | ||
"name": "store_sequence", | ||
"description": "Store a massage sequence.", | ||
"request": { | ||
"name": "request", | ||
"description": "Request.", | ||
"schema": { | ||
"@type": "Object", | ||
"fields": [ | ||
{ | ||
"name": "sequence_name", | ||
"schema": "string" | ||
}, | ||
{ | ||
"name": "sequence", | ||
"schema": "dtmi:sdv:massage_sequence;1" | ||
} | ||
] | ||
} | ||
}, | ||
"response": { | ||
"name": "response", | ||
"description": "Response.", | ||
"schema": { | ||
"@type": "Object", | ||
"fields": [ | ||
{ | ||
"name": "status", | ||
"schema": "dtmi:sdv:airbag_seat_massager:status;1" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"@type": "Command", | ||
"@id": "dtmi:sdv:airbag_seat_massager:perform_step;1", | ||
"name": "perform_step", | ||
"description": "Perform a step in the sequence.", | ||
"request": { | ||
"name": "request", | ||
"description": "Request.", | ||
"schema": { | ||
"@type": "Object", | ||
"fields": [ | ||
{ | ||
"name": "step", | ||
"schema": "dtmi:sdv:massage_step;1" | ||
} | ||
] | ||
} | ||
}, | ||
"response": { | ||
"name": "response", | ||
"schema": { | ||
"@type": "Object", | ||
"fields": [ | ||
{ | ||
"name": "status", | ||
"schema": "dtmi:sdv:airbag_seat_massager:status;1" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"schemas": [ | ||
{ | ||
"@id": "dtmi:sdv:airbag_seat_massager:status;1", | ||
"@type": "Object", | ||
"fields": [ | ||
{ | ||
"name": "code", | ||
"schema": "integer" | ||
}, | ||
{ | ||
"name": "message", | ||
"schema": "string" | ||
} | ||
] | ||
}, | ||
{ | ||
"@id": "dtmi:sdv:massage_sequence;1", | ||
"@type": "Array", | ||
"elementSchema": "dtmi:sdv:massage_step;1" | ||
}, | ||
{ | ||
"@id": "dtmi:sdv:massage_step;1", | ||
"@type": "Array", | ||
"elementSchema": "dtmi:sdv:airbag_adjustment;1" | ||
}, | ||
{ | ||
"@id": "dtmi:sdv:airbag_adjustment;1", | ||
"@type": "Object", | ||
"fields": [ | ||
{ | ||
"name": "airbag_identifier", | ||
"schema": "integer" | ||
}, | ||
{ | ||
"name": "inflation_level", | ||
"schema": "integer" | ||
}, | ||
{ | ||
"name": "inflation_duration_in_seconds", | ||
"schema": "integer" | ||
} | ||
] | ||
} | ||
] | ||
} |
7 changes: 7 additions & 0 deletions
7
digital-twin-model/dtdl/dtmi/sdv/basic_airbag_seat_massager-1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"@context": ["dtmi:dtdl:context;3"], | ||
"@type": "Interface", | ||
"@id": "dtmi:sdv:basic_airbag_seat_massager;1", | ||
"description": "Basic Airbag Seat Massager Interface.", | ||
"extends": "dtmi:sdv:airbag_seat_massager;1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"@context": ["dtmi:dtdl:context;3"], | ||
"@type": "Interface", | ||
"@id": "dtmi:sdv:cabin;1", | ||
"description": "Cabin Interface.", | ||
"contents": [ | ||
{ | ||
"@type": "Relationship", | ||
"@id": "dtmi:sdv:cabin:has_infotainment;1", | ||
"target": "dtmi:sdv:infotainment;1", | ||
"name": "has_infotainment", | ||
"maxMultiplicity": 1 | ||
}, | ||
{ | ||
"@type": "Relationship", | ||
"@id": "dtmi:sdv:cabin:has_hvac;1", | ||
"target": "dtmi:sdv:hvac;1", | ||
"name": "has_hvac", | ||
"maxMultiplicity": 1 | ||
}, | ||
{ | ||
"@type": "Relationship", | ||
"@id": "dtmi:sdv:cabin:has_seat;1", | ||
"name": "has_seat", | ||
"target": "dtmi:sdv:seat;1", | ||
"properties": [ | ||
{ | ||
"@type": "Property", | ||
"@id": "dtmi:sdv:seat:seat_row;1", | ||
"name": "seat_row", | ||
"schema": "integer" | ||
}, | ||
{ | ||
"@type": "Property", | ||
"@id": "dtmi:sdv:Seat:seat_position;1", | ||
"name": "seat_position", | ||
"schema": { | ||
"@type": "Enum", | ||
"valueSchema": "string", | ||
"enumValues": [ | ||
{ | ||
"name": "left", | ||
"displayName": "left", | ||
"enumValue": "left" | ||
}, | ||
{ | ||
"name": "center", | ||
"displayName": "center", | ||
"enumValue": "center" | ||
}, | ||
{ | ||
"name": "right", | ||
"displayName": "right", | ||
"enumValue": "right" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"@context": "dtmi:dtdl:context;3", | ||
"@type": "Interface", | ||
"@id": "dtmi:sdv:camera;1", | ||
"description": "Camera Interface.", | ||
"contents": [ | ||
{ | ||
"@type": "Property", | ||
"@id": "dtmi:sdv:camera:feed;1", | ||
"name": "feed", | ||
"description": "The camera feed.", | ||
"schema": { | ||
"@type": "Object", | ||
"fields": [ | ||
{ | ||
"name": "media_type", | ||
"schema": "string" | ||
}, | ||
{ | ||
"name": "media_content", | ||
"description": "An array of bytes (represented by integers here).", | ||
"schema": { | ||
"@type": "Array", | ||
"elementSchema": "integer" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.