ADTF  3.18.2
Clock Concept

ADTF Stream Time

ADTF defines a so called Stream Time that is used as a common base for processing in all components within an ADTF Session. All Samples and Triggers are tagged with a timestamp that is within the time domain of said Stream Time. All Timers will use the Stream Time as base for their processing.

A Streaming Source can use multiple methods (adtf::services::ant::IReferenceClock::ISync2RefChannel) to synchronize external timestamps (obtained from hardware devices) with the ADTF Stream Time such that they can tag their output data correctly and in sync with other external sources.

The clock implementation that provides this Stream Time is called ADTF Stream Clock and can be exchanged depending on the use-case (see adtf::services::ant::IReferenceClock).

During Online Mode (Live) the "system" clock will be used by default and provide timestamps based on UTC.

During Offline Mode (Playback/Re-Simulation) an artifical time is used that allows full deterministic processing. In most cases this will be a discrete clock (which can also be distributed among multiple sessions/hosts), that collects timing requirements from all active components and advances its time in discrete steps. Either trying to mimic real-time or at any custom speed.

ADTF Reference Clock

ADTF delivers a Reference Clock Service that provides a distinct method for getting timestamps within ADTF Stream Time, no matter if the ADTF System is running in Online Mode (Live) or Offline Mode (Playback/Re-Simulation). It allows the registration of many different time sources, that can either be used as time source for the ADTF Stream Time or be recorded for a simulation during playback. The user can configure which time source is used at a single place, without the need for recompilation of any ADTF components. The Service also extends the ADTF System with a mechanism to register and use synchronization algorithms for hardware timestamp conversions, that take clock drift and offset into account, in order to offer the best possible timestamps in the time domain of ADTF Stream Time. This prevents the use of hardcoded solutions and allows changes during configuration. For more information have a look at Clock Synchronization Service and adtf::services::ant::IReferenceClock::ISync2RefChannel.

Time Barrier Architecture

Time Barriers allow ADTF Components to pass timing constraints to the current ADTF Stream Clock.

A Time Barrier is composed of two instants in time, one that can be waited for to start a task and one that marks a time point that should not be crossed before the task has been completed.

Depending on the clock implementation used as ADTF Stream Clock, these barriers are handled in one of the two following ways/scenarios:

Each component within an ADTF Session is allowed to create such Time Barriers via adtf::services::penguin::IReferenceClock::GetTimeGuard(). Most likely Filter, Streaming Service and System Service implementions have no need to do so, as they can rely on the Timer Runner or the adtf::system::kernel_timer implementations.

The following ADTF Components use Time Barriers to express their timing requirements:

Simulation Clocks

The Reference Clock Service provides two simulation clocks that can be used to run an ADTF Session independently from the wall clock.

Discrete Simulation Clock

The ADTF Stream Time will jump in discrete steps from one Time Barrier to the next. Whenever the beginning of a Time Barrier is reached, the thread waiting for it will be woken up to start its task. The time will not advance past the end of any barrier until the barrier is released. If the beginnings of multiple barriers are reached before the next end of a barrier, the corresponding tasks will be executed in parallel. This clock behaves deterministically at arbitrary simulation speeds, deadlines are met by definition.

Continuous Simulation Clock

The ADTF Stream Time will continue to move forward between one Time Barrier and the next. Whenever the beginning of a Time Barrier is reached, the thread waiting for it will be woken up to start its task, but time will advance immediately. If the end of any barrier is reached before the barrier is released, an error for a deadline violation will be reported.

Simulation Setup

The Reference Clock Service provides several properties to control the simulation of time. Please see their documenation for further information. In this section we will show how to handle four example use cases.

Please keep in mind that there are also other services like FEP which can optionally take control of the clock - generally only a single service per session should attempt to parameterize the clock.

Simulation Without a Player

To configure a simulation without a player choose the following property settings at the Reference Clock Service

PropertyValueDescription
stream_clockdiscrete_simulation or continuous_simulation
control_simulation_clockstrue
simulation_clock/start1970-01-01T00:00:00Set it to the the time where your simulation should start
simulation_clock/end1970-01-01T00:00:30Set it to the the time where your simulation should end. If you leave it empty the simulation will continue to run until the session is stopped.

Simulation With a Player that controls the Clock

To configure a simulation with a player that controls the clock (i.e. starts and pauses the clock) choose the following property settings at the Reference Clock Service

PropertyValueDescription
control_simulation_clocksfalse

and the following property settings at the Playback Service

PropertyValueDescription
control_clocktrue
reset_simulation_clocktrue
interpolate_stream_timefalseIf you want the Continuous Simulation Clock to be used, set it to true

Simulation With a Player that does not control the Clock but sets the start time of the simulation

This enables the simulation to start where the playback data beginns but allows it to continue to run past the end. Choose the following property settings at the Reference Clock Service

PropertyValueDescription
stream_clockdiscrete_simulation or continuous_simulation
control_simulation_clockstrue
simulation_clock/startThis needs to be empty. The player will set this.
simulation_clock/end1970-01-01T00:00:30Either leave this empty or set it to a point in time past the beginning of the playback data.

and the following property settings at the Playback Service

PropertyValueDescription
control_clockfalse
reset_simulation_clocktrue

Simulation With a Player that does not control the Clock at all

This enables the simulation to start and stop independently from playback data. Choose the following property settings at the Reference Clock Service

PropertyValueDescription
stream_clockdiscrete_simulation or continuous_simulation
control_simulation_clockstrue
simulation_clock/start1970-01-01T00:00:00Set it to the the time where your simulation should start, this needs to be before where the playback data ends.
simulation_clock/end1970-01-01T00:00:30Either leave this empty or set it to a point in time past the start.

and the following property settings at the Playback Service

PropertyValueDescription
control_clockfalse
reset_simulation_clockfalse