com.speckled.specksim.state
Class SimulatorState

java.lang.Object
  extended by com.speckled.specksim.state.SimulatorState

public class SimulatorState
extends java.lang.Object

Encapsulates the interesting state of a simulation at a specific moment.

Author:
ryanm

Constructor Summary
SimulatorState(byte[] data)
          Constructs a SimulatorState from encoded data
SimulatorState(SpeckSim simulator)
          Constructs a SimulatorState from the supplied simulator
 
Method Summary
 byte[] encode()
          Encodes the state of this state object to a byte array
 SerializableState getBroadcastDetails()
          Gets details of active and completed broadcasts.
 SerializableState getEnvironmentState(java.lang.String name)
          Gets the state object of a specific Environment object
 java.lang.Object getMovementModelState()
          Gets the state of the movement model
 SpeckPosition[] getPositions()
          Gets an array of the positions of all the specks in the simulator
 long getRealTime()
          Gets the real-world time at which this SimulatorState was extracted from the simulator.
 float getSimTime()
          Gets the simulator time at which this SimulatorState was extracted from the simulator
 SpeckState[] getSpecks()
          Gets an array containing the states of all the Specks in the simulator.
 Wall[] getWallVertices()
          Gets the vertices of the walls in the simulator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimulatorState

public SimulatorState(SpeckSim simulator)
Constructs a SimulatorState from the supplied simulator

Parameters:
simulator - The simulator to sample

SimulatorState

public SimulatorState(byte[] data)
               throws java.io.IOException
Constructs a SimulatorState from encoded data

Parameters:
data - The encoded data
Throws:
java.io.IOException
Method Detail

encode

public byte[] encode()
Encodes the state of this state object to a byte array

Returns:
A byte array that can be used to construct an identical state

getSpecks

public SpeckState[] getSpecks()
Gets an array containing the states of all the Specks in the simulator. This array can assumed to be sorted into order of ascending IDs

Returns:
An array of SpeckState objects

getPositions

public SpeckPosition[] getPositions()
Gets an array of the positions of all the specks in the simulator

Returns:
An array of SpeckPositions

getWallVertices

public Wall[] getWallVertices()
Gets the vertices of the walls in the simulator

Returns:
an array of Wall objects

getSimTime

public float getSimTime()
Gets the simulator time at which this SimulatorState was extracted from the simulator

Returns:
The simulator time.

getRealTime

public long getRealTime()
Gets the real-world time at which this SimulatorState was extracted from the simulator.

Returns:
The real-world time at which this state was created

getBroadcastDetails

public SerializableState getBroadcastDetails()
Gets details of active and completed broadcasts. Details will be included for broadcasts that concluded in the last 5 simulated seconds

Returns:
Details on active and completed broadcasts

getMovementModelState

public java.lang.Object getMovementModelState()
Gets the state of the movement model

Returns:
Returns the movement model state.
See Also:
MovementModel

getEnvironmentState

public SerializableState getEnvironmentState(java.lang.String name)
Gets the state object of a specific Environment object

Parameters:
name - The name of the Environment object
Returns:
The state object from that Environment, or null if there is no such state object