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

    Fields 
    Modifier and Type Field Description
    static int kBidir  
    static int kInput  
    static int kOutput  
  • 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, boolean readonly, HALValue initialValue)
    Deprecated.
    Use direction-taking function instead
    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, boolean readonly, boolean initialValue)
    Deprecated.
    Use direction-taking function instead
    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, boolean readonly, double initialValue)
    Deprecated.
    Use direction-taking function instead
    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, boolean readonly, String[] options, int initialValue)
    Deprecated.
    Use direction-taking function instead
    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 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor 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 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 instead
      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
      readonly - if the value should not be written from simulation side
      initialValue - 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 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

      @Deprecated public static int createSimValueDouble​(int device, String name, boolean readonly, double initialValue)
      Deprecated.
      Use direction-taking function instead
      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
      readonly - if the value should not be written from simulation side
      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

      @Deprecated public static int createSimValueEnum​(int device, String name, boolean readonly, String[] options, int initialValue)
      Deprecated.
      Use direction-taking function instead
      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
      readonly - if the value should not be written from simulation side
      options - array of option descriptions
      initialValue - 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 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

      @Deprecated public static int createSimValueBoolean​(int device, String name, boolean readonly, boolean initialValue)
      Deprecated.
      Use direction-taking function instead
      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
      readonly - if the value should not be written from simulation side
      initialValue - 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 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