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

Class to control a simulated digital input or output. More...

#include <frc/simulation/DIOSim.h>

Public Member Functions

 DIOSim (const DigitalInput &input)
 Constructs from a DigitalInput object. More...
 
 DIOSim (const DigitalOutput &output)
 Constructs from a DigitalOutput object. More...
 
 DIOSim (int channel)
 Constructs from an digital I/O channel number. More...
 
std::unique_ptr< CallbackStoreRegisterInitializedCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run when this DIO is initialized. More...
 
bool GetInitialized () const
 Check whether this DIO has been initialized. More...
 
void SetInitialized (bool initialized)
 Define whether this DIO has been initialized. More...
 
std::unique_ptr< CallbackStoreRegisterValueCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run whenever the DIO value changes. More...
 
bool GetValue () const
 Read the value of the DIO port. More...
 
void SetValue (bool value)
 Change the DIO value. More...
 
std::unique_ptr< CallbackStoreRegisterPulseLengthCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run whenever the pulse length changes. More...
 
double GetPulseLength () const
 Read the pulse length. More...
 
void SetPulseLength (double pulseLength)
 Change the pulse length of this DIO port. More...
 
std::unique_ptr< CallbackStoreRegisterIsInputCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run whenever this DIO changes to be an input. More...
 
bool GetIsInput () const
 Check whether this DIO port is currently an Input. More...
 
void SetIsInput (bool isInput)
 Define whether this DIO port is an Input. More...
 
std::unique_ptr< CallbackStoreRegisterFilterIndexCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run whenever the filter index changes. More...
 
int GetFilterIndex () const
 Read the filter index. More...
 
void SetFilterIndex (int filterIndex)
 Change the filter index of this DIO port. More...
 
void ResetData ()
 Reset all simulation data of this object. More...
 

Detailed Description

Class to control a simulated digital input or output.

Constructor & Destructor Documentation

◆ DIOSim() [1/3]

frc::sim::DIOSim::DIOSim ( const DigitalInput input)
explicit

Constructs from a DigitalInput object.

Parameters
inputDigitalInput to simulate

◆ DIOSim() [2/3]

frc::sim::DIOSim::DIOSim ( const DigitalOutput output)
explicit

Constructs from a DigitalOutput object.

Parameters
outputDigitalOutput to simulate

◆ DIOSim() [3/3]

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

Constructs from an digital I/O channel number.

Parameters
channelChannel number

Member Function Documentation

◆ GetFilterIndex()

int frc::sim::DIOSim::GetFilterIndex ( ) const

Read the filter index.

Returns
the filter index of this DIO port

◆ GetInitialized()

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

Check whether this DIO has been initialized.

Returns
true if initialized

◆ GetIsInput()

bool frc::sim::DIOSim::GetIsInput ( ) const

Check whether this DIO port is currently an Input.

Returns
true if Input

◆ GetPulseLength()

double frc::sim::DIOSim::GetPulseLength ( ) const

Read the pulse length.

Returns
the pulse length of this DIO port

◆ GetValue()

bool frc::sim::DIOSim::GetValue ( ) const

Read the value of the DIO port.

Returns
the DIO value

◆ RegisterFilterIndexCallback()

std::unique_ptr< CallbackStore > frc::sim::DIOSim::RegisterFilterIndexCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback to be run whenever the filter index changes.

Parameters
callbackthe callback
initialNotifywhether the callback should be called with the initial value
Returns
the CallbackStore object associated with this callback

◆ RegisterInitializedCallback()

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

Register a callback to be run when this DIO is initialized.

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

◆ RegisterIsInputCallback()

std::unique_ptr< CallbackStore > frc::sim::DIOSim::RegisterIsInputCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback to be run whenever this DIO changes to be an input.

Parameters
callbackthe callback
initialNotifywhether the callback should be called with the initial state
Returns
the CallbackStore object associated with this callback

◆ RegisterPulseLengthCallback()

std::unique_ptr< CallbackStore > frc::sim::DIOSim::RegisterPulseLengthCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback to be run whenever the pulse length changes.

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

◆ RegisterValueCallback()

std::unique_ptr< CallbackStore > frc::sim::DIOSim::RegisterValueCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback to be run whenever the DIO value changes.

Parameters
callbackthe callback
initialNotifywhether the callback should be called with the initial value
Returns
the CallbackStore object associated with this callback

◆ ResetData()

void frc::sim::DIOSim::ResetData ( )

Reset all simulation data of this object.

◆ SetFilterIndex()

void frc::sim::DIOSim::SetFilterIndex ( int  filterIndex)

Change the filter index of this DIO port.

Parameters
filterIndexthe new filter index

◆ SetInitialized()

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

Define whether this DIO has been initialized.

Parameters
initializedwhether this object is initialized

◆ SetIsInput()

void frc::sim::DIOSim::SetIsInput ( bool  isInput)

Define whether this DIO port is an Input.

Parameters
isInputwhether this DIO should be an Input

◆ SetPulseLength()

void frc::sim::DIOSim::SetPulseLength ( double  pulseLength)

Change the pulse length of this DIO port.

Parameters
pulseLengththe new pulse length

◆ SetValue()

void frc::sim::DIOSim::SetValue ( bool  value)

Change the DIO value.

Parameters
valuethe new value

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