mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 04:03:34 +08:00
Out of line methods - Node<>
This commit is contained in:
@@ -49,19 +49,7 @@ class UAVCAN_EXPORT Node : public INode
|
|||||||
|
|
||||||
bool started_;
|
bool started_;
|
||||||
|
|
||||||
int initNetwork(NodeInitializationResult& node_init_result)
|
int initNetwork(NodeInitializationResult& node_init_result);
|
||||||
{
|
|
||||||
int res = NodeInitializer::publishGlobalDiscoveryRequest(*this);
|
|
||||||
if (res < 0)
|
|
||||||
{
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
NodeInitializer initializer(*this);
|
|
||||||
StaticAssert<(sizeof(initializer) < 1200)>::check();
|
|
||||||
res = initializer.execute();
|
|
||||||
node_init_result = initializer.getResult();
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void registerInternalFailure(const char* msg)
|
virtual void registerInternalFailure(const char* msg)
|
||||||
@@ -109,47 +97,7 @@ public:
|
|||||||
|
|
||||||
bool isStarted() const { return started_; }
|
bool isStarted() const { return started_; }
|
||||||
|
|
||||||
int start(NodeInitializationResult& node_init_result)
|
int start(NodeInitializationResult& node_init_result);
|
||||||
{
|
|
||||||
if (started_)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
GlobalDataTypeRegistry::instance().freeze();
|
|
||||||
|
|
||||||
int res = 0;
|
|
||||||
res = proto_dtp_.start();
|
|
||||||
if (res < 0)
|
|
||||||
{
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
res = proto_logger_.init();
|
|
||||||
if (res < 0)
|
|
||||||
{
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
res = proto_nsp_.startAndPublish();
|
|
||||||
if (res < 0)
|
|
||||||
{
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
res = proto_rrs_.start();
|
|
||||||
if (res < 0)
|
|
||||||
{
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
res = proto_tsp_.start();
|
|
||||||
if (res < 0)
|
|
||||||
{
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
res = initNetwork(node_init_result);
|
|
||||||
started_ = (res >= 0) && node_init_result.isOk();
|
|
||||||
return res;
|
|
||||||
fail:
|
|
||||||
assert(res < 0);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialization methods
|
* Initialization methods
|
||||||
@@ -219,4 +167,68 @@ public:
|
|||||||
Logger& getLogger() { return proto_logger_; }
|
Logger& getLogger() { return proto_logger_; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
template <std::size_t MemPoolSize_, unsigned OutgoingTransferRegistryStaticEntries,
|
||||||
|
unsigned OutgoingTransferMaxPayloadLen>
|
||||||
|
int Node<MemPoolSize_, OutgoingTransferRegistryStaticEntries, OutgoingTransferMaxPayloadLen>::
|
||||||
|
initNetwork(NodeInitializationResult& node_init_result)
|
||||||
|
{
|
||||||
|
int res = NodeInitializer::publishGlobalDiscoveryRequest(*this);
|
||||||
|
if (res < 0)
|
||||||
|
{
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
NodeInitializer initializer(*this);
|
||||||
|
StaticAssert<(sizeof(initializer) < 1200)>::check();
|
||||||
|
res = initializer.execute();
|
||||||
|
node_init_result = initializer.getResult();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <std::size_t MemPoolSize_, unsigned OutgoingTransferRegistryStaticEntries,
|
||||||
|
unsigned OutgoingTransferMaxPayloadLen>
|
||||||
|
int Node<MemPoolSize_, OutgoingTransferRegistryStaticEntries, OutgoingTransferMaxPayloadLen>::
|
||||||
|
start(NodeInitializationResult& node_init_result)
|
||||||
|
{
|
||||||
|
if (started_)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
GlobalDataTypeRegistry::instance().freeze();
|
||||||
|
|
||||||
|
int res = 0;
|
||||||
|
res = proto_dtp_.start();
|
||||||
|
if (res < 0)
|
||||||
|
{
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
res = proto_logger_.init();
|
||||||
|
if (res < 0)
|
||||||
|
{
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
res = proto_nsp_.startAndPublish();
|
||||||
|
if (res < 0)
|
||||||
|
{
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
res = proto_rrs_.start();
|
||||||
|
if (res < 0)
|
||||||
|
{
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
res = proto_tsp_.start();
|
||||||
|
if (res < 0)
|
||||||
|
{
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
res = initNetwork(node_init_result);
|
||||||
|
started_ = (res >= 0) && node_init_result.isOk();
|
||||||
|
return res;
|
||||||
|
fail:
|
||||||
|
assert(res < 0);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user