Skip to content

Commit

Permalink
Improved seat massager sample
Browse files Browse the repository at this point in the history
  • Loading branch information
ashbeitz committed Feb 27, 2024
1 parent 7185b81 commit 3d752d6
Show file tree
Hide file tree
Showing 20 changed files with 133 additions and 149 deletions.
12 changes: 6 additions & 6 deletions digital-twin-model/dtdl/dtmi/sdv/airbag_seat_massager-1.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"@context": ["dtmi:dtdl:context;3"],
"@type": "Interface",
{
"@context": ["dtmi:dtdl:context;3"],
"@type": "Interface",
"@id": "dtmi:sdv:airbag_seat_massager;1",
"description": "Airbag Seat Massager Interface",
"description": "Airbag Seat Massager Interface",
"extends": "dtmi:sdv:seat_massager;1",
"contents": [
{
Expand Down Expand Up @@ -36,7 +36,7 @@
},
{
"@type": "Command",
"@id": "dtmi:sdv:airbag_seat_massager:perform_step;1",
"@id": "dtmi:sdv:airbag_seat_massager:perform_step;1",
"name": "perfom_step",
"request": {
"name": "request",
Expand Down Expand Up @@ -113,4 +113,4 @@
]
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"@context": ["dtmi:dtdl:context;3"],
"@type": "Interface",
"@id": "dtmi:sdv:basic_airbag_seat_massager;1",
"description": "Basic Airbag Seat Massager Interface",
{
"@context": ["dtmi:dtdl:context;3"],
"@type": "Interface",
"@id": "dtmi:sdv:basic_airbag_seat_massager;1",
"description": "Basic Airbag Seat Massager Interface",
"extends": "dtmi:sdv:airbag_seat_massager;1"
}
}
26 changes: 13 additions & 13 deletions digital-twin-model/dtdl/dtmi/sdv/cabin-1.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"@context": ["dtmi:dtdl:context;3"],
"@type": "Interface",
"@id": "dtmi:sdv:cabin;1",
"description": "Cabin Interface",
"contents": [
{
"@type": "Relationship",
"@id": "dtmi:sdv:cabin:has_infotainment;1",
{
"@context": ["dtmi:dtdl:context;3"],
"@type": "Interface",
"@id": "dtmi:sdv:cabin;1",
"description": "Cabin Interface",
"contents": [
{
"@type": "Relationship",
"@id": "dtmi:sdv:cabin:has_infotainment;1",
"target": "dtmi:sdv:infotainment;1",
"name": "has_infotainment",
"maxMultiplicity": 1
Expand All @@ -17,10 +17,10 @@
"target": "dtmi:sdv:hvac;1",
"name": "has_hvac",
"maxMultiplicity": 1
},
},
{
"@type": "Relationship",
"@id": "dtmi:sdv:cabin:has_seat;1",
"@id": "dtmi:sdv:cabin:has_seat;1",
"name": "has_seat",
"target": "dtmi:sdv:seat;1",
"properties": [
Expand Down Expand Up @@ -57,6 +57,6 @@
}
}
]
}
}
]
}
}
24 changes: 12 additions & 12 deletions digital-twin-model/dtdl/dtmi/sdv/infotainment-1.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"@context": ["dtmi:dtdl:context;3"],
"@type": "Interface",
"@id": "dtmi:sdv:infotainment;1",
"description": "Infotainment Interface",
"contents": [
{
"@type": "Relationship",
"@id": "dtmi:sdv:infotainment:has_hmi;1",
"target": "dtmi:sdv:hmi;1",
{
"@context": ["dtmi:dtdl:context;3"],
"@type": "Interface",
"@id": "dtmi:sdv:infotainment;1",
"description": "Infotainment Interface",
"contents": [
{
"@type": "Relationship",
"@id": "dtmi:sdv:infotainment:has_hmi;1",
"target": "dtmi:sdv:hmi;1",
"name": "has_hmi",
"maxMultiplicity": 1
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"@context": ["dtmi:dtdl:context;3"],
"@type": "Interface",
"@id": "dtmi:sdv:premium_airbag_seat_massager;1",
"description": "Premium Airbag Seat Massager Interface",
{
"@context": ["dtmi:dtdl:context;3"],
"@type": "Interface",
"@id": "dtmi:sdv:premium_airbag_seat_massager;1",
"description": "Premium Airbag Seat Massager Interface",
"extends": "dtmi:sdv:airbag_seat_massager;1"
}
}
10 changes: 5 additions & 5 deletions digital-twin-model/dtdl/dtmi/sdv/seat-1.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"@context": ["dtmi:dtdl:context;3"],
"@type": "Interface",
"@id": "dtmi:sdv:seat;1",
{
"@context": ["dtmi:dtdl:context;3"],
"@type": "Interface",
"@id": "dtmi:sdv:seat;1",
"description": "Seat Interface"
}
}
14 changes: 7 additions & 7 deletions digital-twin-model/dtdl/dtmi/sdv/seat_massager-1.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"@context": ["dtmi:dtdl:context;3"],
"@type": "Interface",
"@id": "dtmi:sdv:seat_massager;1",
{
"@context": ["dtmi:dtdl:context;3"],
"@type": "Interface",
"@id": "dtmi:sdv:seat_massager;1",
"description": "Seat Massager Interface",
"contents": [
{
"@type": "Property",
"name": "sequence_names",
"@id": "dtmi:sdv:seat_massager:sequence_names;1",
"@id": "dtmi:sdv:seat_massager:sequence_names;1",
"description": "The name of each of the stored sequences.",
"schema": {
"@type": "Array",
Expand Down Expand Up @@ -40,7 +40,7 @@
}
]
}
}
}
},
{
"@type": "Command",
Expand Down Expand Up @@ -107,4 +107,4 @@
]
}
]
}
}
22 changes: 11 additions & 11 deletions digital-twin-model/dtdl/dtmi/sdv/seat_with_massager-1.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"@context": ["dtmi:dtdl:context;3"],
"@type": "Interface",
"@id": "dtmi:sdv:seat_with_massager;1",
"description": "Seat with Massager Interface",
{
"@context": ["dtmi:dtdl:context;3"],
"@type": "Interface",
"@id": "dtmi:sdv:seat_with_massager;1",
"description": "Seat with Massager Interface",
"extends": "dtmi:sdv:seat;1",
"contents": [
{
"contents": [
{
"@type": "Relationship",
"@id": "dtmi:sdv:seat_with_massager:has_seat_massager;1",
"target": "dtmi:sdv:seatmassager;1",
"target": "dtmi:sdv:seatmassager;1",
"name": "has_seat_massager",
"maxMultiplicity": 1
}
]
}
}
]
}
16 changes: 8 additions & 8 deletions digital-twin-model/src/sdv_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub mod hvac {

pub mod obd {
pub const ID: &str = "dtmi:sdv:obd;1";
pub const DESCRIPTION: &str = "On-board Diagnostics Interface";
pub const DESCRIPTION: &str = "On-board Diagnostics Interface";
pub mod hybrid_battery_remaining {
pub const ID: &str = "dtmi:sdv:obd:hybrid_battery_remaining;1";
pub const NAME: &str = "hybrid_battery_remaining";
Expand All @@ -65,7 +65,7 @@ pub mod obd {

pub mod seat_massager {
pub const ID: &str = "dtmi:sdv:seatmassager;1";
pub const DESCRIPTION: &str = "Seat Massager Interface";
pub const DESCRIPTION: &str = "Seat Massager Interface";
pub mod sequence_names {
pub const ID: &str = "dtmi:sdv:massage_seat:sequence_names;1";
pub const NAME: &str = "sequence_names";
Expand All @@ -76,18 +76,18 @@ pub mod seat_massager {

pub mod basic_airbag_seat_massager {
pub const ID: &str = "dtmi:sdv:basic_airbag_seat_massager;1";
pub const DESCRIPTION: &str = "Basic Airbag Seat Massager Interface";
pub const DESCRIPTION: &str = "Basic Airbag Seat Massager Interface";
}

pub mod premium_airbag_seat_massager {
pub const ID: &str = "dtmi:sdv:premium_airbag_seat_massager;1";
pub const DESCRIPTION: &str = "Premium Airbag Seat Massager Interface";
pub const DESCRIPTION: &str = "Premium Airbag Seat Massager Interface";
}

#[allow(dead_code)]
pub mod airbag_seat_massager {
pub const ID: &str = "dtmi:sdv:airbag_seat_massager;1";
pub const DESCRIPTION: &str = "Airbag Seat Massager Interface";
pub const DESCRIPTION: &str = "Airbag Seat Massager Interface";
pub mod perform_step {
pub const ID: &str = "dtmi:sdv:airbag_seat_massager:perform_step;1";
pub const NAME: &str = "perform_step";
Expand Down Expand Up @@ -120,7 +120,7 @@ pub mod airbag_seat_massager {
pub airbag_identifier: i32,
pub inflation_level: i32
}
}
}
pub mod airbag_adjustments {
pub const ID: &str = "dtmi:sdv:airbag_seat_massager:airbag_adjustments;1";
pub const NAME: &str = "airbag_adjustments";
Expand All @@ -142,12 +142,12 @@ pub mod airbag_seat_massager {
pub code: i32,
pub message: String
}
}
}
}

pub mod seat {
pub const ID: &str = "dtmi:sdv:seat;1";
pub const DESCRIPTION: &str = "Seat Interface";
pub const DESCRIPTION: &str = "Seat Interface";
}

pub mod cabin {
Expand Down
12 changes: 3 additions & 9 deletions dtdl-tools/src/dtdl-validator/DtdlValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,9 @@ static int ValidateDtdl(DirectoryInfo directory, String extension)
foreach (var file in files)
{
try
{
{
string dtmi = ConvertToDTMI(file, directory.FullName, extension);
Console.WriteLine("DTMI = {0}", dtmi);

// var dtdl = File.ReadAllText(file);
// parser.ParseAsync(dtdl).GetAwaiter().GetResult();
var model = dmrClient.GetModelAsync(dtmi).GetAwaiter().GetResult();
Console.WriteLine("For {0} the model cardinality is {1}", dtmi, model.Content.Count);
// Console.WriteLine("Content = {0}", model.Content[dtmi]);
var dictParsed = parser.ParseAsync(model.Content[dtmi]).GetAwaiter().GetResult();
Console.WriteLine($"{file} - ok");
}
Expand All @@ -91,13 +85,13 @@ static int ValidateDtdl(DirectoryInfo directory, String extension)
Console.WriteLine($"{file} - failed");
Console.WriteLine($" {ex.ToString()}");
failureOccured = true;
}
}
catch (Exception ex)
{
Console.WriteLine($"{file} - failed");
Console.WriteLine($" {ex.ToString()}");
failureOccured = true;
}
}
}

if (failureOccured)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ public static async IAsyncEnumerable<string> ParserDtmiResolverAsync(
this ModelsRepositoryClient client, IReadOnlyCollection<Dtmi> dtmis,
[EnumeratorCancellation] CancellationToken ct = default)
{
Console.WriteLine("HERE");
foreach (var dtmi in dtmis.Select(s => s.AbsoluteUri))
{
Console.WriteLine($"DTMI >>> {dtmi}");
var result = await client.GetModelAsync(dtmi, ModelDependencyResolution.Disabled, ct);
Console.WriteLine("DTMI <<<");
yield return result.Content[dtmi];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ syntax = "proto3";

import "common.proto";

package async_rpc.v1.requestor;
package async_rpc.v1.request;

service Requestor {
service Request {
rpc Ask (AskRequest) returns (AskResponse);
rpc Notify (NotifyRequest) returns (NotifyResponse);
rpc Notify (NotifyRequest) returns (NotifyResponse);
}

message AskRequest {
string responder_uri = 1;
string respond_uri = 1;
string request_id = 2;
string payload = 3;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ syntax = "proto3";

import "common.proto";

package async_rpc.v1.responder;
package async_rpc.v1.respond;

service Responder {
service Respond {
rpc Answer (AnswerRequest) returns (AnswerResponse);
}

Expand Down
4 changes: 2 additions & 2 deletions samples/protobuf_data_access/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::compile_protos("../interfaces/sample_grpc/v1/digital_twin_consumer.proto")?;
tonic_build::compile_protos("../interfaces/sample_grpc/v1/digital_twin_provider.proto")?;
tonic_build::compile_protos("../interfaces/async_rpc/v1/common.proto")?;
tonic_build::compile_protos("../interfaces/async_rpc/v1/responder.proto")?;
tonic_build::compile_protos("../interfaces/async_rpc/v1/requestor.proto")?;
tonic_build::compile_protos("../interfaces/async_rpc/v1/respond.proto")?;
tonic_build::compile_protos("../interfaces/async_rpc/v1/request.proto")?;
tonic_build::configure()
.message_attribute("EndpointInfo", "#[derive(serde::Deserialize, serde::Serialize)]")
.message_attribute("EntityAccessInfo", "#[derive(serde::Deserialize, serde::Serialize)]")
Expand Down
8 changes: 4 additions & 4 deletions samples/protobuf_data_access/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ pub mod async_rpc {
tonic::include_proto!("async_rpc.v1.common");
}

pub mod responder {
tonic::include_proto!("async_rpc.v1.responder");
pub mod respond {
tonic::include_proto!("async_rpc.v1.respond");
}

pub mod requestor {
tonic::include_proto!("async_rpc.v1.requestor");
pub mod request {
tonic::include_proto!("async_rpc.v1.request");
}
}
}
1 change: 1 addition & 0 deletions samples/seat_massager/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ pub struct TargetedPayload {
#[serde(rename = "@id")]
pub instance_id: String,
pub member_name: String,
pub operation: String,
pub payload: String
}
Loading

0 comments on commit 3d752d6

Please sign in to comment.