Merge branch 'master' into dynamic_node_id_raft

This commit is contained in:
Pavel Kirienko
2015-05-01 20:54:05 +03:00
2 changed files with 17 additions and 8 deletions
@@ -84,12 +84,15 @@ static Stream& operator<<(Stream& s, const ServiceCallResult<DataType>& scr)
*/
class ServiceClientBase : protected DeadlineHandler
{
const DataTypeDescriptor* data_type_descriptor_; ///< This will be initialized at the time of first call
protected:
MonotonicDuration request_timeout_;
bool pending_;
explicit ServiceClientBase(INode& node)
: DeadlineHandler(node.getScheduler())
, data_type_descriptor_(NULL)
, request_timeout_(getDefaultRequestTimeout())
, pending_(false)
{ }
@@ -159,7 +162,7 @@ private:
void invokeCallback(ServiceCallResultType& result);
void handleReceivedDataStruct(ReceivedDataStructure<ResponseType>& response);
virtual void handleReceivedDataStruct(ReceivedDataStructure<ResponseType>& response);
virtual void handleDeadline(MonotonicTime);
+13 -7
View File
@@ -24,24 +24,30 @@ int ServiceClientBase::prepareToCall(INode& node, const char* dtname, NodeID ser
/*
* Determining the Data Type ID
*/
GlobalDataTypeRegistry::instance().freeze();
const DataTypeDescriptor* const descr = GlobalDataTypeRegistry::instance().find(DataTypeKindService, dtname);
if (!descr)
if (data_type_descriptor_ == NULL)
{
UAVCAN_TRACE("ServiceClient", "Type [%s] is not registered", dtname);
return -ErrUnknownDataType;
GlobalDataTypeRegistry::instance().freeze();
data_type_descriptor_ = GlobalDataTypeRegistry::instance().find(DataTypeKindService, dtname);
if (data_type_descriptor_ == NULL)
{
UAVCAN_TRACE("ServiceClient", "Type [%s] is not registered", dtname);
return -ErrUnknownDataType;
}
UAVCAN_TRACE("ServiceClient", "Data type descriptor inited: %s", data_type_descriptor_->toString().c_str());
}
UAVCAN_ASSERT(data_type_descriptor_ != NULL);
/*
* Determining the Transfer ID
*/
const OutgoingTransferRegistryKey otr_key(descr->getID(), TransferTypeServiceRequest, server_node_id);
const OutgoingTransferRegistryKey otr_key(data_type_descriptor_->getID(),
TransferTypeServiceRequest, server_node_id);
const MonotonicTime otr_deadline = node.getMonotonicTime() + TransferSender::getDefaultMaxTransferInterval();
TransferID* const otr_tid =
node.getDispatcher().getOutgoingTransferRegistry().accessOrCreate(otr_key, otr_deadline);
if (!otr_tid)
{
UAVCAN_TRACE("ServiceClient", "OTR access failure, dtd=%s", descr->toString().c_str());
UAVCAN_TRACE("ServiceClient", "OTR access failure, dtd=%s", data_type_descriptor_->toString().c_str());
return -ErrMemory;
}
out_transfer_id = *otr_tid;