Package com.ctre.phoenixpro
Class BaseStatusSignalValue
java.lang.Object
com.ctre.phoenixpro.BaseStatusSignalValue
- Direct Known Subclasses:
StatusSignalValue
public abstract class BaseStatusSignalValue extends Object
-
Field Summary
Fields Modifier and Type Field Description protected double
baseValue
protected DeviceIdentifier
deviceIdentifier
protected StatusCode
error
protected StatusSignalValueJNI
jni
protected String
signalName
protected int
spn
protected AllTimestamps
timestamps
protected String
units
-
Method Summary
Modifier and Type Method Description protected void
copyFrom(BaseStatusSignalValue other)
AllTimestamps
getAllTimestamps()
Get all timestamps relevant for this signalStatusCode
getError()
Get the error code from when we last received this signalstatic 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.Timestamp
getTimestamp()
Get the best available timestamp for this signalString
getUnits()
Gets the units for this signalstatic boolean
isAllGood(BaseStatusSignalValue... signals)
Checks that all the signals are good.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.
-
Field Details
-
Method Details
-
copyFrom
-
waitForAll
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 secondssignals
- 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 callingStatusSignalValue.refresh()
orStatusSignalValue.waitForUpdate(double)
.signalSlope
- Derivative of signal that informs compensation magnitude. Caller must make sure this signal is up to date either by callingStatusSignalValue.refresh()
orStatusSignalValue.waitForUpdate(double)
.- Returns:
- Latency compensated value from the signal StatusSignalValue.
-
isAllGood
Checks that all the signals are good.- Parameters:
signals
- Signals to check error code of- Returns:
- True if all are good, false otherwise
-
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
Get the error code from when we last received this signal- Returns:
- Last cached Error Code
-