Boeing Simulation 3.1 API Specification

worldsimulator
Class SimulatorBus

java.lang.Object
  |
  +--objects.WhatWhere
        |
        +--objects.MovableWhatWhere
              |
              +--worldsimulator.SocketSimulatorComponentTemplate
                    |
                    +--worldsimulator.SimulatorBus
All Implemented Interfaces:
Component, Destroyable, Extensible, Locatable, Movable, Runnable, Serializable, Targetable

public class SimulatorBus
extends SocketSimulatorComponentTemplate
implements Serializable, Destroyable

A simulated bus that randomly selects a location to move towards and then reselects another random one upon arrival. This implementation is designed to interact with the ComponentizedSimulator.

See Also:
Serialized Form

Field Summary
protected static objects.Dimension BUS_DIMENSIONS
          The default dimensions of this object.
protected static double BUS_MOVEMENT_DISTANCE
          The unit square distance a bus is allowed to travel in one period.
protected static long BUS_STEP_COST
          The time in milliseconds in which at step method can start and finish its execution.
protected static long BUS_UPDATE_PERIOD
          The delay in milliseconds between the start of the periodic run method calls.
private  boolean destroyed
          Flag indicating whether this bus is destroyed.
private  objects.Location goal
          The location that this bus will move towards.
private  Long id
          The unique ID used to distinguish this bus from another bus.
private static long serialVersionUID
           
private  boolean targeted
          Flag indicating whether this bus is targeted.
 
Fields inherited from class worldsimulator.SocketSimulatorComponentTemplate
simulatorConnection, simulatorQueue
 
Fields inherited from class objects.WhatWhere
dim, loc
 
Constructor Summary
SimulatorBus(connect.CreatesConnection toSimulator)
           
SimulatorBus(objects.Location loc, connect.CreatesConnection toSimulator)
           
SimulatorBus(objects.Location loc, objects.Location goal, connect.CreatesConnection toSimulator)
           
 
Method Summary
 boolean accept(Class requestingType)
          Returns true if the requesting component is allowed to control the actions of this bus.
protected  boolean allowMethod(util.MethodRequest request)
          Returns true if this object accepts the method being invoked upon itself.
 void connect(connect.CreatesConnection host)
          This method should not be called in the current implementaiton
 void destroy()
          Marks this bus as being destroyed and stops all movement.
 boolean equals(Object other)
          Returns true if the object is a SimulatorBus and has the same ID value.
 long getID()
          Returns the ID of this object.
protected  long getStepCost()
          Returns the time interval in milliseconds in which the step function may be called and return.
protected  long getUpdatePeriod()
          Returns the time in milliseconds between subsequent calls of the periodic step function.
 int hashCode()
          Returns the hash code based on its ID.
 boolean isDestroyed()
          Returns whether this object has been destroyed.
 boolean isTargeted()
          Returns whether this object is currently targeted.
protected  void processIncomingConnection(Class hostType, connect.ChannelBundle bundle)
          Handles the bevahior of this component when another component initiates the connection to this component.
protected  void processOutgoingConnection(Class hostType, connect.ChannelBundle bundle)
          Handles the bevahior of this component when it initiates a connection to a remote component
 void setAsTargeted()
          Marks this object as targeted.
 void setAsUntargeted()
          Marks this object as untargeted.
 void setGoal(objects.Location goal)
           
 void step()
          Moves the bus one update distance towards its current gaol, then notifies the ComponentizedSimulator of its progress.
 String toString()
           
 
Methods inherited from class worldsimulator.SocketSimulatorComponentTemplate
debug, getComponentEmissary, getConnection, getObject, getOverrunLogic, isStarted, run, startPeriodicMovements, stopPeriodicRun
 
Methods inherited from class objects.MovableWhatWhere
setLoc, setLoc
 
Methods inherited from class objects.WhatWhere
bound, getCenter, getDimensions, getDistance, getHeight, getLoc, getWidth, isEastOf, isNorthOf, isSouthOf, isWestOf, overlaps
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface objects.Locatable
getDistance, getLoc, isEastOf, isNorthOf, isSouthOf, isWestOf
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

BUS_DIMENSIONS

protected static final objects.Dimension BUS_DIMENSIONS
The default dimensions of this object.


BUS_UPDATE_PERIOD

protected static final long BUS_UPDATE_PERIOD
The delay in milliseconds between the start of the periodic run method calls.

See Also:
Constant Field Values

BUS_STEP_COST

protected static final long BUS_STEP_COST
The time in milliseconds in which at step method can start and finish its execution.

See Also:
Constant Field Values

BUS_MOVEMENT_DISTANCE

protected static final double BUS_MOVEMENT_DISTANCE
The unit square distance a bus is allowed to travel in one period.

See Also:
Constant Field Values

destroyed

private boolean destroyed
Flag indicating whether this bus is destroyed.


goal

private objects.Location goal
The location that this bus will move towards.


id

private final Long id
The unique ID used to distinguish this bus from another bus.


targeted

private boolean targeted
Flag indicating whether this bus is targeted.

Constructor Detail

SimulatorBus

public SimulatorBus(objects.Location loc,
                    objects.Location goal,
                    connect.CreatesConnection toSimulator)

SimulatorBus

public SimulatorBus(objects.Location loc,
                    connect.CreatesConnection toSimulator)

SimulatorBus

public SimulatorBus(connect.CreatesConnection toSimulator)
Method Detail

accept

public boolean accept(Class requestingType)
Returns true if the requesting component is allowed to control the actions of this bus.

Specified by:
accept in class SocketSimulatorComponentTemplate

allowMethod

protected boolean allowMethod(util.MethodRequest request)
Description copied from class: SocketSimulatorComponentTemplate
Returns true if this object accepts the method being invoked upon itself.

Specified by:
allowMethod in class SocketSimulatorComponentTemplate

connect

public void connect(connect.CreatesConnection host)
This method should not be called in the current implementaiton

Specified by:
connect in interface Component
Overrides:
connect in class SocketSimulatorComponentTemplate
See Also:
SocketComponentTemplate.allowMethod(util.MethodRequest)

destroy

public void destroy()
Marks this bus as being destroyed and stops all movement.

Specified by:
destroy in interface Destroyable

equals

public boolean equals(Object other)
Returns true if the object is a SimulatorBus and has the same ID value. Note that this is not completely safe among disturbed systems since two SimulatorBuses may get the same ID. However the chance of that happening is n * (1 / (2^63 -1)), where n is the total number of SimulatorBus objects.

Specified by:
equals in class SocketSimulatorComponentTemplate

getID

public long getID()
Returns the ID of this object.


getStepCost

protected long getStepCost()
Description copied from class: SocketSimulatorComponentTemplate
Returns the time interval in milliseconds in which the step function may be called and return.

Specified by:
getStepCost in class SocketSimulatorComponentTemplate
See Also:
SocketSimulatorComponentTemplate.step()

getUpdatePeriod

protected long getUpdatePeriod()
Description copied from class: SocketSimulatorComponentTemplate
Returns the time in milliseconds between subsequent calls of the periodic step function.

Specified by:
getUpdatePeriod in class SocketSimulatorComponentTemplate
See Also:
SocketSimulatorComponentTemplate.step()

hashCode

public int hashCode()
Returns the hash code based on its ID.

Specified by:
hashCode in class SocketSimulatorComponentTemplate

isDestroyed

public boolean isDestroyed()
Description copied from interface: Destroyable
Returns whether this object has been destroyed.

Specified by:
isDestroyed in interface Destroyable

isTargeted

public boolean isTargeted()
Description copied from interface: Targetable
Returns whether this object is currently targeted.

Specified by:
isTargeted in interface Targetable

processOutgoingConnection

protected void processOutgoingConnection(Class hostType,
                                         connect.ChannelBundle bundle)
Description copied from class: SocketSimulatorComponentTemplate
Handles the bevahior of this component when it initiates a connection to a remote component

Specified by:
processOutgoingConnection in class SocketSimulatorComponentTemplate
See Also:
SocketSimulatorComponentTemplate.connect(connect.CreatesConnection)

processIncomingConnection

protected void processIncomingConnection(Class hostType,
                                         connect.ChannelBundle bundle)
Description copied from class: SocketSimulatorComponentTemplate
Handles the bevahior of this component when another component initiates the connection to this component.

Specified by:
processIncomingConnection in class SocketSimulatorComponentTemplate
See Also:
SocketSimulatorComponentTemplate.connect(connect.CreatesConnection)

step

public void step()
Moves the bus one update distance towards its current gaol, then notifies the ComponentizedSimulator of its progress. If the bus reaches its goal, then it begins moving randomly

Specified by:
step in class SocketSimulatorComponentTemplate
See Also:
SocketSimulatorComponentTemplate.run()

setGoal

public void setGoal(objects.Location goal)

setAsTargeted

public void setAsTargeted()
Description copied from interface: Targetable
Marks this object as targeted.

Specified by:
setAsTargeted in interface Targetable

setAsUntargeted

public void setAsUntargeted()
Description copied from interface: Targetable
Marks this object as untargeted.

Specified by:
setAsUntargeted in interface Targetable

toString

public String toString()
Overrides:
toString in class Object

Boeing Simulation 3.1 API Specification

To submit a bug or feature email the author of that class. Funding for this research was provided by Boeing and DARPA.