Class TimeSyncState


  • public class TimeSyncState
    extends java.lang.Object
    An object encapsulating the necessary internal parameters for fake test time generation.
    Author:
    Rene Schneider - initial API and implementation
    • Field Detail

      • LIVE

        public static final TimeSyncState LIVE
        This instance represents live time.
    • Constructor Detail

      • TimeSyncState

        public TimeSyncState​(long aRealtimeOffset,
                             long aRealtimeDecouplingTime,
                             double aProgressionFactor)
        Constructor.
        Parameters:
        aRealtimeOffset - The offset from realtime, in msecs since 1.1.1970.
        aRealtimeDecouplingTime - The time at which the fake time was decoupled from realtime, in msecs since 1.1.1970.
        aProgressionFactor - A time progression factor (1.0 = realtime, 0.0 = frozen).
      • TimeSyncState

        public TimeSyncState​(java.lang.String anInternalsString)
        Constructor using a data string previously generated by getValuesAsString().
        Parameters:
        anInternalsString - the string to use as source
      • TimeSyncState

        public TimeSyncState()
        Constructs an instance that represents local live time.
    • Method Detail

      • getProgressionFactor

        public double getProgressionFactor()
      • getRealtimeDecouplingTime

        public long getRealtimeDecouplingTime()
      • getRealtimeOffset

        public long getRealtimeOffset()
      • getValuesAsString

        public java.lang.String getValuesAsString()
        Returns the values of this TimeSyncState as a String. This string is intended to be fed into another TimeSyncState in order to synchronize it with the source. The string consists of pipe-divided values "realtime offset", "realtime decoupling time" and "multiplier" (first two are long values, third is a double-precision floating point number in normal notation with decimal point).
        Returns:
        the internal values as string without spaces
      • plus

        public TimeSyncState plus​(java.util.List<org.eclipse.xtext.util.Pair<java.lang.Long,​java.time.temporal.TemporalUnit>> aDiffTime)
        Returns a new instance of this TimeSyncState to which the given duration was added. This does NOT modify the state that it is called upon!
        Parameters:
        aDiffTime - the time to add (negative = subtract)
        Returns:
        a new TimeSyncState instance
      • calculateCurrentZonedDateTime

        public java.time.ZonedDateTime calculateCurrentZonedDateTime()
        Calculates the current date/time according to the states' parameters.
        Returns:
      • calculateCurrentDateTime

        public java.time.LocalDateTime calculateCurrentDateTime()
        Calculates the current date/time according to the states' parameters.
        Returns:
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object