edu.wpi.first.wpilibj.smartdashboard
Class SendableChooser

java.lang.Object
  extended by edu.wpi.first.wpilibj.smartdashboard.SendableChooser
All Implemented Interfaces:
SmartDashboardData

public class SendableChooser
extends java.lang.Object
implements SmartDashboardData

The SendableChooser class is a useful tool for presenting a selection of options to the SmartDashboard.

For instance, you may wish to be able to select between multiple autonomous modes. You can do this by putting every possible Command you want to run as an autonomous into a SendableChooser and then put it into the SmartDashboard to have a list of options appear on the laptop. Once autonomous starts, simply ask the SendableChooser what the selected value is.

Author:
Joe Grinstead

Constructor Summary
SendableChooser()
          Instantiates a SendableChooser.
 
Method Summary
 void addDefault(java.lang.String name, java.lang.Object object)
          Add the given object to the list of options and marks it as the default.
 void addObject(java.lang.String name, java.lang.Object object)
          Adds the given object to the list of options.
 java.lang.Object getSelected()
          Returns the selected option.
 NetworkTable getTable()
          Returns the NetworkTable associated with the data.
 java.lang.String getType()
          Returns the type of the data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SendableChooser

public SendableChooser()
Instantiates a SendableChooser.

Method Detail

addObject

public void addObject(java.lang.String name,
                      java.lang.Object object)
Adds the given object to the list of options. On the SmartDashboard on the desktop, the object will appear as the given name.

Parameters:
name - the name of the option
object - the option

addDefault

public void addDefault(java.lang.String name,
                       java.lang.Object object)
Add the given object to the list of options and marks it as the default. Functionally, this is very close to addObject(...) except that it will use this as the default option if none other is explicitly selected.

Parameters:
name - the name of the option
object - the option

getSelected

public java.lang.Object getSelected()
Returns the selected option. If there is none selected, it will return the default. If there is none selected and no default, then it will return null.

Returns:
the option selected

getType

public java.lang.String getType()
Description copied from interface: SmartDashboardData
Returns the type of the data. This is used by the SmartDashboard on the desktop to determine what to do with the table returned by getTable().

For instance, if the type was "Button", then the SmartDashboard would show the data as a button on the desktop and would know to look at and modify the "pressed" field in the NetworkTable returned by getTable().

Specified by:
getType in interface SmartDashboardData
Returns:
the type of the data

getTable

public NetworkTable getTable()
Description copied from interface: SmartDashboardData
Returns the NetworkTable associated with the data. The table should contain all the information the desktop version of SmartDashboard needs to interact with the object. The data should both keep the table up-to-date and also react to changes that the SmartDashboard might make.

For instance, the SendablePIDController will put its p, i and d values into its table and will change them if the table receives new values.

This method should return the same table between calls

Specified by:
getTable in interface SmartDashboardData
Returns:
the table that represents this data