WPILibC++ 2024.3.2
frc::sim::EncoderSim Class Reference

Class to control a simulated encoder. More...

#include <frc/simulation/EncoderSim.h>

Public Member Functions

 EncoderSim (const Encoder &encoder)
 Constructs from an Encoder object. More...
 
std::unique_ptr< CallbackStoreRegisterInitializedCallback (NotifyCallback callback, bool initialNotify)
 Register a callback on the Initialized property of the encoder. More...
 
bool GetInitialized () const
 Read the Initialized value of the encoder. More...
 
void SetInitialized (bool initialized)
 Change the Initialized value of the encoder. More...
 
std::unique_ptr< CallbackStoreRegisterCountCallback (NotifyCallback callback, bool initialNotify)
 Register a callback on the count property of the encoder. More...
 
int GetCount () const
 Read the count of the encoder. More...
 
void SetCount (int count)
 Change the count of the encoder. More...
 
std::unique_ptr< CallbackStoreRegisterPeriodCallback (NotifyCallback callback, bool initialNotify)
 Register a callback on the period of the encoder. More...
 
double GetPeriod () const
 Read the period of the encoder. More...
 
void SetPeriod (double period)
 Change the encoder period. More...
 
std::unique_ptr< CallbackStoreRegisterResetCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be called whenever the encoder is reset. More...
 
bool GetReset () const
 Check if the encoder has been reset. More...
 
void SetReset (bool reset)
 Change the reset property of the encoder. More...
 
std::unique_ptr< CallbackStoreRegisterMaxPeriodCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run whenever the max period of the encoder is changed. More...
 
double GetMaxPeriod () const
 Get the max period of the encoder. More...
 
void SetMaxPeriod (double maxPeriod)
 Change the max period of the encoder. More...
 
std::unique_ptr< CallbackStoreRegisterDirectionCallback (NotifyCallback callback, bool initialNotify)
 Register a callback on the direction of the encoder. More...
 
bool GetDirection () const
 Get the direction of the encoder. More...
 
void SetDirection (bool direction)
 Set the direction of the encoder. More...
 
std::unique_ptr< CallbackStoreRegisterReverseDirectionCallback (NotifyCallback callback, bool initialNotify)
 Register a callback on the reverse direction. More...
 
bool GetReverseDirection () const
 Get the reverse direction of the encoder. More...
 
void SetReverseDirection (bool reverseDirection)
 Set the reverse direction. More...
 
std::unique_ptr< CallbackStoreRegisterSamplesToAverageCallback (NotifyCallback callback, bool initialNotify)
 Register a callback on the samples-to-average value of this encoder. More...
 
int GetSamplesToAverage () const
 Get the samples-to-average value. More...
 
void SetSamplesToAverage (int samplesToAverage)
 Set the samples-to-average value. More...
 
std::unique_ptr< CallbackStoreRegisterDistancePerPulseCallback (NotifyCallback callback, bool initialNotify)
 Register a callback on the distance per pulse value of this encoder. More...
 
double GetDistancePerPulse () const
 Read the distance per pulse of the encoder. More...
 
void SetDistancePerPulse (double distancePerPulse)
 Change the encoder distance per pulse. More...
 
void ResetData ()
 Resets all simulation data for this encoder. More...
 
void SetDistance (double distance)
 Change the encoder distance. More...
 
double GetDistance () const
 Read the distance of the encoder. More...
 
void SetRate (double rate)
 Change the rate of the encoder. More...
 
double GetRate () const
 Get the rate of the encoder. More...
 

Static Public Member Functions

static EncoderSim CreateForChannel (int channel)
 Creates an EncoderSim for a digital input channel. More...
 
static EncoderSim CreateForIndex (int index)
 Creates an EncoderSim for a simulated index. More...
 

Detailed Description

Class to control a simulated encoder.

Constructor & Destructor Documentation

◆ EncoderSim()

frc::sim::EncoderSim::EncoderSim ( const Encoder encoder)
explicit

Constructs from an Encoder object.

Parameters
encoderEncoder to simulate

Member Function Documentation

◆ CreateForChannel()

static EncoderSim frc::sim::EncoderSim::CreateForChannel ( int  channel)
static

Creates an EncoderSim for a digital input channel.

Encoders take two channels, so either one may be specified.

Parameters
channeldigital input channel
Returns
Simulated object
Exceptions
NoSuchElementExceptionif no Encoder is configured for that channel

◆ CreateForIndex()

static EncoderSim frc::sim::EncoderSim::CreateForIndex ( int  index)
static

Creates an EncoderSim for a simulated index.

The index is incremented for each simulated Encoder.

Parameters
indexsimulator index
Returns
Simulated object

◆ GetCount()

int frc::sim::EncoderSim::GetCount ( ) const

Read the count of the encoder.

Returns
the count

◆ GetDirection()

bool frc::sim::EncoderSim::GetDirection ( ) const

Get the direction of the encoder.

Returns
the direction of the encoder

◆ GetDistance()

double frc::sim::EncoderSim::GetDistance ( ) const

Read the distance of the encoder.

Returns
the encoder distance

◆ GetDistancePerPulse()

double frc::sim::EncoderSim::GetDistancePerPulse ( ) const

Read the distance per pulse of the encoder.

Returns
the encoder distance per pulse

◆ GetInitialized()

bool frc::sim::EncoderSim::GetInitialized ( ) const

Read the Initialized value of the encoder.

Returns
true if initialized

◆ GetMaxPeriod()

double frc::sim::EncoderSim::GetMaxPeriod ( ) const

Get the max period of the encoder.

Returns
the max period of the encoder

◆ GetPeriod()

double frc::sim::EncoderSim::GetPeriod ( ) const

Read the period of the encoder.

Returns
the encoder period

◆ GetRate()

double frc::sim::EncoderSim::GetRate ( ) const

Get the rate of the encoder.

Returns
the rate of change

◆ GetReset()

bool frc::sim::EncoderSim::GetReset ( ) const

Check if the encoder has been reset.

Returns
true if reset

◆ GetReverseDirection()

bool frc::sim::EncoderSim::GetReverseDirection ( ) const

Get the reverse direction of the encoder.

Returns
the reverse direction of the encoder

◆ GetSamplesToAverage()

int frc::sim::EncoderSim::GetSamplesToAverage ( ) const

Get the samples-to-average value.

Returns
the samples-to-average value

◆ RegisterCountCallback()

std::unique_ptr< CallbackStore > frc::sim::EncoderSim::RegisterCountCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback on the count property of the encoder.

Parameters
callbackthe callback that will be called whenever the count property is changed
initialNotifyif true, the callback will be run on the initial value
Returns
the CallbackStore object associated with this callback

◆ RegisterDirectionCallback()

std::unique_ptr< CallbackStore > frc::sim::EncoderSim::RegisterDirectionCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback on the direction of the encoder.

Parameters
callbackthe callback that will be called whenever the direction is changed
initialNotifyif true, the callback will be run on the initial value
Returns
the CallbackStore object associated with this callback

◆ RegisterDistancePerPulseCallback()

std::unique_ptr< CallbackStore > frc::sim::EncoderSim::RegisterDistancePerPulseCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback on the distance per pulse value of this encoder.

Parameters
callbackthe callback that will be called whenever the distance per pulse is changed
initialNotifyif true, the callback will be run on the initial value
Returns
the CallbackStore object associated with this callback

◆ RegisterInitializedCallback()

std::unique_ptr< CallbackStore > frc::sim::EncoderSim::RegisterInitializedCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback on the Initialized property of the encoder.

Parameters
callbackthe callback that will be called whenever the Initialized property is changed
initialNotifyif true, the callback will be run on the initial value
Returns
the CallbackStore object associated with this callback

◆ RegisterMaxPeriodCallback()

std::unique_ptr< CallbackStore > frc::sim::EncoderSim::RegisterMaxPeriodCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback to be run whenever the max period of the encoder is changed.

Parameters
callbackthe callback
initialNotifywhether to run the callback on the initial value
Returns
the CallbackStore object associated with this callback

◆ RegisterPeriodCallback()

std::unique_ptr< CallbackStore > frc::sim::EncoderSim::RegisterPeriodCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback on the period of the encoder.

Parameters
callbackthe callback that will be called whenever the period is changed
initialNotifyif true, the callback will be run on the initial value
Returns
the CallbackStore object associated with this callback

◆ RegisterResetCallback()

std::unique_ptr< CallbackStore > frc::sim::EncoderSim::RegisterResetCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback to be called whenever the encoder is reset.

Parameters
callbackthe callback
initialNotifywhether to run the callback on the initial value
Returns
the CallbackStore object associated with this callback

◆ RegisterReverseDirectionCallback()

std::unique_ptr< CallbackStore > frc::sim::EncoderSim::RegisterReverseDirectionCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback on the reverse direction.

Parameters
callbackthe callback that will be called whenever the reverse direction is changed
initialNotifyif true, the callback will be run on the initial value
Returns
the CallbackStore object associated with this callback

◆ RegisterSamplesToAverageCallback()

std::unique_ptr< CallbackStore > frc::sim::EncoderSim::RegisterSamplesToAverageCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback on the samples-to-average value of this encoder.

Parameters
callbackthe callback that will be called whenever the samples-to-average is changed
initialNotifyif true, the callback will be run on the initial value
Returns
the CallbackStore object associated with this callback

◆ ResetData()

void frc::sim::EncoderSim::ResetData ( )

Resets all simulation data for this encoder.

◆ SetCount()

void frc::sim::EncoderSim::SetCount ( int  count)

Change the count of the encoder.

Parameters
countthe new count

◆ SetDirection()

void frc::sim::EncoderSim::SetDirection ( bool  direction)

Set the direction of the encoder.

Parameters
directionthe new direction

◆ SetDistance()

void frc::sim::EncoderSim::SetDistance ( double  distance)

Change the encoder distance.

Parameters
distancethe new distance

◆ SetDistancePerPulse()

void frc::sim::EncoderSim::SetDistancePerPulse ( double  distancePerPulse)

Change the encoder distance per pulse.

Parameters
distancePerPulsethe new distance per pulse

◆ SetInitialized()

void frc::sim::EncoderSim::SetInitialized ( bool  initialized)

Change the Initialized value of the encoder.

Parameters
initializedthe new value

◆ SetMaxPeriod()

void frc::sim::EncoderSim::SetMaxPeriod ( double  maxPeriod)

Change the max period of the encoder.

Parameters
maxPeriodthe new value

◆ SetPeriod()

void frc::sim::EncoderSim::SetPeriod ( double  period)

Change the encoder period.

Parameters
periodthe new period

◆ SetRate()

void frc::sim::EncoderSim::SetRate ( double  rate)

Change the rate of the encoder.

Parameters
ratethe new rate

◆ SetReset()

void frc::sim::EncoderSim::SetReset ( bool  reset)

Change the reset property of the encoder.

Parameters
resetthe new value

◆ SetReverseDirection()

void frc::sim::EncoderSim::SetReverseDirection ( bool  reverseDirection)

Set the reverse direction.

Parameters
reverseDirectionthe new value

◆ SetSamplesToAverage()

void frc::sim::EncoderSim::SetSamplesToAverage ( int  samplesToAverage)

Set the samples-to-average value.

Parameters
samplesToAveragethe new value

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