WPILibC++ 2023.4.3
frc::sim::PWMSim Class Reference

Class to control a simulated PWM output. More...

#include <frc/simulation/PWMSim.h>

Public Member Functions

 PWMSim (const PWM &pwm)
 Constructs from a PWM object. More...
 
 PWMSim (const PWMMotorController &motorctrl)
 Constructs from a PWMMotorController object. More...
 
 PWMSim (int channel)
 Constructs from a PWM channel number. More...
 
std::unique_ptr< CallbackStoreRegisterInitializedCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run when the PWM is initialized. More...
 
bool GetInitialized () const
 Check whether the PWM has been initialized. More...
 
void SetInitialized (bool initialized)
 Define whether the PWM has been initialized. More...
 
std::unique_ptr< CallbackStoreRegisterRawValueCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run when the PWM raw value changes. More...
 
int GetRawValue () const
 Get the PWM raw value. More...
 
void SetRawValue (int rawValue)
 Set the PWM raw value. More...
 
std::unique_ptr< CallbackStoreRegisterSpeedCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run when the PWM speed changes. More...
 
double GetSpeed () const
 Get the PWM speed. More...
 
void SetSpeed (double speed)
 Set the PWM speed. More...
 
std::unique_ptr< CallbackStoreRegisterPositionCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run when the PWM position changes. More...
 
double GetPosition () const
 Get the PWM position. More...
 
void SetPosition (double position)
 Set the PWM position. More...
 
std::unique_ptr< CallbackStoreRegisterPeriodScaleCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run when the PWM period scale changes. More...
 
int GetPeriodScale () const
 Get the PWM period scale. More...
 
void SetPeriodScale (int periodScale)
 Set the PWM period scale. More...
 
std::unique_ptr< CallbackStoreRegisterZeroLatchCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run when the PWM zero latch state changes. More...
 
bool GetZeroLatch () const
 Check whether the PWM is zero latched. More...
 
void SetZeroLatch (bool zeroLatch)
 Define whether the PWM has been zero latched. More...
 
void ResetData ()
 Reset all simulation data. More...
 

Detailed Description

Class to control a simulated PWM output.

Constructor & Destructor Documentation

◆ PWMSim() [1/3]

frc::sim::PWMSim::PWMSim ( const PWM pwm)
explicit

Constructs from a PWM object.

Parameters
pwmPWM to simulate

◆ PWMSim() [2/3]

frc::sim::PWMSim::PWMSim ( const PWMMotorController motorctrl)
explicit

Constructs from a PWMMotorController object.

Parameters
motorctrlPWMMotorController to simulate

◆ PWMSim() [3/3]

frc::sim::PWMSim::PWMSim ( int  channel)
explicit

Constructs from a PWM channel number.

Parameters
channelChannel number

Member Function Documentation

◆ GetInitialized()

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

Check whether the PWM has been initialized.

Returns
true if initialized

◆ GetPeriodScale()

int frc::sim::PWMSim::GetPeriodScale ( ) const

Get the PWM period scale.

Returns
the PWM period scale

◆ GetPosition()

double frc::sim::PWMSim::GetPosition ( ) const

Get the PWM position.

Returns
the PWM position (0.0 to 1.0)

◆ GetRawValue()

int frc::sim::PWMSim::GetRawValue ( ) const

Get the PWM raw value.

Returns
the PWM raw value

◆ GetSpeed()

double frc::sim::PWMSim::GetSpeed ( ) const

Get the PWM speed.

Returns
the PWM speed (-1.0 to 1.0)

◆ GetZeroLatch()

bool frc::sim::PWMSim::GetZeroLatch ( ) const

Check whether the PWM is zero latched.

Returns
true if zero latched

◆ RegisterInitializedCallback()

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

Register a callback to be run when the PWM is initialized.

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

◆ RegisterPeriodScaleCallback()

std::unique_ptr< CallbackStore > frc::sim::PWMSim::RegisterPeriodScaleCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback to be run when the PWM period scale changes.

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

◆ RegisterPositionCallback()

std::unique_ptr< CallbackStore > frc::sim::PWMSim::RegisterPositionCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback to be run when the PWM position changes.

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

◆ RegisterRawValueCallback()

std::unique_ptr< CallbackStore > frc::sim::PWMSim::RegisterRawValueCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback to be run when the PWM raw value changes.

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

◆ RegisterSpeedCallback()

std::unique_ptr< CallbackStore > frc::sim::PWMSim::RegisterSpeedCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback to be run when the PWM speed changes.

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

◆ RegisterZeroLatchCallback()

std::unique_ptr< CallbackStore > frc::sim::PWMSim::RegisterZeroLatchCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback to be run when the PWM zero latch state changes.

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

◆ ResetData()

void frc::sim::PWMSim::ResetData ( )

Reset all simulation data.

◆ SetInitialized()

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

Define whether the PWM has been initialized.

Parameters
initializedwhether this object is initialized

◆ SetPeriodScale()

void frc::sim::PWMSim::SetPeriodScale ( int  periodScale)

Set the PWM period scale.

Parameters
periodScalethe PWM period scale

◆ SetPosition()

void frc::sim::PWMSim::SetPosition ( double  position)

Set the PWM position.

Parameters
positionthe PWM position (0.0 to 1.0)

◆ SetRawValue()

void frc::sim::PWMSim::SetRawValue ( int  rawValue)

Set the PWM raw value.

Parameters
rawValuethe PWM raw value

◆ SetSpeed()

void frc::sim::PWMSim::SetSpeed ( double  speed)

Set the PWM speed.

Parameters
speedthe PWM speed (-1.0 to 1.0)

◆ SetZeroLatch()

void frc::sim::PWMSim::SetZeroLatch ( bool  zeroLatch)

Define whether the PWM has been zero latched.

Parameters
zeroLatchtrue to indicate zero latched

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