SimDevice
- class hal.SimDevice(*args, **kwargs)
Bases:
pybind11_objectWrapper 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.SimDeviceSiminstead.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]”.
Using a device name of the form “Type:Name” will create a WebSockets node with a type value of “Type” and a device value of “Name”
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: typing.SupportsInt | typing.SupportsIndex) -> 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.
Using a device name of the form “Type:Name” will create a WebSockets node with a type value of “Type” and a device value of “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: typing.SupportsInt | typing.SupportsIndex, channel: typing.SupportsInt | typing.SupportsIndex) -> 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.
Using a device name of the form “Type:Name” will create a WebSockets node with a type value of “Type” and a device value of “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: SupportsInt | SupportsIndex)
Bases:
pybind11_objectDirection of a simulated value (from the perspective of user code).
Members:
INPUT
OUTPUT
BIDIR
- BIDIR = <Direction.BIDIR: 2>
- INPUT = <Direction.INPUT: 0>
- OUTPUT = <Direction.OUTPUT: 1>
- SimDevice.Direction.name -> str
- property value
- createBoolean(name: str, direction: hal._wpiHal.SimDevice.Direction, 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: hal._wpiHal.SimDevice.Direction, initialValue: SupportsFloat | SupportsIndex) 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: hal._wpiHal.SimDevice.Direction, options: collections.abc.Sequence[str], initialValue: SupportsInt | SupportsIndex) 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: hal._wpiHal.SimDevice.Direction, options: collections.abc.Sequence[str], optionValues: collections.abc.Sequence[SupportsFloat | SupportsIndex], initialValue: SupportsInt | SupportsIndex) 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: hal._wpiHal.SimDevice.Direction, initialValue: SupportsInt | SupportsIndex) 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: hal._wpiHal.SimDevice.Direction, initialValue: SupportsInt | SupportsIndex) 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