diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/optimizer/EDrtVehicleDataEntryFactory.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/optimizer/EDrtVehicleDataEntryFactory.java index f552fb3ecae..76d84a09e32 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/optimizer/EDrtVehicleDataEntryFactory.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/optimizer/EDrtVehicleDataEntryFactory.java @@ -71,16 +71,23 @@ public VehicleEntry create(DvrpVehicle vehicle, double currentTime) { Battery battery = ((EvDvrpVehicle)vehicle).getElectricVehicle().getBattery(); int nextTaskIdx; double chargeBeforeNextTask; - if (schedule.getStatus() == ScheduleStatus.PLANNED) { - nextTaskIdx = 0; - chargeBeforeNextTask = battery.getCharge(); - } else { // STARTED - Task currentTask = schedule.getCurrentTask(); - ETaskTracker eTracker = (ETaskTracker)currentTask.getTaskTracker(); - chargeBeforeNextTask = eTracker.predictChargeAtEnd(); - nextTaskIdx = currentTask.getTaskIdx() + 1; + + switch (schedule.getStatus()) { + case PLANNED: + nextTaskIdx = 0; + chargeBeforeNextTask = battery.getCharge(); + break; + case STARTED: + Task currentTask = schedule.getCurrentTask(); + ETaskTracker eTracker = (ETaskTracker) currentTask.getTaskTracker(); + chargeBeforeNextTask = eTracker.predictChargeAtEnd(); + nextTaskIdx = currentTask.getTaskIdx() + 1; + break; + default: + return null; } + List tasks = schedule.getTasks(); for (int i = nextTaskIdx; i < tasks.size() - 1; i++) { chargeBeforeNextTask -= ((ETask)tasks.get(i)).getTotalEnergy();