Class TunableBase

java.lang.Object
org.wpilib.tunable.TunableBase
Direct Known Subclasses:
Tunable, TunableBoolean, TunableDouble, TunableFloat, TunableInt, TunableLong

public abstract class TunableBase extends Object
The base class for tunables.
  • Field Details

    • m_changed

      protected boolean m_changed
      Whether the tunable value has changed since the last time it was tuned. This is set to true when set() is called and cleared when notifyTune() is called.
  • Constructor Details

    • TunableBase

      protected TunableBase(TunableConfig config)
      Constructs a tunable base.
      Parameters:
      config - tunable config
    • TunableBase

      protected TunableBase(TunableConfig config, boolean supportsChangeNotification)
      Constructs a tunable base.

      If supportsChangeNotification is true, subclasses must call markChanged() instead of setting m_changed directly.

      Parameters:
      config - tunable config
      supportsChangeNotification - whether the tunable notifies backends when it changes
  • Method Details

    • isRobust

      public boolean isRobust()
      Returns whether this tunable is robust.
      Returns:
      true if the tunable is robust, false otherwise
      See Also:
    • getProperties

      public String getProperties()
      Returns the properties of this tunable as a JSON string.
      Returns:
      the properties of this tunable as a JSON string
      See Also:
    • getConfig

      public TunableConfig getConfig()
      Returns the configuration of this tunable.
      Returns:
      the configuration of this tunable
    • hasChanged

      public boolean hasChanged()
      Returns whether the tunable value has changed since the last time it was tuned.
      Returns:
      true if the tunable value has changed, false otherwise
    • supportsChangeNotification

      public boolean supportsChangeNotification()
      Returns whether this tunable notifies backends when set() marks it changed.
      Returns:
      true if this tunable notifies backends when changed, false otherwise
    • markChanged

      protected void markChanged()
      Marks the tunable changed and notifies backends.
    • resetChanged

      public void resetChanged()
      Resets the changed flag. Should generally only be used by backends.