Class AbstractClock

    • Field Detail

      • DEFAULT_DELTA

        public static final long DEFAULT_DELTA
        The default delta (tick time).
        See Also:
        Constant Field Values
      • name

        protected java.lang.String name
        The clock name.
      • starttime

        protected long starttime
        The start time (model time).
      • currenttime

        protected long currenttime
        The current time (last measurement).
      • delta

        protected long delta
        The clock tick delta (relative to base time).
      • state

        protected java.lang.String state
        The clock state.
      • ticktimers

        protected java.util.List ticktimers
        The tick timers.
      • timers

        public java.util.SortedSet timers
        The timers (entries ordered by timepoint).
      • ticktimer

        protected Timer ticktimer
        The tick timer.
      • listeners

        protected java.util.List listeners
        The change listeners.
    • Constructor Detail

      • AbstractClock

        public AbstractClock​(java.lang.String name,
                             long starttime,
                             long delta)
        Create a new clock.
    • Method Detail

      • copyFromClock

        public void copyFromClock​(IClock oldclock)
        Transfer state from another clock to this clock.
      • dispose

        public void dispose()
        Called, when the clock is no longer used.
        Specified by:
        dispose in interface IClock
      • getName

        public java.lang.String getName()
        Get the current time.
        Specified by:
        getName in interface IClock
        Returns:
        The current time.
      • getStarttime

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

        public void setStarttime​(long starttime)
        Set the clocks start time.
        Specified by:
        setStarttime in interface IClock
        Parameters:
        starttime - The start time.
      • getTime

        public long getTime()
        Get the clocks name.
        Specified by:
        getTime in interface IClock
        Returns:
        The name.
      • getTick

        public double getTick()
        Get the current tick.
        Specified by:
        getTick in interface IClock
        Returns:
        The current tick (can be in between ticks). Returns -1 if no tick size was specified (delta==0).
      • getDelta

        public long getDelta()
        Get the clock delta.
        Specified by:
        getDelta in interface IClock
        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 IClock
      • getNextTimer

        public ITimer getNextTimer()
        Get the next timer.
        Specified by:
        getNextTimer in interface IClock
        Returns:
        The next timer.
      • getState

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

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

        public void stop()
        Stop the clock.
        Specified by:
        stop in interface IClock
      • reset

        public void reset()
        Reset the clock.
        Specified by:
        reset in interface IClock
      • createTimer

        public ITimer createTimer​(long timespan,
                                  ITimedObject to)
        Create a new timer.
        Specified by:
        createTimer in interface IClock
        Parameters:
        timespan - The timespan.
        to - The timed object.
      • createTickTimer

        public ITimer createTickTimer​(ITimedObject to)
        Create a new tick timer.
        Specified by:
        createTickTimer in interface IClock
        Parameters:
        to - The timed object.
        info - Optional info object.
      • getTimers

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

        public ITimer[] getTickTimers()
        Get all active tick timers.
        Specified by:
        getTickTimers in interface IClock
        Returns:
        The active tick timers.
      • addTimer

        public void addTimer​(ITimer timer)
        Add a timer.
        Specified by:
        addTimer in interface IClock
        Parameters:
        timer - The timer.
      • removeTimer

        public void removeTimer​(ITimer timer)
        Remove a timer.
        Specified by:
        removeTimer in interface IClock
        Parameters:
        timer - The timer.
      • addTickTimer

        public void addTickTimer​(ITimer timer)
        Add a tick timer.
        Specified by:
        addTickTimer in interface IClock
        Parameters:
        timer - The timer.
      • activateTickTimer

        protected void activateTickTimer()
        Activate the tick timer.
      • removeTickTimer

        public void removeTickTimer​(ITimer timer)
        Remove a tick timer.
        Specified by:
        removeTickTimer in interface IClock
        Parameters:
        timer - The timer.
      • addChangeListener

        public void addChangeListener​(IChangeListener listener)
        Add a change listener.
        Specified by:
        addChangeListener in interface IClock
        Parameters:
        listener - The change listener.
      • removeChangeListener

        public void removeChangeListener​(IChangeListener listener)
        Remove a change listener.
        Specified by:
        removeChangeListener in interface IClock
        Parameters:
        listener - The change listener.
      • notifyListeners

        protected void notifyListeners​(ChangeEvent ce)
        Notify the listeners.
      • hasListeners

        protected boolean hasListeners()
        Check if the clock has listeners.
      • shutdown

        public void shutdown​(IResultListener listener)
        Shutdown the service.
        Parameters:
        listener - The listener.