jfreerails.controller
Class DropOffAndPickupCargoMoveGenerator

java.lang.Object
  extended by jfreerails.controller.DropOffAndPickupCargoMoveGenerator

public class DropOffAndPickupCargoMoveGenerator
extends java.lang.Object

This class generates moves that transfer cargo between train and the stations it stops at - it also handles cargo conversions that occur when cargo is dropped off.

Author:
Scott Bennett, Luke Lindsay Date Created: 4 June 2003

Nested Class Summary
private static class DropOffAndPickupCargoMoveGenerator.WagonLoad
          Stores the type and quanity of cargo in a wagon.
 
Field Summary
private  boolean autoConsist
           
private  ImInts consist
           
private  java.util.ArrayList<Move> moves
           
private  FreerailsPrincipal principal
           
private  MutableCargoBundle stationAfter
           
private  MutableCargoBundle stationBefore
           
private  int stationBundleId
           
private  int stationId
           
private  TrainAccessor train
           
private  MutableCargoBundle trainAfter
           
private  MutableCargoBundle trainBefore
           
private  int trainBundleId
           
private  int trainId
           
private  ReadOnlyWorld w
           
private  boolean waitingForFullLoad
           
 
Constructor Summary
DropOffAndPickupCargoMoveGenerator(int trainNo, int stationNo, ReadOnlyWorld world, FreerailsPrincipal p, boolean waiting, boolean autoConsist)
          Contructor.
 
Method Summary
 Move generateMove()
           
private  void getBundles()
           
private  MutableCargoBundle getCopyOfBundle(int id)
           
 boolean isCargo2Transfer()
           
private  void processStationBundle()
          Transfer cargo from the station to the train subject to the space available on the train.
private  void processTrainBundle()
           
private static void transferCargo(int cargoTypeToTransfer, int amountToTransfer, MutableCargoBundle from, MutableCargoBundle to)
          Move the specified quantity of the specifed cargotype from one bundle to another.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

w

private final ReadOnlyWorld w

train

private final TrainAccessor train

trainId

private final int trainId

trainBundleId

private int trainBundleId

stationId

private final int stationId

stationBundleId

private int stationBundleId

stationAfter

private MutableCargoBundle stationAfter

stationBefore

private MutableCargoBundle stationBefore

trainAfter

private MutableCargoBundle trainAfter

trainBefore

private MutableCargoBundle trainBefore

moves

private java.util.ArrayList<Move> moves

principal

private final FreerailsPrincipal principal

waitingForFullLoad

private boolean waitingForFullLoad

autoConsist

private boolean autoConsist

consist

private ImInts consist
Constructor Detail

DropOffAndPickupCargoMoveGenerator

public DropOffAndPickupCargoMoveGenerator(int trainNo,
                                          int stationNo,
                                          ReadOnlyWorld world,
                                          FreerailsPrincipal p,
                                          boolean waiting,
                                          boolean autoConsist)
Contructor.

Parameters:
trainNo - ID of the train
stationNo - ID of the station
world - The world object
Method Detail

generateMove

public Move generateMove()

getBundles

private void getBundles()

getCopyOfBundle

private MutableCargoBundle getCopyOfBundle(int id)

processTrainBundle

private void processTrainBundle()

processStationBundle

private void processStationBundle()
Transfer cargo from the station to the train subject to the space available on the train.


isCargo2Transfer

public boolean isCargo2Transfer()

transferCargo

private static void transferCargo(int cargoTypeToTransfer,
                                  int amountToTransfer,
                                  MutableCargoBundle from,
                                  MutableCargoBundle to)
Move the specified quantity of the specifed cargotype from one bundle to another.