adevs
Class Simulator

java.lang.Object
  extended by adevs.Simulator

public class Simulator
extends java.lang.Object

This is a wrapper around the C++ Simulator class. It is used in exactly the same way. The Java version of this simulator does not support parallel simulation (yet).


Constructor Summary
Simulator(Devs model)
          Creates a simulator for an Atomic or Network model.
 
Method Summary
 void addEventListener(EventListener l)
          Register a listener to receive callbacks when output and changes in state occur.
 void computeNextOutput()
          Compute the output at the time of the next internal event.
 void computeNextState(java.util.Collection<Event> input, double t)
          Inject input into the model at the specified time.
 void dispose()
          Release the native resources used by this simulator.
 void execNextEvent()
          Compute the output and next state at the next event time.
 void execUntil(double tend)
          Simulate until nextEventTime() is greater than tend.
protected  void finalize()
          Finalizer deletes native resources if they have not already been taken care of by a call to dispose().
 double nextEventTime()
          Get the time of the model's next event.
 void removeEventListener(EventListener l)
          Unregister a listener so that it will not receive callbacks from the simulator.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Simulator

public Simulator(Devs model)
Creates a simulator for an Atomic or Network model.

Parameters:
model - The Network or Atomic model that you want to simulate
See Also:
Atomic
Method Detail

nextEventTime

public double nextEventTime()
Get the time of the model's next event.

Returns:
the time of the next internal event

execNextEvent

public void execNextEvent()
Compute the output and next state at the next event time. This invokes callbacks on the registered listeners.

See Also:
EventListener

execUntil

public void execUntil(double tend)
Simulate until nextEventTime() is greater than tend. This invokes callbacks on registered listeners as the simulation progresses. Note that tend must be greater than or equal to the time of the last event.

Parameters:
tend - time to stop the simulation
See Also:
EventListener

computeNextOutput

public void computeNextOutput()
Compute the output at the time of the next internal event. This invokes the outputEvent method of registered listeners, but it does not change the state of the model or advance the simualtion clock.

See Also:
EventListener

computeNextState

public void computeNextState(java.util.Collection<Event> input,
                             double t)
Inject input into the model at the specified time. The time t must be greater than the time of the last event and less than or equal to the time of the next internal event. This invokes callbacks on registered listeners.

Parameters:
input - The values to inject and the target models
t - Time to apply the input
See Also:
Event

addEventListener

public void addEventListener(EventListener l)
Register a listener to receive callbacks when output and changes in state occur.

Parameters:
l - The listener to register with the simulator
See Also:
EventListener

removeEventListener

public void removeEventListener(EventListener l)
Unregister a listener so that it will not receive callbacks from the simulator.

Parameters:
l - The listener to unregister
See Also:
EventListener

dispose

public void dispose()
Release the native resources used by this simulator. This must be called if you plan to reuse a model in a new instance of a Simulator. This Simulator object will not respond to method calls after its native resources are disposed of.


finalize

protected void finalize()
Finalizer deletes native resources if they have not already been taken care of by a call to dispose().

Overrides:
finalize in class java.lang.Object