Class StatusSignal<T>
- All Implemented Interfaces:
Cloneable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classInformation from a single measurement of a status signal. -
Field Summary
Fields inherited from class com.ctre.phoenix6.BaseStatusSignal
baseValue, error, jni, timestamps, units -
Constructor Summary
ConstructorsConstructorDescriptionStatusSignal(DeviceIdentifier deviceIdentifier, int spn, String signalName, Runnable reportIfOldFunc, ParentDevice.MapGenerator unitsGenerator, Class<T> classOfSignal, DoubleFunction<T> toValue) StatusSignal(DeviceIdentifier deviceIdentifier, int spn, String signalName, Runnable reportIfOldFunc, Class<T> classOfSignal, DoubleFunction<T> toValue) StatusSignal(StatusCode error, Class<T> classOfSignal, DoubleFunction<T> toValue) -
Method Summary
Modifier and TypeMethodDescriptionReturns a lambda that callsrefresh(boolean)andgetValue()on this object.clone()final StatusSignal.SignalMeasurement<T>Get a basic data-only container with a copy of the current signal data.final TgetValue()Gets the cached value from this status signal.final booleanisNear(double target, double tolerance) Checks whether the signal is near a target value within the given tolerance.final booleanChecks whether the signal is near a target value within the given tolerance.final StatusSignal<T>refresh()Refreshes the value of this status signal.final StatusSignal<T>refresh(boolean reportError) Refreshes the value of this status signal.toString()final StatusSignal<T>waitForUpdate(double timeoutSec) Waits up to timeoutSec to get the up-to-date status signal value.final StatusSignal<T>waitForUpdate(double timeoutSec, boolean reportError) Waits up to timeoutSec to get the up-to-date status signal value.Methods inherited from class com.ctre.phoenix6.BaseStatusSignal
getAllTimestamps, getAppliedUpdateFrequency, getAppliedUpdateFrequencyMeasure, getLatencyCompensatedValue, getLatencyCompensatedValue, getLatencyCompensatedValueAsDouble, getLatencyCompensatedValueAsDouble, getName, getStatus, getTimestamp, getUnits, getValueAsDouble, hasUpdated, isAllGood, isAllGood, refreshAll, refreshAll, refreshValue, setUpdateFrequency, setUpdateFrequency, setUpdateFrequency, setUpdateFrequency, setUpdateFrequencyForAll, setUpdateFrequencyForAll, setUpdateFrequencyForAll, setUpdateFrequencyForAll, updateUnits, waitForAll, waitForAll
-
Constructor Details
-
StatusSignal
public StatusSignal(DeviceIdentifier deviceIdentifier, int spn, String signalName, Runnable reportIfOldFunc, Class<T> classOfSignal, DoubleFunction<T> toValue) -
StatusSignal
public StatusSignal(DeviceIdentifier deviceIdentifier, int spn, String signalName, Runnable reportIfOldFunc, ParentDevice.MapGenerator unitsGenerator, Class<T> classOfSignal, DoubleFunction<T> toValue) -
StatusSignal
-
-
Method Details
-
getTypeClass
-
clone
-
getValue
Gets the cached value from this status signal.Gets the cached value. To make sure the value is up-to-date call
refresh()orwaitForUpdate(double)- Returns:
- Cached value
-
refresh
Refreshes the value of this status signal.If the user application caches this StatusSignal 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 the value of this status signal.If the user application caches this StatusSignal 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
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 updatereportError- Whether to report any errors to the Driver Station/stderr. Defaults true- Returns:
- Reference to itself
-
waitForUpdate
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 update- Returns:
- Reference to itself
-
isNear
Checks whether the signal is near a target value within the given tolerance.- Parameters:
target- The target value of the signaltolerance- The error tolerance between the target and measured values- Returns:
- Whether the signal is near the target value
-
isNear
Checks whether the signal is near a target value within the given tolerance. This signal must be a numeric or unit type.- Parameters:
target- The target value of the signaltolerance- The error tolerance between the target and measured values- Returns:
- Whether the signal is near the target value
-
asSupplier
Returns a lambda that callsrefresh(boolean)andgetValue()on this object. This is useful for command-based programming.- Returns:
- Supplier that refreshes this signal and returns it
-
toString
-
getDataCopy
Get a basic data-only container with a copy of the current signal data.If looking for Phoenix 6 logging features, see the
SignalLoggerclass instead.This function returns a new object every call. As a result, we recommend that this is not called inside a tight loop.
- Returns:
- Basic structure with all relevant information
-