-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e01da2
commit 65b4aab
Showing
3 changed files
with
98 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use crate::grpc::actuator::common::{ | ||
actuator_controller_server::ActuatorController, ActuatorStatus, CommandActuatorsRequest, | ||
CommandActuatorsResponse, ResponseCode, | ||
}; | ||
use tonic::{Request, Response, Status}; | ||
|
||
#[derive(Default, Clone, Copy)] | ||
pub struct ActuatorService {} | ||
|
||
#[tonic::async_trait] | ||
impl ActuatorController for ActuatorService { | ||
async fn command_actuators( | ||
&self, | ||
request: Request<CommandActuatorsRequest>, | ||
) -> Result<Response<CommandActuatorsResponse>, Status> { | ||
let cmd = request.into_inner(); | ||
println!("Received CommandActuatorsRequest: {:?}", cmd); | ||
|
||
// Create a response for each actuator in the request | ||
let statuses: Vec<ActuatorStatus> = cmd | ||
.commands | ||
.iter() | ||
.map(|cmd| ActuatorStatus { | ||
actuator_id: cmd.actuator_id, | ||
position: cmd.position, | ||
velocity: cmd.velocity, | ||
}) | ||
.collect(); | ||
|
||
let response = CommandActuatorsResponse { | ||
statuses, | ||
response_code: ResponseCode::Ok as i32, | ||
}; | ||
|
||
Ok(Response::new(response)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use crate::grpc::google::longrunning::{ | ||
operations_server::Operations, CancelOperationRequest, DeleteOperationRequest, | ||
GetOperationRequest, ListOperationsRequest, ListOperationsResponse, Operation, | ||
WaitOperationRequest, | ||
}; | ||
use tonic::{Request, Response, Status}; | ||
|
||
#[derive(Default, Clone, Copy)] | ||
pub struct OperationsService {} | ||
|
||
#[tonic::async_trait] | ||
impl Operations for OperationsService { | ||
async fn list_operations( | ||
&self, | ||
request: Request<ListOperationsRequest>, | ||
) -> Result<Response<ListOperationsResponse>, Status> { | ||
// Implement your logic here | ||
Ok(Response::new(ListOperationsResponse { | ||
operations: vec![], | ||
next_page_token: String::new(), | ||
})) | ||
} | ||
|
||
async fn get_operation( | ||
&self, | ||
request: Request<GetOperationRequest>, | ||
) -> Result<Response<Operation>, Status> { | ||
Err(Status::unimplemented("Not yet implemented")) | ||
} | ||
|
||
async fn delete_operation( | ||
&self, | ||
request: Request<DeleteOperationRequest>, | ||
) -> Result<Response<()>, Status> { | ||
Err(Status::unimplemented("Not yet implemented")) | ||
} | ||
|
||
async fn cancel_operation( | ||
&self, | ||
request: Request<CancelOperationRequest>, | ||
) -> Result<Response<()>, Status> { | ||
Err(Status::unimplemented("Not yet implemented")) | ||
} | ||
|
||
async fn wait_operation( | ||
&self, | ||
request: Request<WaitOperationRequest>, | ||
) -> Result<Response<Operation>, Status> { | ||
Err(Status::unimplemented("Not yet implemented")) | ||
} | ||
} |