Class SimDeviceJNI
public class SimDeviceJNI extends JNIWrapper
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
Constructors Constructor Description SimDeviceJNI()
-
Method Summary
Modifier and Type Method Description static int
createSimDevice(String name)
Creates a simulated device.static int
createSimValue(int device, String name, int direction, HALValue initialValue)
Creates a value on a simulated device.static 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, int direction, double initialValue)
Creates a double value on a simulated device.static 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 String
getSimDeviceName(int handle)
Get the name of 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).
-
Field Details
-
kInput
- See Also:
- Constant Field Values
-
kOutput
- See Also:
- Constant Field Values
-
kBidir
- See Also:
- Constant Field Values
-
-
Constructor Details
-
SimDeviceJNI
public SimDeviceJNI()
-
-
Method Details
-
createSimDevice
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 identifier 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
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
-
getSimDeviceName
Get the name of a simulated device.- Parameters:
handle
- simulated device handle- Returns:
- name of the simulated device
-
createSimValue
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
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
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
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
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
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
Gets a simulated value.- Parameters:
handle
- simulated value handle- Returns:
- The current value
-
getSimValueInt
Gets a simulated value (int).- Parameters:
handle
- simulated value handle- Returns:
- The current value
-
getSimValueLong
Gets a simulated value (long).- Parameters:
handle
- simulated value handle- Returns:
- The current value
-
getSimValueDouble
Gets a simulated value (double).- Parameters:
handle
- simulated value handle- Returns:
- The current value
-
getSimValueEnum
Gets a simulated value (enum).- Parameters:
handle
- simulated value handle- Returns:
- The current value
-
getSimValueBoolean
Gets a simulated value (boolean).- Parameters:
handle
- simulated value handle- Returns:
- The current value
-
setSimValue
Sets a simulated value.- Parameters:
handle
- simulated value handlevalue
- the value to set
-
setSimValueInt
Sets a simulated value (int).- Parameters:
handle
- simulated value handlevalue
- the value to set
-
setSimValueLong
Sets a simulated value (long).- Parameters:
handle
- simulated value handlevalue
- the value to set
-
setSimValueDouble
Sets a simulated value (double).- Parameters:
handle
- simulated value handlevalue
- the value to set
-
setSimValueEnum
Sets a simulated value (enum).- Parameters:
handle
- simulated value handlevalue
- the value to set
-
setSimValueBoolean
Sets a simulated value (boolean).- Parameters:
handle
- simulated value handlevalue
- the value to set
-
resetSimValue
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
-