Class SimDeviceJNI
- java.lang.Object
-
- edu.wpi.first.hal.JNIWrapper
-
- edu.wpi.first.hal.SimDeviceJNI
-
public class SimDeviceJNI extends JNIWrapper
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class edu.wpi.first.hal.JNIWrapper
JNIWrapper.Helper
-
-
Constructor Summary
Constructors Constructor Description SimDeviceJNI()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static int
createSimDevice(String name)
Creates a simulated device.static int
createSimValue(int device, String name, boolean readonly, HALValue initialValue)
Deprecated.Use direction-taking function insteadstatic int
createSimValue(int device, String name, int direction, HALValue initialValue)
Creates a value on a simulated device.static int
createSimValueBoolean(int device, String name, boolean readonly, boolean initialValue)
Deprecated.Use direction-taking function insteadstatic int
createSimValueBoolean(int device, String name, int direction, boolean initialValue)
Creates a boolean value on a simulated device.static int
createSimValueDouble(int device, String name, boolean readonly, double initialValue)
Deprecated.Use direction-taking function insteadstatic int
createSimValueDouble(int device, String name, int direction, double initialValue)
Creates a double value on a simulated device.static int
createSimValueEnum(int device, String name, boolean readonly, String[] options, int initialValue)
Deprecated.Use direction-taking function insteadstatic int
createSimValueEnum(int device, String name, int direction, String[] options, int initialValue)
Creates an enumerated value on a simulated device.static int
createSimValueEnumDouble(int device, String name, int direction, String[] options, double[] optionValues, int initialValue)
Creates an enumerated value on a simulated device with double values.static int
createSimValueInt(int device, String name, int direction, int initialValue)
Creates an int value on a simulated device.static int
createSimValueLong(int device, String name, int direction, long initialValue)
Creates a long value on a simulated device.static void
freeSimDevice(int handle)
Frees a simulated device.static HALValue
getSimValue(int handle)
Gets a simulated value.static boolean
getSimValueBoolean(int handle)
Gets a simulated value (boolean).static double
getSimValueDouble(int handle)
Gets a simulated value (double).static int
getSimValueEnum(int handle)
Gets a simulated value (enum).static int
getSimValueInt(int handle)
Gets a simulated value (int).static long
getSimValueLong(int handle)
Gets a simulated value (long).static void
resetSimValue(int handle)
Resets a simulated double or integral value to 0.static void
setSimValue(int handle, HALValue value)
Sets a simulated value.static void
setSimValueBoolean(int handle, boolean value)
Sets a simulated value (boolean).static void
setSimValueDouble(int handle, double value)
Sets a simulated value (double).static void
setSimValueEnum(int handle, int value)
Sets a simulated value (enum).static void
setSimValueInt(int handle, int value)
Sets a simulated value (int).static void
setSimValueLong(int handle, long value)
Sets a simulated value (long).-
Methods inherited from class edu.wpi.first.hal.JNIWrapper
forceLoad, suppressUnused
-
-
-
-
Field Detail
-
kInput
public static final int kInput
- See Also:
- Constant Field Values
-
kOutput
public static final int kOutput
- See Also:
- Constant Field Values
-
kBidir
public static final int kBidir
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SimDeviceJNI
public SimDeviceJNI()
-
-
Method Detail
-
createSimDevice
public static int createSimDevice(String name)
Creates a simulated device.The device name must be unique. 0 is returned if the device name already exists. If multiple instances of the same device are desired, recommend appending the instance/unique identifer in brackets to the base name, e.g. "device[1]".
0 is returned if not in simulation.
- Parameters:
name
- device name- Returns:
- simulated device handle
-
freeSimDevice
public static void freeSimDevice(int handle)
Frees a simulated device.This also allows the same device name to be used again. This also frees all the simulated values created on the device.
- Parameters:
handle
- simulated device handle
-
createSimValue
@Deprecated public static int createSimValue(int device, String name, boolean readonly, HALValue initialValue)
Deprecated.Use direction-taking function insteadCreates a value on a simulated device.Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
- Parameters:
device
- simulated device handlename
- value namereadonly
- if the value should not be written from simulation sideinitialValue
- initial value- Returns:
- simulated value handle
-
createSimValue
public static int createSimValue(int device, String name, int direction, HALValue initialValue)
Creates a value on a simulated device.Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
- Parameters:
device
- simulated device handlename
- value namedirection
- input/output/bidir (from perspective of user code)initialValue
- initial value- Returns:
- simulated value handle
-
createSimValueInt
public static int createSimValueInt(int device, String name, int direction, int initialValue)
Creates an int value on a simulated device.Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
- Parameters:
device
- simulated device handlename
- value namedirection
- input/output/bidir (from perspective of user code)initialValue
- initial value- Returns:
- simulated value handle
-
createSimValueLong
public static int createSimValueLong(int device, String name, int direction, long initialValue)
Creates a long value on a simulated device.Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
- Parameters:
device
- simulated device handlename
- value namedirection
- input/output/bidir (from perspective of user code)initialValue
- initial value- Returns:
- simulated value handle
-
createSimValueDouble
@Deprecated public static int createSimValueDouble(int device, String name, boolean readonly, double initialValue)
Deprecated.Use direction-taking function insteadCreates a double value on a simulated device.Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
- Parameters:
device
- simulated device handlename
- value namereadonly
- if the value should not be written from simulation sideinitialValue
- initial value- Returns:
- simulated value handle
-
createSimValueDouble
public static int createSimValueDouble(int device, String name, int direction, double initialValue)
Creates a double value on a simulated device.Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
- Parameters:
device
- simulated device handlename
- value namedirection
- input/output/bidir (from perspective of user code)initialValue
- initial value- Returns:
- simulated value handle
-
createSimValueEnum
@Deprecated public static int createSimValueEnum(int device, String name, boolean readonly, String[] options, int initialValue)
Deprecated.Use direction-taking function insteadCreates an enumerated value on a simulated device.Enumerated values are always in the range 0 to numOptions-1.
Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
- Parameters:
device
- simulated device handlename
- value namereadonly
- if the value should not be written from simulation sideoptions
- array of option descriptionsinitialValue
- initial value (selection)- Returns:
- simulated value handle
-
createSimValueEnum
public static int createSimValueEnum(int device, String name, int direction, String[] options, int initialValue)
Creates an enumerated value on a simulated device.Enumerated values are always in the range 0 to numOptions-1.
Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
- Parameters:
device
- simulated device handlename
- value namedirection
- input/output/bidir (from perspective of user code)options
- array of option descriptionsinitialValue
- initial value (selection)- Returns:
- simulated value handle
-
createSimValueEnumDouble
public static int createSimValueEnumDouble(int device, String name, int direction, String[] options, double[] optionValues, int initialValue)
Creates an enumerated value on a simulated device with double values.Enumerated values are always in the range 0 to numOptions-1.
Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
- Parameters:
device
- simulated device handlename
- value namedirection
- input/output/bidir (from perspective of user code)options
- array of option descriptionsoptionValues
- array of option values (must be the same size as options)initialValue
- initial value (selection)- Returns:
- simulated value handle
-
createSimValueBoolean
@Deprecated public static int createSimValueBoolean(int device, String name, boolean readonly, boolean initialValue)
Deprecated.Use direction-taking function insteadCreates a boolean value on a simulated device.Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
- Parameters:
device
- simulated device handlename
- value namereadonly
- if the value should not be written from simulation sideinitialValue
- initial value- Returns:
- simulated value handle
-
createSimValueBoolean
public static int createSimValueBoolean(int device, String name, int direction, boolean initialValue)
Creates a boolean value on a simulated device.Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
- Parameters:
device
- simulated device handlename
- value namedirection
- input/output/bidir (from perspective of user code)initialValue
- initial value- Returns:
- simulated value handle
-
getSimValue
public static HALValue getSimValue(int handle)
Gets a simulated value.- Parameters:
handle
- simulated value handle- Returns:
- The current value
-
getSimValueInt
public static int getSimValueInt(int handle)
Gets a simulated value (int).- Parameters:
handle
- simulated value handle- Returns:
- The current value
-
getSimValueLong
public static long getSimValueLong(int handle)
Gets a simulated value (long).- Parameters:
handle
- simulated value handle- Returns:
- The current value
-
getSimValueDouble
public static double getSimValueDouble(int handle)
Gets a simulated value (double).- Parameters:
handle
- simulated value handle- Returns:
- The current value
-
getSimValueEnum
public static int getSimValueEnum(int handle)
Gets a simulated value (enum).- Parameters:
handle
- simulated value handle- Returns:
- The current value
-
getSimValueBoolean
public static boolean getSimValueBoolean(int handle)
Gets a simulated value (boolean).- Parameters:
handle
- simulated value handle- Returns:
- The current value
-
setSimValue
public static void setSimValue(int handle, HALValue value)
Sets a simulated value.- Parameters:
handle
- simulated value handlevalue
- the value to set
-
setSimValueInt
public static void setSimValueInt(int handle, int value)
Sets a simulated value (int).- Parameters:
handle
- simulated value handlevalue
- the value to set
-
setSimValueLong
public static void setSimValueLong(int handle, long value)
Sets a simulated value (long).- Parameters:
handle
- simulated value handlevalue
- the value to set
-
setSimValueDouble
public static void setSimValueDouble(int handle, double value)
Sets a simulated value (double).- Parameters:
handle
- simulated value handlevalue
- the value to set
-
setSimValueEnum
public static void setSimValueEnum(int handle, int value)
Sets a simulated value (enum).- Parameters:
handle
- simulated value handlevalue
- the value to set
-
setSimValueBoolean
public static void setSimValueBoolean(int handle, boolean value)
Sets a simulated value (boolean).- Parameters:
handle
- simulated value handlevalue
- the value to set
-
resetSimValue
public static void resetSimValue(int handle)
Resets a simulated double or integral value to 0. Has no effect on other value types. Use this instead of Set(0) for resetting incremental sensor values like encoder counts or gyro accumulated angle to ensure correct behavior in a distributed system (e.g. WebSockets).- Parameters:
handle
- simulated value handle
-
-