SimDevice¶
- class hal.SimDevice(*args, **kwargs)¶
Bases:
pybind11_object
Wrapper around a HAL simulation ‘device’
This creates a simulated ‘device’ object that can be interacted with from user SimDeviceSim objects or via the Simulation GUI.
Note
To interact with an existing device use
hal.simulation.SimDeviceSim
instead.Overloaded function.
__init__(self: hal._wpiHal.SimDevice, name: str) -> None
Creates a simulated device.
The device name must be unique. Returns null if the device name already exists. If multiple instances of the same device are desired, recommend appending the instance/unique identifier in brackets to the base name, e.g. “device[1]”.
If not in simulation, results in an “empty” object that evaluates to false in a boolean context.
- Parameters:
name – device name
__init__(self: hal._wpiHal.SimDevice, name: str, index: int) -> None
Creates a simulated device.
The device name must be unique. Returns null if the device name already exists. This is a convenience method that appends index in brackets to the device name, e.g. passing index=1 results in “device[1]” for the device name.
If not in simulation, results in an “empty” object that evaluates to false in a boolean context.
- Parameters:
name – device name
index – device index number to append to name
__init__(self: hal._wpiHal.SimDevice, name: str, index: int, channel: int) -> None
Creates a simulated device.
The device name must be unique. Returns null if the device name already exists. This is a convenience method that appends index and channel in brackets to the device name, e.g. passing index=1 and channel=2 results in “device[1,2]” for the device name.
If not in simulation, results in an “empty” object that evaluates to false in a boolean context.
- Parameters:
name – device name
index – device index number to append to name
channel – device channel number to append to name
- class Direction(value: int)¶
Bases:
pybind11_object
Direction of a simulated value (from the perspective of user code).
Members:
kInput
kOutput
kBidir
- kBidir = <Direction.kBidir: 2>¶
- kInput = <Direction.kInput: 0>¶
- kOutput = <Direction.kOutput: 1>¶
- property name¶
- property value¶
- createBoolean(name: str, direction: int, initialValue: bool) hal._wpiHal.SimBoolean ¶
Creates a boolean value on the simulated device.
If not in simulation, results in an “empty” object that evaluates to false in a boolean context.
- Parameters:
name – value name
direction – input/output/bidir (from perspective of user code)
initialValue – initial value
- Returns:
simulated boolean value object
- createDouble(name: str, direction: int, initialValue: float) hal._wpiHal.SimDouble ¶
Creates a double value on the simulated device.
If not in simulation, results in an “empty” object that evaluates to false in a boolean context.
- Parameters:
name – value name
direction – input/output/bidir (from perspective of user code)
initialValue – initial value
- Returns:
simulated double value object
- createEnum(name: str, direction: int, options: List[str], initialValue: int) hal._wpiHal.SimEnum ¶
Creates an enumerated value on the simulated device.
Enumerated values are always in the range 0 to numOptions-1.
If not in simulation, results in an “empty” object that evaluates to false in a boolean context.
- Parameters:
name – value name
direction – input/output/bidir (from perspective of user code)
options – array of option descriptions
initialValue – initial value (selection)
- Returns:
simulated enum value object
- createEnumDouble(name: str, direction: int, options: List[str], optionValues: List[float], initialValue: int) hal._wpiHal.SimEnum ¶
Creates an enumerated value on the simulated device with double values.
Enumerated values are always in the range 0 to numOptions-1.
If not in simulation, results in an “empty” object that evaluates to false in a boolean context.
- Parameters:
name – value name
direction – input/output/bidir (from perspective of user code)
options – array of option descriptions
optionValues – array of option values (must be the same size as options)
initialValue – initial value (selection)
- Returns:
simulated enum value object
- createInt(name: str, direction: int, initialValue: int) hal._wpiHal.SimInt ¶
Creates an int value on the simulated device.
If not in simulation, results in an “empty” object that evaluates to false in a boolean context.
- Parameters:
name – value name
direction – input/output/bidir (from perspective of user code)
initialValue – initial value
- Returns:
simulated double value object
- createLong(name: str, direction: int, initialValue: int) hal._wpiHal.SimLong ¶
Creates a long value on the simulated device.
If not in simulation, results in an “empty” object that evaluates to false in a boolean context.
- Parameters:
name – value name
direction – input/output/bidir (from perspective of user code)
initialValue – initial value
- Returns:
simulated double value object
- getName() str ¶
Get the name of the simulated device.
- Returns:
name
- property name¶