Class SimDeviceJNI

java.lang.Object
edu.wpi.first.hal.JNIWrapper
edu.wpi.first.hal.SimDeviceJNI

public class SimDeviceJNI
extends JNIWrapper
  • Field Details

  • Method Details

    • 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 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

      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

      public static String getSimDeviceName​(int handle)
      Get the name of a simulated device.
      Parameters:
      handle - simulated device handle
      Returns:
      name of the simulated device
    • 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 handle
      name - value name
      direction - 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 handle
      name - value name
      direction - 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 handle
      name - value name
      direction - 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 handle
      name - value name
      direction - 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 handle
      name - value name
      direction - input/output/bidir (from perspective of user code)
      options - array of option descriptions
      initialValue - 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 handle
      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 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 handle
      name - value name
      direction - 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 handle
      value - the value to set
    • setSimValueInt

      public static void setSimValueInt​(int handle, int value)
      Sets a simulated value (int).
      Parameters:
      handle - simulated value handle
      value - the value to set
    • setSimValueLong

      public static void setSimValueLong​(int handle, long value)
      Sets a simulated value (long).
      Parameters:
      handle - simulated value handle
      value - the value to set
    • setSimValueDouble

      public static void setSimValueDouble​(int handle, double value)
      Sets a simulated value (double).
      Parameters:
      handle - simulated value handle
      value - the value to set
    • setSimValueEnum

      public static void setSimValueEnum​(int handle, int value)
      Sets a simulated value (enum).
      Parameters:
      handle - simulated value handle
      value - the value to set
    • setSimValueBoolean

      public static void setSimValueBoolean​(int handle, boolean value)
      Sets a simulated value (boolean).
      Parameters:
      handle - simulated value handle
      value - 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