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

Class to control a simulated duty cycle digital input. More...

#include <frc/simulation/DutyCycleSim.h>

Public Member Functions

 DutyCycleSim (const DutyCycle &dutyCycle)
 Constructs from a DutyCycle object. More...
 
std::unique_ptr< CallbackStoreRegisterInitializedCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run when this duty cycle input is initialized. More...
 
bool GetInitialized () const
 Check whether this duty cycle input has been initialized. More...
 
void SetInitialized (bool initialized)
 Define whether this duty cycle input has been initialized. More...
 
std::unique_ptr< CallbackStoreRegisterFrequencyCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run whenever the frequency changes. More...
 
int GetFrequency () const
 Measure the frequency. More...
 
void SetFrequency (int frequency)
 Change the duty cycle frequency. More...
 
std::unique_ptr< CallbackStoreRegisterOutputCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run whenever the output changes. More...
 
double GetOutput () const
 Measure the output from this duty cycle port. More...
 
void SetOutput (double output)
 Change the duty cycle output. More...
 
void ResetData ()
 Reset all simulation data for the duty cycle output. More...
 

Static Public Member Functions

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

Detailed Description

Class to control a simulated duty cycle digital input.

Constructor & Destructor Documentation

◆ DutyCycleSim()

frc::sim::DutyCycleSim::DutyCycleSim ( const DutyCycle dutyCycle)
explicit

Constructs from a DutyCycle object.

Parameters
dutyCycleDutyCycle to simulate

Member Function Documentation

◆ CreateForChannel()

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

Creates a DutyCycleSim for a digital input channel.

Parameters
channeldigital input channel
Returns
Simulated object
Exceptions
std::out_of_rangeif no DutyCycle is configured for that channel

◆ CreateForIndex()

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

Creates a DutyCycleSim for a simulated index.

The index is incremented for each simulated DutyCycle.

Parameters
indexsimulator index
Returns
Simulated object

◆ GetFrequency()

int frc::sim::DutyCycleSim::GetFrequency ( ) const

Measure the frequency.

Returns
the duty cycle frequency

◆ GetInitialized()

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

Check whether this duty cycle input has been initialized.

Returns
true if initialized

◆ GetOutput()

double frc::sim::DutyCycleSim::GetOutput ( ) const

Measure the output from this duty cycle port.

Returns
the output value

◆ RegisterFrequencyCallback()

std::unique_ptr< CallbackStore > frc::sim::DutyCycleSim::RegisterFrequencyCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback to be run whenever the frequency changes.

Parameters
callbackthe callback
initialNotifywhether to call the callback with the initial state
Returns
the CallbackStore object associated with this callback

◆ RegisterInitializedCallback()

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

Register a callback to be run when this duty cycle input is initialized.

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

◆ RegisterOutputCallback()

std::unique_ptr< CallbackStore > frc::sim::DutyCycleSim::RegisterOutputCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback to be run whenever the output changes.

Parameters
callbackthe callback
initialNotifywhether to call the callback with the initial state
Returns
the CallbackStore object associated with this callback

◆ ResetData()

void frc::sim::DutyCycleSim::ResetData ( )

Reset all simulation data for the duty cycle output.

◆ SetFrequency()

void frc::sim::DutyCycleSim::SetFrequency ( int  frequency)

Change the duty cycle frequency.

Parameters
frequencythe new frequency

◆ SetInitialized()

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

Define whether this duty cycle input has been initialized.

Parameters
initializedwhether this object is initialized

◆ SetOutput()

void frc::sim::DutyCycleSim::SetOutput ( double  output)

Change the duty cycle output.

Parameters
outputthe new output value

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