Skip to content

Commit

Permalink
feat/fix(ev): minor changes (#3634)
Browse files Browse the repository at this point in the history
* fix case where vehicle is still queued at end of day

* make all profiles optional

* fix code error
  • Loading branch information
sebhoerl authored Dec 7, 2024
1 parent 9c30281 commit c6e1bf5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ private void proccessChargingEventSequences(CSVPrinter csvPrinter, Collection<Ch

if (sequence.getQueuedAtCharger().isPresent()) {
waitStartTime = sequence.getQueuedAtCharger().get().getTime();
waitEndTime = sequence.getQuitQueueAtChargerEvent().isPresent() ?
sequence.getQuitQueueAtChargerEvent().get().getTime() : sequence.getChargingStart().get().getTime();

if (sequence.getQuitQueueAtChargerEvent().isPresent()) {
waitEndTime = sequence.getQuitQueueAtChargerEvent().get().getTime();
} else if (sequence.getChargingStart().isPresent()) {
waitEndTime = sequence.getChargingStart().get().getTime();
}
}

double startEnergy = Double.NaN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@

package org.matsim.contrib.ev.stats;

import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import org.matsim.contrib.common.timeprofile.ProfileWriter;
import org.matsim.contrib.ev.EvConfigGroup;
import org.matsim.contrib.ev.EvModule;
Expand All @@ -32,6 +29,10 @@
import org.matsim.core.controler.listener.ControlerListener;
import org.matsim.core.mobsim.qsim.AbstractQSimModule;

import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;

/**
* @author Michal Maciejewski (michalm)
*/
Expand All @@ -45,37 +46,42 @@ public void install() {
addEventHandlerBinding().to(ChargingEventSequenceCollector.class);
addControlerListenerBinding().to(ChargingProceduresCSVWriter.class).in(Singleton.class);

installQSimModule(new AbstractQSimModule() {
@Override
protected void configureQSim() {
if (evCfg.timeProfiles) {
addQSimComponentBinding(EvModule.EV_COMPONENT).toProvider(SocHistogramTimeProfileCollectorProvider.class);
addQSimComponentBinding(EvModule.EV_COMPONENT).toProvider(IndividualChargeTimeProfileCollectorProvider.class);
addQSimComponentBinding(EvModule.EV_COMPONENT).toProvider(ChargerOccupancyTimeProfileCollectorProvider.class);
addQSimComponentBinding(EvModule.EV_COMPONENT).to(ChargerOccupancyXYDataCollector.class).asEagerSingleton();
addQSimComponentBinding(EvModule.EV_COMPONENT).toProvider(VehicleTypeAggregatedChargeTimeProfileCollectorProvider.class);
if (evCfg.timeProfiles) {
installQSimModule(new AbstractQSimModule() {
@Override
protected void configureQSim() {
addQSimComponentBinding(EvModule.EV_COMPONENT)
.toProvider(SocHistogramTimeProfileCollectorProvider.class);
addQSimComponentBinding(EvModule.EV_COMPONENT)
.toProvider(IndividualChargeTimeProfileCollectorProvider.class);
addQSimComponentBinding(EvModule.EV_COMPONENT)
.toProvider(ChargerOccupancyTimeProfileCollectorProvider.class);
addQSimComponentBinding(EvModule.EV_COMPONENT).to(ChargerOccupancyXYDataCollector.class)
.asEagerSingleton();
addQSimComponentBinding(EvModule.EV_COMPONENT)
.toProvider(VehicleTypeAggregatedChargeTimeProfileCollectorProvider.class);

bind(EnergyConsumptionCollector.class).asEagerSingleton();
addMobsimScopeEventHandlerBinding().to(EnergyConsumptionCollector.class);
addQSimComponentBinding(EvModule.EV_COMPONENT).to(EnergyConsumptionCollector.class);
// add more time profiles if necessary
}
}
});
bind(ChargerPowerTimeProfileCalculator.class).asEagerSingleton();
addEventHandlerBinding().to(ChargerPowerTimeProfileCalculator.class);
addControlerListenerBinding().toProvider(new Provider<>() {
@Inject
private ChargerPowerTimeProfileCalculator calculator;
@Inject
private MatsimServices matsimServices;
});
bind(ChargerPowerTimeProfileCalculator.class).asEagerSingleton();
addEventHandlerBinding().to(ChargerPowerTimeProfileCalculator.class);
addControlerListenerBinding().toProvider(new Provider<>() {
@Inject
private ChargerPowerTimeProfileCalculator calculator;
@Inject
private MatsimServices matsimServices;

@Override
public ControlerListener get() {
var profileView = new ChargerPowerTimeProfileView(calculator);
return new ProfileWriter(matsimServices,"ev",profileView,"charger_power_time_profiles");
@Override
public ControlerListener get() {
var profileView = new ChargerPowerTimeProfileView(calculator);
return new ProfileWriter(matsimServices, "ev", profileView, "charger_power_time_profiles");

}
});
}
});
}
}
}

0 comments on commit c6e1bf5

Please sign in to comment.