Class StatusSignalValue<T>

java.lang.Object
com.ctre.phoenixpro.BaseStatusSignalValue
com.ctre.phoenixpro.StatusSignalValue<T>
All Implemented Interfaces:
Cloneable

public class StatusSignalValue<T>
extends BaseStatusSignalValue
implements Cloneable
  • Constructor Details

  • Method Details

    • asSupplier

      public Supplier<T> asSupplier()
      Returns a lambda that calls Refresh and GetValue on this object. This is useful for command-based programming.
      Returns:
      Supplier that refreshes this signal and returns it
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • clone

      Overrides:
      clone in class Object
    • getTypeClass

      public Class<T> getTypeClass()
    • getValue

      public T getValue()
      Gets the cached value from this status signal value

      Gets the cached value. To make sure the value is up-to-date call refresh() or waitForUpdate(double)

      Returns:
      Cached value
    • refresh

      public StatusSignalValue<T> refresh​(boolean reportError)
      Refreshes this status signal value

      If the user application caches this StatusSignalValue object instead of periodically fetching it from the hardware device, this function must be called to fetch fresh data.

      This performs a non-blocking refresh operation. If you want to wait until you receive the signal, call waitForUpdate(double) instead.

      Parameters:
      reportError - Whether to report any errors to the Driver Station/stderr. Defaults true
      Returns:
      Reference to itself
    • refresh

      Refreshes this status signal value

      If the user application caches this StatusSignalValue object instead of periodically fetching it from the hardware device, this function must be called to fetch fresh data.

      This performs a non-blocking refresh operation. If you want to wait until you receive the signal, call waitForUpdate(double) instead.

      Returns:
      Reference to itself
    • waitForUpdate

      public StatusSignalValue<T> waitForUpdate​(double timeoutSec, boolean reportError)
      Waits up to timeoutSec to get the up-to-date status signal value

      This performs a blocking refresh operation. If you want to non-blocking refresh the signal, call refresh() instead.

      Parameters:
      timeoutSec - Maximum time to wait for the signal to come in
      reportError - Whether to report any errors to the Driver Station/stderr. Defaults true
      Returns:
      Reference to itself
    • waitForUpdate

      public StatusSignalValue<T> waitForUpdate​(double timeoutSec)
      Waits up to timeoutSec to get the up-to-date status signal value

      This performs a blocking refresh operation. If you want to non-blocking refresh the signal, call refresh() instead.

      Parameters:
      timeoutSec - Maximum time to wait for the signal to come in
      Returns:
      Reference to itself
    • setUpdateFrequency

      public StatusCode setUpdateFrequency​(double frequencyHz)
      Sets the rate at which the device will publish this signal.

      The minimum supported signal frequency is 4 Hz, and the maximum is 1000 Hz.

      This will wait up to 0.050 seconds (50ms) by default.

      Parameters:
      frequencyHz - Rate to publish the signal in Hz.
      Returns:
      Status code of setting the update frequency
    • setUpdateFrequency

      public StatusCode setUpdateFrequency​(double frequencyHz, double timeoutSeconds)
      Sets the rate at which the device will publish this signal.

      The minimum supported signal frequency is 4 Hz, and the maximum is 1000 Hz.

      Parameters:
      frequencyHz - Rate to publish the signal in Hz.
      timeoutSeconds - Maximum amount of time to wait when performing the action
      Returns:
      Status code of setting the update frequency
    • getDataCopy

      Get a basic data-only container with this information, to be used for things such as data logging.
      Returns:
      Basic structure with all relevant information