DIOSim

class wpilib.simulation.DIOSim(*args, **kwargs)

Bases: pybind11_object

Class to control a simulated digital input or output.

Overloaded function.

  1. __init__(self: wpilib.simulation._simulation.DIOSim, input: wpilib._wpilib.DigitalInput) -> None

Constructs from a DigitalInput object.

Parameters:

input – DigitalInput to simulate

  1. __init__(self: wpilib.simulation._simulation.DIOSim, output: wpilib._wpilib.DigitalOutput) -> None

Constructs from a DigitalOutput object.

Parameters:

output – DigitalOutput to simulate

  1. __init__(self: wpilib.simulation._simulation.DIOSim, channel: typing.SupportsInt | typing.SupportsIndex) -> None

Constructs from an digital I/O channel number.

Parameters:

channel – Channel number

get_filter_index() int

Read the filter index.

Returns:

the filter index of this DIO port

get_initialized() bool

Check whether this DIO has been initialized.

Returns:

true if initialized

get_is_input() bool

Check whether this DIO port is currently an Input.

Returns:

true if Input

get_pulse_length() float

Read the pulse length.

Returns:

the pulse length of this DIO port

get_value() bool

Read the value of the DIO port.

Returns:

the DIO value

register_filter_index_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 filter index changes.

Parameters:
  • callback – the callback

  • initial_notify – whether the callback should be called with the initial value

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 DIO 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_is_input_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 this DIO changes to be an input.

Parameters:
  • callback – the callback

  • initial_notify – whether the callback should be called with the initial state

Returns:

the CallbackStore object associated with this callback

register_pulse_length_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 pulse length 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_value_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 DIO value changes.

Parameters:
  • callback – the callback

  • initial_notify – whether the callback should be called with the initial value

Returns:

the CallbackStore object associated with this callback

reset_data() None

Reset all simulation data of this object.

set_filter_index(filter_index: SupportsInt | SupportsIndex) None

Change the filter index of this DIO port.

Parameters:

filter_index – the new filter index

set_initialized(initialized: bool) None

Define whether this DIO has been initialized.

Parameters:

initialized – whether this object is initialized

set_is_input(is_input: bool) None

Define whether this DIO port is an Input.

Parameters:

is_input – whether this DIO should be an Input

set_pulse_length(pulse_length: SupportsFloat | SupportsIndex) None

Change the pulse length of this DIO port.

Parameters:

pulse_length – the new pulse length

set_value(value: bool) None

Change the DIO value.

Parameters:

value – the new value