From d58be907ae90a2a55526b1ddf61252e1145c5b65 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Fri, 5 Jan 2024 16:41:14 +0100 Subject: [PATCH] reorganization --- .../LSPTourEndEventHandler.java | 65 ++++++++++--------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/src/main/java/org/matsim/freight/logistics/resourceImplementations/LSPTourEndEventHandler.java b/src/main/java/org/matsim/freight/logistics/resourceImplementations/LSPTourEndEventHandler.java index 03c1d764..44605174 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/LSPTourEndEventHandler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/LSPTourEndEventHandler.java @@ -102,7 +102,6 @@ public LSPTourEndEventHandler( @Override public void reset(int iteration) { // TODO Auto-generated method stub - } @Override @@ -125,7 +124,7 @@ public void handleEvent(CarrierTourEndEvent event) { } } - + // ex Collection run private void logUnload(CarrierTourEndEvent event, Tour tour) { ShipmentUtils.LoggedShipmentUnloadBuilder builder = ShipmentUtils.LoggedShipmentUnloadBuilder.newInstance(); @@ -144,7 +143,7 @@ private void logUnload(CarrierTourEndEvent event, Tour tour) { lspShipment.getShipmentLog().addPlanElement(unloadId, unload); } - + // ex Collection run private void logTransport(CarrierTourEndEvent event, Tour tour) { String idString = resource.getId() + "" + logisticChainElement.getId() + "TRANSPORT"; Id id = Id.create(idString, ShipmentPlanElement.class); @@ -156,6 +155,37 @@ private void logTransport(CarrierTourEndEvent event, Tour tour) { } } + // Ex Main Run // + private void logUnload(CarrierTourEndEvent event) { + ShipmentUtils.LoggedShipmentUnloadBuilder builder = + ShipmentUtils.LoggedShipmentUnloadBuilder.newInstance(); + builder.setStartTime(event.getTime() - getTotalUnloadingTime(tour)); + builder.setEndTime(event.getTime()); + builder.setLogisticChainElement(logisticChainElement); + builder.setResourceId(resource.getId()); + builder.setCarrierId(event.getCarrierId()); + ShipmentPlanElement unload = builder.build(); + String idString = + unload.getResourceId() + + "" + + unload.getLogisticChainElement().getId() + + unload.getElementType(); + Id unloadId = Id.create(idString, ShipmentPlanElement.class); + lspShipment.getShipmentLog().addPlanElement(unloadId, unload); + } + + // Ex Main Run // + private void logTransport(CarrierTourEndEvent event) { + String idString = resource.getId() + "" + logisticChainElement.getId() + "TRANSPORT"; + Id id = Id.create(idString, ShipmentPlanElement.class); + ShipmentPlanElement abstractPlanElement = + lspShipment.getShipmentLog().getPlanElements().get(id); + if (abstractPlanElement instanceof ShipmentLeg transport) { + transport.setEndTime(event.getTime() - getTotalUnloadingTime(tour)); + transport.setToLinkId(event.getLinkId()); + } + } + private double getTotalUnloadingTime(Tour tour) { double totalTime = 0; for (TourElement element : tour.getTourElements()) { @@ -193,36 +223,7 @@ public void notifyAfterMobsim(AfterMobsimEvent event) {} // ***** (Begin) Ex MainRun *** // - // Ex Main Run // - private void logUnload(CarrierTourEndEvent event) { - ShipmentUtils.LoggedShipmentUnloadBuilder builder = - ShipmentUtils.LoggedShipmentUnloadBuilder.newInstance(); - builder.setStartTime(event.getTime() - getTotalUnloadingTime(tour)); - builder.setEndTime(event.getTime()); - builder.setLogisticChainElement(logisticChainElement); - builder.setResourceId(resource.getId()); - builder.setCarrierId(event.getCarrierId()); - ShipmentPlanElement unload = builder.build(); - String idString = - unload.getResourceId() - + "" - + unload.getLogisticChainElement().getId() - + unload.getElementType(); - Id unloadId = Id.create(idString, ShipmentPlanElement.class); - lspShipment.getShipmentLog().addPlanElement(unloadId, unload); - } - // Ex Main Run // - private void logTransport(CarrierTourEndEvent event) { - String idString = resource.getId() + "" + logisticChainElement.getId() + "TRANSPORT"; - Id id = Id.create(idString, ShipmentPlanElement.class); - ShipmentPlanElement abstractPlanElement = - lspShipment.getShipmentLog().getPlanElements().get(id); - if (abstractPlanElement instanceof ShipmentLeg transport) { - transport.setEndTime(event.getTime() - getTotalUnloadingTime(tour)); - transport.setToLinkId(event.getLinkId()); - } - }