jasi.sim.user
Class Timer

java.lang.Object
  extended by jasi.sim.basic.control.AbstractSimListener
      extended by jasi.sim.basic.control.AbstractSimController
          extended by jasi.sim.user.Timer
All Implemented Interfaces:
SimController, SimListener, ElementsListener, CalendarListener

public class Timer
extends AbstractSimController

A standard simulation timer, that advances time according real time with a given speed. For each time advance this timer calculates the duration which is uses to set the simulation thread to sleep.


Constructor Summary
Timer()
          Constructor.
 
Method Summary
 Time advance(Time time, Time next)
          Request an advance of the simulation time.
 void finish(Time time)
          A simulation thread has finished.
 double getSpeed()
          Get the simulation speed factor, given in multiples of realtime.
 void setSpeed(double speed)
          Set the simulation speed factor, given in multiples of real-time.
 Time start(Time time)
          A simulation thread will be started.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class jasi.sim.basic.control.AbstractSimController
change, createdElement, gotException, request
 
Methods inherited from class jasi.sim.basic.control.AbstractSimListener
advancedTime, changedElement, deletedElement, finishedReadingArchive, finishedSimulation, finishedWritingArchive, gotMessage, poppedEvent, pushedEvent, removedEvent, requestedElement, startedSimulation, startReadingArchive, startWritingArchive
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jasi.sim.basic.control.SimListener
advancedTime, finishedReadingArchive, finishedSimulation, finishedWritingArchive, gotMessage, startedSimulation, startReadingArchive, startWritingArchive
 
Methods inherited from interface jasi.sim.basic.element.ElementsListener
changedElement, deletedElement, requestedElement
 
Methods inherited from interface jasi.sim.basic.event.CalendarListener
poppedEvent, pushedEvent, removedEvent
 

Constructor Detail

Timer

public Timer()
Constructor.

Method Detail

start

public Time start(Time time)
A simulation thread will be started. This instance will always grant the requested start time.

Specified by:
start in interface SimController
Overrides:
start in class AbstractSimController
Parameters:
time - The requested start time.
Returns:
The granted start time.
See Also:
AbstractSimKernel.startSimulation()

advance

public Time advance(Time time,
                    Time next)
Request an advance of the simulation time. This instance will always grant the requested time advance.

Specified by:
advance in interface SimController
Overrides:
advance in class AbstractSimController
Parameters:
time - The current time.
next - The requested time advance.
Returns:
The granted time advance.
See Also:
AbstractSimKernel.continueSimulation(jasi.sim.basic.value.Time, jasi.sim.basic.value.Time)

finish

public void finish(Time time)
A simulation thread has finished.

Specified by:
finish in interface SimController
Overrides:
finish in class AbstractSimController
Parameters:
time - The current time.
See Also:
AbstractSimKernel.finishSimulation()

getSpeed

public double getSpeed()
Get the simulation speed factor, given in multiples of realtime.

Specified by:
getSpeed in interface SimController
Overrides:
getSpeed in class AbstractSimController
Returns:
The simulation speed factor.

setSpeed

public void setSpeed(double speed)
Set the simulation speed factor, given in multiples of real-time.

Specified by:
setSpeed in interface SimController
Overrides:
setSpeed in class AbstractSimController
Parameters:
speed - The simulation speed factor.

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class AbstractSimController
Returns:
The string.