Class SimulationManager
- java.lang.Object
-
- bio.singa.simulation.model.simulation.SimulationManager
-
- All Implemented Interfaces:
Runnable
public class SimulationManager extends Object implements Runnable
Changes in simulations can be observed by taggingAutomatonNodes of theAutomatonGraph. As a standard implementation there is theFlatUpdateRecorderthat can be added to the Simulation that will write log files to the specified file locations.- Author:
- cl
-
-
Constructor Summary
Constructors Constructor Description SimulationManager(Simulation simulation)Creates a new simulation manager for the given simulation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddGraphUpdateListener(bio.singa.core.events.UpdateEventListener<GraphUpdatedEvent> listener)Adds a new listener for graph based events.voidaddNodeUpdateListener(bio.singa.core.events.UpdateEventListener<UpdatableUpdatedEvent> listener)Adds a new listener for node based events.voidemitGraphEvent(Simulation simulation)voidemitNodeEvent(Simulation simulation, Updatable updatable)CopyOnWriteArrayList<bio.singa.core.events.UpdateEventListener<GraphUpdatedEvent>>getGraphListeners()CopyOnWriteArrayList<bio.singa.core.events.UpdateEventListener<UpdatableUpdatedEvent>>getNodeListeners()Returns all currently registered node event listeners.SimulationgetSimulation()Returns the simulation.SimulationStatusgetSimulationStatus()PathgetTargetPath()booleanisWritingAliveFile()booleankeepPlatformOpen()voidrun()voidsetKeepPlatformOpen(boolean keepPlatformOpen)voidsetSimulationTerminationToEpochs(long numberOfEpochs)Schedules the termination of the simulation after the given number of epochs have passed.voidsetSimulationTerminationToTime(javax.measure.Quantity<javax.measure.quantity.Time> time)Schedules the termination of the simulation after the given time (simulation time) has passed.voidsetTargetPath(Path targetPath)voidsetTerminationCondition(Predicate<Simulation> terminationCondition)Sets a condition determining when the simulation should be terminated.voidsetTerminationLatch(CountDownLatch terminationLatch)voidsetUpdateEmissionCondition(Predicate<Simulation> emitCondition)Sets a condition determining when events should be emitted.voidsetUpdateEmissionToTimePassed(javax.measure.Quantity<javax.measure.quantity.Time> timePassed)Schedules the emission of events after the given time (simulation time) has passed.voidsetWriteAliveFile(boolean writeAliveFile)voidtieUpdateEmissionToFPS(int fps)Sets the emission of updates for a rending engine.
-
-
-
Constructor Detail
-
SimulationManager
public SimulationManager(Simulation simulation)
Creates a new simulation manager for the given simulation.- Parameters:
simulation- The simulation.
-
-
Method Detail
-
addNodeUpdateListener
public void addNodeUpdateListener(bio.singa.core.events.UpdateEventListener<UpdatableUpdatedEvent> listener)
Adds a new listener for node based events.- Parameters:
listener- The listener.
-
getNodeListeners
public CopyOnWriteArrayList<bio.singa.core.events.UpdateEventListener<UpdatableUpdatedEvent>> getNodeListeners()
Returns all currently registered node event listeners.- Returns:
- All currently registered node event listeners.
-
addGraphUpdateListener
public void addGraphUpdateListener(bio.singa.core.events.UpdateEventListener<GraphUpdatedEvent> listener)
Adds a new listener for graph based events.- Parameters:
listener- The listener.
-
getGraphListeners
public CopyOnWriteArrayList<bio.singa.core.events.UpdateEventListener<GraphUpdatedEvent>> getGraphListeners()
-
setTerminationCondition
public void setTerminationCondition(Predicate<Simulation> terminationCondition)
Sets a condition determining when the simulation should be terminated.- Parameters:
terminationCondition- The termination condition.
-
setSimulationTerminationToTime
public void setSimulationTerminationToTime(javax.measure.Quantity<javax.measure.quantity.Time> time)
Schedules the termination of the simulation after the given time (simulation time) has passed.- Parameters:
time- The time.
-
setSimulationTerminationToEpochs
public void setSimulationTerminationToEpochs(long numberOfEpochs)
Schedules the termination of the simulation after the given number of epochs have passed.- Parameters:
numberOfEpochs- The number of epochs.
-
setUpdateEmissionCondition
public void setUpdateEmissionCondition(Predicate<Simulation> emitCondition)
Sets a condition determining when events should be emitted.- Parameters:
emitCondition- The emission condition.
-
tieUpdateEmissionToFPS
public void tieUpdateEmissionToFPS(int fps)
Sets the emission of updates for a rending engine. If more epochs are processed than can be displayed the epochs in between are not emitted. If epoch calculation is slower each epoch is emitted.- Parameters:
fps- The frames (emits) per (real time) second.
-
setUpdateEmissionToTimePassed
public void setUpdateEmissionToTimePassed(javax.measure.Quantity<javax.measure.quantity.Time> timePassed)
Schedules the emission of events after the given time (simulation time) has passed.- Parameters:
timePassed- The (simulation) time passed.
-
getSimulationStatus
public SimulationStatus getSimulationStatus()
-
setTerminationLatch
public void setTerminationLatch(CountDownLatch terminationLatch)
-
emitGraphEvent
public void emitGraphEvent(Simulation simulation)
-
emitNodeEvent
public void emitNodeEvent(Simulation simulation, Updatable updatable)
-
keepPlatformOpen
public boolean keepPlatformOpen()
-
setKeepPlatformOpen
public void setKeepPlatformOpen(boolean keepPlatformOpen)
-
isWritingAliveFile
public boolean isWritingAliveFile()
-
setWriteAliveFile
public void setWriteAliveFile(boolean writeAliveFile)
-
getTargetPath
public Path getTargetPath()
-
setTargetPath
public void setTargetPath(Path targetPath)
-
getSimulation
public Simulation getSimulation()
Returns the simulation.- Returns:
- The simulation.
-
-