Skip to content

Commit

Permalink
Use Chariott (#30)
Browse files Browse the repository at this point in the history
* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott

* Use Chariott
  • Loading branch information
ashbeitz authored Jun 6, 2023
1 parent 59c030d commit fe4a8aa
Show file tree
Hide file tree
Showing 34 changed files with 1,086 additions and 391 deletions.
8 changes: 8 additions & 0 deletions .accepted_words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ br
build
cargo
cd
CHARIOTT
Chariott
Chariott's
chariott
com
config
digitaltwins
dir
dt
Expand All @@ -19,6 +24,7 @@ ibeji
Ibeji
Ibeji's
intellectualproperty
invehicle
iot
js
json
Expand All @@ -39,4 +45,6 @@ snapd
sudo
timothee
toolchain
url
www
yaml
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
[submodule "external/iot-plugandplay-models"]
path = external/iot-plugandplay-models
url = https://github.com/Azure/iot-plugandplay-models
[submodule "external/--force"]
path = external/--force
url = https://github.com/eclipse-chariott/chariott
[submodule "external/chariott"]
path = external/chariott
url = https://github.com/eclipse-chariott/chariott
15 changes: 10 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
members = [
# core
"core/protobuf_data_access",
"core/in-vehicle-digital-twin",
"core/invehicle-digital-twin",

# digital twin model
"digital-twin-model",
Expand All @@ -25,6 +25,7 @@ members = [

[workspace.dependencies]
async-std = "^1.5"
config = "0.13.3"
env_logger= "0.10.0"
futures = "0.3"
generic-json = "^0.7"
Expand All @@ -33,12 +34,16 @@ lazy_static = "1.4.0"
log = "^0.4"
parking_lot = "0.12.1"
prost = "0.11"
regex = " 1.8.1"
tokio = "1.0"
tonic = "0.9.2"
tonic-build = "0.9.2"
prost-types = "0.11"
regex = " 1.8.3"
serde = "1.0.160"
serde_derive = "1.0.163"
serde_json = "^1.0"
strum = "0.24"
strum_macros = "0.24"
tokio = "1.0"
tonic = "0.9.2"
tonic-build = "0.9.2"
url = "2.3.1"
uuid = "1.2.2"
yaml-rust = "0.4"
59 changes: 48 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,30 @@ Currently, we have no integration tests or end-to-end tests.
There are currently three demos: one that demonstrates the use of a property, one that demonstrates the use of a command and one that
demonstrates the mixed use of properties and commands.

The demos use config files and we have provided a templated version of each config file. These templates can be found in:

- {repo-root-dir}/core/invehicle_digital_twin/template
- {repo-root-dir}/samples/common/template

The following instructions are for the demo for the use of a property.

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 change directory to the directory containing the build artifacts.
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}/target/debug`<br>
1. Create the three config files with the following contents, if they are not already there:<br><br>
---- consumer_settings.yaml ----<br>
`consumer_authority: "0.0.0.0:6010"`<br>
`invehicle_digital_twin_url: "http://0.0.0.0:5010"`<br><br>
---- invehicle_digital_twin_settings.yaml ----<br>
`invehicle_digital_twin_authority: "0.0.0.0:5010"`<br><br>
---- provider_settings.yaml ----<br>
`provider_authority: "0.0.0.0:4010"`<br>
`invehicle_digital_twin_url: "http://0.0.0.0:5010"`<br><br>
1. In the top window, run:<br><br>
`./in-vehicle-digital-twin`<br>
1. In the middle window, run:<br><br>
Expand All @@ -130,9 +144,18 @@ 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 change directory to the directory containing the build artifacts.
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}/target/debug`<br>
1. Create the three config files with the following contents, if they are not already there:<br><br>
---- consumer_settings.yaml ----<br>
`consumer_authority: "0.0.0.0:6010"`<br>
`invehicle_digital_twin_url: "http://0.0.0.0:5010"`<br><br>
---- invehicle_digital_twin_settings.yaml ----<br>
`invehicle_digital_twin_authority: "0.0.0.0:5010"`<br><br>
---- provider_settings.yaml ----<br>
`provider_authority: "0.0.0.0:4010"`<br>
`invehicle_digital_twin_url: "http://0.0.0.0:5010"`<br><br>
1. In the top window, run:<br><br>
`./in-vehicle-digital-twin`<br>
1. In the middle window, run:<br><br>
Expand All @@ -141,24 +164,25 @@ Make sure that you replace "{repo-root-dir}" with the repository root directory
`./command-consumer`<br>
1. Use control-c in each of the windows when you wish to stop the demo.

## <a name="trademarks">Trademarks</a>

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
trademarks or logos is subject to and must follow
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
Any use of third-party trademarks or logos are subject to those third-party's policies.

The following instructions are for the demo for the mixed use of commands and properties.

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 change directory to the directory containing the build artifacts.
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}/target/debug`<br>
1. Create the three config files with the following contents, if they are not already there:<br><br>
---- consumer_settings.yaml ----<br>
`consumer_authority: "0.0.0.0:6010"`<br>
`invehicle_digital_twin_url: "http://0.0.0.0:5010"`<br><br>
---- invehicle_digital_twin_settings.yaml ----<br>
`invehicle_digital_twin_authority: "0.0.0.0:5010"`<br><br>
---- provider_settings.yaml ----<br>
`provider_authority: "0.0.0.0:4010"`<br>
`invehicle_digital_twin_url: "http://0.0.0.0:5010"`<br><br>
1. In the top window, run:<br><br>
`./in-vehicle-digital-twin`<br>
1. In the middle window, run:<br><br>
Expand All @@ -167,6 +191,19 @@ Make sure that you replace "{repo-root-dir}" with the repository root directory
`./mixed-consumer`<br>
1. Use control-c in each of the windows when you wish to stop the demo.

If you want the consumers and providers for each demo to use Chariott to discover the URL for the In-Vehicle Digital Twin Service, rather than
having it statically provided in their respective config file, then do the following before starting each demo:

1. Clone a copy of Chariott from GitHub (`https://github.com/eclipse-chariott/chariott`).
1. Build Chariott
1. Set Chariott's CHARIOTT_REGISTRY_TTL_SECS environment variable to a high number (we suggest 86400 seconds), as Ibeji does not rely on Chariott's announce feature:<br><br>
`export CHARIOTT_REGISTRY_TTL_SECS=86400`<br>
1. Run Chariott:<br><br>
`cargo run -p chariott`<br>
1. In each of the the config files, add the setting:<br><br>
`chariott_url: "http://0.0.0.0:4243"`<br>
1. In the consumer's config file and the provider's config file, remove the setting for invehicle_digital_twin_url, so that the chariott_url will be used to find the In-vehicle Digital Twin URL.<br>

## <a name="trademarks">Trademarks</a>

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
Expand Down
39 changes: 0 additions & 39 deletions core/in-vehicle-digital-twin/src/main.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,32 @@
# SPDX-License-Identifier: MIT

[package]
name = "in-vehicle-digital-twin"
name = "invehicle-digital-twin"
version = "0.1.0"
edition = "2021"
license = "MIT"

[dependencies]
async-std = { workspace = true, features = ["attributes"] }
config = { workspace = true }
env_logger= { workspace = true }
iref = { workspace = true }
json-ld = { git = "https://github.com/blast-hardcheese/json-ld", branch = "resolve-issue-40" }
log = { workspace = true }
parking_lot = { workspace = true }
prost = { workspace = true }
core-protobuf-data-access = { path = "../protobuf_data_access" }
serde = { workspace = true, features = ["derive"] }
serde_derive = { workspace = true }
serde_json = { workspace = true }
tokio = { workspace = true , features = ["macros", "rt-multi-thread"] }
tonic = { workspace = true }
url = { workspace = true }
yaml-rust = { workspace = true, optional = true }

[build-dependencies]
tonic-build = { workspace = true }
tonic-build = { workspace = true }

[features]
default = ["yaml"]
yaml = ["yaml-rust"]
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ impl DigitalTwinImpl {
{
let mut lock: RwLockWriteGuard<HashMap<String, EntityAccessInfo>> =
self.entity_access_info_map.write();
match lock.get(&entity_access_info.id) {
let get_result = lock.get(&entity_access_info.id);
match get_result {
Some(_) => {
return Err(Status::unimplemented("The in-vehicle digital twin service does not yet support multiple registrations of the same entity."));
}
Expand Down
26 changes: 26 additions & 0 deletions core/invehicle-digital-twin/src/invehicle_digital_twin_config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// SPDX-License-Identifier: MIT

#![cfg(feature = "yaml")]

use config::{Config, File, FileFormat};
use serde_derive::Deserialize;

const CONFIG_FILENAME: &str = "invehicle_digital_twin_settings";

#[derive(Debug, Deserialize)]
pub struct Settings {
pub invehicle_digital_twin_authority: String,
pub chariott_url: Option<String>,
}

/// Load the settings.
pub fn load_settings() -> Settings {
let config =
Config::builder().add_source(File::new(CONFIG_FILENAME, FileFormat::Yaml)).build().unwrap();

let settings: Settings = config.try_deserialize().unwrap();

settings
}
Loading

0 comments on commit fe4a8aa

Please sign in to comment.