ITransporterCommand cmdTrans; String strLocation; int intTransportedLoad; // get current location and transporter load strLocation = traT1.getVisitedScenarioElement().getId(); intTransportedLoad = traT1.getTransportedGoodSet().getTotalQuantity(); try { // check for upload: location must be pump if (strLocation.equals(locPump.getId())) { // check transporter load if (intTransportedLoad == 0) { // production must be finished if (!((IProductionFacility)locPump).hasCommand()) { cmdTrans = cmdFactory.getUploadCommand(traT1, 20, GoodType.WATER); traT1.assignCommand(cmdTrans); } } else { // upload finished. // remove current location and travel to next location vecPath.remove(0); travel(scenario); } } // check for unload: location must be mill AND good loaded else if ((strLocation.equals(locMill.getId())) && (intTransportedLoad == 20)) { // unload 20 units of water cmdTrans = cmdFactory.getUnloadCommand(traT1, 20, GoodType.WATER); traT1.assignCommand(cmdTrans); // set flag to finish bolFinished = true; } // on the road. try to travel to next location else { if ((traT1.getCommand() == null) && (!vecPath.isEmpty())) travel(scenario); } } catch (Exception e) { } }