Class BaseStatusSignalValue

java.lang.Object
com.ctre.phoenixpro.BaseStatusSignalValue
Direct Known Subclasses:
StatusSignalValue

public abstract class BaseStatusSignalValue
extends Object
  • Field Details

  • Method Details

    • copyFrom

      protected void copyFrom​(BaseStatusSignalValue other)
    • waitForAll

      public static StatusCode waitForAll​(double timeoutSeconds, BaseStatusSignalValue... signals)
      Waits for new data on all the signals specified This API is typically used with CANivore Bus signals as they will be synced using the CANivore Timesync feature and arrive simultaneously. Signals on a roboRIO bus cannot be synced and may require a significantly longer blocking call to receive all signals. This can also be used with a timeout of zero to refresh many signals at once, which is faster than calling refresh() on every signal.
      Parameters:
      timeoutSeconds - Maximum time to wait for new data in seconds
      signals - Signals to wait for new data against Pass zero to just refresh all signals without blocking.
      Returns:
      An InvalidParamValue if signals array is empty, InvalidNetwork if signals are on different CAN bus networks, RxTimeout if it took longer than timeoutSeconds to receive all the signals. An OK status code means that all signals arrived within timeoutSeconds and they are all OK. Any other value represents the StatusCode of the first failed signal. Call getError() on each signal to determine which ones failed.
    • getLatencyCompensatedValue

      public static double getLatencyCompensatedValue​(StatusSignalValue<Double> signal, StatusSignalValue<Double> signalSlope)
      Performs latency compensation on signal using the signalSlope and signal's latency to determine the magnitude of compensation. The caller must refresh these StatusSignalValues beforehand, this function only does the math required for latency compensation.

      Important: The signalSlope must be the rate of change of the signal. If it is not the latency compensation may not perform as expected.

      Example: double compensatedTurns = getLatencyCompensatedValue(fx.getPosition(), fx.getVelocity());

      Parameters:
      signal - Signal to be latency compensated. Caller must make sure this signal is up to date either by calling StatusSignalValue.refresh() or StatusSignalValue.waitForUpdate(double).
      signalSlope - Derivative of signal that informs compensation magnitude. Caller must make sure this signal is up to date either by calling StatusSignalValue.refresh() or StatusSignalValue.waitForUpdate(double).
      Returns:
      Latency compensated value from the signal StatusSignalValue.
    • isAllGood

      public static boolean isAllGood​(BaseStatusSignalValue... signals)
      Checks that all the signals are good.
      Parameters:
      signals - Signals to check error code of
      Returns:
      True if all are good, false otherwise
    • getUnits

      public String getUnits()
      Gets the units for this signal
      Returns:
      String representation of units for this signal
    • getAllTimestamps

      Get all timestamps relevant for this signal
      Returns:
      All timestamps available for this signal
    • getTimestamp

      Get the best available timestamp for this signal
      Returns:
      Best available timestamp
    • getError

      public StatusCode getError()
      Get the error code from when we last received this signal
      Returns:
      Last cached Error Code