Skip to content

Commit 07d51b2

Browse files
committed
Digital Twin Graph
1 parent 7e637c3 commit 07d51b2

File tree

1 file changed

+29
-45
lines changed

1 file changed

+29
-45
lines changed

core/module/digital_twin_graph/src/digital_twin_graph_impl.rs

+29-45
Original file line numberDiff line numberDiff line change
@@ -158,27 +158,14 @@ impl DigitalTwinGraphImpl {
158158
/// * `client` - The client to use to send the ask.
159159
/// * `respond_uri` - The respond uri.
160160
/// * `ask_id` - The ask id.
161-
/// * `instance_id` - The instance id.
162-
/// * `member_path` - The member path.
163-
/// * `operation` - The operation.
164-
/// * `payload` - The payload.
161+
/// * `targeted_payload` - The targeted payload.
165162
pub async fn send_ask(
166163
&self,
167164
mut client: RequestClient<tonic::transport::Channel>,
168165
respond_uri: &str,
169166
ask_id: &str,
170-
instance_id: &str,
171-
member_path: &str,
172-
operation: &str,
173-
payload: &str,
167+
targeted_payload: &TargetedPayload,
174168
) -> Result<(), tonic::Status> {
175-
let targeted_payload = TargetedPayload {
176-
instance_id: instance_id.to_string(),
177-
member_path: member_path.to_string(),
178-
operation: operation.to_string(),
179-
payload: payload.to_string(),
180-
};
181-
182169
// Serialize the targeted payload.
183170
let targeted_payload_json = serde_json::to_string_pretty(&targeted_payload).unwrap();
184171

@@ -304,17 +291,16 @@ impl DigitalTwinGraph for DigitalTwinGraphImpl {
304291
// Note: The ask id must be a universally unique value.
305292
let ask_id = Uuid::new_v4().to_string();
306293

294+
// Create the targeted payload.
295+
let targeted_payload = TargetedPayload {
296+
instance_id: instance_id.to_string(),
297+
member_path: "".to_string(),
298+
operation: digital_twin_operation::GET.to_string(),
299+
payload: "".to_string(),
300+
};
301+
307302
// Send the ask.
308-
self.send_ask(
309-
client,
310-
&self.respond_uri,
311-
&ask_id,
312-
&instance_id,
313-
"",
314-
digital_twin_operation::GET,
315-
"",
316-
)
317-
.await?;
303+
self.send_ask(client, &self.respond_uri, &ask_id, &targeted_payload).await?;
318304

319305
// Wait for the answer.
320306
let answer_request = self.wait_for_answer(ask_id, &mut rx).await?;
@@ -378,17 +364,16 @@ impl DigitalTwinGraph for DigitalTwinGraphImpl {
378364
// Note: The ask id must be a universally unique value.
379365
let ask_id = Uuid::new_v4().to_string();
380366

367+
// Create the targeted payload.
368+
let targeted_payload = TargetedPayload {
369+
instance_id: instance_id.to_string(),
370+
member_path: member_path.to_string(),
371+
operation: digital_twin_operation::GET.to_string(),
372+
payload: "".to_string(),
373+
};
374+
381375
// Send the ask.
382-
self.send_ask(
383-
client,
384-
&self.respond_uri,
385-
&ask_id,
386-
&instance_id,
387-
&member_path,
388-
digital_twin_operation::GET,
389-
"",
390-
)
391-
.await?;
376+
self.send_ask(client, &self.respond_uri, &ask_id, &targeted_payload).await?;
392377

393378
// Wait for the answer.
394379
let answer_request = self.wait_for_answer(ask_id, &mut rx).await?;
@@ -460,17 +445,16 @@ impl DigitalTwinGraph for DigitalTwinGraphImpl {
460445
// Note: The ask id must be a universally unique value.
461446
let ask_id = Uuid::new_v4().to_string();
462447

448+
// Create the targeted payload.
449+
let targeted_payload = TargetedPayload {
450+
instance_id: instance_id.to_string(),
451+
member_path: member_path.to_string(),
452+
operation: digital_twin_operation::INVOKE.to_string(),
453+
payload: request_payload.to_string(),
454+
};
455+
463456
// Send the ask.
464-
self.send_ask(
465-
client,
466-
&self.respond_uri,
467-
&ask_id,
468-
&instance_id,
469-
&member_path,
470-
digital_twin_operation::INVOKE,
471-
&request_payload,
472-
)
473-
.await?;
457+
self.send_ask(client, &self.respond_uri, &ask_id, &targeted_payload).await?;
474458

475459
// Wait for the answer.
476460
let answer_request = self.wait_for_answer(ask_id, &mut rx).await?;

0 commit comments

Comments
 (0)