Skip to content

Commit

Permalink
Digital Twin Graph
Browse files Browse the repository at this point in the history
  • Loading branch information
ashbeitz committed May 8, 2024
1 parent 07d51b2 commit 0b5b675
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
14 changes: 6 additions & 8 deletions core/module/digital_twin_graph/src/digital_twin_graph_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,14 @@ impl DigitalTwinGraphImpl {
let mut client =
DigitalTwinRegistryClient::connect(self.digital_twin_registry_uri.to_string())
.await
.map_err(|error| format!("{error}"))?;
.map_err(|error| tonic::Status::internal(format!("{error}")))?;

let request =
tonic::Request::new(FindByModelIdRequest { model_id: model_id.to_string() });

client.find_by_model_id(request).await.map_err(|error| error.to_string())
client.find_by_model_id(request).await
})
.await
.map_err(tonic::Status::internal)?
.await?
.into_inner();

Ok(response
Expand Down Expand Up @@ -129,16 +128,15 @@ impl DigitalTwinGraphImpl {
let mut client =
DigitalTwinRegistryClient::connect(self.digital_twin_registry_uri.to_string())
.await
.map_err(|error| format!("{error}"))?;
.map_err(|error| tonic::Status::internal(format!("{error}")))?;

let request = tonic::Request::new(FindByInstanceIdRequest {
instance_id: instance_id.to_string(),
});

client.find_by_instance_id(request).await.map_err(|error| error.to_string())
client.find_by_instance_id(request).await
})
.await
.map_err(tonic::Status::internal)?
.await?
.into_inner();

Ok(response
Expand Down
4 changes: 3 additions & 1 deletion digital-twin-model/src/sdv_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ pub mod basic_airbag_seat_massager {
value = "crate::sdv_v1::basic_airbag_seat_massager::ID.to_string()"
))]
pub model_id: String,
pub sequence_names: crate::sdv_v1::seat_massager::sequence_names::TYPE,
}
}

Expand Down Expand Up @@ -399,6 +400,7 @@ pub mod premium_airbag_seat_massager {
value = "crate::sdv_v1::premium_airbag_seat_massager::ID.to_string()"
))]
pub model_id: String,
pub sequence_names: crate::sdv_v1::seat_massager::sequence_names::TYPE,
}
}

Expand Down Expand Up @@ -459,7 +461,7 @@ pub mod seat_massager {
value = "crate::sdv_v1::seat_massager::sequence_names::ID.to_string()"
))]
pub model_id: String,
pub sequence_names: Vec<String>,
pub value: Vec<String>,
}
}

Expand Down
20 changes: 20 additions & 0 deletions samples/digital_twin_graph/seat_massager_provider/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ fn create_provider_state() -> ProviderState {
let front_left_airbag_seat_massager: sdv::premium_airbag_seat_massager::TYPE =
sdv::premium_airbag_seat_massager::TYPE {
instance_id: front_left_airbag_seat_massager_instance_id.clone(),
sequence_names: sdv::seat_massager::sequence_names::TYPE {
value: Vec::<String>::new(),
..Default::default()
},
..Default::default()
};

Expand All @@ -66,13 +70,21 @@ fn create_provider_state() -> ProviderState {
let front_right_airbag_seat_massager: sdv::premium_airbag_seat_massager::TYPE =
sdv::premium_airbag_seat_massager::TYPE {
instance_id: front_right_airbag_seat_massager_instance_id.clone(),
sequence_names: sdv::seat_massager::sequence_names::TYPE {
value: Vec::<String>::new(),
..Default::default()
},
..Default::default()
};

let back_left_airbag_seat_massager_instance_id = "back_left_airbag_seat_massager".to_string();
let back_left_airbag_seat_massager: sdv::basic_airbag_seat_massager::TYPE =
sdv::basic_airbag_seat_massager::TYPE {
instance_id: back_left_airbag_seat_massager_instance_id.clone(),
sequence_names: sdv::seat_massager::sequence_names::TYPE {
value: Vec::<String>::new(),
..Default::default()
},
..Default::default()
};

Expand All @@ -81,13 +93,21 @@ fn create_provider_state() -> ProviderState {
let back_center_airbag_seat_massager: sdv::basic_airbag_seat_massager::TYPE =
sdv::basic_airbag_seat_massager::TYPE {
instance_id: back_center_airbag_seat_massager_instance_id.clone(),
sequence_names: sdv::seat_massager::sequence_names::TYPE {
value: Vec::<String>::new(),
..Default::default()
},
..Default::default()
};

let back_right_airbag_seat_massager_instance_id = "back_right_airbag_seat_massager".to_string();
let back_right_airbag_seat_massager: sdv::basic_airbag_seat_massager::TYPE =
sdv::basic_airbag_seat_massager::TYPE {
instance_id: back_right_airbag_seat_massager_instance_id.clone(),
sequence_names: sdv::seat_massager::sequence_names::TYPE {
value: Vec::<String>::new(),
..Default::default()
},
..Default::default()
};

Expand Down

0 comments on commit 0b5b675

Please sign in to comment.