uk.org.arlott.simon.hw.f24.lbsta
Class NetworkSimulation

java.lang.Object
  extended by uk.org.arlott.simon.hw.f24.lbsta.NetworkSimulation

public class NetworkSimulation
extends java.lang.Object

Simulation handler.


Nested Class Summary
private  class NetworkSimulation.Task
          The simulation task.
 
Field Summary
private  java.lang.Boolean active
          Simulation active flag.
private  double aimSpeed
          The speed to aim for.
static int DEFAULT_SPEED
          The default speed of the simulation.
private  java.lang.String lastScriptState
          The last script state string.
static int MAXIMUM_SPEED
          The maximum speed of the simulation.
static int MINIMUM_SPEED
          The minimum speed of the simulation.
private  Network network
          The Network to simulate on.
private  NetworkView networkView
          The NetworkView to update.
private  double oldSpeed
          The previous speed.
private  java.lang.Boolean running
          Simulation should be running flag.
private  Script script
          The Script to simulate with.
private  java.util.Timer simulation
          The simulation timer.
private  double speed
          The current speed.
private  boolean steppingMode
          Whether or not stepping mode is being used.
 
Constructor Summary
NetworkSimulation(Network network, NetworkView networkView, Script script)
          Creates a new network simulation handler.
 
Method Summary
 void restart()
          Restarts the simulation.
 void setSpeed(int speed)
          Changes the speed of the simulation.
 void start(boolean steppingMode)
          Starts the simulation.
 void stop(boolean block)
          Stops the simulation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MINIMUM_SPEED

public static final int MINIMUM_SPEED
The minimum speed of the simulation.

See Also:
Constant Field Values

MAXIMUM_SPEED

public static final int MAXIMUM_SPEED
The maximum speed of the simulation.

See Also:
Constant Field Values

DEFAULT_SPEED

public static final int DEFAULT_SPEED
The default speed of the simulation.

See Also:
Constant Field Values

simulation

private java.util.Timer simulation
The simulation timer.


network

private Network network
The Network to simulate on.


networkView

private NetworkView networkView
The NetworkView to update.


script

private Script script
The Script to simulate with.


aimSpeed

private double aimSpeed
The speed to aim for.


speed

private double speed
The current speed.


oldSpeed

private double oldSpeed
The previous speed.


active

private java.lang.Boolean active
Simulation active flag.


running

private java.lang.Boolean running
Simulation should be running flag.


steppingMode

private boolean steppingMode
Whether or not stepping mode is being used.


lastScriptState

private java.lang.String lastScriptState
The last script state string.

Constructor Detail

NetworkSimulation

public NetworkSimulation(Network network,
                         NetworkView networkView,
                         Script script)
Creates a new network simulation handler.

Parameters:
network - The Network.
networkView - The NetworkView.
script - The Script.
Method Detail

restart

public void restart()
Restarts the simulation.


start

public void start(boolean steppingMode)
Starts the simulation.

Parameters:
steppingMode - Use stepping mode.

stop

public void stop(boolean block)
Stops the simulation.

Parameters:
block - Wait until the simulation is stopped before returning.

setSpeed

public void setSpeed(int speed)
Changes the speed of the simulation.

Parameters:
speed - The new speed to aim for.