Class RealtimeContext
- Direct Known Subclasses:
ConstantRealtimeContext,NoRealtimeContext,SystemTime
Instances of this interface are created by signal drivers and passed to
the computation method Process.step() of all concerned signal-related
objects.
Rate vs. Period
Constant vs. Variable
Sampling can be equidistant or adaptive, resulting in
constant or variable realtime context information. The
latter is the unmarked default, the former is represented by the subinterface
ConstantRealtimeContext. Signal-related objects indicate which kind
they expect and support:
- A signal-related object whose constructor has a parameter of type
ConstantRealtimeContextsupports creation-time configuration of realtime information, and expects equivalent information to be passed at every computation step. - Any signal-related object whose constructor does not mention type
ConstantRealtimeContextis either realtime agnostic or adaptive. The former means thatRealtimeContextinformation passed toProcess.step()is ignored altogether. The latter means that the object supports different realtime information at every step.
When realtime information varies, each period is understood to start at
the step event; i.e., the sampling period reported at a particular invocation
of Process.step() states the intended realtime interval until the
next invocation.
Units
The Java type system does not allow for the specification of dimensions or units of measurement. Thus it cannot be specified whether realtime sampling periods are expressed as multiples of, e.g., seconds, milliseconds, or years.
The values returned by methods of this interface are understood to have the dimensions of time and frequency, respectively. But the units are left unspecified, and subject to agreement between the realtime driver and computations.
For computations that involve constants of time-related dimension, the actual units matter. It is strongly recommended that such computations be documented with respect to the units they assume, such that inconsistencies at interfaces can be detected by the programmer, and corrected via unit conversion.
Conversely, for computations that are invariant with respect to the time unit, it is recommended to mention only abstract time units in the documentation.
Extreme Values
FIXME
Implicit Conversion
FIXME
Signal Probe
FIXME
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the projected sampling period as adoublevalue.floatReturns the projected sampling period as afloatvalue.abstract intReturns the projected sampling period as aintvalue.longReturns the projected sampling period as alongvalue.doubleReturns the projected sampling rate as adoublevalue.floatReturns the projected sampling rate as afloatvalue.abstract intReturns the projected sampling rate as aintvalue.longReturns the projected sampling rate as alongvalue.booleanvoidsetSignalProbe(@Opt SignalProbe<Object> signalProbe)
-
Constructor Details
-
RealtimeContext
public RealtimeContext()
-
-
Method Details
-
getSamplingRateAsDouble
public double getSamplingRateAsDouble()Returns the projected sampling rate as adoublevalue.The returned value is the expected number of clock tick events per unit of time, extrapolated from the interval between the current and the next event.
The value should be the reciprocal of the value returned by
getSamplingPeriodAsDouble(). It should be finite, non-negative, and equal to0.0for one-off events that do not repeat.The default implementation simply returns
1 / getSamplingPeriodAsDouble(). Subclasses must override at least one of the two methods in order to avoid indefinite recursion.Note that the same quantity can also be represented as a
floatvalue (getSamplingRateAsFloat()). Special care should be taken if the intended value loses significant precision infloatformat.- See Also:
-
getSamplingPeriodAsDouble
public double getSamplingPeriodAsDouble()Returns the projected sampling period as adoublevalue.The returned value is the expected multiple of unit time elapsing per clock tick event, extrapolated from the interval between the current and the next event.
The value should be the reciprocal of the value returned by
getSamplingRateAsDouble(). It should be positive, and equal toPOSITIVE_INFINITYfor one-off events that do not repeat.The default implementation simply returns
1 / getSamplingRateAsDouble(). Subclasses must override at least one of the two methods in order to avoid indefinite recursion.Note that the same quantity can also be represented as a
floatvalue (getSamplingPeriodAsFloat()). Special care should be taken if the intended value loses significant precision infloatformat.- See Also:
-
getSamplingRateAsFloat
public float getSamplingRateAsFloat()Returns the projected sampling rate as afloatvalue.The returned value is the expected number of clock tick events per unit of time, extrapolated from the interval between the current and the next event.
The value should be the reciprocal of the value returned by
getSamplingPeriodAsFloat(). It should be finite, non-negative, and exactly0.0for one-off events that do not repeat.The default implementation simply returns
1 / getSamplingPeriodAsFloat(). Subclasses must override at least one of the two methods in order to avoid indefinite recursion.Note that the same quantity can also be represented as a
doublevalue (getSamplingRateAsDouble()). Special care should be taken if the intended value loses significant precision infloatformat.- See Also:
-
getSamplingPeriodAsFloat
public float getSamplingPeriodAsFloat()Returns the projected sampling period as afloatvalue.The returned value is the expected multiple of unit time elapsing per clock tick event, extrapolated from the interval between the current and the next event.
The value should be the reciprocal of the value returned by
getSamplingRateAsFloat(). It should be positive, and equal toPOSITIVE_INFINITYfor one-off events that do not repeat.The default implementation simply returns
1 / getSamplingRateAsFloat(). Subclasses must override at least one of the two methods in order to avoid indefinite recursion.Note that the same quantity can also be represented as a
doublevalue (getSamplingPeriodAsDouble()). Special care should be taken if the intended value loses significant precision infloatformat.- See Also:
-
getSamplingRatePerPeriodAsInt
public abstract int getSamplingRatePerPeriodAsInt()Returns the projected sampling rate as aintvalue.The returned value is the expected integral number of clock tick events per some integral multiple of unit of time specified by
getSamplingPeriodPerRateAsInt(), extrapolated from the interval between the current and the next event.The returned value bears no fixed relationship to unit frequency by itself. It should be non-negative, and equal to
0for one-off events that do not repeat.The rational number
r = getSamplingRatePerPeriodAsInt() / getSamplingPeriodPerRateAsInt()should be approximated by the values returned bygetSamplingRateAsFloat()andgetSamplingRateAsDouble(). Approximations may be adequate for numerical computations, but discrete computations should always use the exact rational number.Note that the name of this method does not imply that the returned value specifies a rate divided by a period. Rather, it specifies a rate as a number of events measured in a reference period specified elsewhere.
Note that the same quantity can also be represented as a
longvalue (getSamplingRatePerPeriodAsLong()). Special care should be taken if the intended value is prone to overflow inintformat.- See Also:
-
getSamplingPeriodPerRateAsInt
public abstract int getSamplingPeriodPerRateAsInt()Returns the projected sampling period as aintvalue.The returned value is the expected integral multiple of unit time required for some integral number of clock tick events specified by
getSamplingRatePerPeriodAsInt(), extrapolated from the interval between the current and the next event.The returned value bears no fixed relationship to unit time by itself. It should be non-negative. The value is irrelevant and should be normalized to
1for one-off events that do not repeat.The rational number
p = getSamplingPeriodPerRateAsInt() / getSamplingRatePerPeriodAsInt()should be approximated by the values returned bygetSamplingPeriodAsFloat()andgetSamplingPeriodAsDouble(). Approximations may be adequate for numerical computations, but discrete computations should always use the exact rational number.Note that the name of this method does not imply that the returned value specifies a rate divided by a period. Rather, it specifies a rate as a number of events measured in a reference period specified elsewhere.
Note that the same quantity can also be represented as a
longvalue (getSamplingPeriodPerRateAsLong()). Special care should be taken if the intended value is prone to overflow inintformat.- See Also:
-
getSamplingRatePerPeriodAsLong
public long getSamplingRatePerPeriodAsLong()Returns the projected sampling rate as alongvalue.The returned value is the expected integral number of clock tick events per some integral multiple of unit of time specified by
getSamplingPeriodPerRateAsLong(), extrapolated from the interval between the current and the next event.The returned value bears no fixed relationship to unit frequency by itself. It should be non-negative, and equal to
0for one-off events that do not repeat.The rational number
r = getSamplingRatePerPeriodAsLong() / getSamplingPeriodPerRateAsLong()should be approximated by the values returned bygetSamplingRateAsFloat()andgetSamplingRateAsDouble(). Approximations may be adequate for numerical computations, but discrete computations should always use the exact rational number.Note that the name of this method does not imply that the returned value specifies a rate divided by a period. Rather, it specifies a rate as a number of events measured in a reference period specified elsewhere.
Note that the same quantity can also be represented as a
intvalue (getSamplingRatePerPeriodAsInt()). Special care should be taken if the intended value is prone to overflow inintformat.- See Also:
-
getSamplingPeriodPerRateAsLong
public long getSamplingPeriodPerRateAsLong()Returns the projected sampling period as alongvalue.The returned value is the expected integral multiple of unit time required for some integral number of clock tick events specified by
getSamplingRatePerPeriodAsLong(), extrapolated from the interval between the current and the next event.The returned value bears no fixed relationship to unit time by itself. It should be non-negative. The value is irrelevant and should be normalized to
1for one-off events that do not repeat.The rational number
p = getSamplingPeriodPerRateAsLong() / getSamplingRatePerPeriodAsLong()should be approximated by the values returned bygetSamplingPeriodAsFloat()andgetSamplingPeriodAsDouble(). Approximations may be adequate for numerical computations, but discrete computations should always use the exact rational number.Note that the name of this method does not imply that the returned value specifies a rate divided by a period. Rather, it specifies a rate as a number of events measured in a reference period specified elsewhere.
Note that the same quantity can also be represented as a
intvalue (getSamplingPeriodPerRateAsInt()). Special care should be taken if the intended value is prone to overflow inintformat.- See Also:
-
getSamplingRateAsIntFraction
-
getSamplingRateAsLongFraction
-
getSamplingPeriodAsIntFraction
-
getSamplingPeriodAsLongFraction
-
isRational
-
setSignalProbe
-
getSignalProbe
-