Skip to content

Add v2g support #683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `ThermalInput` as a distinct abstract class for all thermal models
- `ThermalGrid` as a container for a completely connected thermal grid
- `EmResult` and `FlexOptionsResult` for Energy Management Systems [#651](https://github.com/ie3-institute/PowerSystemDataModel/issues/651)
- `EvcsInput` now has a parameter for enabling and disabling vehicle to grid support [#681](https://github.com/ie3-institute/PowerSystemDataModel/issues/681)

### Fixed
- Reduced code smells [#492](https://github.com/ie3-institute/PowerSystemDataModel/issues/492)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ public class EvcsInputFactory
private static final String CHARGING_POINTS = "chargingpoints";
private static final String COS_PHI_RATED = "cosphirated";
private static final String LOCATION_TYPE = "locationtype";
private static final String V2G_SUPPORT = "v2gsupport";

public EvcsInputFactory() {
super(EvcsInput.class);
}

@Override
protected String[] getAdditionalFields() {
return new String[] {TYPE, CHARGING_POINTS, COS_PHI_RATED, LOCATION_TYPE};
return new String[] {TYPE, CHARGING_POINTS, COS_PHI_RATED, LOCATION_TYPE, V2G_SUPPORT};
}

@Override
Expand Down Expand Up @@ -77,6 +78,8 @@ protected EvcsInput buildModel(
e);
}

final boolean v2gSupport = data.getBoolean(V2G_SUPPORT);

return new EvcsInput(
uuid,
id,
Expand All @@ -87,6 +90,7 @@ protected EvcsInput buildModel(
type,
chargingPoints,
cosPhi,
locationType);
locationType,
v2gSupport);
}
}
45 changes: 37 additions & 8 deletions src/main/java/edu/ie3/datamodel/models/input/system/EvcsInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class EvcsInput extends SystemParticipantInput {
/** Evcs location type */
private final EvcsLocationType locationType;

/** Whether charging station supports vehicle to grid */
private final boolean v2gSupport;

/**
* @param uuid Unique identifier
* @param id Human readable identifier
Expand All @@ -39,6 +42,7 @@ public class EvcsInput extends SystemParticipantInput {
* @param chargingPoints number of charging points available at this charging station
* @param cosPhiRated rated cos phi
* @param locationType the location type
* @param v2gSupport whether charging station supports vehicle to grid
*/
public EvcsInput(
UUID uuid,
Expand All @@ -50,12 +54,14 @@ public EvcsInput(
ChargingPointType type,
int chargingPoints,
double cosPhiRated,
EvcsLocationType locationType) {
EvcsLocationType locationType,
boolean v2gSupport) {
super(uuid, id, operator, operationTime, node, qCharacteristics);
this.type = type;
this.chargingPoints = chargingPoints;
this.cosPhiRated = cosPhiRated;
this.locationType = locationType;
this.v2gSupport = v2gSupport;
}

/**
Expand All @@ -68,6 +74,7 @@ public EvcsInput(
* @param type type of the charging points available to this charging station
* @param cosPhiRated rated cos phi
* @param locationType the location type
* @param v2gSupport whether charging station supports vehicle to grid
*/
public EvcsInput(
UUID uuid,
Expand All @@ -78,7 +85,8 @@ public EvcsInput(
ReactivePowerCharacteristic qCharacteristics,
ChargingPointType type,
double cosPhiRated,
EvcsLocationType locationType) {
EvcsLocationType locationType,
boolean v2gSupport) {
this(
uuid,
id,
Expand All @@ -89,7 +97,8 @@ public EvcsInput(
type,
1,
cosPhiRated,
locationType);
locationType,
v2gSupport);
}
/**
* @param uuid Unique identifier
Expand All @@ -100,6 +109,7 @@ public EvcsInput(
* @param chargingPoints number of charging points available at this charging station
* @param cosPhiRated rated cos phi
* @param locationType the location type
* @param v2gSupport whether charging station supports vehicle to grid
*/
public EvcsInput(
UUID uuid,
Expand All @@ -109,12 +119,14 @@ public EvcsInput(
ChargingPointType type,
int chargingPoints,
double cosPhiRated,
EvcsLocationType locationType) {
EvcsLocationType locationType,
boolean v2gSupport) {
super(uuid, id, node, qCharacteristics);
this.type = type;
this.chargingPoints = chargingPoints;
this.cosPhiRated = cosPhiRated;
this.locationType = locationType;
this.v2gSupport = v2gSupport;
}

/**
Expand All @@ -125,6 +137,7 @@ public EvcsInput(
* @param type type of the charging points available to this charging station
* @param cosPhiRated rated cos phi
* @param locationType the location type
* @param v2gSupport whether charging station supports vehicle to grid
*/
public EvcsInput(
UUID uuid,
Expand All @@ -133,8 +146,9 @@ public EvcsInput(
ReactivePowerCharacteristic qCharacteristics,
ChargingPointType type,
double cosPhiRated,
EvcsLocationType locationType) {
this(uuid, id, node, qCharacteristics, type, 1, cosPhiRated, locationType);
EvcsLocationType locationType,
boolean v2gSupport) {
this(uuid, id, node, qCharacteristics, type, 1, cosPhiRated, locationType, v2gSupport);
}

public ChargingPointType getType() {
Expand All @@ -153,6 +167,10 @@ public EvcsLocationType getLocationType() {
return locationType;
}

public boolean getV2gSupport() {
return v2gSupport;
}

@Override
public EvcsInputCopyBuilder copy() {
return new EvcsInputCopyBuilder(this);
Expand All @@ -166,7 +184,8 @@ public boolean equals(Object o) {
return chargingPoints == evcsInput.chargingPoints
&& Double.compare(evcsInput.cosPhiRated, cosPhiRated) == 0
&& type.equals(evcsInput.type)
&& locationType.equals(evcsInput.locationType);
&& locationType.equals(evcsInput.locationType)
&& v2gSupport == evcsInput.v2gSupport;
}

@Override
Expand All @@ -193,6 +212,8 @@ public String toString() {
+ ", node="
+ getNode()
+ "} "
+ ", v2gSupport="
+ getV2gSupport()
+ super.toString();
}

Expand All @@ -210,13 +231,15 @@ public static class EvcsInputCopyBuilder
private int chargingPoints;
private double cosPhiRated;
private EvcsLocationType locationType;
private boolean v2gSupport;

public EvcsInputCopyBuilder(EvcsInput entity) {
super(entity);
this.type = entity.type;
this.chargingPoints = entity.chargingPoints;
this.cosPhiRated = entity.cosPhiRated;
this.locationType = entity.locationType;
this.v2gSupport = entity.v2gSupport;
}

public EvcsInputCopyBuilder type(ChargingPointType type) {
Expand All @@ -239,6 +262,11 @@ public EvcsInputCopyBuilder locationType(EvcsLocationType locationType) {
return this;
}

public EvcsInputCopyBuilder v2gSupport(boolean v2gSupport) {
this.v2gSupport = v2gSupport;
return this;
}

@Override
public EvcsInput build() {
return new EvcsInput(
Expand All @@ -251,7 +279,8 @@ public EvcsInput build() {
type,
chargingPoints,
cosPhiRated,
locationType);
locationType,
v2gSupport);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class EvcsInputFactoryTest extends Specification implements FactoryTestHelper {
"type" : "Household",
"chargingpoints" : "4",
"cosphirated" : "0.95",
"locationtype" : "CHARGING_HUB_TOWN"
"locationtype" : "CHARGING_HUB_TOWN",
"v2gsupport" : "false"
]
def inputClass = EvcsInput
def nodeInput = Mock(NodeInput)
Expand Down Expand Up @@ -79,6 +80,7 @@ class EvcsInputFactoryTest extends Specification implements FactoryTestHelper {
assert chargingPoints == Integer.parseInt(parameter["chargingpoints"])
assert cosPhiRated == Double.parseDouble(parameter["cosphirated"])
assert locationType == EvcsLocationType.CHARGING_HUB_TOWN
assert !v2gSupport
}
}

Expand All @@ -94,7 +96,8 @@ class EvcsInputFactoryTest extends Specification implements FactoryTestHelper {
"type" : "-- invalid --",
"chargingpoints" : "4",
"cosphirated" : "0.95",
"locationtype" : "CHARGING_HUB_TOWN"
"locationtype" : "CHARGING_HUB_TOWN",
"v2gsupport" : "false"
]
def inputClass = EvcsInput
def nodeInput = Mock(NodeInput)
Expand All @@ -121,7 +124,8 @@ class EvcsInputFactoryTest extends Specification implements FactoryTestHelper {
"type" : "Household",
"chargingpoints" : "4",
"cosphirated" : "0.95",
"locationType" : "-- invalid --"
"locationType" : "-- invalid --",
"v2gsupport" : "false"
]
def inputClass = EvcsInput
def nodeInput = Mock(NodeInput)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ class InputEntityProcessorTest extends Specification {
"type" : SystemParticipantTestData.evcsInput.type.toString(),
"cosPhiRated" : SystemParticipantTestData.evcsInput.cosPhiRated.toString(),
"chargingPoints" : SystemParticipantTestData.evcsInput.chargingPoints.toString(),
"locationType" : SystemParticipantTestData.evcsInput.locationType.name()
"locationType" : SystemParticipantTestData.evcsInput.locationType.name(),
"v2gSupport" : SystemParticipantTestData.evcsInput.v2gSupport.toString()
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat
nodes | operators || resultingSize || resultingSet
[sptd.evcsInput.node] | [sptd.evcsInput.operator] || 1 || [sptd.evcsInput]
[sptd.evcsInput.node] | [] || 1 || [
new EvcsInput(sptd.evcsInput.uuid, sptd.evcsInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evcsInput.operationTime, sptd.evcsInput.node, sptd.evcsInput.qCharacteristics, sptd.evcsInput.type, sptd.evcsInput.chargingPoints, sptd.evcsInput.cosPhiRated, sptd.evcsInput.locationType)
new EvcsInput(sptd.evcsInput.uuid, sptd.evcsInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evcsInput.operationTime, sptd.evcsInput.node, sptd.evcsInput.qCharacteristics, sptd.evcsInput.type, sptd.evcsInput.chargingPoints, sptd.evcsInput.cosPhiRated, sptd.evcsInput.locationType, sptd.evcsInput.v2gSupport)
]
[]| [sptd.evcsInput.operator]|| 0 || []
[]| []|| 0 || []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class EvcsInputTest extends Specification {
.type(ChargingPointTypeUtils.TeslaSuperChargerV3)
.cosPhiRated(0.7d).chargingPoints(1)
.locationType(EvcsLocationType.CHARGING_HUB_HIGHWAY)
.v2gSupport(true)
.build()

then:
Expand All @@ -34,6 +35,7 @@ class EvcsInputTest extends Specification {
assert cosPhiRated == 0.7d
assert chargingPoints == 1
assert locationType == EvcsLocationType.CHARGING_HUB_HIGHWAY
assert v2gSupport
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ class SystemParticipantTestData {
)

// charging station
public static final boolean v2gSupport = false
public static final evcsInput = new EvcsInput(
UUID.fromString("798028b5-caff-4da7-bcd9-1750fdd8742c"),
"test_csInput",
Expand All @@ -307,7 +308,8 @@ class SystemParticipantTestData {
ChargingPointTypeUtils.HouseholdSocket,
4,
cosPhiRated,
EvcsLocationType.HOME
EvcsLocationType.HOME,
v2gSupport
)

// Energy Management
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
uuid,id,operator,operates_from,operates_until,node,q_characteristics,cos_phi_rated,type,charging_points,location_type
798028b5-caff-4da7-bcd9-1750fdd8742c,test_csInput,8f9682df-0744-4b58-a122-f0dc730f6510,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],4ca90220-74c2-4369-9afa-a18bf068840d,cosPhiFixed:{(0.0,0.95)},0.95,hhs,4,HOME
uuid,id,operator,operates_from,operates_until,node,q_characteristics,cos_phi_rated,type,charging_points,location_type,v2g_support
798028b5-caff-4da7-bcd9-1750fdd8742c,test_csInput,8f9682df-0744-4b58-a122-f0dc730f6510,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],4ca90220-74c2-4369-9afa-a18bf068840d,cosPhiFixed:{(0.0,0.95)},0.95,hhs,4,HOME,false