10#include <initializer_list>
125 std::function<
void(std::span<const uint8_t>
data)>
write,
235 void WriterThreadMain(
236 std::function<
void(std::span<const uint8_t>
data)>
write);
242 void AppendImpl(std::span<const uint8_t>
data);
249 bool m_doFlush{
false};
250 bool m_paused{
false};
252 std::string m_extraHeader;
253 std::string m_newFilename;
255 std::vector<Buffer> m_free;
256 std::vector<Buffer> m_outgoing;
264 std::thread m_thread;
294 explicit operator bool()
const {
return m_log !=
nullptr; }
342 m_log->AppendRaw(m_entry,
data, timestamp);
367 m_log->AppendBoolean(m_entry,
value, timestamp);
392 m_log->AppendInteger(m_entry,
value, timestamp);
417 m_log->AppendFloat(m_entry,
value, timestamp);
442 m_log->AppendDouble(m_entry,
value, timestamp);
451 static constexpr const char* kDataType =
"string";
470 m_log->AppendString(m_entry,
value, timestamp);
479 static constexpr const char* kDataType =
"boolean[]";
497 m_log->AppendBooleanArray(m_entry, arr, timestamp);
507 Append(std::span{arr.begin(), arr.end()}, timestamp);
517 m_log->AppendBooleanArray(m_entry, arr, timestamp);
527 Append(std::span{arr.begin(), arr.end()}, timestamp);
537 m_log->AppendBooleanArray(m_entry, arr, timestamp);
546 static constexpr const char* kDataType =
"int64[]";
563 m_log->AppendIntegerArray(m_entry, arr, timestamp);
573 Append({arr.begin(), arr.end()}, timestamp);
582 static constexpr const char* kDataType =
"float[]";
598 m_log->AppendFloatArray(m_entry, arr, timestamp);
608 Append({arr.begin(), arr.end()}, timestamp);
617 static constexpr const char* kDataType =
"double[]";
634 m_log->AppendDoubleArray(m_entry, arr, timestamp);
644 Append({arr.begin(), arr.end()}, timestamp);
653 static constexpr const char* kDataType =
"string[]";
670 m_log->AppendStringArray(m_entry, arr, timestamp);
680 m_log->AppendStringArray(m_entry, arr, timestamp);
689 void Append(std::initializer_list<std::string_view> arr,
691 Append(std::span<const std::string_view>{arr.begin(), arr.end()},
This file defines the DenseMap class.
This file defines the StringMap class.
Log array of boolean values.
Definition: DataLog.h:477
void Append(std::span< const uint8_t > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:536
void Append(std::initializer_list< bool > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:506
BooleanArrayLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:482
void Append(std::initializer_list< int > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:526
void Append(std::span< const int > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:516
void Append(std::span< const bool > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:496
BooleanArrayLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:485
BooleanArrayLogEntry()=default
Log boolean values.
Definition: DataLog.h:349
BooleanLogEntry()=default
BooleanLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:356
void Append(bool value, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:366
BooleanLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:354
Log entry base class.
Definition: DataLog.h:270
DataLogEntry(DataLogEntry &&rhs)
Definition: DataLog.h:281
DataLogEntry(const DataLogEntry &)=delete
void Finish(int64_t timestamp=0)
Finishes the entry.
Definition: DataLog.h:311
DataLog * m_log
Definition: DataLog.h:314
DataLogEntry(DataLog &log, std::string_view name, std::string_view type, std::string_view metadata={}, int64_t timestamp=0)
Definition: DataLog.h:273
DataLogEntry & operator=(const DataLogEntry &)=delete
int m_entry
Definition: DataLog.h:315
DataLogEntry & operator=(DataLogEntry &&rhs)
Definition: DataLog.h:284
void SetMetadata(std::string_view metadata, int64_t timestamp=0)
Updates the metadata for the entry.
Definition: DataLog.h:302
A data log.
Definition: DataLog.h:66
void AppendBooleanArray(int entry, std::span< const bool > arr, int64_t timestamp)
void AppendBooleanArray(int entry, std::span< const int > arr, int64_t timestamp)
void SetMetadata(int entry, std::string_view metadata, int64_t timestamp=0)
Updates the metadata for an entry.
void AppendStringArray(int entry, std::span< const std::string > arr, int64_t timestamp)
int Start(std::string_view name, std::string_view type, std::string_view metadata={}, int64_t timestamp=0)
Start an entry.
DataLog & operator=(const DataLog &)=delete
DataLog(std::string_view dir="", std::string_view filename="", double period=0.25, std::string_view extraHeader="")
Construct a new Data Log.
void Flush()
Explicitly flushes the log data to disk.
void AppendRaw(int entry, std::span< const uint8_t > data, int64_t timestamp)
Appends a record to the log.
void AppendIntegerArray(int entry, std::span< const int64_t > arr, int64_t timestamp)
DataLog(const DataLog &)=delete
void AppendBooleanArray(int entry, std::span< const uint8_t > arr, int64_t timestamp)
void AppendDouble(int entry, double value, int64_t timestamp)
void AppendFloat(int entry, float value, int64_t timestamp)
DataLog & operator=(const DataLog &&)=delete
void AppendFloatArray(int entry, std::span< const float > arr, int64_t timestamp)
DataLog(std::function< void(std::span< const uint8_t > data)> write, double period=0.25, std::string_view extraHeader="")
Construct a new Data Log that passes its output to the provided function rather than a file.
void AppendString(int entry, std::string_view value, int64_t timestamp)
DataLog(wpi::Logger &msglog, std::string_view dir="", std::string_view filename="", double period=0.25, std::string_view extraHeader="")
Construct a new Data Log.
DataLog(DataLog &&)=delete
void Pause()
Pauses appending of data records to the log.
void AppendStringArray(int entry, std::span< const std::string_view > arr, int64_t timestamp)
void SetFilename(std::string_view filename)
Change log filename.
DataLog(wpi::Logger &msglog, std::function< void(std::span< const uint8_t > data)> write, double period=0.25, std::string_view extraHeader="")
Construct a new Data Log that passes its output to the provided function rather than a file.
void AppendRaw2(int entry, std::span< const std::span< const uint8_t > > data, int64_t timestamp)
Appends a record to the log.
void Finish(int entry, int64_t timestamp=0)
Finish an entry.
void AppendDoubleArray(int entry, std::span< const double > arr, int64_t timestamp)
void Resume()
Resumes appending of data records to the log.
void AppendInteger(int entry, int64_t value, int64_t timestamp)
void AppendBoolean(int entry, bool value, int64_t timestamp)
Log array of double values.
Definition: DataLog.h:615
DoubleArrayLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:620
void Append(std::span< const double > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:633
void Append(std::initializer_list< double > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:643
DoubleArrayLogEntry()=default
DoubleArrayLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:623
Log double values.
Definition: DataLog.h:424
DoubleLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:431
void Append(double value, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:441
DoubleLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:429
Log array of float values.
Definition: DataLog.h:580
FloatArrayLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:587
void Append(std::span< const float > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:597
void Append(std::initializer_list< float > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:607
FloatArrayLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:585
FloatArrayLogEntry()=default
Log float values.
Definition: DataLog.h:399
FloatLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:404
FloatLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:406
void Append(float value, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:416
Log array of integer values.
Definition: DataLog.h:544
IntegerArrayLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:552
void Append(std::span< const int64_t > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:562
IntegerArrayLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:549
void Append(std::initializer_list< int64_t > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:572
IntegerArrayLogEntry()=default
Log integer values.
Definition: DataLog.h:374
IntegerLogEntry()=default
IntegerLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:381
IntegerLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:379
void Append(int64_t value, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:391
Log arbitrary byte data.
Definition: DataLog.h:321
RawLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:328
RawLogEntry(DataLog &log, std::string_view name, std::string_view metadata, std::string_view type, int64_t timestamp=0)
Definition: DataLog.h:331
static constexpr std::string_view kDataType
Definition: DataLog.h:323
void Append(std::span< const uint8_t > data, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:341
RawLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:326
Log array of string values.
Definition: DataLog.h:651
void Append(std::initializer_list< std::string_view > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:689
StringArrayLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:659
void Append(std::span< const std::string > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:669
void Append(std::span< const std::string_view > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:679
StringArrayLogEntry()=default
StringArrayLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:656
Log string values.
Definition: DataLog.h:449
StringLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:456
void Append(std::string_view value, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:469
StringLogEntry(DataLog &log, std::string_view name, std::string_view metadata, std::string_view type, int64_t timestamp=0)
Definition: DataLog.h:459
StringLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:454
basic_string_view< char > string_view
Definition: core.h:520
type
Definition: core.h:575
dimensionless::scalar_t log(const ScalarUnit x) noexcept
Compute natural logarithm.
Definition: math.h:349
EIGEN_CONSTEXPR Index size(const T &x)
Definition: Meta.h:479
::uint64_t uint64_t
Definition: Meta.h:58
::uint32_t uint32_t
Definition: Meta.h:56
::int64_t int64_t
Definition: Meta.h:59
::uint8_t uint8_t
Definition: Meta.h:52
auto write(OutputIt out, const std::tm &time, const std::locale &loc, char format, char modifier=0) -> OutputIt
Definition: chrono.h:426
ControlRecordType
Definition: DataLog.h:31
@ kControlFinish
Definition: DataLog.h:33
@ kControlStart
Definition: DataLog.h:32
@ kControlSetMetadata
Definition: DataLog.h:34
Definition: ntcore_cpp.h:30
/file This file defines the SmallVector class.
Definition: AprilTagFieldLayout.h:18
::std::mutex mutex
Definition: mutex.h:17
::std::condition_variable condition_variable
Definition: condition_variable.h:16
Definition: format.h:1544