The Physiologist's Friend Simulation API

ch.unizh.ini.friend.simulation
Class AbstractSimulation

java.lang.Object
  extended by ch.unizh.ini.friend.simulation.AbstractSimulation
All Implemented Interfaces:
SimulationTask
Direct Known Subclasses:
ThreadedSimulation, TimedSimulation

public abstract class AbstractSimulation
extends Object
implements SimulationTask

Provides a few default implementations for the SimulationTask interface.

Version:
$Revision: 1.5 $
Author:
Christof Marti

Field Summary
protected  long delay
          delay in ms between thread simulation update cycles
protected  boolean on
          False iff the simulation should stop.
protected  SimulationStep step
          The simulation step.
 
Constructor Summary
AbstractSimulation(SimulationStep step)
          Creates a new instance with the given simulation step.
 
Method Summary
abstract  void addUpdateable(Updateable u)
          Adds an updateable to the simulation.
 long getDelay()
           
 int getNumberOfIterationsPerStep()
           
 SimulationStep getStep()
          Returns the simulation step instance.
 boolean isOn()
          Returns true if the simulation is running.
abstract  void removeUpdateable(Updateable u)
          Removes an updateable from the simulation.
 void setDelay(long ms)
          set the timer delay in ms between each simulation step
 void setNumberOfIterationsPerStep(int n)
          set the number of iterations over the updateables for each step.
abstract  void start()
          Starts the simulation.
abstract  void stop()
          Stops the simulation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

on

protected volatile boolean on
False iff the simulation should stop.


step

protected SimulationStep step
The simulation step.


delay

protected long delay
delay in ms between thread simulation update cycles

Constructor Detail

AbstractSimulation

public AbstractSimulation(SimulationStep step)
Creates a new instance with the given simulation step.

Parameters:
step - The simulation step instance.
Method Detail

getStep

public SimulationStep getStep()
Returns the simulation step instance.

Specified by:
getStep in interface SimulationTask
Returns:
The simulation step.

isOn

public boolean isOn()
Returns true if the simulation is running.

Returns:
True if the simulation is running.

addUpdateable

public abstract void addUpdateable(Updateable u)
Adds an updateable to the simulation.

Specified by:
addUpdateable in interface SimulationTask
Parameters:
u - An updateable.

getDelay

public long getDelay()
Specified by:
getDelay in interface SimulationTask
Returns:
the delay between simulation steps in ms
See Also:
setDelay(long)

getNumberOfIterationsPerStep

public int getNumberOfIterationsPerStep()
Specified by:
getNumberOfIterationsPerStep in interface SimulationTask
Returns:
the number of simulation iterations per step
See Also:
setNumberOfIterationsPerStep(int)

removeUpdateable

public abstract void removeUpdateable(Updateable u)
Removes an updateable from the simulation.

Specified by:
removeUpdateable in interface SimulationTask
Parameters:
u - An updateable.

setDelay

public void setDelay(long ms)
set the timer delay in ms between each simulation step

Specified by:
setDelay in interface SimulationTask
Parameters:
ms - the delay in ms
See Also:
getDelay()

setNumberOfIterationsPerStep

public void setNumberOfIterationsPerStep(int n)
set the number of iterations over the updateables for each step. This is used for example to propogate an input through a feedforward network more quickly per GUI update. Since a change at the input of a network that is N deep takes at least N cycles to get to the output (owing to the double-buffering), you should set the number of iterations to N if you want an input to have an effect in the same simulation step.

Specified by:
setNumberOfIterationsPerStep in interface SimulationTask
Parameters:
n - the number

start

public abstract void start()
Starts the simulation.

Specified by:
start in interface SimulationTask

stop

public abstract void stop()
Stops the simulation.

Specified by:
stop in interface SimulationTask

http://www.ini.unizh.ch/~tobi/friend