public class DiscreteEventTimeManager extends Object implements TimeManager
DiscreteEventTimeManager
implements a TimeManager
for usage
in simulation mode of the platform.
This time manager advances platform time in heterogeneous steps depending on
the next timestamp requested when calling paceTime(Timestamp)
. The
requested time is adapted based on preset time granularity. For instance, 1 minute
granularity disallows any timestamp with second or millisecond values other than 0.
As a consequence, all requests would be assigned to the start of the next corresponding
minute. Mathematically speaking, all timestamps of this time manager are divisible
by the given granularity with respect to the millisecond UNIX timestamp value.
For instance, with a granularity of 1 second, a requested time corresponding to UNIX millisecond timestamp 135263 will be rounded to next granularity timestamp 136000. A requested timestamp 136000 would still yield 136000 as set time.
Modifier and Type | Field and Description |
---|---|
static Duration |
DEFAULT_GRANULARITY
The default granularity of time applied by this class.
|
Constructor and Description |
---|
DiscreteEventTimeManager(Timestamp start)
Creates a new instance of
DiscreteEventTimeManager . |
DiscreteEventTimeManager(Timestamp start,
Duration granularity)
Creates a new instance of
DiscreteEventTimeManager . |
Modifier and Type | Method and Description |
---|---|
Timestamp |
currentTime()
Returns the timestamp that represents the current model time.
|
Duration |
getGranularity()
Returns the granularity of the time manager's time grid with UNIX epoch as grid
reference origin.
|
void |
interruptPace()
Interrupts a potential sleep period in
TimeManager.paceTime(Timestamp) . |
void |
paceTime(Timestamp minTimestamp)
Sets time based on the time progression policy and the given next time requested
by the platform.
|
Timestamp |
roundToGranularity(Timestamp time)
Returns the timestamp the given time stamp is mapped to in time discretization.
|
public static final Duration DEFAULT_GRANULARITY
public DiscreteEventTimeManager(Timestamp start, Duration granularity)
DiscreteEventTimeManager
. The given start
timestamp and all following timestamps will be rounded according granularity.start
- The desired start time of this time manager.granularity
- The timestamp granularity for this discrete time manager.
All timestamps will fit in this time grid with UNIX epoch as reference.public DiscreteEventTimeManager(Timestamp start)
DiscreteEventTimeManager
. The given start timestamp
and all following timestamps will be rounded according to standard time grid granularity.start
- The desired start time of this time manager.public Duration getGranularity()
public Timestamp roundToGranularity(Timestamp time)
Timestamp.MAX
the method
returns Timestamp.MAX
instead.time
- The timestamp for which to get the discretized timeNullPointerException
- if time is null
public Timestamp currentTime()
TimeProvider
currentTime
in interface TimeProvider
public void paceTime(Timestamp minTimestamp) throws InterruptedException
TimeManager
paceTime
in interface TimeManager
InterruptedException
- if forced pauses are interrupted externally.public void interruptPace()
TimeManager
TimeManager.paceTime(Timestamp)
.
Interface implementations that do not pause just do nothing here.interruptPace
in interface TimeManager
Copyright © Aimpulse Intelligent Systems GmbH
All rights reserved.