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/make protocol and interface agnostic initial solution #26

Merged
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
80e0924
Make protocol agnostic
ashbeitz May 1, 2023
4dcbecb
Make protocol agnostic
ashbeitz May 6, 2023
2e245fd
Make protocol agnostic
ashbeitz May 8, 2023
ecacf09
Make protocol agnostic
ashbeitz May 8, 2023
98b87f5
Make protocol agnostic
ashbeitz May 8, 2023
34f0401
Make protocol agnostic
ashbeitz May 9, 2023
455ca81
Make protocol agnostic
ashbeitz May 9, 2023
a8cd160
Make protocol agnostic
ashbeitz May 9, 2023
d3d15a1
Make protocol agnostic
ashbeitz May 9, 2023
2b52f92
Make protocol agnostic
ashbeitz May 9, 2023
89a263f
Make protocol agnostic
ashbeitz May 9, 2023
ce0e66e
Make protocol agnostic
ashbeitz May 9, 2023
7ec3a34
Make protocol agnostic
ashbeitz May 9, 2023
b2b2c5f
Make protocol agnostic
ashbeitz May 9, 2023
8c33e7b
Make protocol agnostic
ashbeitz May 10, 2023
15d84ca
Make protocol agnostic
ashbeitz May 10, 2023
28d926d
Make protocol agnostic
ashbeitz May 10, 2023
9147330
Make protocol agnostic
ashbeitz May 11, 2023
531fc31
Make protocol agnostic
ashbeitz May 11, 2023
a9dacf3
Make protocol agnostic
ashbeitz May 11, 2023
9b15078
Make protocol agnostic
ashbeitz May 11, 2023
5787bc0
Make protocol agnostic
ashbeitz May 11, 2023
c91519f
Make protocol agnostic
ashbeitz May 12, 2023
d879f54
Make protocol agnostic
ashbeitz May 12, 2023
5218640
Make protocol agnostic
ashbeitz May 12, 2023
3367865
Make protocol agnostic
ashbeitz May 12, 2023
c62ff4c
Make protocol agnostic
ashbeitz May 12, 2023
3a2b249
Make protocol agnostic
ashbeitz May 12, 2023
207099d
Make protocol agnostic
ashbeitz May 12, 2023
ef41511
Make protocol agnostic
ashbeitz May 12, 2023
88ba944
Make protocol agnostic
ashbeitz May 12, 2023
fad560b
Make protocol agnostic
ashbeitz May 15, 2023
b94a898
Make protocol agnostic
ashbeitz May 15, 2023
737fa67
Make protocol agnostic
ashbeitz May 15, 2023
b171c8a
Make protocol agnostic
ashbeitz May 15, 2023
8c5202f
Make protocol agnostic
ashbeitz May 15, 2023
31f143f
Make protocol agnostic
ashbeitz May 15, 2023
e23563e
Make protocol agnostic
ashbeitz May 15, 2023
5b5e364
Render PlantUML files
github-actions[bot] May 15, 2023
687bc6e
Make protocol agnostic
ashbeitz May 15, 2023
11d04ea
Make protocol agnostic
ashbeitz May 15, 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
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
members = [
"common",
"common-test",
"dt-model/dt-model-identifiers",
"proto",
"digital-twin-model",
"dtdl-parser",
"in-vehicle-digital-twin",
"samples/proto",
"samples/command/consumer",
"samples/command/provider",
"samples/mixed/consumer",
Expand All @@ -29,10 +29,11 @@ lazy_static = "1.4.0"
log = "^0.4"
parking_lot = "0.12.1"
prost = "0.11"
regex = " 1.7.1"
regex = " 1.8.1"
tokio = "1.0"
tonic = "0.8.2"
tonic-build = "0.8.2"
tonic = "0.9.2"
tonic-build = "0.9.2"
serde = "1.0.160"
serde_json = "^1.0"
strum = "0.24"
strum_macros = "0.24"
Expand Down
4 changes: 2 additions & 2 deletions common-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn set_dtdl_path() {
let repo_dir_result = get_repo_dir();
if let Some(repo_dir) = repo_dir_result {
let value = format!(
"{repo_dir}/opendigitaltwins-dtdl/DTDL;{repo_dir}/iot-plugandplay-models;{repo_dir}/dtdl"
"{repo_dir}/opendigitaltwins-dtdl/DTDL;{repo_dir}/iot-plugandplay-models;{repo_dir}/dtdl;{repo_dir}/digital-twin-model/dtdl"
);
env::set_var(DTDL_PATH, &value);
trace!("{DTDL_PATH}={value}");
Expand All @@ -56,7 +56,7 @@ mod ibeji_common_test_tests {
assert!(get_dtdl_path_result.is_ok());
let dtdl_path = get_dtdl_path_result.unwrap();
assert!(!dtdl_path.is_empty());
assert!(dtdl_path.contains("/opendigitaltwins-dtdl/DTDL;"));
assert!(dtdl_path.contains("/opendigitaltwins-dtdl/DTDL"));
assert!(dtdl_path.contains("/dtdl"));
}
}
4 changes: 2 additions & 2 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ mod ibeji_common_tests {
fn find_full_path_test() {
set_dtdl_path();

let find_full_path_result = find_full_path("samples/remotely_accessible_resource.json");
ashbeitz marked this conversation as resolved.
Show resolved Hide resolved
let find_full_path_result = find_full_path("v2/content/sdv/vehicle.json");
assert!(find_full_path_result.is_ok());
let full_path = find_full_path_result.unwrap();
assert!(full_path.ends_with("/samples/remotely_accessible_resource.json"));
assert!(full_path.ends_with("/v2/content/sdv/vehicle.json"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: MIT

[package]
name = "dt-model-identifiers"
name = "digital-twin-model"
version = "0.1.0"
edition = "2021"
license = "MIT"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,87 +1,59 @@
[
{
"@context": ["dtmi:dtdl:context;2", "dtmi:sdv:context;2"],
"@context": ["dtmi:dtdl:context;2"],
"@type": "Interface",
"@id": "dtmi:sdv:Vehicle:Cabin:HVAC;1",
"description": "Heat, Ventilation and Air Conditioning",
"contents": [
{
"@type": ["Property", "Temperature", "RemotelyAccessible"],
"@type": ["Property", "Temperature"],
"@id": "dtmi:sdv:Vehicle:Cabin:HVAC:AmbientAirTemperature;1",
"name": "AmbientAirTemperature",
"description": "The immediate surroundings air temperature (in Fahrenheit).",
"schema": "integer",
"unit": "degreeFahrenheit",
"remote_access": [
{
"@type": "Endpoint",
"uri": "http://[::1]:40010",
"operations": [ "Subscribe", "Unsubscribe" ]
}
]
"unit": "degreeFahrenheit"
},
{
"@type": ["Property", "RemotelyAccessible"],
"@type": ["Property"],
"@id": "dtmi:sdv:Vehicle:Cabin:HVAC:IsAirConditioningActive;1",
"name": "IsAirConditioningActive",
"description": "Is air conditioning active?",
"schema": "boolean",
"remote_access": [
{
"@type": "Endpoint",
"uri": "http://[::1]:40010",
"operations": [ "Set", "Subscribe", "Unsubscribe" ]
}
]
"schema": "boolean"
}
]
},
{
"@context": ["dtmi:dtdl:context;2", "dtmi:sdv:context;2"],
"@context": ["dtmi:dtdl:context;2"],
"@type": "Interface",
"@id": "dtmi:sdv:Vehicle:OBD;1",
"description": "On-board Diagnostics Interface",
"contents": [
{
"@type": ["Property", "RemotelyAccessible"],
"@type": ["Property"],
"@id": "dtmi:sdv:Vehicle:OBD:HybridBatteryRemaining;1",
"name": "HybridBatteryRemaining",
"description": "The remaining hybrid battery life.",
"schema": "integer",
"unit": "percent",
"remote_access": [
{
"@type": "Endpoint",
"uri": "http://[::1]:40010",
"operations": [ "Subscribe", "Unsubscribe" ]
}
]
"unit": "percent"
}
]
},
{
"@context": ["dtmi:dtdl:context;2", "dtmi:sdv:context;2"],
"@context": ["dtmi:dtdl:context;2"],
"@type": "Interface",
"@id": "dtmi:sdv:Vehicle:Cabin:Infotainment:HMI;1",
"description": "The Human Machine Interface.",
"contents": [
{
"@type": ["Command", "RemotelyAccessible"],
"@type": ["Command"],
"@id": "dtmi:sdv:Vehicle:Cabin:Infotainment:HMI:ShowNotification;1",
"name": "ShowNotification",
"request": {
"name": "ShowNotification",
"displayName": "Show Notification",
"descriptiption": "Show a notification on the HMI.",
"schema": "string"
},
"remote_access": [
{
"@type": "Endpoint",
"uri": "http://[::1]:40010",
"operations": [ "Invoke" ]
}
]
}
}
]
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,3 @@ pub mod vehicle {
}
}
}

pub mod property {
pub mod uri {
pub const ID: &str = "dtmi:sdv:property:uri;1";
}
}
12 changes: 0 additions & 12 deletions dt-model/dt-model-identifiers/src/Cargo.toml

This file was deleted.

61 changes: 21 additions & 40 deletions dtdl-parser/src/model_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,6 @@ impl ModelParser {
let dtdl_2_context_value = self.retrieve_context(dtdl_2_context_path)?;
self.replace_context_inline_in_doc(doc, "dtmi:dtdl:context;2", &dtdl_2_context_value)?;

let sdv_2_context_path_string = find_full_path("v2/context/SDV.v2.context.json")?;
let sdv_2_context_path_string_unwrapped = sdv_2_context_path_string;
let sdv_2_context_path = Path::new(&sdv_2_context_path_string_unwrapped);
let sdv_2_context_value = self.retrieve_context(sdv_2_context_path)?;
self.replace_context_inline_in_doc(doc, "dtmi:sdv:context;2", &sdv_2_context_value)?;

Ok(())
}

Expand Down Expand Up @@ -1101,16 +1095,16 @@ mod model_parser_tests {

#[rustfmt::skip]
#[test]
fn demo_validation_test() {
fn sdv_vehicle_validation_test() {
ashbeitz marked this conversation as resolved.
Show resolved Hide resolved
set_dtdl_path();

let mut json_texts = Vec::<String>::new();

let demo_path_result = find_full_path("samples/demo_resources.json");
assert!(demo_path_result.is_ok());
let demo_contents_result = retrieve_dtdl(&demo_path_result.unwrap());
assert!(demo_contents_result.is_ok());
json_texts.push(demo_contents_result.unwrap());
let vehicle_path_result = find_full_path("v2/content/sdv/vehicle.json");
assert!(vehicle_path_result.is_ok());
let vehicle_contents_result = retrieve_dtdl(&vehicle_path_result.unwrap());
assert!(vehicle_contents_result.is_ok());
json_texts.push(vehicle_contents_result.unwrap());

let mut parser = ModelParser::new();
let model_dict_result = parser.parse(&json_texts);
Expand All @@ -1120,39 +1114,26 @@ mod model_parser_tests {
model_dict_result.err().unwrap()
);
let model_dict = model_dict_result.unwrap();
assert!(
model_dict.len() == 13,
"expected length was 13, actual length is {}",
model_dict.len()
);

let ambient_air_temperature_id: Option<Dtmi> = create_dtmi("dtmi:sdv:Vehicle:Cabin:HVAC:AmbientAirTemperature;1");
assert!(ambient_air_temperature_id.is_some());
let ambient_air_temperature_entity_result =
model_dict.get(&ambient_air_temperature_id.unwrap());
assert!(ambient_air_temperature_entity_result.is_some());
let ambient_air_temperature_uri_property_result = ambient_air_temperature_entity_result
.unwrap()
.undefined_properties()
.get("dtmi:sdv:property:uri;1");
assert!(ambient_air_temperature_uri_property_result.is_some());
let ambient_air_temperature_uri_property_value_result =
ambient_air_temperature_uri_property_result.unwrap().get("@value");
assert!(ambient_air_temperature_uri_property_value_result.is_some());
assert!(ambient_air_temperature_uri_property_value_result.unwrap() == "http://[::1]:40010"); // Devskim: ignore DS137138

let send_notification_id: Option<Dtmi> = create_dtmi("dtmi:sdv:Vehicle:Cabin:HVAC:SendNotification;1");
assert!(send_notification_id.is_some());
let send_notification_entity_result = model_dict.get(&send_notification_id.unwrap());
assert!(send_notification_entity_result.is_some());
let send_notification_uri_property_result = send_notification_entity_result
.unwrap()
.undefined_properties()
.get("dtmi:sdv:property:uri;1");
assert!(send_notification_uri_property_result.is_some());
let send_notification_uri_property_value_result =
send_notification_uri_property_result.unwrap().get("@value");
assert!(send_notification_uri_property_value_result.is_some());
assert!(send_notification_uri_property_value_result.unwrap() == "http://[::1]:40010"); // Devskim: ignore DS137138

let is_air_conditioning_active_id: Option<Dtmi> = create_dtmi("dtmi:sdv:Vehicle:Cabin:HVAC:IsAirConditioningActive;1");
assert!(is_air_conditioning_active_id.is_some());
let is_air_conditioning_active_entity_result = model_dict.get(&is_air_conditioning_active_id.unwrap());
assert!(is_air_conditioning_active_entity_result.is_some());

let hybrid_battery_remaining_id: Option<Dtmi> = create_dtmi("dtmi:sdv:Vehicle:OBD:HybridBatteryRemaining;1");
assert!(hybrid_battery_remaining_id.is_some());
let hybrid_battery_remaining_entity_result = model_dict.get(&hybrid_battery_remaining_id.unwrap());
assert!(hybrid_battery_remaining_entity_result.is_some());

let show_notification_id: Option<Dtmi> = create_dtmi("dtmi:sdv:Vehicle:Cabin:Infotainment:HMI:ShowNotification;1");
assert!(show_notification_id.is_some());
let show_notification_entity_result = model_dict.get(&show_notification_id.unwrap());
assert!(show_notification_entity_result.is_some());
}
}
22 changes: 0 additions & 22 deletions dtdl/samples/remotely_accessible_resource.json

This file was deleted.

13 changes: 0 additions & 13 deletions dtdl/v2/context/SDV.v2.context.json

This file was deleted.

Loading