Skip to content

Commit ee272d3

Browse files
committed
Add handling of custom load profiles in LoadProfileSource.getResolution.
1 parent ab2c4cb commit ee272d3

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

src/main/java/edu/ie3/datamodel/io/source/LoadProfileSource.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,24 @@ protected Try<LoadProfileEntry<V>, FactoryException> createEntries(
8989
public abstract Optional<ComparableQuantity<Energy>> getLoadProfileEnergyScaling();
9090

9191
/**
92-
* Returns the resolution for the given {@link LoadProfile}.
92+
* Returns an option for the resolution for the given {@link LoadProfile}.
93+
*
94+
* <p>Note: This method does not support {@link LoadProfile.CustomLoadProfile}. If a custom load
95+
* profile is provided, no resolution is returned.
9396
*
9497
* @param loadProfile given load profile
9598
* @return the resolution in seconds.
9699
*/
97-
public static long getResolution(LoadProfile loadProfile) {
98-
100+
public static Optional<Long> getResolution(LoadProfile loadProfile) {
99101
if (loadProfile == LoadProfile.DefaultLoadProfiles.NO_LOAD_PROFILE) {
100-
// since no load profile was assigned, we return the maximal possible value
101-
return Long.MAX_VALUE;
102+
// since no load profile was assigned, we return no resolution
103+
return Optional.empty();
104+
} else if (loadProfile instanceof LoadProfile.CustomLoadProfile c) {
105+
log.info("Custom load profile {} found. Cannot provide resolution!", c.key());
106+
return Optional.empty();
102107
} else {
103108
// currently all registered profiles and all sources use 15 minutes intervals
104-
return 900L;
109+
return Optional.of(900L);
105110
}
106111
}
107112

src/main/java/edu/ie3/datamodel/utils/validation/SystemParticipantValidationUtils.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,7 @@ private static List<Try<Void, InvalidEntityException>> checkLoad(LoadInput loadI
375375
exceptions.add(
376376
Try.ofVoid(
377377
loadInput.getLoadProfile() == null,
378-
() ->
379-
new InvalidEntityException(
380-
"No standard load profile defined for load", loadInput)));
378+
() -> new InvalidEntityException("No load profile defined for load", loadInput)));
381379

382380
exceptions.addAll(
383381
Try.ofVoid(

src/test/groovy/edu/ie3/datamodel/io/source/LoadProfileSourceTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class LoadProfileSourceTest extends Specification {
2222
def resolutions = Arrays.stream(allProfiles).map { it -> LoadProfileSource.getResolution(it) }.toList()
2323

2424
then:
25-
resolutions.every { resolution -> resolution == 900 }
25+
resolutions.every { resolution -> resolution == Optional.of(900L) }
2626
}
2727

2828

src/test/groovy/edu/ie3/datamodel/utils/validation/SystemParticipantValidationUtilsTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ class SystemParticipantValidationUtilsTest extends Specification {
324324

325325
where:
326326
invalidLoad || expectedSize || expectedException
327-
SystemParticipantTestData.loadInput.copy().loadprofile(null).build() || 1 || new InvalidEntityException("No standard load profile defined for load", invalidLoad)
327+
SystemParticipantTestData.loadInput.copy().loadprofile(null).build() || 1 || new InvalidEntityException("No load profile defined for load", invalidLoad)
328328
SystemParticipantTestData.loadInput.copy().sRated(Quantities.getQuantity(-25d, ACTIVE_POWER_IN)).eConsAnnual(Quantities.getQuantity(-4000, ENERGY_IN)).build() || 1 || new InvalidEntityException("The following quantities have to be zero or positive: -25 kVA, -4000 kWh", invalidLoad)
329329
SystemParticipantTestData.loadInput.copy().cosPhiRated(2).build() || 1 || new InvalidEntityException("Rated power factor of LoadInput must be between 0 and 1", invalidLoad)
330330
}

0 commit comments

Comments
 (0)