Exemple #1
0
 /**
  * Updates a car's load when placed at a spur. Load change delayed if wait count is greater than
  * zero.
  */
 public void updateLoad() {
   if (getWait() > 0) {
     return; // change load when wait count reaches 0
   } // arriving at spur with a schedule?
   if (!getNextLoadName().equals(NONE)) {
     setLoadName(getNextLoadName());
     setNextLoadName(NONE);
     // RWE load and no destination?
     if (getLoadName().equals(getReturnWhenEmptyLoadName()) && getFinalDestination() == null) {
       setReturnWhenEmpty();
     }
     return;
   }
   // flip load names
   if (getLoadType().equals(CarLoad.LOAD_TYPE_EMPTY)) {
     setLoadName(carLoads.getDefaultLoadName());
   } else {
     setLoadEmpty();
   }
 }
Exemple #2
0
  public void reset() {
    setScheduleItemId(getPreviousScheduleId()); // revert to previous
    setNextLoadName(NONE);
    setNextWait(0);
    setFinalDestination(getPreviousFinalDestination()); // revert to previous
    setFinalDestinationTrack(getPreviousFinalDestinationTrack()); // revert to previous
    if (isLoadGeneratedFromStaging()) {
      setLoadGeneratedFromStaging(false);
      setLoadName(CarLoads.instance().getDefaultEmptyName());
    }

    super.reset();
  }
Exemple #3
0
 public Car copy() {
   Car car = new Car();
   car.setBuilt(_built);
   car.setColor(_color);
   car.setLength(_length);
   car.setLoadName(_loadName);
   car.setReturnWhenEmptyLoadName(_rweLoadName);
   car.setNumber(_number);
   car.setOwner(_owner);
   car.setRoadName(_road);
   car.setTypeName(_type);
   car.loaded = true;
   return car;
 }
Exemple #4
0
 public void loadNext(Track destTrack) {
   setLoadGeneratedFromStaging(false);
   // update wait count
   setWait(getNextWait());
   setNextWait(0);
   // and the pickup day
   setPickupScheduleId(getNextPickupScheduleId());
   setNextPickupScheduleId(NONE);
   // arrived at spur?
   if (destTrack != null && destTrack.getTrackType().equals(Track.SPUR)) {
     updateLoad();
   } // update load optionally when car reaches staging
   else if (destTrack != null && destTrack.getTrackType().equals(Track.STAGING)) {
     if (destTrack.isLoadSwapEnabled() && getLoadName().equals(carLoads.getDefaultEmptyName())) {
       setLoadName(carLoads.getDefaultLoadName());
     } else if (destTrack.isLoadSwapEnabled()
         && getLoadName().equals(carLoads.getDefaultLoadName())) {
       setLoadEmpty();
     } else if (destTrack.isLoadEmptyEnabled()
         && getLoadName().equals(carLoads.getDefaultLoadName())) {
       setLoadEmpty();
     } // empty car if it has a custom load
     else if (destTrack.isRemoveCustomLoadsEnabled()
         && !getLoadName().equals(carLoads.getDefaultEmptyName())
         && !getLoadName().equals(carLoads.getDefaultLoadName())) {
       // remove this car's final destination if it has one
       setFinalDestination(null);
       setFinalDestinationTrack(null);
       // car arriving into staging with the RWE load?
       if (getLoadName().equals(getReturnWhenEmptyLoadName())) {
         setLoadName(carLoads.getDefaultEmptyName());
       } else {
         setLoadEmpty(); // note that RWE sets the car's final destination
       }
     }
   }
 }
Exemple #5
0
 /**
  * Updates all cars in a kernel. After the update, the cars will all have the same final
  * destination, load, and next load.
  */
 public void updateKernel() {
   if (getKernel() != null && getKernel().isLead(this)) {
     for (Car car : getKernel().getCars()) {
       car.setFinalDestination(getFinalDestination());
       car.setFinalDestinationTrack(getFinalDestinationTrack());
       car.setLoadGeneratedFromStaging(isLoadGeneratedFromStaging());
       if (CarLoads.instance().containsName(car.getTypeName(), getLoadName())) {
         car.setLoadName(getLoadName());
       }
       if (CarLoads.instance().containsName(car.getTypeName(), getNextLoadName())) {
         car.setNextLoadName(getNextLoadName());
       }
     }
   }
 }
Exemple #6
0
 /** Sets the car's load to empty, triggers RWE load and destination if enabled. */
 private void setLoadEmpty() {
   if (!getLoadName().equals(getReturnWhenEmptyLoadName())) {
     setLoadName(getReturnWhenEmptyLoadName()); // default RWE load is the "E" load
     setReturnWhenEmpty();
   }
 }
Exemple #7
0
 @Deprecated
 // saved for scripts
 public void setLoad(String load) {
   setLoadName(load);
 }