-
Notifications
You must be signed in to change notification settings - Fork 5
/
StandardLoadProfile.java
57 lines (51 loc) · 2.06 KB
/
StandardLoadProfile.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* © 2021. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.models;
import edu.ie3.datamodel.exceptions.ParsingException;
import edu.ie3.datamodel.models.timeseries.individual.IndividualTimeSeries;
import edu.ie3.datamodel.models.timeseries.repetitive.RepetitiveTimeSeries;
import java.io.Serializable;
import java.util.Arrays;
import java.util.stream.Stream;
/**
* Giving reference to a known standard load profile to apply to a {@link
* edu.ie3.datamodel.models.input.system.LoadInput}. This interface does nothing more, than giving a
* reference, the values have to be provided by the simulator using the models.
*
* <p>If you intend to provide distinct values, create either an {@link IndividualTimeSeries} or
* {@link RepetitiveTimeSeries} and assign it to the model via mapping to the model.
*/
public interface StandardLoadProfile extends Serializable {
/** @return The identifying String */
String getKey();
/**
* Parses the given key to {@link StandardLoadProfile}.
*
* @param key Key to parse
* @return Matching {@link StandardLoadProfile}
* @throws ParsingException If key cannot be parsed
*/
static StandardLoadProfile parse(String key) throws ParsingException {
if (key == null || key.isEmpty()) return DefaultLoadProfiles.NO_STANDARD_LOAD_PROFILE;
String filterKey = key.toLowerCase().replaceAll("[-_]*", "");
return Stream.concat(
Arrays.stream(BdewLoadProfile.values()),
Arrays.stream(TemperatureDependantLoadProfile.values()))
.filter(profile -> profile.getKey().equals(filterKey))
.findFirst()
.orElseThrow(
() ->
new ParsingException(
"Cannot parse \"" + key + "\" to a valid bdew standard load profile"));
}
enum DefaultLoadProfiles implements StandardLoadProfile {
NO_STANDARD_LOAD_PROFILE;
@Override
public String getKey() {
return "No standard load profile assigned";
}
}
}