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: int) wpilib.simulation._simulation.DutyCycleSim

Creates a DutyCycleSim for a digital input channel.

Parameters:

channel – digital input channel

Returns:

Simulated object @throws std::out_of_range if no DutyCycle is configured for that channel

static createForIndex(index: int) wpilib.simulation._simulation.DutyCycleSim

Creates a DutyCycleSim for a simulated index. The index is incremented for each simulated DutyCycle.

Parameters:

index – simulator index

Returns:

Simulated object

getFrequency() int

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: Callable[[str, HAL_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: Callable[[str, HAL_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: Callable[[str, HAL_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: int) 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: float) None

Change the duty cycle output.

Parameters:

output – the new output value