public abstract class RealtimeContext extends Object
Instances of this interface are created by signal drivers and passed to
the computation method Process.step(eu.bandm.sig.adlib2.RealtimeContext)
of all concerned signal-related
objects.
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:
ConstantRealtimeContext
supports creation-time configuration of
realtime information, and expects equivalent information to be passed at
every computation step.ConstantRealtimeContext
is either realtime agnostic or adaptive.
The former means that RealtimeContext
information passed to Process.step(eu.bandm.sig.adlib2.RealtimeContext)
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(eu.bandm.sig.adlib2.RealtimeContext)
states the intended realtime interval until the
next invocation.
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
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.
Constructor and Description |
---|
RealtimeContext() |
Modifier and Type | Method and Description |
---|---|
double |
getSamplingPeriodAsDouble()
Returns the projected sampling period as a
double value. |
float |
getSamplingPeriodAsFloat()
Returns the projected sampling period as a
float value. |
abstract IntFraction |
getSamplingPeriodAsInt() |
abstract LongFraction |
getSamplingPeriodAsLong() |
abstract int |
getSamplingPeriodPerRateAsInt()
Returns the projected sampling period as a
int value. |
long |
getSamplingPeriodPerRateAsLong()
Returns the projected sampling period as a
long value. |
double |
getSamplingRateAsDouble()
Returns the projected sampling rate as a
double value. |
float |
getSamplingRateAsFloat()
Returns the projected sampling rate as a
float value. |
abstract IntFraction |
getSamplingRateAsInt() |
abstract LongFraction |
getSamplingRateAsLong() |
abstract int |
getSamplingRatePerPeriodAsInt()
Returns the projected sampling rate as a
int value. |
long |
getSamplingRatePerPeriodAsLong()
Returns the projected sampling rate as a
long value. |
SignalProbe<Object> |
getSignalProbe() |
boolean |
isRational() |
void |
setSignalProbe(SignalProbe<Object> signalProbe) |
public double getSamplingRateAsDouble()
double
value.
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 to 0.0
for 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 float
value (getSamplingRateAsFloat()
). Special care should be taken if
the intended value loses significant precision in float
format.
public double getSamplingPeriodAsDouble()
double
value.
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 to POSITIVE_INFINITY
for 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 float
value (getSamplingPeriodAsFloat()
). Special care should be taken if
the intended value loses significant precision in float
format.
public float getSamplingRateAsFloat()
float
value.
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
exactly 0.0
for 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 double
value (getSamplingRateAsDouble()
). Special care should be taken if
the intended value loses significant precision in float
format.
public float getSamplingPeriodAsFloat()
float
value.
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 to POSITIVE_INFINITY
for 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 double
value (getSamplingPeriodAsDouble()
). Special care should be taken if
the intended value loses significant precision in float
format.
public abstract int getSamplingRatePerPeriodAsInt()
int
value.
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 0
for one-off
events that do not repeat.
The rational number r = getSamplingRatePerPeriodAsInt() /
getSamplingPeriodPerRateAsInt()
should be approximated by the values
returned by getSamplingRateAsFloat()
and getSamplingRateAsDouble()
. 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 long
value (getSamplingRatePerPeriodAsLong()
). Special care should be
taken if the intended value is prone to overflow in int
format.
public abstract int getSamplingPeriodPerRateAsInt()
int
value.
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 1
for one-off events that do not repeat.
The rational number p = getSamplingPeriodPerRateAsInt() /
getSamplingRatePerPeriodAsInt()
should be approximated by the values
returned by getSamplingPeriodAsFloat()
and getSamplingPeriodAsDouble()
. 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 long
value (getSamplingPeriodPerRateAsLong()
). Special care should be
taken if the intended value is prone to overflow in int
format.
public long getSamplingRatePerPeriodAsLong()
long
value.
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 0
for one-off
events that do not repeat.
The rational number r = getSamplingRatePerPeriodAsLong() /
getSamplingPeriodPerRateAsLong()
should be approximated by the values
returned by getSamplingRateAsFloat()
and getSamplingRateAsDouble()
. 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 int
value (getSamplingRatePerPeriodAsInt()
). Special care should be
taken if the intended value is prone to overflow in int
format.
public long getSamplingPeriodPerRateAsLong()
long
value.
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 1
for one-off events that do not repeat.
The rational number p = getSamplingPeriodPerRateAsLong() /
getSamplingRatePerPeriodAsLong()
should be approximated by the values
returned by getSamplingPeriodAsFloat()
and getSamplingPeriodAsDouble()
. 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 int
value (getSamplingPeriodPerRateAsInt()
). Special care should be
taken if the intended value is prone to overflow in int
format.
public abstract IntFraction getSamplingPeriodAsInt()
public abstract IntFraction getSamplingRateAsInt()
public abstract LongFraction getSamplingPeriodAsLong()
public abstract LongFraction getSamplingRateAsLong()
public boolean isRational()
public void setSignalProbe(SignalProbe<Object> signalProbe)
public SignalProbe<Object> getSignalProbe()