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 } } } }
/** * 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(); } }