event.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Pavel Kirienko <pavel.kirienko@gmail.com>
3  */
4 
5 #ifndef UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_SERVER_EVENT_HPP_INCLUDED
6 #define UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_SERVER_EVENT_HPP_INCLUDED
7 
10 
11 namespace uavcan
12 {
13 namespace dynamic_node_id_server
14 {
19 enum UAVCAN_EXPORT TraceCode
20 {
21  // Event name Argument
22  // 0
23  TraceError, // error code (may be negated)
24  TraceRaftLogLastIndexRestored, // recovered last index value
25  TraceRaftLogAppend, // index of new entry
26  TraceRaftLogRemove, // new last index value
28  // 5
29  TraceRaftCurrentTermUpdate, // current term
30  TraceRaftVotedForRestored, // value of votedFor
31  TraceRaftVotedForUpdate, // value of votedFor
32  TraceRaftDiscoveryBroadcast, // number of known servers
33  TraceRaftNewServerDiscovered, // node ID of the new server
34  // 10
35  TraceRaftDiscoveryReceived, // node ID of the sender
36  TraceRaftClusterSizeInited, // cluster size
37  TraceRaftBadClusterSizeReceived, // received cluster size
38  TraceRaftCoreInited, // update interval in usec
39  TraceRaftStateSwitch, // 0 - Follower, 1 - Candidate, 2 - Leader
40  // 15
42  TraceRaftNewLogEntry, // node ID value
43  TraceRaftRequestIgnored, // node ID of the client
44  TraceRaftVoteRequestReceived, // node ID of the client
45  TraceRaftVoteRequestSucceeded, // node ID of the server
46  // 20
47  TraceRaftVoteRequestInitiation, // node ID of the server
48  TraceRaftPersistStateUpdateError, // negative error code
49  TraceRaftCommitIndexUpdate, // new commit index value
50  TraceRaftNewerTermInResponse, // new term value
51  TraceRaftNewEntryCommitted, // new commit index value
52  // 25
53  TraceRaftAppendEntriesCallFailure, // error code (may be negated)
54  TraceRaftElectionComplete, // number of votes collected
55  TraceRaftAppendEntriesRespUnsucfl, // node ID of the client
58  // 30
59  TraceAllocationFollowupResponse, // number of unique ID bytes in this response
60  TraceAllocationFollowupDenied, // reason code (see sources for details)
61  TraceAllocationFollowupTimeout, // timeout value in microseconds
62  TraceAllocationBadRequest, // number of unique ID bytes in this request
63  TraceAllocationUnexpectedStage, // stage number in the request - 1, 2, or 3
64  // 35
65  TraceAllocationRequestAccepted, // number of bytes of unique ID after request
66  TraceAllocationExchangeComplete, // first 8 bytes of unique ID interpreted as signed 64 bit big endian
67  TraceAllocationResponse, // allocated node ID
68  TraceAllocationActivity, // source node ID of the message
70  // 40
72  TraceDiscoveryCommitCacheUpdated, // node ID marked as committed
73  TraceDiscoveryNodeFinalized, // node ID in lower 7 bits, bit 8 (256, 0x100) is set if unique ID is known
75  TraceDiscoveryTimerStart, // interval in microseconds
76  // 45
77  TraceDiscoveryTimerStop, // reason code (see sources for details)
82  // 50
83 
84  NumTraceCodes
85 };
86 
91 {
92 public:
93 #if UAVCAN_TOSTRING
94 
98  static const char* getEventName(TraceCode code)
99  {
100  // import re;m = lambda s:',\n'.join('"%s"' % x for x in re.findall(r'\ {4}Trace[0-9]*([A-Za-z0-9]*),',s))
101  static const char* const Strings[] =
102  {
103  "Error",
104  "RaftLogLastIndexRestored",
105  "RaftLogAppend",
106  "RaftLogRemove",
107  "RaftCurrentTermRestored",
108  "RaftCurrentTermUpdate",
109  "RaftVotedForRestored",
110  "RaftVotedForUpdate",
111  "RaftDiscoveryBroadcast",
112  "RaftNewServerDiscovered",
113  "RaftDiscoveryReceived",
114  "RaftClusterSizeInited",
115  "RaftBadClusterSizeReceived",
116  "RaftCoreInited",
117  "RaftStateSwitch",
118  "",
119  "RaftNewLogEntry",
120  "RaftRequestIgnored",
121  "RaftVoteRequestReceived",
122  "RaftVoteRequestSucceeded",
123  "RaftVoteRequestInitiation",
124  "RaftPersistStateUpdateError",
125  "RaftCommitIndexUpdate",
126  "RaftNewerTermInResponse",
127  "RaftNewEntryCommitted",
128  "RaftAppendEntriesCallFailure",
129  "RaftElectionComplete",
130  "RaftAppendEntriesRespUnsucfl",
131  "",
132  "",
133  "AllocationFollowupResponse",
134  "AllocationFollowupDenied",
135  "AllocationFollowupTimeout",
136  "AllocationBadRequest",
137  "AllocationUnexpectedStage",
138  "AllocationRequestAccepted",
139  "AllocationExchangeComplete",
140  "AllocationResponse",
141  "AllocationActivity",
142  "",
143  "DiscoveryNewNodeFound",
144  "DiscoveryCommitCacheUpdated",
145  "DiscoveryNodeFinalized",
146  "DiscoveryGetNodeInfoFailure",
147  "DiscoveryTimerStart",
148  "DiscoveryTimerStop",
149  "DiscoveryGetNodeInfoRequest",
150  "DiscoveryNodeRestartDetected",
151  "DiscoveryNodeRemoved",
152  ""
153  };
154  uavcan::StaticAssert<sizeof(Strings) / sizeof(Strings[0]) == NumTraceCodes>::check();
155  UAVCAN_ASSERT(code < NumTraceCodes);
156  // coverity[dead_error_line]
157  return (code < NumTraceCodes) ? Strings[static_cast<unsigned>(code)] : "INVALID_EVENT_CODE";
158  }
159 #endif
160 
168  virtual void onEvent(TraceCode event_code, int64_t event_argument) = 0;
169 
170  virtual ~IEventTracer() { }
171 };
172 
173 }
174 }
175 
176 #endif // Include guard
uavcan::dynamic_node_id_server::IEventTracer::~IEventTracer
virtual ~IEventTracer()
Definition: event.hpp:170
TraceRaftVotedForRestored
TraceRaftVotedForRestored
Definition: event.hpp:30
TraceError
TraceError
Definition: event.hpp:23
types.hpp
TraceRaftRequestIgnored
TraceRaftRequestIgnored
Definition: event.hpp:43
TraceRaftNewEntryCommitted
TraceRaftNewEntryCommitted
Definition: event.hpp:51
TraceRaftVoteRequestSucceeded
TraceRaftVoteRequestSucceeded
Definition: event.hpp:45
TraceAllocationFollowupDenied
TraceAllocationFollowupDenied
Definition: event.hpp:60
TraceAllocationActivity
TraceAllocationActivity
Definition: event.hpp:68
TraceRaftNewServerDiscovered
TraceRaftNewServerDiscovered
Definition: event.hpp:33
TraceRaftNewerTermInResponse
TraceRaftNewerTermInResponse
Definition: event.hpp:50
TraceDiscoveryCommitCacheUpdated
TraceDiscoveryCommitCacheUpdated
Definition: event.hpp:72
TraceAllocationResponse
TraceAllocationResponse
Definition: event.hpp:67
TraceAllocationUnexpectedStage
TraceAllocationUnexpectedStage
Definition: event.hpp:63
TraceRaftPersistStateUpdateError
TraceRaftPersistStateUpdateError
Definition: event.hpp:48
TraceRaftLogRemove
TraceRaftLogRemove
Definition: event.hpp:26
uavcan::StaticAssert
struct UAVCAN_EXPORT StaticAssert
Definition: templates.hpp:29
uavcan::int64_t
std::int64_t int64_t
Definition: std.hpp:32
TraceRaftLogLastIndexRestored
TraceRaftLogLastIndexRestored
Definition: event.hpp:24
TraceDiscoveryNodeRemoved
TraceDiscoveryNodeRemoved
Definition: event.hpp:80
Trace2
Trace2
Definition: event.hpp:56
TraceDiscoveryNodeRestartDetected
TraceDiscoveryNodeRestartDetected
Definition: event.hpp:79
Trace3
Trace3
Definition: event.hpp:57
TraceDiscoveryGetNodeInfoRequest
TraceDiscoveryGetNodeInfoRequest
Definition: event.hpp:78
TraceRaftVotedForUpdate
TraceRaftVotedForUpdate
Definition: event.hpp:31
TraceRaftCurrentTermUpdate
TraceRaftCurrentTermUpdate
Definition: event.hpp:29
TraceAllocationBadRequest
TraceAllocationBadRequest
Definition: event.hpp:62
UAVCAN_EXPORT
#define UAVCAN_EXPORT
Definition: libuavcan/libuavcan/include/uavcan/build_config.hpp:108
TraceRaftDiscoveryBroadcast
TraceRaftDiscoveryBroadcast
Definition: event.hpp:32
TraceDiscoveryTimerStop
TraceDiscoveryTimerStop
Definition: event.hpp:77
TraceRaftAppendEntriesCallFailure
TraceRaftAppendEntriesCallFailure
Definition: event.hpp:53
TraceRaftClusterSizeInited
TraceRaftClusterSizeInited
Definition: event.hpp:36
TraceDiscoveryNewNodeFound
TraceDiscoveryNewNodeFound
Definition: event.hpp:71
TraceRaftVoteRequestInitiation
TraceRaftVoteRequestInitiation
Definition: event.hpp:47
TraceRaftElectionComplete
TraceRaftElectionComplete
Definition: event.hpp:54
build_config.hpp
TraceDiscoveryTimerStart
TraceDiscoveryTimerStart
Definition: event.hpp:75
Trace12
Trace12
Definition: event.hpp:69
TraceAllocationFollowupResponse
TraceAllocationFollowupResponse
Definition: event.hpp:59
TraceRaftCoreInited
TraceRaftCoreInited
Definition: event.hpp:38
uavcan::dynamic_node_id_server::IEventTracer
Definition: event.hpp:90
TraceAllocationRequestAccepted
TraceAllocationRequestAccepted
Definition: event.hpp:65
TraceRaftAppendEntriesRespUnsucfl
TraceRaftAppendEntriesRespUnsucfl
Definition: event.hpp:55
TraceDiscoveryGetNodeInfoFailure
TraceDiscoveryGetNodeInfoFailure
Definition: event.hpp:74
TraceRaftBadClusterSizeReceived
TraceRaftBadClusterSizeReceived
Definition: event.hpp:37
TraceRaftNewLogEntry
TraceRaftNewLogEntry
Definition: event.hpp:42
TraceRaftVoteRequestReceived
TraceRaftVoteRequestReceived
Definition: event.hpp:44
TraceDiscoveryNodeFinalized
TraceDiscoveryNodeFinalized
Definition: event.hpp:73
TraceRaftDiscoveryReceived
TraceRaftDiscoveryReceived
Definition: event.hpp:35
TraceRaftStateSwitch
TraceRaftStateSwitch
Definition: event.hpp:39
uavcan
Definition: libuavcan/libuavcan/include/uavcan/build_config.hpp:204
Trace22
Trace22
Definition: event.hpp:81
TraceRaftCurrentTermRestored
TraceRaftCurrentTermRestored
Definition: event.hpp:27
Trace0
Trace0
Definition: event.hpp:41
TraceRaftLogAppend
TraceRaftLogAppend
Definition: event.hpp:25
TraceAllocationExchangeComplete
TraceAllocationExchangeComplete
Definition: event.hpp:66
UAVCAN_ASSERT
#define UAVCAN_ASSERT(x)
Definition: libuavcan/libuavcan/include/uavcan/build_config.hpp:184
TraceRaftCommitIndexUpdate
TraceRaftCommitIndexUpdate
Definition: event.hpp:49
TraceAllocationFollowupTimeout
TraceAllocationFollowupTimeout
Definition: event.hpp:61


uavcan_communicator
Author(s):
autogenerated on Fri Dec 13 2024 03:10:02