de.upb.swtpra05.group03.shuttle
Class PluginMessenger

java.lang.Object
  extended byde.upb.swtpra05.group03.shuttle.PluginMessenger
All Implemented Interfaces:
Module, PluginMessengerInterface, ShuttleModule

public class PluginMessenger
extends java.lang.Object
implements ShuttleModule, PluginMessengerInterface

single class to send infos to the plugin

Version:
$Revision: 1.3 $

Field Summary
private  AccountingInterface accounting
          The accounting
private  ShuttleControlInterface agent
          No comment provided by developer, please add a comment to improve documentation.
private  int currentTime
           
private  ExecutionInterface execution
          The execution
private  AccountLinkedList expenses
          List of maximal 4 objects describing an expense, e.g.
private  AccountLinkedList income
          List of maximal 4 objects describing an income, e.g.
private  boolean isWorking
           
private  MarginControllerInterface marginController
          The margin controller
(package private)  java.util.HashMap namesMap
          A HashMap with a relation from StationID (as an int) to the corresponding StationName (as a string)
private  OrderContainerInterface orderContainer
          The order container
private  PeriodicalWakeUpControlInterface periodical
          The periodical wake up control
(package private)  PluginGameConstants pGC
          No comment provided by developer, please add a comment to improve documentation.
(package private)  RoutingData rD
          No comment provided by developer, please add a comment to improve documentation.
(package private)  ShuttleCompanyControlData sccD
           
(package private)  ShuttleStrategyData sD
          No comment provided by developer, please add a comment to improve documentation.
private  int startTime
           
private  int startWorkingTime
           
private  TaskPlanInterface taskPlan
          The taskplan
private static java.lang.Integer WAKE_UP_FREQUENCY
          The status message frequency
private  int workingTime
           
 
Constructor Summary
PluginMessenger()
          Constructor
 
Method Summary
private  java.lang.String constructPickabackString()
          Used to construct and save a PickabackString if one or more things changes, otherwise returns the already build and saved PickabackString.
private  void gameConstants(de.upb.swtpra.kernel.message.GameConstantsMessage msg)
          Sets some constant variables which are used by the plugin
 void init(ModuleContainerInterface container)
          Initializes this module.
 void masterShuttleChanged(de.upb.swtpra.kernel.id.ID masterShuttle)
          Informs the plugin that the master shuttle changed.
private  void moneyTransferred(de.upb.swtpra.kernel.message.MoneyTransferredMessage msg)
          Description of the Method
 void newMessageReceived(de.upb.swtpra.kernel.message.Message msg)
          Description of the Method
private  void paidPenalty(de.upb.swtpra.kernel.message.PaidPenaltyMessage msg)
          If the PluginMessenger receives a PaidPenaltyMessage this method is called.
private  RoutingData parseAndConstructRoutingData()
          Parses the current TaskPlan and generates a RoutingData object.
private  void parseTopology(de.upb.swtpra.kernel.TopologyData td)
          Called when PluginMessenger receives a Topology.
 void repairShuttle(int value)
          Informs the plugin that the shuttle repaired
 void send()
          A call of this method will collect all data the plugin needs, converts it into a string and sends it to the plugin using a ShuttleAgentStatusMessage
private  void setMaximumLoad(int newMaximumLoad)
          Sets the maximumLoad attribute of the PluginMessenger object
private  void setMaximumStretch(int newMaximumStretch)
          Sets the maximumStretch attribute of the PluginMessenger object
 void shuttlePaidPenalty(int orderID, int penalty)
           
private  void wakeUpCall(de.upb.swtpra.kernel.message.WakeUpCallMessage msg)
          Handles received WakeUpCallMessages which are used to remind us to send ShuttleAgentStatusMessages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

expenses

private AccountLinkedList expenses
List of maximal 4 objects describing an expense, e.g. Penalty or Service


income

private AccountLinkedList income
List of maximal 4 objects describing an income, e.g. Profit of order


agent

private ShuttleControlInterface agent
No comment provided by developer, please add a comment to improve documentation.


execution

private ExecutionInterface execution
The execution


marginController

private MarginControllerInterface marginController
The margin controller


accounting

private AccountingInterface accounting
The accounting


orderContainer

private OrderContainerInterface orderContainer
The order container


taskPlan

private TaskPlanInterface taskPlan
The taskplan


periodical

private PeriodicalWakeUpControlInterface periodical
The periodical wake up control


pGC

PluginGameConstants pGC
No comment provided by developer, please add a comment to improve documentation.


sD

ShuttleStrategyData sD
No comment provided by developer, please add a comment to improve documentation.


sccD

ShuttleCompanyControlData sccD

WAKE_UP_FREQUENCY

private static final java.lang.Integer WAKE_UP_FREQUENCY
The status message frequency


startTime

private int startTime

currentTime

private int currentTime

startWorkingTime

private int startWorkingTime

workingTime

private int workingTime

isWorking

private boolean isWorking

rD

RoutingData rD
No comment provided by developer, please add a comment to improve documentation.


namesMap

java.util.HashMap namesMap
A HashMap with a relation from StationID (as an int) to the corresponding StationName (as a string)

Constructor Detail

PluginMessenger

public PluginMessenger()
Constructor

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

masterShuttleChanged

public void masterShuttleChanged(de.upb.swtpra.kernel.id.ID masterShuttle)
Description copied from interface: PluginMessengerInterface
Informs the plugin that the master shuttle changed.

Specified by:
masterShuttleChanged in interface PluginMessengerInterface
Parameters:
masterShuttle - The new master shuttle id

setMaximumStretch

private void setMaximumStretch(int newMaximumStretch)
Sets the maximumStretch attribute of the PluginMessenger object

Parameters:
newMaximumStretch - The new maximumStretch value

setMaximumLoad

private void setMaximumLoad(int newMaximumLoad)
Sets the maximumLoad attribute of the PluginMessenger object

Parameters:
newMaximumLoad - The new maximumLoad value

constructPickabackString

private java.lang.String constructPickabackString()
Used to construct and save a PickabackString if one or more things changes, otherwise returns the already build and saved PickabackString. The PickabackString in here contains all information the plugin needs from the shuttle to display with the exception of parts about we don't know if they changed in the meantime and have no way to find out

Returns:
Description of the Return Value

parseTopology

private void parseTopology(de.upb.swtpra.kernel.TopologyData td)
Called when PluginMessenger receives a Topology. It will fill the namesMap with stationids and their relating stationnames.

Parameters:
td - Description of the Parameter

parseAndConstructRoutingData

private RoutingData parseAndConstructRoutingData()
Parses the current TaskPlan and generates a RoutingData object. This RoutingData object will be send to the plugin on call of send();

Returns:
the RoutingData with the current route the shuttle will use

send

public void send()
Description copied from interface: PluginMessengerInterface
A call of this method will collect all data the plugin needs, converts it into a string and sends it to the plugin using a ShuttleAgentStatusMessage

Specified by:
send in interface PluginMessengerInterface

moneyTransferred

private void moneyTransferred(de.upb.swtpra.kernel.message.MoneyTransferredMessage msg)
Description of the Method

Parameters:
msg - Description of the Parameter

repairShuttle

public void repairShuttle(int value)
Description copied from interface: PluginMessengerInterface
Informs the plugin that the shuttle repaired

Specified by:
repairShuttle in interface PluginMessengerInterface
Parameters:
value - repair costs

shuttlePaidPenalty

public void shuttlePaidPenalty(int orderID,
                               int penalty)

newMessageReceived

public void newMessageReceived(de.upb.swtpra.kernel.message.Message msg)
Description of the Method

Specified by:
newMessageReceived in interface ShuttleModule
Parameters:
msg - Description of the Parameter

wakeUpCall

private void wakeUpCall(de.upb.swtpra.kernel.message.WakeUpCallMessage msg)
Handles received WakeUpCallMessages which are used to remind us to send ShuttleAgentStatusMessages.

Parameters:
msg - The received WakeUpCallMessage

gameConstants

private void gameConstants(de.upb.swtpra.kernel.message.GameConstantsMessage msg)
Sets some constant variables which are used by the plugin

Parameters:
msg - The received GameConstantsMessage

paidPenalty

private void paidPenalty(de.upb.swtpra.kernel.message.PaidPenaltyMessage msg)
If the PluginMessenger receives a PaidPenaltyMessage this method is called. It adds the penalty to the AccountData

Parameters:
msg - The PaidPenaltyMessage