Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ashbeitz/add command support #17

Merged
merged 46 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
987da28
Add commoand support
ashbeitz Jan 13, 2023
f23e9ae
Add commoand support
ashbeitz Jan 17, 2023
16e0603
Add commoand support
ashbeitz Jan 18, 2023
480ea39
Add commoand support
ashbeitz Jan 18, 2023
3748dea
Add commoand support
ashbeitz Jan 19, 2023
e8a2802
Add commoand support
ashbeitz Jan 19, 2023
cdc2a08
Add commoand support
ashbeitz Jan 19, 2023
15ccfde
Add command support
ashbeitz Jan 20, 2023
dd625f6
Add command support
ashbeitz Jan 20, 2023
dd68f9f
Add command support
ashbeitz Jan 20, 2023
64b126c
Add command support
ashbeitz Jan 24, 2023
61e3860
Render PlantUML files
github-actions[bot] Jan 24, 2023
bde1245
Add command support
ashbeitz Jan 24, 2023
d423eed
Merge branch 'ashbeitz/addCommandSupport' of https://github.com/eclip…
ashbeitz Jan 24, 2023
a41edd7
Add command support
ashbeitz Jan 24, 2023
23f4ca8
Add command support
ashbeitz Jan 24, 2023
1463ab0
Add command support
ashbeitz Jan 24, 2023
7cb922a
Add command support
ashbeitz Jan 24, 2023
22aadba
Add command support
ashbeitz Jan 24, 2023
f194f9c
Add command support
ashbeitz Jan 24, 2023
eafec0f
Add command support
ashbeitz Jan 24, 2023
f194449
Add command support
ashbeitz Jan 24, 2023
28c6c49
Add command support
ashbeitz Jan 24, 2023
a99eed6
Add command support
ashbeitz Jan 24, 2023
705e373
Add command support
ashbeitz Jan 25, 2023
a008310
Add command support
ashbeitz Jan 25, 2023
85f01bf
Add command support
ashbeitz Jan 25, 2023
e3da491
Add command support
ashbeitz Jan 25, 2023
f52c517
Add command support
ashbeitz Jan 25, 2023
a19e96d
Add command support
ashbeitz Jan 25, 2023
27926a5
Add command support
ashbeitz Jan 25, 2023
39b8462
Add command support
ashbeitz Jan 25, 2023
f64c52c
Add command support
ashbeitz Jan 25, 2023
947a5ca
Add command support
ashbeitz Jan 25, 2023
87796d5
Add command support
ashbeitz Jan 25, 2023
369823a
Add command support
ashbeitz Jan 25, 2023
9b779fc
Add command support
ashbeitz Jan 25, 2023
73262f6
Add command support
ashbeitz Jan 27, 2023
9b0eb64
Add command support
ashbeitz Jan 27, 2023
a0973ba
Add command support
ashbeitz Jan 30, 2023
426dc04
Add command support
ashbeitz Jan 30, 2023
cac9de9
Add command support
ashbeitz Jan 31, 2023
9ced14e
Add command support
ashbeitz Jan 31, 2023
911663e
Add command support
ashbeitz Jan 31, 2023
a1026ee
Add command support
ashbeitz Jan 31, 2023
0114d88
Add command support
ashbeitz Jan 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "opendigitaltwins-dtdl"]
path = opendigitaltwins-dtdl
url = https://github.com/Azure/opendigitaltwins-dtdl
[submodule "iot-plugandplay-models"]
path = iot-plugandplay-models
url = https://github.com/Azure/iot-plugandplay-models
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ members = [
"proto",
"dtdl-parser",
"in-vehicle-digital-twin",
"provider",
"samples/simple/consumer",
"samples/simple/provider"
"samples/command/consumer",
"samples/command/provider",
"samples/property/consumer",
"samples/property/provider"
]
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- [Introduction](#introduction)
- [High-level Design](#high-level-design)
- [Prerequisites](#prerequisites)
- [Install gcc](#install-gcc)
- [Install Rust](#install-rust)
- [Install Protobuf Compiler](#install-protobuf-compiler)
- [Cloning the Repo](#cloning-the-repo)
Expand All @@ -21,14 +22,22 @@ through an extensible, open and dynamic architecture that provides access to the

## <a name="high-level-design">High-level Design</a>

Ibeji's architecture has a In-Vehicle Digital Twin Service at its core. The In-Vehicle Digital Twin Service captures all of the vehicle's primary capabilities
and make them available to Ibeji consumers. Another component in Ibeji's architecture is the Provider. A vehicle may have one or more providers.
Ibeji's architecture has an In-Vehicle Digital Twin Service at its core. The In-Vehicle Digital Twin Service captures all of the vehicle's primary capabilities
and makes them available to Ibeji consumers. Another component in Ibeji's architecture is the Provider. A vehicle may have one or more providers.
A provider exposes a subset of the vehicle's primary capabilities by registering them with the In-Vehicle Digital Twin Service. Once registered with the
In-Vehicle Digital Twin Service they can in turn be offered to Ibeji consumers. Each capability includes meta data that allow Ibeji consumers to comprehend
the nature of the capability, how to work with it and how it can be remotely accessed.

## <a name="prerequisites">Prerequisites</a>

### <a name="install-gcc">Install gcc</a>

Rust needs gcc's linker, so you will need to intsall it. To install gcc, do the following:

```
sudo apt install gcc
```

### <a name="install-rust">Install Rust</a>

At this point in time, you will need to use the nightly release of Rust. While it is not ideal to rely on a nightly release, we should be able to rely on the
Expand Down Expand Up @@ -57,8 +66,8 @@ You will need to install the Protobuf Compiler. This can be done by executing:

## <a name="cloning-the-repo">Cloning the Repo</a>

The repo has one submodule [opendigitaltwins-dtdl](https://github.com/Azure/opendigitaltwins-dtdl) that provide the DTDL context files and DTDL samples file.
To ensure that it is included, please use the following command when cloning Ibeji's github repo:
The repo has two submodule [opendigitaltwins-dtdl](https://github.com/Azure/opendigitaltwins-dtdl) and [iot-plugandplay-models](https://github.com/Azure/iot-plugandplay-models) that provide DTDL context files
ashbeitz marked this conversation as resolved.
Show resolved Hide resolved
and DTDL samples file. To ensure that these are included, please use the following command when cloning Ibeji's github repo:

`git clone --recurse-submodules https://github.com/eclipse-ibeji/ibeji`

Expand All @@ -73,7 +82,7 @@ and checkout its "resolve-issue-40" branch. It should be cloned to a directory t

### <a name="dtdl-parser">DTDL Parser</a>

There is no existing DTDL Parser for Rust, so we have provided a minimalistic one that is based on the [JavaScript DTDL Parser](https://github.com/Azure/azure-sdk-for-js/tree/%40azure/dtdl-parser_1.0.0-beta.2/sdk/digitaltwins/dtdl-parser).
There is no existing DTDL Parser for Rust, so we have provided a minimalistic one for DTDL v2 that is based on the [JavaScript DTDL Parser](https://github.com/Azure/azure-sdk-for-js/tree/%40azure/dtdl-parser_1.0.0-beta.2/sdk/digitaltwins/dtdl-parser).

## <a name="building">Building</a>

Expand All @@ -93,23 +102,25 @@ Currently, we have no integration tests or end-to-end tests.

## <a name="running-the-demo">Running the Demo</a>

There are currently two demos: one that demonstrates the use of a property and one that demonstrates the use of a command. The following instructions are for the demo for the use of a property. These instructions can easily be adjusted for the demonstration for the use of a command.

Steps:

1. The best way to run the demo is by using three windows: one running the In-Vehicle Digital Twin, one running the Provider and one running a Consumer.
Orientate the three windows so that they are lined up in a column. The top window can be used for the In-Vehicle Digital Twin.
The middle window can be used for the Provider. The bottom window can be used for a Consumer.<br>
1. In each window run the following command too set the DTDL_PATH environment variable.
Make sure that you replace "{repo-root-dir}" with the repository root directory on the machine where you are running the demo.<br><br>
`export DTDL_PATH="{repo-root-dir}/ibeji/opendigitaltwins-dtdl/DTDL;{repo-root-dir}/ibeji/dtdl;{repo-root-dir}/ibeji/samples/simple/dtdl"`<br>
`export DTDL_PATH="{repo-root-dir}/ibeji/opendigitaltwins-dtdl/DTDL;{repo-root-dir}/ibeji/dtdl;{repo-root-dir}/ibeji/samples/property/dtdl"`<br>
1. In each window change directory to the directory containing the build artifacts.
Make sure that you replace "{repo-root-dir}" with the repository root directory on the machine where you are running the demo.<br><br>
`cd {repo-root-dir}/ibeji/target/debug`<br>
1. In the top window, run:<br><br>
`./in-vehicle-digital-twin`<br>
1. In the middle window, run:<br><br>
`./simple-provider`<br>
`./property-provider`<br>
1. In the bottom window, run:<br><br>
`./simple-consumer`<br>
`./property-consumer`<br>
1. Use control-c in each of the windows when you wish to stop the demo.

## <a name="trademarks">Trademarks</a>
Expand Down
2 changes: 1 addition & 1 deletion common-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn get_repo_dir() -> Option<String> {
pub fn set_dtdl_path() {
let repo_dir_result = get_repo_dir();
if let Some(repo_dir) = repo_dir_result {
let value = format!("{}/opendigitaltwins-dtdl/DTDL;{}/dtdl", repo_dir, repo_dir);
let value = format!("{}/opendigitaltwins-dtdl/DTDL;{}/iot-plugandplay-models;{}/dtdl", repo_dir, repo_dir, repo_dir);
env::set_var(DTDL_PATH, &value);
trace!("{}={}", DTDL_PATH, &value);
} else {
Expand Down
90 changes: 65 additions & 25 deletions docs/design/design_spec.md → docs/design/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Please note that the initial Ibeji implementation is a proof-of-concept. We woul
Ibeji has three main architectural concepts:

- Consumer
- Provider.
- Provider
- In-Vehicle Digital Twin Service

The first Ibeji architectural concept that we will introduce is the Consumer. A Consumer is a software entity that utilizes Ibeji to interface with the digital representation of the In-Vehicle hardware components.
Expand Down Expand Up @@ -70,7 +70,7 @@ The DTDL must use the standard dtmi dtdl context. It must also use the dtmi sdv

### In-Vehicle Digital Twin Service Overview

The initial In-Vehicle Digital Twin Service will provide the functionality needed by the proof-of-concept. On the Provider side, this initial contribution supports only a single Provider registering its DTDL. On the Consumer side, there is a simplified query api and the ability to subscribe to a provided hardware resource data feed.
The initial In-Vehicle Digital Twin Service will provide the functionality needed by the proof-of-concept. On the Provider side, this initial contribution supports only a single Provider registering its DTDL. On the Consumer side, there is a simplified query api, and the ability to subscribe to a provided hardware resource data feed and to invoke commands on provided hardware resources.

### Interfaces

Expand All @@ -94,11 +94,11 @@ Below is the sequence diagram for the Find-By-Id activity.

### Overview

The initial Provider will provide the functionality needed by the proof-of-concept, implementing one resource - the AmbientAirTemperature property.
The initial Providers will implement simple resources - the AmbientAirTemperature property and the send_notification command.

### Interfaces

A Provider supports a gRPC interface for subscribing to resource's data feeds, unsubscribing, request a resource's value and setting a resource's value.
A Provider supports a gRPC interface for subscribing to resource's data feeds, unsubscribing from a resource's data feed, requesting a resource's value, setting a resource's value and invoking a command.

### Activities

Expand All @@ -108,11 +108,17 @@ Below is the sequence diagram for the Subscribe activity. The Provider's endpoin

![Sequence Diagram](diagrams/subscribe_sequence.svg)

#### Invoke

Below is the sequence diagram for the Invoke activity. The Provider's endpoint details are exported by the Provider as DTDL to the Digital Twin Service.

![Sequence Diagram](diagrams/invoke_sequence.svg)

## <a name="consumer">Consumer</a>

### Overview

The initial Consumer will provide the functionality needed by the proof-of-concept. It will only query and subscribe to one resource - the AmbientAirTemperature property. It will use the resource's endpoint metadata to subscribe.
The initial Consumers will provide the functionality needed by the proof-of-concept to subscribe to resources data feeds and invoke commands on resources.

Interfaces

Expand All @@ -126,55 +132,75 @@ Below is the sequence diagram for the Publish activity.

![Sequence Diagram](diagrams/publish_sequence.svg)

#### Respond

Below is the sequence diagram for the Respond activity.

![Sequence Diagram](diagrams/respond_sequence.svg)

## <a name="appendix-a">Appendix A – Provider gRPC Interface</a>

### Subscribe

Subscribe to a resource's data feed and publish the resource's updates to a Consumer using the Publish operation on its Consumer interface.
Subscribe to an property's data feed.
ashbeitz marked this conversation as resolved.
Show resolved Hide resolved
ashbeitz marked this conversation as resolved.
Show resolved Hide resolved

#### Request

- id - The resource's id.
- uri - The uri for the endpoint where the data feed will be delivered.
- entity_id - The property's id.
- consumer_uri - The uri for the consumer endpoint where the data feed will be delivered.

#### Response

- No response.

### Unsubscribe

Unsubscribe from a resource's data feed.
Unsubscribe from an entity's data feed.

#### Request

- id - The resource's id.
- uri - The uri for the endpoint where the data feed should no longer be delivered.
- entity_id - The property's id.
- consumer_uri - The uri for the consumer endpoint where the data feed should no longer be delivered.

#### Response

- No response.

### Get

Get the latest value for a resource and publish it to a Consumer using the Publish operation on its Consumer interface.
Get the latest value for a property and publish it to a consumer endpoint.

#### Request

- id - The resource's id.
- uri - The uri for the endpoint where the value should be delivered.
- entity_id - The property's id.
- consumer_uri - The uri for the consumer endpoint where the value should be delivered.

#### Response

- No response.

### Set

Set a resource's value to the one provided. This may not cause a change if the resource cannot be updated.
Set an entity's value to the one provided. This may not cause a change if the entity cannot be updated.

#### Request

- id - The resource's id.
- value - The resource's new value.
- entity_id - The entity's id.
- value - The entity's new value.

#### Response

- No response.

### Invoke

Invoke a command.

#### Request

- entity_id - The command's id.
- uri - The uri for the endpoint where the command's response should be delivered.
- payload - The command's request payload.

#### Response

Expand All @@ -184,31 +210,31 @@ Set a resource's value to the one provided. This may not cause a change if the r

### FindById

Find a resource's DTDL.
Find an entity's DTDL.

#### Request

- id - The resource's id.
- entity_id - The entity's id.

#### Response

- dtdl - The resource's DTDL.

### Register

Register one or more resources.
Register one or more entities.

#### Request

- dtdl - The DTDL that represents the resource/s.
- dtdl - The DTDL that represents the entities.

#### Response

- No response.

### Unregister

Unregister a resource.
Unregister a entity.
ashbeitz marked this conversation as resolved.
Show resolved Hide resolved

#### Request

Expand All @@ -222,13 +248,27 @@ Unregister a resource.

### Publish

Publish a resource value.
Publish a value for a specific entity.

#### Request

- id - The resource's id.
- value - The resource's value.
- entity_id - The entity's id.
- value - The value to publish.

#### Response

- No response.

### Respond

Respond for the execution of a command.

#### Request

- entity_id - The command's id.
- response_id - The id that the invoker of the command provided for the reponse.
- payload - The command's response payload.

#### Response

- No response.
8 changes: 8 additions & 0 deletions docs/design/diagrams/invoke_sequence.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@startuml

participant "Provider"
participant "Consumer"

"Consumer" -> "Provider" : Invoke - request (id, url, payload)

@enduml
1 change: 1 addition & 0 deletions docs/design/diagrams/invoke_sequence.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions docs/design/diagrams/respond_sequence.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@startuml

participant "Provider"
participant "Consumer"

"Provider" -> "Consumer" : Respond - request (id, payload)

@enduml
1 change: 1 addition & 0 deletions docs/design/diagrams/respond_sequence.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion dtdl-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ json-ld = { git = "https://github.com/blast-hardcheese/json-ld", branch = "reso
# json-ld = { git = "https://github.com/timothee-haudebourg/json-ld", tag = "0.9.1-beta" }
lazy_static = "1.4.0"
log = "^0.4"
regex = " 1.7.0"
regex = " 1.7.1"
serde_json = "1.0.88"
strum = "0.24"
strum_macros = "0.24"
Expand Down
2 changes: 1 addition & 1 deletion dtdl-parser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

## Overview

This is a DTDL Parser for Rust, based on the [JavaScript DTDL Parser](https://github.com/Azure/azure-sdk-for-js/tree/%40azure/dtdl-parser_1.0.0-beta.2/sdk/digitaltwins/dtdl-parser). Currently, it only provides a subset of the functionality of the JavaScript DTDL Parser.
This is a DTDL Parser for Rust, based on the [JavaScript DTDL Parser](https://github.com/Azure/azure-sdk-for-js/tree/%40azure/dtdl-parser_1.0.0-beta.2/sdk/digitaltwins/dtdl-parser). Currently, it only provides a subset of the functionality of the JavaScript DTDL Parser.
13 changes: 13 additions & 0 deletions dtdl-parser/src/command_info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

use crate::content_info::ContentInfo;
use crate::command_payload_info::CommandPayloadInfo;

pub trait CommandInfo : ContentInfo {
/// Returns the request.
fn request(&self) -> &Option<Box<dyn CommandPayloadInfo>>;

/// Returns the response.
fn response(&self) -> &Option<Box<dyn CommandPayloadInfo>>;
}
Loading