-
-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove 'using namespace' from header * create implementation file for actionrpc_impl * update action proto file and change actionrpc_impl accordingly Fixes #238.
- Loading branch information
1 parent
4b3ba51
commit 648c8f8
Showing
4 changed files
with
62 additions
and
33 deletions.
There are no files selected for viewing
Submodule proto
updated
from cfd81b to 2af63b
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,48 @@ | ||
#include "actionrpc_impl.h" | ||
|
||
namespace rpc_action = dronecore::rpc::action; | ||
|
||
grpc::Status ActionServiceImpl::Arm(grpc::ServerContext *context, | ||
const rpc_action::ArmRequest *request, | ||
rpc_action::ArmResponse *response) | ||
{ | ||
const auto action_result = action.arm(); | ||
|
||
auto *rpc_action_result = new rpc_action::ActionResult(); | ||
rpc_action_result->set_result(static_cast<rpc_action::ActionResult::Result>(action_result)); | ||
rpc_action_result->set_result_str(dronecore::Action::result_str(action_result)); | ||
|
||
response->set_allocated_action_result(rpc_action_result); | ||
|
||
return grpc::Status::OK; | ||
} | ||
|
||
grpc::Status ActionServiceImpl::Takeoff(grpc::ServerContext *context, | ||
const rpc_action::TakeoffRequest *request, | ||
rpc_action::TakeoffResponse *response) | ||
{ | ||
const auto action_result = action.takeoff(); | ||
|
||
auto *rpc_action_result = new rpc_action::ActionResult(); | ||
rpc_action_result->set_result(static_cast<rpc_action::ActionResult::Result>(action_result)); | ||
rpc_action_result->set_result_str(dronecore::Action::result_str(action_result)); | ||
|
||
response->set_allocated_action_result(rpc_action_result); | ||
|
||
return grpc::Status::OK; | ||
} | ||
|
||
grpc::Status ActionServiceImpl::Land(grpc::ServerContext *context, | ||
const rpc_action::LandRequest *request, | ||
rpc_action::LandResponse *response) | ||
{ | ||
const auto action_result = action.land(); | ||
|
||
auto *rpc_action_result = new rpc_action::ActionResult(); | ||
rpc_action_result->set_result(static_cast<rpc_action::ActionResult::Result>(action_result)); | ||
rpc_action_result->set_result_str(dronecore::Action::result_str(action_result)); | ||
|
||
response->set_allocated_action_result(rpc_action_result); | ||
|
||
return grpc::Status::OK; | ||
} |
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 |
---|---|---|
@@ -1,44 +1,24 @@ | ||
#include "action.h" | ||
#include "action/action.grpc.pb.h" | ||
|
||
using grpc::Status; | ||
using grpc::ServerContext; | ||
|
||
using namespace dronecore; | ||
|
||
class ActionServiceImpl final : public rpc::action::ActionService::Service | ||
class ActionServiceImpl final : public dronecore::rpc::action::ActionService::Service | ||
{ | ||
public: | ||
ActionServiceImpl(const Action &action) | ||
ActionServiceImpl(const dronecore::Action &action) | ||
: action(action) {} | ||
|
||
Status Arm(ServerContext *context, const rpc::action::ArmRequest *request, | ||
rpc::action::ActionResult *response) override | ||
{ | ||
const Action::Result action_result = action.arm(); | ||
response->set_result(static_cast<rpc::action::ActionResult::Result>(action_result)); | ||
response->set_result_str(Action::result_str(action_result)); | ||
return Status::OK; | ||
} | ||
grpc::Status Arm(grpc::ServerContext *context, | ||
const dronecore::rpc::action::ArmRequest *request, | ||
dronecore::rpc::action::ArmResponse *response) override; | ||
|
||
Status TakeOff(ServerContext *context, const rpc::action::TakeOffRequest *request, | ||
rpc::action::ActionResult *response) override | ||
{ | ||
const Action::Result action_result = action.takeoff(); | ||
response->set_result(static_cast<rpc::action::ActionResult::Result>(action_result)); | ||
response->set_result_str(Action::result_str(action_result)); | ||
return Status::OK; | ||
} | ||
grpc::Status Takeoff(grpc::ServerContext *context, | ||
const dronecore::rpc::action::TakeoffRequest *request, | ||
dronecore::rpc::action::TakeoffResponse *response) override; | ||
|
||
Status Land(ServerContext *context, const rpc::action::LandRequest *request, | ||
rpc::action::ActionResult *response) override | ||
{ | ||
const Action::Result action_result = action.land(); | ||
response->set_result(static_cast<rpc::action::ActionResult::Result>(action_result)); | ||
response->set_result_str(Action::result_str(action_result)); | ||
return Status::OK; | ||
} | ||
grpc::Status Land(grpc::ServerContext *context, | ||
const dronecore::rpc::action::LandRequest *request, | ||
dronecore::rpc::action::LandResponse *response) override; | ||
|
||
private: | ||
const Action &action; | ||
const dronecore::Action &action; | ||
}; |