mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 10:23:34 +08:00
ServiceClient<>::hasPendingCallToServer()
This commit is contained in:
@@ -165,6 +165,13 @@ protected:
|
||||
bool operator()(const CallState& state) const { return (state.getCallID() == id) && !state.hasTimedOut(); }
|
||||
};
|
||||
|
||||
struct ServerSearchPredicate
|
||||
{
|
||||
const NodeID server_node_id;
|
||||
ServerSearchPredicate(NodeID nid) : server_node_id(nid) { }
|
||||
bool operator()(const CallState& state) const { return state.getCallID().server_node_id == server_node_id; }
|
||||
};
|
||||
|
||||
MonotonicDuration request_timeout_;
|
||||
|
||||
ServiceClientBase(INode& node)
|
||||
@@ -329,6 +336,11 @@ public:
|
||||
*/
|
||||
void cancelAllCalls();
|
||||
|
||||
/**
|
||||
* Checks whether there's currently a pending call addressed to the specified node ID.
|
||||
*/
|
||||
bool hasPendingCallToServer(NodeID server_node_id) const;
|
||||
|
||||
/**
|
||||
* Service response callback must be set prior service call.
|
||||
*/
|
||||
@@ -538,6 +550,12 @@ void ServiceClient<DataType_, Callback_, NumStaticCalls_>::cancelAllCalls()
|
||||
SubscriberType::stop();
|
||||
}
|
||||
|
||||
template <typename DataType_, typename Callback_, unsigned NumStaticCalls_>
|
||||
bool ServiceClient<DataType_, Callback_, NumStaticCalls_>::hasPendingCallToServer(NodeID server_node_id) const
|
||||
{
|
||||
return NULL != call_registry_.find(ServerSearchPredicate(server_node_id));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // UAVCAN_NODE_SERVICE_CLIENT_HPP_INCLUDED
|
||||
|
||||
Reference in New Issue
Block a user