mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
[ntcore] Add DataLog support
This commit is contained in:
@@ -505,6 +505,52 @@ class NetworkTableInstance final {
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @name Data Logger Functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* Starts logging entry changes to a DataLog.
|
||||
*
|
||||
* @param log data log object; lifetime must extend until StopEntryDataLog is
|
||||
* called or the instance is destroyed
|
||||
* @param prefix only store entries with names that start with this prefix;
|
||||
* the prefix is not included in the data log entry name
|
||||
* @param logPrefix prefix to add to data log entry names
|
||||
* @return Data logger handle
|
||||
*/
|
||||
NT_DataLogger StartEntryDataLog(wpi::log::DataLog& log,
|
||||
std::string_view prefix,
|
||||
std::string_view logPrefix);
|
||||
|
||||
/**
|
||||
* Stops logging entry changes to a DataLog.
|
||||
*
|
||||
* @param logger data logger handle
|
||||
*/
|
||||
static void StopEntryDataLog(NT_DataLogger logger);
|
||||
|
||||
/**
|
||||
* Starts logging connection changes to a DataLog.
|
||||
*
|
||||
* @param log data log object; lifetime must extend until
|
||||
* StopConnectionDataLog is called or the instance is destroyed
|
||||
* @param name data log entry name
|
||||
* @return Data logger handle
|
||||
*/
|
||||
NT_ConnectionDataLogger StartConnectionDataLog(wpi::log::DataLog& log,
|
||||
std::string_view name);
|
||||
|
||||
/**
|
||||
* Stops logging connection changes to a DataLog.
|
||||
*
|
||||
* @param logger data logger handle
|
||||
*/
|
||||
static void StopConnectionDataLog(NT_ConnectionDataLogger logger);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @name Logger Functions
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "networktables/NetworkTableInstance.h"
|
||||
#include "ntcore_cpp.h"
|
||||
|
||||
namespace nt {
|
||||
|
||||
@@ -192,6 +193,26 @@ inline const char* NetworkTableInstance::LoadEntries(
|
||||
return ::nt::LoadEntries(m_handle, filename, prefix, warn);
|
||||
}
|
||||
|
||||
inline NT_DataLogger NetworkTableInstance::StartEntryDataLog(
|
||||
wpi::log::DataLog& log, std::string_view prefix,
|
||||
std::string_view logPrefix) {
|
||||
return ::nt::StartEntryDataLog(m_handle, log, prefix, logPrefix);
|
||||
}
|
||||
|
||||
inline void NetworkTableInstance::StopEntryDataLog(NT_DataLogger logger) {
|
||||
::nt::StopEntryDataLog(logger);
|
||||
}
|
||||
|
||||
inline NT_ConnectionDataLogger NetworkTableInstance::StartConnectionDataLog(
|
||||
wpi::log::DataLog& log, std::string_view name) {
|
||||
return ::nt::StartConnectionDataLog(m_handle, log, name);
|
||||
}
|
||||
|
||||
inline void NetworkTableInstance::StopConnectionDataLog(
|
||||
NT_ConnectionDataLogger logger) {
|
||||
::nt::StopConnectionDataLog(logger);
|
||||
}
|
||||
|
||||
inline NT_Logger NetworkTableInstance::AddLogger(
|
||||
std::function<void(const LogMessage& msg)> func, unsigned int min_level,
|
||||
unsigned int max_level) {
|
||||
|
||||
@@ -29,8 +29,10 @@ extern "C" {
|
||||
typedef int NT_Bool;
|
||||
|
||||
typedef unsigned int NT_Handle;
|
||||
typedef NT_Handle NT_ConnectionDataLogger;
|
||||
typedef NT_Handle NT_ConnectionListener;
|
||||
typedef NT_Handle NT_ConnectionListenerPoller;
|
||||
typedef NT_Handle NT_DataLogger;
|
||||
typedef NT_Handle NT_Entry;
|
||||
typedef NT_Handle NT_EntryListener;
|
||||
typedef NT_Handle NT_EntryListenerPoller;
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
|
||||
#include "networktables/NetworkTableValue.h"
|
||||
|
||||
namespace wpi::log {
|
||||
class DataLog;
|
||||
} // namespace wpi::log
|
||||
|
||||
/** NetworkTables (ntcore) namespace */
|
||||
namespace nt {
|
||||
|
||||
@@ -1233,6 +1237,55 @@ uint64_t Now();
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup ntcore_data_logger_func Data Logger Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Starts logging entry changes to a DataLog.
|
||||
*
|
||||
* @param inst instance handle
|
||||
* @param log data log object; lifetime must extend until StopEntryDataLog is
|
||||
* called or the instance is destroyed
|
||||
* @param prefix only store entries with names that start with this prefix;
|
||||
* the prefix is not included in the data log entry name
|
||||
* @param logPrefix prefix to add to data log entry names
|
||||
* @return Data logger handle
|
||||
*/
|
||||
NT_DataLogger StartEntryDataLog(NT_Inst inst, wpi::log::DataLog& log,
|
||||
std::string_view prefix,
|
||||
std::string_view logPrefix);
|
||||
|
||||
/**
|
||||
* Stops logging entry changes to a DataLog.
|
||||
*
|
||||
* @param logger data logger handle
|
||||
*/
|
||||
void StopEntryDataLog(NT_DataLogger logger);
|
||||
|
||||
/**
|
||||
* Starts logging connection changes to a DataLog.
|
||||
*
|
||||
* @param inst instance handle
|
||||
* @param log data log object; lifetime must extend until StopConnectionDataLog
|
||||
* is called or the instance is destroyed
|
||||
* @param name data log entry name
|
||||
* @return Data logger handle
|
||||
*/
|
||||
NT_ConnectionDataLogger StartConnectionDataLog(NT_Inst inst,
|
||||
wpi::log::DataLog& log,
|
||||
std::string_view name);
|
||||
|
||||
/**
|
||||
* Stops logging connection changes to a DataLog.
|
||||
*
|
||||
* @param logger data logger handle
|
||||
*/
|
||||
void StopConnectionDataLog(NT_ConnectionDataLogger logger);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup ntcore_logger_func Logger Functions
|
||||
* @{
|
||||
|
||||
Reference in New Issue
Block a user