Class SimDeviceJNI
-
Nested Class Summary
Nested classes/interfaces inherited from class JNIWrapper
JNIWrapper.Helper -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intBidirectional between user code and simulator.static final intInput to user code from the simulator.static final intOutput from user code to the simulator. -
Method Summary
Modifier and TypeMethodDescriptionstatic intcreateSimDevice(String name) Creates a simulated device.static intcreateSimValue(int device, String name, int direction, HALValue initialValue) Creates a value on a simulated device.static intcreateSimValueBoolean(int device, String name, int direction, boolean initialValue) Creates a boolean value on a simulated device.static intcreateSimValueDouble(int device, String name, int direction, double initialValue) Creates a double value on a simulated device.static intcreateSimValueEnum(int device, String name, int direction, String[] options, int initialValue) Creates an enumerated value on a simulated device.static intcreateSimValueEnumDouble(int device, String name, int direction, String[] options, double[] optionValues, int initialValue) Creates an enumerated value on a simulated device with double values.static intcreateSimValueInt(int device, String name, int direction, int initialValue) Creates an int value on a simulated device.static intcreateSimValueLong(int device, String name, int direction, long initialValue) Creates a long value on a simulated device.static voidfreeSimDevice(int handle) Frees a simulated device.static StringgetSimDeviceName(int handle) Get the name of a simulated device.static HALValuegetSimValue(int handle) Gets a simulated value.static booleangetSimValueBoolean(int handle) Gets a simulated value (boolean).static doublegetSimValueDouble(int handle) Gets a simulated value (double).static intgetSimValueEnum(int handle) Gets a simulated value (enum).static intgetSimValueInt(int handle) Gets a simulated value (int).static longgetSimValueLong(int handle) Gets a simulated value (long).static voidresetSimValue(int handle) Resets a simulated double or integral value to 0.static voidsetSimValue(int handle, HALValue value) Sets a simulated value.static voidsetSimValueBoolean(int handle, boolean value) Sets a simulated value (boolean).static voidsetSimValueDouble(int handle, double value) Sets a simulated value (double).static voidsetSimValueEnum(int handle, int value) Sets a simulated value (enum).static voidsetSimValueInt(int handle, int value) Sets a simulated value (int).static voidsetSimValueLong(int handle, long value) Sets a simulated value (long).Methods inherited from class JNIWrapper
forceLoad, suppressUnused
-
Field Details
-
VALUE_INPUT
public static final int VALUE_INPUTInput to user code from the simulator.- See Also:
-
VALUE_OUTPUT
public static final int VALUE_OUTPUTOutput from user code to the simulator.- See Also:
-
VALUE_BIDIR
public static final int VALUE_BIDIRBidirectional between user code and simulator.- See Also:
-
-
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]".
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"
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
-
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
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
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
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
-