YAMS
Yet Another Mechanism System
Loading...
Searching...
No Matches
Public Member Functions | List of all members
yams::telemetry::StructTelemetry< T, F > Class Template Reference

#include <StructTelemetry.hpp>

Public Member Functions

 StructTelemetry (std::string key, T defaultVal, F field, bool tunable)
 
void SetDefaultValue (T value)
 
void SetupNetworkTables (std::shared_ptr< wpi::nt::NetworkTable > dataTable, std::shared_ptr< wpi::nt::NetworkTable > tuningTable)
 
void SetupNetworkTable (std::shared_ptr< wpi::nt::NetworkTable > dataTable)
 
void SetupDataLog (const std::string &prefix)
 
bool Set (const T &value)
 
T Get () const
 
bool IsTunable ()
 
void Enable ()
 
void Disable ()
 
void Display (bool state)
 
F GetField () const
 
bool IsEnabled () const
 
void Close ()
 

Detailed Description

template<typename T, typename F>
class yams::telemetry::StructTelemetry< T, F >

NT4 pub/sub wrapper for a single struct-encoded telemetry field.

Mirrors DoubleTelemetry/BooleanTelemetry, but is generic over both the published value type T (must satisfy wpi::StructSerializable) and the enum type F identifying which field this entry represents, so the same wrapper can be reused across unrelated telemetry coordinators (e.g. SwerveDriveTelemetry, SwerveModuleTelemetry) each with their own field enum.

Template Parameters
TStruct-serializable value type being published.
FEnum type identifying which field this telemetry entry represents.

Constructor & Destructor Documentation

◆ StructTelemetry()

template<typename T , typename F >
yams::telemetry::StructTelemetry< T, F >::StructTelemetry ( std::string  key,
T  defaultVal,
F  field,
bool  tunable 
)
inline

Construct a StructTelemetry entry.

Parameters
keyNT4 table key for this field.
defaultValDefault value published on startup.
fieldField identifier.
tunabletrue if the field should be placed in the tuning table with a subscriber.

Member Function Documentation

◆ Close()

template<typename T , typename F >
void yams::telemetry::StructTelemetry< T, F >::Close ( )
inline

Release all NT4 publishers/subscribers and DataLog entries.

◆ Disable()

template<typename T , typename F >
void yams::telemetry::StructTelemetry< T, F >::Disable ( )
inline

Disable this field so publishing and reading are skipped.

◆ Display()

template<typename T , typename F >
void yams::telemetry::StructTelemetry< T, F >::Display ( bool  state)
inline

Enable or disable this field.

Parameters
statetrue to enable.

◆ Enable()

template<typename T , typename F >
void yams::telemetry::StructTelemetry< T, F >::Enable ( )
inline

Enable this field so it is published / read each loop.

◆ Get()

template<typename T , typename F >
T yams::telemetry::StructTelemetry< T, F >::Get ( ) const
inline

Read the current value from the subscriber (tunable) or return the default.

Returns
Current field value.

◆ GetField()

template<typename T , typename F >
F yams::telemetry::StructTelemetry< T, F >::GetField ( ) const
inline
Returns
The field identifier for this entry.

◆ IsEnabled()

template<typename T , typename F >
bool yams::telemetry::StructTelemetry< T, F >::IsEnabled ( ) const
inline
Returns
true if this field is currently enabled.

◆ IsTunable()

template<typename T , typename F >
bool yams::telemetry::StructTelemetry< T, F >::IsTunable ( )
inline

Return true if a tunable subscriber is active and the value has changed since the last call.

Returns
true when the NT4 subscriber holds a value different from the cached value.

◆ Set()

template<typename T , typename F >
bool yams::telemetry::StructTelemetry< T, F >::Set ( const T &  value)
inline

Publish a value; returns false if the field is disabled or a tunable subscriber disagrees.

Parameters
valueValue to publish.
Returns
true if the value was accepted and published.

◆ SetDefaultValue()

template<typename T , typename F >
void yams::telemetry::StructTelemetry< T, F >::SetDefaultValue ( T  value)
inline

Override the default published value.

Parameters
valueNew default value.

◆ SetupDataLog()

template<typename T , typename F >
void yams::telemetry::StructTelemetry< T, F >::SetupDataLog ( const std::string &  prefix)
inline

Create a DataLog entry under the given prefix path.

Parameters
prefixDataLog path prefix (a trailing "/" is added if missing).

◆ SetupNetworkTable()

template<typename T , typename F >
void yams::telemetry::StructTelemetry< T, F >::SetupNetworkTable ( std::shared_ptr< wpi::nt::NetworkTable >  dataTable)
inline

Create a read-only NT4 publisher under the data table (no tuning table).

Parameters
dataTableNT4 table for sensor data.

◆ SetupNetworkTables()

template<typename T , typename F >
void yams::telemetry::StructTelemetry< T, F >::SetupNetworkTables ( std::shared_ptr< wpi::nt::NetworkTable >  dataTable,
std::shared_ptr< wpi::nt::NetworkTable >  tuningTable 
)
inline

Create the NT4 publisher (and subscriber if tunable) under the given tables.

Parameters
dataTableNT4 table for read-only sensor data.
tuningTableNT4 table for live-tunable fields.

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