DutyCycleSim

class wpilib.simulation.DutyCycleSim(dutyCycle: wpilib._wpilib.DutyCycle)

Bases: pybind11_object

Class to control a simulated duty cycle digital input.

Constructs from a DutyCycle object.

Parameters:

dutyCycle – DutyCycle to simulate

static createForChannel(channel: SupportsInt | SupportsIndex) wpilib.simulation._simulation.DutyCycleSim

Creates a DutyCycleSim for a SmartIO channel.

Parameters:

channel – SmartIO channel

Returns:

Simulated object

getFrequency() wpimath.units.hertz

Measure the frequency.

Returns:

the duty cycle frequency

getInitialized() bool

Check whether this duty cycle input has been initialized.

Returns:

true if initialized

getOutput() float

Measure the output from this duty cycle port.

Returns:

the output value

registerFrequencyCallback(callback: collections.abc.Callable[[str, hal._wpiHal.Value], None], initialNotify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback to be run whenever the frequency changes.

Parameters:
  • callback – the callback

  • initialNotify – whether to call the callback with the initial state

Returns:

the CallbackStore object associated with this callback

registerInitializedCallback(callback: collections.abc.Callable[[str, hal._wpiHal.Value], None], initialNotify: bool) wpilib.simulation._simulation.CallbackStore

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

Parameters:
  • callback – the callback

  • initialNotify – whether to run the callback with the initial state

Returns:

the CallbackStore object associated with this callback

registerOutputCallback(callback: collections.abc.Callable[[str, hal._wpiHal.Value], None], initialNotify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback to be run whenever the output changes.

Parameters:
  • callback – the callback

  • initialNotify – whether to call the callback with the initial state

Returns:

the CallbackStore object associated with this callback

resetData() None

Reset all simulation data for the duty cycle output.

setFrequency(frequency: wpimath.units.hertz) None

Change the duty cycle frequency.

Parameters:

frequency – the new frequency

setInitialized(initialized: bool) None

Define whether this duty cycle input has been initialized.

Parameters:

initialized – whether this object is initialized

setOutput(output: SupportsFloat | SupportsIndex) None

Change the duty cycle output.

Parameters:

output – the new output value