Skip to content

Commit e58e134

Browse files
Merge pull request #194 from ie3-institute/rel/sp/#192-release-0.5
Release version 0.5
2 parents 4e12506 + 217e757 commit e58e134

28 files changed

+615
-46
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased/Snapshot]
88

9+
## [0.5.0] - 2024-08-09
10+
11+
### Added
12+
- Implemented `ExtPrimaryData` and `ExtResultsData` [#145](https://github.com/ie3-institute/simonaAPI/issues/145)
13+
- Have EV simulation communicate the next tick [#170](https://github.com/ie3-institute/simonaAPI/issues/170)
14+
- Only communicate the next tick of activation of EV simulation as a whole [#176](https://github.com/ie3-institute/simonaAPI/issues/176)
15+
916
## [0.4.0] - 2023-11-22
1017

1118
### Changed
@@ -30,7 +37,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3037
- Renamed messages to ease understanding [#62](https://github.com/ie3-institute/simonaAPI/issues/62)
3138
- Separating departures and arrivals in message protocol, properly handling exceptions [#77](https://github.com/ie3-institute/simonaAPI/issues/77)
3239

33-
[Unreleased/Snapshot]: https://github.com/ie3-institute/simonaapi/compare/0.4.0...HEAD
40+
[Unreleased/Snapshot]: https://github.com/ie3-institute/simonaapi/compare/0.5.0...HEAD
41+
[0.5.0]: https://github.com/ie3-institute/powersystemdatamodel/compare/0.4.0...0.5.0
3442
[0.4.0]: https://github.com/ie3-institute/powersystemdatamodel/compare/0.3.0...0.4.0
3543
[0.3.0]: https://github.com/ie3-institute/powersystemdatamodel/compare/0.2.0...0.3.0
3644
[0.2.0]: https://github.com/ie3-institute/powersystemdatamodel/compare/e3f0c247d9d2a92840f49412aa729c5f033cb4de...0.2.0

build.gradle

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
plugins {
22
id 'groovy' // groovy support
33
id 'java' // java support
4-
id 'com.diffplug.spotless' version '6.22.0'//code format
4+
id 'com.diffplug.spotless' version '6.25.0'//code format
55
id 'pmd' // code check, working on source code
6-
id 'com.github.spotbugs' version '5.2.3' // code check, working on byte code
7-
id "org.sonarqube" version "4.4.1.3373" // sonarqube
6+
id 'com.github.spotbugs' version '6.0.20' // code check, working on byte code
7+
id "org.sonarqube" version "5.1.0.4882" // sonarqube
88
id 'signing'
99
id 'maven-publish' // publish to a maven repo (local or mvn central, has to be defined)
1010
id 'jacoco' // java code coverage plugin
@@ -17,8 +17,8 @@ ext {
1717

1818
// required for pekko
1919
scalaVersion = "2.13"
20-
scalaBinaryVersion = "2.13.12"
21-
pekkoVersion = "1.0.1"
20+
scalaBinaryVersion = "2.13.14"
21+
pekkoVersion = "1.0.3"
2222
}
2323

2424
group = 'com.github.ie3-institute'
@@ -51,12 +51,28 @@ dependencies{
5151
// scala (needed for pekko)
5252
implementation "org.scala-lang:scala-library:${scalaBinaryVersion}"
5353

54+
//PSDM
55+
implementation('com.github.ie3-institute:PowerSystemUtils:2.2.1') {
56+
exclude group: 'org.apache.logging.log4j'
57+
exclude group: 'org.slf4j'
58+
/* Exclude our own nested dependencies */
59+
exclude group: 'com.github.ie3-institute'
60+
}
61+
implementation('com.github.ie3-institute:PowerSystemDataModel:5.1.0') {
62+
exclude group: 'org.apache.logging.log4j'
63+
exclude group: 'org.slf4j'
64+
/* Exclude our own nested dependencies */
65+
exclude group: 'com.github.ie3-institute'
66+
}
67+
5468
// pekko
5569
implementation "org.apache.pekko:pekko-actor_${scalaVersion}:${pekkoVersion}"
5670
testImplementation "org.apache.pekko:pekko-testkit_${scalaVersion}:${pekkoVersion}" // pekko testkit
5771

5872
// TESTING
5973
testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0'
74+
75+
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.17.2'
6076
}
6177

6278
task printVersion {

gradle/scripts/jacoco.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jacocoTestReport {
2828
]
2929

3030
getClassDirectories().setFrom(fileTree(
31-
dir: "${layout.buildDirectory}/classes/",
31+
dir: layout.buildDirectory.dir("classes"),
3232
excludes: excludes
3333
))
3434

gradle/scripts/spotbugs.gradle

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
// spotBugs is a code check tool, working on byte code
22

3+
// workaround because imports do not work in files that are only included by build.gradle
4+
def classLoader = plugins['com.github.spotbugs'].class.classLoader
5+
def SpotBugsEffort = classLoader.findLoadedClass( 'com.github.spotbugs.snom.Effort' )
6+
def SpotBugsConfidence = classLoader.findLoadedClass( 'com.github.spotbugs.snom.Confidence' )
7+
38
spotbugs{
49
ignoreFailures = true // dont let the build fail on rule violations
5-
effort = 'max'
6-
reportLevel = 'high'
10+
effort = SpotBugsEffort.valueOf("MAX")
11+
reportLevel = SpotBugsConfidence.valueOf("HIGH")
712
}
813

914
spotbugsMain{
1015
reports{
11-
html.enabled = false
12-
xml.enabled = true
16+
html.required.set(false)
17+
xml.required.set(true)
1318
}
1419
}
1520

1621
spotbugsTest{
1722
reports{
18-
html.enabled = false
19-
xml.enabled = true
23+
html.required.set(false)
24+
xml.required.set(true)
2025
}
2126
}

gradle/wrapper/gradle-wrapper.jar

346 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ done
8383
# This is normally unused
8484
# shellcheck disable=SC2034
8585
APP_BASE_NAME=${0##*/}
86-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
86+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87+
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
8788

8889
# Use the maximum available, or set MAX_FD != -1 to use that value.
8990
MAX_FD=maximum
@@ -144,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144145
case $MAX_FD in #(
145146
max*)
146147
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147-
# shellcheck disable=SC3045
148+
# shellcheck disable=SC2039,SC3045
148149
MAX_FD=$( ulimit -H -n ) ||
149150
warn "Could not query maximum file descriptor limit"
150151
esac
151152
case $MAX_FD in #(
152153
'' | soft) :;; #(
153154
*)
154155
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155-
# shellcheck disable=SC3045
156+
# shellcheck disable=SC2039,SC3045
156157
ulimit -n "$MAX_FD" ||
157158
warn "Could not set maximum file descriptor limit to $MAX_FD"
158159
esac
@@ -201,11 +202,11 @@ fi
201202
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
202203
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
203204

204-
# Collect all arguments for the java command;
205-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
206-
# shell script including quotes and variable substitutions, so put them in
207-
# double quotes to make sure that they get re-expanded; and
208-
# * put everything else in single quotes, so that it's not re-expanded.
205+
# Collect all arguments for the java command:
206+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207+
# and any embedded shellness will be escaped.
208+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209+
# treated as '${Hostname}' itself on the command line.
209210

210211
set -- \
211212
"-Dorg.gradle.appname=$APP_BASE_NAME" \

src/main/java/edu/ie3/simona/api/data/ev/ExtEvData.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ public List<EvModel> requestDepartingEvs(Map<UUID, List<UUID>> departures)
8282
* without expecting an answer from SIMONA.
8383
*
8484
* @param arrivals the arriving EV models per charging station UUID
85+
* @param maybeNextTick the next tick at which new arrivals are expected, or empty if simulation
86+
* is about to end
8587
*/
86-
public void provideArrivingEvs(Map<UUID, List<EvModel>> arrivals) {
87-
sendExtMsg(new ProvideArrivingEvs(arrivals));
88+
public void provideArrivingEvs(Map<UUID, List<EvModel>> arrivals, Optional<Long> maybeNextTick) {
89+
sendExtMsg(new ProvideArrivingEvs(arrivals, maybeNextTick));
8890
}
8991

9092
/**

src/main/java/edu/ie3/simona/api/data/ev/ontology/ProvideArrivingEvs.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@
99
import edu.ie3.simona.api.data.ev.model.EvModel;
1010
import java.util.List;
1111
import java.util.Map;
12+
import java.util.Optional;
1213
import java.util.UUID;
1314

1415
/**
1516
* Provide arriving EVs to SIMONA and its charging stations
1617
*
1718
* @param arrivals the arriving EVs per charging station UUID
19+
* @param maybeNextTick the next tick at which new arrivals are expected, or empty if simulation is
20+
* about to end
1821
*/
19-
public record ProvideArrivingEvs(Map<UUID, List<EvModel>> arrivals)
22+
public record ProvideArrivingEvs(Map<UUID, List<EvModel>> arrivals, Optional<Long> maybeNextTick)
2023
implements EvDataMessageFromExt {}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* © 2024. TU Dortmund University,
3+
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
4+
* Research group Distribution grid planning and operation
5+
*/
6+
7+
package edu.ie3.simona.api.data.primarydata;
8+
9+
import edu.ie3.datamodel.models.value.Value;
10+
import edu.ie3.simona.api.data.ExtData;
11+
import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage;
12+
import edu.ie3.simona.api.data.primarydata.ontology.PrimaryDataMessageFromExt;
13+
import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData;
14+
import edu.ie3.simona.api.exceptions.ConvertionException;
15+
import java.util.HashMap;
16+
import java.util.Map;
17+
import java.util.UUID;
18+
import org.apache.pekko.actor.ActorRef;
19+
20+
public class ExtPrimaryData implements ExtData {
21+
22+
/** Actor reference to service that handles ev data within SIMONA */
23+
private final ActorRef dataService;
24+
25+
/** Actor reference to adapter that handles scheduler control flow in SIMONA */
26+
private final ActorRef extSimAdapter;
27+
28+
/** Factory to convert an external object to PSDM primary data */
29+
private final PrimaryDataFactory factory;
30+
31+
public ExtPrimaryData(ActorRef dataService, ActorRef extSimAdapter, PrimaryDataFactory factory) {
32+
this.dataService = dataService;
33+
this.extSimAdapter = extSimAdapter;
34+
this.factory = factory;
35+
}
36+
37+
/** Provide primary data from an external simulation in one tick. */
38+
public void providePrimaryData(Long tick, Map<String, Object> primaryData) {
39+
Map<UUID, Value> convertedMap = new HashMap<>();
40+
primaryData.forEach(
41+
(k, v) -> {
42+
try {
43+
convertedMap.put(UUID.fromString(k), factory.convert(v));
44+
} catch (ConvertionException e) {
45+
throw new RuntimeException(e);
46+
}
47+
});
48+
sendExtMsg(new ProvidePrimaryData(tick, convertedMap));
49+
}
50+
51+
/**
52+
* Send information from the external simulation to SIMONA's external primary data service.
53+
* Furthermore, ExtSimAdapter within SIMONA is instructed to activate the ev data service with the
54+
* current tick.
55+
*
56+
* @param msg the data/information that is sent to SIMONA's external primary data service
57+
*/
58+
public void sendExtMsg(PrimaryDataMessageFromExt msg) {
59+
dataService.tell(msg, ActorRef.noSender());
60+
// we need to schedule data receiver activation with scheduler
61+
extSimAdapter.tell(new ScheduleDataServiceMessage(dataService), ActorRef.noSender());
62+
}
63+
}

0 commit comments

Comments
 (0)