mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 06:53:34 +08:00
RestartRequestServer
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <uavcan/node/service_server.hpp>
|
||||
#include <uavcan/util/method_binder.hpp>
|
||||
#include <uavcan/protocol/RestartNode.hpp>
|
||||
|
||||
namespace uavcan
|
||||
{
|
||||
|
||||
class IRestartRequestHandler
|
||||
{
|
||||
public:
|
||||
virtual ~IRestartRequestHandler() { }
|
||||
virtual bool handleRestartRequest(NodeID request_source) = 0;
|
||||
};
|
||||
|
||||
|
||||
class RestartRequestServer : Noncopyable
|
||||
{
|
||||
typedef MethodBinder<const RestartRequestServer*,
|
||||
void(RestartRequestServer::*)(const ReceivedDataStructure<protocol::RestartNode::Request>&,
|
||||
protocol::RestartNode::Response&) const> RestartNodeCallback;
|
||||
|
||||
ServiceServer<protocol::RestartNode, RestartNodeCallback> srv_;
|
||||
IRestartRequestHandler* handler_;
|
||||
|
||||
void handleRestartNode(const ReceivedDataStructure<protocol::RestartNode::Request>& request,
|
||||
protocol::RestartNode::Response& response) const;
|
||||
|
||||
public:
|
||||
RestartRequestServer(INode& node)
|
||||
: srv_(node)
|
||||
, handler_(NULL)
|
||||
{ }
|
||||
|
||||
IRestartRequestHandler* getHandler() const { return handler_; }
|
||||
void setHandler(IRestartRequestHandler* handler) { handler_ = handler; }
|
||||
|
||||
int start();
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user