mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 15:43:34 +08:00
Improved Raft event tracer - added event code to string conversion
This commit is contained in:
@@ -15,6 +15,51 @@
|
||||
|
||||
namespace uavcan
|
||||
{
|
||||
/*
|
||||
* IDynamicNodeIDAllocationServerEventTracer
|
||||
*/
|
||||
#if UAVCAN_TOSTRING
|
||||
const char* IDynamicNodeIDAllocationServerEventTracer::getEventName(uint16_t code)
|
||||
{
|
||||
using namespace dynamic_node_id_server_impl;
|
||||
|
||||
// import re
|
||||
// make_strings = lambda s: ',\n'.join('"%s"' % x for x in re.findall(r'\ \ \ \ Trace([A-Za-z0-9]+),', s))
|
||||
static const char* const Strings[NumTraceEventCodes] =
|
||||
{
|
||||
"Error",
|
||||
"LogLastIndexRestored",
|
||||
"LogAppend",
|
||||
"LogRemove",
|
||||
"CurrentTermRestored",
|
||||
"CurrentTermUpdate",
|
||||
"VotedForRestored",
|
||||
"VotedForUpdate",
|
||||
"DiscoveryBroadcast",
|
||||
"NewServerDiscovered",
|
||||
"DiscoveryReceived",
|
||||
"ClusterSizeInited",
|
||||
"InvalidClusterSizeReceived",
|
||||
"RaftCoreInited",
|
||||
"RaftStateSwitch",
|
||||
"RaftModeSwitch",
|
||||
"RaftNewLogEntry",
|
||||
"RaftRequestIgnored",
|
||||
"RaftVoteRequestReceived",
|
||||
"RaftVoteRequestSucceeded",
|
||||
"RaftVoteRequestInitiation",
|
||||
"RaftPersistStateUpdateError",
|
||||
"RaftCommitIndexUpdate",
|
||||
"RaftNewerTermInResponse",
|
||||
"RaftNewEntryCommitted",
|
||||
"RaftAppendEntriesCallFailure"
|
||||
};
|
||||
uavcan::StaticAssert<sizeof(Strings) / sizeof(Strings[0]) == NumTraceEventCodes>::check();
|
||||
UAVCAN_ASSERT(code < NumTraceEventCodes);
|
||||
return (code < NumTraceEventCodes) ? Strings[code] : "INVALID_EVENT_CODE";
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace dynamic_node_id_server_impl
|
||||
{
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user