Class ClockService

    • Field Detail

      • clock

        protected IClock clock
        The clock.
      • threadpool

        protected IThreadPool threadpool
        The threadpool.
      • listeners

        protected java.util.List<IChangeListener> listeners
        The clock listeners.
      • timer

        protected java.util.Timer timer
        The realtime timer.
    • Method Detail

      • getTime

        public long getTime()
        Get the current time.
        Specified by:
        getTime in interface IClockService
        Returns:
        The current time.
      • setTime

        public void setTime​(long time)
        Set the current time.
        Parameters:
        time - The current time.
      • getTick

        public double getTick()
        Get the current tick.
        Specified by:
        getTick in interface IClockService
        Returns:
        The current tick.
      • getStarttime

        public long getStarttime()
        Get the clocks start time.
        Specified by:
        getStarttime in interface IClockService
        Returns:
        The start time.
      • getDelta

        public long getDelta()
        Get the clock delta.
        Specified by:
        getDelta in interface IClockService
        Returns:
        The clock delta.
      • setDelta

        public void setDelta​(long delta)
        Set the clock delta. param delta The new clock delta.
        Specified by:
        setDelta in interface IClockService
        Parameters:
        delta - The new clock delta.
      • getState

        public java.lang.String getState()
        Get the clock state.
        Specified by:
        getState in interface IClockService
        Returns:
        The clock state.
      • getDilation

        public double getDilation()
        Get the clocks dilation.
        Specified by:
        getDilation in interface IClockService
        Returns:
        The clocks dilation. // Hack!!! only for continuous clock.
      • setDilation

        public void setDilation​(double dilation)
        Set the clocks dilation.
        Specified by:
        setDilation in interface IClockService
        Parameters:
        dilation - The clocks dilation. // Hack. Remove? only for continuous
      • getClockType

        public java.lang.String getClockType()
        Get the clock type.
        Specified by:
        getClockType in interface IClockService
        Returns:
        The clock type.
      • createTimer

        public ITimer createTimer​(long time,
                                  ITimedObject to)
        Create a new timer. The unit of the timespan value depends on the clock implementation. For system clocks, the time value should adhere to the time representation as used by System.currentTimeMillis().
        Specified by:
        createTimer in interface IClockService
        Parameters:
        timespan - The relative timespan after which the timed object should be notified.
        to - The timed object.
      • createTickTimer

        public ITimer createTickTimer​(ITimedObject to)
        Create a new tick timer. todo: @param tickcount The number of ticks.
        Specified by:
        createTickTimer in interface IClockService
        Parameters:
        to - The timed object.
      • createRealtimeTimer

        public java.util.TimerTask createRealtimeTimer​(long time,
                                                       ITimedObject to)
        Create a new realtime timer.
        Specified by:
        createRealtimeTimer in interface IClockService
        Parameters:
        timespan - The relative timespan after which the timed object should be notified.
        to - The timed object.
      • getTimers

        public ITimer[] getTimers()
        Get all active timers.
        Specified by:
        getTimers in interface IClockService
        Returns:
        The active timers.
      • advanceEvent

        public boolean advanceEvent()
        Advance one event.
        Specified by:
        advanceEvent in interface IClockService
        Returns:
        True, if clock could be advanced.
      • start

        public void start()
        Start the clock.
        Specified by:
        start in interface IClockService
      • stop

        public void stop()
        Stop the clock.
        Specified by:
        stop in interface IClockService
      • startService

        public IFuture<java.lang.Void> startService()
        Start the service.
        Specified by:
        startService in interface IInternalService
        Returns:
        A future that is done when the service has completed starting.
      • shutdownService

        public IFuture<java.lang.Void> shutdownService()
        Shutdown the service.
        Specified by:
        shutdownService in interface IInternalService
        Parameters:
        listener - The listener.
        Returns:
        A future that is done when the service has completed its shutdown.
      • setClock

        public void setClock​(java.lang.String type,
                             IThreadPool tp)
        Change the clock.
        Specified by:
        setClock in interface IClockService
        Parameters:
        type - The new clock type