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

New demo for dog mode props and cmds #18

Merged
merged 34 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f9a135f
New demo for dog mode props and cmds
ashbeitz Feb 3, 2023
b3be214
New demo for dog mode props and cmds
ashbeitz Feb 4, 2023
e44e4d1
Add command support
ashbeitz Feb 5, 2023
c11ccb6
Add command support
ashbeitz Feb 5, 2023
40cd47a
Add command support
ashbeitz Feb 5, 2023
252db30
New demo for dog mode props and cmds
ashbeitz Feb 5, 2023
c270ea8
New demo for dog mode props and cmds
ashbeitz Feb 5, 2023
beedbbc
New demo for dog mode props and cmds
ashbeitz Feb 6, 2023
a5b7f00
New demo for dog mode props and cmds
ashbeitz Feb 6, 2023
5a10556
New demo for dog mode props and cmds
ashbeitz Feb 6, 2023
b120a72
New demo for dog mode props and cmds
ashbeitz Feb 7, 2023
83da34a
New demo for dog mode props and cmds
ashbeitz Feb 8, 2023
67d9efd
New demo for dog mode props and cmds
ashbeitz Feb 9, 2023
90929cc
New demo for dog mode props and cmds
ashbeitz Feb 10, 2023
e284aa8
New demo for dog mode props and cmds
ashbeitz Feb 10, 2023
591b337
New demo for dog mode props and cmds
ashbeitz Feb 11, 2023
196cf5d
New demo for dog mode props and cmds
ashbeitz Feb 11, 2023
3970f0c
New demo for dog mode props and cmds
ashbeitz Feb 11, 2023
4baf1b5
New demo for dog mode props and cmds
ashbeitz Feb 11, 2023
402ae8c
New demo for dog mode props and cmds
ashbeitz Feb 11, 2023
684e887
New demo for dog mode props and cmds
ashbeitz Feb 14, 2023
3010f40
New demo for dog mode props and cmds
ashbeitz Feb 14, 2023
8f08de5
New demo for dog mode props and cmds
ashbeitz Feb 14, 2023
0f00076
New demo for dog mode props and cmds
ashbeitz Feb 14, 2023
3c6980d
New demo for dog mode props and cmds
ashbeitz Feb 15, 2023
ff3017c
New demo for dog mode props and cmds
ashbeitz Feb 16, 2023
06a3f87
New demo for dog mode props and cmds
ashbeitz Feb 16, 2023
245ba37
New demo for dog mode props and cmds
ashbeitz Feb 16, 2023
bd946ac
New demo for dog mode props and cmds
ashbeitz Feb 16, 2023
2051e04
New demo for dog mode props and cmds
ashbeitz Feb 17, 2023
002dd75
New demo for dog mode props and cmds
ashbeitz Feb 17, 2023
33ec3c9
New demo for dog mode props and cmds
ashbeitz Feb 17, 2023
501374a
New demo for dog mode props and cmds
ashbeitz Feb 17, 2023
1ac4436
New demo for dog mode props and cmds
ashbeitz Feb 17, 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
6 changes: 3 additions & 3 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Install nightly Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
toolchain: nightly-2022-08-11
default: true
override: true
components: clippy, rustfmt
Expand Down Expand Up @@ -61,12 +61,12 @@ jobs:
- name: Install nightly Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
toolchain: nightly-2022-08-11
default: true
override: true
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build
- name: Test
run: cargo test
run: cargo test
24 changes: 23 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,33 @@
members = [
"common",
"common-test",
"dt-model/dt-model-identifiers",
"proto",
"dtdl-parser",
"in-vehicle-digital-twin",
"samples/command/consumer",
"samples/command/provider",
"samples/mixed/consumer",
ashbeitz marked this conversation as resolved.
Show resolved Hide resolved
"samples/mixed/provider",
"samples/property/consumer",
"samples/property/provider"
]
]

[workspace.dependencies]
async-std = "^1.5"
env_logger= "0.10.0"
futures = "0.3"
generic-json = "^0.7"
iref = "^2.0.3"
lazy_static = "1.4.0"
log = "^0.4"
parking_lot = "0.12.1"
prost = "0.11"
regex = " 1.7.1"
tokio = "1.0"
tonic = "0.8.2"
tonic-build = "0.8.2"
serde_json = "^1.0"
strum = "0.24"
strum_macros = "0.24"
uuid = "1.2.2"
48 changes: 39 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ 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
At this point in time, you will need to use a nightly release of Rust. While it is not ideal to rely on a nightly release, we should be able to rely on the
stable release of Rust sometime in the not too distant future when some of the Rust crates that we use can all rely on it as well. To install Rust, do the following:

```shell
sudo apt update
sudo apt install -y snapd
sudo snap install rustup --classic
rustup toolchain install nightly
rustup default nightly
rustup toolchain install nightly-2022-08-11
rustup default nightly-2022-08-11
```

If you have already installed Rust, but you are using another release, then you can switch to the nightly release by running the following commands:
If you have already installed Rust, but you are using another release, then you can switch to the nightly-2022-08-11 release by running the following commands:

```shell
rustup toolchain install nightly
rustup default nightly
rustup toolchain install nightly-2022-08-11
rustup default nightly-2022-08-11
```

### <a name="install-protobuf-compiler">Install Protobuf Compiler</a>
Expand Down Expand Up @@ -102,7 +102,8 @@ 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.
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 following instructions are for the demo for the use of a property.

Expand All @@ -111,7 +112,7 @@ 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.
1. In each window run the following command to 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/property/dtdl"`<br>
1. In each window change directory to the directory containing the build artifacts.
Expand All @@ -132,7 +133,7 @@ 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.
1. In each window run the following command to 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/command/dtdl"`<br>
1. In each window change directory to the directory containing the build artifacts.
Expand All @@ -153,3 +154,32 @@ 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 run the following command to 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/mixed/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>
`./mixed-provider`<br>
1. In the bottom window, run:<br><br>
`./mixed-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.
2 changes: 1 addition & 1 deletion common-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ edition = "2021"
license = "MIT"

[dependencies]
log = "0.4.17"
log = { workspace = true}
4 changes: 2 additions & 2 deletions common-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ pub fn set_dtdl_path() {
"{repo_dir}/opendigitaltwins-dtdl/DTDL;{repo_dir}/iot-plugandplay-models;{repo_dir}/dtdl"
);
env::set_var(DTDL_PATH, &value);
trace!("{}={}", DTDL_PATH, &value);
trace!("{DTDL_PATH}={value}");
} else {
warn!("Unable to set {}, as repo directory could not be determined.", DTDL_PATH);
warn!("Unable to set {DTDL_PATH}, as repo directory could not be determined.");
}
}

Expand Down
14 changes: 14 additions & 0 deletions dt-model/dt-model-identifiers/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.

[package]
name = "dt-model-identifiers"
version = "0.1.0"
edition = "2021"
license = "MIT"

[dependencies]

[lib]
path = "src/lib.rs"
crate-type = ["lib"]
11 changes: 11 additions & 0 deletions dt-model/dt-model-identifiers/src/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.

[package]
name = "model-identifiers"
version = "0.1.0"
edition = "2021"
license = "MIT"

[dependencies]

4 changes: 4 additions & 0 deletions dt-model/dt-model-identifiers/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

pub mod sdv_v1;
36 changes: 36 additions & 0 deletions dt-model/dt-model-identifiers/src/sdv_v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

// Note: In the future this code could be auto-generated from a DTDL spec.

pub mod vehicle {
pub mod cabin {
pub mod hvac {
pub mod ambient_air_temperature {
pub const ID: &str = "dtmi:sdv:Vehicle:Cabin:HVAC:AmbientAirTemperature;1";
}
pub mod is_air_conditioning_active {
pub const ID: &str = "dtmi:sdv:Vehicle:Cabin:HVAC:IsAirConditioningActive;1";
}
}
pub mod infotainment {
pub mod hmi {
pub mod show_notification {
pub const ID: &str =
"dtmi:sdv:Vehicle:Cabin:Infotainment:HMI:ShowNotification;1";
}
}
}
}
pub mod obd {
pub mod hybrid_battery_remaining {
pub const ID: &str = "dtmi:sdv:Vehicle:OBD:HybridBatteryRemaining;1";
}
}
}

pub mod property {
pub mod uri {
pub const ID: &str = "dtmi:sdv:property:uri;1";
}
}
20 changes: 10 additions & 10 deletions dtdl-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ edition = "2021"
license = "MIT"

[dependencies]
async-std = { version = "^1.5", features = ["attributes"] }
async-std = { workspace = true, features = ["attributes"] }
ibeji-common = { path = "../common" }
ibeji-common_test = { path = "../common-test" }
generic-json = { version = "^0.7", features = ["serde_json-impl"] }
iref = "^2.0.3"
futures = { workspace = true }
generic-json = { workspace = true, features = ["serde_json-impl"] }
iref = { workspace = true }
json-ld = { git = "https://github.com/blast-hardcheese/json-ld", branch = "resolve-issue-40" }
# 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.1"
serde_json = "1.0.88"
strum = "0.24"
strum_macros = "0.24"
lazy_static = { workspace = true }
log = { workspace = true }
regex = { workspace = true }
serde_json = { workspace = true }
strum = { workspace = true }
strum_macros = { workspace = true }

[lib]
path = "src/lib.rs"
Expand Down
6 changes: 3 additions & 3 deletions dtdl-parser/src/dtmi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl Dtmi {

let fragment = match iri.fragment() {
Some(fragment) => String::from(fragment.as_str()),
None => String::from(""),
None => String::new(),
ashbeitz marked this conversation as resolved.
Show resolved Hide resolved
};

Ok(Self {
Expand Down Expand Up @@ -152,13 +152,13 @@ impl fmt::Display for Dtmi {
/// * `value` - The IRI to copy from.
pub fn create_dtmi(value: &str) -> Option<Dtmi> {
if !DTMI_REGEX.is_match(value) {
warn!("The value '{}' does not represent a valid DTMI", value);
warn!("The value '{value}' does not represent a valid DTMI");
return None;
}

let new_dtmi_result = Dtmi::new(value);
if let Err(error) = new_dtmi_result {
warn!("{}", error);
warn!("{error}");
return None;
}

Expand Down
Loading