2022-Robot
Robot code for 2022 FRC Season by Argos, FRC team #1756
Loading...
Searching...
No Matches
argos_lib::NTSubscriber Class Reference

Subscribes to Network Tables entry updates and calls a specified callback to use the new value. More...

#include <nt_subscriber.h>

Public Member Functions

 NTSubscriber (const std::string &tableName)
 Construct a new NTSubscriber object. More...
 
void AddMonitor (const std::string &keyName, std::function< void(double)> onUpdateCallback, const double defaultValue=0.0, const bool forceUpdate=true)
 Register a new listener for the specified key and send values to callback on update. More...
 

Private Attributes

std::shared_ptr< nt::NetworkTable > m_pntTable
 Table with monitored keys. More...
 

Detailed Description

Subscribes to Network Tables entry updates and calls a specified callback to use the new value.

Constructor & Destructor Documentation

◆ NTSubscriber()

NTSubscriber::NTSubscriber ( const std::string &  tableName)
explicit

Construct a new NTSubscriber object.

Parameters
tableNameName of the table containing keys to watch

Member Function Documentation

◆ AddMonitor()

void NTSubscriber::AddMonitor ( const std::string &  keyName,
std::function< void(double)>  onUpdateCallback,
const double  defaultValue = 0.0,
const bool  forceUpdate = true 
)

Register a new listener for the specified key and send values to callback on update.

Parameters
keyNameKey to listen for updates. Will be at tableName/keyName (keyName can have more slashes)
onUpdateCallbackCallback to run when keyName changes
defaultValueDefault value to initialize key if it doesn't exist yet
forceUpdateWhen true, update network tables value to default even if another value is already set

Member Data Documentation

◆ m_pntTable

std::shared_ptr<nt::NetworkTable> argos_lib::NTSubscriber::m_pntTable
private

Table with monitored keys.


The documentation for this class was generated from the following files: