WPILibC++ 2023.4.3-108-ge5452e3
|
A move-only C++ wrapper around a HAL simulator device handle. More...
#include <hal/SimDevice.h>
Public Types | |
enum | Direction { kInput = HAL_SimValueInput , kOutput = HAL_SimValueOutput , kBidir = HAL_SimValueBidir } |
Direction of a simulated value (from the perspective of user code). More... | |
Public Member Functions | |
SimDevice ()=default | |
Default constructor that results in an "empty" object that is false in a boolean context. More... | |
SimDevice (const char *name) | |
Creates a simulated device. More... | |
SimDevice (const char *name, int index) | |
Creates a simulated device. More... | |
SimDevice (const char *name, int index, int channel) | |
Creates a simulated device. More... | |
~SimDevice () | |
SimDevice (const SimDevice &)=delete | |
SimDevice & | operator= (const SimDevice &)=delete |
SimDevice (SimDevice &&rhs) | |
SimDevice & | operator= (SimDevice &&rhs) |
operator bool () const | |
Determine if handle is empty. More... | |
operator HAL_SimDeviceHandle () const | |
Get the internal device handle. More... | |
std::string | GetName () const |
Get the name of the simulated device. More... | |
SimValue | CreateValue (const char *name, int32_t direction, const HAL_Value &initialValue) |
Creates a value on the simulated device. More... | |
SimInt | CreateInt (const char *name, int32_t direction, int32_t initialValue) |
Creates an int value on the simulated device. More... | |
SimLong | CreateLong (const char *name, int32_t direction, int64_t initialValue) |
Creates a long value on the simulated device. More... | |
SimDouble | CreateDouble (const char *name, int32_t direction, double initialValue) |
Creates a double value on the simulated device. More... | |
SimEnum | CreateEnum (const char *name, int32_t direction, std::initializer_list< const char * > options, int32_t initialValue) |
Creates an enumerated value on the simulated device. More... | |
SimEnum | CreateEnum (const char *name, int32_t direction, std::span< const char *const > options, int32_t initialValue) |
Creates an enumerated value on the simulated device. More... | |
SimEnum | CreateEnumDouble (const char *name, int32_t direction, std::initializer_list< const char * > options, std::initializer_list< double > optionValues, int32_t initialValue) |
Creates an enumerated value on the simulated device with double values. More... | |
SimEnum | CreateEnumDouble (const char *name, int32_t direction, std::span< const char *const > options, std::span< const double > optionValues, int32_t initialValue) |
Creates an enumerated value on the simulated device with double values. More... | |
SimBoolean | CreateBoolean (const char *name, int32_t direction, bool initialValue) |
Creates a boolean value on the simulated device. More... | |
Protected Attributes | |
HAL_SimDeviceHandle | m_handle = HAL_kInvalidHandle |
A move-only C++ wrapper around a HAL simulator device handle.
|
default |
Default constructor that results in an "empty" object that is false in a boolean context.
|
inlineexplicit |
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.
name | device name |
hal::SimDevice::SimDevice | ( | const char * | name, |
int | index | ||
) |
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.
name | device name |
index | device index number to append to name |
hal::SimDevice::SimDevice | ( | const char * | name, |
int | index, | ||
int | channel | ||
) |
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.
name | device name |
index | device index number to append to name |
channel | device channel number to append to name |
|
inline |
|
delete |
|
inline |
|
inline |
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.
name | value name |
direction | input/output/bidir (from perspective of user code) |
initialValue | initial value |
|
inline |
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.
name | value name |
direction | input/output/bidir (from perspective of user code) |
initialValue | initial value |
|
inline |
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.
name | value name |
direction | input/output/bidir (from perspective of user code) |
options | array of option descriptions |
initialValue | initial value (selection) |
|
inline |
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.
name | value name |
direction | input/output/bidir (from perspective of user code) |
options | array of option descriptions |
initialValue | initial value (selection) |
|
inline |
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.
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) |
|
inline |
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.
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) |
|
inline |
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.
name | value name |
direction | input/output/bidir (from perspective of user code) |
initialValue | initial value |
|
inline |
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.
name | value name |
direction | input/output/bidir (from perspective of user code) |
initialValue | initial value |
|
inline |
Creates a value on the simulated device.
If not in simulation, results in an "empty" object that evaluates to false in a boolean context.
name | value name |
direction | input/output/bidir (from perspective of user code) |
initialValue | initial value |
|
inline |
Get the name of the simulated device.
|
inlineexplicit |
Determine if handle is empty.
Should be used to optimize out code paths that are taken/not taken in simulation.
|
inline |
Get the internal device handle.
|
protected |