nl.tudelft.simulation.dsol.simulators
Class Simulator

java.lang.Object
  extended by nl.tudelft.simulation.event.EventProducer
      extended by nl.tudelft.simulation.dsol.simulators.Simulator
All Implemented Interfaces:
Serializable, Runnable, Remote, SimulatorInterface, EventProducerInterface
Direct Known Subclasses:
DESSSimulator, DEVSSimulator

public abstract class Simulator
extends EventProducer
implements SimulatorInterface, Runnable

The Simulator class is an abstract implementation of the SimulatorInterface.

(c) copyright 2002-2005 Delft University of Technology , the Netherlands.
See for project information www.simulation.tudelft.nl
License of use: Lesser General Public License (LGPL) , no warranty.

Since:
1.4
Version:
$Revision: 1.2 $ $Date: 2007/04/23 15:30:48 $
Author:
Peter Jacobs
See Also:
Serialized Form

Field Summary
protected  Replication replication
          replication represents the currently active replication
protected  boolean running
          running represents the binary state of the simulator
protected  Object semaphore
          the simulatorSemaphore
protected  double simulatorTime
          simulatorTime represents the simulationTime
protected  WorkerThread worker
          a worker
 
Fields inherited from class nl.tudelft.simulation.event.EventProducer
listeners
 
Fields inherited from interface nl.tudelft.simulation.dsol.simulators.SimulatorInterface
END_OF_REPLICATION_EVENT, START_EVENT, START_REPLICATION_EVENT, STEP_EVENT, STOP_EVENT, TIME_CHANGED_EVENT, WARMUP_EVENT
 
Fields inherited from interface nl.tudelft.simulation.event.EventProducerInterface
FIRST_POSITION, LAST_POSITION
 
Constructor Summary
Simulator()
          constructs a new Simulator
 
Method Summary
 Replication getReplication()
          returns the currently executed replication.
 double getSimulatorTime()
          returns the actual simulator time.
 void initialize(Replication replication)
          initializes the simulator with a specified replication.
 boolean isRunning()
          is the simulator running.
abstract  void run()
          The run method defines the actual time step mechanism of the simulator.
 void start()
          starts the simulator
 void step()
          steps the simulator.
 void stop()
          stops the simulator.
 
Methods inherited from class nl.tudelft.simulation.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, getEventTypes, removeAllListeners, removeAllListeners, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface nl.tudelft.simulation.event.EventProducerInterface
addListener, addListener, addListener, addListener, getEventTypes, removeListener
 

Field Detail

simulatorTime

protected double simulatorTime
simulatorTime represents the simulationTime


running

protected transient boolean running
running represents the binary state of the simulator


replication

protected Replication replication
replication represents the currently active replication


worker

protected transient WorkerThread worker
a worker


semaphore

protected transient Object semaphore
the simulatorSemaphore

Constructor Detail

Simulator

public Simulator()
constructs a new Simulator

Method Detail

getSimulatorTime

public double getSimulatorTime()
Description copied from interface: SimulatorInterface
returns the actual simulator time.

Specified by:
getSimulatorTime in interface SimulatorInterface
Returns:
the simulator time.
See Also:
#getSimulatorTime()

getReplication

public Replication getReplication()
Description copied from interface: SimulatorInterface
returns the currently executed replication.

Specified by:
getReplication in interface SimulatorInterface
Returns:
the current replication
See Also:
#getReplication()

initialize

public void initialize(Replication replication)
                throws RemoteException,
                       SimRuntimeException
Description copied from interface: SimulatorInterface
initializes the simulator with a specified replication.

Specified by:
initialize in interface SimulatorInterface
Parameters:
replication - the replication
Throws:
RemoteException - on network failure
SimRuntimeException - on simulator failure (simulator is running)
See Also:
#initialize(Replication)

isRunning

public boolean isRunning()
Description copied from interface: SimulatorInterface
is the simulator running.

Specified by:
isRunning in interface SimulatorInterface
Returns:
boolean
See Also:
SimulatorInterface.isRunning()

run

public abstract void run()
The run method defines the actual time step mechanism of the simulator. The implementation of this method depends on the formalism. Where discrete event formalisms loop over an eventlist continuous simulators take pre-defined time steps.

Specified by:
run in interface Runnable

start

public void start()
           throws SimRuntimeException
Description copied from interface: SimulatorInterface
starts the simulator

Specified by:
start in interface SimulatorInterface
Throws:
SimRuntimeException - whenever starting fails. Possible occasions include starting a started simulator
See Also:
SimulatorInterface.start()

step

public void step()
          throws SimRuntimeException
Description copied from interface: SimulatorInterface
steps the simulator.

Specified by:
step in interface SimulatorInterface
Throws:
SimRuntimeException - whenever stepping fails. Possible occasions include stepping a stopped simulator
See Also:
SimulatorInterface.step()

stop

public void stop()
Description copied from interface: SimulatorInterface
stops the simulator.

Specified by:
stop in interface SimulatorInterface
See Also:
SimulatorInterface.stop()


Copyright © 2002-2010 Delft University of Technology, the Netherlands. All Rights Reserved.