Class SendableChooser<V>
- java.lang.Object
-
- edu.wpi.first.wpilibj.smartdashboard.SendableChooser<V>
-
- Type Parameters:
V
- The type of the values to be stored
- All Implemented Interfaces:
NTSendable
,Sendable
,AutoCloseable
public class SendableChooser<V> extends Object implements NTSendable, AutoCloseable
TheSendableChooser
class is a useful tool for presenting a selection of options to theSmartDashboard
.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 theSmartDashboard
to have a list of options appear on the laptop. Once autonomous starts, simply ask theSendableChooser
what the selected value is.
-
-
Constructor Summary
Constructors Constructor Description SendableChooser()
Instantiates aSendableChooser
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addDefault(String name, V object)
Deprecated.UsesetDefaultOption(String, Object)
instead.void
addObject(String name, V object)
Deprecated.UseaddOption(String, Object)
instead.void
addOption(String name, V object)
Adds the given object to the list of options.void
close()
V
getSelected()
Returns the selected option.void
initSendable(NTSendableBuilder builder)
Initializes thisSendable
object.void
setDefaultOption(String name, V object)
Adds the given object to the list of options and marks it as the default.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface edu.wpi.first.networktables.NTSendable
initSendable
-
-
-
-
Constructor Detail
-
SendableChooser
public SendableChooser()
Instantiates aSendableChooser
.
-
-
Method Detail
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
addOption
public void addOption(String name, V object)
Adds the given object to the list of options. On theSmartDashboard
on the desktop, the object will appear as the given name.- Parameters:
name
- the name of the optionobject
- the option
-
addObject
@Deprecated public void addObject(String name, V object)
Deprecated.UseaddOption(String, Object)
instead.Adds the given object to the list of options.- Parameters:
name
- the name of the optionobject
- the option
-
setDefaultOption
public void setDefaultOption(String name, V object)
Adds the given object to the list of options and marks it as the default. Functionally, this is very close toaddOption(String, Object)
except that it will use this as the default option if none other is explicitly selected.- Parameters:
name
- the name of the optionobject
- the option
-
addDefault
@Deprecated public void addDefault(String name, V object)
Deprecated.UsesetDefaultOption(String, Object)
instead.Adds the given object to the list of options and marks it as the default.- Parameters:
name
- the name of the optionobject
- the option
-
getSelected
public V 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 returnnull
.- Returns:
- the option selected
-
initSendable
public void initSendable(NTSendableBuilder builder)
Description copied from interface:NTSendable
Initializes thisSendable
object.- Specified by:
initSendable
in interfaceNTSendable
- Parameters:
builder
- sendable builder
-
-