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 8 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
21 changes: 20 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@ members = [
"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"
generic-json = "^0.7"
iref = "^2.0.3"
lazy_static = "1.4.0"
log = "^0.4"
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"
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}
19 changes: 9 additions & 10 deletions dtdl-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ 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"
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
2 changes: 1 addition & 1 deletion 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
6 changes: 0 additions & 6 deletions dtdl-parser/src/model_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ impl ModelParser {

if let Some(entity_kind) = entity_kind_option {
if is_primitive_schema_kind(entity_kind) {
println!("entity_kind is_primitive_entity_kind");
let id: Option<Dtmi> = self.generate_id(parent_id, "test");
if id.is_none() {
return Err(String::from(
Expand All @@ -337,7 +336,6 @@ impl ModelParser {
entity_kind,
)))
} else {
println!("entity_kind is_NOT primitive_entity_kind");
Err(format!("expected a primitive schema, found {entity_kind}"))
}
} else {
Expand Down Expand Up @@ -461,7 +459,6 @@ impl ModelParser {
}

if entity_kind_option.is_none() {
println!("Complex schema has no associated type. It must have one.");
return Err(String::from("Complex schema has no associated type. It must have one."));
}

Expand All @@ -470,7 +467,6 @@ impl ModelParser {
if entity_kind == EntityKind::Object {
self.get_object_schema(node, model_dict, parent_id)
} else {
println!("Unsupported complex object: {entity_kind:?}.");
Err(format!("Unsupported complex object: {entity_kind:?}."))
}
}
Expand Down Expand Up @@ -902,8 +898,6 @@ impl ModelParser {
// name - optional
let name = self.get_property_value(node, "dtmi:dtdl:property:name;2")?;

println!("Command: {}", name.clone().unwrap());

let mut id: Option<Dtmi> = None;
if node.id().is_some() {
id = create_dtmi(node.id().unwrap().as_str());
Expand Down
19 changes: 9 additions & 10 deletions in-vehicle-digital-twin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ edition = "2021"
license = "MIT"

[dependencies]
async-std = { version = "^1.5", features = ["attributes"] }
env_logger= "0.10.0"
async-std = { workspace = true, features = ["attributes"] }
env_logger= { workspace = true }
ibeji-common = { path = "../common" }
ibeji-common_test = { path = "../common-test" }
dtdl-parser = { path = "../dtdl-parser" }
iref = "^2.0.3"
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" }
log = "0.4.17"
prost = "0.11"
log = { workspace = true }
prost = { workspace = true }
proto = { path = "../proto" }
serde_json = "1.0.88"
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
tonic = "0.8.2"
serde_json = { workspace = true }
tokio = { workspace = true , features = ["macros", "rt-multi-thread"] }
tonic = { workspace = true }

[build-dependencies]
tonic-build = "0.8.2"
tonic-build = { workspace = true }
14 changes: 6 additions & 8 deletions in-vehicle-digital-twin/src/digitaltwin_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
extern crate iref;

use dtdl_parser::model_parser::ModelParser;
use log::info;
use log::{debug, info, warn};
use proto::digitaltwin::digital_twin_server::DigitalTwin;
use proto::digitaltwin::{
FindByIdRequest, FindByIdResponse, RegisterRequest, RegisterResponse, UnregisterRequest,
Expand Down Expand Up @@ -74,7 +74,7 @@ impl DigitalTwin for DigitalTwinImpl {
&self,
request: Request<RegisterRequest>,
) -> Result<Response<RegisterResponse>, Status> {
info!("Received a register request.");
debug!("Received a register request.");

let request_inner = request.into_inner();
let dtdl = request_inner.dtdl;
Expand All @@ -86,7 +86,7 @@ impl DigitalTwin for DigitalTwinImpl {

let response = RegisterResponse {};

info!("Completed registration.");
debug!("Completed registration.");

Ok(Response::new(response))
}
Expand All @@ -99,11 +99,9 @@ impl DigitalTwin for DigitalTwinImpl {
&self,
request: Request<UnregisterRequest>,
) -> Result<Response<UnregisterResponse>, Status> {
info!("Received an unregister request: {:?}", request);
// TODO - provide unregister functionality
let response = UnregisterResponse {};
warn!("Got an unregister request: {request:?}");

Ok(Response::new(response))
Err(Status::unimplemented("unregister has not been implemented"))
}
}

Expand Down Expand Up @@ -155,7 +153,7 @@ impl DigitalTwinImpl {
for (id, _entity) in model_dict {
let mut lock: MutexGuard<HashMap<String, Value>> = self.entity_map.lock().unwrap();
lock.insert(id.to_string(), doc.clone());
info!("Registered DTDL for id {}", &id);
debug!("Registered DTDL for id {}", &id);
}

Ok(())
Expand Down
32 changes: 11 additions & 21 deletions in-vehicle-digital-twin/src/provider_impl.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

use log::info;
use log::warn;
use proto::provider::provider_server::Provider;
use proto::provider::{
GetRequest, GetResponse, InvokeRequest, InvokeResponse, SetRequest, SetResponse,
Expand All @@ -22,11 +22,9 @@ impl Provider for ProviderImpl {
&self,
request: Request<SubscribeRequest>,
) -> Result<Response<SubscribeResponse>, Status> {
info!("Got a subscribe request: {:?}", request);
// TODO - provide subscribe functionality
let response = SubscribeResponse {};
warn!("Got a subscribe request: {request:?}");

Ok(Response::new(response))
Err(Status::unimplemented("subscribe has not been implemented"))
}

/// Unsubscribe implementation.
Expand All @@ -37,35 +35,29 @@ impl Provider for ProviderImpl {
&self,
request: Request<UnsubscribeRequest>,
) -> Result<Response<UnsubscribeResponse>, Status> {
info!("Got an unsubscribe request: {:?}", request);
// TODO - provide unsubscribe functionality
let response = UnsubscribeResponse {};
warn!("Got an unsubscribe request: {request:?}");

Ok(Response::new(response))
Err(Status::unimplemented("unsubscribe has not been implemented"))
ashbeitz marked this conversation as resolved.
Show resolved Hide resolved
}

/// Get implementation.
///
/// # Arguments
/// * `request` - Get request.
async fn get(&self, request: Request<GetRequest>) -> Result<Response<GetResponse>, Status> {
info!("Got a get request: {:?}", request);
// TODO - provide get functionality
let response = GetResponse {};
warn!("Got a get request: {request:?}");

Ok(Response::new(response))
Err(Status::unimplemented("get has not been implemented"))
}

/// Set implementation.
///
/// # Arguments
/// * `request` - Set request.
async fn set(&self, request: Request<SetRequest>) -> Result<Response<SetResponse>, Status> {
info!("Got a set request: {:?}", request);
// TODO - provide set functionality
let response = SetResponse {};
warn!("Got a set request: {request:?}");

Ok(Response::new(response))
Err(Status::unimplemented("set has not been implemented"))
}

/// Invoke implementation.
Expand All @@ -76,10 +68,8 @@ impl Provider for ProviderImpl {
&self,
request: Request<InvokeRequest>,
) -> Result<Response<InvokeResponse>, Status> {
info!("Got an invoke request: {:?}", request);
// TODO - provide set functionality
let response = InvokeResponse {};
warn!("Got an invoke request: {request:?}");

Ok(Response::new(response))
Err(Status::unimplemented("invoke has not been implemented"))
}
}
8 changes: 4 additions & 4 deletions proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ edition = "2021"
license = "MIT"

[dependencies]
tonic = "0.8.2"
prost = "0.11"
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
tonic = { workspace = true }
prost = { workspace = true }
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }

[build-dependencies]
tonic-build = "0.8.2"
tonic-build = { workspace = true }
29 changes: 10 additions & 19 deletions samples/command/consumer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,18 @@ edition = "2021"
license = "MIT"

[dependencies]
async-std = { version = "^1.5", features = ["attributes"] }
async-std = { workspace = true, features = ["attributes"] }
dtdl-parser = { path = "../../../dtdl-parser" }
env_logger= "0.10.0"
iref = "^2.0.3"
env_logger= { workspace = true }
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" }

log = "0.4.17"
prost = "0.11"
log = { workspace = true }
prost = { workspace = true }
proto = { path = "../../../proto" }
serde_json = "1.0.88"
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
tonic = "0.8.2"

[dependencies.uuid]
version = "1.2.2"
features = [
"v4", # Lets you generate random UUIDs
"fast-rng", # Use a faster (but still sufficiently random) RNG
"macro-diagnostics", # Enable better diagnostics for compile-time UUIDs
]
serde_json = { workspace = true }
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
tonic = { workspace = true }
uuid = { workspace = true, features = ["v4", "fast-rng", "macro-diagnostics"] }

[build-dependencies]
tonic-build = "0.8.2"
tonic-build = { workspace = true }
9 changes: 3 additions & 6 deletions samples/command/consumer/src/consumer_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl Consumer for ConsumerImpl {
&self,
request: Request<PublishRequest>,
) -> Result<Response<PublishResponse>, Status> {
warn!("Got a publish request: {:?}", request);
warn!("Got a publish request: {request:?}");

Err(Status::unimplemented("publish has not been implemented"))
}
Expand All @@ -32,12 +32,9 @@ impl Consumer for ConsumerImpl {
&self,
request: Request<RespondRequest>,
) -> Result<Response<RespondResponse>, Status> {
let request_inner = request.into_inner();
let RespondRequest { entity_id, response_id, payload } = request.into_inner();

info!(
"Received a respond for entity id {} with the response id {} and the payload '{}'",
request_inner.entity_id, request_inner.response_id, request_inner.payload
);
info!("Received a respond for entity id {entity_id} with the response id {response_id} and the payload '{payload}'");

let response = RespondResponse {};

Expand Down
3 changes: 2 additions & 1 deletion samples/command/consumer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ use tonic::transport::Server;
use uuid::Uuid;

/// The id for send notification command.
const SEND_NOTIFICATION_COMMAND_ID: &str = "dtmi:org:eclipse:sdv:command:HVAC:send_notification;1";
const SEND_NOTIFICATION_COMMAND_ID: &str =
"dtmi:org:eclipse:sdv:vehicle:cabin:hvac:send_notification;1";

/// The id for the URI property.
const URI_PROPERTY_ID: &str = "dtmi:sdv:property:uri;1";
Expand Down
7 changes: 4 additions & 3 deletions samples/command/dtdl/content/send_notification.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
{
"@context": ["dtmi:dtdl:context;2", "dtmi:sdv:context;2"],
"@type": "Interface",
"@id": "dtmi:org:eclipse:sdv:interface:HVAC:send_notification;1",
"@id": "dtmi:org:eclipse:sdv:vehicle:cabin:hvac;1",
"description": "Heat, Ventilation and Air Conditioning",
"contents": [
{
"@type": ["Command", "RemotelyAccessible"],
"@id": "dtmi:org:eclipse:sdv:command:HVAC:send_notification;1",
"name": "HVAC_send_notification",
"@id": "dtmi:org:eclipse:sdv:vehicle:cabin:hvac:send_notification;1",
"name": "send_notification",
"request": {
"name": "send_notification",
"displayName": "send_notification",
Expand Down
Loading