de.upb.swtpra05.group03.shuttle
Class Execution

java.lang.Object
  extended byde.upb.swtpra05.group03.shuttle.Execution
All Implemented Interfaces:
ExecutionInterface, Module, OrderEvaluaterInterface, ShuttleModule, UnsuccessfulOfferInterface

public class Execution
extends java.lang.Object
implements ShuttleModule, ExecutionInterface, OrderEvaluaterInterface, UnsuccessfulOfferInterface

The Execution module of the shuttle which will execute all assigned orders.

Version:
$Revision: 1.3 $

Field Summary
private  ShuttleControlInterface agent
          The shuttle control
protected  EfficientBitSet assignedOrders
          Collection which holds all order ids which were assigned to the shuttle
private  int currentState
          The current state the shuttle is in
protected  EfficientBitSet evaluatedOrders
          Collection which holds all order ids the Execution evaluated
protected  EfficientBitSet loadedOrders
          Collection which holds all order ids the shuttle has currently loaded
private static java.util.logging.Logger log
          Logger for debugging
private  NavigationInterface navigation
          The navigation
private  OrderContainerInterface orderContainer
          The order container
private  PluginMessengerInterface plugin
          The plugin
private  RouteManagementInterface routeManagement
          The route management
private  ShuttleDataInterface shuttleData
          Container class, contains the constants, currentStretch, etc.
private  TaskPlanInterface taskPlan
          Collection which holds all Task the shuttle has to process
protected static int TASKPLANEMPTY
          Constant which is used to assure the correct usage of any time value
protected static int TIMEVARIANCE
          Constant which is used to assure the correct usage of any time value
private  EfficientBitSet wakeUpTimes
           
 
Fields inherited from interface de.upb.swtpra05.group03.shuttle.ExecutionInterface
LOADING_STATE, MOVING_STATE, NOTHINGTODO_STATE, REPAIRING_STATE, UNLOADING_STATE
 
Fields inherited from interface de.upb.swtpra05.group03.shuttle.OrderEvaluaterInterface
NOTEVALUATEABLE
 
Constructor Summary
Execution()
          Constructor for class Execution
 
Method Summary
private  void assignOrder(de.upb.swtpra.kernel.message.AssignOrder msg)
          Called if execution receives an AssignOrder message
private  void connectionDefect(de.upb.swtpra.kernel.message.ConnectionDefectMessage msg)
          Called if execution receives a ConnectionDefectMessage and handles the defect connection.
private  void connectionOkResponse(de.upb.swtpra.kernel.message.ConnectionOkResponse msg)
          Called if execution receives a ConnectionOkResponse message
private  void connectionStatus(de.upb.swtpra.kernel.message.ConnectionStatusMessage msg)
          Informs the route managment about a disabled connection.
 int evaluateOrderCosts(de.upb.swtpra.kernel.id.OrderID id, int currentTime)
          Evaluates the costs to add an order to the current route and returns the value
private  void executeNextTask()
          Executes the next task out of the tasks collection whether it is active and there are tasks
 EfficientBitSet getAssignedOrders()
          Returns the current assigned order ids as bit set.
 EfficientBitSet getEvaluatedOrders()
          Returns the evaluated order ids as bit set.
 int getLoad()
          Returns the current load of the shuttle.
 EfficientBitSet getLoadedOrders()
          Returns the current load order ids as bit set.
 int getState()
          Returns the current shuttle state.
 int getStation()
          Returns the current station id
 void init(ModuleContainerInterface container)
          Initializes this module.
private  void insertedInQueue(de.upb.swtpra.kernel.message.InsertedInQueueMessage msg)
          Called if execution receives a InsertedInQueueMessage
private  void invalidDestination(de.upb.swtpra.kernel.message.InvalidDestinationMessage msg)
          Called if execution receives a InvalidDestinationMessage
private  void loadShuttleError(de.upb.swtpra.kernel.message.LoadShuttleErrorMessage msg)
          Called if execution receives a LoadShuttleErrorMessage
private  void maxStretchLimitReached(de.upb.swtpra.kernel.message.MaxStretchLimitReachedMessage msg)
          Called if execution receives a MaxStretchLimitReachedMessage
 void moveToStation(int stationID)
          Move the shuttle from current station to stationID if the taskplan is emtpy.
 void newMessageReceived(de.upb.swtpra.kernel.message.Message msg)
          React on the received message of the shuttle or not.
 void offerUnsuccessful(de.upb.swtpra.kernel.id.OrderID id)
          Is called to notify the shuttle that an offer is supposed to be unsuccessful
private  void paidPenalty(de.upb.swtpra.kernel.message.PaidPenaltyMessage msg)
          Calle if execution receives a PaidPenaltyMessage
private  void shuttleArrived(de.upb.swtpra.kernel.message.ShuttleArrivedMessage msg)
          Called if execution receives a ShuttleArrivedMessage
private  void shuttleLoaded(de.upb.swtpra.kernel.message.ShuttleLoaded msg)
          Called if execution receives a ShuttleLoaded message
private  void shuttleMoving(de.upb.swtpra.kernel.message.ShuttleMovingMessage msg)
          Called if execution receives a ShuttleMovingMessage
private  void shuttleRepaired(de.upb.swtpra.kernel.message.ShuttleRepaired msg)
          Called if execution receives a ShuttleRepaired message
private  void shuttleStatus(de.upb.swtpra.kernel.message.ShuttleStatus msg)
          Called if execution receives a ShuttleStatus message
private  void shuttleUnloaded(de.upb.swtpra.kernel.message.ShuttleUnLoadedMessage msg)
          Called if execution receives a ShuttleUnLoadedMessage
private  void stationNotReachable(de.upb.swtpra.kernel.message.StationNotReachableMessage msg)
          Called if execution receives a StationNotReachableMessage
private  void unloadShuttleError(de.upb.swtpra.kernel.message.UnLoadShuttleErrorMessage msg)
          Called if execution receives a UnLoadShuttleErrorMessage
private  void wakeUpCall(de.upb.swtpra.kernel.message.WakeUpCallMessage msg)
          Called if execution receives a WakeUpCallMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TASKPLANEMPTY

protected static final int TASKPLANEMPTY
Constant which is used to assure the correct usage of any time value

See Also:
Constant Field Values

TIMEVARIANCE

protected static final int TIMEVARIANCE
Constant which is used to assure the correct usage of any time value

See Also:
Constant Field Values

evaluatedOrders

protected EfficientBitSet evaluatedOrders
Collection which holds all order ids the Execution evaluated


assignedOrders

protected EfficientBitSet assignedOrders
Collection which holds all order ids which were assigned to the shuttle


loadedOrders

protected EfficientBitSet loadedOrders
Collection which holds all order ids the shuttle has currently loaded


agent

private ShuttleControlInterface agent
The shuttle control


navigation

private NavigationInterface navigation
The navigation


routeManagement

private RouteManagementInterface routeManagement
The route management


plugin

private PluginMessengerInterface plugin
The plugin


orderContainer

private OrderContainerInterface orderContainer
The order container


shuttleData

private ShuttleDataInterface shuttleData
Container class, contains the constants, currentStretch, etc.


currentState

private int currentState
The current state the shuttle is in


taskPlan

private TaskPlanInterface taskPlan
Collection which holds all Task the shuttle has to process


wakeUpTimes

private EfficientBitSet wakeUpTimes

log

private static final java.util.logging.Logger log
Logger for debugging

Constructor Detail

Execution

public Execution()
Constructor for class Execution

Method Detail

init

public void init(ModuleContainerInterface container)
Description copied from interface: Module
Initializes this module. References to other modules should be set here to avoid circle dependencies.

Specified by:
init in interface Module
Parameters:
container - The module manager which contain all modules

newMessageReceived

public void newMessageReceived(de.upb.swtpra.kernel.message.Message msg)
Description copied from interface: ShuttleModule
React on the received message of the shuttle or not.

Specified by:
newMessageReceived in interface ShuttleModule
Parameters:
msg - The received message of the shuttle

offerUnsuccessful

public void offerUnsuccessful(de.upb.swtpra.kernel.id.OrderID id)
Description copied from interface: UnsuccessfulOfferInterface
Is called to notify the shuttle that an offer is supposed to be unsuccessful

Specified by:
offerUnsuccessful in interface UnsuccessfulOfferInterface
Parameters:
id - The order if for which the offer was sent

evaluateOrderCosts

public int evaluateOrderCosts(de.upb.swtpra.kernel.id.OrderID id,
                              int currentTime)
Description copied from interface: OrderEvaluaterInterface
Evaluates the costs to add an order to the current route and returns the value

Specified by:
evaluateOrderCosts in interface OrderEvaluaterInterface
Parameters:
id - The order id of the order to evaluate
currentTime - The current time
Returns:
the estimated selfcosts if the order is added to the current route

getState

public int getState()
Description copied from interface: ExecutionInterface
Returns the current shuttle state.

Specified by:
getState in interface ExecutionInterface
Returns:
the current shuttle state

assignOrder

private void assignOrder(de.upb.swtpra.kernel.message.AssignOrder msg)
Called if execution receives an AssignOrder message

Parameters:
msg - The AssignOrder message

connectionOkResponse

private void connectionOkResponse(de.upb.swtpra.kernel.message.ConnectionOkResponse msg)
Called if execution receives a ConnectionOkResponse message

Parameters:
msg - The ConnectionOkResponse message

shuttleMoving

private void shuttleMoving(de.upb.swtpra.kernel.message.ShuttleMovingMessage msg)
Called if execution receives a ShuttleMovingMessage

Parameters:
msg - The ShuttleMovingMessage

shuttleArrived

private void shuttleArrived(de.upb.swtpra.kernel.message.ShuttleArrivedMessage msg)
Called if execution receives a ShuttleArrivedMessage

Parameters:
msg - The ShuttleArrivedMessage

shuttleLoaded

private void shuttleLoaded(de.upb.swtpra.kernel.message.ShuttleLoaded msg)
Called if execution receives a ShuttleLoaded message

Parameters:
msg - The ShuttleLoaded message

shuttleUnloaded

private void shuttleUnloaded(de.upb.swtpra.kernel.message.ShuttleUnLoadedMessage msg)
Called if execution receives a ShuttleUnLoadedMessage

Parameters:
msg - The ShuttleUnLoadedMessage

shuttleRepaired

private void shuttleRepaired(de.upb.swtpra.kernel.message.ShuttleRepaired msg)
Called if execution receives a ShuttleRepaired message

Parameters:
msg - The ShuttleRepaired message

loadShuttleError

private void loadShuttleError(de.upb.swtpra.kernel.message.LoadShuttleErrorMessage msg)
Called if execution receives a LoadShuttleErrorMessage

Parameters:
msg - The LoadShuttleErrorMessage

unloadShuttleError

private void unloadShuttleError(de.upb.swtpra.kernel.message.UnLoadShuttleErrorMessage msg)
Called if execution receives a UnLoadShuttleErrorMessage

Parameters:
msg - The UnLoadShuttleErrorMessage

insertedInQueue

private void insertedInQueue(de.upb.swtpra.kernel.message.InsertedInQueueMessage msg)
Called if execution receives a InsertedInQueueMessage

Parameters:
msg - The InsertedInQueueMessage

invalidDestination

private void invalidDestination(de.upb.swtpra.kernel.message.InvalidDestinationMessage msg)
Called if execution receives a InvalidDestinationMessage

Parameters:
msg - The InvalidDestinationMessage

stationNotReachable

private void stationNotReachable(de.upb.swtpra.kernel.message.StationNotReachableMessage msg)
Called if execution receives a StationNotReachableMessage

Parameters:
msg - The StationNotReachableMessage

maxStretchLimitReached

private void maxStretchLimitReached(de.upb.swtpra.kernel.message.MaxStretchLimitReachedMessage msg)
Called if execution receives a MaxStretchLimitReachedMessage

Parameters:
msg - The MaxStretchLimitReachedMessage

connectionDefect

private void connectionDefect(de.upb.swtpra.kernel.message.ConnectionDefectMessage msg)
Called if execution receives a ConnectionDefectMessage and handles the defect connection. It will insert a DoNothingUntilTask into the current TaskPlan to make the shuttle wait as long as the connection is defect. Notice: This is an ErrorMessage the shuttle gets if it tries to move through a defect connection. Normally the normal RouteManagement should manage defect connections.

Parameters:
msg - The ConnectionDefectMessage

wakeUpCall

private void wakeUpCall(de.upb.swtpra.kernel.message.WakeUpCallMessage msg)
Called if execution receives a WakeUpCallMessage

Parameters:
msg - The WakeUpCallMessage

shuttleStatus

private void shuttleStatus(de.upb.swtpra.kernel.message.ShuttleStatus msg)
Called if execution receives a ShuttleStatus message

Parameters:
msg - The ShuttleStatus message

paidPenalty

private void paidPenalty(de.upb.swtpra.kernel.message.PaidPenaltyMessage msg)
Calle if execution receives a PaidPenaltyMessage

Parameters:
msg - The PaidPenaltyMessage

executeNextTask

private void executeNextTask()
Executes the next task out of the tasks collection whether it is active and there are tasks


getLoad

public int getLoad()
Description copied from interface: ExecutionInterface
Returns the current load of the shuttle.

Specified by:
getLoad in interface ExecutionInterface
Returns:
current load of the shuttle

getLoadedOrders

public EfficientBitSet getLoadedOrders()
Description copied from interface: ExecutionInterface
Returns the current load order ids as bit set.

Specified by:
getLoadedOrders in interface ExecutionInterface
Returns:
loaded order ids as bit set

getAssignedOrders

public EfficientBitSet getAssignedOrders()
Description copied from interface: ExecutionInterface
Returns the current assigned order ids as bit set.

Specified by:
getAssignedOrders in interface ExecutionInterface
Returns:
assigned order ids as bit set

getEvaluatedOrders

public EfficientBitSet getEvaluatedOrders()
Description copied from interface: ExecutionInterface
Returns the evaluated order ids as bit set.

Specified by:
getEvaluatedOrders in interface ExecutionInterface
Returns:
evaluated order ids as bit set

getStation

public int getStation()
Description copied from interface: ExecutionInterface
Returns the current station id

Specified by:
getStation in interface ExecutionInterface
Returns:
the current station id

moveToStation

public void moveToStation(int stationID)
Description copied from interface: ExecutionInterface
Move the shuttle from current station to stationID if the taskplan is emtpy.

Specified by:
moveToStation in interface ExecutionInterface
Parameters:
stationID - id where the shuttle has to move

connectionStatus

private void connectionStatus(de.upb.swtpra.kernel.message.ConnectionStatusMessage msg)
Informs the route managment about a disabled connection.

Parameters:
msg - The connection status message which contains the information about the disabled connection