Skip to content

Commit ef9794a

Browse files
authored
Merge branch 'dev' into ms/#642-find-and-add-standard-asset-types
2 parents 197ea91 + 1bb5ca7 commit ef9794a

File tree

43 files changed

+782
-119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+782
-119
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,4 @@ updates:
1515
ignore:
1616
- dependency-name: org.spockframework:spock-core
1717
versions:
18-
- 2.1-groovy-2.5-SNAPSHOT
19-
- 2.1-groovy-3.0-SNAPSHOT
20-
- 2.2-groovy-2.5-SNAPSHOT
21-
- 2.2-groovy-3.0-SNAPSHOT
22-
- 2.2-groovy-4.0-SNAPSHOT
23-
- 2.2-M1-groovy-2.5
24-
- 2.2-M1-groovy-3.0
25-
- 2.2-M1-groovy-4.0
26-
- 2.2-M2-groovy-2.5
27-
- 2.2-M2-groovy-3.0
28-
- 2.2-M2-groovy-4.0
18+
- 2.3-groovy-4.0

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- `ThermalUnits` as a container to hold all thermal units [#134](https://github.com/ie3-institute/PowerSystemDataModel/issues/134)
1616
- `ThermalInput` as a distinct abstract class for all thermal models
1717
- `ThermalGrid` as a container for a completely connected thermal grid
18+
- `EmResult` and `FlexOptionsResult` for Energy Management Systems [#651](https://github.com/ie3-institute/PowerSystemDataModel/issues/651)
19+
- `EvcsInput` now has a parameter for enabling and disabling vehicle to grid support [#681](https://github.com/ie3-institute/PowerSystemDataModel/issues/681)
1820

1921
### Fixed
2022
- Reduced code smells [#492](https://github.com/ie3-institute/PowerSystemDataModel/issues/492)
@@ -41,6 +43,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4143
- `BufferedCsvWriter` writes columns in the order, that the headline elements are defined [#434](https://github.com/ie3-institute/PowerSystemDataModel/issues/393)
4244
- Cleaned up `IndividualTimeSeriesMetaInformation`-related methods in `CsvFileConnector` [#544](https://github.com/ie3-institute/PowerSystemDataModel/issues/544)
4345
- Fixed spotlessApply handling for `.groovy` files [#637](https://github.com/ie3-institute/PowerSystemDataModel/issues/637)
46+
- Re-using SQL connection per default [#653](https://github.com/ie3-institute/PowerSystemDataModel/issues/653)
47+
- Persisting EmInputs [#665](https://github.com/ie3-institute/PowerSystemDataModel/issues/665)
48+
- Charging point type parsing now works with more id definitions [#686](https://github.com/ie3-institute/PowerSystemDataModel/issues/685)
4449

4550
### Changed
4651
- BREAKING: PvInput Model parameter name height changed to elevationAngle [#393](https://github.com/ie3-institute/PowerSystemDataModel/issues/393) :warning:

Jenkinsfile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ String sshCredentialsId = '19f16959-8a0d-4a60-bd1f-5adb4572b702' // id that matc
2525

2626
/* ci configuration */
2727
String sonarqubeProjectKey = 'edu.ie3:PowerSystemDataModel' // sonarqube project key, case-sensitive
28-
String codeCovTokenId = 'psdm-codecov-token' // id that matches the code coverage token set as jenkins property
2928

3029
/* maven central configuration */
3130
String mavenCentralCredentialsId = '87bfb2d4-7613-4816-9fe1-70dfd7e6dec2' // id that matches the maven central credentials set as jenkins property
@@ -191,12 +190,6 @@ node {
191190
// publish reports
192191
publishReports(projectName)
193192

194-
// call codecov.io
195-
withCredentials([
196-
string(credentialsId: codeCovTokenId, variable: 'codeCovToken')
197-
]) {
198-
sh "curl -s https://codecov.io/bash | bash -s - -t ${env.codeCovToken} -C ${commitHash}"
199-
}
200193
}
201194

202195
} catch (Exception e) {

build.gradle

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ plugins {
44
id 'maven-publish'
55
id 'signing'
66
id 'pmd' // code check, working on source code
7-
id 'com.diffplug.spotless' version '6.9.1'//code format
8-
id 'com.github.spotbugs' version '5.0.9' // code check, working on byte code
9-
id 'de.undercouch.download' version '5.1.0'
7+
id 'com.diffplug.spotless' version '6.11.0'//code format
8+
id 'com.github.spotbugs' version '5.0.12' // code check, working on byte code
9+
id 'de.undercouch.download' version '5.2.1'
1010
id 'kr.motd.sphinx' version '2.10.1' // documentation generation
1111
id 'jacoco' // java code coverage plugin
1212
id "org.sonarqube" version "3.4.0.2513" // sonarqube
@@ -17,7 +17,7 @@ ext {
1717
//version (changing these should be considered thoroughly!)
1818
javaVersion = JavaVersion.VERSION_17
1919
tscfgVersion = '0.9.9'
20-
testcontainersVersion = '1.17.3'
20+
testcontainersVersion = '1.17.5'
2121

2222
scriptsLocation = 'gradle' + File.separator + 'scripts' + File.separator //location of script plugins
2323
}
@@ -73,9 +73,10 @@ dependencies {
7373
implementation 'org.jgrapht:jgrapht-core:1.5.1'
7474

7575
// testing
76-
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
77-
testImplementation 'org.spockframework:spock-core:2.1-groovy-3.0'
76+
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.1'
77+
testImplementation 'org.spockframework:spock-core:2.3-groovy-3.0'
7878
testImplementation 'org.objenesis:objenesis:3.3' // Mock creation with constructor parameters
79+
testImplementation 'net.bytebuddy:byte-buddy:1.12.18' // Mocks of classes
7980

8081
// testcontainers (docker framework for testing)
8182
testImplementation "org.testcontainers:testcontainers:$testcontainersVersion"
@@ -85,15 +86,15 @@ dependencies {
8586
testImplementation "org.testcontainers:couchbase:$testcontainersVersion"
8687

8788
// logging
88-
implementation platform('org.apache.logging.log4j:log4j-bom:2.18.0')
89+
implementation platform('org.apache.logging.log4j:log4j-bom:2.19.0')
8990
implementation 'org.apache.logging.log4j:log4j-api' // log4j
9091
implementation 'org.apache.logging.log4j:log4j-core' // log4j
9192
implementation 'org.apache.logging.log4j:log4j-slf4j-impl' // log4j -> slf4j
9293

9394
// Databases
9495
implementation 'org.influxdb:influxdb-java:2.23'
95-
implementation 'com.couchbase.client:java-client:3.3.3'
96-
runtimeOnly 'org.postgresql:postgresql:42.4.1' // postgresql jdbc driver required during runtime
96+
implementation 'com.couchbase.client:java-client:3.3.4'
97+
runtimeOnly 'org.postgresql:postgresql:42.5.0' // postgresql jdbc driver required during runtime
9798

9899
implementation 'commons-io:commons-io:2.11.0' // I/O functionalities
99100
implementation 'org.apache.commons:commons-compress:1.21' // I/O functionalities

src/main/java/edu/ie3/datamodel/io/connectors/SqlConnector.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,14 @@ public int executeUpdate(String updateQuery) {
7474
}
7575

7676
/**
77-
* Establishes and returns a new database connection
77+
* Establishes and returns a database connection. If a connection has not been established yet, a
78+
* new one is created.
7879
*
7980
* @return the connection object
8081
* @throws SQLException if the connection could not be established
8182
*/
8283
public Connection getConnection() throws SQLException {
83-
return getConnection(false);
84+
return getConnection(true);
8485
}
8586

8687
/**
@@ -92,12 +93,15 @@ public Connection getConnection() throws SQLException {
9293
* @throws SQLException if the connection could not be established
9394
*/
9495
public Connection getConnection(boolean reuseConnection) throws SQLException {
95-
if (!reuseConnection || connection == null || connection.isClosed())
96+
if (!reuseConnection || connection == null || connection.isClosed()) {
9697
try {
98+
if (connection != null) connection.close();
99+
97100
connection = DriverManager.getConnection(jdbcUrl, connectionProps);
98101
} catch (SQLException e) {
99102
throw new SQLException("Could not establish connection: ", e);
100103
}
104+
}
101105
return connection;
102106
}
103107

src/main/java/edu/ie3/datamodel/io/factory/FactoryData.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ field, getField(field)),
146146
*/
147147
public UUID[] getUUIDs(String field) {
148148
try {
149-
String[] uuidFields = field.split(" ");
149+
String fieldValue = getField(field);
150+
if (fieldValue.trim().isEmpty()) return new UUID[0];
151+
152+
String[] uuidFields = fieldValue.split(" ");
150153
return Arrays.stream(uuidFields).map(UUID::fromString).toArray(UUID[]::new);
151154
} catch (IllegalArgumentException iae) {
152155
throw new FactoryException(

src/main/java/edu/ie3/datamodel/io/factory/input/participant/EmInputFactory.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ protected EmInput buildModel(
5353
id);
5454
controlStrategy = ControlStrategy.DefaultControlStrategies.NO_CONTROL_STRATEGY;
5555
}
56-
final UUID[] connectedAssets = data.getUUIDs(data.getField(CONNECTED_ASSETS));
56+
final UUID[] connectedAssets = data.getUUIDs(CONNECTED_ASSETS);
57+
58+
if (connectedAssets.length == 0)
59+
logger.warn("There are no connected assets for energy management system \"{}\".", id);
60+
5761
return new EmInput(
5862
uuid,
5963
id,

src/main/java/edu/ie3/datamodel/io/factory/input/participant/EvcsInputFactory.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ public class EvcsInputFactory
3333
private static final String CHARGING_POINTS = "chargingpoints";
3434
private static final String COS_PHI_RATED = "cosphirated";
3535
private static final String LOCATION_TYPE = "locationtype";
36+
private static final String V2G_SUPPORT = "v2gsupport";
3637

3738
public EvcsInputFactory() {
3839
super(EvcsInput.class);
3940
}
4041

4142
@Override
4243
protected String[] getAdditionalFields() {
43-
return new String[] {TYPE, CHARGING_POINTS, COS_PHI_RATED, LOCATION_TYPE};
44+
return new String[] {TYPE, CHARGING_POINTS, COS_PHI_RATED, LOCATION_TYPE, V2G_SUPPORT};
4445
}
4546

4647
@Override
@@ -77,6 +78,8 @@ protected EvcsInput buildModel(
7778
e);
7879
}
7980

81+
final boolean v2gSupport = data.getBoolean(V2G_SUPPORT);
82+
8083
return new EvcsInput(
8184
uuid,
8285
id,
@@ -87,6 +90,7 @@ protected EvcsInput buildModel(
8790
type,
8891
chargingPoints,
8992
cosPhi,
90-
locationType);
93+
locationType,
94+
v2gSupport);
9195
}
9296
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* © 2022. TU Dortmund University,
3+
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
4+
* Research group Distribution grid planning and operation
5+
*/
6+
package edu.ie3.datamodel.io.factory.result;
7+
8+
import edu.ie3.datamodel.io.factory.SimpleEntityData;
9+
import edu.ie3.datamodel.models.StandardUnits;
10+
import edu.ie3.datamodel.models.result.system.FlexOptionsResult;
11+
import java.time.ZonedDateTime;
12+
import java.util.*;
13+
import javax.measure.quantity.Power;
14+
import tech.units.indriya.ComparableQuantity;
15+
16+
public class FlexOptionsResultFactory extends ResultEntityFactory<FlexOptionsResult> {
17+
18+
private static final String P_REF = "pref";
19+
private static final String P_MIN = "pmin";
20+
private static final String P_MAX = "pmax";
21+
22+
public FlexOptionsResultFactory() {
23+
super(FlexOptionsResult.class);
24+
}
25+
26+
/**
27+
* Create a new factory to build {@link FlexOptionsResult}s and utilize the given date time
28+
* formatter pattern to parse date time strings
29+
*
30+
* @param dtfPattern Pattern to parse date time strings
31+
*/
32+
public FlexOptionsResultFactory(String dtfPattern) {
33+
super(dtfPattern, FlexOptionsResult.class);
34+
}
35+
36+
@Override
37+
protected List<Set<String>> getFields(SimpleEntityData data) {
38+
Set<String> minConstructorParams = newSet(TIME, INPUT_MODEL, P_REF, P_MIN, P_MAX);
39+
Set<String> optionalFields = expandSet(minConstructorParams, ENTITY_UUID);
40+
41+
return Arrays.asList(minConstructorParams, optionalFields);
42+
}
43+
44+
@Override
45+
protected FlexOptionsResult buildModel(SimpleEntityData data) {
46+
ZonedDateTime zdtTime = timeUtil.toZonedDateTime(data.getField(TIME));
47+
UUID inputModelUuid = data.getUUID(INPUT_MODEL);
48+
ComparableQuantity<Power> pRef = data.getQuantity(P_REF, StandardUnits.ACTIVE_POWER_RESULT);
49+
ComparableQuantity<Power> pMin = data.getQuantity(P_MIN, StandardUnits.ACTIVE_POWER_RESULT);
50+
ComparableQuantity<Power> pMax = data.getQuantity(P_MAX, StandardUnits.ACTIVE_POWER_RESULT);
51+
52+
Optional<UUID> uuidOpt =
53+
data.containsKey(ENTITY_UUID) ? Optional.of(data.getUUID(ENTITY_UUID)) : Optional.empty();
54+
55+
return uuidOpt
56+
.map(uuid -> new FlexOptionsResult(uuid, zdtTime, inputModelUuid, pRef, pMin, pMax))
57+
.orElseGet(() -> new FlexOptionsResult(zdtTime, inputModelUuid, pRef, pMin, pMax));
58+
}
59+
}

src/main/java/edu/ie3/datamodel/io/factory/result/SystemParticipantResultFactory.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public SystemParticipantResultFactory() {
4040
StorageResult.class,
4141
EvcsResult.class,
4242
EvResult.class,
43-
HpResult.class);
43+
HpResult.class,
44+
EmResult.class);
4445
}
4546

4647
/**
@@ -61,7 +62,8 @@ public SystemParticipantResultFactory(String dtfPattern) {
6162
StorageResult.class,
6263
EvcsResult.class,
6364
EvResult.class,
64-
HpResult.class);
65+
HpResult.class,
66+
EmResult.class);
6567
}
6668

6769
@Override
@@ -116,6 +118,10 @@ protected SystemParticipantResult buildModel(SimpleEntityData data) {
116118
return uuidOpt
117119
.map(uuid -> new EvcsResult(uuid, zdtTime, inputModelUuid, p, q))
118120
.orElseGet(() -> new EvcsResult(zdtTime, inputModelUuid, p, q));
121+
} else if (entityClass.equals(EmResult.class)) {
122+
return uuidOpt
123+
.map(uuid -> new EmResult(uuid, zdtTime, inputModelUuid, p, q))
124+
.orElseGet(() -> new EmResult(zdtTime, inputModelUuid, p, q));
119125
} else if (SystemParticipantWithHeatResult.class.isAssignableFrom(entityClass)) {
120126
/* The following classes all have a heat component as well */
121127
ComparableQuantity<Power> qDot = data.getQuantity(Q_DOT, StandardUnits.Q_DOT_RESULT);

0 commit comments

Comments
 (0)