mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
Raft: Test event tracer logs timestamp
This commit is contained in:
parent
f839cf010b
commit
10877089d8
@ -8,6 +8,8 @@
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <uavcan/protocol/dynamic_node_id_server/event.hpp>
|
||||
#include <uavcan/time.hpp>
|
||||
#include "../../clock.hpp"
|
||||
|
||||
|
||||
class EventTracer : public uavcan::dynamic_node_id_server::IEventTracer
|
||||
@ -24,16 +26,24 @@ class EventTracer : public uavcan::dynamic_node_id_server::IEventTracer
|
||||
};
|
||||
|
||||
const std::string id_;
|
||||
const uavcan::MonotonicTime startup_ts_;
|
||||
std::list<EventLogEntry> event_log_;
|
||||
|
||||
public:
|
||||
EventTracer() { }
|
||||
EventTracer() :
|
||||
startup_ts_(SystemClockDriver().getMonotonic())
|
||||
{ }
|
||||
|
||||
EventTracer(const std::string& id) : id_(id) { }
|
||||
EventTracer(const std::string& id) :
|
||||
id_(id),
|
||||
startup_ts_(SystemClockDriver().getMonotonic())
|
||||
{ }
|
||||
|
||||
virtual void onEvent(uavcan::dynamic_node_id_server::TraceCode code, uavcan::int64_t argument)
|
||||
{
|
||||
std::cout << "EVENT [" << id_ << "]\t" << code << "\t" << getEventName(code) << "\t" << argument << std::endl;
|
||||
const uavcan::MonotonicDuration ts = SystemClockDriver().getMonotonic() - startup_ts_;
|
||||
std::cout << "EVENT [" << id_ << "]\t" << ts.toString() << "\t"
|
||||
<< code << "\t" << getEventName(code) << "\t" << argument << std::endl;
|
||||
event_log_.push_back(EventLogEntry(code, argument));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user