jasi.sim.basic.control
Class AbstractSimController

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

public abstract class AbstractSimController
extends AbstractSimListener
implements SimController

Basic simulation controller. An instance of this class allows to control the execution the simulation task. This simulation controller will always run as fast as possible.


Constructor Summary
AbstractSimController()
           
 
Method Summary
 Time advance(Time time, Time next)
          Request an advance of the simulation time.
<T> boolean
change(Element element, java.lang.String name, T value)
          Request the change of the value of a simulation element's attribute/property.
 void createdElement(Element element)
          A new simulation element has been created and registered.
 void finish(Time time)
          A simulation thread has finished.
 double getSpeed()
          Get the simulation speed factor, given in multiples of real-time.
 void gotException(java.lang.Exception e)
          An exception occurred during simulation.
<T> T
request(Element element, java.lang.String name, T value)
          The value of a simulation element's attribute/property is requested for reading.
 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.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

AbstractSimController

public AbstractSimController()
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
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
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
Parameters:
time - The current time.
See Also:
AbstractSimKernel.finishSimulation()

change

public <T> boolean change(Element element,
                          java.lang.String name,
                          T value)
Request the change of the value of a simulation element's attribute/property. This instance will always grant the request to change.

Specified by:
change in interface SimController
Type Parameters:
T - The value type.
Parameters:
element - The simulation element.
name - The attribute's name.
value - The new value of the attribute.
Returns:
True, if the request to change is granted.

request

public <T> T request(Element element,
                     java.lang.String name,
                     T value)
The value of a simulation element's attribute/property is requested for reading. This instance will always grant the request for reading.

Specified by:
request in interface SimController
Type Parameters:
T - The value type.
Parameters:
element - The simulation element.
name - The attribute's name.
value - The current value of the attribute.
Returns:
True, if request for reading is granted.

createdElement

public void createdElement(Element element)
A new simulation element has been created and registered. This instance will set the external ID by using the internal ID, if not already set.

Specified by:
createdElement in interface ElementsListener
Overrides:
createdElement in class AbstractSimListener
Parameters:
element - The created simulation element.

gotException

public void gotException(java.lang.Exception e)
An exception occurred during simulation. This instance will print a trace of the method stack to the console.

Specified by:
gotException in interface SimListener
Overrides:
gotException in class AbstractSimListener
Parameters:
e - The exception.

setSpeed

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

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

getSpeed

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

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

toString

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

Overrides:
toString in class java.lang.Object
Returns:
The string.