Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Commit

Permalink
include unloading in the shipment log as a temporal fix. Adding todos…
Browse files Browse the repository at this point in the history
… and links to discussions
  • Loading branch information
kt86 committed Nov 17, 2023
1 parent e000671 commit 32ada6f
Showing 1 changed file with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void handleEvent(CarrierTourEndEvent event) {
if (serviceActivity.getLocation() == transshipmentHubResource.getStartLinkId()
&& allServicesAreInOnePoint(tour)
&& (tour.getStartLinkId() != transshipmentHubResource.getStartLinkId())) {
logHandlingInHub(serviceActivity.getService(), event.getTime());
logHandlingInHub(serviceActivity.getService(), event, tour );
}
}
}
Expand All @@ -129,7 +129,7 @@ && allServicesAreInOnePoint(tour)
for (TourElement tourElement : tour.getTourElements()) {
if (tourElement instanceof ServiceActivity serviceActivity ) {
if (tour.getEndLinkId() == transshipmentHubResource.getStartLinkId())
logHandlingInHub(serviceActivity.getService(), event.getTime());
logHandlingInHub(serviceActivity.getService(), event, tour );
}
}
}
Expand All @@ -148,11 +148,27 @@ private boolean allShipmentsOfTourEndInOnePoint(Tour tour) {
return allShipmentsOfTourEndInOnePoint;
}

private void logHandlingInHub(CarrierService carrierService, double startTime) {
private double getTotalUnloadingTime(Tour tour) {
double totalTime = 0;
for (TourElement element : tour.getTourElements()) {
if (element instanceof ServiceActivity serviceActivity) {
totalTime = totalTime + serviceActivity.getDuration();
}
}
return totalTime;
}

private void logHandlingInHub(CarrierService carrierService, CarrierTourEndEvent event, Tour tour) {

LSPShipment lspShipment = servicesWaitedFor.get(carrierService).shipment;

//TODO: Adding this here to be more in line with the schedule and have the shipment log fitting to it.
// This does NOT mean, that it really makes sense, because we decided for some reasons, that the handlingEvent start once the vehicle has arrived.
// It may change again, once we have unloading events available.
double expUnloadingTime = getTotalUnloadingTime(tour);
double expHandlingDuration = transshipmentHubResource.getCapacityNeedFixed() + transshipmentHubResource.getCapacityNeedLinear() * lspShipment.getSize();
double endTime = startTime + expHandlingDuration;
final double startTime = event.getTime() + expUnloadingTime ;
double endTime = startTime + expUnloadingTime+ expHandlingDuration;

{ //Old logging approach - will be removed at some point in time
ShipmentPlanElement handle = ShipmentUtils.LoggedShipmentHandleBuilder.newInstance()
Expand All @@ -168,8 +184,9 @@ private void logHandlingInHub(CarrierService carrierService, double startTime) {
}
}
{ // New event-based approach
// Könnte sein, dass das jetzt funktioniert. kai, may'23
eventsManager.processEvent(new HandlingInHubStartsEvent(startTime, linkId, lspShipment.getId(), resourceId, expHandlingDuration));
//Todo: We need to decide what we write into the exp. handling duration: See #175 for discussion.
// The start time, must start at the same time as the triggering event. -> keep events stream ordered.
eventsManager.processEvent(new HandlingInHubStartsEvent(event.getTime(), linkId, lspShipment.getId(), resourceId, expHandlingDuration));
}

}
Expand Down

0 comments on commit 32ada6f

Please sign in to comment.