001/* *********************************************************************** *
002 * project: org.matsim.*
003 * *********************************************************************** *
004 *                                                                         *
005 * copyright       : (C) 2018 by the members listed in the COPYING,        *
006 *                   LICENSE and WARRANTY file.                            *
007 * email           : info at matsim dot org                                *
008 *                                                                         *
009 * *********************************************************************** *
010 *                                                                         *
011 *   This program is free software; you can redistribute it and/or modify  *
012 *   it under the terms of the GNU General Public License as published by  *
013 *   the Free Software Foundation; either version 2 of the License, or     *
014 *   (at your option) any later version.                                   *
015 *   See also COPYING, LICENSE and WARRANTY file                           *
016 *                                                                         *
017 * *********************************************************************** */
018
019package org.matsim.contrib.ev.dvrp.tracker;
020
021import org.matsim.contrib.ev.dvrp.ETask;
022import org.matsim.contrib.ev.dvrp.EvDvrpVehicle;
023import org.matsim.core.mobsim.framework.MobsimTimer;
024
025/**
026 * @author michalm
027 */
028public class OfflineETaskTracker implements ETaskTracker {
029        private final MobsimTimer timer;
030        private final ETask task;
031        private final double socAtStart;
032
033        public OfflineETaskTracker(EvDvrpVehicle vehicle, MobsimTimer timer) {
034                this.timer = timer;
035                task = (ETask)vehicle.getSchedule().getCurrentTask();
036                socAtStart = vehicle.getElectricVehicle().getBattery().getSoc();
037        }
038
039        @Override
040        public double predictEndTime() {
041                return Math.max(task.getEndTime(), timer.getTimeOfDay());
042        }
043
044        @Override
045        public double predictSocAtEnd() {
046                return socAtStart - task.getTotalEnergy();
047        }
048}