diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java index c49c04aa533..c02717031fa 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java @@ -84,7 +84,7 @@ public static CarrierShipmentDeliveryEndEvent convert(GenericEvent event) { Id shipmentTo = Id.createLinkId(attributes.get(ATTRIBUTE_LINK)); int size = Integer.parseInt(attributes.get(CarrierEventAttributes.ATTRIBUTE_CAPACITYDEMAND)); CarrierShipment shipment = CarrierShipment.Builder.newInstance(shipmentId, null, shipmentTo, size) - .setDeliveryServiceTime(Double.parseDouble(attributes.get(CarrierEventAttributes.ATTRIBUTE_SERVICE_DURATION))) + .setDeliveryServiceTime(Double.parseDouble(attributes.get(CarrierEventAttributes.ATTRIBUTE_DROPOFF_DURATION))) .build(); Id vehicleId = Id.createVehicleId(attributes.get(ATTRIBUTE_VEHICLE)); return new CarrierShipmentDeliveryEndEvent(time, carrierId, shipment, vehicleId); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java index e12222973c1..43cf21fc752 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java @@ -85,7 +85,7 @@ public static CarrierShipmentDeliveryStartEvent convert(GenericEvent event) { Id shipmentTo = Id.createLinkId(attributes.get(ATTRIBUTE_LINK)); int size = Integer.parseInt(attributes.get(ATTRIBUTE_CAPACITYDEMAND)); CarrierShipment shipment = CarrierShipment.Builder.newInstance(shipmentId, null, shipmentTo, size) - .setDeliveryServiceTime(Double.parseDouble(attributes.get(ATTRIBUTE_SERVICE_DURATION))) + .setDeliveryServiceTime(Double.parseDouble(attributes.get(ATTRIBUTE_DROPOFF_DURATION))) .build(); Id vehicleId = Id.createVehicleId(attributes.get(ATTRIBUTE_VEHICLE)); return new CarrierShipmentDeliveryStartEvent(time, carrierId, shipment, vehicleId); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/FreightServiceEndEventHandler.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierServiceEndEventHandler.java similarity index 95% rename from contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/FreightServiceEndEventHandler.java rename to contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierServiceEndEventHandler.java index 65db8298b92..11ccfde0372 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/FreightServiceEndEventHandler.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierServiceEndEventHandler.java @@ -25,7 +25,7 @@ import org.matsim.core.events.handler.EventHandler; import org.matsim.freight.carriers.events.CarrierServiceEndEvent; -public interface FreightServiceEndEventHandler extends EventHandler{ +public interface CarrierServiceEndEventHandler extends EventHandler{ void handleEvent( CarrierServiceEndEvent event ); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/FreightServiceStartEventHandler.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierServiceStartEventHandler.java similarity index 96% rename from contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/FreightServiceStartEventHandler.java rename to contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierServiceStartEventHandler.java index 78534b0337e..a8ea55c13e8 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/FreightServiceStartEventHandler.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierServiceStartEventHandler.java @@ -25,7 +25,7 @@ import org.matsim.freight.carriers.events.CarrierServiceStartEvent; -public interface FreightServiceStartEventHandler extends EventHandler { +public interface CarrierServiceStartEventHandler extends EventHandler { void handleEvent( CarrierServiceStartEvent event ); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/FreightShipmentDeliveryEventHandler.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierShipmentDeliveryEndEventHandler.java similarity index 95% rename from contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/FreightShipmentDeliveryEventHandler.java rename to contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierShipmentDeliveryEndEventHandler.java index 858a91fdca5..b2cc8ff31dc 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/FreightShipmentDeliveryEventHandler.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierShipmentDeliveryEndEventHandler.java @@ -30,7 +30,7 @@ * @author sschroeder * */ -public interface FreightShipmentDeliveryEventHandler extends EventHandler { +public interface CarrierShipmentDeliveryEndEventHandler extends EventHandler { void handleEvent(CarrierShipmentDeliveryEndEvent event); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierShipmentDeliveryStartEventHandler.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierShipmentDeliveryStartEventHandler.java new file mode 100644 index 00000000000..df8a7b9785a --- /dev/null +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierShipmentDeliveryStartEventHandler.java @@ -0,0 +1,37 @@ +/* + * *********************************************************************** * + * project: org.matsim.* + * *********************************************************************** * + * * + * copyright : (C) by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** + * + */ + +package org.matsim.freight.carriers.events.eventhandler; + +import org.matsim.core.events.handler.EventHandler; +import org.matsim.freight.carriers.events.CarrierShipmentDeliveryStartEvent; + +/** + * Interface to listen to shipmentDeliveredEvents. + * + * @author sschroeder + * + */ +public interface CarrierShipmentDeliveryStartEventHandler extends EventHandler { + + void handleEvent(CarrierShipmentDeliveryStartEvent event); + +} diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/FreightShipmentPickupEventHandler.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierShipmentPickupEndEventHandler.java similarity index 95% rename from contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/FreightShipmentPickupEventHandler.java rename to contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierShipmentPickupEndEventHandler.java index 126942b432f..4c7282c29c7 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/FreightShipmentPickupEventHandler.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierShipmentPickupEndEventHandler.java @@ -30,6 +30,6 @@ * @author sschroeder * */ -public interface FreightShipmentPickupEventHandler extends EventHandler { +public interface CarrierShipmentPickupEndEventHandler extends EventHandler { void handleEvent(CarrierShipmentPickupEndEvent event); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierShipmentPickupStartEventHandler.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierShipmentPickupStartEventHandler.java new file mode 100644 index 00000000000..79c2426f023 --- /dev/null +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierShipmentPickupStartEventHandler.java @@ -0,0 +1,35 @@ +/* + * *********************************************************************** * + * project: org.matsim.* + * *********************************************************************** * + * * + * copyright : (C) by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** + * + */ + +package org.matsim.freight.carriers.events.eventhandler; + +import org.matsim.core.events.handler.EventHandler; +import org.matsim.freight.carriers.events.CarrierShipmentPickupStartEvent; + +/** + * Interface to listen to shipmentPickedUpEvents. + * + * @author sschroeder + * + */ +public interface CarrierShipmentPickupStartEventHandler extends EventHandler { + void handleEvent(CarrierShipmentPickupStartEvent event); +} diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/FreightTourEndEventHandler.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierTourEndEventHandler.java similarity index 95% rename from contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/FreightTourEndEventHandler.java rename to contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierTourEndEventHandler.java index 7a91f767c4d..2d30ce4d70c 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/FreightTourEndEventHandler.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierTourEndEventHandler.java @@ -25,7 +25,7 @@ import org.matsim.freight.carriers.events.CarrierTourEndEvent; -public interface FreightTourEndEventHandler extends EventHandler { +public interface CarrierTourEndEventHandler extends EventHandler { void handleEvent( CarrierTourEndEvent event ); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/FreightTourStartEventHandler.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierTourStartEventHandler.java similarity index 95% rename from contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/FreightTourStartEventHandler.java rename to contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierTourStartEventHandler.java index 21b14f86ce0..5f4b26ce4bb 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/FreightTourStartEventHandler.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/CarrierTourStartEventHandler.java @@ -25,7 +25,7 @@ import org.matsim.freight.carriers.events.CarrierTourStartEvent; -public interface FreightTourStartEventHandler extends EventHandler { +public interface CarrierTourStartEventHandler extends EventHandler { void handleEvent( CarrierTourStartEvent event ); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/Vehicle2CarrierEventHandler.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/Vehicle2CarrierEventHandler.java index e116ab1493e..bc9236decbf 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/Vehicle2CarrierEventHandler.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/eventhandler/Vehicle2CarrierEventHandler.java @@ -36,7 +36,7 @@ * * @author kturner */ -public final class Vehicle2CarrierEventHandler implements FreightTourStartEventHandler, FreightTourEndEventHandler { +public final class Vehicle2CarrierEventHandler implements CarrierTourStartEventHandler, CarrierTourEndEventHandler { // Comment from Janek (in https://github.com/matsim-org/matsim-libs/pull/2128) diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierEventsReadersTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierEventsReadersTest.java new file mode 100644 index 00000000000..37a4cabaf82 --- /dev/null +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierEventsReadersTest.java @@ -0,0 +1,251 @@ +/* + * *********************************************************************** * + * project: org.matsim.* + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** * + */ + +package org.matsim.freight.carriers; + +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.matsim.api.core.v01.Id; +import org.matsim.api.core.v01.events.Event; +import org.matsim.api.core.v01.network.Link; +import org.matsim.core.api.experimental.events.EventsManager; +import org.matsim.core.config.groups.ControllerConfigGroup; +import org.matsim.core.events.EventsUtils; +import org.matsim.core.events.algorithms.EventWriterXML; +import org.matsim.freight.carriers.events.*; +import org.matsim.freight.carriers.events.eventhandler.*; +import org.matsim.testcases.MatsimTestUtils; +import org.matsim.testcases.utils.EventsCollector; +import org.matsim.vehicles.Vehicle; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + + +/** + * @author Kai Martins-Turner (kturner) + * @author Niclas Richter (nixlaos) + */ +public class CarrierEventsReadersTest { + + + @Rule + public final MatsimTestUtils utils = new MatsimTestUtils(); + + private final Id linkId = Id.createLinkId("demoLink"); + private final Id linkId2 = Id.createLinkId("demoLink2"); + private final Id carrierId = Id.create("testCarrier", Carrier.class); + private final Id vehicleId = Id.createVehicleId("myVehicle"); + + private final Id tourId = Id.create("myCarrierTour", Tour.class); + private final CarrierService service = CarrierService.Builder.newInstance(Id.create("service42", CarrierService.class), linkId2 ).build(); + private final CarrierShipment shipment = CarrierShipment.Builder.newInstance(Id.create("shipment11", CarrierShipment.class), linkId, linkId2,7 ).build(); + + private final List carrierEvents = List.of( + new CarrierTourStartEvent(10, carrierId, linkId, vehicleId, tourId), + new CarrierTourEndEvent(500, carrierId, linkId, vehicleId, tourId), + new CarrierServiceStartEvent(20, carrierId, service, vehicleId), + new CarrierServiceEndEvent(25, carrierId, service, vehicleId), + new CarrierShipmentPickupStartEvent(100, carrierId, shipment, vehicleId), + new CarrierShipmentPickupEndEvent(115, carrierId, shipment, vehicleId), + new CarrierShipmentDeliveryStartEvent(210, carrierId, shipment, vehicleId), + new CarrierShipmentDeliveryEndEvent(225, carrierId, shipment, vehicleId) + ); + + @Test + public void testWriteReadServiceBasedEvents() { + EventsManager eventsManager1 = EventsUtils.createEventsManager(); + EventsManager eventsManager2 = EventsUtils.createEventsManager(); + EventsCollector collector1 = new EventsCollector(); + EventsCollector collector2 = new EventsCollector(); + + eventsManager1.addHandler(collector1); + eventsManager1.initProcessing(); + CarrierEventsReaders.createEventsReader(eventsManager1) + .readFile(utils.getClassInputDirectory() + "serviceBasedEvents.xml"); + eventsManager1.finishProcessing(); + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + EventWriterXML writer = new EventWriterXML(outputStream); + collector1.getEvents().forEach(writer::handleEvent); + writer.closeFile(); + + eventsManager2.addHandler(collector2); + eventsManager2.initProcessing(); + CarrierEventsReaders.createEventsReader(eventsManager2) + .readStream(new ByteArrayInputStream(outputStream.toByteArray()), ControllerConfigGroup.EventsFileFormat.xml); + eventsManager2.finishProcessing(); + + Assert.assertEquals(collector1.getEvents(), collector2.getEvents()); + } + + + @Test + public void testReadServiceBasedEvents() { + + EventsManager eventsManager = EventsUtils.createEventsManager(); + TestEventHandlerTours eventHandlerTours = new TestEventHandlerTours(); + TestEventHandlerServices eventHandlerServices = new TestEventHandlerServices(); + + eventsManager.addHandler(eventHandlerTours); + eventsManager.addHandler(eventHandlerServices); + eventsManager.initProcessing(); + CarrierEventsReaders.createEventsReader(eventsManager) + .readFile(utils.getClassInputDirectory() + "serviceBasedEvents.xml"); + eventsManager.finishProcessing(); + + Assert.assertEquals("Number of tour related carrier events is not correct", 4 , eventHandlerTours.handledEvents.size()); + Assert.assertEquals("Number of service related carrier events is not correct", 14 , eventHandlerServices.handledEvents.size()); + } + + @Test + public void testWriteReadShipmentBasedEvents() { + EventsManager eventsManager1 = EventsUtils.createEventsManager(); + EventsManager eventsManager2 = EventsUtils.createEventsManager(); + EventsCollector collector1 = new EventsCollector(); + EventsCollector collector2 = new EventsCollector(); + + eventsManager1.addHandler(collector1); + eventsManager1.initProcessing(); + CarrierEventsReaders.createEventsReader(eventsManager1) + .readFile(utils.getClassInputDirectory() + "shipmentBasedEvents.xml"); + eventsManager1.finishProcessing(); + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + EventWriterXML writer = new EventWriterXML(outputStream); + collector1.getEvents().forEach(writer::handleEvent); + writer.closeFile(); + + eventsManager2.addHandler(collector2); + eventsManager2.initProcessing(); + CarrierEventsReaders.createEventsReader(eventsManager2) + .readStream(new ByteArrayInputStream(outputStream.toByteArray()), ControllerConfigGroup.EventsFileFormat.xml); + eventsManager2.finishProcessing(); + + Assert.assertEquals(collector1.getEvents(), collector2.getEvents()); + } + + @Test + public void testReadShipmentBasedEvents() { + + EventsManager eventsManager = EventsUtils.createEventsManager(); + TestEventHandlerTours eventHandlerTours = new TestEventHandlerTours(); + TestEventHandlerShipments testEventHandlerShipments = new TestEventHandlerShipments(); + + eventsManager.addHandler(eventHandlerTours); + eventsManager.addHandler(testEventHandlerShipments); + eventsManager.initProcessing(); + CarrierEventsReaders.createEventsReader(eventsManager) + .readFile(utils.getClassInputDirectory() + "shipmentBasedEvents.xml"); + eventsManager.finishProcessing(); + + Assert.assertEquals("Number of tour related carrier events is not correct", 2 , eventHandlerTours.handledEvents.size()); + Assert.assertEquals("Number of shipments related carrier events is not correct", 20 , testEventHandlerShipments.handledEvents.size()); + } + + + /** + * This test is testing the reader with some locally created events (see above). + * This test is inspired by the DrtEventsReaderTest from michalm. + */ + @Test + public void testReader() { + var outputStream = new ByteArrayOutputStream(); + EventWriterXML writer = new EventWriterXML(outputStream); + carrierEvents.forEach(writer::handleEvent); + writer.closeFile(); + + EventsManager eventsManager = EventsUtils.createEventsManager(); + TestEventHandlerTours eventHandlerTours = new TestEventHandlerTours(); + TestEventHandlerServices eventHandlerServices = new TestEventHandlerServices(); + TestEventHandlerShipments eventHandlerShipments = new TestEventHandlerShipments(); + + eventsManager.addHandler(eventHandlerTours); + eventsManager.addHandler(eventHandlerServices); + eventsManager.addHandler(eventHandlerShipments); + + eventsManager.initProcessing(); + CarrierEventsReaders.createEventsReader(eventsManager) + .readStream(new ByteArrayInputStream(outputStream.toByteArray()), + ControllerConfigGroup.EventsFileFormat.xml); + eventsManager.finishProcessing(); + + var handledEvents = new ArrayList(); + handledEvents.addAll(eventHandlerTours.handledEvents); + handledEvents.addAll(eventHandlerServices.handledEvents); + handledEvents.addAll(eventHandlerShipments.handledEvents); + + //Please note: This test is sensitive to the order of events as they are added in carrierEvents (input) and the resukts of the handler... + Assert.assertArrayEquals(carrierEvents.toArray(), handledEvents.toArray()); + } + + private static class TestEventHandlerTours + implements CarrierTourStartEventHandler, CarrierTourEndEventHandler { + private final List handledEvents = new ArrayList<>(); + + + @Override public void handleEvent(CarrierTourEndEvent event) { + handledEvents.add(event); + } + + @Override public void handleEvent(CarrierTourStartEvent event) { + handledEvents.add(event); + } + } + + private static class TestEventHandlerServices + implements CarrierServiceStartEventHandler, CarrierServiceEndEventHandler { + private final List handledEvents = new ArrayList<>(); + + @Override public void handleEvent(CarrierServiceEndEvent event) { + handledEvents.add(event); + } + + @Override public void handleEvent(CarrierServiceStartEvent event) { + handledEvents.add(event); + } + + } + + private static class TestEventHandlerShipments + implements CarrierShipmentDeliveryStartEventHandler, CarrierShipmentDeliveryEndEventHandler, CarrierShipmentPickupStartEventHandler, CarrierShipmentPickupEndEventHandler { + private final List handledEvents = new ArrayList<>(); + + + @Override public void handleEvent(CarrierShipmentDeliveryEndEvent event) { + handledEvents.add(event); + } + + @Override public void handleEvent(CarrierShipmentPickupEndEvent event) { + handledEvents.add(event); + } + + @Override public void handleEvent(CarrierShipmentDeliveryStartEvent event) { + handledEvents.add(event); + } + + @Override public void handleEvent(CarrierShipmentPickupStartEvent event) { + handledEvents.add(event); + } + } +} diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierEventsReadersTest/serviceBasedEvents.xml b/contribs/freight/test/input/org/matsim/freight/carriers/CarrierEventsReadersTest/serviceBasedEvents.xml new file mode 100644 index 00000000000..b4121096264 --- /dev/null +++ b/contribs/freight/test/input/org/matsim/freight/carriers/CarrierEventsReadersTest/serviceBasedEvents.xml @@ -0,0 +1,213 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierEventsReadersTest/shipmentBasedEvents.xml b/contribs/freight/test/input/org/matsim/freight/carriers/CarrierEventsReadersTest/shipmentBasedEvents.xml new file mode 100644 index 00000000000..ca675a9bcbf --- /dev/null +++ b/contribs/freight/test/input/org/matsim/freight/carriers/CarrierEventsReadersTest/shipmentBasedEvents.xml @@ -0,0 +1,193 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventHandler.java b/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventHandler.java index 5a9daccf1cf..2f322e8640f 100644 --- a/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventHandler.java +++ b/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventHandler.java @@ -36,10 +36,10 @@ import org.matsim.freight.carriers.events.CarrierServiceStartEvent; import org.matsim.freight.carriers.events.CarrierShipmentDeliveryEndEvent; import org.matsim.freight.carriers.events.CarrierShipmentPickupEndEvent; -import org.matsim.freight.carriers.events.eventhandler.FreightServiceEndEventHandler; -import org.matsim.freight.carriers.events.eventhandler.FreightServiceStartEventHandler; -import org.matsim.freight.carriers.events.eventhandler.FreightShipmentDeliveryEventHandler; -import org.matsim.freight.carriers.events.eventhandler.FreightShipmentPickupEventHandler; +import org.matsim.freight.carriers.events.eventhandler.CarrierServiceEndEventHandler; +import org.matsim.freight.carriers.events.eventhandler.CarrierServiceStartEventHandler; +import org.matsim.freight.carriers.events.eventhandler.CarrierShipmentDeliveryEndEventHandler; +import org.matsim.freight.carriers.events.eventhandler.CarrierShipmentPickupEndEventHandler; import org.matsim.core.network.NetworkUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.Vehicles; @@ -59,7 +59,7 @@ * */ @Deprecated(since = "apr23") -class FreightAnalysisEventHandler implements ActivityStartEventHandler, LinkEnterEventHandler, LinkLeaveEventHandler, PersonEntersVehicleEventHandler, PersonLeavesVehicleEventHandler, FreightShipmentPickupEventHandler, FreightShipmentDeliveryEventHandler, FreightServiceStartEventHandler, FreightServiceEndEventHandler { +class FreightAnalysisEventHandler implements ActivityStartEventHandler, LinkEnterEventHandler, LinkLeaveEventHandler, PersonEntersVehicleEventHandler, PersonLeavesVehicleEventHandler, CarrierShipmentPickupEndEventHandler, CarrierShipmentDeliveryEndEventHandler, CarrierServiceStartEventHandler, CarrierServiceEndEventHandler { private final static Logger log = LogManager.getLogger(FreightAnalysisEventHandler.class); private final Vehicles vehicles; diff --git a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/MyServiceTrackerEventHandler.java b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/MyServiceTrackerEventHandler.java index 43c9dd2d524..ae51676c57b 100644 --- a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/MyServiceTrackerEventHandler.java +++ b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/MyServiceTrackerEventHandler.java @@ -29,11 +29,11 @@ import org.matsim.freight.carriers.Carriers; import org.matsim.freight.carriers.events.CarrierServiceEndEvent; import org.matsim.freight.carriers.events.CarrierServiceStartEvent; -import org.matsim.freight.carriers.events.eventhandler.FreightServiceEndEventHandler; -import org.matsim.freight.carriers.events.eventhandler.FreightServiceStartEventHandler; +import org.matsim.freight.carriers.events.eventhandler.CarrierServiceEndEventHandler; +import org.matsim.freight.carriers.events.eventhandler.CarrierServiceStartEventHandler; import org.matsim.vehicles.Vehicles; - class MyServiceTrackerEventHandler implements ActivityStartEventHandler, FreightServiceStartEventHandler, FreightServiceEndEventHandler { + class MyServiceTrackerEventHandler implements ActivityStartEventHandler, CarrierServiceStartEventHandler, CarrierServiceEndEventHandler { private final Vehicles vehicles; private final Network network; private final Carriers carriers; diff --git a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/MyShipmentTrackerEventHandler.java b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/MyShipmentTrackerEventHandler.java index 35b455b8944..178652c1c7d 100644 --- a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/MyShipmentTrackerEventHandler.java +++ b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/MyShipmentTrackerEventHandler.java @@ -29,11 +29,11 @@ import org.matsim.freight.carriers.Carriers; import org.matsim.freight.carriers.events.CarrierShipmentDeliveryEndEvent; import org.matsim.freight.carriers.events.CarrierShipmentPickupEndEvent; -import org.matsim.freight.carriers.events.eventhandler.FreightShipmentDeliveryEventHandler; -import org.matsim.freight.carriers.events.eventhandler.FreightShipmentPickupEventHandler; +import org.matsim.freight.carriers.events.eventhandler.CarrierShipmentDeliveryEndEventHandler; +import org.matsim.freight.carriers.events.eventhandler.CarrierShipmentPickupEndEventHandler; import org.matsim.vehicles.Vehicles; -public class MyShipmentTrackerEventHandler implements ActivityStartEventHandler, FreightShipmentPickupEventHandler, FreightShipmentDeliveryEventHandler { +public class MyShipmentTrackerEventHandler implements ActivityStartEventHandler, CarrierShipmentPickupEndEventHandler, CarrierShipmentDeliveryEndEventHandler { private final Vehicles vehicles; private final Network network; @@ -69,7 +69,7 @@ public void handleEvent(CarrierShipmentPickupEndEvent event) { @Override public void reset(int iteration) { - FreightShipmentPickupEventHandler.super.reset(iteration); + CarrierShipmentPickupEndEventHandler.super.reset(iteration); } @Override