Class DriverStationSim

java.lang.Object
edu.wpi.first.wpilibj.simulation.DriverStationSim

public final class DriverStationSim
extends Object
Class to control a simulated driver station.
  • Method Details

    • registerEnabledCallback

      public static CallbackStore registerEnabledCallback​(NotifyCallback callback, boolean initialNotify)
      Register a callback on whether the DS is enabled.
      Parameters:
      callback - the callback that will be called whenever the enabled state is changed
      initialNotify - if true, the callback will be run on the initial value
      Returns:
      the CallbackStore object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
    • getEnabled

      public static boolean getEnabled()
      Check if the DS is enabled.
      Returns:
      true if enabled
    • setEnabled

      public static void setEnabled​(boolean enabled)
      Change whether the DS is enabled.
      Parameters:
      enabled - the new value
    • registerAutonomousCallback

      public static CallbackStore registerAutonomousCallback​(NotifyCallback callback, boolean initialNotify)
      Register a callback on whether the DS is in autonomous mode.
      Parameters:
      callback - the callback that will be called on autonomous mode entrance/exit
      initialNotify - if true, the callback will be run on the initial value
      Returns:
      the CallbackStore object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
    • getAutonomous

      public static boolean getAutonomous()
      Check if the DS is in autonomous.
      Returns:
      true if autonomous
    • setAutonomous

      public static void setAutonomous​(boolean autonomous)
      Change whether the DS is in autonomous.
      Parameters:
      autonomous - the new value
    • registerTestCallback

      public static CallbackStore registerTestCallback​(NotifyCallback callback, boolean initialNotify)
      Register a callback on whether the DS is in test mode.
      Parameters:
      callback - the callback that will be called whenever the test mode is entered or left
      initialNotify - if true, the callback will be run on the initial value
      Returns:
      the CallbackStore object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
    • getTest

      public static boolean getTest()
      Check if the DS is in test.
      Returns:
      true if test
    • setTest

      public static void setTest​(boolean test)
      Change whether the DS is in test.
      Parameters:
      test - the new value
    • registerEStopCallback

      public static CallbackStore registerEStopCallback​(NotifyCallback callback, boolean initialNotify)
      Register a callback on the eStop state.
      Parameters:
      callback - the callback that will be called whenever the eStop state changes
      initialNotify - if true, the callback will be run on the initial value
      Returns:
      the CallbackStore object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
    • getEStop

      public static boolean getEStop()
      Check if eStop has been activated.
      Returns:
      true if eStopped
    • setEStop

      public static void setEStop​(boolean eStop)
      Set whether eStop is active.
      Parameters:
      eStop - true to activate
    • registerFmsAttachedCallback

      public static CallbackStore registerFmsAttachedCallback​(NotifyCallback callback, boolean initialNotify)
      Register a callback on whether the FMS is connected.
      Parameters:
      callback - the callback that will be called whenever the FMS connection changes
      initialNotify - if true, the callback will be run on the initial value
      Returns:
      the CallbackStore object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
    • getFmsAttached

      public static boolean getFmsAttached()
      Check if the FMS is connected.
      Returns:
      true if FMS is connected
    • setFmsAttached

      public static void setFmsAttached​(boolean fmsAttached)
      Change whether the FMS is connected.
      Parameters:
      fmsAttached - the new value
    • registerDsAttachedCallback

      public static CallbackStore registerDsAttachedCallback​(NotifyCallback callback, boolean initialNotify)
      Register a callback on whether the DS is connected.
      Parameters:
      callback - the callback that will be called whenever the DS connection changes
      initialNotify - if true, the callback will be run on the initial value
      Returns:
      the CallbackStore object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
    • getDsAttached

      public static boolean getDsAttached()
      Check if the DS is attached.
      Returns:
      true if attached
    • setDsAttached

      public static void setDsAttached​(boolean dsAttached)
      Change whether the DS is attached.
      Parameters:
      dsAttached - the new value
    • registerAllianceStationIdCallback

      public static CallbackStore registerAllianceStationIdCallback​(NotifyCallback callback, boolean initialNotify)
      Register a callback on the alliance station ID.
      Parameters:
      callback - the callback that will be called whenever the alliance station changes
      initialNotify - if true, the callback will be run on the initial value
      Returns:
      the CallbackStore object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
    • getAllianceStationId

      Get the alliance station ID (color + number).
      Returns:
      the alliance station color and number
    • setAllianceStationId

      public static void setAllianceStationId​(AllianceStationID allianceStationId)
      Change the alliance station.
      Parameters:
      allianceStationId - the new alliance station
    • registerMatchTimeCallback

      public static CallbackStore registerMatchTimeCallback​(NotifyCallback callback, boolean initialNotify)
      Register a callback on match time.
      Parameters:
      callback - the callback that will be called whenever match time changes
      initialNotify - if true, the callback will be run on the initial value
      Returns:
      the CallbackStore object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
    • getMatchTime

      public static double getMatchTime()
      Get the current value of the match timer.
      Returns:
      the current match time
    • setMatchTime

      public static void setMatchTime​(double matchTime)
      Sets the match timer.
      Parameters:
      matchTime - the new match time
    • notifyNewData

      public static void notifyNewData()
      Updates DriverStation data so that new values are visible to the user program.
    • setSendError

      public static void setSendError​(boolean shouldSend)
      Sets suppression of DriverStation.reportError and reportWarning messages.
      Parameters:
      shouldSend - If false then messages will be suppressed.
    • setSendConsoleLine

      public static void setSendConsoleLine​(boolean shouldSend)
      Sets suppression of DriverStation.sendConsoleLine messages.
      Parameters:
      shouldSend - If false then messages will be suppressed.
    • getJoystickOutputs

      public static long getJoystickOutputs​(int stick)
      Gets the joystick outputs.
      Parameters:
      stick - The joystick number
      Returns:
      The joystick outputs
    • getJoystickRumble

      public static int getJoystickRumble​(int stick, int rumbleNum)
      Gets the joystick rumble.
      Parameters:
      stick - The joystick number
      rumbleNum - Rumble to get (0=left, 1=right)
      Returns:
      The joystick rumble value
    • setJoystickButton

      public static void setJoystickButton​(int stick, int button, boolean state)
      Sets the state of one joystick button. Button indexes begin at 1.
      Parameters:
      stick - The joystick number
      button - The button index, beginning at 1
      state - The state of the joystick button
    • setJoystickAxis

      public static void setJoystickAxis​(int stick, int axis, double value)
      Gets the value of the axis on a joystick.
      Parameters:
      stick - The joystick number
      axis - The analog axis number
      value - The value of the axis on the joystick
    • setJoystickPOV

      public static void setJoystickPOV​(int stick, int pov, int value)
      Gets the state of a POV on a joystick.
      Parameters:
      stick - The joystick number
      pov - The POV number
      value - the angle of the POV in degrees, or -1 for not pressed
    • setJoystickButtons

      public static void setJoystickButtons​(int stick, int buttons)
      Sets the state of all the buttons on a joystick.
      Parameters:
      stick - The joystick number
      buttons - The bitmap state of the buttons on the joystick
    • setJoystickAxisCount

      public static void setJoystickAxisCount​(int stick, int count)
      Sets the number of axes for a joystick.
      Parameters:
      stick - The joystick number
      count - The number of axes on the indicated joystick
    • setJoystickPOVCount

      public static void setJoystickPOVCount​(int stick, int count)
      Sets the number of POVs for a joystick.
      Parameters:
      stick - The joystick number
      count - The number of POVs on the indicated joystick
    • setJoystickButtonCount

      public static void setJoystickButtonCount​(int stick, int count)
      Sets the number of buttons for a joystick.
      Parameters:
      stick - The joystick number
      count - The number of buttons on the indicated joystick
    • setJoystickIsXbox

      public static void setJoystickIsXbox​(int stick, boolean isXbox)
      Sets the value of isXbox for a joystick.
      Parameters:
      stick - The joystick number
      isXbox - The value of isXbox
    • setJoystickType

      public static void setJoystickType​(int stick, int type)
      Sets the value of type for a joystick.
      Parameters:
      stick - The joystick number
      type - The value of type
    • setJoystickName

      public static void setJoystickName​(int stick, String name)
      Sets the name of a joystick.
      Parameters:
      stick - The joystick number
      name - The value of name
    • setJoystickAxisType

      public static void setJoystickAxisType​(int stick, int axis, int type)
      Sets the types of Axes for a joystick.
      Parameters:
      stick - The joystick number
      axis - The target axis
      type - The type of axis
    • setGameSpecificMessage

      public static void setGameSpecificMessage​(String message)
      Sets the game specific message.
      Parameters:
      message - the game specific message
    • setEventName

      public static void setEventName​(String name)
      Sets the event name.
      Parameters:
      name - the event name
    • setMatchType

      public static void setMatchType​(DriverStation.MatchType type)
      Sets the match type.
      Parameters:
      type - the match type
    • setMatchNumber

      public static void setMatchNumber​(int matchNumber)
      Sets the match number.
      Parameters:
      matchNumber - the match number
    • setReplayNumber

      public static void setReplayNumber​(int replayNumber)
      Sets the replay number.
      Parameters:
      replayNumber - the replay number
    • resetData

      public static void resetData()
      Reset all simulation data for the Driver Station.