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
27  TraceRaftCurrentTermRestored, // current term
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
41  Trace0,
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
56  Trace2,
57  Trace3,
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
69  Trace12,
70  // 40
71  TraceDiscoveryNewNodeFound, // node ID
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)
78  TraceDiscoveryGetNodeInfoRequest, // target node ID
80  TraceDiscoveryNodeRemoved, // node ID
81  Trace22,
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
TraceDiscoveryNewNodeFound
Definition: event.hpp:23
TraceDiscoveryNodeRemoved
Definition: event.hpp:23
TraceRaftDiscoveryReceived
Definition: event.hpp:23
TraceRaftPersistStateUpdateError
Definition: event.hpp:23
TraceRaftNewerTermInResponse
Definition: event.hpp:23
TraceRaftVoteRequestSucceeded
Definition: event.hpp:23
TraceRaftLogAppend
Definition: event.hpp:23
TraceRaftStateSwitch
Definition: event.hpp:23
TraceRaftCommitIndexUpdate
Definition: event.hpp:23
TraceRaftNewEntryCommitted
Definition: event.hpp:23
TraceRaftVoteRequestInitiation
Definition: event.hpp:23
TraceDiscoveryNodeRestartDetected
Definition: event.hpp:23
TraceDiscoveryNodeFinalized
Definition: event.hpp:23
TraceRaftLogRemove
Definition: event.hpp:23
TraceRaftVotedForUpdate
Definition: event.hpp:23
TraceAllocationBadRequest
Definition: event.hpp:23
TraceRaftAppendEntriesRespUnsucfl
Definition: event.hpp:23
TraceRaftCurrentTermRestored
Definition: event.hpp:23
TraceAllocationRequestAccepted
Definition: event.hpp:23
TraceDiscoveryCommitCacheUpdated
Definition: event.hpp:23
TraceRaftRequestIgnored
Definition: event.hpp:23
TraceAllocationUnexpectedStage
Definition: event.hpp:23
TraceAllocationExchangeComplete
Definition: event.hpp:23
TraceRaftNewServerDiscovered
Definition: event.hpp:23
TraceRaftElectionComplete
Definition: event.hpp:23
TraceRaftVotedForRestored
Definition: event.hpp:23
TraceRaftClusterSizeInited
Definition: event.hpp:23
TraceRaftNewLogEntry
Definition: event.hpp:23
TraceDiscoveryTimerStart
Definition: event.hpp:23
TraceRaftCurrentTermUpdate
Definition: event.hpp:23
TraceRaftBadClusterSizeReceived
Definition: event.hpp:23
Trace2
Definition: event.hpp:23
TraceDiscoveryGetNodeInfoRequest
Definition: event.hpp:23
TraceRaftCoreInited
Definition: event.hpp:23
TraceAllocationActivity
Definition: event.hpp:23
std::int64_t int64_t
Definition: std.hpp:32
Trace3
Definition: event.hpp:23
TraceAllocationFollowupTimeout
Definition: event.hpp:23
TraceDiscoveryTimerStop
Definition: event.hpp:23
TraceRaftLogLastIndexRestored
Definition: event.hpp:23
TraceRaftVoteRequestReceived
Definition: event.hpp:23
struct UAVCAN_EXPORT StaticAssert
Definition: templates.hpp:29
TraceError
Definition: event.hpp:23
Trace12
Definition: event.hpp:23
TraceAllocationResponse
Definition: event.hpp:23
TraceAllocationFollowupDenied
Definition: event.hpp:23
Trace22
Definition: event.hpp:23
TraceDiscoveryGetNodeInfoFailure
Definition: event.hpp:23
TraceRaftDiscoveryBroadcast
Definition: event.hpp:23
Trace0
Definition: event.hpp:23
TraceAllocationFollowupResponse
Definition: event.hpp:23
TraceRaftAppendEntriesCallFailure
Definition: event.hpp:23


uavcan_communicator
Author(s):
autogenerated on Wed Jan 11 2023 03:59:39