10#include <initializer_list>
125 std::function<
void(std::span<const uint8_t>
data)>
write,
338 void WriterThreadMain(
339 std::function<
void(std::span<const uint8_t>
data)>
write);
345 void AppendImpl(std::span<const uint8_t>
data);
352 bool m_doFlush{
false};
353 bool m_paused{
false};
355 std::string m_extraHeader;
356 std::string m_newFilename;
358 std::vector<Buffer> m_free;
359 std::vector<Buffer> m_outgoing;
367 std::thread m_thread;
397 explicit operator bool()
const {
return m_log !=
nullptr; }
445 m_log->AppendRaw(m_entry,
data, timestamp);
470 m_log->AppendBoolean(m_entry,
value, timestamp);
495 m_log->AppendInteger(m_entry,
value, timestamp);
520 m_log->AppendFloat(m_entry,
value, timestamp);
545 m_log->AppendDouble(m_entry,
value, timestamp);
554 static constexpr const char* kDataType =
"string";
573 m_log->AppendString(m_entry,
value, timestamp);
582 static constexpr const char* kDataType =
"boolean[]";
600 m_log->AppendBooleanArray(m_entry, arr, timestamp);
610 Append(std::span{arr.begin(), arr.end()}, timestamp);
620 m_log->AppendBooleanArray(m_entry, arr, timestamp);
630 Append(std::span{arr.begin(), arr.end()}, timestamp);
640 m_log->AppendBooleanArray(m_entry, arr, timestamp);
649 static constexpr const char* kDataType =
"int64[]";
666 m_log->AppendIntegerArray(m_entry, arr, timestamp);
676 Append({arr.begin(), arr.end()}, timestamp);
685 static constexpr const char* kDataType =
"float[]";
701 m_log->AppendFloatArray(m_entry, arr, timestamp);
711 Append({arr.begin(), arr.end()}, timestamp);
720 static constexpr const char* kDataType =
"double[]";
737 m_log->AppendDoubleArray(m_entry, arr, timestamp);
747 Append({arr.begin(), arr.end()}, timestamp);
756 static constexpr const char* kDataType =
"string[]";
773 m_log->AppendStringArray(m_entry, arr, timestamp);
783 m_log->AppendStringArray(m_entry, arr, timestamp);
792 void Append(std::initializer_list<std::string_view> arr,
794 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:580
void Append(std::span< const uint8_t > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:639
void Append(std::initializer_list< bool > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:609
BooleanArrayLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:585
void Append(std::initializer_list< int > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:629
void Append(std::span< const int > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:619
void Append(std::span< const bool > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:599
BooleanArrayLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:588
BooleanArrayLogEntry()=default
Log boolean values.
Definition: DataLog.h:452
BooleanLogEntry()=default
BooleanLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:459
void Append(bool value, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:469
BooleanLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:457
Log entry base class.
Definition: DataLog.h:373
DataLogEntry(DataLogEntry &&rhs)
Definition: DataLog.h:384
DataLogEntry(const DataLogEntry &)=delete
void Finish(int64_t timestamp=0)
Finishes the entry.
Definition: DataLog.h:414
DataLog * m_log
Definition: DataLog.h:417
DataLogEntry(DataLog &log, std::string_view name, std::string_view type, std::string_view metadata={}, int64_t timestamp=0)
Definition: DataLog.h:376
DataLogEntry & operator=(const DataLogEntry &)=delete
int m_entry
Definition: DataLog.h:418
DataLogEntry & operator=(DataLogEntry &&rhs)
Definition: DataLog.h:387
void SetMetadata(std::string_view metadata, int64_t timestamp=0)
Updates the metadata for the entry.
Definition: DataLog.h:405
A data log.
Definition: DataLog.h:66
void AppendBooleanArray(int entry, std::span< const bool > arr, int64_t timestamp)
Appends a boolean array record to the log.
void AppendBooleanArray(int entry, std::span< const int > arr, int64_t timestamp)
Appends a boolean array record to the log.
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)
Appends a string array record to the log.
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 raw record to the log.
void AppendIntegerArray(int entry, std::span< const int64_t > arr, int64_t timestamp)
Appends an integer array record to the log.
DataLog(const DataLog &)=delete
void AppendBooleanArray(int entry, std::span< const uint8_t > arr, int64_t timestamp)
Appends a boolean array record to the log.
void AppendDouble(int entry, double value, int64_t timestamp)
Appends a double record to the log.
void AppendFloat(int entry, float value, int64_t timestamp)
Appends a float record to the log.
DataLog & operator=(const DataLog &&)=delete
void AppendFloatArray(int entry, std::span< const float > arr, int64_t timestamp)
Appends a float array record to the log.
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)
Appends a string record to the log.
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)
Appends a string array record to the log.
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 raw 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)
Appends a double array record to the log.
void Resume()
Resumes appending of data records to the log.
void AppendInteger(int entry, int64_t value, int64_t timestamp)
Appends an integer record to the log.
void AppendBoolean(int entry, bool value, int64_t timestamp)
Appends a boolean record to the log.
Log array of double values.
Definition: DataLog.h:718
DoubleArrayLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:723
void Append(std::span< const double > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:736
void Append(std::initializer_list< double > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:746
DoubleArrayLogEntry()=default
DoubleArrayLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:726
Log double values.
Definition: DataLog.h:527
DoubleLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:534
void Append(double value, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:544
DoubleLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:532
Log array of float values.
Definition: DataLog.h:683
FloatArrayLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:690
void Append(std::span< const float > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:700
void Append(std::initializer_list< float > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:710
FloatArrayLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:688
FloatArrayLogEntry()=default
Log float values.
Definition: DataLog.h:502
FloatLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:507
FloatLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:509
void Append(float value, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:519
Log array of integer values.
Definition: DataLog.h:647
IntegerArrayLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:655
void Append(std::span< const int64_t > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:665
IntegerArrayLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:652
void Append(std::initializer_list< int64_t > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:675
IntegerArrayLogEntry()=default
Log integer values.
Definition: DataLog.h:477
IntegerLogEntry()=default
IntegerLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:484
IntegerLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:482
void Append(int64_t value, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:494
Log arbitrary byte data.
Definition: DataLog.h:424
RawLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:431
RawLogEntry(DataLog &log, std::string_view name, std::string_view metadata, std::string_view type, int64_t timestamp=0)
Definition: DataLog.h:434
static constexpr std::string_view kDataType
Definition: DataLog.h:426
void Append(std::span< const uint8_t > data, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:444
RawLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:429
Log array of string values.
Definition: DataLog.h:754
void Append(std::initializer_list< std::string_view > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:792
StringArrayLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:762
void Append(std::span< const std::string > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:772
void Append(std::span< const std::string_view > arr, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:782
StringArrayLogEntry()=default
StringArrayLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:759
Log string values.
Definition: DataLog.h:552
StringLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition: DataLog.h:559
void Append(std::string_view value, int64_t timestamp=0)
Appends a record to the log.
Definition: DataLog.h:572
StringLogEntry(DataLog &log, std::string_view name, std::string_view metadata, std::string_view type, int64_t timestamp=0)
Definition: DataLog.h:562
StringLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition: DataLog.h:557
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
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
Definition: AprilTagFieldLayout.h:18
::std::mutex mutex
Definition: mutex.h:17
::std::condition_variable condition_variable
Definition: condition_variable.h:16
Definition: format.h:1552