Class StatusSignal<T>
- All Implemented Interfaces:
Cloneable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Information from a single measurement of a status signal. -
Field Summary
Fields inherited from class com.ctre.phoenix6.BaseStatusSignal
_reportIfOldFunc, baseValue, deviceIdentifier, error, jni, signalName, spn, timestamps, units
-
Constructor Summary
ConstructorsConstructorDescriptionStatusSignal
(DeviceIdentifier deviceIdentifier, int spn, Runnable reportIfOldFunc, Class<T> classOfSignal, DoubleFunction<T> toValue, ParentDevice.MapGenerator<T> generator, String signalName) StatusSignal
(DeviceIdentifier deviceIdentifier, int spn, Runnable reportIfOldFunc, Class<T> classOfSignal, DoubleFunction<T> toValue, String signalName) StatusSignal
(Class<T> classOfSignal, DoubleFunction<T> toValue, StatusCode error) -
Method Summary
Modifier and TypeMethodDescriptionReturns a lambda that callsrefresh(boolean)
andgetValue()
on this object.clone()
Get a basic data-only container with this information, to be used for things such as data logging.getValue()
Gets the cached value from this status signal.refresh()
Refreshes the value of this status signal.refresh
(boolean reportError) Refreshes the value of this status signal.toString()
protected void
updateUnits
(int unitsKey) waitForUpdate
(double timeoutSec) Waits up to timeoutSec to get the up-to-date status signal value.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, refreshAll, setUpdateFrequency, setUpdateFrequency, setUpdateFrequency, setUpdateFrequency, setUpdateFrequencyForAll, setUpdateFrequencyForAll, waitForAll
-
Constructor Details
-
StatusSignal
public StatusSignal(DeviceIdentifier deviceIdentifier, int spn, Runnable reportIfOldFunc, Class<T> classOfSignal, DoubleFunction<T> toValue, String signalName) -
StatusSignal
public StatusSignal(DeviceIdentifier deviceIdentifier, int spn, Runnable reportIfOldFunc, Class<T> classOfSignal, DoubleFunction<T> toValue, ParentDevice.MapGenerator<T> generator, String signalName) -
StatusSignal
-
-
Method Details
-
updateUnits
- Specified by:
updateUnits
in classBaseStatusSignal
-
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
-
clone
-
getTypeClass
-
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
-
getDataCopy
Get a basic data-only container with this information, to be used for things such as data logging.Note if looking for Phoenix 6 logging features, see the
SignalLogger
class 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
-