Class BaseStatusSignal
Common parent type for the StatusSignal<T> object.
This can be used for a collection of StatusSignal<T> objects, but we recommend using the derived class instead when possible.public abstract class BaseStatusSignal
- Inheritance
-
BaseStatusSignal
- Derived
-
StatusSignal<T>
- Inherited Members
Fields
localRef
Local reference to a StatusSignalNative.StatusSignalInfo object for use with the native interface.
protected StatusSignalNative.StatusSignalInfo localRef
Field Value
Properties
AllTimestamps
All the timestamps associated with this signal.
public AllTimestamps AllTimestamps { get; protected set; }
Property Value
HasUpdated
Whether the signal has been updated since the last check.
Note that the signal must be refreshed before calling this routine.public bool HasUpdated { get; }
Property Value
Name
The name of this signal.
public string Name { get; }
Property Value
Status
The status of the last time this signal was updated.
public StatusCode Status { get; protected set; }
Property Value
Timestamp
The most accurate timestamp associated with this signal.
public Timestamp Timestamp { get; }
Property Value
Units
The units associated with this signal. These units are encoded as UTF-8, so some applications may not render them properly.
public string Units { get; protected set; }
Property Value
ValueAsDouble
The value as a double instead of the generic type. This may be helpful when working with the base class.
public double ValueAsDouble { get; protected set; }
Property Value
Methods
GetAppliedUpdateFrequency()
Gets the rate at which the device will publish this signal.
This is typically the last value passed into SetUpdateFrequency(double, double). The returned value may be higher if another StatusSignal<T> in the same status frame has been set to a higher update frequency.public double GetAppliedUpdateFrequency()
Returns
- double
Applied update frequency of the signal in Hz
GetLatencyCompensatedValue(StatusSignal<double>, StatusSignal<double>, double)
Performs latency compensation on signal using the signalSlope and signal's latency to determine the magnitude of compensation.The caller must refresh these StatusSignals 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.double compensatedTurns = BaseStatusSignal.GetLatencyCompensatedValue(fx.GetPosition(), fx.GetVelocity());
public static double GetLatencyCompensatedValue(StatusSignal<double> signal, StatusSignal<double> signalSlope, double maxLatencySeconds = 0.3)
Parameters
signalStatusSignal<double>Signal to be latency compensated. Caller must make sure this signal is up to date either by calling Refresh(bool) or WaitForUpdate(double, bool)
signalSlopeStatusSignal<double>Derivative of the signal that informs compensation magnitude. Caller must make sure this signal is up to date either by calling Refresh(bool) or WaitForUpdate(double, bool)
maxLatencySecondsdoubleThe maximum amount of latency to compensate for in seconds. A negative or zero value disables the max latency cap. This is used to cap the contribution of latency compensation for stale signals, such as after the device has been disconnected from the CAN bus.
Returns
- double
Latency compensated value from the signal StatusSignal
IsAllGood(params IReadOnlyList<BaseStatusSignal>)
Checks if all signals have an OK error code.
public static bool IsAllGood(params IReadOnlyList<BaseStatusSignal> signals)
Parameters
signalsIReadOnlyList<BaseStatusSignal>Signals to check error code of
Returns
- bool
true if all signals are good, false otherwise
RefreshAll(params IReadOnlyList<BaseStatusSignal>)
Performs a non-blocking refresh on all provided signals.
This provides a performance improvement over separately calling Refresh(bool) on each signal.public static StatusCode RefreshAll(params IReadOnlyList<BaseStatusSignal> signals)
Parameters
signalsIReadOnlyList<BaseStatusSignal>Signals to refresh
Returns
- StatusCode
An InvalidParamValue if signals array is empty, InvalidNetwork if signals are on different CAN bus networks, OK if all signals are OK,
Any other signal represents the StatusCode of the first failed signal. Call Status on each signal to determine which ones failed.
RefreshValue(bool, double, bool)
protected void RefreshValue(bool waitForSignal, double timeout, bool reportError)
Parameters
SetUpdateFrequency(double, double)
Sets the rate at which the device will publish this signal.
A frequency of 0 Hz will turn off the signal. Otherwise, the minimum supported signal frequency is 4 Hz, and the maximum is 1000 Hz. Additionally, some update frequencies are not supported and will be promoted up to the next highest supported frequency. If other StatusSignals in the same status frame have been set to an update frequency, the fastest requested update frequency will be applied to the frame.public StatusCode SetUpdateFrequency(double frequencyHz, double timeoutSeconds = 0.1)
Parameters
frequencyHzdoubleRate to publish the signal in Hz
timeoutSecondsdoubleMaximum amount of time to wait when performing the action
Returns
- StatusCode
Status code of setting the update frequency
SetUpdateFrequencyForAll(double, params IReadOnlyList<BaseStatusSignal>)
Sets the update frequency of all specified status signals to the provided common frequency.
A frequency of 0 Hz will turn off the signal. Otherwise, the minimum supported signal frequency is 4 Hz, and the maximum is 1000 Hz. Additionally, some update frequencies are not supported and will be promoted up to the next highest supported frequency. If other StatusSignals in the same status frame have been set to an update frequency, the fastest requested update frequency will be applied to each frame. This will wait up to 0.100 seconds (100ms) for each signal.public static StatusCode SetUpdateFrequencyForAll(double frequencyHz, params IReadOnlyList<BaseStatusSignal> signals)
Parameters
frequencyHzdoubleRate to publish the signal in Hz
signalsIReadOnlyList<BaseStatusSignal>Signals to apply the update frequency to
Returns
- StatusCode
Status code of the first failed update frequency call, or OK if all succeeded
UpdateUnits(ushort)
protected void UpdateUnits(ushort unitsKey)
Parameters
unitsKeyushort
WaitForAll(double, params IReadOnlyList<BaseStatusSignal>)
Waits for new data on all provided signals up to timeout. 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.
Note that CANivore Timesync requires Phoenix Pro. This can also be used with a timeout of zero to refresh many signals at once, which is faster than calling Refresh(bool) on every signal. This is equivalent to calling RefreshAll(params IReadOnlyList<BaseStatusSignal>). If a signal arrives multiple times while waiting, such as when *not* using CANivore Timesync, the newest signal data is fetched. Additionally, if this function times out, the newest signal data is fetched for all signals (when possible). We recommend checking the individual status codes using Status when this happens.public static StatusCode WaitForAll(double timeoutSeconds, params IReadOnlyList<BaseStatusSignal> signals)
Parameters
timeoutSecondsdoubleMaximum time to wait for new data in seconds. Pass Zero to refresh all signals without blocking.
signalsIReadOnlyList<BaseStatusSignal>Signals to wait for new data against.
Returns
- StatusCode
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 signals, MultiSignalNotSupported if using a network that does not support more than one signal, OK if all signals arrived within timeoutSeconds and they are all OK,
Any other signal represents the StatusCode of the first failed signal. Call Status on each signal to determine which ones failed.