Skip to content

Commit

Permalink
max soc retrieval function
Browse files Browse the repository at this point in the history
  • Loading branch information
ladenaw committed Sep 20, 2023
1 parent b5191ad commit b6270fe
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
* @author Michal Maciejewski (michalm)
*/
public class ChargeUpToTypeMaxSocStrategy implements ChargingStrategy {

private final Charger charger;
private final double maxRelativeSoc;

private final Map<String,Double> maxRelativeSocByChargerType = Stream.of(new Object[][] {{ "private_ac", 0.8 },{ "public_dc", 0.8 }, { "public_ac", 0.9 }, { "default", 0.5 }}).collect(Collectors.toMap(data -> (String) data[0], data -> (double) data[1]));


public ChargeUpToTypeMaxSocStrategy(Charger charger) {

this.maxRelativeSoc = maxRelativeSocByChargerType.getOrDefault(charger.getChargerType(), 1.0);
this.maxRelativeSoc = getMaxRelativeSoc(charger);

if (maxRelativeSoc < 0 || maxRelativeSoc > 1) {
throw new IllegalArgumentException();
Expand All @@ -67,4 +67,10 @@ public double calcRemainingEnergyToCharge(ElectricVehicle ev) {
public double calcRemainingTimeToCharge(ElectricVehicle ev) {
return ((BatteryCharging)ev.getChargingPower()).calcChargingTime(charger, calcRemainingEnergyToCharge(ev));
}

public static double getMaxRelativeSoc(Charger charger)
{
final Map<String,Double> maxRelativeSocByChargerType = Stream.of(new Object[][] {{ "private_ac", 0.8 },{ "public_dc", 0.8 }, { "public_ac", 0.9 }, { "default", 0.5 }}).collect(Collectors.toMap(data -> (String) data[0], data -> (double) data[1]));
return maxRelativeSocByChargerType.getOrDefault(charger.getChargerType(), 1.0);
}
}

0 comments on commit b6270fe

Please sign in to comment.