WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
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.
 
std::unique_ptr< CallbackStoreRegisterInitializedCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run when this duty cycle input is initialized.
 
bool GetInitialized () const
 Check whether this duty cycle input has been initialized.
 
void SetInitialized (bool initialized)
 Define whether this duty cycle input has been initialized.
 
std::unique_ptr< CallbackStoreRegisterFrequencyCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run whenever the frequency changes.
 
int GetFrequency () const
 Measure the frequency.
 
void SetFrequency (int frequency)
 Change the duty cycle frequency.
 
std::unique_ptr< CallbackStoreRegisterOutputCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run whenever the output changes.
 
double GetOutput () const
 Measure the output from this duty cycle port.
 
void SetOutput (double output)
 Change the duty cycle output.
 
void ResetData ()
 Reset all simulation data for the duty cycle output.
 

Static Public Member Functions

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

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
Throws:
std::out_of_range if 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 )
nodiscard

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 )
nodiscard

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 )
nodiscard

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: