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

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

public class ScriptState
extends ScriptComponent

Represents a state to wait for in a script.


Field Summary
static int BRIDGE_PORT_STATE_CHANGED
          Bridge Port State Changed state.
 int bridgeID
          Bridge ID.
 int bridgePort
          Bridge Port.
 int dstHostAddress
          Destination Host address.
static int HOST_GETS_PACKET
          Host Receives a Packet state.
 boolean pause
          Whether or not the simulation should pause when this state is reached.
 int portState
          Bridge Port state.
static int ROOT_ID_AT_BRIDGE
          Root ID at Bridge Changed state.
 int rootID
          Root ID.
static int SLEEP
          Sleep state.
static int SPANNING_TREE_ALGORITHM_COMPLETE
          Spanning Tree Algorithm Complete state.
 int srcHostAddress
          Source Host address.
 int time
          Time to wait.
 int type
          Type of this state.
 int waited
          Time waited.
 
Constructor Summary
private ScriptState(int type, boolean pause)
          Creates a new ScriptState of the specified type.
 
Method Summary
 boolean check(Network network, java.util.Vector<NetworkEvent> events, boolean first)
          Check if this state has been reached on the network.
static ScriptState createBridgePortStateChanged(int bridgeID, int bridgePort, int portState, boolean pause)
          Creates a new Bridge Port State Changed state.
static ScriptState createHostGetsPacket(int srcHostAddress, int dstHostAddress, boolean pause)
          Creates a new Host Received Packet state.
static ScriptState createRootIDatBridge(int bridgeID, int rootID, boolean pause)
          Creates a new Root ID Changed state.
static ScriptState createSleep(int time, boolean pause)
          Creates a new Sleep state.
static ScriptState createSpanningTreeAlgorithmComplete(int bridgeID, boolean pause)
          Creates a new Spanning Tree Algorithm Complete state.
 java.lang.String toString()
          Gets a string representation of this state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SPANNING_TREE_ALGORITHM_COMPLETE

public static final int SPANNING_TREE_ALGORITHM_COMPLETE
Spanning Tree Algorithm Complete state.

See Also:
Constant Field Values

BRIDGE_PORT_STATE_CHANGED

public static final int BRIDGE_PORT_STATE_CHANGED
Bridge Port State Changed state.

See Also:
Constant Field Values

HOST_GETS_PACKET

public static final int HOST_GETS_PACKET
Host Receives a Packet state.

See Also:
Constant Field Values

ROOT_ID_AT_BRIDGE

public static final int ROOT_ID_AT_BRIDGE
Root ID at Bridge Changed state.

See Also:
Constant Field Values

SLEEP

public static final int SLEEP
Sleep state.

See Also:
Constant Field Values

type

public int type
Type of this state.


pause

public boolean pause
Whether or not the simulation should pause when this state is reached.


bridgeID

public int bridgeID
Bridge ID.


bridgePort

public int bridgePort
Bridge Port.


portState

public int portState
Bridge Port state.


rootID

public int rootID
Root ID.


srcHostAddress

public int srcHostAddress
Source Host address.


dstHostAddress

public int dstHostAddress
Destination Host address.


time

public int time
Time to wait.


waited

public int waited
Time waited.

Constructor Detail

ScriptState

private ScriptState(int type,
                    boolean pause)
Creates a new ScriptState of the specified type.

Parameters:
type - The type of state to create.
pause - Whether or not the simulation should pause when this state is reached.
Method Detail

createSpanningTreeAlgorithmComplete

public static ScriptState createSpanningTreeAlgorithmComplete(int bridgeID,
                                                              boolean pause)
Creates a new Spanning Tree Algorithm Complete state.

Parameters:
bridgeID - The Bridge ID to check the network from.
pause - Whether or not the simulation should pause when this state is reached.
Returns:
A new ScriptState.

createBridgePortStateChanged

public static ScriptState createBridgePortStateChanged(int bridgeID,
                                                       int bridgePort,
                                                       int portState,
                                                       boolean pause)
Creates a new Bridge Port State Changed state.

Parameters:
bridgeID - The Bridge ID.
bridgePort - The Bridge Port ID.
portState - The state the port should have changed to.
pause - Whether or not the simulation should pause when this state is reached.
Returns:
A new ScriptState.

createHostGetsPacket

public static ScriptState createHostGetsPacket(int srcHostAddress,
                                               int dstHostAddress,
                                               boolean pause)
Creates a new Host Received Packet state.

Parameters:
srcHostAddress - The source Host address.
dstHostAddress - The destination Host address.
pause - Whether or not the simulation should pause when this state is reached.
Returns:
A new ScriptState.

createRootIDatBridge

public static ScriptState createRootIDatBridge(int bridgeID,
                                               int rootID,
                                               boolean pause)
Creates a new Root ID Changed state.

Parameters:
bridgeID - The Bridge ID.
rootID - The root ID the bridge should have changed to.
pause - Whether or not the simulation should pause when this state is reached.
Returns:
A new ScriptState.

createSleep

public static ScriptState createSleep(int time,
                                      boolean pause)
Creates a new Sleep state.

Parameters:
time - The time to sleep for in seconds.
pause - Whether or not the simulation should pause when this state is reached.
Returns:
A new ScriptState.

check

public boolean check(Network network,
                     java.util.Vector<NetworkEvent> events,
                     boolean first)
Check if this state has been reached on the network.

Parameters:
network - The Network to check the state on.
events - A list of events that have occured.
first - true if this is the first time this state has been checked in this run of the Script.
Returns:
true if the state has been reached.

toString

public java.lang.String toString()
Gets a string representation of this state.

Overrides:
toString in class java.lang.Object
Returns:
String explaining what this state is waiting for.