mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[ntcore] Add DataLog support
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <wpi/DataLog.h>
|
||||
#include <wpi/UidVector.h>
|
||||
#include <wpi/condition_variable.h>
|
||||
#include <wpi/mutex.h>
|
||||
#include <wpi/span.h>
|
||||
@@ -61,6 +63,9 @@ class DispatcherBase : public IDispatcher {
|
||||
unsigned int AddPolledListener(unsigned int poller_uid,
|
||||
bool immediate_notify) const;
|
||||
|
||||
unsigned int StartDataLog(wpi::log::DataLog& log, std::string_view name);
|
||||
void StopDataLog(unsigned int logger);
|
||||
|
||||
void SetConnector(Connector connector);
|
||||
void SetConnectorOverride(Connector connector);
|
||||
void ClearConnectorOverride();
|
||||
@@ -120,6 +125,20 @@ class DispatcherBase : public IDispatcher {
|
||||
unsigned int m_reconnect_proto_rev = 0x0300;
|
||||
bool m_do_reconnect = true;
|
||||
|
||||
struct DataLogger {
|
||||
DataLogger() = default;
|
||||
DataLogger(wpi::log::DataLog& log, std::string_view name, int64_t time)
|
||||
: entry{log, name,
|
||||
"{\"schema\":\"NTConnectionInfo\",\"source\":\"NT\"}", "json",
|
||||
time} {}
|
||||
|
||||
explicit operator bool() const { return static_cast<bool>(entry); }
|
||||
|
||||
wpi::log::StringLogEntry entry;
|
||||
unsigned int notifier = 0;
|
||||
};
|
||||
wpi::UidVector<DataLogger, 4> m_dataloggers;
|
||||
|
||||
protected:
|
||||
wpi::Logger& m_logger;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user