Skip to content

Commit

Permalink
Bugfix edrt failIfNotStarted (#2972)
Browse files Browse the repository at this point in the history
* Fix edrt failIfNotStarted
  • Loading branch information
steffenaxer authored Nov 30, 2023
1 parent 0a81975 commit 76a5bdd
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends Task> tasks = schedule.getTasks();
for (int i = nextTaskIdx; i < tasks.size() - 1; i++) {
chargeBeforeNextTask -= ((ETask)tasks.get(i)).getTotalEnergy();
Expand Down

0 comments on commit 76a5bdd

Please sign in to comment.