Package edu.wpi.first.wpilibj.simulation
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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AllianceStationID
getAllianceStationId()
Get the alliance station ID (color + number).static boolean
getAutonomous()
Check if the DS is in autonomous.static boolean
getDsAttached()
Check if the DS is attached.static boolean
getEnabled()
Check if the DS is enabled.static boolean
getEStop()
Check if eStop has been activated.static boolean
getFmsAttached()
Check if the FMS is connected.static long
getJoystickOutputs(int stick)
Gets the joystick outputs.static int
getJoystickRumble(int stick, int rumbleNum)
Gets the joystick rumble.static double
getMatchTime()
Get the current value of the match timer.static boolean
getTest()
Check if the DS is in test.static void
notifyNewData()
Updates DriverStation data so that new values are visible to the user program.static CallbackStore
registerAllianceStationIdCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on the alliance station ID.static CallbackStore
registerAutonomousCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on whether the DS is in autonomous mode.static CallbackStore
registerDsAttachedCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on whether the DS is connected.static CallbackStore
registerEnabledCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on whether the DS is enabled.static CallbackStore
registerEStopCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on the eStop state.static CallbackStore
registerFmsAttachedCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on whether the FMS is connected.static CallbackStore
registerMatchTimeCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on match time.static CallbackStore
registerTestCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on whether the DS is in test mode.static void
resetData()
Reset all simulation data for the Driver Station.static void
setAllianceStationId(AllianceStationID allianceStationId)
Change the alliance station.static void
setAutonomous(boolean autonomous)
Change whether the DS is in autonomous.static void
setDsAttached(boolean dsAttached)
Change whether the DS is attached.static void
setEnabled(boolean enabled)
Change whether the DS is enabled.static void
setEStop(boolean eStop)
Set whether eStop is active.static void
setEventName(String name)
Sets the event name.static void
setFmsAttached(boolean fmsAttached)
Change whether the FMS is connected.static void
setGameSpecificMessage(String message)
Sets the game specific message.static void
setJoystickAxis(int stick, int axis, double value)
Gets the value of the axis on a joystick.static void
setJoystickAxisCount(int stick, int count)
Sets the number of axes for a joystick.static void
setJoystickAxisType(int stick, int axis, int type)
Sets the types of Axes for a joystick.static void
setJoystickButton(int stick, int button, boolean state)
Sets the state of one joystick button.static void
setJoystickButtonCount(int stick, int count)
Sets the number of buttons for a joystick.static void
setJoystickButtons(int stick, int buttons)
Sets the state of all the buttons on a joystick.static void
setJoystickIsXbox(int stick, boolean isXbox)
Sets the value of isXbox for a joystick.static void
setJoystickName(int stick, String name)
Sets the name of a joystick.static void
setJoystickPOV(int stick, int pov, int value)
Gets the state of a POV on a joystick.static void
setJoystickPOVCount(int stick, int count)
Sets the number of POVs for a joystick.static void
setJoystickType(int stick, int type)
Sets the value of type for a joystick.static void
setMatchNumber(int matchNumber)
Sets the match number.static void
setMatchTime(double matchTime)
Sets the match timer.static void
setMatchType(DriverStation.MatchType type)
Sets the match type.static void
setReplayNumber(int replayNumber)
Sets the replay number.static void
setSendConsoleLine(boolean shouldSend)
Sets suppression of DriverStation.sendConsoleLine messages.static void
setSendError(boolean shouldSend)
Sets suppression of DriverStation.reportError and reportWarning messages.static void
setTest(boolean test)
Change whether the DS is in test.
-
-
-
Method Detail
-
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 changedinitialNotify
- 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/exitinitialNotify
- 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 leftinitialNotify
- 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 changesinitialNotify
- 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 changesinitialNotify
- 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 changesinitialNotify
- 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 changesinitialNotify
- 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
public static AllianceStationID 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 changesinitialNotify
- 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 numberrumbleNum
- 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 numberbutton
- The button index, beginning at 1state
- 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 numberaxis
- The analog axis numbervalue
- 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 numberpov
- The POV numbervalue
- 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 numberbuttons
- 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 numbercount
- 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 numbercount
- 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 numbercount
- 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 numberisXbox
- 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 numbertype
- The value of type
-
setJoystickName
public static void setJoystickName(int stick, String name)
Sets the name of a joystick.- Parameters:
stick
- The joystick numbername
- 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 numberaxis
- The target axistype
- 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.
-
-