DutyCycleSim

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

Bases: pybind11_object

Class to control a simulated duty cycle digital input.

Constructs from a DutyCycle object.

Parameters:

duty_cycle – DutyCycle to simulate

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

Creates a DutyCycleSim for a SmartIO channel.

Parameters:

channel – SmartIO channel

Returns:

Simulated object

get_frequency() wpimath.units.hertz

Measure the frequency.

Returns:

the duty cycle frequency

get_initialized() bool

Check whether this duty cycle input has been initialized.

Returns:

true if initialized

get_output() float

Measure the output from this duty cycle port.

Returns:

the output value

register_frequency_callback(callback: collections.abc.Callable[[str, hal._wpi_hal.Value], None], initial_notify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback to be run whenever the frequency changes.

Parameters:
  • callback – the callback

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

Returns:

the CallbackStore object associated with this callback

register_initialized_callback(callback: collections.abc.Callable[[str, hal._wpi_hal.Value], None], initial_notify: bool) wpilib.simulation._simulation.CallbackStore

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

Parameters:
  • callback – the callback

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

Returns:

the CallbackStore object associated with this callback

register_output_callback(callback: collections.abc.Callable[[str, hal._wpi_hal.Value], None], initial_notify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback to be run whenever the output changes.

Parameters:
  • callback – the callback

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

Returns:

the CallbackStore object associated with this callback

reset_data() None

Reset all simulation data for the duty cycle output.

set_frequency(frequency: wpimath.units.hertz) None

Change the duty cycle frequency.

Parameters:

frequency – the new frequency

set_initialized(initialized: bool) None

Define whether this duty cycle input has been initialized.

Parameters:

initialized – whether this object is initialized

set_output(output: SupportsFloat | SupportsIndex) None

Change the duty cycle output.

Parameters:

output – the new output value