From fa7263f6dde0de50ee46c5f1e0770599cc23ed95 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Sat, 16 Mar 2024 10:06:02 +0100 Subject: [PATCH 01/82] Temp --- build.gradle | 4 +-- .../api/data/primarydata/ExtPrimaryData.java | 8 ++++- .../primarydata/ExtPrimaryDataSimulation.java | 5 +++ .../ontology/ProvidePrimaryData.java | 5 +-- .../api/data/results/ExtResultData.java | 32 ++++++++++++------- .../data/results/ExtResultDataSimulation.java | 5 +++ .../ontology/ProvideExpectedAssets.java | 6 ++++ .../ontology/ProvideResultEntities.java | 15 +++++++-- .../ontology/RequestResultEntities.java | 2 +- .../ontology/ResultDataMessageFromExt.java | 4 ++- .../simona/api/simulation/ExtSimulation.java | 8 +++++ 11 files changed, 74 insertions(+), 20 deletions(-) create mode 100644 src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideExpectedAssets.java diff --git a/build.gradle b/build.gradle index 244b157..2c4ec09 100644 --- a/build.gradle +++ b/build.gradle @@ -52,13 +52,13 @@ dependencies{ implementation "org.scala-lang:scala-library:${scalaBinaryVersion}" //PSDM - implementation('com.github.ie3-institute:PowerSystemUtils:2.0') { + implementation('com.github.ie3-institute:PowerSystemUtils:2.2.1') { exclude group: 'org.apache.logging.log4j' exclude group: 'org.slf4j' /* Exclude our own nested dependencies */ exclude group: 'com.github.ie3-institute' } - implementation('com.github.ie3-institute:PowerSystemDataModel:4.1.0') { + implementation('com.github.ie3-institute:PowerSystemDataModel:5.0.1') { exclude group: 'org.apache.logging.log4j' exclude group: 'org.slf4j' /* Exclude our own nested dependencies */ diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java index 7188e29..2e14708 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java @@ -13,6 +13,7 @@ import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData; import edu.ie3.simona.api.exceptions.ConvertionException; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.UUID; import org.apache.pekko.actor.ActorRef; @@ -28,12 +29,17 @@ public class ExtPrimaryData implements ExtData { /** Factory to convert an external object to PSDM primary data */ private final PrimaryDataFactory factory; - public ExtPrimaryData(ActorRef dataService, ActorRef extSimAdapter, PrimaryDataFactory factory) { + private final List primaryDataAssets; + + public ExtPrimaryData(ActorRef dataService, ActorRef extSimAdapter, PrimaryDataFactory factory, List primaryDataAssets) { this.dataService = dataService; this.extSimAdapter = extSimAdapter; this.factory = factory; + this.primaryDataAssets = primaryDataAssets; } + public List getPrimaryDataAssets() { return primaryDataAssets; } + /** Provide primary data from an external simulation in one tick. */ public void providePrimaryData(Long tick, Map primaryData) { Map convertedMap = new HashMap<>(); diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java index d217209..e8f288a 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java @@ -8,6 +8,9 @@ import edu.ie3.simona.api.data.ExtDataSimulation; +import java.util.List; +import java.util.UUID; + /** * An external simulation that provides primary data should implement this interface and handle the * ExtPrimaryData that is handed over. @@ -19,4 +22,6 @@ public interface ExtPrimaryDataSimulation extends ExtDataSimulation { /** Should implement the convertion of the external format to the PSDM format of primary data. */ PrimaryDataFactory getPrimaryDataFactory(); + + List getPrimaryDataAssets(); } diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java index a87d9f7..05eb85b 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java @@ -11,5 +11,6 @@ import java.util.UUID; /** Message that provides primary data from an external primary data simulation */ -public record ProvidePrimaryData(long tick, Map primaryData) - implements PrimaryDataMessageFromExt {} +public record ProvidePrimaryData( + long tick, + Map primaryData) implements PrimaryDataMessageFromExt {} diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java index 99fd1c7..f704018 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java @@ -8,15 +8,15 @@ import edu.ie3.datamodel.models.result.ResultEntity; import edu.ie3.simona.api.data.ExtData; +import edu.ie3.simona.api.data.ev.model.EvModel; +import edu.ie3.simona.api.data.ev.ontology.ProvideArrivingEvs; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; -import edu.ie3.simona.api.data.results.ontology.ProvideResultEntities; -import edu.ie3.simona.api.data.results.ontology.RequestResultEntities; -import edu.ie3.simona.api.data.results.ontology.ResultDataMessageFromExt; -import edu.ie3.simona.api.data.results.ontology.ResultDataResponseMessageToExt; +import edu.ie3.simona.api.data.results.ontology.*; import edu.ie3.simona.api.exceptions.ConvertionException; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.UUID; import java.util.concurrent.LinkedBlockingQueue; import org.apache.pekko.actor.ActorRef; @@ -29,29 +29,39 @@ public class ExtResultData implements ExtData { /** Actor reference to service that handles ev data within SIMONA */ private final ActorRef dataService; + private final ActorRef dataServiceActivation; + /** Actor reference to adapter that handles scheduler control flow in SIMONA */ private final ActorRef extSimAdapter; private final ResultDataFactory factory; - public ExtResultData(ActorRef dataService, ActorRef extSimAdapter, ResultDataFactory factory) { + private final List resultDataAssets; + + public ExtResultData(ActorRef dataService, ActorRef dataServiceActivation, ActorRef extSimAdapter, ResultDataFactory factory, List resultDataAssets) { this.dataService = dataService; + this.dataServiceActivation = dataServiceActivation; this.extSimAdapter = extSimAdapter; this.factory = factory; + this.resultDataAssets = resultDataAssets; + } + + public List getResultDataAssets() { + return resultDataAssets; } /** Method that an external simulation can request results from SIMONA as a list. */ - public List requestResults() throws InterruptedException { - sendExtMsg(new RequestResultEntities()); + public List requestResults(long tick) throws InterruptedException { + sendExtMsg(new RequestResultEntities(tick)); return receiveWithType(ProvideResultEntities.class).results(); } /** * Method that an external simulation can request results from SIMONA as a map string to object. */ - public Map requestResultObjects() + public Map requestResultObjects(long tick) throws ConvertionException, InterruptedException { - return convertResultsList(requestResults()); + return convertResultsList(requestResults(tick)); } protected Map convertResultsList(List results) @@ -60,7 +70,7 @@ protected Map convertResultsList(List results) Object convertedResult; for (ResultEntity res : results) { convertedResult = factory.convert(res); - resultsMap.put(res.getUuid().toString(), convertedResult); + resultsMap.put(res.getInputModel().toString(), convertedResult); } return resultsMap; } @@ -75,7 +85,7 @@ protected Map convertResultsList(List results) public void sendExtMsg(ResultDataMessageFromExt msg) { dataService.tell(msg, ActorRef.noSender()); // we need to schedule data receiver activation with scheduler - extSimAdapter.tell(new ScheduleDataServiceMessage(dataService), ActorRef.noSender()); + extSimAdapter.tell(new ScheduleDataServiceMessage(dataServiceActivation), ActorRef.noSender()); } /** Queues message from SIMONA that should be handled by the external simulation. */ diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java index 31ea7ac..18e8ae6 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java @@ -8,6 +8,9 @@ import edu.ie3.simona.api.data.ExtDataSimulation; +import java.util.List; +import java.util.UUID; + /** * An external simulation that needs results from SIMONA should implement this interface and handle * the ExtResultsData that is handed over. @@ -19,4 +22,6 @@ public interface ExtResultDataSimulation extends ExtDataSimulation { /** Should implement the convertion of the PSDM format to the external format of result data. */ ResultDataFactory getResultDataFactory(); + + List getResultDataAssets(); } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideExpectedAssets.java b/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideExpectedAssets.java new file mode 100644 index 0000000..ac8bfb7 --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideExpectedAssets.java @@ -0,0 +1,6 @@ +package edu.ie3.simona.api.data.results.ontology; + +import java.util.List; +import java.util.UUID; + +public record ProvideExpectedAssets(List expectedAssets) implements ResultDataMessageFromExt {} diff --git a/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java b/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java index 26b4ae5..fa02cae 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java @@ -7,8 +7,19 @@ package edu.ie3.simona.api.data.results.ontology; import edu.ie3.datamodel.models.result.ResultEntity; + +import java.util.ArrayList; import java.util.List; /** Provides a list of results from SIMONA to an external simulation. */ -public record ProvideResultEntities(List results) - implements ResultDataResponseMessageToExt {} +public record ProvideResultEntities(List results) implements ResultDataResponseMessageToExt { + public ProvideResultEntities() { + this(new ArrayList<>()); + } + + public ProvideResultEntities(List results) { + this.results = results; + } + + +} diff --git a/src/main/java/edu/ie3/simona/api/data/results/ontology/RequestResultEntities.java b/src/main/java/edu/ie3/simona/api/data/results/ontology/RequestResultEntities.java index 05f8aae..67896cb 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ontology/RequestResultEntities.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ontology/RequestResultEntities.java @@ -7,4 +7,4 @@ package edu.ie3.simona.api.data.results.ontology; /** Request calculated results from SIMONA in the current tick */ -public record RequestResultEntities() implements ResultDataMessageFromExt {} +public record RequestResultEntities(Long tick) implements ResultDataMessageFromExt {} \ No newline at end of file diff --git a/src/main/java/edu/ie3/simona/api/data/results/ontology/ResultDataMessageFromExt.java b/src/main/java/edu/ie3/simona/api/data/results/ontology/ResultDataMessageFromExt.java index 60ebff4..83b2e31 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ontology/ResultDataMessageFromExt.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ontology/ResultDataMessageFromExt.java @@ -6,5 +6,7 @@ package edu.ie3.simona.api.data.results.ontology; +import edu.ie3.simona.api.data.ontology.DataMessageFromExt; + /** Messages that are sent from an external simulation to the SIMONA */ -public interface ResultDataMessageFromExt {} +public interface ResultDataMessageFromExt extends DataMessageFromExt {} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java index aa8d5b7..43b7247 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java @@ -9,6 +9,10 @@ import edu.ie3.simona.api.data.ExtData; import edu.ie3.simona.api.data.ev.ExtEvData; import edu.ie3.simona.api.data.ev.ExtEvSimulation; +import edu.ie3.simona.api.data.primarydata.ExtPrimaryData; +import edu.ie3.simona.api.data.primarydata.ExtPrimaryDataSimulation; +import edu.ie3.simona.api.data.results.ExtResultData; +import edu.ie3.simona.api.data.results.ExtResultDataSimulation; import edu.ie3.simona.api.simulation.ontology.*; import java.util.ArrayList; import java.util.List; @@ -114,6 +118,10 @@ public final void setup(ExtSimAdapterData data, List adapters) { // todo sanity check if all required data is available for (ExtData adapter : adapters) { + if (adapter instanceof ExtPrimaryData && this instanceof ExtPrimaryDataSimulation) + ((ExtPrimaryDataSimulation) this).setExtPrimaryData((ExtPrimaryData) adapter); + if (adapter instanceof ExtResultData && this instanceof ExtResultDataSimulation) + ((ExtResultDataSimulation) this).setExtResultData((ExtResultData) adapter); if (adapter instanceof ExtEvData && this instanceof ExtEvSimulation) ((ExtEvSimulation) this).setExtEvData((ExtEvData) adapter); } From f323f658a16e41162138515d13790bf3e27cf063 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Tue, 19 Mar 2024 17:39:59 +0100 Subject: [PATCH 02/82] data support --- .../api/data/primarydata/ExtPrimaryData.java | 1 + .../primarydata/ExtPrimaryDataSimulation.java | 33 ++++++++++++++--- .../data/results/ExtResultDataSimulation.java | 36 ++++++++++++++++--- .../ontology/ProvideExpectedAssets.java | 6 ---- .../ontology/ProvideResultEntities.java | 2 -- .../simona/api/simulation/ExtSimulation.java | 12 +++---- .../datasupport/ExtPrimaryDataSupport.java | 8 +++++ .../datasupport/ExtResultDataSupport.java | 7 ++++ 8 files changed, 82 insertions(+), 23 deletions(-) delete mode 100644 src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideExpectedAssets.java create mode 100644 src/main/java/edu/ie3/simona/api/simulation/datasupport/ExtPrimaryDataSupport.java create mode 100644 src/main/java/edu/ie3/simona/api/simulation/datasupport/ExtResultDataSupport.java diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java index 2e14708..33ae59a 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java @@ -29,6 +29,7 @@ public class ExtPrimaryData implements ExtData { /** Factory to convert an external object to PSDM primary data */ private final PrimaryDataFactory factory; + /** Assets that provide primary data to SIMONA */ private final List primaryDataAssets; public ExtPrimaryData(ActorRef dataService, ActorRef extSimAdapter, PrimaryDataFactory factory, List primaryDataAssets) { diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java index e8f288a..c4cabe4 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java @@ -15,13 +15,38 @@ * An external simulation that provides primary data should implement this interface and handle the * ExtPrimaryData that is handed over. */ -public interface ExtPrimaryDataSimulation extends ExtDataSimulation { +public class ExtPrimaryDataSimulation implements ExtDataSimulation { + + private final List primaryDataAssets; + + private final PrimaryDataFactory primaryDataFactory; + + private ExtPrimaryData extPrimaryData; + + public ExtPrimaryDataSimulation( + PrimaryDataFactory primaryDataFactory, + List primaryDataAssets + ) { + this.primaryDataFactory = primaryDataFactory; + this.primaryDataAssets = primaryDataAssets; + } /** Hand over an ExtPrimaryData which enables communication regarding primary data. */ - void setExtPrimaryData(ExtPrimaryData extPrimaryData); + public void setExtPrimaryData(ExtPrimaryData extPrimaryData) { + this.extPrimaryData = extPrimaryData; + } /** Should implement the convertion of the external format to the PSDM format of primary data. */ - PrimaryDataFactory getPrimaryDataFactory(); + public PrimaryDataFactory getPrimaryDataFactory() { + return primaryDataFactory; + } + + /** Should implement the list of assets that provide primary data to SIMOAN */ + public List getPrimaryDataAssets() { + return primaryDataAssets; + } - List getPrimaryDataAssets(); + public ExtPrimaryData getExtPrimaryData() { + return extPrimaryData; + } } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java index 18e8ae6..5a11209 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java @@ -7,6 +7,8 @@ package edu.ie3.simona.api.data.results; import edu.ie3.simona.api.data.ExtDataSimulation; +import edu.ie3.simona.api.data.primarydata.ExtPrimaryData; +import edu.ie3.simona.api.data.primarydata.PrimaryDataFactory; import java.util.List; import java.util.UUID; @@ -15,13 +17,37 @@ * An external simulation that needs results from SIMONA should implement this interface and handle * the ExtResultsData that is handed over. */ -public interface ExtResultDataSimulation extends ExtDataSimulation { +public class ExtResultDataSimulation implements ExtDataSimulation { + private final List resultDataAssets; + + private final ResultDataFactory resultDataFactory; + + private ExtResultData extResultData; + + public ExtResultDataSimulation( + ResultDataFactory resultDataFactory, + List resultDataAssets + ) { + this.resultDataFactory = resultDataFactory; + this.resultDataAssets = resultDataAssets; + } /** Hand over an ExtPrimaryData which enables communication regarding primary data. */ - void setExtResultData(ExtResultData extResultData); + public void setExtResultData(ExtResultData extResultData) { + this.extResultData = extResultData; + } + + /** Should implement the convertion of the external format to the PSDM format of primary data. */ + public ResultDataFactory getResultDataFactory() { + return resultDataFactory; + } - /** Should implement the convertion of the PSDM format to the external format of result data. */ - ResultDataFactory getResultDataFactory(); + /** Should implement the list of assets that provide primary data to SIMOAN */ + public List getResultDataAssets() { + return resultDataAssets; + } - List getResultDataAssets(); + public ExtResultData getExtResultData() { + return extResultData; + } } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideExpectedAssets.java b/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideExpectedAssets.java deleted file mode 100644 index ac8bfb7..0000000 --- a/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideExpectedAssets.java +++ /dev/null @@ -1,6 +0,0 @@ -package edu.ie3.simona.api.data.results.ontology; - -import java.util.List; -import java.util.UUID; - -public record ProvideExpectedAssets(List expectedAssets) implements ResultDataMessageFromExt {} diff --git a/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java b/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java index fa02cae..6efe5c6 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java @@ -20,6 +20,4 @@ public ProvideResultEntities() { public ProvideResultEntities(List results) { this.results = results; } - - } diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java index 43b7247..f9f66a7 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java @@ -6,13 +6,13 @@ package edu.ie3.simona.api.simulation; +import edu.ie3.simona.api.simulation.datasupport.ExtPrimaryDataSupport; +import edu.ie3.simona.api.simulation.datasupport.ExtResultDataSupport; import edu.ie3.simona.api.data.ExtData; import edu.ie3.simona.api.data.ev.ExtEvData; import edu.ie3.simona.api.data.ev.ExtEvSimulation; import edu.ie3.simona.api.data.primarydata.ExtPrimaryData; -import edu.ie3.simona.api.data.primarydata.ExtPrimaryDataSimulation; import edu.ie3.simona.api.data.results.ExtResultData; -import edu.ie3.simona.api.data.results.ExtResultDataSimulation; import edu.ie3.simona.api.simulation.ontology.*; import java.util.ArrayList; import java.util.List; @@ -118,10 +118,10 @@ public final void setup(ExtSimAdapterData data, List adapters) { // todo sanity check if all required data is available for (ExtData adapter : adapters) { - if (adapter instanceof ExtPrimaryData && this instanceof ExtPrimaryDataSimulation) - ((ExtPrimaryDataSimulation) this).setExtPrimaryData((ExtPrimaryData) adapter); - if (adapter instanceof ExtResultData && this instanceof ExtResultDataSimulation) - ((ExtResultDataSimulation) this).setExtResultData((ExtResultData) adapter); + if (adapter instanceof ExtPrimaryData && this instanceof ExtPrimaryDataSupport) + ((ExtPrimaryDataSupport) this).setExtPrimaryData((ExtPrimaryData) adapter); + if (adapter instanceof ExtResultData && this instanceof ExtResultDataSupport) + ((ExtResultDataSupport) this).setExtResultData((ExtResultData) adapter); if (adapter instanceof ExtEvData && this instanceof ExtEvSimulation) ((ExtEvSimulation) this).setExtEvData((ExtEvData) adapter); } diff --git a/src/main/java/edu/ie3/simona/api/simulation/datasupport/ExtPrimaryDataSupport.java b/src/main/java/edu/ie3/simona/api/simulation/datasupport/ExtPrimaryDataSupport.java new file mode 100644 index 0000000..29ee86c --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/simulation/datasupport/ExtPrimaryDataSupport.java @@ -0,0 +1,8 @@ +package edu.ie3.simona.api.simulation.datasupport; + +import edu.ie3.simona.api.data.primarydata.ExtPrimaryData; + +public interface ExtPrimaryDataSupport { + void setExtPrimaryData(ExtPrimaryData extPrimaryData); + +} diff --git a/src/main/java/edu/ie3/simona/api/simulation/datasupport/ExtResultDataSupport.java b/src/main/java/edu/ie3/simona/api/simulation/datasupport/ExtResultDataSupport.java new file mode 100644 index 0000000..5637ec0 --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/simulation/datasupport/ExtResultDataSupport.java @@ -0,0 +1,7 @@ +package edu.ie3.simona.api.simulation.datasupport; + +import edu.ie3.simona.api.data.results.ExtResultData; + +public interface ExtResultDataSupport { + void setExtResultData(ExtResultData extResultData); +} From 88f71079ada1ac3a62d299c0fc7c0a5bfcb8b27e Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Tue, 19 Mar 2024 23:16:02 +0100 Subject: [PATCH 03/82] fine tuning --- .../simona/api/data/results/ExtResultDataSimulation.java | 2 -- .../edu/ie3/simona/api/simulation/ExtSimulation.java | 9 +-------- .../simulation/datasupport/ExtPrimaryDataSupport.java | 8 -------- .../api/simulation/datasupport/ExtResultDataSupport.java | 7 ------- 4 files changed, 1 insertion(+), 25 deletions(-) delete mode 100644 src/main/java/edu/ie3/simona/api/simulation/datasupport/ExtPrimaryDataSupport.java delete mode 100644 src/main/java/edu/ie3/simona/api/simulation/datasupport/ExtResultDataSupport.java diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java index 5a11209..3e20da3 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java @@ -37,12 +37,10 @@ public void setExtResultData(ExtResultData extResultData) { this.extResultData = extResultData; } - /** Should implement the convertion of the external format to the PSDM format of primary data. */ public ResultDataFactory getResultDataFactory() { return resultDataFactory; } - /** Should implement the list of assets that provide primary data to SIMOAN */ public List getResultDataAssets() { return resultDataAssets; } diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java index f9f66a7..d521654 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java @@ -6,13 +6,10 @@ package edu.ie3.simona.api.simulation; -import edu.ie3.simona.api.simulation.datasupport.ExtPrimaryDataSupport; -import edu.ie3.simona.api.simulation.datasupport.ExtResultDataSupport; +import edu.ie3.simona.api.data.ExtDataSimulation; import edu.ie3.simona.api.data.ExtData; import edu.ie3.simona.api.data.ev.ExtEvData; import edu.ie3.simona.api.data.ev.ExtEvSimulation; -import edu.ie3.simona.api.data.primarydata.ExtPrimaryData; -import edu.ie3.simona.api.data.results.ExtResultData; import edu.ie3.simona.api.simulation.ontology.*; import java.util.ArrayList; import java.util.List; @@ -118,10 +115,6 @@ public final void setup(ExtSimAdapterData data, List adapters) { // todo sanity check if all required data is available for (ExtData adapter : adapters) { - if (adapter instanceof ExtPrimaryData && this instanceof ExtPrimaryDataSupport) - ((ExtPrimaryDataSupport) this).setExtPrimaryData((ExtPrimaryData) adapter); - if (adapter instanceof ExtResultData && this instanceof ExtResultDataSupport) - ((ExtResultDataSupport) this).setExtResultData((ExtResultData) adapter); if (adapter instanceof ExtEvData && this instanceof ExtEvSimulation) ((ExtEvSimulation) this).setExtEvData((ExtEvData) adapter); } diff --git a/src/main/java/edu/ie3/simona/api/simulation/datasupport/ExtPrimaryDataSupport.java b/src/main/java/edu/ie3/simona/api/simulation/datasupport/ExtPrimaryDataSupport.java deleted file mode 100644 index 29ee86c..0000000 --- a/src/main/java/edu/ie3/simona/api/simulation/datasupport/ExtPrimaryDataSupport.java +++ /dev/null @@ -1,8 +0,0 @@ -package edu.ie3.simona.api.simulation.datasupport; - -import edu.ie3.simona.api.data.primarydata.ExtPrimaryData; - -public interface ExtPrimaryDataSupport { - void setExtPrimaryData(ExtPrimaryData extPrimaryData); - -} diff --git a/src/main/java/edu/ie3/simona/api/simulation/datasupport/ExtResultDataSupport.java b/src/main/java/edu/ie3/simona/api/simulation/datasupport/ExtResultDataSupport.java deleted file mode 100644 index 5637ec0..0000000 --- a/src/main/java/edu/ie3/simona/api/simulation/datasupport/ExtResultDataSupport.java +++ /dev/null @@ -1,7 +0,0 @@ -package edu.ie3.simona.api.simulation.datasupport; - -import edu.ie3.simona.api.data.results.ExtResultData; - -public interface ExtResultDataSupport { - void setExtResultData(ExtResultData extResultData); -} From f3ac57d0d3a2b259e82d6d2053aa692d750bd399 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Wed, 27 Mar 2024 14:56:11 +0100 Subject: [PATCH 04/82] phase in extsim --- .../primarydata/ExtPrimaryDataSimulation.java | 2 -- .../api/data/results/ExtResultData.java | 15 ++++++++---- .../data/results/ExtResultDataSimulation.java | 3 +-- .../api/simulation/ExtSimAdapterData.java | 13 +++++++---- .../simona/api/simulation/ExtSimulation.java | 23 ++++++++++++++----- .../ontology/ActivationMessage.java | 11 ++++++++- .../ontology/CompletionMessage.java | 12 ++++++++-- .../ontology/ControlMessageToExt.java | 5 +++- .../ControlResponseMessageFromExt.java | 4 +++- .../ontology/TerminationCompleted.java | 7 +++++- .../ontology/TerminationMessage.java | 7 +++++- 11 files changed, 75 insertions(+), 27 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java index c4cabe4..d65ee33 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java @@ -36,12 +36,10 @@ public void setExtPrimaryData(ExtPrimaryData extPrimaryData) { this.extPrimaryData = extPrimaryData; } - /** Should implement the convertion of the external format to the PSDM format of primary data. */ public PrimaryDataFactory getPrimaryDataFactory() { return primaryDataFactory; } - /** Should implement the list of assets that provide primary data to SIMOAN */ public List getPrimaryDataAssets() { return primaryDataAssets; } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java index f704018..38c7f73 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java @@ -8,17 +8,19 @@ import edu.ie3.datamodel.models.result.ResultEntity; import edu.ie3.simona.api.data.ExtData; -import edu.ie3.simona.api.data.ev.model.EvModel; -import edu.ie3.simona.api.data.ev.ontology.ProvideArrivingEvs; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; -import edu.ie3.simona.api.data.results.ontology.*; +import edu.ie3.simona.api.data.results.ontology.ProvideResultEntities; +import edu.ie3.simona.api.data.results.ontology.RequestResultEntities; +import edu.ie3.simona.api.data.results.ontology.ResultDataMessageFromExt; +import edu.ie3.simona.api.data.results.ontology.ResultDataResponseMessageToExt; import edu.ie3.simona.api.exceptions.ConvertionException; +import org.apache.pekko.actor.ActorRef; + import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; import java.util.concurrent.LinkedBlockingQueue; -import org.apache.pekko.actor.ActorRef; public class ExtResultData implements ExtData { @@ -26,16 +28,19 @@ public class ExtResultData implements ExtData { public final LinkedBlockingQueue receiveTriggerQueue = new LinkedBlockingQueue<>(); - /** Actor reference to service that handles ev data within SIMONA */ + /** Actor reference to service that handles result data within SIMONA */ private final ActorRef dataService; + /** Actor reference to the dataServiceAdapter */ private final ActorRef dataServiceActivation; /** Actor reference to adapter that handles scheduler control flow in SIMONA */ private final ActorRef extSimAdapter; + /** Factory to convert a result entity to an object, that is readable from the external simulation */ private final ResultDataFactory factory; + /** Assets in SIMONA that send result data */ private final List resultDataAssets; public ExtResultData(ActorRef dataService, ActorRef dataServiceActivation, ActorRef extSimAdapter, ResultDataFactory factory, List resultDataAssets) { diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java index 3e20da3..29ae016 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java @@ -7,8 +7,6 @@ package edu.ie3.simona.api.data.results; import edu.ie3.simona.api.data.ExtDataSimulation; -import edu.ie3.simona.api.data.primarydata.ExtPrimaryData; -import edu.ie3.simona.api.data.primarydata.PrimaryDataFactory; import java.util.List; import java.util.UUID; @@ -18,6 +16,7 @@ * the ExtResultsData that is handed over. */ public class ExtResultDataSimulation implements ExtDataSimulation { + private final List resultDataAssets; private final ResultDataFactory resultDataFactory; diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java b/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java index 20004bc..53f60d4 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java @@ -8,7 +8,10 @@ import edu.ie3.simona.api.simulation.ontology.ControlMessageToExt; import edu.ie3.simona.api.simulation.ontology.ControlResponseMessageFromExt; + +import java.util.Map; import java.util.concurrent.LinkedBlockingQueue; + import org.apache.pekko.actor.ActorRef; public class ExtSimAdapterData { @@ -17,16 +20,16 @@ public class ExtSimAdapterData { public final LinkedBlockingQueue receiveMessageQueue = new LinkedBlockingQueue<>(); - /** Actor reference to adapter that handles scheduler control flow in SIMONA */ - private final ActorRef extSimAdapter; + /** Actor references to the adapters for the phases that handles scheduler control flow in SIMONA */ + private final Map extSimAdapters; /** CLI arguments with which SIMONA is initiated */ private final String[] mainArgs; // important trigger queue must be the same as held in actor // to make it safer one might consider asking the actor for a reference on its trigger queue?! - public ExtSimAdapterData(ActorRef extSimAdapter, String[] mainArgs) { - this.extSimAdapter = extSimAdapter; + public ExtSimAdapterData(Map extSimAdapters, String[] mainArgs) { + this.extSimAdapters = extSimAdapters; this.mainArgs = mainArgs; } @@ -48,7 +51,7 @@ public void queueExtMsg(ControlMessageToExt msg) throws InterruptedException { * @param msg the message to send */ public void send(ControlResponseMessageFromExt msg) { - extSimAdapter.tell(msg, ActorRef.noSender()); + extSimAdapters.get(msg.getPhase()).tell(msg, ActorRef.noSender()); } public String[] getMainArgs() { diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java index d521654..9034390 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java @@ -49,6 +49,7 @@ public void run() { private boolean takeAndHandleMessage() throws InterruptedException { // take() will block until an object is ready for us final ControlMessageToExt msg = data.receiveMessageQueue.take(); + int currentPhase = msg.getPhase(); if (msg.getClass().equals(ActivationMessage.class)) { final ActivationMessage activationMessage = (ActivationMessage) msg; @@ -58,17 +59,15 @@ private boolean takeAndHandleMessage() throws InterruptedException { newTrigger = initialize(); // this is blocking until initialization has finished } else { newTrigger = - doActivity( - activationMessage - .tick()); // this is blocking until processing of this tick has finished + doActivity(activationMessage.tick(), currentPhase); // this is blocking until processing of this tick has finished } - data.send(new CompletionMessage(newTrigger)); + data.send(new CompletionMessage(newTrigger, currentPhase)); return newTrigger.isEmpty(); } else if (msg.getClass().equals(TerminationMessage.class)) { final TerminationMessage terminationMsg = (TerminationMessage) msg; terminate(terminationMsg.simulationSuccessful()); - data.send(new TerminationCompleted()); + data.send(new TerminationCompleted(currentPhase)); return true; } else { @@ -90,7 +89,19 @@ private boolean takeAndHandleMessage() throws InterruptedException { * @param tick The current tick * @return The next tick at which this external simulation wants to be triggered, if applicable. */ - protected abstract Optional doActivity(long tick); + protected Optional doActivity(long tick, int phase) { + if (phase == 1) { + return doPreActivity(tick); + } else if (phase == 2) { + return doPostActivity(tick); + } else { + return Optional.empty(); + } + } + + protected abstract Optional doPreActivity(long tick); + + protected abstract Optional doPostActivity(long tick); /** * This method is called when the main simulation wants to terminate. diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/ActivationMessage.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/ActivationMessage.java index f6b7f13..31f889d 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/ActivationMessage.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/ActivationMessage.java @@ -10,5 +10,14 @@ * Message that the external simulation is activated with by SIMONA * * @param tick The current tick + * @param phase Phase of the simulation */ -public record ActivationMessage(long tick) implements ControlMessageToExt {} +public record ActivationMessage( + long tick, + int phase +) implements ControlMessageToExt { + @Override + public int getPhase() { + return phase; + } +} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/CompletionMessage.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/CompletionMessage.java index 35364c9..f8d0220 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/CompletionMessage.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/CompletionMessage.java @@ -12,6 +12,14 @@ * Message that is returned to SIMONA * * @param nextActivation The tick that the external simulation would like to be activated at again + * @param phase The phase of the simulation */ -public record CompletionMessage(Optional nextActivation) - implements ControlResponseMessageFromExt {} +public record CompletionMessage( + Optional nextActivation, + int phase +) implements ControlResponseMessageFromExt { + @Override + public int getPhase() { + return phase; + } +} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlMessageToExt.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlMessageToExt.java index 42826eb..a0aba5c 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlMessageToExt.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlMessageToExt.java @@ -6,4 +6,7 @@ package edu.ie3.simona.api.simulation.ontology; -public interface ControlMessageToExt {} +/** Interface for control messages from the SIMONA to the external simulation */ +public interface ControlMessageToExt { + int getPhase(); +} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlResponseMessageFromExt.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlResponseMessageFromExt.java index f3df097..cc35018 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlResponseMessageFromExt.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlResponseMessageFromExt.java @@ -7,4 +7,6 @@ package edu.ie3.simona.api.simulation.ontology; /** Interface for control messages from the external simulation to SIMONA */ -public interface ControlResponseMessageFromExt {} +public interface ControlResponseMessageFromExt { + int getPhase(); +} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationCompleted.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationCompleted.java index c46ca04..78dd5b8 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationCompleted.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationCompleted.java @@ -7,4 +7,9 @@ package edu.ie3.simona.api.simulation.ontology; /** Message returned to SIMONA indicating that the external simulation terminated */ -public record TerminationCompleted() implements ControlResponseMessageFromExt {} +public record TerminationCompleted(int phase) implements ControlResponseMessageFromExt { + @Override + public int getPhase() { + return phase; + } +} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationMessage.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationMessage.java index c281d04..efad176 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationMessage.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationMessage.java @@ -12,4 +12,9 @@ * * @param simulationSuccessful Whether SIMONA terminated successfully */ -public record TerminationMessage(Boolean simulationSuccessful) implements ControlMessageToExt {} +public record TerminationMessage(Boolean simulationSuccessful, int phase) implements ControlMessageToExt { + @Override + public int getPhase() { + return phase; + } +} From 0814e920340749705b24db3e6e1e76082209eea7 Mon Sep 17 00:00:00 2001 From: smjobaoo Date: Tue, 9 Apr 2024 10:08:29 +0200 Subject: [PATCH 05/82] opsim coupling --- .../ie3/simona/api/data/results/ExtResultData.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java index 38c7f73..48ffaf3 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java @@ -16,6 +16,7 @@ import edu.ie3.simona.api.exceptions.ConvertionException; import org.apache.pekko.actor.ActorRef; +import java.time.ZonedDateTime; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -43,12 +44,23 @@ public class ExtResultData implements ExtData { /** Assets in SIMONA that send result data */ private final List resultDataAssets; - public ExtResultData(ActorRef dataService, ActorRef dataServiceActivation, ActorRef extSimAdapter, ResultDataFactory factory, List resultDataAssets) { + private final ZonedDateTime simulationStartTime; + + public ExtResultData(ActorRef dataService, ActorRef dataServiceActivation, ActorRef extSimAdapter, ResultDataFactory factory, List resultDataAssets, ZonedDateTime simulationStartTime) { this.dataService = dataService; this.dataServiceActivation = dataServiceActivation; this.extSimAdapter = extSimAdapter; this.factory = factory; this.resultDataAssets = resultDataAssets; + this.simulationStartTime = simulationStartTime; + } + + public ZonedDateTime getSimulationStartTime() { + return simulationStartTime; + } + + public ZonedDateTime getSimulationTime(Long tick) { + return simulationStartTime.plusSeconds(tick); } public List getResultDataAssets() { From 66574337dd498261c44aad76c84f1850d80b4869 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 16 May 2024 22:29:56 +0200 Subject: [PATCH 06/82] temp --- .../ie3/simona/api/data/em/EmDataFactory.java | 17 +++++ .../edu/ie3/simona/api/data/em/ExtEmData.java | 72 +++++++++++++++++++ .../api/data/em/ExtEmDataSimulation.java | 52 ++++++++++++++ .../em/ontology/EmDataMessageFromExt.java | 12 ++++ .../api/data/em/ontology/ProvideEmData.java | 19 +++++ 5 files changed, 172 insertions(+) create mode 100644 src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java create mode 100644 src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java create mode 100644 src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java create mode 100644 src/main/java/edu/ie3/simona/api/data/em/ontology/EmDataMessageFromExt.java create mode 100644 src/main/java/edu/ie3/simona/api/data/em/ontology/ProvideEmData.java diff --git a/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java b/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java new file mode 100644 index 0000000..d617405 --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java @@ -0,0 +1,17 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + +package edu.ie3.simona.api.data.em; + +import edu.ie3.datamodel.models.value.Value; +import edu.ie3.simona.api.exceptions.ConvertionException; + +/** Interface that should be implemented by an external simulation. */ +public interface EmDataFactory { + + /** Should convert an object to a primary data value with a check if the object is primary data */ + Value convert(Object entity) throws ConvertionException; +} diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java new file mode 100644 index 0000000..cf5e1de --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java @@ -0,0 +1,72 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + +package edu.ie3.simona.api.data.em; + +import edu.ie3.datamodel.models.value.Value; +import edu.ie3.simona.api.data.ExtData; +import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; +import edu.ie3.simona.api.data.primarydata.PrimaryDataFactory; +import edu.ie3.simona.api.data.primarydata.ontology.PrimaryDataMessageFromExt; +import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData; +import edu.ie3.simona.api.exceptions.ConvertionException; +import org.apache.pekko.actor.ActorRef; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +public class ExtEmData implements ExtData { + + /** Actor reference to service that handles ev data within SIMONA */ + private final ActorRef dataService; + + /** Actor reference to adapter that handles scheduler control flow in SIMONA */ + private final ActorRef extSimAdapter; + + /** Factory to convert an external object to PSDM primary data */ + private final EmDataFactory factory; + + /** Assets that provide primary data to SIMONA */ + private final List controlledEms; + + public ExtEmData(ActorRef dataService, ActorRef extSimAdapter, EmDataFactory factory, List controlledEms) { + this.dataService = dataService; + this.extSimAdapter = extSimAdapter; + this.factory = factory; + this.controlledEms = controlledEms; + } + + public List getPrimaryDataAssets() { return controlledEms; } + + /** Provide primary data from an external simulation in one tick. */ + public void provideEmData(Long tick, Map emData) { + Map convertedMap = new HashMap<>(); + emData.forEach( + (k, v) -> { + try { + convertedMap.put(UUID.fromString(k), factory.convert(v)); + } catch (ConvertionException e) { + throw new RuntimeException(e); + } + }); + sendExtMsg(new ProvidePrimaryData(tick, convertedMap)); + } + + /** + * Send information from the external simulation to SIMONA's external primary data service. + * Furthermore, ExtSimAdapter within SIMONA is instructed to activate the ev data service with the + * current tick. + * + * @param msg the data/information that is sent to SIMONA's external primary data service + */ + public void sendExtMsg(PrimaryDataMessageFromExt msg) { + dataService.tell(msg, ActorRef.noSender()); + // we need to schedule data receiver activation with scheduler + extSimAdapter.tell(new ScheduleDataServiceMessage(dataService), ActorRef.noSender()); + } +} diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java new file mode 100644 index 0000000..e813253 --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java @@ -0,0 +1,52 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + +package edu.ie3.simona.api.data.em; + +import edu.ie3.simona.api.data.ExtDataSimulation; +import edu.ie3.simona.api.data.primarydata.ExtPrimaryData; +import edu.ie3.simona.api.data.primarydata.PrimaryDataFactory; + +import java.util.List; +import java.util.UUID; + +/** + * An external simulation that provides primary data should implement this interface and handle the + * ExtPrimaryData that is handed over. + */ +public class ExtEmDataSimulation implements ExtDataSimulation { + + private final List controlledEms; + + private final EmDataFactory emDataFactory; + + private ExtEmData extEmData; + + public ExtEmDataSimulation( + EmDataFactory emDataFactory, + List controlledEms + ) { + this.emDataFactory = emDataFactory; + this.controlledEms = controlledEms; + } + + /** Hand over an ExtPrimaryData which enables communication regarding primary data. */ + public void setExtEmData(ExtEmData extEmData) { + this.extEmData = extEmData; + } + + public EmDataFactory getEmDataFactory() { + return emDataFactory; + } + + public List getControlledEms() { + return controlledEms; + } + + public ExtEmData getExtEmData() { + return extEmData; + } +} diff --git a/src/main/java/edu/ie3/simona/api/data/em/ontology/EmDataMessageFromExt.java b/src/main/java/edu/ie3/simona/api/data/em/ontology/EmDataMessageFromExt.java new file mode 100644 index 0000000..5125e29 --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/data/em/ontology/EmDataMessageFromExt.java @@ -0,0 +1,12 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + +package edu.ie3.simona.api.data.em.ontology; + +import edu.ie3.simona.api.data.ontology.DataMessageFromExt; + +/** Messages that are sent from an external data simulation which provides em data to SIMONA */ +public interface EmDataMessageFromExt extends DataMessageFromExt {} diff --git a/src/main/java/edu/ie3/simona/api/data/em/ontology/ProvideEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ontology/ProvideEmData.java new file mode 100644 index 0000000..d39c9da --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/data/em/ontology/ProvideEmData.java @@ -0,0 +1,19 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + +package edu.ie3.simona.api.data.em.ontology; + +import edu.ie3.datamodel.models.value.PValue; +import edu.ie3.datamodel.models.value.Value; +import edu.ie3.simona.api.data.primarydata.ontology.PrimaryDataMessageFromExt; + +import java.util.Map; +import java.util.UUID; + +/** Message that provides primary data from an external primary data simulation */ +public record ProvideEmData( + long tick, + Map emData) implements EmDataMessageFromExt {} From a7f1ca2461f093b7821709ac44fca56655772966 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Mon, 20 May 2024 22:20:57 +0200 Subject: [PATCH 07/82] simple em ext simulation --- .../edu/ie3/simona/api/data/em/EmDataFactory.java | 3 ++- .../java/edu/ie3/simona/api/data/em/ExtEmData.java | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java b/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java index d617405..d66b84a 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java +++ b/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java @@ -6,6 +6,7 @@ package edu.ie3.simona.api.data.em; +import edu.ie3.datamodel.models.value.PValue; import edu.ie3.datamodel.models.value.Value; import edu.ie3.simona.api.exceptions.ConvertionException; @@ -13,5 +14,5 @@ public interface EmDataFactory { /** Should convert an object to a primary data value with a check if the object is primary data */ - Value convert(Object entity) throws ConvertionException; + PValue convert(Object entity) throws ConvertionException; } diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java index cf5e1de..125b893 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java @@ -6,8 +6,11 @@ package edu.ie3.simona.api.data.em; +import edu.ie3.datamodel.models.value.PValue; import edu.ie3.datamodel.models.value.Value; import edu.ie3.simona.api.data.ExtData; +import edu.ie3.simona.api.data.em.ontology.EmDataMessageFromExt; +import edu.ie3.simona.api.data.em.ontology.ProvideEmData; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import edu.ie3.simona.api.data.primarydata.PrimaryDataFactory; import edu.ie3.simona.api.data.primarydata.ontology.PrimaryDataMessageFromExt; @@ -41,11 +44,11 @@ public ExtEmData(ActorRef dataService, ActorRef extSimAdapter, EmDataFactory fac this.controlledEms = controlledEms; } - public List getPrimaryDataAssets() { return controlledEms; } + public List getControlledEms() { return controlledEms; } /** Provide primary data from an external simulation in one tick. */ public void provideEmData(Long tick, Map emData) { - Map convertedMap = new HashMap<>(); + Map convertedMap = new HashMap<>(); emData.forEach( (k, v) -> { try { @@ -54,7 +57,7 @@ public void provideEmData(Long tick, Map emData) { throw new RuntimeException(e); } }); - sendExtMsg(new ProvidePrimaryData(tick, convertedMap)); + sendExtMsg(new ProvideEmData(tick, convertedMap)); } /** @@ -64,7 +67,8 @@ public void provideEmData(Long tick, Map emData) { * * @param msg the data/information that is sent to SIMONA's external primary data service */ - public void sendExtMsg(PrimaryDataMessageFromExt msg) { + public void sendExtMsg(EmDataMessageFromExt msg) { + System.out.println("ExtEmData : " +dataService); dataService.tell(msg, ActorRef.noSender()); // we need to schedule data receiver activation with scheduler extSimAdapter.tell(new ScheduleDataServiceMessage(dataService), ActorRef.noSender()); From a86c5ff1556f7ff95c988ebd55b184b656bca46e Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Tue, 21 May 2024 16:26:45 +0200 Subject: [PATCH 08/82] temp --- src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java index 125b893..1760996 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java @@ -68,7 +68,6 @@ public void provideEmData(Long tick, Map emData) { * @param msg the data/information that is sent to SIMONA's external primary data service */ public void sendExtMsg(EmDataMessageFromExt msg) { - System.out.println("ExtEmData : " +dataService); dataService.tell(msg, ActorRef.noSender()); // we need to schedule data receiver activation with scheduler extSimAdapter.tell(new ScheduleDataServiceMessage(dataService), ActorRef.noSender()); From 1bb71add7f91ad6dda35ca3fc5f3e31dad2d656a Mon Sep 17 00:00:00 2001 From: smjobaoo Date: Fri, 24 May 2024 08:54:42 +0200 Subject: [PATCH 09/82] ext address as argument --- .../api/data/results/ExtResultData.java | 23 +++++++++++++++---- .../data/results/ExtResultDataSimulation.java | 16 +++++++++---- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java index 48ffaf3..a34655d 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java @@ -42,29 +42,42 @@ public class ExtResultData implements ExtData { private final ResultDataFactory factory; /** Assets in SIMONA that send result data */ - private final List resultDataAssets; + private final List gridResultDataAssets; + + private final List particpantResultDataAssets; private final ZonedDateTime simulationStartTime; - public ExtResultData(ActorRef dataService, ActorRef dataServiceActivation, ActorRef extSimAdapter, ResultDataFactory factory, List resultDataAssets, ZonedDateTime simulationStartTime) { + private final Long powerFlowResolution; + + public ExtResultData(ActorRef dataService, ActorRef dataServiceActivation, ActorRef extSimAdapter, ResultDataFactory factory, List gridResultDataAssets, List particpantResultDataAssets, ZonedDateTime simulationStartTime, Long powerFlowResolution) { this.dataService = dataService; this.dataServiceActivation = dataServiceActivation; this.extSimAdapter = extSimAdapter; this.factory = factory; - this.resultDataAssets = resultDataAssets; + this.gridResultDataAssets = gridResultDataAssets; + this.particpantResultDataAssets = particpantResultDataAssets; this.simulationStartTime = simulationStartTime; + this.powerFlowResolution = powerFlowResolution; } public ZonedDateTime getSimulationStartTime() { return simulationStartTime; } + public Long getPowerFlowResolution() { + return powerFlowResolution; + } public ZonedDateTime getSimulationTime(Long tick) { return simulationStartTime.plusSeconds(tick); } - public List getResultDataAssets() { - return resultDataAssets; + public List getGridResultDataAssets() { + return gridResultDataAssets; + } + + public List getParticpantResultDataAssets() { + return particpantResultDataAssets; } /** Method that an external simulation can request results from SIMONA as a list. */ diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java index 29ae016..fe7ec7d 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java @@ -17,7 +17,8 @@ */ public class ExtResultDataSimulation implements ExtDataSimulation { - private final List resultDataAssets; + private final List particpantResultDataAssets; + private final List gridResultDataAssets; private final ResultDataFactory resultDataFactory; @@ -25,10 +26,12 @@ public class ExtResultDataSimulation implements ExtDataSimulation { public ExtResultDataSimulation( ResultDataFactory resultDataFactory, - List resultDataAssets + List particpantResultDataAssets, + List gridResultDataAssets ) { this.resultDataFactory = resultDataFactory; - this.resultDataAssets = resultDataAssets; + this.particpantResultDataAssets = particpantResultDataAssets; + this.gridResultDataAssets = gridResultDataAssets; } /** Hand over an ExtPrimaryData which enables communication regarding primary data. */ @@ -40,8 +43,11 @@ public ResultDataFactory getResultDataFactory() { return resultDataFactory; } - public List getResultDataAssets() { - return resultDataAssets; + public List getParticipantResultDataAssets() { + return particpantResultDataAssets; + } + public List getGridResultDataAssets() { + return gridResultDataAssets; } public ExtResultData getExtResultData() { From 01354cce754733ea63b7656b479042f3becd2661 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Mon, 3 Jun 2024 15:39:08 +0200 Subject: [PATCH 10/82] mapping in runtime --- build.gradle | 1 + .../simona/api/data/ExtInputDataPackage.java | 7 ++ .../simona/api/data/ExtInputDataValue.java | 3 + .../edu/ie3/simona/api/data/em/ExtEmData.java | 17 +-- .../api/data/em/ExtEmDataSimulation.java | 35 +++++- .../api/data/primarydata/ExtPrimaryData.java | 13 +-- .../primarydata/ExtPrimaryDataSimulation.java | 35 +++++- .../api/data/results/ExtResultData.java | 27 ++--- .../data/results/ExtResultDataSimulation.java | 45 ++++++-- .../api/data/results/ExtResultPackage.java | 65 +++++++++++ .../api/data/results/ResultDataFactory.java | 19 ---- .../simulation/mapping/ExtEntityEntry.java | 27 +++++ .../simulation/mapping/ExtEntityFactory.java | 40 +++++++ .../simulation/mapping/ExtEntityMapping.java | 44 ++++++++ .../mapping/ExtEntityMappingCsvSource.java | 104 ++++++++++++++++++ .../mapping/ExtEntityMappingSource.java | 10 ++ 16 files changed, 414 insertions(+), 78 deletions(-) create mode 100644 src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java create mode 100644 src/main/java/edu/ie3/simona/api/data/ExtInputDataValue.java create mode 100644 src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java delete mode 100644 src/main/java/edu/ie3/simona/api/data/results/ResultDataFactory.java create mode 100644 src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityEntry.java create mode 100644 src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java create mode 100644 src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMapping.java create mode 100644 src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java create mode 100644 src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSource.java diff --git a/build.gradle b/build.gradle index 3fe8a3b..b5117c9 100644 --- a/build.gradle +++ b/build.gradle @@ -45,6 +45,7 @@ repositories { } dependencies{ + implementation 'com.opencsv:opencsv:5.5.2' implementation 'tech.units:indriya:2.2' // quantities diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java new file mode 100644 index 0000000..368d635 --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java @@ -0,0 +1,7 @@ +package edu.ie3.simona.api.data; + +import java.util.Map; + +public interface ExtInputDataPackage { + Map getSimonaInputMap(); +} diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataValue.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataValue.java new file mode 100644 index 0000000..5b521aa --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataValue.java @@ -0,0 +1,3 @@ +package edu.ie3.simona.api.data; + +public interface ExtInputDataValue {} diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java index 1760996..1afe645 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java @@ -31,33 +31,20 @@ public class ExtEmData implements ExtData { /** Actor reference to adapter that handles scheduler control flow in SIMONA */ private final ActorRef extSimAdapter; - /** Factory to convert an external object to PSDM primary data */ - private final EmDataFactory factory; - /** Assets that provide primary data to SIMONA */ private final List controlledEms; public ExtEmData(ActorRef dataService, ActorRef extSimAdapter, EmDataFactory factory, List controlledEms) { this.dataService = dataService; this.extSimAdapter = extSimAdapter; - this.factory = factory; this.controlledEms = controlledEms; } public List getControlledEms() { return controlledEms; } /** Provide primary data from an external simulation in one tick. */ - public void provideEmData(Long tick, Map emData) { - Map convertedMap = new HashMap<>(); - emData.forEach( - (k, v) -> { - try { - convertedMap.put(UUID.fromString(k), factory.convert(v)); - } catch (ConvertionException e) { - throw new RuntimeException(e); - } - }); - sendExtMsg(new ProvideEmData(tick, convertedMap)); + public void provideEmData(Long tick, Map emData) { + sendExtMsg(new ProvideEmData(tick, emData)); } /** diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java index e813253..b4809b2 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java @@ -6,11 +6,16 @@ package edu.ie3.simona.api.data.em; +import edu.ie3.datamodel.models.value.PValue; import edu.ie3.simona.api.data.ExtDataSimulation; +import edu.ie3.simona.api.data.ExtInputDataPackage; import edu.ie3.simona.api.data.primarydata.ExtPrimaryData; import edu.ie3.simona.api.data.primarydata.PrimaryDataFactory; +import edu.ie3.simona.api.exceptions.ConvertionException; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.UUID; /** @@ -21,16 +26,19 @@ public class ExtEmDataSimulation implements ExtDataSimulation { private final List controlledEms; + private final Map extEmMapping; + private final EmDataFactory emDataFactory; private ExtEmData extEmData; public ExtEmDataSimulation( EmDataFactory emDataFactory, - List controlledEms + Map extEmMapping ) { this.emDataFactory = emDataFactory; - this.controlledEms = controlledEms; + this.extEmMapping = extEmMapping; + this.controlledEms = extEmMapping.values().stream().toList(); } /** Hand over an ExtPrimaryData which enables communication regarding primary data. */ @@ -49,4 +57,27 @@ public List getControlledEms() { public ExtEmData getExtEmData() { return extEmData; } + + public Map createExtEmDataMap( + ExtInputDataPackage extEmData + ) { + Map emDataForSimona = new HashMap<>(); + extEmData.getSimonaInputMap().forEach( + (id, extInput) -> { + if (extEmMapping.containsKey(id)) { + try { + emDataForSimona.put( + extEmMapping.get(id), + emDataFactory.convert(extInput) + ); + } catch (ConvertionException e) { + throw new RuntimeException(e); + } + } + } + ); + return emDataForSimona; + } + + } diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java index 33ae59a..5481e67 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java @@ -42,17 +42,8 @@ public ExtPrimaryData(ActorRef dataService, ActorRef extSimAdapter, PrimaryDataF public List getPrimaryDataAssets() { return primaryDataAssets; } /** Provide primary data from an external simulation in one tick. */ - public void providePrimaryData(Long tick, Map primaryData) { - Map convertedMap = new HashMap<>(); - primaryData.forEach( - (k, v) -> { - try { - convertedMap.put(UUID.fromString(k), factory.convert(v)); - } catch (ConvertionException e) { - throw new RuntimeException(e); - } - }); - sendExtMsg(new ProvidePrimaryData(tick, convertedMap)); + public void providePrimaryData(Long tick, Map primaryData) { + sendExtMsg(new ProvidePrimaryData(tick, primaryData)); } /** diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java index d65ee33..c94a49b 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java @@ -6,9 +6,15 @@ package edu.ie3.simona.api.data.primarydata; +import edu.ie3.datamodel.models.value.PValue; +import edu.ie3.datamodel.models.value.Value; import edu.ie3.simona.api.data.ExtDataSimulation; +import edu.ie3.simona.api.data.ExtInputDataPackage; +import edu.ie3.simona.api.exceptions.ConvertionException; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.UUID; /** @@ -19,16 +25,19 @@ public class ExtPrimaryDataSimulation implements ExtDataSimulation { private final List primaryDataAssets; + private final Map extPrimaryDataMapping; + private final PrimaryDataFactory primaryDataFactory; private ExtPrimaryData extPrimaryData; public ExtPrimaryDataSimulation( PrimaryDataFactory primaryDataFactory, - List primaryDataAssets + Map extPrimaryDataMapping ) { this.primaryDataFactory = primaryDataFactory; - this.primaryDataAssets = primaryDataAssets; + this.extPrimaryDataMapping = extPrimaryDataMapping; + this.primaryDataAssets = this.extPrimaryDataMapping.values().stream().toList(); } /** Hand over an ExtPrimaryData which enables communication regarding primary data. */ @@ -47,4 +56,26 @@ public List getPrimaryDataAssets() { public ExtPrimaryData getExtPrimaryData() { return extPrimaryData; } + + + public Map createExtPrimaryDataMap( + ExtInputDataPackage extInputDataPackage + ) { + Map primaryDataForSimona = new HashMap<>(); + extInputDataPackage.getSimonaInputMap().forEach( + (id, extInput) -> { + if (extPrimaryDataMapping.containsKey(id)) { + try { + primaryDataForSimona.put( + extPrimaryDataMapping.get(id), + primaryDataFactory.convert(extInput) + ); + } catch (ConvertionException e) { + throw new RuntimeException(e); + } + } + } + ); + return primaryDataForSimona; + } } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java index a34655d..8ff8260 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java @@ -38,9 +38,6 @@ public class ExtResultData implements ExtData { /** Actor reference to adapter that handles scheduler control flow in SIMONA */ private final ActorRef extSimAdapter; - /** Factory to convert a result entity to an object, that is readable from the external simulation */ - private final ResultDataFactory factory; - /** Assets in SIMONA that send result data */ private final List gridResultDataAssets; @@ -50,11 +47,10 @@ public class ExtResultData implements ExtData { private final Long powerFlowResolution; - public ExtResultData(ActorRef dataService, ActorRef dataServiceActivation, ActorRef extSimAdapter, ResultDataFactory factory, List gridResultDataAssets, List particpantResultDataAssets, ZonedDateTime simulationStartTime, Long powerFlowResolution) { + public ExtResultData(ActorRef dataService, ActorRef dataServiceActivation, ActorRef extSimAdapter, List gridResultDataAssets, List particpantResultDataAssets, ZonedDateTime simulationStartTime, Long powerFlowResolution) { this.dataService = dataService; this.dataServiceActivation = dataServiceActivation; this.extSimAdapter = extSimAdapter; - this.factory = factory; this.gridResultDataAssets = gridResultDataAssets; this.particpantResultDataAssets = particpantResultDataAssets; this.simulationStartTime = simulationStartTime; @@ -81,7 +77,7 @@ public List getParticpantResultDataAssets() { } /** Method that an external simulation can request results from SIMONA as a list. */ - public List requestResults(long tick) throws InterruptedException { + public List requestResultList(long tick) throws InterruptedException { sendExtMsg(new RequestResultEntities(tick)); return receiveWithType(ProvideResultEntities.class).results(); } @@ -89,19 +85,16 @@ public List requestResults(long tick) throws InterruptedException /** * Method that an external simulation can request results from SIMONA as a map string to object. */ - public Map requestResultObjects(long tick) - throws ConvertionException, InterruptedException { - return convertResultsList(requestResults(tick)); + public Map requestResults(long tick) + throws InterruptedException { + return convertResultsList(requestResultList(tick)); } - protected Map convertResultsList(List results) - throws ConvertionException { - Map resultsMap = new HashMap<>(); - Object convertedResult; - for (ResultEntity res : results) { - convertedResult = factory.convert(res); - resultsMap.put(res.getInputModel().toString(), convertedResult); - } + protected Map convertResultsList(List results) { + Map resultsMap = new HashMap<>(); + results.forEach( + res -> resultsMap.put(res.getInputModel(), res) + ); return resultsMap; } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java index fe7ec7d..810fbfa 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java @@ -6,9 +6,14 @@ package edu.ie3.simona.api.data.results; +import edu.ie3.datamodel.models.result.NodeResult; +import edu.ie3.datamodel.models.result.ResultEntity; +import edu.ie3.datamodel.models.result.system.SystemParticipantResult; import edu.ie3.simona.api.data.ExtDataSimulation; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.UUID; /** @@ -17,21 +22,21 @@ */ public class ExtResultDataSimulation implements ExtDataSimulation { + private final Map gridResultAssetMapping; + private final Map participantResultAssetMapping; private final List particpantResultDataAssets; private final List gridResultDataAssets; - private final ResultDataFactory resultDataFactory; - private ExtResultData extResultData; public ExtResultDataSimulation( - ResultDataFactory resultDataFactory, - List particpantResultDataAssets, - List gridResultDataAssets + Map participantResultAssetMapping, + Map gridResultAssetMapping ) { - this.resultDataFactory = resultDataFactory; - this.particpantResultDataAssets = particpantResultDataAssets; - this.gridResultDataAssets = gridResultDataAssets; + this.participantResultAssetMapping = participantResultAssetMapping; + this.gridResultAssetMapping = gridResultAssetMapping; + this.particpantResultDataAssets = participantResultAssetMapping.keySet().stream().toList(); + this.gridResultDataAssets = gridResultAssetMapping.keySet().stream().toList(); } /** Hand over an ExtPrimaryData which enables communication regarding primary data. */ @@ -39,10 +44,6 @@ public void setExtResultData(ExtResultData extResultData) { this.extResultData = extResultData; } - public ResultDataFactory getResultDataFactory() { - return resultDataFactory; - } - public List getParticipantResultDataAssets() { return particpantResultDataAssets; } @@ -50,6 +51,26 @@ public List getGridResultDataAssets() { return gridResultDataAssets; } + public Map requestResults(Long tick) throws InterruptedException { + return createResultMap(extResultData.requestResults(tick)); + } + + private Map createResultMap(Map results) { + Map resultMap = new HashMap<>(); + results.forEach( + (uuid, res) -> { + if (res instanceof NodeResult) { + resultMap.put(gridResultAssetMapping.get(res.getInputModel()), res); + } else if (res instanceof SystemParticipantResult) { + resultMap.put(participantResultAssetMapping.get(res.getInputModel()), res); + } else { + throw new RuntimeException(); + } + } + ); + return resultMap; + } + public ExtResultData getExtResultData() { return extResultData; } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java new file mode 100644 index 0000000..2c03057 --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java @@ -0,0 +1,65 @@ +package edu.ie3.simona.api.data.results; + +import edu.ie3.datamodel.models.result.NodeResult; +import edu.ie3.datamodel.models.result.ResultEntity; +import edu.ie3.datamodel.models.result.system.SystemParticipantResult; +import tech.units.indriya.ComparableQuantity; +import tech.units.indriya.quantity.Quantities; + +import javax.measure.quantity.Dimensionless; +import java.util.Map; + +import static edu.ie3.util.quantities.PowerSystemUnits.PU; + +public class ExtResultPackage { + + private final Long tick; + private final Map simonaResultsMap; + + public ExtResultPackage( + Long tick, + Map simonaResultsMap) { + this.tick = tick; + this.simonaResultsMap = simonaResultsMap; + } + + public Long getTick() { + return tick; + } + + public double getVoltageDeviation(String assetId) { + if (simonaResultsMap.get(assetId) instanceof NodeResult nodeResult) { + ComparableQuantity vMagDev = Quantities.getQuantity(0, PU); + vMagDev = Quantities.getQuantity(0, PU) + .add(nodeResult.getvMag() + .subtract(Quantities.getQuantity(1.0, PU))); + return vMagDev.getValue().doubleValue(); + } else { + throw new RuntimeException("VOLTAGE DEVIATION is only available for NodeResult's!"); + } + } + + public double getActivePower(String assetId) { + if (simonaResultsMap.get(assetId) instanceof SystemParticipantResult systemParticipantResult) { + return systemParticipantResult.getP().getValue().doubleValue(); + } else { + throw new RuntimeException("ACTIVE POWER is only available for SystemParticipantResult's!"); + } + } + + public double getReactivePower(String assetId) { + if (simonaResultsMap.get(assetId) instanceof SystemParticipantResult systemParticipantResult) { + return systemParticipantResult.getQ().getValue().doubleValue(); + } else { + throw new RuntimeException("REACTIVE POWER is only available for SystemParticipantResult's!"); + } + } + + public double getLineLoading(String assetId) { + throw new RuntimeException("LINE LOADING is not implemented yet!"); + } + + public String toString() { + return simonaResultsMap.toString(); + } +} diff --git a/src/main/java/edu/ie3/simona/api/data/results/ResultDataFactory.java b/src/main/java/edu/ie3/simona/api/data/results/ResultDataFactory.java deleted file mode 100644 index 1632944..0000000 --- a/src/main/java/edu/ie3/simona/api/data/results/ResultDataFactory.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * © 2024. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation - */ - -package edu.ie3.simona.api.data.results; - -import edu.ie3.datamodel.models.result.ResultEntity; -import edu.ie3.simona.api.exceptions.ConvertionException; - -public interface ResultDataFactory { - - /** - * Should convert a result entity to an object, that can be read by the external simulation, with - * a check if the object is primary data - */ - Object convert(ResultEntity entity) throws ConvertionException; -} diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityEntry.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityEntry.java new file mode 100644 index 0000000..5806844 --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityEntry.java @@ -0,0 +1,27 @@ +package edu.ie3.simona.api.simulation.mapping; + +import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme; +import edu.ie3.datamodel.models.input.InputEntity; + +import java.util.UUID; + +public record ExtEntityEntry( + UUID uuid, + String id, + ColumnScheme columnScheme, + String resultType +) implements InputEntity { + public static final String EXT_INPUT = "input"; + public static final String EXT_RESULT_PARTICIPANT = "result_participant"; + public static final String EXT_RESULT_GRID = "result_grid"; + + + public String toString() { + return "ExtEntityEntry={" + + "UUID=" + uuid() + ", " + + "ExtId=" + id() + ", " + + "ColumnScheme=" + columnScheme() + ", " + + "ResultType=" + resultType() + + "}"; + } +} diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java new file mode 100644 index 0000000..15aed5d --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java @@ -0,0 +1,40 @@ +package edu.ie3.simona.api.simulation.mapping; + +import edu.ie3.datamodel.io.factory.EntityData; +import edu.ie3.datamodel.io.factory.EntityFactory; +import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme; + +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class ExtEntityFactory extends EntityFactory { + + public static final String SIMONA_UUID = "uuid"; + public static final String EXT_ID = "id"; + public static final String COLUMN_SCHEME = "columnScheme"; + public static final String DATA_TYPE = "dataType"; + + @Override + protected List> getFields(Class entityClass) { + return Collections.singletonList( + Stream.of(SIMONA_UUID, EXT_ID, COLUMN_SCHEME, DATA_TYPE).collect(Collectors.toSet())); + } + + @Override + protected ExtEntityEntry buildModel( + EntityData data + ) { + UUID simonaUuid = data.getUUID(SIMONA_UUID); + String extId = data.getField(EXT_ID); + Optional columnScheme = ColumnScheme.parse(COLUMN_SCHEME); + String inputType = data.getField(DATA_TYPE); + + return new ExtEntityEntry( + simonaUuid, + extId, + columnScheme.get(), + inputType + ); + } +} diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMapping.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMapping.java new file mode 100644 index 0000000..03fae54 --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMapping.java @@ -0,0 +1,44 @@ +package edu.ie3.simona.api.simulation.mapping; + +import java.util.*; + +public class ExtEntityMapping { + + private final List extEntities; + + public ExtEntityMapping( + List extEntityEntryList + ) { + this.extEntities = extEntityEntryList; + } + + public Map getExtIdUuidMapping( + String dataType + ) { + Map extIdUuidMapping = new HashMap<>(); + extEntities.forEach( + ent -> { + if (Objects.equals(ent.resultType(), dataType)) { + extIdUuidMapping.put( + ent.id(), ent.uuid() + ); + } + } + ); + return extIdUuidMapping; + } + + public Map getExtUuidIdMapping( + String dataType + ) { + Map extUuidIdMapping = new HashMap<>(); + extEntities.forEach( + ent -> { + if (Objects.equals(ent.resultType(), dataType)) { + extUuidIdMapping.put(ent.uuid(), ent.id()); + } + } + ); + return extUuidIdMapping; + } +} diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java new file mode 100644 index 0000000..d62fe01 --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java @@ -0,0 +1,104 @@ +package edu.ie3.simona.api.simulation.mapping; + +import com.opencsv.CSVReaderHeaderAware; +import com.opencsv.exceptions.CsvValidationException; +import edu.ie3.datamodel.exceptions.SourceException; +import edu.ie3.datamodel.io.naming.FileNamingStrategy; +import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme; +import edu.ie3.datamodel.io.source.csv.CsvDataSource; + +import java.io.FileReader; +import java.io.IOException; +import java.nio.file.Path; +import java.util.*; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; + +public class ExtEntityMappingCsvSource extends ExtEntityMappingSource { + private final ExtEntityMapping extEntities; + private final CsvDataSource dataSource; + + private final Path mappingPath; + + public ExtEntityMappingCsvSource(String csvSep, Path folderPath, FileNamingStrategy fileNamingStrategy) { + super(); + this.dataSource = new CsvDataSource(csvSep, folderPath, fileNamingStrategy); + this.mappingPath = folderPath; + this.extEntities = buildExtEntityMapping(); + } + + public ExtEntityMapping getMapping() { + return extEntities; + } + + + public Optional> getSourceFields() throws SourceException { + return dataSource.getSourceFields(ExtEntityEntry.class); + } + + protected ExtEntityMapping buildExtEntityMapping() { + return new ExtEntityMapping(buildStream().map(this::createExtEntityEntry).toList()); + } + + private Stream> buildStream() { + try { + FileReader fileReader = new FileReader(String.valueOf(mappingPath)); + CSVReaderHeaderAware csvReader = new CSVReaderHeaderAware(fileReader); + + // Creating a Stream from CSVReader + Stream> csvStream = StreamSupport.stream( + new Spliterators.AbstractSpliterator>(Long.MAX_VALUE, Spliterator.ORDERED) { + @Override + public boolean tryAdvance(Consumer> action) { + try { + Map line = csvReader.readMap(); + if (line == null) { + return false; + } + action.accept(line); + //System.out.println(line); + return true; + } catch (IOException | CsvValidationException e) { + throw new RuntimeException(e); + } + } + }, false); + + //csvReader.close(); + return csvStream; + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private ExtEntityEntry createExtEntityEntry( + Map fieldToValues + ) { + return new ExtEntityEntry( + UUID.fromString(fieldToValues.get(ExtEntityFactory.SIMONA_UUID)), + fieldToValues.get(ExtEntityFactory.EXT_ID), + ColumnScheme.parse(fieldToValues.get(ExtEntityFactory.COLUMN_SCHEME)).get(), + fieldToValues.get(ExtEntityFactory.DATA_TYPE) + ); + } + + public static ExtEntityMapping createExtEntityMapping(Path mappingPath) { + ExtEntityMappingCsvSource mappingSource = new ExtEntityMappingCsvSource( + ",", + mappingPath, + new FileNamingStrategy() + ); + return mappingSource.getMapping(); + } + + /* + private Try createExtEntityEntry( + Map fieldToValues + ) { + System.out.println("create: " + fieldToValues); + EntityData entityData = new EntityData(fieldToValues, ExtEntityEntry.class); + return factory.get(entityData); + } + */ +} diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSource.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSource.java new file mode 100644 index 0000000..0c7dc1b --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSource.java @@ -0,0 +1,10 @@ +package edu.ie3.simona.api.simulation.mapping; + +public abstract class ExtEntityMappingSource { + + protected final ExtEntityFactory factory; + + public ExtEntityMappingSource() { + this.factory = new ExtEntityFactory(); + } +} From 754ebc56cc6056140966ff4f0390525ea350d5ef Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Tue, 4 Jun 2024 11:22:50 +0200 Subject: [PATCH 11/82] temp --- .../DataQueueExtSimulationExtSimulator.java | 17 +++++++++++++++++ .../edu/ie3/simona/api/data/ExtDataPackage.java | 4 ++++ .../simona/api/data/ExtInputDataPackage.java | 2 +- .../api/data/results/ExtResultPackage.java | 3 ++- 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java create mode 100644 src/main/java/edu/ie3/simona/api/data/ExtDataPackage.java diff --git a/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java b/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java new file mode 100644 index 0000000..44e807f --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java @@ -0,0 +1,17 @@ +package edu.ie3.simona.api.data; + +import java.util.concurrent.LinkedBlockingQueue; + +public class DataQueueExtSimulationExtSimulator { + public final LinkedBlockingQueue receiverTriggerQueue = new LinkedBlockingQueue<>(); + + public DataQueueExtSimulationExtSimulator() {} + + public void queueData(V data) throws InterruptedException { + this.receiverTriggerQueue.put(data); + } + + public V takeData() throws InterruptedException { + return this.receiverTriggerQueue.take(); + } +} diff --git a/src/main/java/edu/ie3/simona/api/data/ExtDataPackage.java b/src/main/java/edu/ie3/simona/api/data/ExtDataPackage.java new file mode 100644 index 0000000..024b75a --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/data/ExtDataPackage.java @@ -0,0 +1,4 @@ +package edu.ie3.simona.api.data; + +public interface ExtDataPackage { +} diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java index 368d635..7525af0 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java @@ -2,6 +2,6 @@ import java.util.Map; -public interface ExtInputDataPackage { +public interface ExtInputDataPackage extends ExtDataPackage { Map getSimonaInputMap(); } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java index 2c03057..1f8a4fa 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java @@ -3,6 +3,7 @@ import edu.ie3.datamodel.models.result.NodeResult; import edu.ie3.datamodel.models.result.ResultEntity; import edu.ie3.datamodel.models.result.system.SystemParticipantResult; +import edu.ie3.simona.api.data.ExtDataPackage; import tech.units.indriya.ComparableQuantity; import tech.units.indriya.quantity.Quantities; @@ -11,7 +12,7 @@ import static edu.ie3.util.quantities.PowerSystemUnits.PU; -public class ExtResultPackage { +public class ExtResultPackage implements ExtDataPackage { private final Long tick; private final Map simonaResultsMap; From 6f6b097821d329c33929ddcc6a759501f5ff2b54 Mon Sep 17 00:00:00 2001 From: smjobaoo Date: Wed, 5 Jun 2024 13:11:24 +0200 Subject: [PATCH 12/82] removed dataSimulation --- .../edu/ie3/simona/api/data/em/ExtEmData.java | 51 ++++++++++-- .../api/data/em/ExtEmDataSimulation.java | 83 ------------------- .../api/data/primarydata/ExtPrimaryData.java | 49 +++++++++-- .../primarydata/ExtPrimaryDataSimulation.java | 81 ------------------ .../api/data/results/ExtResultData.java | 66 ++++++++++----- .../data/results/ExtResultDataSimulation.java | 77 ----------------- .../simona/api/simulation/ExtSimulation.java | 2 + 7 files changed, 133 insertions(+), 276 deletions(-) delete mode 100644 src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java delete mode 100644 src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java delete mode 100644 src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java index 1afe645..ea3f962 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java @@ -9,6 +9,7 @@ import edu.ie3.datamodel.models.value.PValue; import edu.ie3.datamodel.models.value.Value; import edu.ie3.simona.api.data.ExtData; +import edu.ie3.simona.api.data.ExtInputDataPackage; import edu.ie3.simona.api.data.em.ontology.EmDataMessageFromExt; import edu.ie3.simona.api.data.em.ontology.ProvideEmData; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; @@ -26,21 +27,37 @@ public class ExtEmData implements ExtData { /** Actor reference to service that handles ev data within SIMONA */ - private final ActorRef dataService; + private ActorRef dataService; /** Actor reference to adapter that handles scheduler control flow in SIMONA */ - private final ActorRef extSimAdapter; + private ActorRef extSimAdapter; /** Assets that provide primary data to SIMONA */ - private final List controlledEms; + private final Map extEmMapping; - public ExtEmData(ActorRef dataService, ActorRef extSimAdapter, EmDataFactory factory, List controlledEms) { + private final EmDataFactory emDataFactory; + + public ExtEmData( + EmDataFactory emDataFactory, + Map extEmMapping + ) { + this.emDataFactory = emDataFactory; + this.extEmMapping = extEmMapping; + } + + public void setActorRefs( + ActorRef dataService, + ActorRef extSimAdapter + ) { this.dataService = dataService; this.extSimAdapter = extSimAdapter; - this.controlledEms = controlledEms; } - public List getControlledEms() { return controlledEms; } + public List getControlledEms() { return extEmMapping.values().stream().toList(); } + + public EmDataFactory getEmDataFactory() { + return emDataFactory; + } /** Provide primary data from an external simulation in one tick. */ public void provideEmData(Long tick, Map emData) { @@ -59,4 +76,26 @@ public void sendExtMsg(EmDataMessageFromExt msg) { // we need to schedule data receiver activation with scheduler extSimAdapter.tell(new ScheduleDataServiceMessage(dataService), ActorRef.noSender()); } + + + public Map createExtEmDataMap( + ExtInputDataPackage extEmData + ) { + Map emDataForSimona = new HashMap<>(); + extEmData.getSimonaInputMap().forEach( + (id, extInput) -> { + if (extEmMapping.containsKey(id)) { + try { + emDataForSimona.put( + extEmMapping.get(id), + emDataFactory.convert(extInput) + ); + } catch (ConvertionException e) { + throw new RuntimeException(e); + } + } + } + ); + return emDataForSimona; + } } diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java deleted file mode 100644 index b4809b2..0000000 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * © 2024. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation - */ - -package edu.ie3.simona.api.data.em; - -import edu.ie3.datamodel.models.value.PValue; -import edu.ie3.simona.api.data.ExtDataSimulation; -import edu.ie3.simona.api.data.ExtInputDataPackage; -import edu.ie3.simona.api.data.primarydata.ExtPrimaryData; -import edu.ie3.simona.api.data.primarydata.PrimaryDataFactory; -import edu.ie3.simona.api.exceptions.ConvertionException; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -/** - * An external simulation that provides primary data should implement this interface and handle the - * ExtPrimaryData that is handed over. - */ -public class ExtEmDataSimulation implements ExtDataSimulation { - - private final List controlledEms; - - private final Map extEmMapping; - - private final EmDataFactory emDataFactory; - - private ExtEmData extEmData; - - public ExtEmDataSimulation( - EmDataFactory emDataFactory, - Map extEmMapping - ) { - this.emDataFactory = emDataFactory; - this.extEmMapping = extEmMapping; - this.controlledEms = extEmMapping.values().stream().toList(); - } - - /** Hand over an ExtPrimaryData which enables communication regarding primary data. */ - public void setExtEmData(ExtEmData extEmData) { - this.extEmData = extEmData; - } - - public EmDataFactory getEmDataFactory() { - return emDataFactory; - } - - public List getControlledEms() { - return controlledEms; - } - - public ExtEmData getExtEmData() { - return extEmData; - } - - public Map createExtEmDataMap( - ExtInputDataPackage extEmData - ) { - Map emDataForSimona = new HashMap<>(); - extEmData.getSimonaInputMap().forEach( - (id, extInput) -> { - if (extEmMapping.containsKey(id)) { - try { - emDataForSimona.put( - extEmMapping.get(id), - emDataFactory.convert(extInput) - ); - } catch (ConvertionException e) { - throw new RuntimeException(e); - } - } - } - ); - return emDataForSimona; - } - - -} diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java index 5481e67..d748c72 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java @@ -8,6 +8,7 @@ import edu.ie3.datamodel.models.value.Value; import edu.ie3.simona.api.data.ExtData; +import edu.ie3.simona.api.data.ExtInputDataPackage; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import edu.ie3.simona.api.data.primarydata.ontology.PrimaryDataMessageFromExt; import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData; @@ -21,25 +22,36 @@ public class ExtPrimaryData implements ExtData { /** Actor reference to service that handles ev data within SIMONA */ - private final ActorRef dataService; + private ActorRef dataService; /** Actor reference to adapter that handles scheduler control flow in SIMONA */ - private final ActorRef extSimAdapter; + private ActorRef extSimAdapter; /** Factory to convert an external object to PSDM primary data */ - private final PrimaryDataFactory factory; + private final PrimaryDataFactory primaryDataFactory; /** Assets that provide primary data to SIMONA */ - private final List primaryDataAssets; + private final Map extPrimaryDataMapping; - public ExtPrimaryData(ActorRef dataService, ActorRef extSimAdapter, PrimaryDataFactory factory, List primaryDataAssets) { + public ExtPrimaryData(PrimaryDataFactory primaryDataFactory, Map extPrimaryDataMapping) { + this.primaryDataFactory = primaryDataFactory; + this.extPrimaryDataMapping = extPrimaryDataMapping; + } + + public void setActorRefs( + ActorRef dataService, ActorRef extSimAdapter + ) { this.dataService = dataService; this.extSimAdapter = extSimAdapter; - this.factory = factory; - this.primaryDataAssets = primaryDataAssets; } - public List getPrimaryDataAssets() { return primaryDataAssets; } + public PrimaryDataFactory getPrimaryDataFactory() { + return primaryDataFactory; + } + + public List getPrimaryDataAssets() { + return extPrimaryDataMapping.values().stream().toList(); + } /** Provide primary data from an external simulation in one tick. */ public void providePrimaryData(Long tick, Map primaryData) { @@ -58,4 +70,25 @@ public void sendExtMsg(PrimaryDataMessageFromExt msg) { // we need to schedule data receiver activation with scheduler extSimAdapter.tell(new ScheduleDataServiceMessage(dataService), ActorRef.noSender()); } + + public Map createExtPrimaryDataMap( + ExtInputDataPackage extInputDataPackage + ) { + Map primaryDataForSimona = new HashMap<>(); + extInputDataPackage.getSimonaInputMap().forEach( + (id, extInput) -> { + if (extPrimaryDataMapping.containsKey(id)) { + try { + primaryDataForSimona.put( + extPrimaryDataMapping.get(id), + primaryDataFactory.convert(extInput) + ); + } catch (ConvertionException e) { + throw new RuntimeException(e); + } + } + } + ); + return primaryDataForSimona; + } } diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java deleted file mode 100644 index c94a49b..0000000 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * © 2024. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation - */ - -package edu.ie3.simona.api.data.primarydata; - -import edu.ie3.datamodel.models.value.PValue; -import edu.ie3.datamodel.models.value.Value; -import edu.ie3.simona.api.data.ExtDataSimulation; -import edu.ie3.simona.api.data.ExtInputDataPackage; -import edu.ie3.simona.api.exceptions.ConvertionException; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -/** - * An external simulation that provides primary data should implement this interface and handle the - * ExtPrimaryData that is handed over. - */ -public class ExtPrimaryDataSimulation implements ExtDataSimulation { - - private final List primaryDataAssets; - - private final Map extPrimaryDataMapping; - - private final PrimaryDataFactory primaryDataFactory; - - private ExtPrimaryData extPrimaryData; - - public ExtPrimaryDataSimulation( - PrimaryDataFactory primaryDataFactory, - Map extPrimaryDataMapping - ) { - this.primaryDataFactory = primaryDataFactory; - this.extPrimaryDataMapping = extPrimaryDataMapping; - this.primaryDataAssets = this.extPrimaryDataMapping.values().stream().toList(); - } - - /** Hand over an ExtPrimaryData which enables communication regarding primary data. */ - public void setExtPrimaryData(ExtPrimaryData extPrimaryData) { - this.extPrimaryData = extPrimaryData; - } - - public PrimaryDataFactory getPrimaryDataFactory() { - return primaryDataFactory; - } - - public List getPrimaryDataAssets() { - return primaryDataAssets; - } - - public ExtPrimaryData getExtPrimaryData() { - return extPrimaryData; - } - - - public Map createExtPrimaryDataMap( - ExtInputDataPackage extInputDataPackage - ) { - Map primaryDataForSimona = new HashMap<>(); - extInputDataPackage.getSimonaInputMap().forEach( - (id, extInput) -> { - if (extPrimaryDataMapping.containsKey(id)) { - try { - primaryDataForSimona.put( - extPrimaryDataMapping.get(id), - primaryDataFactory.convert(extInput) - ); - } catch (ConvertionException e) { - throw new RuntimeException(e); - } - } - } - ); - return primaryDataForSimona; - } -} diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java index 8ff8260..d019a57 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java @@ -6,7 +6,9 @@ package edu.ie3.simona.api.data.results; +import edu.ie3.datamodel.models.result.NodeResult; import edu.ie3.datamodel.models.result.ResultEntity; +import edu.ie3.datamodel.models.result.system.SystemParticipantResult; import edu.ie3.simona.api.data.ExtData; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import edu.ie3.simona.api.data.results.ontology.ProvideResultEntities; @@ -30,29 +32,43 @@ public class ExtResultData implements ExtData { new LinkedBlockingQueue<>(); /** Actor reference to service that handles result data within SIMONA */ - private final ActorRef dataService; + private ActorRef dataService; /** Actor reference to the dataServiceAdapter */ - private final ActorRef dataServiceActivation; + private ActorRef dataServiceActivation; /** Actor reference to adapter that handles scheduler control flow in SIMONA */ - private final ActorRef extSimAdapter; + private ActorRef extSimAdapter; - /** Assets in SIMONA that send result data */ - private final List gridResultDataAssets; + private final Map gridResultAssetMapping; + private final Map participantResultAssetMapping; - private final List particpantResultDataAssets; + private ZonedDateTime simulationStartTime; - private final ZonedDateTime simulationStartTime; + private Long powerFlowResolution; - private final Long powerFlowResolution; + public ExtResultData( + Map participantResultAssetMapping, + Map gridResultAssetMapping + ) { + this.participantResultAssetMapping = participantResultAssetMapping; + this.gridResultAssetMapping = gridResultAssetMapping; + } - public ExtResultData(ActorRef dataService, ActorRef dataServiceActivation, ActorRef extSimAdapter, List gridResultDataAssets, List particpantResultDataAssets, ZonedDateTime simulationStartTime, Long powerFlowResolution) { + public void setActorRefs( + ActorRef dataService, + ActorRef dataServiceActivation, + ActorRef extSimAdapter + ) { this.dataService = dataService; this.dataServiceActivation = dataServiceActivation; this.extSimAdapter = extSimAdapter; - this.gridResultDataAssets = gridResultDataAssets; - this.particpantResultDataAssets = particpantResultDataAssets; + } + + public void setSimulationData( + ZonedDateTime simulationStartTime, + Long powerFlowResolution + ) { this.simulationStartTime = simulationStartTime; this.powerFlowResolution = powerFlowResolution; } @@ -69,15 +85,15 @@ public ZonedDateTime getSimulationTime(Long tick) { } public List getGridResultDataAssets() { - return gridResultDataAssets; + return gridResultAssetMapping.keySet().stream().toList(); } - public List getParticpantResultDataAssets() { - return particpantResultDataAssets; + public List getParticipantResultDataAssets() { + return participantResultAssetMapping.keySet().stream().toList(); } /** Method that an external simulation can request results from SIMONA as a list. */ - public List requestResultList(long tick) throws InterruptedException { + private List requestResultList(long tick) throws InterruptedException { sendExtMsg(new RequestResultEntities(tick)); return receiveWithType(ProvideResultEntities.class).results(); } @@ -85,17 +101,25 @@ public List requestResultList(long tick) throws InterruptedExcepti /** * Method that an external simulation can request results from SIMONA as a map string to object. */ - public Map requestResults(long tick) + public Map requestResults(long tick) throws InterruptedException { - return convertResultsList(requestResultList(tick)); + return createResultMap(requestResultList(tick)); } - protected Map convertResultsList(List results) { - Map resultsMap = new HashMap<>(); + private Map createResultMap(List results) { + Map resultMap = new HashMap<>(); results.forEach( - res -> resultsMap.put(res.getInputModel(), res) + res -> { + if (res instanceof NodeResult) { + resultMap.put(gridResultAssetMapping.get(res.getInputModel()), res); + } else if (res instanceof SystemParticipantResult) { + resultMap.put(participantResultAssetMapping.get(res.getInputModel()), res); + } else { + throw new RuntimeException(); + } + } ); - return resultsMap; + return resultMap; } /** diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java deleted file mode 100644 index 810fbfa..0000000 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * © 2024. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation - */ - -package edu.ie3.simona.api.data.results; - -import edu.ie3.datamodel.models.result.NodeResult; -import edu.ie3.datamodel.models.result.ResultEntity; -import edu.ie3.datamodel.models.result.system.SystemParticipantResult; -import edu.ie3.simona.api.data.ExtDataSimulation; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -/** - * An external simulation that needs results from SIMONA should implement this interface and handle - * the ExtResultsData that is handed over. - */ -public class ExtResultDataSimulation implements ExtDataSimulation { - - private final Map gridResultAssetMapping; - private final Map participantResultAssetMapping; - private final List particpantResultDataAssets; - private final List gridResultDataAssets; - - private ExtResultData extResultData; - - public ExtResultDataSimulation( - Map participantResultAssetMapping, - Map gridResultAssetMapping - ) { - this.participantResultAssetMapping = participantResultAssetMapping; - this.gridResultAssetMapping = gridResultAssetMapping; - this.particpantResultDataAssets = participantResultAssetMapping.keySet().stream().toList(); - this.gridResultDataAssets = gridResultAssetMapping.keySet().stream().toList(); - } - - /** Hand over an ExtPrimaryData which enables communication regarding primary data. */ - public void setExtResultData(ExtResultData extResultData) { - this.extResultData = extResultData; - } - - public List getParticipantResultDataAssets() { - return particpantResultDataAssets; - } - public List getGridResultDataAssets() { - return gridResultDataAssets; - } - - public Map requestResults(Long tick) throws InterruptedException { - return createResultMap(extResultData.requestResults(tick)); - } - - private Map createResultMap(Map results) { - Map resultMap = new HashMap<>(); - results.forEach( - (uuid, res) -> { - if (res instanceof NodeResult) { - resultMap.put(gridResultAssetMapping.get(res.getInputModel()), res); - } else if (res instanceof SystemParticipantResult) { - resultMap.put(participantResultAssetMapping.get(res.getInputModel()), res); - } else { - throw new RuntimeException(); - } - } - ); - return resultMap; - } - - public ExtResultData getExtResultData() { - return extResultData; - } -} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java index 9feeb6d..6738710 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java @@ -140,4 +140,6 @@ public final void setup(ExtSimAdapterData data, List adapters) { protected String[] getMainArgs() { return data.getMainArgs(); } + + public abstract List getDataConnections(); } From ca6fad9f46d896d26dfbfb725d57a61ecfc45323 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Fri, 7 Jun 2024 14:18:27 +0200 Subject: [PATCH 13/82] modified setup --- .../simona/api/data/ExtInputDataPackage.java | 21 +++++++++++++++++-- .../ie3/simona/api/data/ExtOutputData.java | 3 +++ .../ie3/simona/api/data/em/EmDataFactory.java | 3 ++- .../edu/ie3/simona/api/data/em/ExtEmData.java | 4 ++-- .../api/data/em/ExtEmDataSimulation.java | 6 ++++++ .../primarydata/ExtPrimaryDataSimulation.java | 6 ++++++ .../data/primarydata/PrimaryDataFactory.java | 3 ++- .../api/data/results/ExtResultData.java | 3 ++- .../data/results/ExtResultDataSimulation.java | 6 ++++++ .../ontology/ProvideResultEntities.java | 6 ++++++ .../api/simulation/ExtSimAdapterData.java | 8 +++++++ 11 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 src/main/java/edu/ie3/simona/api/data/ExtOutputData.java create mode 100644 src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java create mode 100644 src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java create mode 100644 src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java index 7525af0..af4f704 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java @@ -1,7 +1,24 @@ package edu.ie3.simona.api.data; +import java.util.HashMap; import java.util.Map; -public interface ExtInputDataPackage extends ExtDataPackage { - Map getSimonaInputMap(); +public class ExtInputDataPackage implements ExtDataPackage { + private final Map dataMap; + + public ExtInputDataPackage(Map dataMap) { + this.dataMap = dataMap; + } + + public ExtInputDataPackage() { + this(new HashMap<>()); + } + + public Map getSimonaInputMap() { + return dataMap; + } + + public void addValue(String id, ExtInputDataValue value) { + dataMap.put(id, value); + } } diff --git a/src/main/java/edu/ie3/simona/api/data/ExtOutputData.java b/src/main/java/edu/ie3/simona/api/data/ExtOutputData.java new file mode 100644 index 0000000..4179d37 --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/data/ExtOutputData.java @@ -0,0 +1,3 @@ +package edu.ie3.simona.api.data; + +public interface ExtOutputData extends ExtData {} diff --git a/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java b/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java index d66b84a..f75a5b7 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java +++ b/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java @@ -8,11 +8,12 @@ import edu.ie3.datamodel.models.value.PValue; import edu.ie3.datamodel.models.value.Value; +import edu.ie3.simona.api.data.ExtInputDataValue; import edu.ie3.simona.api.exceptions.ConvertionException; /** Interface that should be implemented by an external simulation. */ public interface EmDataFactory { /** Should convert an object to a primary data value with a check if the object is primary data */ - PValue convert(Object entity) throws ConvertionException; + PValue convert(ExtInputDataValue entity) throws ConvertionException; } diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java index ea3f962..2cdb91e 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java @@ -79,10 +79,10 @@ public void sendExtMsg(EmDataMessageFromExt msg) { public Map createExtEmDataMap( - ExtInputDataPackage extEmData + ExtInputDataPackage extInputDataPackage ) { Map emDataForSimona = new HashMap<>(); - extEmData.getSimonaInputMap().forEach( + extInputDataPackage.getSimonaInputMap().forEach( (id, extInput) -> { if (extEmMapping.containsKey(id)) { try { diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java new file mode 100644 index 0000000..ae21209 --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java @@ -0,0 +1,6 @@ +package edu.ie3.simona.api.data.em; + +import edu.ie3.simona.api.data.ExtDataSimulation; +import edu.ie3.simona.api.data.em.ExtEmData; + +public interface ExtEmDataSimulation extends ExtDataSimulation {} diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java new file mode 100644 index 0000000..6282159 --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java @@ -0,0 +1,6 @@ +package edu.ie3.simona.api.data.primarydata; + +import edu.ie3.simona.api.data.ExtDataSimulation; +import edu.ie3.simona.api.data.primarydata.ExtPrimaryData; + +public interface ExtPrimaryDataSimulation extends ExtDataSimulation {} diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/PrimaryDataFactory.java b/src/main/java/edu/ie3/simona/api/data/primarydata/PrimaryDataFactory.java index 9ff74d5..fc108cf 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/PrimaryDataFactory.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/PrimaryDataFactory.java @@ -7,11 +7,12 @@ package edu.ie3.simona.api.data.primarydata; import edu.ie3.datamodel.models.value.Value; +import edu.ie3.simona.api.data.ExtInputDataValue; import edu.ie3.simona.api.exceptions.ConvertionException; /** Interface that should be implemented by an external simulation. */ public interface PrimaryDataFactory { /** Should convert an object to a primary data value with a check if the object is primary data */ - Value convert(Object entity) throws ConvertionException; + Value convert(ExtInputDataValue entity) throws ConvertionException; } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java index d019a57..eea10b2 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java @@ -10,6 +10,7 @@ import edu.ie3.datamodel.models.result.ResultEntity; import edu.ie3.datamodel.models.result.system.SystemParticipantResult; import edu.ie3.simona.api.data.ExtData; +import edu.ie3.simona.api.data.ExtOutputData; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import edu.ie3.simona.api.data.results.ontology.ProvideResultEntities; import edu.ie3.simona.api.data.results.ontology.RequestResultEntities; @@ -25,7 +26,7 @@ import java.util.UUID; import java.util.concurrent.LinkedBlockingQueue; -public class ExtResultData implements ExtData { +public class ExtResultData implements ExtOutputData { /** Data message queue containing messages from SIMONA */ public final LinkedBlockingQueue receiveTriggerQueue = diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java new file mode 100644 index 0000000..cc15111 --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java @@ -0,0 +1,6 @@ +package edu.ie3.simona.api.data.results; + +import edu.ie3.simona.api.data.ExtDataSimulation; +import edu.ie3.simona.api.data.results.ExtResultData; + +public interface ExtResultDataSimulation extends ExtDataSimulation {} diff --git a/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java b/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java index 6efe5c6..198ba1b 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java @@ -10,6 +10,8 @@ import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.UUID; /** Provides a list of results from SIMONA to an external simulation. */ public record ProvideResultEntities(List results) implements ResultDataResponseMessageToExt { @@ -17,6 +19,10 @@ public ProvideResultEntities() { this(new ArrayList<>()); } + public ProvideResultEntities(Map resultMap) { + this(resultMap.values().stream().toList()); + } + public ProvideResultEntities(List results) { this.results = results; } diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java b/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java index 53f60d4..186e9ea 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java @@ -33,6 +33,14 @@ public ExtSimAdapterData(Map extSimAdapters, String[] mainArg this.mainArgs = mainArgs; } + public ActorRef getPhase1Adapter() { + return extSimAdapters.get(1); + } + + public ActorRef getPhase2Adapter() { + return extSimAdapters.get(2); + } + /** * Called within SIMONA to queue messages for the external simulation * From 49e3468ab5e4903d66766fb431c4b3de8a906a54 Mon Sep 17 00:00:00 2001 From: smjobaoo Date: Tue, 11 Jun 2024 10:38:42 +0200 Subject: [PATCH 14/82] docs --- .../edu/ie3/simona/api/data/ExtDataPackage.java | 3 +-- .../ie3/simona/api/data/ExtInputDataPackage.java | 6 ++++++ .../edu/ie3/simona/api/data/em/ExtEmData.java | 11 ++++++----- .../api/data/primarydata/ExtPrimaryData.java | 8 +++++++- .../simona/api/data/results/ExtResultData.java | 6 ++++++ .../simona/api/data/results/ExtResultPackage.java | 15 ++++++++++++++- 6 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/data/ExtDataPackage.java b/src/main/java/edu/ie3/simona/api/data/ExtDataPackage.java index 024b75a..24e4209 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtDataPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtDataPackage.java @@ -1,4 +1,3 @@ package edu.ie3.simona.api.data; -public interface ExtDataPackage { -} +public interface ExtDataPackage {} diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java index af4f704..dbe4169 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java @@ -3,7 +3,12 @@ import java.util.HashMap; import java.util.Map; +/** + * Contains all inputs for SIMONA for a certain tick + */ public class ExtInputDataPackage implements ExtDataPackage { + + /** Map external id to input for SIMONA */ private final Map dataMap; public ExtInputDataPackage(Map dataMap) { @@ -18,6 +23,7 @@ public Map getSimonaInputMap() { return dataMap; } + /** Adds a value to the input map */ public void addValue(String id, ExtInputDataValue value) { dataMap.put(id, value); } diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java index 2cdb91e..34c04aa 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java @@ -7,15 +7,11 @@ package edu.ie3.simona.api.data.em; import edu.ie3.datamodel.models.value.PValue; -import edu.ie3.datamodel.models.value.Value; import edu.ie3.simona.api.data.ExtData; import edu.ie3.simona.api.data.ExtInputDataPackage; import edu.ie3.simona.api.data.em.ontology.EmDataMessageFromExt; import edu.ie3.simona.api.data.em.ontology.ProvideEmData; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; -import edu.ie3.simona.api.data.primarydata.PrimaryDataFactory; -import edu.ie3.simona.api.data.primarydata.ontology.PrimaryDataMessageFromExt; -import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData; import edu.ie3.simona.api.exceptions.ConvertionException; import org.apache.pekko.actor.ActorRef; @@ -35,6 +31,7 @@ public class ExtEmData implements ExtData { /** Assets that provide primary data to SIMONA */ private final Map extEmMapping; + /** Factory, that converts external input data to set points for EM agents */ private final EmDataFactory emDataFactory; public ExtEmData( @@ -45,6 +42,7 @@ public ExtEmData( this.extEmMapping = extEmMapping; } + /** Sets the actor refs for data and control flow */ public void setActorRefs( ActorRef dataService, ActorRef extSimAdapter @@ -53,6 +51,7 @@ public void setActorRefs( this.extSimAdapter = extSimAdapter; } + /** Returns a list of the uuids of the em agents that expect external set points */ public List getControlledEms() { return extEmMapping.values().stream().toList(); } public EmDataFactory getEmDataFactory() { @@ -77,7 +76,9 @@ public void sendExtMsg(EmDataMessageFromExt msg) { extSimAdapter.tell(new ScheduleDataServiceMessage(dataService), ActorRef.noSender()); } - + /** + * Converts an input data package from an external simulation to a map of set points + */ public Map createExtEmDataMap( ExtInputDataPackage extInputDataPackage ) { diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java index d748c72..2243e7a 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java @@ -38,8 +38,10 @@ public ExtPrimaryData(PrimaryDataFactory primaryDataFactory, Map e this.extPrimaryDataMapping = extPrimaryDataMapping; } + /** Sets the actor refs for data and control flow */ public void setActorRefs( - ActorRef dataService, ActorRef extSimAdapter + ActorRef dataService, + ActorRef extSimAdapter ) { this.dataService = dataService; this.extSimAdapter = extSimAdapter; @@ -49,6 +51,7 @@ public PrimaryDataFactory getPrimaryDataFactory() { return primaryDataFactory; } + /** Returns a list of the uuids of the system participants that expect external primary data */ public List getPrimaryDataAssets() { return extPrimaryDataMapping.values().stream().toList(); } @@ -71,6 +74,9 @@ public void sendExtMsg(PrimaryDataMessageFromExt msg) { extSimAdapter.tell(new ScheduleDataServiceMessage(dataService), ActorRef.noSender()); } + /** + * Converts an input data package from an external simulation to a map of primary data + */ public Map createExtPrimaryDataMap( ExtInputDataPackage extInputDataPackage ) { diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java index eea10b2..8c38fdc 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java @@ -41,7 +41,11 @@ public class ExtResultData implements ExtOutputData { /** Actor reference to adapter that handles scheduler control flow in SIMONA */ private ActorRef extSimAdapter; + /** Map uuid to external id of grid related entities*/ private final Map gridResultAssetMapping; + + + /** Map uuid to external id of system participants*/ private final Map participantResultAssetMapping; private ZonedDateTime simulationStartTime; @@ -56,6 +60,7 @@ public ExtResultData( this.gridResultAssetMapping = gridResultAssetMapping; } + /** Sets the actor refs for data and control flow */ public void setActorRefs( ActorRef dataService, ActorRef dataServiceActivation, @@ -66,6 +71,7 @@ public void setActorRefs( this.extSimAdapter = extSimAdapter; } + /** Sets simulation data from config */ public void setSimulationData( ZonedDateTime simulationStartTime, Long powerFlowResolution diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java index 1f8a4fa..8ac6752 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java @@ -12,14 +12,23 @@ import static edu.ie3.util.quantities.PowerSystemUnits.PU; +/** + * Contains all results from SIMONA for a certain tick + */ public class ExtResultPackage implements ExtDataPackage { + /** Tick the package is meant for */ private final Long tick; + + /** Map external id to result from SIMONA + * ATTENTION: The time stamp of the result entities is not necessarily corresponding to the tick + */ private final Map simonaResultsMap; public ExtResultPackage( Long tick, - Map simonaResultsMap) { + Map simonaResultsMap + ) { this.tick = tick; this.simonaResultsMap = simonaResultsMap; } @@ -28,6 +37,7 @@ public Long getTick() { return tick; } + /** Returns the voltage deviation for certain asset, if this asset provided a {@link NodeResult} */ public double getVoltageDeviation(String assetId) { if (simonaResultsMap.get(assetId) instanceof NodeResult nodeResult) { ComparableQuantity vMagDev = Quantities.getQuantity(0, PU); @@ -40,6 +50,7 @@ public double getVoltageDeviation(String assetId) { } } + /** Returns the active power for certain asset, if this asset provided a {@link SystemParticipantResult} */ public double getActivePower(String assetId) { if (simonaResultsMap.get(assetId) instanceof SystemParticipantResult systemParticipantResult) { return systemParticipantResult.getP().getValue().doubleValue(); @@ -48,6 +59,7 @@ public double getActivePower(String assetId) { } } + /** Returns the reactive power for certain asset, if this asset provided a {@link SystemParticipantResult} */ public double getReactivePower(String assetId) { if (simonaResultsMap.get(assetId) instanceof SystemParticipantResult systemParticipantResult) { return systemParticipantResult.getQ().getValue().doubleValue(); @@ -56,6 +68,7 @@ public double getReactivePower(String assetId) { } } + /** Returns the line loading for certain asset, if this asset provided a {@link NodeResult} */ public double getLineLoading(String assetId) { throw new RuntimeException("LINE LOADING is not implemented yet!"); } From 72d1f1280c088eb4419fbd853ba1560d7c88de1c Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Tue, 23 Jul 2024 11:21:50 +0200 Subject: [PATCH 15/82] ext simulation with storage --- build.gradle | 2 +- .../DataQueueExtSimulationExtSimulator.java | 3 ++ .../api/data/results/ExtResultData.java | 24 ++++++------- .../api/data/results/ExtResultPackage.java | 5 +-- .../ontology/ProvideResultEntities.java | 6 ++-- .../primarydata/ExtPrimaryDataTest.groovy | 35 +++++++++++++++---- .../api/data/results/ExtResultDataTest.groovy | 34 +++++++++--------- 7 files changed, 69 insertions(+), 40 deletions(-) diff --git a/build.gradle b/build.gradle index b0a4274..aa13089 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ ext { // required for pekko scalaVersion = "2.13" scalaBinaryVersion = "2.13.14" - pekkoVersion = "1.0.3" + pekkoVersion = "1.0.2" } group = 'com.github.ie3-institute' diff --git a/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java b/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java index 44e807f..9e7bf69 100644 --- a/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java +++ b/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java @@ -2,6 +2,9 @@ import java.util.concurrent.LinkedBlockingQueue; +/** + * Data queue to allow data flow between SIMONA and a co-simulator + */ public class DataQueueExtSimulationExtSimulator { public final LinkedBlockingQueue receiverTriggerQueue = new LinkedBlockingQueue<>(); diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java index f8ebb45..2883c72 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java @@ -6,18 +6,15 @@ package edu.ie3.simona.api.data.results; +import edu.ie3.datamodel.models.result.ModelResultEntity; import edu.ie3.datamodel.models.result.NodeResult; -import edu.ie3.datamodel.models.result.ResultEntity; import edu.ie3.datamodel.models.result.system.SystemParticipantResult; -import edu.ie3.datamodel.models.result.ModelResultEntity; -import edu.ie3.simona.api.data.ExtData; import edu.ie3.simona.api.data.ExtOutputData; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import edu.ie3.simona.api.data.results.ontology.ProvideResultEntities; import edu.ie3.simona.api.data.results.ontology.RequestResultEntities; import edu.ie3.simona.api.data.results.ontology.ResultDataMessageFromExt; import edu.ie3.simona.api.data.results.ontology.ResultDataResponseMessageToExt; -import edu.ie3.simona.api.exceptions.ConvertionException; import org.apache.pekko.actor.ActorRef; import java.time.ZonedDateTime; @@ -84,6 +81,7 @@ public void setSimulationData( public ZonedDateTime getSimulationStartTime() { return simulationStartTime; } + public Long getPowerFlowResolution() { return powerFlowResolution; } @@ -101,7 +99,7 @@ public List getParticipantResultDataAssets() { } /** Method that an external simulation can request results from SIMONA as a list. */ - private List requestResultList(long tick) throws InterruptedException { + private List requestResultList(long tick) throws InterruptedException { sendExtMsg(new RequestResultEntities(tick)); return receiveWithType(ProvideResultEntities.class).results(); } @@ -109,19 +107,19 @@ private List requestResultList(long tick) throws InterruptedExcept /** * Method that an external simulation can request results from SIMONA as a map string to object. */ - public Map requestResults(long tick) + public Map requestResults(long tick) throws InterruptedException { return createResultMap(requestResultList(tick)); } - private Map createResultMap(List results) { - Map resultMap = new HashMap<>(); + private Map createResultMap(List results) { + Map resultMap = new HashMap<>(); results.forEach( - res -> { - if (res instanceof NodeResult) { - resultMap.put(gridResultAssetMapping.get(res.getInputModel()), res); - } else if (res instanceof SystemParticipantResult) { - resultMap.put(participantResultAssetMapping.get(res.getInputModel()), res); + result -> { + if (result instanceof NodeResult nodeResult) { + resultMap.put(gridResultAssetMapping.get(nodeResult.getInputModel()), nodeResult); + } else if (result instanceof SystemParticipantResult systemParticipantResult) { + resultMap.put(participantResultAssetMapping.get(systemParticipantResult.getInputModel()), systemParticipantResult); } else { throw new RuntimeException(); } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java index 8ac6752..653464e 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java @@ -1,5 +1,6 @@ package edu.ie3.simona.api.data.results; +import edu.ie3.datamodel.models.result.ModelResultEntity; import edu.ie3.datamodel.models.result.NodeResult; import edu.ie3.datamodel.models.result.ResultEntity; import edu.ie3.datamodel.models.result.system.SystemParticipantResult; @@ -23,11 +24,11 @@ public class ExtResultPackage implements ExtDataPackage { /** Map external id to result from SIMONA * ATTENTION: The time stamp of the result entities is not necessarily corresponding to the tick */ - private final Map simonaResultsMap; + private final Map simonaResultsMap; public ExtResultPackage( Long tick, - Map simonaResultsMap + Map simonaResultsMap ) { this.tick = tick; this.simonaResultsMap = simonaResultsMap; diff --git a/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java b/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java index 69e801d..61d436b 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java @@ -7,6 +7,8 @@ package edu.ie3.simona.api.data.results.ontology; import edu.ie3.datamodel.models.result.ModelResultEntity; + +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.UUID; @@ -17,11 +19,11 @@ public ProvideResultEntities() { this(new ArrayList<>()); } - public ProvideResultEntities(Map resultMap) { + public ProvideResultEntities(Map resultMap) { this(resultMap.values().stream().toList()); } - public ProvideResultEntities(List results) { + public ProvideResultEntities(List results) { this.results = results; } } diff --git a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy index 7163f0b..37c7f77 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy @@ -3,6 +3,7 @@ package edu.ie3.simona.api.data.primarydata import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.value.PValue import edu.ie3.datamodel.models.value.Value +import edu.ie3.simona.api.data.ExtInputDataValue import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData import edu.ie3.simona.api.exceptions.ConvertionException @@ -13,20 +14,42 @@ import spock.lang.Shared import spock.lang.Specification import tech.units.indriya.quantity.Quantities +import java.sql.ShardingKey + class ExtPrimaryDataTest extends Specification { @Shared ActorSystem actorSystem + @Shared + UUID inputUuid = UUID.fromString("22bea5fc-2cb2-4c61-beb9-b476e0107f52") + + + @Shared + HashMap extPrimaryDataMapping = Map.of( + "Pv", + inputUuid + ) + + class TestInputDataValue implements ExtInputDataValue { + private Value value + + TestInputDataValue(Value value) { + this.value = value + } - class PValuePrimaryDataFactory implements PrimaryDataFactory { + Value getValue() { + return value + } + } + class TestPrimaryDataFactory implements PrimaryDataFactory { @Override - Value convert(Object entity) throws ConvertionException { - if (entity.getClass() == PValue) { - return (PValue) entity + Value convert(ExtInputDataValue entity) throws ConvertionException { + if (entity instanceof TestInputDataValue) { + return entity.getValue(); } else { - throw new ConvertionException("This factory can convert PValue entities only!") + throw new ConvertionException("This factory can only convert PValue entities."); } } } @@ -44,7 +67,7 @@ class ExtPrimaryDataTest extends Specification { given: def dataService = new TestProbe(actorSystem) def extSimAdapter = new TestProbe(actorSystem) - def extPrimaryData = new ExtPrimaryData(dataService.ref(), extSimAdapter.ref(), new PValuePrimaryDataFactory()) + def extPrimaryData = new ExtPrimaryData(new TestPrimaryDataFactory(), extPrimaryDataMapping) def primaryData = new HashMap() def uuid = UUID.randomUUID() diff --git a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy index 5b0ee7c..a2fb59a 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy @@ -33,17 +33,11 @@ class ExtResultDataTest extends Specification { Quantities.getQuantity(10, StandardUnits.REACTIVE_POWER_IN) ) - class DefaultResultFactory implements ResultDataFactory { - - @Override - Object convert(ResultEntity entity) throws ConvertionException { - if (entity instanceof LoadResult) { - return "{\"p\":\"" + entity.p.toString() + ",\"q\":\"" + entity.q.toString() + "\"}" - } else { - throw new ConvertionException("This factory can convert LoadResult's only!") - } - } - } + @Shared + HashMap participantResultAssetMapping = Map.of(loadUuid, "Load") as HashMap + + @Shared + HashMap gridResultAssetMapping = [:] class WrongResultDataResponseMessageToExt implements ResultDataResponseMessageToExt {} @@ -59,23 +53,29 @@ class ExtResultDataTest extends Specification { def "ExtResultsData should request and receive results correctly as Object"() { given: def dataService = new TestProbe(actorSystem) + def dataServiceActivation = new TestProbe(actorSystem) def extSimAdapter = new TestProbe(actorSystem) - def resultDataFactory = new DefaultResultFactory() - def extResultData = new ExtResultData(dataService.ref(), extSimAdapter.ref(), resultDataFactory) + def extResultData = new ExtResultData(participantResultAssetMapping, gridResultAssetMapping) + extResultData.setActorRefs( + dataService.ref(), + dataServiceActivation.ref(), + extSimAdapter.ref() + ) def sentMsg = new ProvideResultEntities([loadResult]) when: // we need to queue the msg beforehand because the receive method is blocking extResultData.queueExtResponseMsg(sentMsg) - def receivedResults = extResultData.requestResultObjects() + def receivedResults = extResultData.requestResults(0L) then: - dataService.expectMsg(new RequestResultEntities()) + dataService.expectMsg(new RequestResultEntities(0L)) extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) - receivedResults.get(loadUuid.toString()) == resultDataFactory.convert(loadResult) + receivedResults.get("Load") == loadResult } + /* def "ExtResultsData should request and receive results correctly as a list of results entities"() { given: def dataService = new TestProbe(actorSystem) @@ -127,4 +127,6 @@ class ExtResultDataTest extends Specification { mapOfResults.size() == 1 mapOfResults.get(loadUuid.toString()) == "{\"p\":\"10 kW,\"q\":\"10 kvar\"}" } + + */ } From 6d98e9b7a8f8c7adacb56b7afad9a38537b896e3 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Wed, 24 Jul 2024 08:56:14 +0200 Subject: [PATCH 16/82] fixing tests --- .../simona/api/simulation/ExtSimulation.java | 2 +- .../primarydata/ExtPrimaryDataTest.groovy | 6 +- .../api/data/results/ExtResultDataTest.groovy | 10 ++- .../api/simulation/ExtSimulationSpec.groovy | 70 ++++++++++++++----- 4 files changed, 67 insertions(+), 21 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java index 6738710..a0bc12f 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java @@ -96,7 +96,7 @@ protected Optional doActivity(long tick, int phase) { } else if (phase == 2) { return doPostActivity(tick); } else { - return Optional.empty(); + throw new IllegalArgumentException("ExtSimulation can only handle phase 1 and 2!"); } } diff --git a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy index 37c7f77..6dc3b10 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy @@ -68,6 +68,10 @@ class ExtPrimaryDataTest extends Specification { def dataService = new TestProbe(actorSystem) def extSimAdapter = new TestProbe(actorSystem) def extPrimaryData = new ExtPrimaryData(new TestPrimaryDataFactory(), extPrimaryDataMapping) + extPrimaryData.setActorRefs( + dataService.ref(), + extSimAdapter.ref() + ) def primaryData = new HashMap() def uuid = UUID.randomUUID() @@ -76,7 +80,7 @@ class ExtPrimaryDataTest extends Specification { def convertedPrimaryData = Map.of(uuid, new PValue(Quantities.getQuantity(500.0, StandardUnits.ACTIVE_POWER_IN))) when: - extPrimaryData.providePrimaryData(0, primaryData) + extPrimaryData.providePrimaryData(0, convertedPrimaryData) then: dataService.expectMsg(new ProvidePrimaryData(0, convertedPrimaryData)) diff --git a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy index a2fb59a..fe06dc3 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy @@ -79,8 +79,14 @@ class ExtResultDataTest extends Specification { def "ExtResultsData should request and receive results correctly as a list of results entities"() { given: def dataService = new TestProbe(actorSystem) + def dataServiceActivation = new TestProbe(actorSystem) def extSimAdapter = new TestProbe(actorSystem) - def extResultData = new ExtResultData(dataService.ref(), extSimAdapter.ref(), new DefaultResultFactory()) + def extResultData = new ExtResultData(participantResultAssetMapping, gridResultAssetMapping) + extResultData.setActorRefs( + dataService.ref(), + dataServiceActivation.ref(), + extSimAdapter.ref() + ) def sentMsg = new ProvideResultEntities([loadResult]) @@ -129,4 +135,4 @@ class ExtResultDataTest extends Specification { } */ -} +} \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy b/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy index c1fd13b..10e85bd 100644 --- a/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy +++ b/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy @@ -42,9 +42,19 @@ class ExtSimulationSpec extends Specification { } @Override - protected Optional doActivity(long tick) { + protected Optional doPreActivity(long tick) { return this.activationReturnTick } + + @Override + protected Optional doPostActivity(long tick) { + return this.activationReturnTick + } + + @Override + List getDataConnections() { + return new ArrayList() + } } def setupSpec() { @@ -64,36 +74,36 @@ class ExtSimulationSpec extends Specification { given: def tick = -1L def newTick = 0L - def testProbe = new TestProbe(actorSystem) - def extSimData = new ExtSimAdapterData(testProbe.ref(), new String[0]) + def extSimAdapter = new TestProbe(actorSystem) + def extSimData = new ExtSimAdapterData(Map.of(1, extSimAdapter.ref()), new String[0]) def extSim = new TestSimulation(newTick, Optional.of(-2L)) extSim.setup(extSimData, new ArrayList()) when: - extSimData.queueExtMsg(new ActivationMessage(tick)) + extSimData.queueExtMsg(new ActivationMessage(tick, 1)) def finishedActual = handleMessage.invoke(extSim) then: finishedActual == false - testProbe.expectMsg(new CompletionMessage(Optional.of(newTick))) + extSimAdapter.expectMsg(new CompletionMessage(Optional.of(newTick), 1)) } def "An ExtSimulation should handle activation and return given new triggers"() { given: - def testProbe = new TestProbe(actorSystem) - def extSimData = new ExtSimAdapterData(testProbe.ref(), new String[0]) + def extSimAdapter = new TestProbe(actorSystem) + def extSimData = new ExtSimAdapterData(Map.of(1, extSimAdapter.ref()), new String[0]) def newTickOpt = newTick.isEmpty() ? Optional.empty() : Optional.of(newTick.first()) def extSim = new TestSimulation(-2L, newTickOpt) extSim.setup(extSimData, new ArrayList()) when: - extSimData.queueExtMsg(new ActivationMessage(tick)) + extSimData.queueExtMsg(new ActivationMessage(tick, 1)) def finishedActual = handleMessage.invoke(extSim) then: finishedActual == finished - testProbe.expectMsg(new CompletionMessage(newTickOpt)) + extSimAdapter.expectMsg(new CompletionMessage(newTickOpt, 1)) where: tick | newTick || finished @@ -103,20 +113,41 @@ class ExtSimulationSpec extends Specification { 10800L | [] || true } + def "An ExtSimulation throw an exception if a wrong phase was triggered"() { + given: + def tick = 0L + def newTick = 900L + def extSimAdapter = new TestProbe(actorSystem) + def extSimData = new ExtSimAdapterData(Map.of(1, extSimAdapter.ref()), new String[0]) + def extSim = new TestSimulation(tick, Optional.of(newTick)) + extSim.setup(extSimData, new ArrayList()) + + when: + extSimData.queueExtMsg(new ActivationMessage(tick, 0)) + handleMessage.invoke(extSim) + + then: + Exception ex = thrown() + // since we call a private method through reflection, + // our expected exception is wrapped in an InvocationTargetException + ex.getCause().getClass() == IllegalArgumentException + extSimAdapter.expectNoMessage() + } + def "An ExtSimulation should handle termination properly"() { given: - def testProbe = new TestProbe(actorSystem) - def extSimData = new ExtSimAdapterData(testProbe.ref(), new String[0]) + def extSimAdapter = new TestProbe(actorSystem) + def extSimData = new ExtSimAdapterData(Map.of(1, extSimAdapter.ref()), new String[0]) def extSim = new TestSimulation(-1L, Optional.empty()) extSim.setup(extSimData, new ArrayList()) when: - extSimData.queueExtMsg(new TerminationMessage(simlulationSuccessful)) + extSimData.queueExtMsg(new TerminationMessage(simlulationSuccessful, 1)) def finishedActual = handleMessage.invoke(extSim) then: finishedActual == finished - testProbe.expectMsg(new TerminationCompleted()) + extSimAdapter.expectMsg(new TerminationCompleted(1)) where: simlulationSuccessful || finished @@ -124,12 +155,17 @@ class ExtSimulationSpec extends Specification { true || true } - class UnknownMessage implements ControlMessageToExt {} + class UnknownMessage implements ControlMessageToExt { + @Override + int getPhase() { + return 0 + } + } def "An ExtSimulation should handle unknown messages by throwing an exception"() { given: - def testProbe = new TestProbe(actorSystem) - def extSimData = new ExtSimAdapterData(testProbe.ref(), new String[0]) + def extSimAdapter = new TestProbe(actorSystem) + def extSimData = new ExtSimAdapterData(Map.of(1, extSimAdapter.ref()), new String[0]) def extSim = new TestSimulation(-1L, Optional.empty()) extSim.setup(extSimData, new ArrayList()) @@ -142,6 +178,6 @@ class ExtSimulationSpec extends Specification { // since we call a private method through reflection, // our expected exception is wrapped in an InvocationTargetException ex.getCause().getClass() == IllegalArgumentException - testProbe.expectNoMessage() + extSimAdapter.expectNoMessage() } } From ebfeda0d018a4e0b4f94e6eaedc14e2b16d5af14 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Wed, 24 Jul 2024 09:51:47 +0200 Subject: [PATCH 17/82] improve docs --- .../DataQueueExtSimulationExtSimulator.java | 26 +-- .../ie3/simona/api/data/ExtDataPackage.java | 6 + .../simona/api/data/ExtInputDataPackage.java | 44 ++--- .../simona/api/data/ExtInputDataValue.java | 6 + .../ie3/simona/api/data/ExtOutputData.java | 6 + .../ie3/simona/api/data/em/EmDataFactory.java | 1 - .../edu/ie3/simona/api/data/em/ExtEmData.java | 37 ++--- .../api/data/em/ExtEmDataSimulation.java | 7 +- .../api/data/em/ontology/ProvideEmData.java | 7 +- .../api/data/primarydata/ExtPrimaryData.java | 27 ++-- .../primarydata/ExtPrimaryDataSimulation.java | 7 +- .../ontology/ProvidePrimaryData.java | 5 +- .../api/data/results/ExtResultData.java | 49 +++--- .../data/results/ExtResultDataSimulation.java | 7 +- .../api/data/results/ExtResultPackage.java | 122 +++++++------- .../ontology/ProvideResultEntities.java | 22 +-- .../ontology/RequestResultEntities.java | 2 +- .../api/simulation/ExtSimAdapterData.java | 6 +- .../simona/api/simulation/ExtSimulation.java | 5 +- .../simulation/mapping/ExtEntityEntry.java | 55 ++++--- .../simulation/mapping/ExtEntityFactory.java | 52 +++--- .../simulation/mapping/ExtEntityMapping.java | 77 +++++---- .../mapping/ExtEntityMappingCsvSource.java | 153 +++++++++--------- .../mapping/ExtEntityMappingSource.java | 15 +- .../ontology/ActivationMessage.java | 13 +- .../ontology/CompletionMessage.java | 14 +- .../ontology/ControlMessageToExt.java | 2 +- .../ControlResponseMessageFromExt.java | 2 +- .../ontology/TerminationCompleted.java | 8 +- .../ontology/TerminationMessage.java | 11 +- .../api/data/results/ExtResultDataTest.groovy | 44 ++--- 31 files changed, 437 insertions(+), 401 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java b/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java index 9e7bf69..883ed80 100644 --- a/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java +++ b/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java @@ -1,20 +1,24 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + package edu.ie3.simona.api.data; import java.util.concurrent.LinkedBlockingQueue; -/** - * Data queue to allow data flow between SIMONA and a co-simulator - */ +/** Data queue to allow data flow between SIMONA and a co-simulator */ public class DataQueueExtSimulationExtSimulator { - public final LinkedBlockingQueue receiverTriggerQueue = new LinkedBlockingQueue<>(); + private final LinkedBlockingQueue receiverTriggerQueue = new LinkedBlockingQueue<>(); - public DataQueueExtSimulationExtSimulator() {} + public DataQueueExtSimulationExtSimulator() {} - public void queueData(V data) throws InterruptedException { - this.receiverTriggerQueue.put(data); - } + public void queueData(V data) throws InterruptedException { + this.receiverTriggerQueue.put(data); + } - public V takeData() throws InterruptedException { - return this.receiverTriggerQueue.take(); - } + public V takeData() throws InterruptedException { + return this.receiverTriggerQueue.take(); + } } diff --git a/src/main/java/edu/ie3/simona/api/data/ExtDataPackage.java b/src/main/java/edu/ie3/simona/api/data/ExtDataPackage.java index 24e4209..8171e67 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtDataPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtDataPackage.java @@ -1,3 +1,9 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + package edu.ie3.simona.api.data; public interface ExtDataPackage {} diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java index dbe4169..b32e9bd 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java @@ -1,30 +1,38 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + package edu.ie3.simona.api.data; import java.util.HashMap; import java.util.Map; -/** - * Contains all inputs for SIMONA for a certain tick - */ +/** Contains all inputs for SIMONA for a certain tick */ public class ExtInputDataPackage implements ExtDataPackage { - /** Map external id to input for SIMONA */ - private final Map dataMap; + /** Map external id to input for SIMONA */ + private final Map dataMap; + + public ExtInputDataPackage(Map dataMap) { + this.dataMap = dataMap; + } - public ExtInputDataPackage(Map dataMap) { - this.dataMap = dataMap; - } + public ExtInputDataPackage() { + this(new HashMap<>()); + } - public ExtInputDataPackage() { - this(new HashMap<>()); - } + public Map getSimonaInputMap() { + return dataMap; + } - public Map getSimonaInputMap() { - return dataMap; - } + /** Adds a value to the input map */ + public void addValue(String id, ExtInputDataValue value) { + dataMap.put(id, value); + } - /** Adds a value to the input map */ - public void addValue(String id, ExtInputDataValue value) { - dataMap.put(id, value); - } + public String toString() { + return dataMap.toString(); + } } diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataValue.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataValue.java index 5b521aa..6217396 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtInputDataValue.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataValue.java @@ -1,3 +1,9 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + package edu.ie3.simona.api.data; public interface ExtInputDataValue {} diff --git a/src/main/java/edu/ie3/simona/api/data/ExtOutputData.java b/src/main/java/edu/ie3/simona/api/data/ExtOutputData.java index 4179d37..e62ed16 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtOutputData.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtOutputData.java @@ -1,3 +1,9 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + package edu.ie3.simona.api.data; public interface ExtOutputData extends ExtData {} diff --git a/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java b/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java index f75a5b7..2dd9862 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java +++ b/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java @@ -7,7 +7,6 @@ package edu.ie3.simona.api.data.em; import edu.ie3.datamodel.models.value.PValue; -import edu.ie3.datamodel.models.value.Value; import edu.ie3.simona.api.data.ExtInputDataValue; import edu.ie3.simona.api.exceptions.ConvertionException; diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java index 34c04aa..59a9b49 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java @@ -13,12 +13,11 @@ import edu.ie3.simona.api.data.em.ontology.ProvideEmData; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import edu.ie3.simona.api.exceptions.ConvertionException; -import org.apache.pekko.actor.ActorRef; - import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; +import org.apache.pekko.actor.ActorRef; public class ExtEmData implements ExtData { @@ -34,25 +33,21 @@ public class ExtEmData implements ExtData { /** Factory, that converts external input data to set points for EM agents */ private final EmDataFactory emDataFactory; - public ExtEmData( - EmDataFactory emDataFactory, - Map extEmMapping - ) { + public ExtEmData(EmDataFactory emDataFactory, Map extEmMapping) { this.emDataFactory = emDataFactory; this.extEmMapping = extEmMapping; } /** Sets the actor refs for data and control flow */ - public void setActorRefs( - ActorRef dataService, - ActorRef extSimAdapter - ) { + public void setActorRefs(ActorRef dataService, ActorRef extSimAdapter) { this.dataService = dataService; this.extSimAdapter = extSimAdapter; } /** Returns a list of the uuids of the em agents that expect external set points */ - public List getControlledEms() { return extEmMapping.values().stream().toList(); } + public List getControlledEms() { + return extEmMapping.values().stream().toList(); + } public EmDataFactory getEmDataFactory() { return emDataFactory; @@ -76,27 +71,21 @@ public void sendExtMsg(EmDataMessageFromExt msg) { extSimAdapter.tell(new ScheduleDataServiceMessage(dataService), ActorRef.noSender()); } - /** - * Converts an input data package from an external simulation to a map of set points - */ - public Map createExtEmDataMap( - ExtInputDataPackage extInputDataPackage - ) { + /** Converts an input data package from an external simulation to a map of set points */ + public Map createExtEmDataMap(ExtInputDataPackage extInputDataPackage) { Map emDataForSimona = new HashMap<>(); - extInputDataPackage.getSimonaInputMap().forEach( + extInputDataPackage + .getSimonaInputMap() + .forEach( (id, extInput) -> { if (extEmMapping.containsKey(id)) { try { - emDataForSimona.put( - extEmMapping.get(id), - emDataFactory.convert(extInput) - ); + emDataForSimona.put(extEmMapping.get(id), emDataFactory.convert(extInput)); } catch (ConvertionException e) { throw new RuntimeException(e); } } - } - ); + }); return emDataForSimona; } } diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java index ae21209..dfc9937 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java @@ -1,6 +1,11 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + package edu.ie3.simona.api.data.em; import edu.ie3.simona.api.data.ExtDataSimulation; -import edu.ie3.simona.api.data.em.ExtEmData; public interface ExtEmDataSimulation extends ExtDataSimulation {} diff --git a/src/main/java/edu/ie3/simona/api/data/em/ontology/ProvideEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ontology/ProvideEmData.java index d39c9da..1f182a1 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ontology/ProvideEmData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ontology/ProvideEmData.java @@ -7,13 +7,8 @@ package edu.ie3.simona.api.data.em.ontology; import edu.ie3.datamodel.models.value.PValue; -import edu.ie3.datamodel.models.value.Value; -import edu.ie3.simona.api.data.primarydata.ontology.PrimaryDataMessageFromExt; - import java.util.Map; import java.util.UUID; /** Message that provides primary data from an external primary data simulation */ -public record ProvideEmData( - long tick, - Map emData) implements EmDataMessageFromExt {} +public record ProvideEmData(long tick, Map emData) implements EmDataMessageFromExt {} diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java index 2243e7a..1b5568b 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java @@ -33,16 +33,14 @@ public class ExtPrimaryData implements ExtData { /** Assets that provide primary data to SIMONA */ private final Map extPrimaryDataMapping; - public ExtPrimaryData(PrimaryDataFactory primaryDataFactory, Map extPrimaryDataMapping) { + public ExtPrimaryData( + PrimaryDataFactory primaryDataFactory, Map extPrimaryDataMapping) { this.primaryDataFactory = primaryDataFactory; this.extPrimaryDataMapping = extPrimaryDataMapping; } /** Sets the actor refs for data and control flow */ - public void setActorRefs( - ActorRef dataService, - ActorRef extSimAdapter - ) { + public void setActorRefs(ActorRef dataService, ActorRef extSimAdapter) { this.dataService = dataService; this.extSimAdapter = extSimAdapter; } @@ -74,27 +72,22 @@ public void sendExtMsg(PrimaryDataMessageFromExt msg) { extSimAdapter.tell(new ScheduleDataServiceMessage(dataService), ActorRef.noSender()); } - /** - * Converts an input data package from an external simulation to a map of primary data - */ - public Map createExtPrimaryDataMap( - ExtInputDataPackage extInputDataPackage - ) { + /** Converts an input data package from an external simulation to a map of primary data */ + public Map createExtPrimaryDataMap(ExtInputDataPackage extInputDataPackage) { Map primaryDataForSimona = new HashMap<>(); - extInputDataPackage.getSimonaInputMap().forEach( + extInputDataPackage + .getSimonaInputMap() + .forEach( (id, extInput) -> { if (extPrimaryDataMapping.containsKey(id)) { try { primaryDataForSimona.put( - extPrimaryDataMapping.get(id), - primaryDataFactory.convert(extInput) - ); + extPrimaryDataMapping.get(id), primaryDataFactory.convert(extInput)); } catch (ConvertionException e) { throw new RuntimeException(e); } } - } - ); + }); return primaryDataForSimona; } } diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java index 6282159..6e646a8 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java @@ -1,6 +1,11 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + package edu.ie3.simona.api.data.primarydata; import edu.ie3.simona.api.data.ExtDataSimulation; -import edu.ie3.simona.api.data.primarydata.ExtPrimaryData; public interface ExtPrimaryDataSimulation extends ExtDataSimulation {} diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java index 05eb85b..a87d9f7 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java @@ -11,6 +11,5 @@ import java.util.UUID; /** Message that provides primary data from an external primary data simulation */ -public record ProvidePrimaryData( - long tick, - Map primaryData) implements PrimaryDataMessageFromExt {} +public record ProvidePrimaryData(long tick, Map primaryData) + implements PrimaryDataMessageFromExt {} diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java index 2883c72..5d1ea70 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java @@ -15,14 +15,13 @@ import edu.ie3.simona.api.data.results.ontology.RequestResultEntities; import edu.ie3.simona.api.data.results.ontology.ResultDataMessageFromExt; import edu.ie3.simona.api.data.results.ontology.ResultDataResponseMessageToExt; -import org.apache.pekko.actor.ActorRef; - import java.time.ZonedDateTime; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; import java.util.concurrent.LinkedBlockingQueue; +import org.apache.pekko.actor.ActorRef; public class ExtResultData implements ExtOutputData { @@ -39,11 +38,10 @@ public class ExtResultData implements ExtOutputData { /** Actor reference to adapter that handles scheduler control flow in SIMONA */ private ActorRef extSimAdapter; - /** Map uuid to external id of grid related entities*/ + /** Map uuid to external id of grid related entities */ private final Map gridResultAssetMapping; - - /** Map uuid to external id of system participants*/ + /** Map uuid to external id of system participants */ private final Map participantResultAssetMapping; private ZonedDateTime simulationStartTime; @@ -51,29 +49,21 @@ public class ExtResultData implements ExtOutputData { private Long powerFlowResolution; public ExtResultData( - Map participantResultAssetMapping, - Map gridResultAssetMapping - ) { + Map participantResultAssetMapping, Map gridResultAssetMapping) { this.participantResultAssetMapping = participantResultAssetMapping; this.gridResultAssetMapping = gridResultAssetMapping; } /** Sets the actor refs for data and control flow */ public void setActorRefs( - ActorRef dataService, - ActorRef dataServiceActivation, - ActorRef extSimAdapter - ) { + ActorRef dataService, ActorRef dataServiceActivation, ActorRef extSimAdapter) { this.dataService = dataService; this.dataServiceActivation = dataServiceActivation; this.extSimAdapter = extSimAdapter; } /** Sets simulation data from config */ - public void setSimulationData( - ZonedDateTime simulationStartTime, - Long powerFlowResolution - ) { + public void setSimulationData(ZonedDateTime simulationStartTime, Long powerFlowResolution) { this.simulationStartTime = simulationStartTime; this.powerFlowResolution = powerFlowResolution; } @@ -107,24 +97,25 @@ private List requestResultList(long tick) throws InterruptedE /** * Method that an external simulation can request results from SIMONA as a map string to object. */ - public Map requestResults(long tick) - throws InterruptedException { + public Map requestResults(long tick) throws InterruptedException { return createResultMap(requestResultList(tick)); } - private Map createResultMap(List results) { + protected Map createResultMap(List results) { Map resultMap = new HashMap<>(); results.forEach( - result -> { - if (result instanceof NodeResult nodeResult) { - resultMap.put(gridResultAssetMapping.get(nodeResult.getInputModel()), nodeResult); - } else if (result instanceof SystemParticipantResult systemParticipantResult) { - resultMap.put(participantResultAssetMapping.get(systemParticipantResult.getInputModel()), systemParticipantResult); - } else { - throw new RuntimeException(); - } - } - ); + result -> { + if (result instanceof NodeResult nodeResult) { + resultMap.put(gridResultAssetMapping.get(nodeResult.getInputModel()), nodeResult); + } else if (result instanceof SystemParticipantResult systemParticipantResult) { + resultMap.put( + participantResultAssetMapping.get(systemParticipantResult.getInputModel()), + systemParticipantResult); + } else { + throw new IllegalArgumentException( + "ExtResultData can only handle NodeResult's and SystemParticipantResult's!"); + } + }); return resultMap; } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java index cc15111..3947f36 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java @@ -1,6 +1,11 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + package edu.ie3.simona.api.data.results; import edu.ie3.simona.api.data.ExtDataSimulation; -import edu.ie3.simona.api.data.results.ExtResultData; public interface ExtResultDataSimulation extends ExtDataSimulation {} diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java index 653464e..92155b6 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java @@ -1,80 +1,88 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + package edu.ie3.simona.api.data.results; +import static edu.ie3.util.quantities.PowerSystemUnits.PU; + import edu.ie3.datamodel.models.result.ModelResultEntity; import edu.ie3.datamodel.models.result.NodeResult; -import edu.ie3.datamodel.models.result.ResultEntity; import edu.ie3.datamodel.models.result.system.SystemParticipantResult; import edu.ie3.simona.api.data.ExtDataPackage; +import java.util.Map; +import javax.measure.quantity.Dimensionless; import tech.units.indriya.ComparableQuantity; import tech.units.indriya.quantity.Quantities; -import javax.measure.quantity.Dimensionless; -import java.util.Map; - -import static edu.ie3.util.quantities.PowerSystemUnits.PU; - -/** - * Contains all results from SIMONA for a certain tick - */ +/** Contains all results from SIMONA for a certain tick */ public class ExtResultPackage implements ExtDataPackage { - /** Tick the package is meant for */ - private final Long tick; + /** Tick the package is meant for */ + private final Long tick; - /** Map external id to result from SIMONA - * ATTENTION: The time stamp of the result entities is not necessarily corresponding to the tick - */ - private final Map simonaResultsMap; + /** + * Map external id to result from SIMONA ATTENTION: The time stamp of the result entities is not + * necessarily corresponding to the tick + */ + private final Map simonaResultsMap; - public ExtResultPackage( - Long tick, - Map simonaResultsMap - ) { - this.tick = tick; - this.simonaResultsMap = simonaResultsMap; - } + public ExtResultPackage(Long tick, Map simonaResultsMap) { + this.tick = tick; + this.simonaResultsMap = simonaResultsMap; + } - public Long getTick() { - return tick; - } + public Long getTick() { + return tick; + } - /** Returns the voltage deviation for certain asset, if this asset provided a {@link NodeResult} */ - public double getVoltageDeviation(String assetId) { - if (simonaResultsMap.get(assetId) instanceof NodeResult nodeResult) { - ComparableQuantity vMagDev = Quantities.getQuantity(0, PU); - vMagDev = Quantities.getQuantity(0, PU) - .add(nodeResult.getvMag() - .subtract(Quantities.getQuantity(1.0, PU))); - return vMagDev.getValue().doubleValue(); - } else { - throw new RuntimeException("VOLTAGE DEVIATION is only available for NodeResult's!"); - } + /** + * Returns the voltage deviation for certain asset, if this asset provided a {@link NodeResult} + */ + public double getVoltageDeviation(String assetId) { + if (simonaResultsMap.get(assetId) instanceof NodeResult nodeResult) { + ComparableQuantity vMagDev = Quantities.getQuantity(0, PU); + vMagDev = + Quantities.getQuantity(0, PU) + .add(nodeResult.getvMag().subtract(Quantities.getQuantity(1.0, PU))); + return vMagDev.getValue().doubleValue(); + } else { + throw new RuntimeException("VOLTAGE DEVIATION is only available for NodeResult's!"); } + } - /** Returns the active power for certain asset, if this asset provided a {@link SystemParticipantResult} */ - public double getActivePower(String assetId) { - if (simonaResultsMap.get(assetId) instanceof SystemParticipantResult systemParticipantResult) { - return systemParticipantResult.getP().getValue().doubleValue(); - } else { - throw new RuntimeException("ACTIVE POWER is only available for SystemParticipantResult's!"); - } + /** + * Returns the active power for certain asset, if this asset provided a {@link + * SystemParticipantResult} + */ + public double getActivePower(String assetId) { + if (simonaResultsMap.get(assetId) instanceof SystemParticipantResult systemParticipantResult) { + return systemParticipantResult.getP().getValue().doubleValue(); + } else { + throw new RuntimeException("ACTIVE POWER is only available for SystemParticipantResult's!"); } + } - /** Returns the reactive power for certain asset, if this asset provided a {@link SystemParticipantResult} */ - public double getReactivePower(String assetId) { - if (simonaResultsMap.get(assetId) instanceof SystemParticipantResult systemParticipantResult) { - return systemParticipantResult.getQ().getValue().doubleValue(); - } else { - throw new RuntimeException("REACTIVE POWER is only available for SystemParticipantResult's!"); - } + /** + * Returns the reactive power for certain asset, if this asset provided a {@link + * SystemParticipantResult} + */ + public double getReactivePower(String assetId) { + if (simonaResultsMap.get(assetId) instanceof SystemParticipantResult systemParticipantResult) { + return systemParticipantResult.getQ().getValue().doubleValue(); + } else { + throw new RuntimeException("REACTIVE POWER is only available for SystemParticipantResult's!"); } + } - /** Returns the line loading for certain asset, if this asset provided a {@link NodeResult} */ - public double getLineLoading(String assetId) { - throw new RuntimeException("LINE LOADING is not implemented yet!"); - } + /** Returns the line loading for certain asset, if this asset provided a {@link NodeResult} */ + public double getLineLoading(String assetId) { + throw new RuntimeException("LINE LOADING is not implemented yet!"); + } - public String toString() { - return simonaResultsMap.toString(); - } + public String toString() { + return simonaResultsMap.toString(); + } } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java b/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java index 61d436b..a0070fe 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java @@ -7,23 +7,23 @@ package edu.ie3.simona.api.data.results.ontology; import edu.ie3.datamodel.models.result.ModelResultEntity; - import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.UUID; /** Provides a list of results from SIMONA to an external simulation. */ -public record ProvideResultEntities(List results) implements ResultDataResponseMessageToExt { - public ProvideResultEntities() { - this(new ArrayList<>()); - } +public record ProvideResultEntities(List results) + implements ResultDataResponseMessageToExt { + public ProvideResultEntities() { + this(new ArrayList<>()); + } - public ProvideResultEntities(Map resultMap) { - this(resultMap.values().stream().toList()); - } + public ProvideResultEntities(Map resultMap) { + this(resultMap.values().stream().toList()); + } - public ProvideResultEntities(List results) { - this.results = results; - } + public ProvideResultEntities(List results) { + this.results = results; + } } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ontology/RequestResultEntities.java b/src/main/java/edu/ie3/simona/api/data/results/ontology/RequestResultEntities.java index 67896cb..8ef656b 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ontology/RequestResultEntities.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ontology/RequestResultEntities.java @@ -7,4 +7,4 @@ package edu.ie3.simona.api.data.results.ontology; /** Request calculated results from SIMONA in the current tick */ -public record RequestResultEntities(Long tick) implements ResultDataMessageFromExt {} \ No newline at end of file +public record RequestResultEntities(Long tick) implements ResultDataMessageFromExt {} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java b/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java index 186e9ea..014202d 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java @@ -8,10 +8,8 @@ import edu.ie3.simona.api.simulation.ontology.ControlMessageToExt; import edu.ie3.simona.api.simulation.ontology.ControlResponseMessageFromExt; - import java.util.Map; import java.util.concurrent.LinkedBlockingQueue; - import org.apache.pekko.actor.ActorRef; public class ExtSimAdapterData { @@ -20,7 +18,9 @@ public class ExtSimAdapterData { public final LinkedBlockingQueue receiveMessageQueue = new LinkedBlockingQueue<>(); - /** Actor references to the adapters for the phases that handles scheduler control flow in SIMONA */ + /** + * Actor references to the adapters for the phases that handles scheduler control flow in SIMONA + */ private final Map extSimAdapters; /** CLI arguments with which SIMONA is initiated */ diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java index a0bc12f..72ec3b0 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java @@ -6,7 +6,6 @@ package edu.ie3.simona.api.simulation; -import edu.ie3.simona.api.data.ExtDataSimulation; import edu.ie3.simona.api.data.ExtData; import edu.ie3.simona.api.data.ev.ExtEvData; import edu.ie3.simona.api.data.ev.ExtEvSimulation; @@ -60,7 +59,9 @@ private boolean takeAndHandleMessage() throws InterruptedException { newTrigger = Optional.of(initialize()); } else { newTrigger = - doActivity(activationMessage.tick(), currentPhase); // this is blocking until processing of this tick has finished + doActivity( + activationMessage.tick(), + currentPhase); // this is blocking until processing of this tick has finished } data.send(new CompletionMessage(newTrigger, currentPhase)); diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityEntry.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityEntry.java index 5806844..f1c267e 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityEntry.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityEntry.java @@ -1,27 +1,46 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + package edu.ie3.simona.api.simulation.mapping; import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme; import edu.ie3.datamodel.models.input.InputEntity; - import java.util.UUID; +/** + * Package of an external asset with all information for the mapping + * + * @param uuid SIMONA uuid + * @param id external id + * @param columnScheme data types the external asset expects + * @param resultType data types the external asset expects + */ public record ExtEntityEntry( - UUID uuid, - String id, - ColumnScheme columnScheme, - String resultType -) implements InputEntity { - public static final String EXT_INPUT = "input"; - public static final String EXT_RESULT_PARTICIPANT = "result_participant"; - public static final String EXT_RESULT_GRID = "result_grid"; - + UUID uuid, + String id, + ColumnScheme columnScheme, // FIXME: placeholder -> ColumnScheme should handle more data types + String resultType) + implements InputEntity { + public static final String EXT_INPUT = "input"; + public static final String EXT_RESULT_PARTICIPANT = "result_participant"; + public static final String EXT_RESULT_GRID = "result_grid"; - public String toString() { - return "ExtEntityEntry={" - + "UUID=" + uuid() + ", " - + "ExtId=" + id() + ", " - + "ColumnScheme=" + columnScheme() + ", " - + "ResultType=" + resultType() - + "}"; - } + public String toString() { + return "ExtEntityEntry={" + + "UUID=" + + uuid() + + ", " + + "ExtId=" + + id() + + ", " + + "ColumnScheme=" + + columnScheme() + + ", " + + "ResultType=" + + resultType() + + "}"; + } } diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java index 15aed5d..f96de44 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java @@ -1,40 +1,42 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + package edu.ie3.simona.api.simulation.mapping; import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.io.factory.EntityFactory; import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme; - import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; public class ExtEntityFactory extends EntityFactory { - public static final String SIMONA_UUID = "uuid"; - public static final String EXT_ID = "id"; - public static final String COLUMN_SCHEME = "columnScheme"; - public static final String DATA_TYPE = "dataType"; + public static final String SIMONA_UUID = "uuid"; + public static final String EXT_ID = "id"; + public static final String COLUMN_SCHEME = "columnScheme"; + public static final String DATA_TYPE = "dataType"; - @Override - protected List> getFields(Class entityClass) { - return Collections.singletonList( - Stream.of(SIMONA_UUID, EXT_ID, COLUMN_SCHEME, DATA_TYPE).collect(Collectors.toSet())); - } + @Override + protected List> getFields(Class entityClass) { + return Collections.singletonList( + Stream.of(SIMONA_UUID, EXT_ID, COLUMN_SCHEME, DATA_TYPE).collect(Collectors.toSet())); + } - @Override - protected ExtEntityEntry buildModel( - EntityData data - ) { - UUID simonaUuid = data.getUUID(SIMONA_UUID); - String extId = data.getField(EXT_ID); - Optional columnScheme = ColumnScheme.parse(COLUMN_SCHEME); - String inputType = data.getField(DATA_TYPE); + @Override + protected ExtEntityEntry buildModel(EntityData data) { + UUID simonaUuid = data.getUUID(SIMONA_UUID); + String extId = data.getField(EXT_ID); + Optional columnScheme = ColumnScheme.parse(COLUMN_SCHEME); + String inputType = data.getField(DATA_TYPE); - return new ExtEntityEntry( - simonaUuid, - extId, - columnScheme.get(), - inputType - ); - } + return new ExtEntityEntry( + simonaUuid, + extId, + columnScheme.get(), // FIXME: Interim version -> ColumnScheme should handle more data types + inputType); + } } diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMapping.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMapping.java index 03fae54..e964a17 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMapping.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMapping.java @@ -1,44 +1,53 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + package edu.ie3.simona.api.simulation.mapping; import java.util.*; +/** Contains the mapping between SIMONA uuid and external id and the data type the assets hold */ public class ExtEntityMapping { - private final List extEntities; + private final List extEntities; - public ExtEntityMapping( - List extEntityEntryList - ) { - this.extEntities = extEntityEntryList; - } + public ExtEntityMapping(List extEntityEntryList) { + this.extEntities = extEntityEntryList; + } - public Map getExtIdUuidMapping( - String dataType - ) { - Map extIdUuidMapping = new HashMap<>(); - extEntities.forEach( - ent -> { - if (Objects.equals(ent.resultType(), dataType)) { - extIdUuidMapping.put( - ent.id(), ent.uuid() - ); - } - } - ); - return extIdUuidMapping; - } + /** + * Mapping external id to SIMONA uuid + * + * @param dataType data type the external asset expects + * @return Mapping external id to SIMONA uuid + */ + public Map getExtIdUuidMapping(String dataType) { + Map extIdUuidMapping = new HashMap<>(); + extEntities.forEach( + ent -> { + if (Objects.equals(ent.resultType(), dataType)) { + extIdUuidMapping.put(ent.id(), ent.uuid()); + } + }); + return extIdUuidMapping; + } - public Map getExtUuidIdMapping( - String dataType - ) { - Map extUuidIdMapping = new HashMap<>(); - extEntities.forEach( - ent -> { - if (Objects.equals(ent.resultType(), dataType)) { - extUuidIdMapping.put(ent.uuid(), ent.id()); - } - } - ); - return extUuidIdMapping; - } + /** + * Mapping SIMONA uuid to external id + * + * @param dataType data type the external asset expects + * @return Mapping SIMONA uuid to external id + */ + public Map getExtUuidIdMapping(String dataType) { + Map extUuidIdMapping = new HashMap<>(); + extEntities.forEach( + ent -> { + if (Objects.equals(ent.resultType(), dataType)) { + extUuidIdMapping.put(ent.uuid(), ent.id()); + } + }); + return extUuidIdMapping; + } } diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java index d62fe01..ed30f74 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java @@ -1,3 +1,9 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + package edu.ie3.simona.api.simulation.mapping; import com.opencsv.CSVReaderHeaderAware; @@ -6,7 +12,6 @@ import edu.ie3.datamodel.io.naming.FileNamingStrategy; import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme; import edu.ie3.datamodel.io.source.csv.CsvDataSource; - import java.io.FileReader; import java.io.IOException; import java.nio.file.Path; @@ -15,90 +20,92 @@ import java.util.stream.Stream; import java.util.stream.StreamSupport; +/** Source that is capable of providing information around external mapping from csv files. */ public class ExtEntityMappingCsvSource extends ExtEntityMappingSource { - private final ExtEntityMapping extEntities; - private final CsvDataSource dataSource; - private final Path mappingPath; + private final ExtEntityMapping extEntities; - public ExtEntityMappingCsvSource(String csvSep, Path folderPath, FileNamingStrategy fileNamingStrategy) { - super(); - this.dataSource = new CsvDataSource(csvSep, folderPath, fileNamingStrategy); - this.mappingPath = folderPath; - this.extEntities = buildExtEntityMapping(); - } + private final CsvDataSource dataSource; - public ExtEntityMapping getMapping() { - return extEntities; - } + private final Path mappingPath; + public ExtEntityMappingCsvSource( + String csvSep, Path folderPath, FileNamingStrategy fileNamingStrategy) { + super(); + this.dataSource = new CsvDataSource(csvSep, folderPath, fileNamingStrategy); + this.mappingPath = folderPath; + this.extEntities = buildExtEntityMapping(); + } - public Optional> getSourceFields() throws SourceException { - return dataSource.getSourceFields(ExtEntityEntry.class); - } + public ExtEntityMapping getMapping() { + return extEntities; + } - protected ExtEntityMapping buildExtEntityMapping() { - return new ExtEntityMapping(buildStream().map(this::createExtEntityEntry).toList()); - } + /** + * Method to retrieve the fields found in the source. + * + * @return an option for the found fields + */ + public Optional> getSourceFields() throws SourceException { + return dataSource.getSourceFields(ExtEntityEntry.class); + } - private Stream> buildStream() { - try { - FileReader fileReader = new FileReader(String.valueOf(mappingPath)); - CSVReaderHeaderAware csvReader = new CSVReaderHeaderAware(fileReader); + /** + * Builds the mapping from CSV + * + * @return Mapping external id and SIMONA uuid + */ + protected ExtEntityMapping buildExtEntityMapping() { + return new ExtEntityMapping(buildStream().map(this::createExtEntityEntry).toList()); + } - // Creating a Stream from CSVReader - Stream> csvStream = StreamSupport.stream( - new Spliterators.AbstractSpliterator>(Long.MAX_VALUE, Spliterator.ORDERED) { - @Override - public boolean tryAdvance(Consumer> action) { - try { - Map line = csvReader.readMap(); - if (line == null) { - return false; - } - action.accept(line); - //System.out.println(line); - return true; - } catch (IOException | CsvValidationException e) { - throw new RuntimeException(e); - } - } - }, false); + private Stream> + buildStream() { // TODO: Interim version -> maybe it would be easier to use PSDM methods for + // reading the CSV + try { + FileReader fileReader = new FileReader(String.valueOf(mappingPath)); + CSVReaderHeaderAware csvReader = new CSVReaderHeaderAware(fileReader); - //csvReader.close(); - return csvStream; - } catch (IOException e) { - throw new RuntimeException(e); - } - } + // Creating a Stream from CSVReader + Stream> csvStream = + StreamSupport.stream( + new Spliterators.AbstractSpliterator>( + Long.MAX_VALUE, Spliterator.ORDERED) { + @Override + public boolean tryAdvance(Consumer> action) { + try { + Map line = csvReader.readMap(); + if (line == null) { + return false; + } + action.accept(line); + // System.out.println(line); + return true; + } catch (IOException | CsvValidationException e) { + throw new RuntimeException(e); + } + } + }, + false); - private ExtEntityEntry createExtEntityEntry( - Map fieldToValues - ) { - return new ExtEntityEntry( - UUID.fromString(fieldToValues.get(ExtEntityFactory.SIMONA_UUID)), - fieldToValues.get(ExtEntityFactory.EXT_ID), - ColumnScheme.parse(fieldToValues.get(ExtEntityFactory.COLUMN_SCHEME)).get(), - fieldToValues.get(ExtEntityFactory.DATA_TYPE) - ); + // csvReader.close(); + return csvStream; + } catch (IOException e) { + throw new RuntimeException(e); } + } - public static ExtEntityMapping createExtEntityMapping(Path mappingPath) { - ExtEntityMappingCsvSource mappingSource = new ExtEntityMappingCsvSource( - ",", - mappingPath, - new FileNamingStrategy() - ); - return mappingSource.getMapping(); - } + private ExtEntityEntry createExtEntityEntry(Map fieldToValues) { + return new ExtEntityEntry( + UUID.fromString(fieldToValues.get(ExtEntityFactory.SIMONA_UUID)), + fieldToValues.get(ExtEntityFactory.EXT_ID), + ColumnScheme.parse(fieldToValues.get(ExtEntityFactory.COLUMN_SCHEME)).get(), + fieldToValues.get(ExtEntityFactory.DATA_TYPE)); + } - /* - private Try createExtEntityEntry( - Map fieldToValues - ) { - System.out.println("create: " + fieldToValues); - EntityData entityData = new EntityData(fieldToValues, ExtEntityEntry.class); - return factory.get(entityData); - } - */ + public static ExtEntityMapping createExtEntityMapping(Path mappingPath) { + ExtEntityMappingCsvSource mappingSource = + new ExtEntityMappingCsvSource(",", mappingPath, new FileNamingStrategy()); + return mappingSource.getMapping(); + } } diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSource.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSource.java index 0c7dc1b..137841b 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSource.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSource.java @@ -1,10 +1,17 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + package edu.ie3.simona.api.simulation.mapping; +/** Interface definition of a source, that is able to provide external mapping. */ public abstract class ExtEntityMappingSource { - protected final ExtEntityFactory factory; + protected final ExtEntityFactory factory; - public ExtEntityMappingSource() { - this.factory = new ExtEntityFactory(); - } + public ExtEntityMappingSource() { + this.factory = new ExtEntityFactory(); + } } diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/ActivationMessage.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/ActivationMessage.java index 31f889d..878ceec 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/ActivationMessage.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/ActivationMessage.java @@ -12,12 +12,9 @@ * @param tick The current tick * @param phase Phase of the simulation */ -public record ActivationMessage( - long tick, - int phase -) implements ControlMessageToExt { - @Override - public int getPhase() { - return phase; - } +public record ActivationMessage(long tick, int phase) implements ControlMessageToExt { + @Override + public int getPhase() { + return phase; + } } diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/CompletionMessage.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/CompletionMessage.java index f8d0220..32a7cac 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/CompletionMessage.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/CompletionMessage.java @@ -14,12 +14,10 @@ * @param nextActivation The tick that the external simulation would like to be activated at again * @param phase The phase of the simulation */ -public record CompletionMessage( - Optional nextActivation, - int phase -) implements ControlResponseMessageFromExt { - @Override - public int getPhase() { - return phase; - } +public record CompletionMessage(Optional nextActivation, int phase) + implements ControlResponseMessageFromExt { + @Override + public int getPhase() { + return phase; + } } diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlMessageToExt.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlMessageToExt.java index a0aba5c..08cf3c8 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlMessageToExt.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlMessageToExt.java @@ -8,5 +8,5 @@ /** Interface for control messages from the SIMONA to the external simulation */ public interface ControlMessageToExt { - int getPhase(); + int getPhase(); } diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlResponseMessageFromExt.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlResponseMessageFromExt.java index cc35018..2626967 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlResponseMessageFromExt.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlResponseMessageFromExt.java @@ -8,5 +8,5 @@ /** Interface for control messages from the external simulation to SIMONA */ public interface ControlResponseMessageFromExt { - int getPhase(); + int getPhase(); } diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationCompleted.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationCompleted.java index 78dd5b8..8b89713 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationCompleted.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationCompleted.java @@ -8,8 +8,8 @@ /** Message returned to SIMONA indicating that the external simulation terminated */ public record TerminationCompleted(int phase) implements ControlResponseMessageFromExt { - @Override - public int getPhase() { - return phase; - } + @Override + public int getPhase() { + return phase; + } } diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationMessage.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationMessage.java index efad176..995ab31 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationMessage.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationMessage.java @@ -12,9 +12,10 @@ * * @param simulationSuccessful Whether SIMONA terminated successfully */ -public record TerminationMessage(Boolean simulationSuccessful, int phase) implements ControlMessageToExt { - @Override - public int getPhase() { - return phase; - } +public record TerminationMessage(Boolean simulationSuccessful, int phase) + implements ControlMessageToExt { + @Override + public int getPhase() { + return phase; + } } diff --git a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy index fe06dc3..e2219de 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy @@ -50,7 +50,7 @@ class ExtResultDataTest extends Specification { actorSystem = null } - def "ExtResultsData should request and receive results correctly as Object"() { + def "ExtResultsData should request and receive results correctly as ModelResultEntity"() { given: def dataService = new TestProbe(actorSystem) def dataServiceActivation = new TestProbe(actorSystem) @@ -71,12 +71,11 @@ class ExtResultDataTest extends Specification { then: dataService.expectMsg(new RequestResultEntities(0L)) - extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) + extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataServiceActivation.ref())) receivedResults.get("Load") == loadResult } - /* - def "ExtResultsData should request and receive results correctly as a list of results entities"() { + def "ExtResultsData should fail if wrong response is sent"() { given: def dataService = new TestProbe(actorSystem) def dataServiceActivation = new TestProbe(actorSystem) @@ -88,51 +87,28 @@ class ExtResultDataTest extends Specification { extSimAdapter.ref() ) - def sentMsg = new ProvideResultEntities([loadResult]) - - when: - // we need to queue the msg beforehand because the receive method is blocking - extResultData.queueExtResponseMsg(sentMsg) - def receivedResults = extResultData.requestResults() - - then: - dataService.expectMsg(new RequestResultEntities()) - extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) - receivedResults == sentMsg.results() - } - - def "ExtResultsData should fail if wrong response is sent"() { - given: - def dataService = new TestProbe(actorSystem) - def extSimAdapter = new TestProbe(actorSystem) - def extResultData = new ExtResultData(dataService.ref(), extSimAdapter.ref(), new DefaultResultFactory()) - def unexpectedMsg = new WrongResultDataResponseMessageToExt() when: // we need to queue the msg beforehand because the receive method is blocking extResultData.queueExtResponseMsg(unexpectedMsg) - extResultData.requestResults() + extResultData.requestResults(0L) then: - dataService.expectMsg(new RequestResultEntities()) - extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) + dataService.expectMsg(new RequestResultEntities(0L)) + extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataServiceActivation.ref())) thrown RuntimeException } - def "ExtResultData should convert a list of result entities correctly to a map of objects"() { + def "ExtResultData should convert a list of result entities correctly to a map of resultAssetMappingId to result entity"() { given: - def dataService = new TestProbe(actorSystem) - def extSimAdapter = new TestProbe(actorSystem) - def extResultData = new ExtResultData(dataService.ref(), extSimAdapter.ref(), new DefaultResultFactory()) + def extResultData = new ExtResultData(participantResultAssetMapping, gridResultAssetMapping) when: - def mapOfResults = extResultData.convertResultsList([loadResult]) + def mapOfResults = extResultData.createResultMap([loadResult]) then: mapOfResults.size() == 1 - mapOfResults.get(loadUuid.toString()) == "{\"p\":\"10 kW,\"q\":\"10 kvar\"}" + mapOfResults.get("Load") == loadResult } - - */ } \ No newline at end of file From cf22d848d25569bf48f0ede2aea4c1b7312b0ade Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Wed, 24 Jul 2024 10:23:25 +0200 Subject: [PATCH 18/82] fixing pmd? --- .../api/simulation/mapping/ExtEntityMappingCsvSource.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java index ed30f74..7421206 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java @@ -79,7 +79,6 @@ public boolean tryAdvance(Consumer> action) { return false; } action.accept(line); - // System.out.println(line); return true; } catch (IOException | CsvValidationException e) { throw new RuntimeException(e); @@ -88,7 +87,6 @@ public boolean tryAdvance(Consumer> action) { }, false); - // csvReader.close(); return csvStream; } catch (IOException e) { throw new RuntimeException(e); From 2207a4535f8b32c0964ce109ec7bf79a28e274ca Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Wed, 24 Jul 2024 10:25:06 +0200 Subject: [PATCH 19/82] fixing pmd? --- .../api/simulation/mapping/ExtEntityMappingCsvSource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java index 7421206..431a288 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java @@ -55,7 +55,7 @@ public Optional> getSourceFields() throws SourceException { * * @return Mapping external id and SIMONA uuid */ - protected ExtEntityMapping buildExtEntityMapping() { + protected final ExtEntityMapping buildExtEntityMapping() { return new ExtEntityMapping(buildStream().map(this::createExtEntityEntry).toList()); } From aee53bb212bd7bfd093f21fe1d766ec3371ff0f7 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Wed, 24 Jul 2024 11:42:22 +0200 Subject: [PATCH 20/82] em data test --- .../DataQueueExtSimulationExtSimulator.java | 2 - .../edu/ie3/simona/api/data/em/ExtEmData.java | 3 + .../api/data/primarydata/ExtPrimaryData.java | 3 + .../simona/api/data/em/ExtEmDataTest.groovy | 119 ++++++++++++++++++ .../primarydata/ExtPrimaryDataTest.groovy | 43 +++++-- 5 files changed, 160 insertions(+), 10 deletions(-) create mode 100644 src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy diff --git a/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java b/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java index 883ed80..e0ce05b 100644 --- a/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java +++ b/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java @@ -12,8 +12,6 @@ public class DataQueueExtSimulationExtSimulator { private final LinkedBlockingQueue receiverTriggerQueue = new LinkedBlockingQueue<>(); - public DataQueueExtSimulationExtSimulator() {} - public void queueData(V data) throws InterruptedException { this.receiverTriggerQueue.put(data); } diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java index 59a9b49..1831704 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java @@ -84,6 +84,9 @@ public Map createExtEmDataMap(ExtInputDataPackage extInputDataPack } catch (ConvertionException e) { throw new RuntimeException(e); } + } else { + throw new IllegalArgumentException( + "Input for asset with id " + id + " was provided, but it wasn't requested!"); } }); return emDataForSimona; diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java index 1b5568b..d4ba17f 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java @@ -86,6 +86,9 @@ public Map createExtPrimaryDataMap(ExtInputDataPackage extInputData } catch (ConvertionException e) { throw new RuntimeException(e); } + } else { + throw new IllegalArgumentException( + "Input for asset with id " + id + " was provided, but it wasn't requested!"); } }); return primaryDataForSimona; diff --git a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy new file mode 100644 index 0000000..6427d3c --- /dev/null +++ b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy @@ -0,0 +1,119 @@ +package edu.ie3.simona.api.data.em + +import edu.ie3.datamodel.models.StandardUnits +import edu.ie3.datamodel.models.value.PValue +import edu.ie3.datamodel.models.value.Value +import edu.ie3.simona.api.data.ExtInputDataPackage +import edu.ie3.simona.api.data.ExtInputDataValue +import edu.ie3.simona.api.data.em.ontology.ProvideEmData +import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage +import edu.ie3.simona.api.data.primarydata.ExtPrimaryData +import edu.ie3.simona.api.data.primarydata.PrimaryDataFactory +import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData +import edu.ie3.simona.api.exceptions.ConvertionException +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.testkit.TestProbe +import org.apache.pekko.testkit.javadsl.TestKit +import spock.lang.Shared +import spock.lang.Specification +import tech.units.indriya.quantity.Quantities + +class ExtEmDataTest extends Specification { + + @Shared + ActorSystem actorSystem + + @Shared + UUID inputUuid = UUID.fromString("22bea5fc-2cb2-4c61-beb9-b476e0107f52") + + @Shared + PValue pValue = new PValue(Quantities.getQuantity(500.0, StandardUnits.ACTIVE_POWER_IN)) + + @Shared + Map extEmDataMapping = Map.of( + "Em", + inputUuid + ) + + class TestInputDataValue implements ExtInputDataValue { + private PValue value + + TestInputDataValue(PValue value) { + this.value = value + } + + PValue getValue() { + return value + } + } + + class TestEmDataFactory implements EmDataFactory { + @Override + PValue convert(ExtInputDataValue entity) throws ConvertionException { + if (entity instanceof TestInputDataValue) { + return entity.getValue() + } else { + throw new ConvertionException("This factory can only convert PValue entities.") + } + } + } + + def setupSpec() { + actorSystem = ActorSystem.create() + } + + def cleanupSpec() { + TestKit.shutdownActorSystem(actorSystem) + actorSystem = null + } + + def "ExtEmData should provide em data correctly"() { + given: + def dataService = new TestProbe(actorSystem) + def extSimAdapter = new TestProbe(actorSystem) + def extEmData = new ExtEmData(new TestEmDataFactory(), extEmDataMapping) + extEmData.setActorRefs( + dataService.ref(), + extSimAdapter.ref() + ) + + def emData = new HashMap() + def uuid = UUID.randomUUID() + emData.put(uuid.toString(), pValue) + + def convertedEmData = Map.of(uuid, pValue) + + when: + extEmData.provideEmData(0, convertedEmData) + + then: + dataService.expectMsg(new ProvideEmData(0, convertedEmData)) + extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) + } + + def "ExtEmData should convert ExtInputDataPackage to a map"() { + given: + def extEmData = new ExtEmData(new TestEmDataFactory(), extEmDataMapping) + def inputDataMap = Map.of("Em", new TestInputDataValue(pValue)) + def inputDataPackage = new ExtInputDataPackage(inputDataMap) + + when: + def emDataMap = extEmData.createExtEmDataMap(inputDataPackage) + + then: + emDataMap.get(inputUuid) == pValue + } + + def "ExtPrimaryData should throw an exception, if input data for a not requested asset was provided"() { + given: + def extEmData = new ExtEmData(new TestEmDataFactory(), extEmDataMapping) + def inputDataMap = Map.of("Load", new TestInputDataValue(pValue)) + def inputDataPackage = new ExtInputDataPackage(inputDataMap) + + when: + extEmData.createExtEmDataMap(inputDataPackage) + + then: + thrown IllegalArgumentException + } +} diff --git a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy index 6dc3b10..ca7089d 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy @@ -3,6 +3,7 @@ package edu.ie3.simona.api.data.primarydata import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.value.PValue import edu.ie3.datamodel.models.value.Value +import edu.ie3.simona.api.data.ExtInputDataPackage import edu.ie3.simona.api.data.ExtInputDataValue import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData @@ -14,8 +15,6 @@ import spock.lang.Shared import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import java.sql.ShardingKey - class ExtPrimaryDataTest extends Specification { @Shared @@ -24,9 +23,11 @@ class ExtPrimaryDataTest extends Specification { @Shared UUID inputUuid = UUID.fromString("22bea5fc-2cb2-4c61-beb9-b476e0107f52") + @Shared + PValue pValue = new PValue(Quantities.getQuantity(500.0, StandardUnits.ACTIVE_POWER_IN)) @Shared - HashMap extPrimaryDataMapping = Map.of( + Map extPrimaryDataMapping = Map.of( "Pv", inputUuid ) @@ -47,9 +48,9 @@ class ExtPrimaryDataTest extends Specification { @Override Value convert(ExtInputDataValue entity) throws ConvertionException { if (entity instanceof TestInputDataValue) { - return entity.getValue(); + return entity.getValue() } else { - throw new ConvertionException("This factory can only convert PValue entities."); + throw new ConvertionException("This factory can only convert PValue entities.") } } } @@ -73,11 +74,11 @@ class ExtPrimaryDataTest extends Specification { extSimAdapter.ref() ) - def primaryData = new HashMap() + def primaryData = new HashMap() def uuid = UUID.randomUUID() - primaryData.put(uuid.toString(), new PValue(Quantities.getQuantity(500.0, StandardUnits.ACTIVE_POWER_IN))) + primaryData.put(uuid.toString(), pValue) - def convertedPrimaryData = Map.of(uuid, new PValue(Quantities.getQuantity(500.0, StandardUnits.ACTIVE_POWER_IN))) + def convertedPrimaryData = Map.of(uuid, pValue) when: extPrimaryData.providePrimaryData(0, convertedPrimaryData) @@ -86,4 +87,30 @@ class ExtPrimaryDataTest extends Specification { dataService.expectMsg(new ProvidePrimaryData(0, convertedPrimaryData)) extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) } + + def "ExtPrimaryData should convert ExtInputDataPackage to a map"() { + given: + def extPrimaryData = new ExtPrimaryData(new TestPrimaryDataFactory(), extPrimaryDataMapping) + def inputDataMap = Map.of("Pv", new TestInputDataValue(pValue)) + def inputDataPackage = new ExtInputDataPackage(inputDataMap) + + when: + def primaryDataMap = extPrimaryData.createExtPrimaryDataMap(inputDataPackage) + + then: + primaryDataMap.get(inputUuid) == pValue + } + + def "ExtPrimaryData should throw an exception, if input data for a not requested asset was provided"() { + given: + def extPrimaryData = new ExtPrimaryData(new TestPrimaryDataFactory(), extPrimaryDataMapping) + def inputDataMap = Map.of("Load", new TestInputDataValue(pValue)) + def inputDataPackage = new ExtInputDataPackage(inputDataMap) + + when: + extPrimaryData.createExtPrimaryDataMap(inputDataPackage) + + then: + thrown IllegalArgumentException + } } From f5d2c322638bb5f74775454c44f3c652d1dbefa6 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Wed, 24 Jul 2024 13:31:06 +0200 Subject: [PATCH 21/82] new tests --- .../api/data/results/ExtResultPackage.java | 10 +- .../simona/api/data/em/ExtEmDataTest.groovy | 3 +- .../api/data/results/ExtResultDataTest.groovy | 22 ++++ .../data/results/ExtResultPackageTest.groovy | 103 ++++++++++++++++++ .../mapping/ExtEntityMappingTest.groovy | 53 +++++++++ 5 files changed, 186 insertions(+), 5 deletions(-) create mode 100644 src/test/groovy/edu/ie3/simona/api/data/results/ExtResultPackageTest.groovy create mode 100644 src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingTest.groovy diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java index 92155b6..b6f990d 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java @@ -49,7 +49,7 @@ public double getVoltageDeviation(String assetId) { .add(nodeResult.getvMag().subtract(Quantities.getQuantity(1.0, PU))); return vMagDev.getValue().doubleValue(); } else { - throw new RuntimeException("VOLTAGE DEVIATION is only available for NodeResult's!"); + throw new IllegalArgumentException("VOLTAGE DEVIATION is only available for NodeResult's!"); } } @@ -61,7 +61,8 @@ public double getActivePower(String assetId) { if (simonaResultsMap.get(assetId) instanceof SystemParticipantResult systemParticipantResult) { return systemParticipantResult.getP().getValue().doubleValue(); } else { - throw new RuntimeException("ACTIVE POWER is only available for SystemParticipantResult's!"); + throw new IllegalArgumentException( + "ACTIVE POWER is only available for SystemParticipantResult's!"); } } @@ -73,13 +74,14 @@ public double getReactivePower(String assetId) { if (simonaResultsMap.get(assetId) instanceof SystemParticipantResult systemParticipantResult) { return systemParticipantResult.getQ().getValue().doubleValue(); } else { - throw new RuntimeException("REACTIVE POWER is only available for SystemParticipantResult's!"); + throw new IllegalArgumentException( + "REACTIVE POWER is only available for SystemParticipantResult's!"); } } /** Returns the line loading for certain asset, if this asset provided a {@link NodeResult} */ public double getLineLoading(String assetId) { - throw new RuntimeException("LINE LOADING is not implemented yet!"); + throw new IllegalArgumentException("LINE LOADING is not implemented yet!"); } public String toString() { diff --git a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy index 6427d3c..a4f5b80 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy @@ -104,7 +104,7 @@ class ExtEmDataTest extends Specification { emDataMap.get(inputUuid) == pValue } - def "ExtPrimaryData should throw an exception, if input data for a not requested asset was provided"() { + def "ExtEmData should throw an exception, if input data for a not requested asset was provided"() { given: def extEmData = new ExtEmData(new TestEmDataFactory(), extEmDataMapping) def inputDataMap = Map.of("Load", new TestInputDataValue(pValue)) @@ -116,4 +116,5 @@ class ExtEmDataTest extends Specification { then: thrown IllegalArgumentException } + } diff --git a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy index e2219de..8e52c07 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy @@ -2,6 +2,7 @@ package edu.ie3.simona.api.data.results import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.result.ResultEntity +import edu.ie3.datamodel.models.result.connector.LineResult import edu.ie3.datamodel.models.result.system.LoadResult import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage import edu.ie3.simona.api.data.results.ontology.ProvideResultEntities @@ -15,6 +16,9 @@ import spock.lang.Shared import spock.lang.Specification import tech.units.indriya.quantity.Quantities +import javax.measure.Quantity +import javax.measure.quantity.Angle +import javax.measure.quantity.ElectricCurrent import java.time.ZonedDateTime class ExtResultDataTest extends Specification { @@ -111,4 +115,22 @@ class ExtResultDataTest extends Specification { mapOfResults.size() == 1 mapOfResults.get("Load") == loadResult } + + def "ExtResultData should throw an exception, if a result with a wrong data type was provided"() { + given: + def extResultData = new ExtResultData(participantResultAssetMapping, gridResultAssetMapping) + Quantity iAMag = Quantities.getQuantity(100, StandardUnits.ELECTRIC_CURRENT_MAGNITUDE) + Quantity iAAng = Quantities.getQuantity(45, StandardUnits.ELECTRIC_CURRENT_ANGLE) + Quantity iBMag = Quantities.getQuantity(150, StandardUnits.ELECTRIC_CURRENT_MAGNITUDE) + Quantity iBAng = Quantities.getQuantity(30, StandardUnits.ELECTRIC_CURRENT_ANGLE) + def wrongResult = new LineResult( + ZonedDateTime.parse("2020-01-30T17:26:44Z"), loadUuid, iAMag, iAAng, iBMag, iBAng + ) + + when: + extResultData.createResultMap([wrongResult]) + + then: + thrown IllegalArgumentException + } } \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultPackageTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultPackageTest.groovy new file mode 100644 index 0000000..fbc1517 --- /dev/null +++ b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultPackageTest.groovy @@ -0,0 +1,103 @@ +package edu.ie3.simona.api.data.results + +import edu.ie3.datamodel.models.StandardUnits +import edu.ie3.datamodel.models.result.NodeResult +import edu.ie3.datamodel.models.result.connector.LineResult +import edu.ie3.datamodel.models.result.system.LoadResult +import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage +import edu.ie3.simona.api.data.results.ontology.ProvideResultEntities +import edu.ie3.simona.api.data.results.ontology.RequestResultEntities +import edu.ie3.simona.api.data.results.ontology.ResultDataResponseMessageToExt +import edu.ie3.util.quantities.PowerSystemUnits +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.testkit.TestProbe +import org.apache.pekko.testkit.javadsl.TestKit +import spock.lang.Shared +import spock.lang.Specification +import tech.units.indriya.quantity.Quantities + +import javax.measure.Quantity +import javax.measure.quantity.Angle +import javax.measure.quantity.Dimensionless +import javax.measure.quantity.ElectricCurrent +import java.time.ZonedDateTime + +class ExtResultPackageTest extends Specification { + @Shared + UUID loadUuid = UUID.fromString("22bea5fc-2cb2-4c61-beb9-b476e0107f52") + + @Shared + UUID nodeUuid = UUID.fromString("55b97041-64be-4e6b-983a-72dbde6eddf4") + + @Shared + NodeResult nodeResult = new NodeResult( + ZonedDateTime.parse("2020-01-30T17:26:44Z"), + nodeUuid, + Quantities.getQuantity(0.95, PowerSystemUnits.PU), + Quantities.getQuantity(45, StandardUnits.VOLTAGE_ANGLE) + ) + + @Shared + LoadResult loadResult = new LoadResult( + ZonedDateTime.parse("2020-01-30T17:26:44Z"), + loadUuid, + Quantities.getQuantity(10, StandardUnits.ACTIVE_POWER_IN), + Quantities.getQuantity(10, StandardUnits.REACTIVE_POWER_IN) + ) + + def "ExtResultPackage should return voltage deviation correctly"() { + given: + def resultMap = Map.of( + "Node", nodeResult + ) + def extResultPackage = new ExtResultPackage(0L, resultMap) + + when: + def calculatedVoltageDeviation = extResultPackage.getVoltageDeviation("Node") + + then: + calculatedVoltageDeviation == -0.05d + } + + def "ExtResultPackage should throw an exception, if voltage deviation was requested for a not NodeResult"() { + given: + def resultMap = Map.of( + "Load", loadResult + ) + def extResultPackage = new ExtResultPackage(0L, resultMap) + + when: + extResultPackage.getVoltageDeviation("Load") + + then: + thrown IllegalArgumentException + } + + def "ExtResultPackage should return active power correctly"() { + given: + def resultMap = Map.of( + "Load", loadResult + ) + def extResultPackage = new ExtResultPackage(0L, resultMap) + + when: + def returnedActivePower = extResultPackage.getActivePower("Load") + + then: + returnedActivePower == 10d + } + + def "ExtResultPackage should throw an exception, if active power was requested for a not SystemParticipantResult"() { + given: + def resultMap = Map.of( + "Node", nodeResult + ) + def extResultPackage = new ExtResultPackage(0L, resultMap) + + when: + extResultPackage.getActivePower("Node") + + then: + thrown IllegalArgumentException + } +} \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingTest.groovy b/src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingTest.groovy new file mode 100644 index 0000000..8e1710f --- /dev/null +++ b/src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingTest.groovy @@ -0,0 +1,53 @@ +package edu.ie3.simona.api.simulation.mapping + +import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme +import spock.lang.Shared +import spock.lang.Specification + +class ExtEntityMappingTest extends Specification { + @Shared + UUID loadUuid = UUID.fromString("22bea5fc-2cb2-4c61-beb9-b476e0107f52") + + @Shared + ExtEntityEntry extResultEntry = new ExtEntityEntry( + loadUuid, + "Load", + ColumnScheme.parse("p").get(), + "result_participant" + ) + + @Shared + ExtEntityEntry extInputEntry = new ExtEntityEntry( + loadUuid, + "Load", + ColumnScheme.parse("p").get(), + "input" + ) + + def "ExtEntityMapping should return external id to SIMONA uuid mapping correctly"() { + given: + def extAssetList = List.of(extResultEntry, extInputEntry) + def extEntryMapping = new ExtEntityMapping(extAssetList) + + when: + def inputMap = extEntryMapping.getExtIdUuidMapping("input") + + then: + inputMap.size() == 1 + inputMap.get("Load") == loadUuid + } + + + def "ExtEntityMapping should return external id to SIMONA uuid mapping correctly"() { + given: + def extAssetList = List.of(extResultEntry, extInputEntry) + def extEntryMapping = new ExtEntityMapping(extAssetList) + + when: + def inputMap = extEntryMapping.getExtUuidIdMapping("input") + + then: + inputMap.size() == 1 + inputMap.get(loadUuid) == "Load" + } +} \ No newline at end of file From d54be627b30196806071985b6d1e4e9038a90f57 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Wed, 24 Jul 2024 14:01:05 +0200 Subject: [PATCH 22/82] temp csv --- .../mapping/ExtEntityMappingCsvSource.java | 51 ++++++++----------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java index 431a288..0a5426c 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java @@ -6,19 +6,16 @@ package edu.ie3.simona.api.simulation.mapping; -import com.opencsv.CSVReaderHeaderAware; -import com.opencsv.exceptions.CsvValidationException; import edu.ie3.datamodel.exceptions.SourceException; import edu.ie3.datamodel.io.naming.FileNamingStrategy; import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme; import edu.ie3.datamodel.io.source.csv.CsvDataSource; -import java.io.FileReader; + import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.util.*; -import java.util.function.Consumer; import java.util.stream.Stream; -import java.util.stream.StreamSupport; /** Source that is capable of providing information around external mapping from csv files. */ public class ExtEntityMappingCsvSource extends ExtEntityMappingSource { @@ -62,32 +59,28 @@ protected final ExtEntityMapping buildExtEntityMapping() { private Stream> buildStream() { // TODO: Interim version -> maybe it would be easier to use PSDM methods for // reading the CSV - try { - FileReader fileReader = new FileReader(String.valueOf(mappingPath)); - CSVReaderHeaderAware csvReader = new CSVReaderHeaderAware(fileReader); - - // Creating a Stream from CSVReader - Stream> csvStream = - StreamSupport.stream( - new Spliterators.AbstractSpliterator>( - Long.MAX_VALUE, Spliterator.ORDERED) { - @Override - public boolean tryAdvance(Consumer> action) { - try { - Map line = csvReader.readMap(); - if (line == null) { - return false; - } - action.accept(line); - return true; - } catch (IOException | CsvValidationException e) { - throw new RuntimeException(e); - } + Path pathToCsv = mappingPath; + + try (Stream lines = Files.lines(pathToCsv)) { + // Read the header line + List headers = lines + .findFirst() + .map(line -> Arrays.asList(line.split(","))) + .orElseThrow(() -> new RuntimeException("No header line found")); + + // Stream the rest of the lines + Stream> mapStream = Files.lines(pathToCsv) + .skip(1) // Skip the header line + .map(line -> { + String[] values = line.split(","); + Map map = new HashMap<>(); + for (int i = 0; i < headers.size(); i++) { + map.put(headers.get(i), values[i]); } - }, - false); + return map; + }); - return csvStream; + return mapStream; } catch (IOException e) { throw new RuntimeException(e); } From c44fce7ad7ad2853580f3fbe1560bd91299d2a07 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Wed, 24 Jul 2024 14:24:18 +0200 Subject: [PATCH 23/82] spotless --- .../mapping/ExtEntityMappingCsvSource.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java index 0a5426c..b281e0f 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java @@ -10,7 +10,6 @@ import edu.ie3.datamodel.io.naming.FileNamingStrategy; import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme; import edu.ie3.datamodel.io.source.csv.CsvDataSource; - import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -63,22 +62,25 @@ protected final ExtEntityMapping buildExtEntityMapping() { try (Stream lines = Files.lines(pathToCsv)) { // Read the header line - List headers = lines + List headers = + lines .findFirst() .map(line -> Arrays.asList(line.split(","))) .orElseThrow(() -> new RuntimeException("No header line found")); // Stream the rest of the lines - Stream> mapStream = Files.lines(pathToCsv) + Stream> mapStream = + Files.lines(pathToCsv) .skip(1) // Skip the header line - .map(line -> { - String[] values = line.split(","); - Map map = new HashMap<>(); - for (int i = 0; i < headers.size(); i++) { - map.put(headers.get(i), values[i]); - } - return map; - }); + .map( + line -> { + String[] values = line.split(","); + Map map = new HashMap<>(); + for (int i = 0; i < headers.size(); i++) { + map.put(headers.get(i), values[i]); + } + return map; + }); return mapStream; } catch (IOException e) { From f81ca1678883254067c5b7156b78157ba4d91c6b Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Wed, 24 Jul 2024 14:37:43 +0200 Subject: [PATCH 24/82] columnScheme get --- .../ie3/simona/api/simulation/mapping/ExtEntityFactory.java | 3 ++- .../api/simulation/mapping/ExtEntityMappingCsvSource.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java index f96de44..8e6f466 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java @@ -36,7 +36,8 @@ protected ExtEntityEntry buildModel(EntityData data) { return new ExtEntityEntry( simonaUuid, extId, - columnScheme.get(), // FIXME: Interim version -> ColumnScheme should handle more data types + columnScheme + .orElseThrow(), // FIXME: Interim version -> ColumnScheme should handle more data types inputType); } } diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java index b281e0f..c94b809 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java @@ -92,7 +92,7 @@ private ExtEntityEntry createExtEntityEntry(Map fieldToValues) { return new ExtEntityEntry( UUID.fromString(fieldToValues.get(ExtEntityFactory.SIMONA_UUID)), fieldToValues.get(ExtEntityFactory.EXT_ID), - ColumnScheme.parse(fieldToValues.get(ExtEntityFactory.COLUMN_SCHEME)).get(), + ColumnScheme.parse(fieldToValues.get(ExtEntityFactory.COLUMN_SCHEME)).orElseThrow(), fieldToValues.get(ExtEntityFactory.DATA_TYPE)); } From 92a6a7e32bee43cdcdc731744871e9c2cdf45f63 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Wed, 24 Jul 2024 14:57:37 +0200 Subject: [PATCH 25/82] update build.gradle --- build.gradle | 2 -- 1 file changed, 2 deletions(-) diff --git a/build.gradle b/build.gradle index aa13089..5a83a1e 100644 --- a/build.gradle +++ b/build.gradle @@ -45,8 +45,6 @@ repositories { } dependencies{ - implementation 'com.opencsv:opencsv:5.5.2' - implementation 'tech.units:indriya:2.2' // quantities // scala (needed for pekko) From 7e5d65c7c46ace389cc2330f9c5d7dffc27bacd6 Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Fri, 9 Aug 2024 15:20:15 +0200 Subject: [PATCH 26/82] Downgrading current version --- version.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/version.properties b/version.properties index 4fd9773..91b15a0 100644 --- a/version.properties +++ b/version.properties @@ -1,8 +1,8 @@ #Generated by the Semver Plugin for Gradle -#Thu Nov 30 15:04:34 CET 2023 +#Fri Aug 09 15:20:01 CEST 2024 version.buildmeta= version.major=0 -version.minor=5 +version.minor=4 version.patch=0 version.prerelease= -version.semver=0.5.0 +version.semver=0.4.0 From db7594945b15c0fd19189c6f1e77ea7b0dff0017 Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Fri, 9 Aug 2024 15:43:06 +0200 Subject: [PATCH 27/82] Upgrade working version --- version.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/version.properties b/version.properties index 91b15a0..142da6e 100644 --- a/version.properties +++ b/version.properties @@ -1,8 +1,8 @@ #Generated by the Semver Plugin for Gradle -#Fri Aug 09 15:20:01 CEST 2024 +#Fri Aug 09 15:42:54 CEST 2024 version.buildmeta= version.major=0 -version.minor=4 +version.minor=6 version.patch=0 version.prerelease= -version.semver=0.4.0 +version.semver=0.6.0 From 92c9b6a408c2e0ef0df63d540d949d8535ede765 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 Aug 2024 11:36:09 +0000 Subject: [PATCH 28/82] Bump com.github.spotbugs from 6.0.20 to 6.0.21 (#196) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e27b37f..9df2fcb 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'java' // java support id 'com.diffplug.spotless' version '6.25.0'//code format id 'pmd' // code check, working on source code - id 'com.github.spotbugs' version '6.0.20' // code check, working on byte code + id 'com.github.spotbugs' version '6.0.21' // code check, working on byte code id "org.sonarqube" version "5.1.0.4882" // sonarqube id 'signing' id 'maven-publish' // publish to a maven repo (local or mvn central, has to be defined) From e9edd456abbd79ef2e0c36588c82f51eba4f964f Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Tue, 10 Sep 2024 15:53:55 +0200 Subject: [PATCH 29/82] provide next tick --- .../simona/api/data/ExtInputDataPackage.java | 14 +++++++++-- .../api/data/primarydata/ExtPrimaryData.java | 11 ++++----- .../ontology/ProvidePrimaryData.java | 3 ++- .../api/simulation/ExtSimAdapterData.java | 16 ++++++------- .../simona/api/simulation/ExtSimulation.java | 23 ++++--------------- .../ontology/ActivationMessage.java | 7 +----- .../ontology/CompletionMessage.java | 9 ++------ .../ontology/ControlMessageToExt.java | 4 +--- .../ControlResponseMessageFromExt.java | 4 +--- .../ontology/TerminationCompleted.java | 7 +----- .../ontology/TerminationMessage.java | 8 +------ .../api/simulation/ExtSimulationSpec.groovy | 7 +----- 12 files changed, 38 insertions(+), 75 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java index b32e9bd..6b642b2 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.Map; +import java.util.Optional; /** Contains all inputs for SIMONA for a certain tick */ public class ExtInputDataPackage implements ExtDataPackage { @@ -15,18 +16,27 @@ public class ExtInputDataPackage implements ExtDataPackage { /** Map external id to input for SIMONA */ private final Map dataMap; - public ExtInputDataPackage(Map dataMap) { + private final Optional maybeNextTick; + + public ExtInputDataPackage(Map dataMap, Optional maybeNextTick) { this.dataMap = dataMap; + this.maybeNextTick = maybeNextTick; + } + + public ExtInputDataPackage(long nextTick) { + this(new HashMap<>(), Optional.of(nextTick)); } public ExtInputDataPackage() { - this(new HashMap<>()); + this(new HashMap<>(), Optional.empty()); } public Map getSimonaInputMap() { return dataMap; } + public Optional getMaybeNextTick() { return maybeNextTick; } + /** Adds a value to the input map */ public void addValue(String id, ExtInputDataValue value) { dataMap.put(id, value); diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java index d4ba17f..b072c10 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java @@ -13,10 +13,9 @@ import edu.ie3.simona.api.data.primarydata.ontology.PrimaryDataMessageFromExt; import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData; import edu.ie3.simona.api.exceptions.ConvertionException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; + +import java.util.*; + import org.apache.pekko.actor.ActorRef; public class ExtPrimaryData implements ExtData { @@ -55,8 +54,8 @@ public List getPrimaryDataAssets() { } /** Provide primary data from an external simulation in one tick. */ - public void providePrimaryData(Long tick, Map primaryData) { - sendExtMsg(new ProvidePrimaryData(tick, primaryData)); + public void providePrimaryData(Long tick, Map primaryData, Optional maybeNextTick) { + sendExtMsg(new ProvidePrimaryData(tick, primaryData, maybeNextTick)); } /** diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java index a87d9f7..426575d 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java @@ -8,8 +8,9 @@ import edu.ie3.datamodel.models.value.Value; import java.util.Map; +import java.util.Optional; import java.util.UUID; /** Message that provides primary data from an external primary data simulation */ -public record ProvidePrimaryData(long tick, Map primaryData) +public record ProvidePrimaryData(long tick, Map primaryData, Optional maybeNextTick) implements PrimaryDataMessageFromExt {} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java b/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java index 014202d..54bc97a 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java @@ -6,6 +6,7 @@ package edu.ie3.simona.api.simulation; +import edu.ie3.simona.api.simulation.ontology.ActivationMessage; import edu.ie3.simona.api.simulation.ontology.ControlMessageToExt; import edu.ie3.simona.api.simulation.ontology.ControlResponseMessageFromExt; import java.util.Map; @@ -21,25 +22,22 @@ public class ExtSimAdapterData { /** * Actor references to the adapters for the phases that handles scheduler control flow in SIMONA */ - private final Map extSimAdapters; + private final ActorRef extSimAdapter; /** CLI arguments with which SIMONA is initiated */ private final String[] mainArgs; // important trigger queue must be the same as held in actor // to make it safer one might consider asking the actor for a reference on its trigger queue?! - public ExtSimAdapterData(Map extSimAdapters, String[] mainArgs) { - this.extSimAdapters = extSimAdapters; + public ExtSimAdapterData(ActorRef extSimAdapter, String[] mainArgs) { + this.extSimAdapter = extSimAdapter; this.mainArgs = mainArgs; } - public ActorRef getPhase1Adapter() { - return extSimAdapters.get(1); + public ActorRef getAdapter() { + return extSimAdapter; } - public ActorRef getPhase2Adapter() { - return extSimAdapters.get(2); - } /** * Called within SIMONA to queue messages for the external simulation @@ -59,7 +57,7 @@ public void queueExtMsg(ControlMessageToExt msg) throws InterruptedException { * @param msg the message to send */ public void send(ControlResponseMessageFromExt msg) { - extSimAdapters.get(msg.getPhase()).tell(msg, ActorRef.noSender()); + extSimAdapter.tell(msg, ActorRef.noSender()); } public String[] getMainArgs() { diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java index 72ec3b0..4550dec 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java @@ -48,7 +48,6 @@ public void run() { private boolean takeAndHandleMessage() throws InterruptedException { // take() will block until an object is ready for us final ControlMessageToExt msg = data.receiveMessageQueue.take(); - int currentPhase = msg.getPhase(); if (msg.getClass().equals(ActivationMessage.class)) { final ActivationMessage activationMessage = (ActivationMessage) msg; @@ -59,17 +58,15 @@ private boolean takeAndHandleMessage() throws InterruptedException { newTrigger = Optional.of(initialize()); } else { newTrigger = - doActivity( - activationMessage.tick(), - currentPhase); // this is blocking until processing of this tick has finished + doActivity(activationMessage.tick()); // this is blocking until processing of this tick has finished } - data.send(new CompletionMessage(newTrigger, currentPhase)); + data.send(new CompletionMessage(newTrigger)); return newTrigger.isEmpty(); } else if (msg.getClass().equals(TerminationMessage.class)) { final TerminationMessage terminationMsg = (TerminationMessage) msg; terminate(terminationMsg.simulationSuccessful()); - data.send(new TerminationCompleted(currentPhase)); + data.send(new TerminationCompleted()); return true; } else { @@ -91,19 +88,7 @@ private boolean takeAndHandleMessage() throws InterruptedException { * @param tick The current tick * @return The next tick at which this external simulation wants to be triggered, if applicable. */ - protected Optional doActivity(long tick, int phase) { - if (phase == 1) { - return doPreActivity(tick); - } else if (phase == 2) { - return doPostActivity(tick); - } else { - throw new IllegalArgumentException("ExtSimulation can only handle phase 1 and 2!"); - } - } - - protected abstract Optional doPreActivity(long tick); - - protected abstract Optional doPostActivity(long tick); + protected abstract Optional doActivity(long tick); /** * This method is called when the main simulation wants to terminate. diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/ActivationMessage.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/ActivationMessage.java index 878ceec..61e4022 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/ActivationMessage.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/ActivationMessage.java @@ -12,9 +12,4 @@ * @param tick The current tick * @param phase Phase of the simulation */ -public record ActivationMessage(long tick, int phase) implements ControlMessageToExt { - @Override - public int getPhase() { - return phase; - } -} +public record ActivationMessage(long tick) implements ControlMessageToExt {} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/CompletionMessage.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/CompletionMessage.java index 32a7cac..be251ab 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/CompletionMessage.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/CompletionMessage.java @@ -14,10 +14,5 @@ * @param nextActivation The tick that the external simulation would like to be activated at again * @param phase The phase of the simulation */ -public record CompletionMessage(Optional nextActivation, int phase) - implements ControlResponseMessageFromExt { - @Override - public int getPhase() { - return phase; - } -} +public record CompletionMessage(Optional nextActivation) + implements ControlResponseMessageFromExt {} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlMessageToExt.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlMessageToExt.java index 08cf3c8..601b162 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlMessageToExt.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlMessageToExt.java @@ -7,6 +7,4 @@ package edu.ie3.simona.api.simulation.ontology; /** Interface for control messages from the SIMONA to the external simulation */ -public interface ControlMessageToExt { - int getPhase(); -} +public interface ControlMessageToExt {} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlResponseMessageFromExt.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlResponseMessageFromExt.java index 2626967..f3df097 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlResponseMessageFromExt.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/ControlResponseMessageFromExt.java @@ -7,6 +7,4 @@ package edu.ie3.simona.api.simulation.ontology; /** Interface for control messages from the external simulation to SIMONA */ -public interface ControlResponseMessageFromExt { - int getPhase(); -} +public interface ControlResponseMessageFromExt {} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationCompleted.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationCompleted.java index 8b89713..c46ca04 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationCompleted.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationCompleted.java @@ -7,9 +7,4 @@ package edu.ie3.simona.api.simulation.ontology; /** Message returned to SIMONA indicating that the external simulation terminated */ -public record TerminationCompleted(int phase) implements ControlResponseMessageFromExt { - @Override - public int getPhase() { - return phase; - } -} +public record TerminationCompleted() implements ControlResponseMessageFromExt {} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationMessage.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationMessage.java index 995ab31..c281d04 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationMessage.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/TerminationMessage.java @@ -12,10 +12,4 @@ * * @param simulationSuccessful Whether SIMONA terminated successfully */ -public record TerminationMessage(Boolean simulationSuccessful, int phase) - implements ControlMessageToExt { - @Override - public int getPhase() { - return phase; - } -} +public record TerminationMessage(Boolean simulationSuccessful) implements ControlMessageToExt {} diff --git a/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy b/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy index 10e85bd..31b7c87 100644 --- a/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy +++ b/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy @@ -155,12 +155,7 @@ class ExtSimulationSpec extends Specification { true || true } - class UnknownMessage implements ControlMessageToExt { - @Override - int getPhase() { - return 0 - } - } + class UnknownMessage implements ControlMessageToExt {} def "An ExtSimulation should handle unknown messages by throwing an exception"() { given: From 74db2365bc574768fcbcd38842db1b58103e9f07 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 12 Sep 2024 08:42:04 +0200 Subject: [PATCH 30/82] fixing messages --- .../edu/ie3/simona/api/data/ExtInputDataValue.java | 1 + .../java/edu/ie3/simona/api/data/em/ExtEmData.java | 13 ++++++------- ...rovideEmData.java => ProvideEmSetPointData.java} | 9 +++++++-- .../primarydata/ontology/ProvidePrimaryData.java | 7 +++++-- .../edu/ie3/simona/api/data/em/ExtEmDataTest.groovy | 7 ++----- 5 files changed, 21 insertions(+), 16 deletions(-) rename src/main/java/edu/ie3/simona/api/data/em/ontology/{ProvideEmData.java => ProvideEmSetPointData.java} (53%) diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataValue.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataValue.java index 6217396..df4a3c9 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtInputDataValue.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataValue.java @@ -6,4 +6,5 @@ package edu.ie3.simona.api.data; +/** Interface that represents a value of an external simulation */ public interface ExtInputDataValue {} diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java index 1831704..6f9867b 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java @@ -10,13 +10,12 @@ import edu.ie3.simona.api.data.ExtData; import edu.ie3.simona.api.data.ExtInputDataPackage; import edu.ie3.simona.api.data.em.ontology.EmDataMessageFromExt; -import edu.ie3.simona.api.data.em.ontology.ProvideEmData; +import edu.ie3.simona.api.data.em.ontology.ProvideEmSetPointData; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import edu.ie3.simona.api.exceptions.ConvertionException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; + +import java.util.*; + import org.apache.pekko.actor.ActorRef; public class ExtEmData implements ExtData { @@ -54,8 +53,8 @@ public EmDataFactory getEmDataFactory() { } /** Provide primary data from an external simulation in one tick. */ - public void provideEmData(Long tick, Map emData) { - sendExtMsg(new ProvideEmData(tick, emData)); + public void provideEmData(Long tick, Map emData, Optional maybeNextTick) { + sendExtMsg(new ProvideEmSetPointData(tick, emData, maybeNextTick)); } /** diff --git a/src/main/java/edu/ie3/simona/api/data/em/ontology/ProvideEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ontology/ProvideEmSetPointData.java similarity index 53% rename from src/main/java/edu/ie3/simona/api/data/em/ontology/ProvideEmData.java rename to src/main/java/edu/ie3/simona/api/data/em/ontology/ProvideEmSetPointData.java index 1f182a1..232818f 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ontology/ProvideEmData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ontology/ProvideEmSetPointData.java @@ -8,7 +8,12 @@ import edu.ie3.datamodel.models.value.PValue; import java.util.Map; +import java.util.Optional; import java.util.UUID; -/** Message that provides primary data from an external primary data simulation */ -public record ProvideEmData(long tick, Map emData) implements EmDataMessageFromExt {} +/** Message that provides em data (set points) from an external simulation */ +public record ProvideEmSetPointData( + long tick, + Map emData, + Optional maybeNextTick +) implements EmDataMessageFromExt {} diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java index 426575d..182ffed 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java @@ -12,5 +12,8 @@ import java.util.UUID; /** Message that provides primary data from an external primary data simulation */ -public record ProvidePrimaryData(long tick, Map primaryData, Optional maybeNextTick) - implements PrimaryDataMessageFromExt {} +public record ProvidePrimaryData( + long tick, + Map primaryData, + Optional maybeNextTick +) implements PrimaryDataMessageFromExt {} diff --git a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy index a4f5b80..1ba09e8 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy @@ -5,11 +5,8 @@ import edu.ie3.datamodel.models.value.PValue import edu.ie3.datamodel.models.value.Value import edu.ie3.simona.api.data.ExtInputDataPackage import edu.ie3.simona.api.data.ExtInputDataValue -import edu.ie3.simona.api.data.em.ontology.ProvideEmData +import edu.ie3.simona.api.data.em.ontology.ProvideEmSetPointData import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage -import edu.ie3.simona.api.data.primarydata.ExtPrimaryData -import edu.ie3.simona.api.data.primarydata.PrimaryDataFactory -import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData import edu.ie3.simona.api.exceptions.ConvertionException import org.apache.pekko.actor.ActorSystem import org.apache.pekko.testkit.TestProbe @@ -87,7 +84,7 @@ class ExtEmDataTest extends Specification { extEmData.provideEmData(0, convertedEmData) then: - dataService.expectMsg(new ProvideEmData(0, convertedEmData)) + dataService.expectMsg(new ProvideEmSetPointData(0, convertedEmData)) extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) } From b5d050ad83104f2f805889ad462e5ee7e18da49b Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 12 Sep 2024 10:20:26 +0200 Subject: [PATCH 31/82] fix tests --- .../simona/api/data/em/ExtEmDataTest.groovy | 20 ++++---- .../primarydata/ExtPrimaryDataTest.groovy | 8 ++-- .../api/simulation/ExtSimulationSpec.groovy | 48 +++++-------------- 3 files changed, 25 insertions(+), 51 deletions(-) diff --git a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy index 1ba09e8..d891219 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy @@ -81,37 +81,37 @@ class ExtEmDataTest extends Specification { def convertedEmData = Map.of(uuid, pValue) when: - extEmData.provideEmData(0, convertedEmData) + extEmData.provideEmData(0L, convertedEmData, Optional.of(900L)) then: - dataService.expectMsg(new ProvideEmSetPointData(0, convertedEmData)) + dataService.expectMsg(new ProvideEmSetPointData(0, convertedEmData, Optional.of(900L))) extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) } def "ExtEmData should convert ExtInputDataPackage to a map"() { given: - def extEmData = new ExtEmData(new TestEmDataFactory(), extEmDataMapping) - def inputDataMap = Map.of("Em", new TestInputDataValue(pValue)) - def inputDataPackage = new ExtInputDataPackage(inputDataMap) + def extEmData = new ExtEmData(new TestEmDataFactory(), extEmDataMapping) + def inputDataMap = Map.of("Em", new TestInputDataValue(pValue)) + def inputDataPackage = new ExtInputDataPackage(inputDataMap, Optional.of(900L)) when: - def emDataMap = extEmData.createExtEmDataMap(inputDataPackage) + def emDataMap = extEmData.createExtEmDataMap(inputDataPackage) then: - emDataMap.get(inputUuid) == pValue + emDataMap.get(inputUuid) == pValue } def "ExtEmData should throw an exception, if input data for a not requested asset was provided"() { given: def extEmData = new ExtEmData(new TestEmDataFactory(), extEmDataMapping) def inputDataMap = Map.of("Load", new TestInputDataValue(pValue)) - def inputDataPackage = new ExtInputDataPackage(inputDataMap) + def inputDataPackage = new ExtInputDataPackage(inputDataMap, Optional.of(900L)) when: - extEmData.createExtEmDataMap(inputDataPackage) + extEmData.createExtEmDataMap(inputDataPackage) then: - thrown IllegalArgumentException + thrown IllegalArgumentException } } diff --git a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy index ca7089d..2ecda57 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy @@ -81,10 +81,10 @@ class ExtPrimaryDataTest extends Specification { def convertedPrimaryData = Map.of(uuid, pValue) when: - extPrimaryData.providePrimaryData(0, convertedPrimaryData) + extPrimaryData.providePrimaryData(0L, convertedPrimaryData, Optional.of(900L)) then: - dataService.expectMsg(new ProvidePrimaryData(0, convertedPrimaryData)) + dataService.expectMsg(new ProvidePrimaryData(0L, convertedPrimaryData, Optional.of(900L))) extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) } @@ -92,7 +92,7 @@ class ExtPrimaryDataTest extends Specification { given: def extPrimaryData = new ExtPrimaryData(new TestPrimaryDataFactory(), extPrimaryDataMapping) def inputDataMap = Map.of("Pv", new TestInputDataValue(pValue)) - def inputDataPackage = new ExtInputDataPackage(inputDataMap) + def inputDataPackage = new ExtInputDataPackage(inputDataMap, Optional.of(900L)) when: def primaryDataMap = extPrimaryData.createExtPrimaryDataMap(inputDataPackage) @@ -105,7 +105,7 @@ class ExtPrimaryDataTest extends Specification { given: def extPrimaryData = new ExtPrimaryData(new TestPrimaryDataFactory(), extPrimaryDataMapping) def inputDataMap = Map.of("Load", new TestInputDataValue(pValue)) - def inputDataPackage = new ExtInputDataPackage(inputDataMap) + def inputDataPackage = new ExtInputDataPackage(inputDataMap, Optional.of(900L)) when: extPrimaryData.createExtPrimaryDataMap(inputDataPackage) diff --git a/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy b/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy index 31b7c87..5ba2e09 100644 --- a/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy +++ b/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy @@ -42,12 +42,7 @@ class ExtSimulationSpec extends Specification { } @Override - protected Optional doPreActivity(long tick) { - return this.activationReturnTick - } - - @Override - protected Optional doPostActivity(long tick) { + protected Optional doActivity(long tick) { return this.activationReturnTick } @@ -75,35 +70,35 @@ class ExtSimulationSpec extends Specification { def tick = -1L def newTick = 0L def extSimAdapter = new TestProbe(actorSystem) - def extSimData = new ExtSimAdapterData(Map.of(1, extSimAdapter.ref()), new String[0]) + def extSimData = new ExtSimAdapterData(extSimAdapter.ref(), new String[0]) def extSim = new TestSimulation(newTick, Optional.of(-2L)) extSim.setup(extSimData, new ArrayList()) when: - extSimData.queueExtMsg(new ActivationMessage(tick, 1)) + extSimData.queueExtMsg(new ActivationMessage(tick)) def finishedActual = handleMessage.invoke(extSim) then: finishedActual == false - extSimAdapter.expectMsg(new CompletionMessage(Optional.of(newTick), 1)) + extSimAdapter.expectMsg(new CompletionMessage(Optional.of(newTick))) } def "An ExtSimulation should handle activation and return given new triggers"() { given: def extSimAdapter = new TestProbe(actorSystem) - def extSimData = new ExtSimAdapterData(Map.of(1, extSimAdapter.ref()), new String[0]) + def extSimData = new ExtSimAdapterData(extSimAdapter.ref(), new String[0]) def newTickOpt = newTick.isEmpty() ? Optional.empty() : Optional.of(newTick.first()) def extSim = new TestSimulation(-2L, newTickOpt) extSim.setup(extSimData, new ArrayList()) when: - extSimData.queueExtMsg(new ActivationMessage(tick, 1)) + extSimData.queueExtMsg(new ActivationMessage(tick)) def finishedActual = handleMessage.invoke(extSim) then: finishedActual == finished - extSimAdapter.expectMsg(new CompletionMessage(newTickOpt, 1)) + extSimAdapter.expectMsg(new CompletionMessage(newTickOpt)) where: tick | newTick || finished @@ -113,41 +108,20 @@ class ExtSimulationSpec extends Specification { 10800L | [] || true } - def "An ExtSimulation throw an exception if a wrong phase was triggered"() { - given: - def tick = 0L - def newTick = 900L - def extSimAdapter = new TestProbe(actorSystem) - def extSimData = new ExtSimAdapterData(Map.of(1, extSimAdapter.ref()), new String[0]) - def extSim = new TestSimulation(tick, Optional.of(newTick)) - extSim.setup(extSimData, new ArrayList()) - - when: - extSimData.queueExtMsg(new ActivationMessage(tick, 0)) - handleMessage.invoke(extSim) - - then: - Exception ex = thrown() - // since we call a private method through reflection, - // our expected exception is wrapped in an InvocationTargetException - ex.getCause().getClass() == IllegalArgumentException - extSimAdapter.expectNoMessage() - } - def "An ExtSimulation should handle termination properly"() { given: def extSimAdapter = new TestProbe(actorSystem) - def extSimData = new ExtSimAdapterData(Map.of(1, extSimAdapter.ref()), new String[0]) + def extSimData = new ExtSimAdapterData(extSimAdapter.ref(), new String[0]) def extSim = new TestSimulation(-1L, Optional.empty()) extSim.setup(extSimData, new ArrayList()) when: - extSimData.queueExtMsg(new TerminationMessage(simlulationSuccessful, 1)) + extSimData.queueExtMsg(new TerminationMessage(simlulationSuccessful)) def finishedActual = handleMessage.invoke(extSim) then: finishedActual == finished - extSimAdapter.expectMsg(new TerminationCompleted(1)) + extSimAdapter.expectMsg(new TerminationCompleted()) where: simlulationSuccessful || finished @@ -160,7 +134,7 @@ class ExtSimulationSpec extends Specification { def "An ExtSimulation should handle unknown messages by throwing an exception"() { given: def extSimAdapter = new TestProbe(actorSystem) - def extSimData = new ExtSimAdapterData(Map.of(1, extSimAdapter.ref()), new String[0]) + def extSimData = new ExtSimAdapterData(extSimAdapter.ref(), new String[0]) def extSim = new TestSimulation(-1L, Optional.empty()) extSim.setup(extSimData, new ArrayList()) From 896885220823172059260cf7b8c40f2e8799a58e Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 12 Sep 2024 10:21:46 +0200 Subject: [PATCH 32/82] spotless --- .../java/edu/ie3/simona/api/data/ExtInputDataPackage.java | 4 +++- src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java | 2 -- .../simona/api/data/em/ontology/ProvideEmSetPointData.java | 6 ++---- .../edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java | 5 ++--- .../api/data/primarydata/ontology/ProvidePrimaryData.java | 6 ++---- .../edu/ie3/simona/api/simulation/ExtSimAdapterData.java | 3 --- .../java/edu/ie3/simona/api/simulation/ExtSimulation.java | 4 +++- 7 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java index 6b642b2..f8f4bb8 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java @@ -35,7 +35,9 @@ public Map getSimonaInputMap() { return dataMap; } - public Optional getMaybeNextTick() { return maybeNextTick; } + public Optional getMaybeNextTick() { + return maybeNextTick; + } /** Adds a value to the input map */ public void addValue(String id, ExtInputDataValue value) { diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java index 6f9867b..f238f5f 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java @@ -13,9 +13,7 @@ import edu.ie3.simona.api.data.em.ontology.ProvideEmSetPointData; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import edu.ie3.simona.api.exceptions.ConvertionException; - import java.util.*; - import org.apache.pekko.actor.ActorRef; public class ExtEmData implements ExtData { diff --git a/src/main/java/edu/ie3/simona/api/data/em/ontology/ProvideEmSetPointData.java b/src/main/java/edu/ie3/simona/api/data/em/ontology/ProvideEmSetPointData.java index 232818f..dc505dc 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ontology/ProvideEmSetPointData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ontology/ProvideEmSetPointData.java @@ -13,7 +13,5 @@ /** Message that provides em data (set points) from an external simulation */ public record ProvideEmSetPointData( - long tick, - Map emData, - Optional maybeNextTick -) implements EmDataMessageFromExt {} + long tick, Map emData, Optional maybeNextTick) + implements EmDataMessageFromExt {} diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java index b072c10..8a2af0a 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java @@ -13,9 +13,7 @@ import edu.ie3.simona.api.data.primarydata.ontology.PrimaryDataMessageFromExt; import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData; import edu.ie3.simona.api.exceptions.ConvertionException; - import java.util.*; - import org.apache.pekko.actor.ActorRef; public class ExtPrimaryData implements ExtData { @@ -54,7 +52,8 @@ public List getPrimaryDataAssets() { } /** Provide primary data from an external simulation in one tick. */ - public void providePrimaryData(Long tick, Map primaryData, Optional maybeNextTick) { + public void providePrimaryData( + Long tick, Map primaryData, Optional maybeNextTick) { sendExtMsg(new ProvidePrimaryData(tick, primaryData, maybeNextTick)); } diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java index 182ffed..2c31632 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ontology/ProvidePrimaryData.java @@ -13,7 +13,5 @@ /** Message that provides primary data from an external primary data simulation */ public record ProvidePrimaryData( - long tick, - Map primaryData, - Optional maybeNextTick -) implements PrimaryDataMessageFromExt {} + long tick, Map primaryData, Optional maybeNextTick) + implements PrimaryDataMessageFromExt {} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java b/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java index 54bc97a..e065f18 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java @@ -6,10 +6,8 @@ package edu.ie3.simona.api.simulation; -import edu.ie3.simona.api.simulation.ontology.ActivationMessage; import edu.ie3.simona.api.simulation.ontology.ControlMessageToExt; import edu.ie3.simona.api.simulation.ontology.ControlResponseMessageFromExt; -import java.util.Map; import java.util.concurrent.LinkedBlockingQueue; import org.apache.pekko.actor.ActorRef; @@ -38,7 +36,6 @@ public ActorRef getAdapter() { return extSimAdapter; } - /** * Called within SIMONA to queue messages for the external simulation * diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java index 4550dec..a5d3101 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java @@ -58,7 +58,9 @@ private boolean takeAndHandleMessage() throws InterruptedException { newTrigger = Optional.of(initialize()); } else { newTrigger = - doActivity(activationMessage.tick()); // this is blocking until processing of this tick has finished + doActivity( + activationMessage + .tick()); // this is blocking until processing of this tick has finished } data.send(new CompletionMessage(newTrigger)); From 41cd02c3b164038a762d364558c4dd8ec52be21c Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 12 Sep 2024 10:28:44 +0200 Subject: [PATCH 33/82] fix javadoc --- .../ie3/simona/api/simulation/ontology/ActivationMessage.java | 1 - .../ie3/simona/api/simulation/ontology/CompletionMessage.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/ActivationMessage.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/ActivationMessage.java index 61e4022..f6b7f13 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/ActivationMessage.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/ActivationMessage.java @@ -10,6 +10,5 @@ * Message that the external simulation is activated with by SIMONA * * @param tick The current tick - * @param phase Phase of the simulation */ public record ActivationMessage(long tick) implements ControlMessageToExt {} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ontology/CompletionMessage.java b/src/main/java/edu/ie3/simona/api/simulation/ontology/CompletionMessage.java index be251ab..35364c9 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ontology/CompletionMessage.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ontology/CompletionMessage.java @@ -12,7 +12,6 @@ * Message that is returned to SIMONA * * @param nextActivation The tick that the external simulation would like to be activated at again - * @param phase The phase of the simulation */ public record CompletionMessage(Optional nextActivation) implements ControlResponseMessageFromExt {} From 376c05703729c26aea84b07699fcbbe78540167b Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 12 Sep 2024 14:36:22 +0200 Subject: [PATCH 34/82] fix codacy --- .../edu/ie3/simona/api/data/em/ExtEmDataTest.groovy | 6 +++--- .../api/data/primarydata/ExtPrimaryDataTest.groovy | 6 +++--- .../simona/api/data/results/ExtResultDataTest.groovy | 6 ++---- .../api/data/results/ExtResultPackageTest.groovy | 12 ------------ .../simona/api/simulation/ExtSimulationSpec.groovy | 2 +- .../simulation/mapping/ExtEntityMappingTest.groovy | 4 ++-- 6 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy index d891219..9321e2f 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy @@ -33,7 +33,7 @@ class ExtEmDataTest extends Specification { ) class TestInputDataValue implements ExtInputDataValue { - private PValue value + private final PValue value TestInputDataValue(PValue value) { this.value = value @@ -48,7 +48,7 @@ class ExtEmDataTest extends Specification { @Override PValue convert(ExtInputDataValue entity) throws ConvertionException { if (entity instanceof TestInputDataValue) { - return entity.getValue() + return entity.value } else { throw new ConvertionException("This factory can only convert PValue entities.") } @@ -74,7 +74,7 @@ class ExtEmDataTest extends Specification { extSimAdapter.ref() ) - def emData = new HashMap() + def emData = [:] as HashMap def uuid = UUID.randomUUID() emData.put(uuid.toString(), pValue) diff --git a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy index 2ecda57..dd539dc 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy @@ -33,7 +33,7 @@ class ExtPrimaryDataTest extends Specification { ) class TestInputDataValue implements ExtInputDataValue { - private Value value + private final Value value TestInputDataValue(Value value) { this.value = value @@ -48,7 +48,7 @@ class ExtPrimaryDataTest extends Specification { @Override Value convert(ExtInputDataValue entity) throws ConvertionException { if (entity instanceof TestInputDataValue) { - return entity.getValue() + return entity.value } else { throw new ConvertionException("This factory can only convert PValue entities.") } @@ -74,7 +74,7 @@ class ExtPrimaryDataTest extends Specification { extSimAdapter.ref() ) - def primaryData = new HashMap() + def primaryData = [:] as HashMap def uuid = UUID.randomUUID() primaryData.put(uuid.toString(), pValue) diff --git a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy index 8e52c07..ef73b22 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy @@ -1,14 +1,12 @@ package edu.ie3.simona.api.data.results import edu.ie3.datamodel.models.StandardUnits -import edu.ie3.datamodel.models.result.ResultEntity import edu.ie3.datamodel.models.result.connector.LineResult import edu.ie3.datamodel.models.result.system.LoadResult import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage import edu.ie3.simona.api.data.results.ontology.ProvideResultEntities import edu.ie3.simona.api.data.results.ontology.RequestResultEntities import edu.ie3.simona.api.data.results.ontology.ResultDataResponseMessageToExt -import edu.ie3.simona.api.exceptions.ConvertionException import org.apache.pekko.actor.ActorSystem import org.apache.pekko.testkit.TestProbe import org.apache.pekko.testkit.javadsl.TestKit @@ -38,10 +36,10 @@ class ExtResultDataTest extends Specification { ) @Shared - HashMap participantResultAssetMapping = Map.of(loadUuid, "Load") as HashMap + Map participantResultAssetMapping = Map.of(loadUuid, "Load") @Shared - HashMap gridResultAssetMapping = [:] + Map gridResultAssetMapping = [:] class WrongResultDataResponseMessageToExt implements ResultDataResponseMessageToExt {} diff --git a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultPackageTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultPackageTest.groovy index fbc1517..276eb3c 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultPackageTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultPackageTest.groovy @@ -2,24 +2,12 @@ package edu.ie3.simona.api.data.results import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.result.NodeResult -import edu.ie3.datamodel.models.result.connector.LineResult import edu.ie3.datamodel.models.result.system.LoadResult -import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage -import edu.ie3.simona.api.data.results.ontology.ProvideResultEntities -import edu.ie3.simona.api.data.results.ontology.RequestResultEntities -import edu.ie3.simona.api.data.results.ontology.ResultDataResponseMessageToExt import edu.ie3.util.quantities.PowerSystemUnits -import org.apache.pekko.actor.ActorSystem -import org.apache.pekko.testkit.TestProbe -import org.apache.pekko.testkit.javadsl.TestKit import spock.lang.Shared import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import javax.measure.Quantity -import javax.measure.quantity.Angle -import javax.measure.quantity.Dimensionless -import javax.measure.quantity.ElectricCurrent import java.time.ZonedDateTime class ExtResultPackageTest extends Specification { diff --git a/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy b/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy index 5ba2e09..054a04f 100644 --- a/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy +++ b/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy @@ -48,7 +48,7 @@ class ExtSimulationSpec extends Specification { @Override List getDataConnections() { - return new ArrayList() + return [] } } diff --git a/src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingTest.groovy b/src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingTest.groovy index 8e1710f..1878de5 100644 --- a/src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingTest.groovy @@ -24,7 +24,7 @@ class ExtEntityMappingTest extends Specification { "input" ) - def "ExtEntityMapping should return external id to SIMONA uuid mapping correctly"() { + def "ExtEntityMapping should return SIMONA uuid mapping correctly"() { given: def extAssetList = List.of(extResultEntry, extInputEntry) def extEntryMapping = new ExtEntityMapping(extAssetList) @@ -38,7 +38,7 @@ class ExtEntityMappingTest extends Specification { } - def "ExtEntityMapping should return external id to SIMONA uuid mapping correctly"() { + def "ExtEntityMapping should return external id mapping correctly"() { given: def extAssetList = List.of(extResultEntry, extInputEntry) def extEntryMapping = new ExtEntityMapping(extAssetList) From aac59704e7365717c49fcced942c694133706909 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 08:18:00 +0000 Subject: [PATCH 35/82] Bump pekkoVersion from 1.0.3 to 1.1.1 (#199) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9df2fcb..ed3e39f 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ ext { // required for pekko scalaVersion = "2.13" scalaBinaryVersion = "2.13.14" - pekkoVersion = "1.0.3" + pekkoVersion = "1.1.1" } group = 'com.github.ie3-institute' From 9d9e306475b48956d2cde7a733306b78e96a763f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 08:20:49 +0000 Subject: [PATCH 36/82] Bump com.github.spotbugs from 6.0.21 to 6.0.22 (#198) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ed3e39f..51c821b 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'java' // java support id 'com.diffplug.spotless' version '6.25.0'//code format id 'pmd' // code check, working on source code - id 'com.github.spotbugs' version '6.0.21' // code check, working on byte code + id 'com.github.spotbugs' version '6.0.22' // code check, working on byte code id "org.sonarqube" version "5.1.0.4882" // sonarqube id 'signing' id 'maven-publish' // publish to a maven repo (local or mvn central, has to be defined) From eae57ff0678b89ed017e6bd35d499238a3e06ee8 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Wed, 18 Sep 2024 11:41:51 +0200 Subject: [PATCH 37/82] improve doc --- .../DataQueueExtSimulationExtSimulator.java | 2 +- .../ie3/simona/api/data/ExtDataPackage.java | 1 + .../simona/api/data/ExtInputDataPackage.java | 25 ++++++++++++------- .../ie3/simona/api/data/ExtOutputData.java | 4 +++ .../ie3/simona/api/data/em/EmDataFactory.java | 4 ++- .../data/primarydata/PrimaryDataFactory.java | 5 +++- .../api/data/results/ExtResultData.java | 9 ++++++- .../api/data/results/ExtResultPackage.java | 10 +++++--- .../simulation/mapping/ExtEntityFactory.java | 1 + .../simona/api/data/em/ExtEmDataTest.groovy | 4 +-- .../primarydata/ExtPrimaryDataTest.groovy | 4 +-- 11 files changed, 48 insertions(+), 21 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java b/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java index e0ce05b..011e00e 100644 --- a/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java +++ b/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java @@ -8,7 +8,7 @@ import java.util.concurrent.LinkedBlockingQueue; -/** Data queue to allow data flow between SIMONA and a co-simulator */ +/** Data queue to allow data flow between SIMONA and an external simulation */ public class DataQueueExtSimulationExtSimulator { private final LinkedBlockingQueue receiverTriggerQueue = new LinkedBlockingQueue<>(); diff --git a/src/main/java/edu/ie3/simona/api/data/ExtDataPackage.java b/src/main/java/edu/ie3/simona/api/data/ExtDataPackage.java index 8171e67..33abcb4 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtDataPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtDataPackage.java @@ -6,4 +6,5 @@ package edu.ie3.simona.api.data; +/** Interface for data format to exchange data with an external simulation */ public interface ExtDataPackage {} diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java index f8f4bb8..75a3195 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java @@ -13,22 +13,33 @@ /** Contains all inputs for SIMONA for a certain tick */ public class ExtInputDataPackage implements ExtDataPackage { + private final long tick; + /** Map external id to input for SIMONA */ private final Map dataMap; private final Optional maybeNextTick; - public ExtInputDataPackage(Map dataMap, Optional maybeNextTick) { + /** + * Container class for input data for SIMONA + * + * @param tick current tick + * @param dataMap data to be provided to SIMONA + * @param maybeNextTick tick, when the next data will be provided + */ + public ExtInputDataPackage( + long tick, Map dataMap, Optional maybeNextTick) { + this.tick = tick; this.dataMap = dataMap; this.maybeNextTick = maybeNextTick; } - public ExtInputDataPackage(long nextTick) { - this(new HashMap<>(), Optional.of(nextTick)); + public ExtInputDataPackage(long tick, long nextTick) { + this(tick, new HashMap<>(), Optional.of(nextTick)); } - public ExtInputDataPackage() { - this(new HashMap<>(), Optional.empty()); + public ExtInputDataPackage(long tick) { + this(tick, new HashMap<>(), Optional.empty()); } public Map getSimonaInputMap() { @@ -43,8 +54,4 @@ public Optional getMaybeNextTick() { public void addValue(String id, ExtInputDataValue value) { dataMap.put(id, value); } - - public String toString() { - return dataMap.toString(); - } } diff --git a/src/main/java/edu/ie3/simona/api/data/ExtOutputData.java b/src/main/java/edu/ie3/simona/api/data/ExtOutputData.java index e62ed16..80d949a 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtOutputData.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtOutputData.java @@ -6,4 +6,8 @@ package edu.ie3.simona.api.data; +/** + * Interface for a connection between SIMONA and an external simulation with data flow from SIMONA + * to external + */ public interface ExtOutputData extends ExtData {} diff --git a/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java b/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java index 2dd9862..ffa440e 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java +++ b/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java @@ -13,6 +13,8 @@ /** Interface that should be implemented by an external simulation. */ public interface EmDataFactory { - /** Should convert an object to a primary data value with a check if the object is primary data */ + /** + * Should convert an object to an em data value with a check if the object has a valid data type + */ PValue convert(ExtInputDataValue entity) throws ConvertionException; } diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/PrimaryDataFactory.java b/src/main/java/edu/ie3/simona/api/data/primarydata/PrimaryDataFactory.java index fc108cf..bd7d262 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/PrimaryDataFactory.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/PrimaryDataFactory.java @@ -13,6 +13,9 @@ /** Interface that should be implemented by an external simulation. */ public interface PrimaryDataFactory { - /** Should convert an object to a primary data value with a check if the object is primary data */ + /** + * Should convert an external value to a primary data value with a check if the object is primary + * data + */ Value convert(ExtInputDataValue entity) throws ConvertionException; } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java index 5d1ea70..5b2da6c 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java @@ -54,7 +54,14 @@ public ExtResultData( this.gridResultAssetMapping = gridResultAssetMapping; } - /** Sets the actor refs for data and control flow */ + /** + * Sets the actor refs for data and control flow + * + * @param dataService actor ref to the adapter of the data service for data messages + * @param dataServiceActivation actor ref to the adapter of the data service for schedule + * activation messages + * @param extSimAdapter actor ref to the extSimAdapter + */ public void setActorRefs( ActorRef dataService, ActorRef dataServiceActivation, ActorRef extSimAdapter) { this.dataService = dataService; diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java index b6f990d..1d34c9a 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java @@ -29,6 +29,12 @@ public class ExtResultPackage implements ExtDataPackage { */ private final Map simonaResultsMap; + /** + * Container class for output data from SIMONA + * + * @param tick current tick + * @param simonaResultsMap results from SIMONA with external id as key + */ public ExtResultPackage(Long tick, Map simonaResultsMap) { this.tick = tick; this.simonaResultsMap = simonaResultsMap; @@ -83,8 +89,4 @@ public double getReactivePower(String assetId) { public double getLineLoading(String assetId) { throw new IllegalArgumentException("LINE LOADING is not implemented yet!"); } - - public String toString() { - return simonaResultsMap.toString(); - } } diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java index 8e6f466..9504750 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java @@ -13,6 +13,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +/** Class to build a mapping entry external simulation to SIMONA */ public class ExtEntityFactory extends EntityFactory { public static final String SIMONA_UUID = "uuid"; diff --git a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy index 9321e2f..7ea0495 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy @@ -92,7 +92,7 @@ class ExtEmDataTest extends Specification { given: def extEmData = new ExtEmData(new TestEmDataFactory(), extEmDataMapping) def inputDataMap = Map.of("Em", new TestInputDataValue(pValue)) - def inputDataPackage = new ExtInputDataPackage(inputDataMap, Optional.of(900L)) + def inputDataPackage = new ExtInputDataPackage(0L, inputDataMap, Optional.of(900L)) when: def emDataMap = extEmData.createExtEmDataMap(inputDataPackage) @@ -105,7 +105,7 @@ class ExtEmDataTest extends Specification { given: def extEmData = new ExtEmData(new TestEmDataFactory(), extEmDataMapping) def inputDataMap = Map.of("Load", new TestInputDataValue(pValue)) - def inputDataPackage = new ExtInputDataPackage(inputDataMap, Optional.of(900L)) + def inputDataPackage = new ExtInputDataPackage(0L, inputDataMap, Optional.of(900L)) when: extEmData.createExtEmDataMap(inputDataPackage) diff --git a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy index dd539dc..6b57cd7 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy @@ -92,7 +92,7 @@ class ExtPrimaryDataTest extends Specification { given: def extPrimaryData = new ExtPrimaryData(new TestPrimaryDataFactory(), extPrimaryDataMapping) def inputDataMap = Map.of("Pv", new TestInputDataValue(pValue)) - def inputDataPackage = new ExtInputDataPackage(inputDataMap, Optional.of(900L)) + def inputDataPackage = new ExtInputDataPackage(0L, inputDataMap, Optional.of(900L)) when: def primaryDataMap = extPrimaryData.createExtPrimaryDataMap(inputDataPackage) @@ -105,7 +105,7 @@ class ExtPrimaryDataTest extends Specification { given: def extPrimaryData = new ExtPrimaryData(new TestPrimaryDataFactory(), extPrimaryDataMapping) def inputDataMap = Map.of("Load", new TestInputDataValue(pValue)) - def inputDataPackage = new ExtInputDataPackage(inputDataMap, Optional.of(900L)) + def inputDataPackage = new ExtInputDataPackage(0L, inputDataMap, Optional.of(900L)) when: extPrimaryData.createExtPrimaryDataMap(inputDataPackage) From 6a903dd6df6b1f253069b5c5407364adc2f8f83f Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Sat, 21 Sep 2024 14:51:42 +0200 Subject: [PATCH 38/82] code quality --- .../api/data/results/ExtResultData.java | 19 ------------------- .../api/data/results/ExtResultPackage.java | 3 +-- .../ontology/ProvideResultEntities.java | 8 -------- .../mapping/ExtEntityMappingSource.java | 2 +- 4 files changed, 2 insertions(+), 30 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java index 5b2da6c..3ab5baa 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java @@ -46,7 +46,6 @@ public class ExtResultData implements ExtOutputData { private ZonedDateTime simulationStartTime; - private Long powerFlowResolution; public ExtResultData( Map participantResultAssetMapping, Map gridResultAssetMapping) { @@ -69,24 +68,6 @@ public void setActorRefs( this.extSimAdapter = extSimAdapter; } - /** Sets simulation data from config */ - public void setSimulationData(ZonedDateTime simulationStartTime, Long powerFlowResolution) { - this.simulationStartTime = simulationStartTime; - this.powerFlowResolution = powerFlowResolution; - } - - public ZonedDateTime getSimulationStartTime() { - return simulationStartTime; - } - - public Long getPowerFlowResolution() { - return powerFlowResolution; - } - - public ZonedDateTime getSimulationTime(Long tick) { - return simulationStartTime.plusSeconds(tick); - } - public List getGridResultDataAssets() { return gridResultAssetMapping.keySet().stream().toList(); } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java index 1d34c9a..3611370 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java @@ -49,8 +49,7 @@ public Long getTick() { */ public double getVoltageDeviation(String assetId) { if (simonaResultsMap.get(assetId) instanceof NodeResult nodeResult) { - ComparableQuantity vMagDev = Quantities.getQuantity(0, PU); - vMagDev = + ComparableQuantity vMagDev = Quantities.getQuantity(0, PU) .add(nodeResult.getvMag().subtract(Quantities.getQuantity(1.0, PU))); return vMagDev.getValue().doubleValue(); diff --git a/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java b/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java index a0070fe..cb4e3d1 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java @@ -15,15 +15,7 @@ /** Provides a list of results from SIMONA to an external simulation. */ public record ProvideResultEntities(List results) implements ResultDataResponseMessageToExt { - public ProvideResultEntities() { - this(new ArrayList<>()); - } - public ProvideResultEntities(Map resultMap) { this(resultMap.values().stream().toList()); } - - public ProvideResultEntities(List results) { - this.results = results; - } } diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSource.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSource.java index 137841b..8a56471 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSource.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSource.java @@ -11,7 +11,7 @@ public abstract class ExtEntityMappingSource { protected final ExtEntityFactory factory; - public ExtEntityMappingSource() { + protected ExtEntityMappingSource() { this.factory = new ExtEntityFactory(); } } From 3e471163e6bde4340204c166171886bf01a65a3d Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Sat, 21 Sep 2024 14:57:02 +0200 Subject: [PATCH 39/82] changelog and spotless --- CHANGELOG.md | 3 ++- .../java/edu/ie3/simona/api/data/results/ExtResultData.java | 4 ---- .../api/data/results/ontology/ProvideResultEntities.java | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e499ca..8c8adae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Implemented `ExtPrimaryData` and `ExtResultsData` [#145](https://github.com/ie3-institute/simonaAPI/issues/145) - Have EV simulation communicate the next tick [#170](https://github.com/ie3-institute/simonaAPI/issues/170) -- Only communicate the next tick of activation of EV simulation as a whole [#176](https://github.com/ie3-institute/simonaAPI/issues/176) +- Only communicate the next tick of activation of EV simulation as a whole [#176](https://github.co/ie3-institute/simonaAPI/issues/176) +- Enable initialization of external data simulation [#167](https://github.com/ie3-institute/simonaAPI/issues/167) ## [0.4.0] - 2023-11-22 diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java index 3ab5baa..bd5eeed 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java @@ -15,7 +15,6 @@ import edu.ie3.simona.api.data.results.ontology.RequestResultEntities; import edu.ie3.simona.api.data.results.ontology.ResultDataMessageFromExt; import edu.ie3.simona.api.data.results.ontology.ResultDataResponseMessageToExt; -import java.time.ZonedDateTime; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -44,9 +43,6 @@ public class ExtResultData implements ExtOutputData { /** Map uuid to external id of system participants */ private final Map participantResultAssetMapping; - private ZonedDateTime simulationStartTime; - - public ExtResultData( Map participantResultAssetMapping, Map gridResultAssetMapping) { this.participantResultAssetMapping = participantResultAssetMapping; diff --git a/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java b/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java index cb4e3d1..525d702 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ontology/ProvideResultEntities.java @@ -7,7 +7,6 @@ package edu.ie3.simona.api.data.results.ontology; import edu.ie3.datamodel.models.result.ModelResultEntity; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.UUID; From b5f316ea3fa03005f0c0512edaa4cef5115f5926 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Sat, 21 Sep 2024 15:22:48 +0200 Subject: [PATCH 40/82] codacy --- .../java/edu/ie3/simona/api/data/ExtInputDataPackage.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java index 75a3195..af959ce 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java @@ -46,6 +46,10 @@ public Map getSimonaInputMap() { return dataMap; } + public Long getTick() { + return tick; + } + public Optional getMaybeNextTick() { return maybeNextTick; } From 3454047262bd7237b5125a9f7f4f29640061d2b8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 06:51:41 +0000 Subject: [PATCH 41/82] Bump com.github.spotbugs from 6.0.22 to 6.0.23 (#201) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 51c821b..56a93f3 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'java' // java support id 'com.diffplug.spotless' version '6.25.0'//code format id 'pmd' // code check, working on source code - id 'com.github.spotbugs' version '6.0.22' // code check, working on byte code + id 'com.github.spotbugs' version '6.0.23' // code check, working on byte code id "org.sonarqube" version "5.1.0.4882" // sonarqube id 'signing' id 'maven-publish' // publish to a maven repo (local or mvn central, has to be defined) From 7fea26622f7316232b74f26b498bf9999c6bd031 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 27 Sep 2024 07:59:10 +0000 Subject: [PATCH 42/82] Bump com.fasterxml.jackson.core:jackson-databind from 2.17.2 to 2.18.0 (#202) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 56a93f3..a3a7fe3 100644 --- a/build.gradle +++ b/build.gradle @@ -72,7 +72,7 @@ dependencies{ // TESTING testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0' - implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.17.2' + implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.18.0' } task printVersion { From 494e951a409d172dc6f473cad31a636564ec2ce3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 27 Sep 2024 08:21:07 +0000 Subject: [PATCH 43/82] Bump org.scala-lang:scala-library from 2.13.14 to 2.13.15 (#200) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index a3a7fe3..7f7faeb 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ ext { // required for pekko scalaVersion = "2.13" - scalaBinaryVersion = "2.13.14" + scalaBinaryVersion = "2.13.15" pekkoVersion = "1.1.1" } From a5aa82ea7f0b44c751d17941c5b1d8606208f4d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 12:40:50 +0000 Subject: [PATCH 44/82] Bump com.github.spotbugs from 6.0.23 to 6.0.24 (#203) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7f7faeb..bb1d1c3 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'java' // java support id 'com.diffplug.spotless' version '6.25.0'//code format id 'pmd' // code check, working on source code - id 'com.github.spotbugs' version '6.0.23' // code check, working on byte code + id 'com.github.spotbugs' version '6.0.24' // code check, working on byte code id "org.sonarqube" version "5.1.0.4882" // sonarqube id 'signing' id 'maven-publish' // publish to a maven repo (local or mvn central, has to be defined) From ae70000fb46ddd0549c0d3da63687c80b0fdb730 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 07:37:44 +0000 Subject: [PATCH 45/82] Bump pekkoVersion from 1.1.1 to 1.1.2 (#204) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index bb1d1c3..d4b21f8 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ ext { // required for pekko scalaVersion = "2.13" scalaBinaryVersion = "2.13.15" - pekkoVersion = "1.1.1" + pekkoVersion = "1.1.2" } group = 'com.github.ie3-institute' From cc8819d19df0bd37735b341b273805e4012145a8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:40:21 +0000 Subject: [PATCH 46/82] Bump com.github.spotbugs from 6.0.24 to 6.0.25 (#205) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index d4b21f8..09e3c1d 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'java' // java support id 'com.diffplug.spotless' version '6.25.0'//code format id 'pmd' // code check, working on source code - id 'com.github.spotbugs' version '6.0.24' // code check, working on byte code + id 'com.github.spotbugs' version '6.0.25' // code check, working on byte code id "org.sonarqube" version "5.1.0.4882" // sonarqube id 'signing' id 'maven-publish' // publish to a maven repo (local or mvn central, has to be defined) From 62c938b772e2b362e91fbe7ba0c9c1f10b7b0713 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Wed, 23 Oct 2024 15:13:26 +0200 Subject: [PATCH 47/82] deleted ExtDataSimulation implementations --- .../ie3/simona/api/data/em/ExtEmDataSimulation.java | 11 ----------- .../data/primarydata/ExtPrimaryDataSimulation.java | 11 ----------- .../api/data/results/ExtResultDataSimulation.java | 11 ----------- 3 files changed, 33 deletions(-) delete mode 100644 src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java delete mode 100644 src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java delete mode 100644 src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java deleted file mode 100644 index dfc9937..0000000 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataSimulation.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * © 2024. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation - */ - -package edu.ie3.simona.api.data.em; - -import edu.ie3.simona.api.data.ExtDataSimulation; - -public interface ExtEmDataSimulation extends ExtDataSimulation {} diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java deleted file mode 100644 index 6e646a8..0000000 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * © 2024. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation - */ - -package edu.ie3.simona.api.data.primarydata; - -import edu.ie3.simona.api.data.ExtDataSimulation; - -public interface ExtPrimaryDataSimulation extends ExtDataSimulation {} diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java deleted file mode 100644 index 3947f36..0000000 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataSimulation.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * © 2024. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation - */ - -package edu.ie3.simona.api.data.results; - -import edu.ie3.simona.api.data.ExtDataSimulation; - -public interface ExtResultDataSimulation extends ExtDataSimulation {} From 930c647f6bbf15537c8f9d1843d176525b0b4d80 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Wed, 23 Oct 2024 15:26:41 +0200 Subject: [PATCH 48/82] changes after review --- .../java/edu/ie3/simona/api/data/em/ExtEmData.java | 13 +++++++------ .../data/primarydata/ExtPrimaryDataSimulation.java | 4 ++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java index f238f5f..39a7877 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java @@ -19,7 +19,7 @@ public class ExtEmData implements ExtData { /** Actor reference to service that handles ev data within SIMONA */ - private ActorRef dataService; + private ActorRef emDataService; /** Actor reference to adapter that handles scheduler control flow in SIMONA */ private ActorRef extSimAdapter; @@ -36,8 +36,8 @@ public ExtEmData(EmDataFactory emDataFactory, Map extEmMapping) { } /** Sets the actor refs for data and control flow */ - public void setActorRefs(ActorRef dataService, ActorRef extSimAdapter) { - this.dataService = dataService; + public void setActorRefs(ActorRef emDataService, ActorRef extSimAdapter) { + this.emDataService = emDataService; this.extSimAdapter = extSimAdapter; } @@ -46,11 +46,12 @@ public List getControlledEms() { return extEmMapping.values().stream().toList(); } + /** Return the factory, that converts external input data to set points for EM agents */ public EmDataFactory getEmDataFactory() { return emDataFactory; } - /** Provide primary data from an external simulation in one tick. */ + /** Provide primary data from an external simulation for one tick. */ public void provideEmData(Long tick, Map emData, Optional maybeNextTick) { sendExtMsg(new ProvideEmSetPointData(tick, emData, maybeNextTick)); } @@ -63,9 +64,9 @@ public void provideEmData(Long tick, Map emData, Optional ma * @param msg the data/information that is sent to SIMONA's external primary data service */ public void sendExtMsg(EmDataMessageFromExt msg) { - dataService.tell(msg, ActorRef.noSender()); + emDataService.tell(msg, ActorRef.noSender()); // we need to schedule data receiver activation with scheduler - extSimAdapter.tell(new ScheduleDataServiceMessage(dataService), ActorRef.noSender()); + extSimAdapter.tell(new ScheduleDataServiceMessage(emDataService), ActorRef.noSender()); } /** Converts an input data package from an external simulation to a map of set points */ diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java index 6e646a8..16b2e14 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataSimulation.java @@ -8,4 +8,8 @@ import edu.ie3.simona.api.data.ExtDataSimulation; +/** + * An external simulation that provides primary data should implement this interface and handle the + * ExtPrimaryData that is handed over. + */ public interface ExtPrimaryDataSimulation extends ExtDataSimulation {} From c0132843d387d054ba8881f75bc8b8c90e102fb8 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 24 Oct 2024 13:26:17 +0200 Subject: [PATCH 49/82] changes after review --- .../simona/api/data/results/ExtResultData.java | 10 +++++----- .../api/data/results/ExtResultPackage.java | 7 ++++--- .../api/simulation/ExtSimAdapterData.java | 4 +--- .../simona/api/simulation/ExtSimulation.java | 6 ++---- .../simulation/mapping/ExtEntityFactory.java | 2 +- .../simulation/mapping/ExtEntityMapping.java | 18 +++++++++--------- 6 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java index bd5eeed..f426a10 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java @@ -29,7 +29,7 @@ public class ExtResultData implements ExtOutputData { new LinkedBlockingQueue<>(); /** Actor reference to service that handles result data within SIMONA */ - private ActorRef dataService; + private ActorRef extResultDataService; /** Actor reference to the dataServiceAdapter */ private ActorRef dataServiceActivation; @@ -52,14 +52,14 @@ public ExtResultData( /** * Sets the actor refs for data and control flow * - * @param dataService actor ref to the adapter of the data service for data messages + * @param extResultDataService actor ref to the adapter of the data service for data messages * @param dataServiceActivation actor ref to the adapter of the data service for schedule * activation messages * @param extSimAdapter actor ref to the extSimAdapter */ public void setActorRefs( - ActorRef dataService, ActorRef dataServiceActivation, ActorRef extSimAdapter) { - this.dataService = dataService; + ActorRef extResultDataService, ActorRef dataServiceActivation, ActorRef extSimAdapter) { + this.extResultDataService = extResultDataService; this.dataServiceActivation = dataServiceActivation; this.extSimAdapter = extSimAdapter; } @@ -111,7 +111,7 @@ protected Map createResultMap(List * @param msg the data/information that is sent to SIMONA's result data service */ public void sendExtMsg(ResultDataMessageFromExt msg) { - dataService.tell(msg, ActorRef.noSender()); + extResultDataService.tell(msg, ActorRef.noSender()); // we need to schedule data receiver activation with scheduler extSimAdapter.tell(new ScheduleDataServiceMessage(dataServiceActivation), ActorRef.noSender()); } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java index 3611370..6d72aac 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java @@ -10,6 +10,7 @@ import edu.ie3.datamodel.models.result.ModelResultEntity; import edu.ie3.datamodel.models.result.NodeResult; +import edu.ie3.datamodel.models.result.connector.LineResult; import edu.ie3.datamodel.models.result.system.SystemParticipantResult; import edu.ie3.simona.api.data.ExtDataPackage; import java.util.Map; @@ -59,7 +60,7 @@ public double getVoltageDeviation(String assetId) { } /** - * Returns the active power for certain asset, if this asset provided a {@link + * Returns the active power in kW for certain asset, if this asset provided a {@link * SystemParticipantResult} */ public double getActivePower(String assetId) { @@ -72,7 +73,7 @@ public double getActivePower(String assetId) { } /** - * Returns the reactive power for certain asset, if this asset provided a {@link + * Returns the reactive power in kVAr for certain asset, if this asset provided a {@link * SystemParticipantResult} */ public double getReactivePower(String assetId) { @@ -84,7 +85,7 @@ public double getReactivePower(String assetId) { } } - /** Returns the line loading for certain asset, if this asset provided a {@link NodeResult} */ + /** Returns the line loading for certain asset, if this asset provided a {@link LineResult} */ public double getLineLoading(String assetId) { throw new IllegalArgumentException("LINE LOADING is not implemented yet!"); } diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java b/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java index e065f18..e0906ce 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java @@ -17,9 +17,7 @@ public class ExtSimAdapterData { public final LinkedBlockingQueue receiveMessageQueue = new LinkedBlockingQueue<>(); - /** - * Actor references to the adapters for the phases that handles scheduler control flow in SIMONA - */ + /** Actor reference to the adapter for the phases that handles scheduler control flow in SIMONA */ private final ActorRef extSimAdapter; /** CLI arguments with which SIMONA is initiated */ diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java index a5d3101..5e7c9e7 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java @@ -57,10 +57,8 @@ private boolean takeAndHandleMessage() throws InterruptedException { // this is blocking until initialization has finished newTrigger = Optional.of(initialize()); } else { - newTrigger = - doActivity( - activationMessage - .tick()); // this is blocking until processing of this tick has finished + // this is blocking until processing of this tick has finished + newTrigger = doActivity(activationMessage.tick()); } data.send(new CompletionMessage(newTrigger)); diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java index 9504750..1626324 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java @@ -13,7 +13,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -/** Class to build a mapping entry external simulation to SIMONA */ +/** Class to build a mapping entry from the external simulation to SIMONA */ public class ExtEntityFactory extends EntityFactory { public static final String SIMONA_UUID = "uuid"; diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMapping.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMapping.java index e964a17..a0826fd 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMapping.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMapping.java @@ -8,7 +8,7 @@ import java.util.*; -/** Contains the mapping between SIMONA uuid and external id and the data type the assets hold */ +/** Contains the mapping between SIMONA uuid, the external id and the data type the assets hold */ public class ExtEntityMapping { private final List extEntities; @@ -23,15 +23,15 @@ public ExtEntityMapping(List extEntityEntryList) { * @param dataType data type the external asset expects * @return Mapping external id to SIMONA uuid */ - public Map getExtIdUuidMapping(String dataType) { - Map extIdUuidMapping = new HashMap<>(); + public Map getExtId2UuidMapping(String dataType) { + Map extId2UuidMapping = new HashMap<>(); extEntities.forEach( ent -> { if (Objects.equals(ent.resultType(), dataType)) { - extIdUuidMapping.put(ent.id(), ent.uuid()); + extId2UuidMapping.put(ent.id(), ent.uuid()); } }); - return extIdUuidMapping; + return extId2UuidMapping; } /** @@ -40,14 +40,14 @@ public Map getExtIdUuidMapping(String dataType) { * @param dataType data type the external asset expects * @return Mapping SIMONA uuid to external id */ - public Map getExtUuidIdMapping(String dataType) { - Map extUuidIdMapping = new HashMap<>(); + public Map getExtUuid2IdMapping(String dataType) { + Map extUuid2IdMapping = new HashMap<>(); extEntities.forEach( ent -> { if (Objects.equals(ent.resultType(), dataType)) { - extUuidIdMapping.put(ent.uuid(), ent.id()); + extUuid2IdMapping.put(ent.uuid(), ent.id()); } }); - return extUuidIdMapping; + return extUuid2IdMapping; } } From f4c60010803f58315bb7a47c5481215069152cdf Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 24 Oct 2024 13:31:45 +0200 Subject: [PATCH 50/82] changes after review --- .../simona/api/simulation/mapping/ExtEntityMappingTest.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingTest.groovy b/src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingTest.groovy index 1878de5..cd92e95 100644 --- a/src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingTest.groovy @@ -30,7 +30,7 @@ class ExtEntityMappingTest extends Specification { def extEntryMapping = new ExtEntityMapping(extAssetList) when: - def inputMap = extEntryMapping.getExtIdUuidMapping("input") + def inputMap = extEntryMapping.getExtId2UuidMapping("input") then: inputMap.size() == 1 @@ -44,7 +44,7 @@ class ExtEntityMappingTest extends Specification { def extEntryMapping = new ExtEntityMapping(extAssetList) when: - def inputMap = extEntryMapping.getExtUuidIdMapping("input") + def inputMap = extEntryMapping.getExtUuid2IdMapping("input") then: inputMap.size() == 1 From 6146585ef323f8e0b41e603043acd6314ff914f5 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 24 Oct 2024 14:19:06 +0200 Subject: [PATCH 51/82] implement DataServiceTestData --- .../simona/api/data/em/ExtEmDataTest.groovy | 31 ++++++++----------- .../primarydata/ExtPrimaryDataTest.groovy | 11 ++----- .../api/data/results/ExtResultDataTest.groovy | 18 +++-------- .../test/common/DataServiceTestData.groovy | 20 ++++++++++++ .../api/test/common/TestInputDataValue.groovy | 18 +++++++++++ 5 files changed, 58 insertions(+), 40 deletions(-) create mode 100644 src/test/groovy/edu/ie3/simona/api/test/common/DataServiceTestData.groovy create mode 100644 src/test/groovy/edu/ie3/simona/api/test/common/TestInputDataValue.groovy diff --git a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy index 7ea0495..df543a6 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy @@ -8,6 +8,7 @@ import edu.ie3.simona.api.data.ExtInputDataValue import edu.ie3.simona.api.data.em.ontology.ProvideEmSetPointData import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage import edu.ie3.simona.api.exceptions.ConvertionException +import edu.ie3.simona.api.test.common.DataServiceTestData import org.apache.pekko.actor.ActorSystem import org.apache.pekko.testkit.TestProbe import org.apache.pekko.testkit.javadsl.TestKit @@ -15,40 +16,34 @@ import spock.lang.Shared import spock.lang.Specification import tech.units.indriya.quantity.Quantities -class ExtEmDataTest extends Specification { +class ExtEmDataTest extends Specification implements DataServiceTestData { @Shared ActorSystem actorSystem - @Shared - UUID inputUuid = UUID.fromString("22bea5fc-2cb2-4c61-beb9-b476e0107f52") - - @Shared - PValue pValue = new PValue(Quantities.getQuantity(500.0, StandardUnits.ACTIVE_POWER_IN)) - @Shared Map extEmDataMapping = Map.of( "Em", inputUuid ) - class TestInputDataValue implements ExtInputDataValue { - private final PValue value + class TestInputDataPValue implements ExtInputDataValue { + private final PValue pValue - TestInputDataValue(PValue value) { - this.value = value + TestInputDataPValue(PValue pValue) { + this.pValue = pValue } - PValue getValue() { - return value + PValue getPValue() { + return pValue } } class TestEmDataFactory implements EmDataFactory { @Override PValue convert(ExtInputDataValue entity) throws ConvertionException { - if (entity instanceof TestInputDataValue) { - return entity.value + if (entity instanceof TestInputDataPValue) { + return entity.pValue } else { throw new ConvertionException("This factory can only convert PValue entities.") } @@ -78,7 +73,7 @@ class ExtEmDataTest extends Specification { def uuid = UUID.randomUUID() emData.put(uuid.toString(), pValue) - def convertedEmData = Map.of(uuid, pValue) + def convertedEmData = Map.of(uuid, pValue as PValue) when: extEmData.provideEmData(0L, convertedEmData, Optional.of(900L)) @@ -91,7 +86,7 @@ class ExtEmDataTest extends Specification { def "ExtEmData should convert ExtInputDataPackage to a map"() { given: def extEmData = new ExtEmData(new TestEmDataFactory(), extEmDataMapping) - def inputDataMap = Map.of("Em", new TestInputDataValue(pValue)) + def inputDataMap = Map.of("Em", new TestInputDataPValue(pValue)) def inputDataPackage = new ExtInputDataPackage(0L, inputDataMap, Optional.of(900L)) when: @@ -104,7 +99,7 @@ class ExtEmDataTest extends Specification { def "ExtEmData should throw an exception, if input data for a not requested asset was provided"() { given: def extEmData = new ExtEmData(new TestEmDataFactory(), extEmDataMapping) - def inputDataMap = Map.of("Load", new TestInputDataValue(pValue)) + def inputDataMap = Map.of("Load", new TestInputDataPValue(pValue)) def inputDataPackage = new ExtInputDataPackage(0L, inputDataMap, Optional.of(900L)) when: diff --git a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy index 6b57cd7..bd00e68 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy @@ -8,6 +8,7 @@ import edu.ie3.simona.api.data.ExtInputDataValue import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData import edu.ie3.simona.api.exceptions.ConvertionException +import edu.ie3.simona.api.test.common.DataServiceTestData import org.apache.pekko.actor.ActorSystem import org.apache.pekko.testkit.TestProbe import org.apache.pekko.testkit.javadsl.TestKit @@ -15,17 +16,11 @@ import spock.lang.Shared import spock.lang.Specification import tech.units.indriya.quantity.Quantities -class ExtPrimaryDataTest extends Specification { +class ExtPrimaryDataTest extends Specification implements DataServiceTestData { @Shared ActorSystem actorSystem - @Shared - UUID inputUuid = UUID.fromString("22bea5fc-2cb2-4c61-beb9-b476e0107f52") - - @Shared - PValue pValue = new PValue(Quantities.getQuantity(500.0, StandardUnits.ACTIVE_POWER_IN)) - @Shared Map extPrimaryDataMapping = Map.of( "Pv", @@ -78,7 +73,7 @@ class ExtPrimaryDataTest extends Specification { def uuid = UUID.randomUUID() primaryData.put(uuid.toString(), pValue) - def convertedPrimaryData = Map.of(uuid, pValue) + def convertedPrimaryData = Map.of(uuid, pValue as Value) when: extPrimaryData.providePrimaryData(0L, convertedPrimaryData, Optional.of(900L)) diff --git a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy index ef73b22..dd11182 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy @@ -7,6 +7,7 @@ import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage import edu.ie3.simona.api.data.results.ontology.ProvideResultEntities import edu.ie3.simona.api.data.results.ontology.RequestResultEntities import edu.ie3.simona.api.data.results.ontology.ResultDataResponseMessageToExt +import edu.ie3.simona.api.test.common.DataServiceTestData import org.apache.pekko.actor.ActorSystem import org.apache.pekko.testkit.TestProbe import org.apache.pekko.testkit.javadsl.TestKit @@ -19,24 +20,13 @@ import javax.measure.quantity.Angle import javax.measure.quantity.ElectricCurrent import java.time.ZonedDateTime -class ExtResultDataTest extends Specification { +class ExtResultDataTest extends Specification implements DataServiceTestData { @Shared ActorSystem actorSystem @Shared - UUID loadUuid = UUID.fromString("22bea5fc-2cb2-4c61-beb9-b476e0107f52") - - @Shared - LoadResult loadResult = new LoadResult( - ZonedDateTime.parse("2020-01-30T17:26:44Z[UTC]"), - loadUuid, - Quantities.getQuantity(10, StandardUnits.ACTIVE_POWER_IN), - Quantities.getQuantity(10, StandardUnits.REACTIVE_POWER_IN) - ) - - @Shared - Map participantResultAssetMapping = Map.of(loadUuid, "Load") + Map participantResultAssetMapping = Map.of(inputUuid, "Load") @Shared Map gridResultAssetMapping = [:] @@ -122,7 +112,7 @@ class ExtResultDataTest extends Specification { Quantity iBMag = Quantities.getQuantity(150, StandardUnits.ELECTRIC_CURRENT_MAGNITUDE) Quantity iBAng = Quantities.getQuantity(30, StandardUnits.ELECTRIC_CURRENT_ANGLE) def wrongResult = new LineResult( - ZonedDateTime.parse("2020-01-30T17:26:44Z"), loadUuid, iAMag, iAAng, iBMag, iBAng + ZonedDateTime.parse("2020-01-30T17:26:44Z"), inputUuid, iAMag, iAAng, iBMag, iBAng ) when: diff --git a/src/test/groovy/edu/ie3/simona/api/test/common/DataServiceTestData.groovy b/src/test/groovy/edu/ie3/simona/api/test/common/DataServiceTestData.groovy new file mode 100644 index 0000000..5ccd661 --- /dev/null +++ b/src/test/groovy/edu/ie3/simona/api/test/common/DataServiceTestData.groovy @@ -0,0 +1,20 @@ +package edu.ie3.simona.api.test.common + +import edu.ie3.datamodel.models.StandardUnits +import edu.ie3.datamodel.models.result.system.LoadResult +import edu.ie3.datamodel.models.value.PValue +import tech.units.indriya.quantity.Quantities + +import java.time.ZonedDateTime + +trait DataServiceTestData { + UUID inputUuid = UUID.fromString("22bea5fc-2cb2-4c61-beb9-b476e0107f52") + PValue pValue = new PValue(Quantities.getQuantity(500.0, StandardUnits.ACTIVE_POWER_IN)) + + LoadResult loadResult = new LoadResult( + ZonedDateTime.parse("2020-01-30T17:26:44Z[UTC]"), + inputUuid, + Quantities.getQuantity(10, StandardUnits.ACTIVE_POWER_IN), + Quantities.getQuantity(10, StandardUnits.REACTIVE_POWER_IN) + ) +} \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/simona/api/test/common/TestInputDataValue.groovy b/src/test/groovy/edu/ie3/simona/api/test/common/TestInputDataValue.groovy new file mode 100644 index 0000000..5b4624d --- /dev/null +++ b/src/test/groovy/edu/ie3/simona/api/test/common/TestInputDataValue.groovy @@ -0,0 +1,18 @@ +package edu.ie3.simona.api.test.common + +import edu.ie3.datamodel.models.value.PValue +import edu.ie3.datamodel.models.value.Value +import edu.ie3.simona.api.data.ExtInputDataValue + + +class TestInputDataValue implements ExtInputDataValue { + private final Value value + + TestInputDataValue(Value value) { + this.value = value + } + + Value getValue() { + return value + } +} From 7caf708c39e6fea1636464889c6a91750859b537 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 09:34:40 +0000 Subject: [PATCH 52/82] Bump com.fasterxml.jackson.core:jackson-databind from 2.18.0 to 2.18.1 (#206) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 09e3c1d..dd882f8 100644 --- a/build.gradle +++ b/build.gradle @@ -72,7 +72,7 @@ dependencies{ // TESTING testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0' - implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.18.0' + implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.18.1' } task printVersion { From edf0b38756c73cc8fb384de32bb1d94abe4e6d20 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 08:43:53 +0000 Subject: [PATCH 53/82] Bump com.github.spotbugs from 6.0.25 to 6.0.26 (#207) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index dd882f8..bbb52f7 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'java' // java support id 'com.diffplug.spotless' version '6.25.0'//code format id 'pmd' // code check, working on source code - id 'com.github.spotbugs' version '6.0.25' // code check, working on byte code + id 'com.github.spotbugs' version '6.0.26' // code check, working on byte code id "org.sonarqube" version "5.1.0.4882" // sonarqube id 'signing' id 'maven-publish' // publish to a maven repo (local or mvn central, has to be defined) From b14b26f8cc13d56ff7723938466435a606e48967 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Thu, 14 Nov 2024 12:04:08 +0100 Subject: [PATCH 54/82] Renaming power fields in `EvModel`. --- CHANGELOG.md | 4 ++++ .../java/edu/ie3/simona/api/data/ev/model/EvModel.java | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e499ca..1085534 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased/Snapshot] +### Changed +- Renaming power fields in `EvModel` [#208](https://github.com/ie3-institute/simonaAPI/issues/208) + + ## [0.5.0] - 2024-08-09 ### Added diff --git a/src/main/java/edu/ie3/simona/api/data/ev/model/EvModel.java b/src/main/java/edu/ie3/simona/api/data/ev/model/EvModel.java index 06f8b7c..2ea3082 100644 --- a/src/main/java/edu/ie3/simona/api/data/ev/model/EvModel.java +++ b/src/main/java/edu/ie3/simona/api/data/ev/model/EvModel.java @@ -23,14 +23,14 @@ public interface EvModel { String getId(); /** - * @return the maximum AC charging power of this ev + * @return the maximum AC charging power of this ev (as active power) */ - ComparableQuantity getSRatedAC(); + ComparableQuantity getPRatedAC(); /** - * @return the maximum DC charging power of this ev + * @return the maximum DC charging power of this ev (as active power) */ - ComparableQuantity getSRatedDC(); + ComparableQuantity getPRatedDC(); /** * @return the storage capacity of this ev's battery From 5a66653d0171df82fde65f5e0b74f7089d8f16bb Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Fri, 15 Nov 2024 11:14:09 +0100 Subject: [PATCH 55/82] changes after review MS --- CHANGELOG.md | 2 +- build.gradle | 1 + .../ie3/simona/api/data/em/EmDataFactory.java | 4 +-- .../edu/ie3/simona/api/data/em/ExtEmData.java | 4 +-- .../api/data/primarydata/ExtPrimaryData.java | 4 +-- .../data/primarydata/PrimaryDataFactory.java | 4 +-- .../api/data/results/ExtResultPackage.java | 4 +-- ...xception.java => ConversionException.java} | 4 +-- .../mapping/ExtEntityMappingCsvSource.java | 12 +++++---- .../simona/api/data/em/ExtEmDataTest.groovy | 9 +++---- .../primarydata/ExtPrimaryDataTest.groovy | 10 +++---- .../data/results/ExtResultPackageTest.groovy | 27 +++++++++++-------- .../test/common/DataServiceTestData.groovy | 2 +- 13 files changed, 45 insertions(+), 42 deletions(-) rename src/main/java/edu/ie3/simona/api/exceptions/{ConvertionException.java => ConversionException.java} (69%) diff --git a/CHANGELOG.md b/CHANGELOG.md index b372b8b..d99a9ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Implemented `ExtPrimaryData` and `ExtResultsData` [#145](https://github.com/ie3-institute/simonaAPI/issues/145) - Have EV simulation communicate the next tick [#170](https://github.com/ie3-institute/simonaAPI/issues/170) -- Only communicate the next tick of activation of EV simulation as a whole [#176](https://github.co/ie3-institute/simonaAPI/issues/176) +- Only communicate the next tick of activation of EV simulation as a whole [#176](https://github.com/ie3-institute/simonaAPI/issues/176) - Enable initialization of external data simulation [#167](https://github.com/ie3-institute/simonaAPI/issues/167) ## [0.4.0] - 2023-11-22 diff --git a/build.gradle b/build.gradle index 1c8cac2..bbb52f7 100644 --- a/build.gradle +++ b/build.gradle @@ -45,6 +45,7 @@ repositories { } dependencies{ + implementation 'tech.units:indriya:2.2' // quantities // scala (needed for pekko) diff --git a/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java b/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java index ffa440e..693e59e 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java +++ b/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java @@ -8,7 +8,7 @@ import edu.ie3.datamodel.models.value.PValue; import edu.ie3.simona.api.data.ExtInputDataValue; -import edu.ie3.simona.api.exceptions.ConvertionException; +import edu.ie3.simona.api.exceptions.ConversionException; /** Interface that should be implemented by an external simulation. */ public interface EmDataFactory { @@ -16,5 +16,5 @@ public interface EmDataFactory { /** * Should convert an object to an em data value with a check if the object has a valid data type */ - PValue convert(ExtInputDataValue entity) throws ConvertionException; + PValue convert(ExtInputDataValue entity) throws ConversionException; } diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java index 39a7877..8c96263 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java @@ -12,7 +12,7 @@ import edu.ie3.simona.api.data.em.ontology.EmDataMessageFromExt; import edu.ie3.simona.api.data.em.ontology.ProvideEmSetPointData; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; -import edu.ie3.simona.api.exceptions.ConvertionException; +import edu.ie3.simona.api.exceptions.ConversionException; import java.util.*; import org.apache.pekko.actor.ActorRef; @@ -79,7 +79,7 @@ public Map createExtEmDataMap(ExtInputDataPackage extInputDataPack if (extEmMapping.containsKey(id)) { try { emDataForSimona.put(extEmMapping.get(id), emDataFactory.convert(extInput)); - } catch (ConvertionException e) { + } catch (ConversionException e) { throw new RuntimeException(e); } } else { diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java index 8a2af0a..04dcbe4 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java @@ -12,7 +12,7 @@ import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import edu.ie3.simona.api.data.primarydata.ontology.PrimaryDataMessageFromExt; import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData; -import edu.ie3.simona.api.exceptions.ConvertionException; +import edu.ie3.simona.api.exceptions.ConversionException; import java.util.*; import org.apache.pekko.actor.ActorRef; @@ -81,7 +81,7 @@ public Map createExtPrimaryDataMap(ExtInputDataPackage extInputData try { primaryDataForSimona.put( extPrimaryDataMapping.get(id), primaryDataFactory.convert(extInput)); - } catch (ConvertionException e) { + } catch (ConversionException e) { throw new RuntimeException(e); } } else { diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/PrimaryDataFactory.java b/src/main/java/edu/ie3/simona/api/data/primarydata/PrimaryDataFactory.java index bd7d262..1893a40 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/PrimaryDataFactory.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/PrimaryDataFactory.java @@ -8,7 +8,7 @@ import edu.ie3.datamodel.models.value.Value; import edu.ie3.simona.api.data.ExtInputDataValue; -import edu.ie3.simona.api.exceptions.ConvertionException; +import edu.ie3.simona.api.exceptions.ConversionException; /** Interface that should be implemented by an external simulation. */ public interface PrimaryDataFactory { @@ -17,5 +17,5 @@ public interface PrimaryDataFactory { * Should convert an external value to a primary data value with a check if the object is primary * data */ - Value convert(ExtInputDataValue entity) throws ConvertionException; + Value convert(ExtInputDataValue entity) throws ConversionException; } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java index 6d72aac..e4dc578 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java @@ -50,9 +50,7 @@ public Long getTick() { */ public double getVoltageDeviation(String assetId) { if (simonaResultsMap.get(assetId) instanceof NodeResult nodeResult) { - ComparableQuantity vMagDev = - Quantities.getQuantity(0, PU) - .add(nodeResult.getvMag().subtract(Quantities.getQuantity(1.0, PU))); + ComparableQuantity vMagDev = Quantities.getQuantity(-1.0, PU).add(nodeResult.getvMag()); return vMagDev.getValue().doubleValue(); } else { throw new IllegalArgumentException("VOLTAGE DEVIATION is only available for NodeResult's!"); diff --git a/src/main/java/edu/ie3/simona/api/exceptions/ConvertionException.java b/src/main/java/edu/ie3/simona/api/exceptions/ConversionException.java similarity index 69% rename from src/main/java/edu/ie3/simona/api/exceptions/ConvertionException.java rename to src/main/java/edu/ie3/simona/api/exceptions/ConversionException.java index 2065203..c9fb547 100644 --- a/src/main/java/edu/ie3/simona/api/exceptions/ConvertionException.java +++ b/src/main/java/edu/ie3/simona/api/exceptions/ConversionException.java @@ -6,9 +6,9 @@ package edu.ie3.simona.api.exceptions; -public class ConvertionException extends Exception { +public class ConversionException extends Exception { - public ConvertionException(final String message) { + public ConversionException(final String message) { super(message); } } diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java index c94b809..b649cf8 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java @@ -7,6 +7,7 @@ package edu.ie3.simona.api.simulation.mapping; import edu.ie3.datamodel.exceptions.SourceException; +import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.io.naming.FileNamingStrategy; import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme; import edu.ie3.datamodel.io.source.csv.CsvDataSource; @@ -89,11 +90,12 @@ protected final ExtEntityMapping buildExtEntityMapping() { } private ExtEntityEntry createExtEntityEntry(Map fieldToValues) { - return new ExtEntityEntry( - UUID.fromString(fieldToValues.get(ExtEntityFactory.SIMONA_UUID)), - fieldToValues.get(ExtEntityFactory.EXT_ID), - ColumnScheme.parse(fieldToValues.get(ExtEntityFactory.COLUMN_SCHEME)).orElseThrow(), - fieldToValues.get(ExtEntityFactory.DATA_TYPE)); + return factory.get( + new EntityData( + fieldToValues, + ExtEntityEntry.class + ) + ).getOrThrow(); } public static ExtEntityMapping createExtEntityMapping(Path mappingPath) { diff --git a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy index df543a6..dfc2b79 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy @@ -1,20 +1,19 @@ package edu.ie3.simona.api.data.em -import edu.ie3.datamodel.models.StandardUnits + import edu.ie3.datamodel.models.value.PValue import edu.ie3.datamodel.models.value.Value import edu.ie3.simona.api.data.ExtInputDataPackage import edu.ie3.simona.api.data.ExtInputDataValue import edu.ie3.simona.api.data.em.ontology.ProvideEmSetPointData import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage -import edu.ie3.simona.api.exceptions.ConvertionException +import edu.ie3.simona.api.exceptions.ConversionException import edu.ie3.simona.api.test.common.DataServiceTestData import org.apache.pekko.actor.ActorSystem import org.apache.pekko.testkit.TestProbe import org.apache.pekko.testkit.javadsl.TestKit import spock.lang.Shared import spock.lang.Specification -import tech.units.indriya.quantity.Quantities class ExtEmDataTest extends Specification implements DataServiceTestData { @@ -41,11 +40,11 @@ class ExtEmDataTest extends Specification implements DataServiceTestData { class TestEmDataFactory implements EmDataFactory { @Override - PValue convert(ExtInputDataValue entity) throws ConvertionException { + PValue convert(ExtInputDataValue entity) throws ConversionException { if (entity instanceof TestInputDataPValue) { return entity.pValue } else { - throw new ConvertionException("This factory can only convert PValue entities.") + throw new ConversionException("This factory can only convert PValue entities.") } } } diff --git a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy index bd00e68..8deed4f 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy @@ -1,20 +1,18 @@ package edu.ie3.simona.api.data.primarydata -import edu.ie3.datamodel.models.StandardUnits -import edu.ie3.datamodel.models.value.PValue + import edu.ie3.datamodel.models.value.Value import edu.ie3.simona.api.data.ExtInputDataPackage import edu.ie3.simona.api.data.ExtInputDataValue import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData -import edu.ie3.simona.api.exceptions.ConvertionException +import edu.ie3.simona.api.exceptions.ConversionException import edu.ie3.simona.api.test.common.DataServiceTestData import org.apache.pekko.actor.ActorSystem import org.apache.pekko.testkit.TestProbe import org.apache.pekko.testkit.javadsl.TestKit import spock.lang.Shared import spock.lang.Specification -import tech.units.indriya.quantity.Quantities class ExtPrimaryDataTest extends Specification implements DataServiceTestData { @@ -41,11 +39,11 @@ class ExtPrimaryDataTest extends Specification implements DataServiceTestData { class TestPrimaryDataFactory implements PrimaryDataFactory { @Override - Value convert(ExtInputDataValue entity) throws ConvertionException { + Value convert(ExtInputDataValue entity) throws ConversionException { if (entity instanceof TestInputDataValue) { return entity.value } else { - throw new ConvertionException("This factory can only convert PValue entities.") + throw new ConversionException("This factory can only convert PValue entities.") } } } diff --git a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultPackageTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultPackageTest.groovy index 276eb3c..314c65c 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultPackageTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultPackageTest.groovy @@ -3,6 +3,7 @@ package edu.ie3.simona.api.data.results import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.result.NodeResult import edu.ie3.datamodel.models.result.system.LoadResult +import edu.ie3.simona.api.test.common.DataServiceTestData import edu.ie3.util.quantities.PowerSystemUnits import spock.lang.Shared import spock.lang.Specification @@ -10,9 +11,7 @@ import tech.units.indriya.quantity.Quantities import java.time.ZonedDateTime -class ExtResultPackageTest extends Specification { - @Shared - UUID loadUuid = UUID.fromString("22bea5fc-2cb2-4c61-beb9-b476e0107f52") +class ExtResultPackageTest extends Specification implements DataServiceTestData { @Shared UUID nodeUuid = UUID.fromString("55b97041-64be-4e6b-983a-72dbde6eddf4") @@ -25,14 +24,6 @@ class ExtResultPackageTest extends Specification { Quantities.getQuantity(45, StandardUnits.VOLTAGE_ANGLE) ) - @Shared - LoadResult loadResult = new LoadResult( - ZonedDateTime.parse("2020-01-30T17:26:44Z"), - loadUuid, - Quantities.getQuantity(10, StandardUnits.ACTIVE_POWER_IN), - Quantities.getQuantity(10, StandardUnits.REACTIVE_POWER_IN) - ) - def "ExtResultPackage should return voltage deviation correctly"() { given: def resultMap = Map.of( @@ -75,6 +66,20 @@ class ExtResultPackageTest extends Specification { returnedActivePower == 10d } + def "ExtResultPackage should return reactive power correctly"() { + given: + def resultMap = Map.of( + "Load", loadResult + ) + def extResultPackage = new ExtResultPackage(0L, resultMap) + + when: + def returnedReactivePower = extResultPackage.getReactivePower("Load") + + then: + returnedReactivePower == 5d + } + def "ExtResultPackage should throw an exception, if active power was requested for a not SystemParticipantResult"() { given: def resultMap = Map.of( diff --git a/src/test/groovy/edu/ie3/simona/api/test/common/DataServiceTestData.groovy b/src/test/groovy/edu/ie3/simona/api/test/common/DataServiceTestData.groovy index 5ccd661..c589bc1 100644 --- a/src/test/groovy/edu/ie3/simona/api/test/common/DataServiceTestData.groovy +++ b/src/test/groovy/edu/ie3/simona/api/test/common/DataServiceTestData.groovy @@ -15,6 +15,6 @@ trait DataServiceTestData { ZonedDateTime.parse("2020-01-30T17:26:44Z[UTC]"), inputUuid, Quantities.getQuantity(10, StandardUnits.ACTIVE_POWER_IN), - Quantities.getQuantity(10, StandardUnits.REACTIVE_POWER_IN) + Quantities.getQuantity(5, StandardUnits.REACTIVE_POWER_IN) ) } \ No newline at end of file From 06e2205ff1a0deb0d5f85cf88d1858983a047ffe Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Fri, 15 Nov 2024 11:57:27 +0100 Subject: [PATCH 56/82] changes after review --- .../api/data/DataQueueExtSimulationExtSimulator.java | 2 +- .../{ExtDataPackage.java => ExtDataContainer.java} | 2 +- ...putDataPackage.java => ExtInputDataContainer.java} | 8 ++++---- .../java/edu/ie3/simona/api/data/em/ExtEmData.java | 4 ++-- .../simona/api/data/primarydata/ExtPrimaryData.java | 4 ++-- ...{ExtResultPackage.java => ExtResultContainer.java} | 9 +++++---- .../api/simulation/mapping/ExtEntityFactory.java | 6 +++++- .../simulation/mapping/ExtEntityMappingCsvSource.java | 8 +------- .../edu/ie3/simona/api/data/em/ExtEmDataTest.groovy | 6 +++--- .../api/data/primarydata/ExtPrimaryDataTest.groovy | 6 +++--- .../api/data/results/ExtResultPackageTest.groovy | 11 +++++------ 11 files changed, 32 insertions(+), 34 deletions(-) rename src/main/java/edu/ie3/simona/api/data/{ExtDataPackage.java => ExtDataContainer.java} (88%) rename src/main/java/edu/ie3/simona/api/data/{ExtInputDataPackage.java => ExtInputDataContainer.java} (87%) rename src/main/java/edu/ie3/simona/api/data/results/{ExtResultPackage.java => ExtResultContainer.java} (90%) diff --git a/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java b/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java index 011e00e..8416ce4 100644 --- a/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java +++ b/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java @@ -9,7 +9,7 @@ import java.util.concurrent.LinkedBlockingQueue; /** Data queue to allow data flow between SIMONA and an external simulation */ -public class DataQueueExtSimulationExtSimulator { +public class DataQueueExtSimulationExtSimulator { private final LinkedBlockingQueue receiverTriggerQueue = new LinkedBlockingQueue<>(); public void queueData(V data) throws InterruptedException { diff --git a/src/main/java/edu/ie3/simona/api/data/ExtDataPackage.java b/src/main/java/edu/ie3/simona/api/data/ExtDataContainer.java similarity index 88% rename from src/main/java/edu/ie3/simona/api/data/ExtDataPackage.java rename to src/main/java/edu/ie3/simona/api/data/ExtDataContainer.java index 33abcb4..60a2e44 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtDataPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtDataContainer.java @@ -7,4 +7,4 @@ package edu.ie3.simona.api.data; /** Interface for data format to exchange data with an external simulation */ -public interface ExtDataPackage {} +public interface ExtDataContainer {} diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataContainer.java similarity index 87% rename from src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java rename to src/main/java/edu/ie3/simona/api/data/ExtInputDataContainer.java index af959ce..65657c5 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtInputDataPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataContainer.java @@ -11,7 +11,7 @@ import java.util.Optional; /** Contains all inputs for SIMONA for a certain tick */ -public class ExtInputDataPackage implements ExtDataPackage { +public class ExtInputDataContainer implements ExtDataContainer { private final long tick; @@ -27,18 +27,18 @@ public class ExtInputDataPackage implements ExtDataPackage { * @param dataMap data to be provided to SIMONA * @param maybeNextTick tick, when the next data will be provided */ - public ExtInputDataPackage( + public ExtInputDataContainer( long tick, Map dataMap, Optional maybeNextTick) { this.tick = tick; this.dataMap = dataMap; this.maybeNextTick = maybeNextTick; } - public ExtInputDataPackage(long tick, long nextTick) { + public ExtInputDataContainer(long tick, long nextTick) { this(tick, new HashMap<>(), Optional.of(nextTick)); } - public ExtInputDataPackage(long tick) { + public ExtInputDataContainer(long tick) { this(tick, new HashMap<>(), Optional.empty()); } diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java index 8c96263..f43bcce 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java @@ -8,7 +8,7 @@ import edu.ie3.datamodel.models.value.PValue; import edu.ie3.simona.api.data.ExtData; -import edu.ie3.simona.api.data.ExtInputDataPackage; +import edu.ie3.simona.api.data.ExtInputDataContainer; import edu.ie3.simona.api.data.em.ontology.EmDataMessageFromExt; import edu.ie3.simona.api.data.em.ontology.ProvideEmSetPointData; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; @@ -70,7 +70,7 @@ public void sendExtMsg(EmDataMessageFromExt msg) { } /** Converts an input data package from an external simulation to a map of set points */ - public Map createExtEmDataMap(ExtInputDataPackage extInputDataPackage) { + public Map createExtEmDataMap(ExtInputDataContainer extInputDataPackage) { Map emDataForSimona = new HashMap<>(); extInputDataPackage .getSimonaInputMap() diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java index 04dcbe4..91c86de 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java @@ -8,7 +8,7 @@ import edu.ie3.datamodel.models.value.Value; import edu.ie3.simona.api.data.ExtData; -import edu.ie3.simona.api.data.ExtInputDataPackage; +import edu.ie3.simona.api.data.ExtInputDataContainer; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import edu.ie3.simona.api.data.primarydata.ontology.PrimaryDataMessageFromExt; import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData; @@ -71,7 +71,7 @@ public void sendExtMsg(PrimaryDataMessageFromExt msg) { } /** Converts an input data package from an external simulation to a map of primary data */ - public Map createExtPrimaryDataMap(ExtInputDataPackage extInputDataPackage) { + public Map createExtPrimaryDataMap(ExtInputDataContainer extInputDataPackage) { Map primaryDataForSimona = new HashMap<>(); extInputDataPackage .getSimonaInputMap() diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultContainer.java similarity index 90% rename from src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java rename to src/main/java/edu/ie3/simona/api/data/results/ExtResultContainer.java index e4dc578..7f26ead 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultPackage.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultContainer.java @@ -12,14 +12,14 @@ import edu.ie3.datamodel.models.result.NodeResult; import edu.ie3.datamodel.models.result.connector.LineResult; import edu.ie3.datamodel.models.result.system.SystemParticipantResult; -import edu.ie3.simona.api.data.ExtDataPackage; +import edu.ie3.simona.api.data.ExtDataContainer; import java.util.Map; import javax.measure.quantity.Dimensionless; import tech.units.indriya.ComparableQuantity; import tech.units.indriya.quantity.Quantities; /** Contains all results from SIMONA for a certain tick */ -public class ExtResultPackage implements ExtDataPackage { +public class ExtResultContainer implements ExtDataContainer { /** Tick the package is meant for */ private final Long tick; @@ -36,7 +36,7 @@ public class ExtResultPackage implements ExtDataPackage { * @param tick current tick * @param simonaResultsMap results from SIMONA with external id as key */ - public ExtResultPackage(Long tick, Map simonaResultsMap) { + public ExtResultContainer(Long tick, Map simonaResultsMap) { this.tick = tick; this.simonaResultsMap = simonaResultsMap; } @@ -50,7 +50,8 @@ public Long getTick() { */ public double getVoltageDeviation(String assetId) { if (simonaResultsMap.get(assetId) instanceof NodeResult nodeResult) { - ComparableQuantity vMagDev = Quantities.getQuantity(-1.0, PU).add(nodeResult.getvMag()); + ComparableQuantity vMagDev = + Quantities.getQuantity(-1.0, PU).add(nodeResult.getvMag()); return vMagDev.getValue().doubleValue(); } else { throw new IllegalArgumentException("VOLTAGE DEVIATION is only available for NodeResult's!"); diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java index 1626324..343c577 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java @@ -21,6 +21,10 @@ public class ExtEntityFactory extends EntityFactory public static final String COLUMN_SCHEME = "columnScheme"; public static final String DATA_TYPE = "dataType"; + public ExtEntityFactory() { + super(new Class[] {ExtEntityEntry.class}); + } + @Override protected List> getFields(Class entityClass) { return Collections.singletonList( @@ -31,7 +35,7 @@ protected List> getFields(Class entityClass) { protected ExtEntityEntry buildModel(EntityData data) { UUID simonaUuid = data.getUUID(SIMONA_UUID); String extId = data.getField(EXT_ID); - Optional columnScheme = ColumnScheme.parse(COLUMN_SCHEME); + Optional columnScheme = ColumnScheme.parse(data.getField(COLUMN_SCHEME)); String inputType = data.getField(DATA_TYPE); return new ExtEntityEntry( diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java index b649cf8..e1bf920 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java @@ -9,7 +9,6 @@ import edu.ie3.datamodel.exceptions.SourceException; import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.io.naming.FileNamingStrategy; -import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme; import edu.ie3.datamodel.io.source.csv.CsvDataSource; import java.io.IOException; import java.nio.file.Files; @@ -90,12 +89,7 @@ protected final ExtEntityMapping buildExtEntityMapping() { } private ExtEntityEntry createExtEntityEntry(Map fieldToValues) { - return factory.get( - new EntityData( - fieldToValues, - ExtEntityEntry.class - ) - ).getOrThrow(); + return factory.get(new EntityData(fieldToValues, ExtEntityEntry.class)).getOrThrow(); } public static ExtEntityMapping createExtEntityMapping(Path mappingPath) { diff --git a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy index dfc2b79..f070bb1 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy @@ -3,7 +3,7 @@ package edu.ie3.simona.api.data.em import edu.ie3.datamodel.models.value.PValue import edu.ie3.datamodel.models.value.Value -import edu.ie3.simona.api.data.ExtInputDataPackage +import edu.ie3.simona.api.data.ExtInputDataContainer import edu.ie3.simona.api.data.ExtInputDataValue import edu.ie3.simona.api.data.em.ontology.ProvideEmSetPointData import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage @@ -86,7 +86,7 @@ class ExtEmDataTest extends Specification implements DataServiceTestData { given: def extEmData = new ExtEmData(new TestEmDataFactory(), extEmDataMapping) def inputDataMap = Map.of("Em", new TestInputDataPValue(pValue)) - def inputDataPackage = new ExtInputDataPackage(0L, inputDataMap, Optional.of(900L)) + def inputDataPackage = new ExtInputDataContainer(0L, inputDataMap, Optional.of(900L)) when: def emDataMap = extEmData.createExtEmDataMap(inputDataPackage) @@ -99,7 +99,7 @@ class ExtEmDataTest extends Specification implements DataServiceTestData { given: def extEmData = new ExtEmData(new TestEmDataFactory(), extEmDataMapping) def inputDataMap = Map.of("Load", new TestInputDataPValue(pValue)) - def inputDataPackage = new ExtInputDataPackage(0L, inputDataMap, Optional.of(900L)) + def inputDataPackage = new ExtInputDataContainer(0L, inputDataMap, Optional.of(900L)) when: extEmData.createExtEmDataMap(inputDataPackage) diff --git a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy index 8deed4f..20cc540 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy @@ -2,7 +2,7 @@ package edu.ie3.simona.api.data.primarydata import edu.ie3.datamodel.models.value.Value -import edu.ie3.simona.api.data.ExtInputDataPackage +import edu.ie3.simona.api.data.ExtInputDataContainer import edu.ie3.simona.api.data.ExtInputDataValue import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData @@ -85,7 +85,7 @@ class ExtPrimaryDataTest extends Specification implements DataServiceTestData { given: def extPrimaryData = new ExtPrimaryData(new TestPrimaryDataFactory(), extPrimaryDataMapping) def inputDataMap = Map.of("Pv", new TestInputDataValue(pValue)) - def inputDataPackage = new ExtInputDataPackage(0L, inputDataMap, Optional.of(900L)) + def inputDataPackage = new ExtInputDataContainer(0L, inputDataMap, Optional.of(900L)) when: def primaryDataMap = extPrimaryData.createExtPrimaryDataMap(inputDataPackage) @@ -98,7 +98,7 @@ class ExtPrimaryDataTest extends Specification implements DataServiceTestData { given: def extPrimaryData = new ExtPrimaryData(new TestPrimaryDataFactory(), extPrimaryDataMapping) def inputDataMap = Map.of("Load", new TestInputDataValue(pValue)) - def inputDataPackage = new ExtInputDataPackage(0L, inputDataMap, Optional.of(900L)) + def inputDataPackage = new ExtInputDataContainer(0L, inputDataMap, Optional.of(900L)) when: extPrimaryData.createExtPrimaryDataMap(inputDataPackage) diff --git a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultPackageTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultPackageTest.groovy index 314c65c..3c6d89c 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultPackageTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultPackageTest.groovy @@ -2,7 +2,6 @@ package edu.ie3.simona.api.data.results import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.result.NodeResult -import edu.ie3.datamodel.models.result.system.LoadResult import edu.ie3.simona.api.test.common.DataServiceTestData import edu.ie3.util.quantities.PowerSystemUnits import spock.lang.Shared @@ -29,7 +28,7 @@ class ExtResultPackageTest extends Specification implements DataServiceTestData def resultMap = Map.of( "Node", nodeResult ) - def extResultPackage = new ExtResultPackage(0L, resultMap) + def extResultPackage = new ExtResultContainer(0L, resultMap) when: def calculatedVoltageDeviation = extResultPackage.getVoltageDeviation("Node") @@ -43,7 +42,7 @@ class ExtResultPackageTest extends Specification implements DataServiceTestData def resultMap = Map.of( "Load", loadResult ) - def extResultPackage = new ExtResultPackage(0L, resultMap) + def extResultPackage = new ExtResultContainer(0L, resultMap) when: extResultPackage.getVoltageDeviation("Load") @@ -57,7 +56,7 @@ class ExtResultPackageTest extends Specification implements DataServiceTestData def resultMap = Map.of( "Load", loadResult ) - def extResultPackage = new ExtResultPackage(0L, resultMap) + def extResultPackage = new ExtResultContainer(0L, resultMap) when: def returnedActivePower = extResultPackage.getActivePower("Load") @@ -71,7 +70,7 @@ class ExtResultPackageTest extends Specification implements DataServiceTestData def resultMap = Map.of( "Load", loadResult ) - def extResultPackage = new ExtResultPackage(0L, resultMap) + def extResultPackage = new ExtResultContainer(0L, resultMap) when: def returnedReactivePower = extResultPackage.getReactivePower("Load") @@ -85,7 +84,7 @@ class ExtResultPackageTest extends Specification implements DataServiceTestData def resultMap = Map.of( "Node", nodeResult ) - def extResultPackage = new ExtResultPackage(0L, resultMap) + def extResultPackage = new ExtResultContainer(0L, resultMap) when: extResultPackage.getActivePower("Node") From d33bf8afaa6a64e1f1129135ca9c03c3235a3ce0 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Tue, 19 Nov 2024 13:27:15 +0100 Subject: [PATCH 57/82] change dataconversion --- build.gradle | 4 + .../api/data/ExtInputDataContainer.java | 32 ++++--- .../ie3/simona/api/data/em/EmDataFactory.java | 20 ---- .../edu/ie3/simona/api/data/em/ExtEmData.java | 28 +++--- .../api/data/primarydata/ExtPrimaryData.java | 24 +---- .../data/primarydata/PrimaryDataFactory.java | 21 ----- .../api/simulation/ExtCoSimulation.java | 92 +++++++++++++++++++ .../simona/api/simulation/ExtSimulation.java | 6 +- .../simulation/mapping/ExtEntityFactory.java | 3 +- 9 files changed, 138 insertions(+), 92 deletions(-) delete mode 100644 src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java delete mode 100644 src/main/java/edu/ie3/simona/api/data/primarydata/PrimaryDataFactory.java create mode 100644 src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java diff --git a/build.gradle b/build.gradle index bbb52f7..25f0752 100644 --- a/build.gradle +++ b/build.gradle @@ -65,6 +65,10 @@ dependencies{ exclude group: 'com.github.ie3-institute' } + // logging + implementation "com.typesafe.scala-logging:scala-logging_${scalaVersion}:3.9.5" // pekko scala logging + implementation "ch.qos.logback:logback-classic:1.4.14" + // pekko implementation "org.apache.pekko:pekko-actor_${scalaVersion}:${pekkoVersion}" testImplementation "org.apache.pekko:pekko-testkit_${scalaVersion}:${pekkoVersion}" // pekko testkit diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataContainer.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataContainer.java index 65657c5..5f4d11e 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtInputDataContainer.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataContainer.java @@ -6,17 +6,20 @@ package edu.ie3.simona.api.data; +import edu.ie3.datamodel.models.value.Value; + import java.util.HashMap; import java.util.Map; import java.util.Optional; +import java.util.Set; /** Contains all inputs for SIMONA for a certain tick */ public class ExtInputDataContainer implements ExtDataContainer { private final long tick; - /** Map external id to input for SIMONA */ - private final Map dataMap; + /** Map external id to an input value for SIMONA */ + private final Map dataMap; private final Optional maybeNextTick; @@ -25,24 +28,29 @@ public class ExtInputDataContainer implements ExtDataContainer { * * @param tick current tick * @param dataMap data to be provided to SIMONA - * @param maybeNextTick tick, when the next data will be provided + * @param nextTick tick, when the next data will be provided */ - public ExtInputDataContainer( - long tick, Map dataMap, Optional maybeNextTick) { + public ExtInputDataContainer(long tick, Map dataMap, long nextTick) { this.tick = tick; this.dataMap = dataMap; - this.maybeNextTick = maybeNextTick; + this.maybeNextTick = Optional.of(nextTick); } - public ExtInputDataContainer(long tick, long nextTick) { - this(tick, new HashMap<>(), Optional.of(nextTick)); + public ExtInputDataContainer(long tick, Map dataMap) { + this.tick = tick; + this.dataMap = dataMap; + this.maybeNextTick = Optional.empty(); } public ExtInputDataContainer(long tick) { - this(tick, new HashMap<>(), Optional.empty()); + this(tick, new HashMap<>()); + } + + public ExtInputDataContainer(long tick, long nextTick) { + this(tick, new HashMap<>(), nextTick); } - public Map getSimonaInputMap() { + public Map getSimonaInputMap() { return dataMap; } @@ -55,7 +63,7 @@ public Optional getMaybeNextTick() { } /** Adds a value to the input map */ - public void addValue(String id, ExtInputDataValue value) { - dataMap.put(id, value); + public void addValue(String id, Value value) { + dataMap.put(id, value); } } diff --git a/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java b/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java deleted file mode 100644 index 693e59e..0000000 --- a/src/main/java/edu/ie3/simona/api/data/em/EmDataFactory.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * © 2024. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation - */ - -package edu.ie3.simona.api.data.em; - -import edu.ie3.datamodel.models.value.PValue; -import edu.ie3.simona.api.data.ExtInputDataValue; -import edu.ie3.simona.api.exceptions.ConversionException; - -/** Interface that should be implemented by an external simulation. */ -public interface EmDataFactory { - - /** - * Should convert an object to an em data value with a check if the object has a valid data type - */ - PValue convert(ExtInputDataValue entity) throws ConversionException; -} diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java index f43bcce..4b9e7bf 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java @@ -7,6 +7,7 @@ package edu.ie3.simona.api.data.em; import edu.ie3.datamodel.models.value.PValue; +import edu.ie3.datamodel.models.value.Value; import edu.ie3.simona.api.data.ExtData; import edu.ie3.simona.api.data.ExtInputDataContainer; import edu.ie3.simona.api.data.em.ontology.EmDataMessageFromExt; @@ -27,11 +28,7 @@ public class ExtEmData implements ExtData { /** Assets that provide primary data to SIMONA */ private final Map extEmMapping; - /** Factory, that converts external input data to set points for EM agents */ - private final EmDataFactory emDataFactory; - - public ExtEmData(EmDataFactory emDataFactory, Map extEmMapping) { - this.emDataFactory = emDataFactory; + public ExtEmData(Map extEmMapping) { this.extEmMapping = extEmMapping; } @@ -46,11 +43,6 @@ public List getControlledEms() { return extEmMapping.values().stream().toList(); } - /** Return the factory, that converts external input data to set points for EM agents */ - public EmDataFactory getEmDataFactory() { - return emDataFactory; - } - /** Provide primary data from an external simulation for one tick. */ public void provideEmData(Long tick, Map emData, Optional maybeNextTick) { sendExtMsg(new ProvideEmSetPointData(tick, emData, maybeNextTick)); @@ -70,17 +62,19 @@ public void sendExtMsg(EmDataMessageFromExt msg) { } /** Converts an input data package from an external simulation to a map of set points */ - public Map createExtEmDataMap(ExtInputDataContainer extInputDataPackage) { + public Map createExtEmDataMap(ExtInputDataContainer extInputDataContainer) { Map emDataForSimona = new HashMap<>(); - extInputDataPackage + extInputDataContainer .getSimonaInputMap() .forEach( - (id, extInput) -> { + (id, value) -> { if (extEmMapping.containsKey(id)) { - try { - emDataForSimona.put(extEmMapping.get(id), emDataFactory.convert(extInput)); - } catch (ConversionException e) { - throw new RuntimeException(e); + if (value instanceof PValue pValue) { + emDataForSimona.put(extEmMapping.get(id), pValue); + } else { + throw new IllegalArgumentException( + "EmData can only handle PValue's!" + ); } } else { throw new IllegalArgumentException( diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java index 91c86de..ce02d8c 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java @@ -24,15 +24,10 @@ public class ExtPrimaryData implements ExtData { /** Actor reference to adapter that handles scheduler control flow in SIMONA */ private ActorRef extSimAdapter; - /** Factory to convert an external object to PSDM primary data */ - private final PrimaryDataFactory primaryDataFactory; - /** Assets that provide primary data to SIMONA */ private final Map extPrimaryDataMapping; - public ExtPrimaryData( - PrimaryDataFactory primaryDataFactory, Map extPrimaryDataMapping) { - this.primaryDataFactory = primaryDataFactory; + public ExtPrimaryData(Map extPrimaryDataMapping) { this.extPrimaryDataMapping = extPrimaryDataMapping; } @@ -42,10 +37,6 @@ public void setActorRefs(ActorRef dataService, ActorRef extSimAdapter) { this.extSimAdapter = extSimAdapter; } - public PrimaryDataFactory getPrimaryDataFactory() { - return primaryDataFactory; - } - /** Returns a list of the uuids of the system participants that expect external primary data */ public List getPrimaryDataAssets() { return extPrimaryDataMapping.values().stream().toList(); @@ -71,19 +62,14 @@ public void sendExtMsg(PrimaryDataMessageFromExt msg) { } /** Converts an input data package from an external simulation to a map of primary data */ - public Map createExtPrimaryDataMap(ExtInputDataContainer extInputDataPackage) { + public Map convertExternalInputToPrimaryData(ExtInputDataContainer extInputDataContainer) { Map primaryDataForSimona = new HashMap<>(); - extInputDataPackage + extInputDataContainer .getSimonaInputMap() .forEach( - (id, extInput) -> { + (id, value) -> { if (extPrimaryDataMapping.containsKey(id)) { - try { - primaryDataForSimona.put( - extPrimaryDataMapping.get(id), primaryDataFactory.convert(extInput)); - } catch (ConversionException e) { - throw new RuntimeException(e); - } + primaryDataForSimona.put(extPrimaryDataMapping.get(id), value); } else { throw new IllegalArgumentException( "Input for asset with id " + id + " was provided, but it wasn't requested!"); diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/PrimaryDataFactory.java b/src/main/java/edu/ie3/simona/api/data/primarydata/PrimaryDataFactory.java deleted file mode 100644 index 1893a40..0000000 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/PrimaryDataFactory.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * © 2024. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation - */ - -package edu.ie3.simona.api.data.primarydata; - -import edu.ie3.datamodel.models.value.Value; -import edu.ie3.simona.api.data.ExtInputDataValue; -import edu.ie3.simona.api.exceptions.ConversionException; - -/** Interface that should be implemented by an external simulation. */ -public interface PrimaryDataFactory { - - /** - * Should convert an external value to a primary data value with a check if the object is primary - * data - */ - Value convert(ExtInputDataValue entity) throws ConversionException; -} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java new file mode 100644 index 0000000..c5669d3 --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java @@ -0,0 +1,92 @@ +package edu.ie3.simona.api.simulation; + +import ch.qos.logback.classic.Logger; +import edu.ie3.datamodel.models.result.ModelResultEntity; +import edu.ie3.datamodel.models.value.Value; +import edu.ie3.simona.api.data.DataQueueExtSimulationExtSimulator; +import edu.ie3.simona.api.data.ExtData; +import edu.ie3.simona.api.data.ExtInputDataContainer; +import edu.ie3.simona.api.data.em.ExtEmData; +import edu.ie3.simona.api.data.primarydata.ExtPrimaryData; +import edu.ie3.simona.api.data.results.ExtResultContainer; +import edu.ie3.simona.api.data.results.ExtResultData; +import org.slf4j.LoggerFactory; + +import java.util.Map; +import java.util.Optional; + +/** + * Abstract class for an external co-simulation with the structure: external api - ext-co-simulation - extsimulation - simonaAPI - simona + * It contains all function to transfer primary data and em data to SIMONA and results to the external co-simulation. + */ +public abstract class ExtCoSimulation extends ExtSimulation { + + protected final ch.qos.logback.classic.Logger log = (Logger) LoggerFactory.getLogger(simulationName); + + protected final DataQueueExtSimulationExtSimulator dataQueueExtCoSimulatorToSimonaApi; + protected final DataQueueExtSimulationExtSimulator dataQueueSimonaApiToExtCoSimulator; + + private final long deltaT = 900L; + + protected ExtCoSimulation(String simulationName) { + super(simulationName); + this.dataQueueExtCoSimulatorToSimonaApi = new DataQueueExtSimulationExtSimulator<>(); + this.dataQueueSimonaApiToExtCoSimulator = new DataQueueExtSimulationExtSimulator<>(); + } + + protected void sendPrimaryDataToSimona( + ExtPrimaryData extPrimaryData, + long tick + ) { + try { + ExtInputDataContainer inputData = dataQueueExtCoSimulatorToSimonaApi.takeData(); + log.debug("Received Primary Data from " + simulationName + " = " + inputData); + + extPrimaryData.providePrimaryData( + tick, + extPrimaryData.convertExternalInputToPrimaryData(inputData), + inputData.getMaybeNextTick() + ); + log.info("Provided Primary Data to SIMONA"); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + + protected void sendEmDataToSimona( + ExtEmData extEmData, + long tick, + long nextTick + ) { + try { + log.info("+++++ External simulation triggered for tick " + tick + " +++++"); + log.info("Wait for new EmData from OpSim..."); + ExtInputDataContainer rawEmData = dataQueueExtCoSimulatorToSimonaApi.takeData(); + extEmData.provideEmData( + tick, + extEmData.createExtEmDataMap(rawEmData), + Optional.of(nextTick) + ); + log.info("Provided EmData to SIMONA!"); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + + protected void sendResultsToExtCoSimulator( + ExtResultData extResultData, + long tick, + long nextTick + ) { + try { + log.info("Request Results from SIMONA!"); + Map resultsToBeSend = extResultData.requestResults(tick); + log.info("Received results from SIMONA! Now convert them and send them to Mosaik!"); + + dataQueueSimonaApiToExtCoSimulator.queueData(new ExtResultContainer(tick, resultsToBeSend)); + log.info("***** External simulation for tick " + tick + " completed. Next simulation tick = " + nextTick + " *****"); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java index 5e7c9e7..2be6855 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java @@ -20,9 +20,13 @@ */ public abstract class ExtSimulation implements Runnable { + protected String simulationName; + private ExtSimAdapterData data; - protected ExtSimulation() {} + protected ExtSimulation(String simulationName) { + this.simulationName = simulationName; + } public void run() { try { diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java index 343c577..b60d3aa 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java @@ -41,8 +41,7 @@ protected ExtEntityEntry buildModel(EntityData data) { return new ExtEntityEntry( simonaUuid, extId, - columnScheme - .orElseThrow(), // FIXME: Interim version -> ColumnScheme should handle more data types + columnScheme.orElseThrow(), // FIXME: Interim version -> ColumnScheme should handle more data types inputType); } } From ad85c9bd24fd6d7ff127b7badeff0fffa5cf9d84 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 10:14:59 +0000 Subject: [PATCH 58/82] Bump org.sonarqube from 5.1.0.4882 to 6.0.0.5145 (#211) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index bbb52f7..7267b8e 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { id 'com.diffplug.spotless' version '6.25.0'//code format id 'pmd' // code check, working on source code id 'com.github.spotbugs' version '6.0.26' // code check, working on byte code - id "org.sonarqube" version "5.1.0.4882" // sonarqube + id "org.sonarqube" version "6.0.0.5145" // sonarqube id 'signing' id 'maven-publish' // publish to a maven repo (local or mvn central, has to be defined) id 'jacoco' // java code coverage plugin From c2961f2c894540b32e3ffbe3eb966bfc8ef69e3f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 06:28:44 +0000 Subject: [PATCH 59/82] Bump tech.units:indriya from 2.2 to 2.2.1 (#212) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7267b8e..705c811 100644 --- a/build.gradle +++ b/build.gradle @@ -46,7 +46,7 @@ repositories { dependencies{ - implementation 'tech.units:indriya:2.2' // quantities + implementation 'tech.units:indriya:2.2.1' // quantities // scala (needed for pekko) implementation "org.scala-lang:scala-library:${scalaBinaryVersion}" From 1bf59cfd9d463f937cfb61fc06fd0165359ea107 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 21 Nov 2024 08:31:56 +0100 Subject: [PATCH 60/82] improve doc --- .../api/data/ExtInputDataContainer.java | 8 +- .../simona/api/data/ExtInputDataValue.java | 10 -- .../edu/ie3/simona/api/data/em/ExtEmData.java | 9 +- .../api/data/primarydata/ExtPrimaryData.java | 4 +- .../api/data/results/ExtResultContainer.java | 19 ++- .../api/simulation/ExtCoSimulation.java | 136 +++++++++--------- .../simulation/mapping/ExtEntityEntry.java | 2 +- .../simulation/mapping/ExtEntityFactory.java | 3 +- .../simona/api/data/em/ExtEmDataTest.groovy | 43 ++---- .../primarydata/ExtPrimaryDataTest.groovy | 44 ++---- ...t.groovy => ExtResultContainerTest.groovy} | 32 ++--- .../api/simulation/ExtSimulationSpec.groovy | 1 + .../api/test/common/TestInputDataValue.groovy | 18 --- 13 files changed, 134 insertions(+), 195 deletions(-) delete mode 100644 src/main/java/edu/ie3/simona/api/data/ExtInputDataValue.java rename src/test/groovy/edu/ie3/simona/api/data/results/{ExtResultPackageTest.groovy => ExtResultContainerTest.groovy} (56%) delete mode 100644 src/test/groovy/edu/ie3/simona/api/test/common/TestInputDataValue.groovy diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataContainer.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataContainer.java index 5f4d11e..794d3b1 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtInputDataContainer.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataContainer.java @@ -7,26 +7,26 @@ package edu.ie3.simona.api.data; import edu.ie3.datamodel.models.value.Value; - import java.util.HashMap; import java.util.Map; import java.util.Optional; -import java.util.Set; /** Contains all inputs for SIMONA for a certain tick */ public class ExtInputDataContainer implements ExtDataContainer { + /** The tick, the input data is meant for */ private final long tick; /** Map external id to an input value for SIMONA */ private final Map dataMap; + /** The next tick, when data will be provided, if available */ private final Optional maybeNextTick; /** * Container class for input data for SIMONA * - * @param tick current tick + * @param tick The tick, the input data is meant for * @param dataMap data to be provided to SIMONA * @param nextTick tick, when the next data will be provided */ @@ -64,6 +64,6 @@ public Optional getMaybeNextTick() { /** Adds a value to the input map */ public void addValue(String id, Value value) { - dataMap.put(id, value); + dataMap.put(id, value); } } diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataValue.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataValue.java deleted file mode 100644 index df4a3c9..0000000 --- a/src/main/java/edu/ie3/simona/api/data/ExtInputDataValue.java +++ /dev/null @@ -1,10 +0,0 @@ -/* - * © 2024. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation - */ - -package edu.ie3.simona.api.data; - -/** Interface that represents a value of an external simulation */ -public interface ExtInputDataValue {} diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java index 4b9e7bf..cb944e6 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java @@ -7,13 +7,11 @@ package edu.ie3.simona.api.data.em; import edu.ie3.datamodel.models.value.PValue; -import edu.ie3.datamodel.models.value.Value; import edu.ie3.simona.api.data.ExtData; import edu.ie3.simona.api.data.ExtInputDataContainer; import edu.ie3.simona.api.data.em.ontology.EmDataMessageFromExt; import edu.ie3.simona.api.data.em.ontology.ProvideEmSetPointData; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; -import edu.ie3.simona.api.exceptions.ConversionException; import java.util.*; import org.apache.pekko.actor.ActorRef; @@ -62,7 +60,8 @@ public void sendExtMsg(EmDataMessageFromExt msg) { } /** Converts an input data package from an external simulation to a map of set points */ - public Map createExtEmDataMap(ExtInputDataContainer extInputDataContainer) { + public Map convertExternalInputToEmSetPoints( + ExtInputDataContainer extInputDataContainer) { Map emDataForSimona = new HashMap<>(); extInputDataContainer .getSimonaInputMap() @@ -72,9 +71,7 @@ public Map createExtEmDataMap(ExtInputDataContainer extInputDataCo if (value instanceof PValue pValue) { emDataForSimona.put(extEmMapping.get(id), pValue); } else { - throw new IllegalArgumentException( - "EmData can only handle PValue's!" - ); + throw new IllegalArgumentException("EmData can only handle PValue's!"); } } else { throw new IllegalArgumentException( diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java index ce02d8c..2121699 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java @@ -12,7 +12,6 @@ import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import edu.ie3.simona.api.data.primarydata.ontology.PrimaryDataMessageFromExt; import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData; -import edu.ie3.simona.api.exceptions.ConversionException; import java.util.*; import org.apache.pekko.actor.ActorRef; @@ -62,7 +61,8 @@ public void sendExtMsg(PrimaryDataMessageFromExt msg) { } /** Converts an input data package from an external simulation to a map of primary data */ - public Map convertExternalInputToPrimaryData(ExtInputDataContainer extInputDataContainer) { + public Map convertExternalInputToPrimaryData( + ExtInputDataContainer extInputDataContainer) { Map primaryDataForSimona = new HashMap<>(); extInputDataContainer .getSimonaInputMap() diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultContainer.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultContainer.java index 7f26ead..8d2efad 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultContainer.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultContainer.java @@ -14,6 +14,7 @@ import edu.ie3.datamodel.models.result.system.SystemParticipantResult; import edu.ie3.simona.api.data.ExtDataContainer; import java.util.Map; +import java.util.Optional; import javax.measure.quantity.Dimensionless; import tech.units.indriya.ComparableQuantity; import tech.units.indriya.quantity.Quantities; @@ -21,8 +22,11 @@ /** Contains all results from SIMONA for a certain tick */ public class ExtResultContainer implements ExtDataContainer { - /** Tick the package is meant for */ - private final Long tick; + /** Tick the results are meant for */ + private final long tick; + + /** Tick the external simulation can expect the next results */ + private final Optional maybeNextTick; /** * Map external id to result from SIMONA ATTENTION: The time stamp of the result entities is not @@ -31,14 +35,21 @@ public class ExtResultContainer implements ExtDataContainer { private final Map simonaResultsMap; /** - * Container class for output data from SIMONA + * Container class for result data from SIMONA * * @param tick current tick * @param simonaResultsMap results from SIMONA with external id as key + * @param nextTick tick the external simulation can expect the next results */ - public ExtResultContainer(Long tick, Map simonaResultsMap) { + public ExtResultContainer( + long tick, Map simonaResultsMap, Optional nextTick) { this.tick = tick; this.simonaResultsMap = simonaResultsMap; + this.maybeNextTick = nextTick; + } + + public ExtResultContainer(long tick, Map simonaResultsMap) { + this(tick, simonaResultsMap, Optional.empty()); } public Long getTick() { diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java index c5669d3..228978d 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java @@ -1,92 +1,100 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + package edu.ie3.simona.api.simulation; import ch.qos.logback.classic.Logger; import edu.ie3.datamodel.models.result.ModelResultEntity; -import edu.ie3.datamodel.models.value.Value; import edu.ie3.simona.api.data.DataQueueExtSimulationExtSimulator; -import edu.ie3.simona.api.data.ExtData; import edu.ie3.simona.api.data.ExtInputDataContainer; import edu.ie3.simona.api.data.em.ExtEmData; import edu.ie3.simona.api.data.primarydata.ExtPrimaryData; import edu.ie3.simona.api.data.results.ExtResultContainer; import edu.ie3.simona.api.data.results.ExtResultData; -import org.slf4j.LoggerFactory; - import java.util.Map; import java.util.Optional; +import org.slf4j.LoggerFactory; /** - * Abstract class for an external co-simulation with the structure: external api - ext-co-simulation - extsimulation - simonaAPI - simona - * It contains all function to transfer primary data and em data to SIMONA and results to the external co-simulation. + * Abstract class for an external co-simulation with the structure: external api - ext-co-simulation + * - extsimulation - simonaAPI - simona It contains all function to transfer primary data and em + * data to SIMONA and results to the external co-simulation. */ public abstract class ExtCoSimulation extends ExtSimulation { - protected final ch.qos.logback.classic.Logger log = (Logger) LoggerFactory.getLogger(simulationName); + /** Logging for the external co simulation */ + protected final ch.qos.logback.classic.Logger log = + (Logger) LoggerFactory.getLogger(simulationName); - protected final DataQueueExtSimulationExtSimulator dataQueueExtCoSimulatorToSimonaApi; - protected final DataQueueExtSimulationExtSimulator dataQueueSimonaApiToExtCoSimulator; + /** Queue for the data connection from the external co-simulation to SimonaAPI */ + protected final DataQueueExtSimulationExtSimulator + dataQueueExtCoSimulatorToSimonaApi; - private final long deltaT = 900L; + /** Queue for the data connection from SimonaAPI to the external co-simulation */ + protected final DataQueueExtSimulationExtSimulator + dataQueueSimonaApiToExtCoSimulator; - protected ExtCoSimulation(String simulationName) { - super(simulationName); - this.dataQueueExtCoSimulatorToSimonaApi = new DataQueueExtSimulationExtSimulator<>(); - this.dataQueueSimonaApiToExtCoSimulator = new DataQueueExtSimulationExtSimulator<>(); - } + /** Time resolution for the data exchange */ + private final long deltaT = 900L; - protected void sendPrimaryDataToSimona( - ExtPrimaryData extPrimaryData, - long tick - ) { - try { - ExtInputDataContainer inputData = dataQueueExtCoSimulatorToSimonaApi.takeData(); - log.debug("Received Primary Data from " + simulationName + " = " + inputData); + /** Name of the external co-simulation */ + protected final String extSimulatorName; - extPrimaryData.providePrimaryData( - tick, - extPrimaryData.convertExternalInputToPrimaryData(inputData), - inputData.getMaybeNextTick() - ); - log.info("Provided Primary Data to SIMONA"); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } + protected ExtCoSimulation(String simulationName, String extSimulatorName) { + super(simulationName); + this.extSimulatorName = extSimulatorName; + this.dataQueueExtCoSimulatorToSimonaApi = new DataQueueExtSimulationExtSimulator<>(); + this.dataQueueSimonaApiToExtCoSimulator = new DataQueueExtSimulationExtSimulator<>(); + } - protected void sendEmDataToSimona( - ExtEmData extEmData, - long tick, - long nextTick - ) { - try { - log.info("+++++ External simulation triggered for tick " + tick + " +++++"); - log.info("Wait for new EmData from OpSim..."); - ExtInputDataContainer rawEmData = dataQueueExtCoSimulatorToSimonaApi.takeData(); - extEmData.provideEmData( - tick, - extEmData.createExtEmDataMap(rawEmData), - Optional.of(nextTick) - ); - log.info("Provided EmData to SIMONA!"); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } + /** Function to send primary data to SIMONA using ExtPrimaryData */ + protected void sendPrimaryDataToSimona(ExtPrimaryData extPrimaryData, long tick) { + try { + log.debug("Wait for Primary Data from " + extSimulatorName); + ExtInputDataContainer inputData = dataQueueExtCoSimulatorToSimonaApi.takeData(); + log.debug("Received Primary Data from " + extSimulatorName); + extPrimaryData.providePrimaryData( + tick, + extPrimaryData.convertExternalInputToPrimaryData(inputData), + inputData.getMaybeNextTick()); + log.debug("Provided Primary Data to SIMONA!"); + } catch (InterruptedException e) { + throw new RuntimeException(e); } + } - protected void sendResultsToExtCoSimulator( - ExtResultData extResultData, - long tick, - long nextTick - ) { - try { - log.info("Request Results from SIMONA!"); - Map resultsToBeSend = extResultData.requestResults(tick); - log.info("Received results from SIMONA! Now convert them and send them to Mosaik!"); + /** + * Function to send em data to SIMONA using ExtPrimaryData nextTick is necessary, because the em + * agents have an own scheduler that should know, when the next set point arrives. + */ + protected void sendEmDataToSimona(ExtEmData extEmData, long tick, long nextTick) { + try { + log.debug("Wait for EmData from " + extSimulatorName); + ExtInputDataContainer inputData = dataQueueExtCoSimulatorToSimonaApi.takeData(); + log.debug("Received EmData from " + extSimulatorName); + extEmData.provideEmData( + tick, extEmData.convertExternalInputToEmSetPoints(inputData), Optional.of(nextTick)); + log.debug("Provided EmData to SIMONA!"); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } - dataQueueSimonaApiToExtCoSimulator.queueData(new ExtResultContainer(tick, resultsToBeSend)); - log.info("***** External simulation for tick " + tick + " completed. Next simulation tick = " + nextTick + " *****"); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } + /** Function to get result data from SIMONA using ExtResultData */ + protected void sendResultsToExtCoSimulator( + ExtResultData extResultData, long tick, Optional nextTick) { + try { + log.debug("Request results from SIMONA!"); + Map resultsToBeSend = extResultData.requestResults(tick); + log.debug("Received results from SIMONA!"); + dataQueueSimonaApiToExtCoSimulator.queueData( + new ExtResultContainer(tick, resultsToBeSend, nextTick)); + log.debug("Sent results to " + extSimulatorName); + } catch (InterruptedException e) { + throw new RuntimeException(e); } + } } diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityEntry.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityEntry.java index f1c267e..2346023 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityEntry.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityEntry.java @@ -11,7 +11,7 @@ import java.util.UUID; /** - * Package of an external asset with all information for the mapping + * Container for an external asset with all information for the mapping * * @param uuid SIMONA uuid * @param id external id diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java index b60d3aa..343c577 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java @@ -41,7 +41,8 @@ protected ExtEntityEntry buildModel(EntityData data) { return new ExtEntityEntry( simonaUuid, extId, - columnScheme.orElseThrow(), // FIXME: Interim version -> ColumnScheme should handle more data types + columnScheme + .orElseThrow(), // FIXME: Interim version -> ColumnScheme should handle more data types inputType); } } diff --git a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy index f070bb1..8152e3c 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy @@ -4,10 +4,8 @@ package edu.ie3.simona.api.data.em import edu.ie3.datamodel.models.value.PValue import edu.ie3.datamodel.models.value.Value import edu.ie3.simona.api.data.ExtInputDataContainer -import edu.ie3.simona.api.data.ExtInputDataValue import edu.ie3.simona.api.data.em.ontology.ProvideEmSetPointData import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage -import edu.ie3.simona.api.exceptions.ConversionException import edu.ie3.simona.api.test.common.DataServiceTestData import org.apache.pekko.actor.ActorSystem import org.apache.pekko.testkit.TestProbe @@ -26,29 +24,6 @@ class ExtEmDataTest extends Specification implements DataServiceTestData { inputUuid ) - class TestInputDataPValue implements ExtInputDataValue { - private final PValue pValue - - TestInputDataPValue(PValue pValue) { - this.pValue = pValue - } - - PValue getPValue() { - return pValue - } - } - - class TestEmDataFactory implements EmDataFactory { - @Override - PValue convert(ExtInputDataValue entity) throws ConversionException { - if (entity instanceof TestInputDataPValue) { - return entity.pValue - } else { - throw new ConversionException("This factory can only convert PValue entities.") - } - } - } - def setupSpec() { actorSystem = ActorSystem.create() } @@ -62,7 +37,7 @@ class ExtEmDataTest extends Specification implements DataServiceTestData { given: def dataService = new TestProbe(actorSystem) def extSimAdapter = new TestProbe(actorSystem) - def extEmData = new ExtEmData(new TestEmDataFactory(), extEmDataMapping) + def extEmData = new ExtEmData(extEmDataMapping) extEmData.setActorRefs( dataService.ref(), extSimAdapter.ref() @@ -84,12 +59,12 @@ class ExtEmDataTest extends Specification implements DataServiceTestData { def "ExtEmData should convert ExtInputDataPackage to a map"() { given: - def extEmData = new ExtEmData(new TestEmDataFactory(), extEmDataMapping) - def inputDataMap = Map.of("Em", new TestInputDataPValue(pValue)) - def inputDataPackage = new ExtInputDataContainer(0L, inputDataMap, Optional.of(900L)) + def extEmData = new ExtEmData(extEmDataMapping) + def inputDataMap = Map.of("Em", pValue) + def inputDataContainer = new ExtInputDataContainer(0L, inputDataMap, 900L) when: - def emDataMap = extEmData.createExtEmDataMap(inputDataPackage) + def emDataMap = extEmData.convertExternalInputToEmSetPoints(inputDataContainer) then: emDataMap.get(inputUuid) == pValue @@ -97,12 +72,12 @@ class ExtEmDataTest extends Specification implements DataServiceTestData { def "ExtEmData should throw an exception, if input data for a not requested asset was provided"() { given: - def extEmData = new ExtEmData(new TestEmDataFactory(), extEmDataMapping) - def inputDataMap = Map.of("Load", new TestInputDataPValue(pValue)) - def inputDataPackage = new ExtInputDataContainer(0L, inputDataMap, Optional.of(900L)) + def extEmData = new ExtEmData(extEmDataMapping) + def inputDataMap = Map.of("Load", pValue) + def inputDataContainer = new ExtInputDataContainer(0L, inputDataMap, 900L) when: - extEmData.createExtEmDataMap(inputDataPackage) + extEmData.convertExternalInputToEmSetPoints(inputDataContainer) then: thrown IllegalArgumentException diff --git a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy index 20cc540..099087f 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy @@ -1,12 +1,9 @@ package edu.ie3.simona.api.data.primarydata - import edu.ie3.datamodel.models.value.Value import edu.ie3.simona.api.data.ExtInputDataContainer -import edu.ie3.simona.api.data.ExtInputDataValue import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData -import edu.ie3.simona.api.exceptions.ConversionException import edu.ie3.simona.api.test.common.DataServiceTestData import org.apache.pekko.actor.ActorSystem import org.apache.pekko.testkit.TestProbe @@ -25,29 +22,6 @@ class ExtPrimaryDataTest extends Specification implements DataServiceTestData { inputUuid ) - class TestInputDataValue implements ExtInputDataValue { - private final Value value - - TestInputDataValue(Value value) { - this.value = value - } - - Value getValue() { - return value - } - } - - class TestPrimaryDataFactory implements PrimaryDataFactory { - @Override - Value convert(ExtInputDataValue entity) throws ConversionException { - if (entity instanceof TestInputDataValue) { - return entity.value - } else { - throw new ConversionException("This factory can only convert PValue entities.") - } - } - } - def setupSpec() { actorSystem = ActorSystem.create() } @@ -61,7 +35,7 @@ class ExtPrimaryDataTest extends Specification implements DataServiceTestData { given: def dataService = new TestProbe(actorSystem) def extSimAdapter = new TestProbe(actorSystem) - def extPrimaryData = new ExtPrimaryData(new TestPrimaryDataFactory(), extPrimaryDataMapping) + def extPrimaryData = new ExtPrimaryData(extPrimaryDataMapping) extPrimaryData.setActorRefs( dataService.ref(), extSimAdapter.ref() @@ -83,12 +57,12 @@ class ExtPrimaryDataTest extends Specification implements DataServiceTestData { def "ExtPrimaryData should convert ExtInputDataPackage to a map"() { given: - def extPrimaryData = new ExtPrimaryData(new TestPrimaryDataFactory(), extPrimaryDataMapping) - def inputDataMap = Map.of("Pv", new TestInputDataValue(pValue)) - def inputDataPackage = new ExtInputDataContainer(0L, inputDataMap, Optional.of(900L)) + def extPrimaryData = new ExtPrimaryData(extPrimaryDataMapping) + def inputDataMap = Map.of("Pv", pValue) + def inputDataContainer = new ExtInputDataContainer(0L, inputDataMap, 900L) when: - def primaryDataMap = extPrimaryData.createExtPrimaryDataMap(inputDataPackage) + def primaryDataMap = extPrimaryData.convertExternalInputToPrimaryData(inputDataContainer) then: primaryDataMap.get(inputUuid) == pValue @@ -96,12 +70,12 @@ class ExtPrimaryDataTest extends Specification implements DataServiceTestData { def "ExtPrimaryData should throw an exception, if input data for a not requested asset was provided"() { given: - def extPrimaryData = new ExtPrimaryData(new TestPrimaryDataFactory(), extPrimaryDataMapping) - def inputDataMap = Map.of("Load", new TestInputDataValue(pValue)) - def inputDataPackage = new ExtInputDataContainer(0L, inputDataMap, Optional.of(900L)) + def extPrimaryData = new ExtPrimaryData(extPrimaryDataMapping) + def inputDataMap = Map.of("Load", pValue) + def inputDataContainer = new ExtInputDataContainer(0L, inputDataMap, 900L) when: - extPrimaryData.createExtPrimaryDataMap(inputDataPackage) + extPrimaryData.convertExternalInputToPrimaryData(inputDataContainer) then: thrown IllegalArgumentException diff --git a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultPackageTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultContainerTest.groovy similarity index 56% rename from src/test/groovy/edu/ie3/simona/api/data/results/ExtResultPackageTest.groovy rename to src/test/groovy/edu/ie3/simona/api/data/results/ExtResultContainerTest.groovy index 3c6d89c..b86f6ae 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultPackageTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultContainerTest.groovy @@ -10,7 +10,7 @@ import tech.units.indriya.quantity.Quantities import java.time.ZonedDateTime -class ExtResultPackageTest extends Specification implements DataServiceTestData { +class ExtResultContainerTest extends Specification implements DataServiceTestData { @Shared UUID nodeUuid = UUID.fromString("55b97041-64be-4e6b-983a-72dbde6eddf4") @@ -23,71 +23,71 @@ class ExtResultPackageTest extends Specification implements DataServiceTestData Quantities.getQuantity(45, StandardUnits.VOLTAGE_ANGLE) ) - def "ExtResultPackage should return voltage deviation correctly"() { + def "ExtResultContainer should return voltage deviation correctly"() { given: def resultMap = Map.of( "Node", nodeResult ) - def extResultPackage = new ExtResultContainer(0L, resultMap) + def extResultContainer = new ExtResultContainer(0L, resultMap) when: - def calculatedVoltageDeviation = extResultPackage.getVoltageDeviation("Node") + def calculatedVoltageDeviation = extResultContainer.getVoltageDeviation("Node") then: calculatedVoltageDeviation == -0.05d } - def "ExtResultPackage should throw an exception, if voltage deviation was requested for a not NodeResult"() { + def "ExtResultContainer should throw an exception, if voltage deviation was requested for a not NodeResult"() { given: def resultMap = Map.of( "Load", loadResult ) - def extResultPackage = new ExtResultContainer(0L, resultMap) + def extResultContainer = new ExtResultContainer(0L, resultMap) when: - extResultPackage.getVoltageDeviation("Load") + extResultContainer.getVoltageDeviation("Load") then: thrown IllegalArgumentException } - def "ExtResultPackage should return active power correctly"() { + def "ExtResultContainer should return active power correctly"() { given: def resultMap = Map.of( "Load", loadResult ) - def extResultPackage = new ExtResultContainer(0L, resultMap) + def extResultContainer = new ExtResultContainer(0L, resultMap) when: - def returnedActivePower = extResultPackage.getActivePower("Load") + def returnedActivePower = extResultContainer.getActivePower("Load") then: returnedActivePower == 10d } - def "ExtResultPackage should return reactive power correctly"() { + def "ExtResultContainer should return reactive power correctly"() { given: def resultMap = Map.of( "Load", loadResult ) - def extResultPackage = new ExtResultContainer(0L, resultMap) + def extResultContainer = new ExtResultContainer(0L, resultMap) when: - def returnedReactivePower = extResultPackage.getReactivePower("Load") + def returnedReactivePower = extResultContainer.getReactivePower("Load") then: returnedReactivePower == 5d } - def "ExtResultPackage should throw an exception, if active power was requested for a not SystemParticipantResult"() { + def "ExtResultContainer should throw an exception, if active power was requested for a not SystemParticipantResult"() { given: def resultMap = Map.of( "Node", nodeResult ) - def extResultPackage = new ExtResultContainer(0L, resultMap) + def extResultContainer = new ExtResultContainer(0L, resultMap) when: - extResultPackage.getActivePower("Node") + extResultContainer.getActivePower("Node") then: thrown IllegalArgumentException diff --git a/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy b/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy index 054a04f..8c2724a 100644 --- a/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy +++ b/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy @@ -32,6 +32,7 @@ class ExtSimulationSpec extends Specification { private Optional activationReturnTick TestSimulation(Long initReturnTick, Optional activationReturnTick) { + super("TestSimulation") this.initReturnTick = initReturnTick this.activationReturnTick = activationReturnTick } diff --git a/src/test/groovy/edu/ie3/simona/api/test/common/TestInputDataValue.groovy b/src/test/groovy/edu/ie3/simona/api/test/common/TestInputDataValue.groovy deleted file mode 100644 index 5b4624d..0000000 --- a/src/test/groovy/edu/ie3/simona/api/test/common/TestInputDataValue.groovy +++ /dev/null @@ -1,18 +0,0 @@ -package edu.ie3.simona.api.test.common - -import edu.ie3.datamodel.models.value.PValue -import edu.ie3.datamodel.models.value.Value -import edu.ie3.simona.api.data.ExtInputDataValue - - -class TestInputDataValue implements ExtInputDataValue { - private final Value value - - TestInputDataValue(Value value) { - this.value = value - } - - Value getValue() { - return value - } -} From b262929e3267830d6da081705c6b4aeb5c3dcf80 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 21 Nov 2024 10:32:47 +0100 Subject: [PATCH 61/82] improve doc --- src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java | 1 + .../java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java | 1 + src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java | 1 + 3 files changed, 3 insertions(+) diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java index cb944e6..3e80ddf 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java @@ -15,6 +15,7 @@ import java.util.*; import org.apache.pekko.actor.ActorRef; +/** Enables data connection of em data between SIMONA and SimonaAPI */ public class ExtEmData implements ExtData { /** Actor reference to service that handles ev data within SIMONA */ diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java index 2121699..048353b 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java @@ -15,6 +15,7 @@ import java.util.*; import org.apache.pekko.actor.ActorRef; +/** Enables data connection of primary data between SIMONA and SimonaAPI */ public class ExtPrimaryData implements ExtData { /** Actor reference to service that handles ev data within SIMONA */ diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java index f426a10..389d62b 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java @@ -22,6 +22,7 @@ import java.util.concurrent.LinkedBlockingQueue; import org.apache.pekko.actor.ActorRef; +/** Enables data connection of results between SIMONA and SimonaAPI */ public class ExtResultData implements ExtOutputData { /** Data message queue containing messages from SIMONA */ From 31bd7ccb65e18934ab0a0bdc2092c14a9abb9daa Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 21 Nov 2024 14:10:49 +0100 Subject: [PATCH 62/82] clean code --- .../java/edu/ie3/simona/api/data/ExtInputDataContainer.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataContainer.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataContainer.java index 794d3b1..e4de933 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtInputDataContainer.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataContainer.java @@ -54,10 +54,6 @@ public Map getSimonaInputMap() { return dataMap; } - public Long getTick() { - return tick; - } - public Optional getMaybeNextTick() { return maybeNextTick; } From dfa26fbaccf0d4b1e1730c133a0f6ffa399328dd Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 21 Nov 2024 14:33:32 +0100 Subject: [PATCH 63/82] improve doc --- .../simona/api/data/DataQueueExtSimulationExtSimulator.java | 2 +- src/main/java/edu/ie3/simona/api/data/ExtDataContainer.java | 2 +- .../java/edu/ie3/simona/api/data/ExtInputDataContainer.java | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java b/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java index 8416ce4..67d8cb0 100644 --- a/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java +++ b/src/main/java/edu/ie3/simona/api/data/DataQueueExtSimulationExtSimulator.java @@ -8,7 +8,7 @@ import java.util.concurrent.LinkedBlockingQueue; -/** Data queue to allow data flow between SIMONA and an external simulation */ +/** Data queue to allow data flow between SimonaAPI and an external simulation */ public class DataQueueExtSimulationExtSimulator { private final LinkedBlockingQueue receiverTriggerQueue = new LinkedBlockingQueue<>(); diff --git a/src/main/java/edu/ie3/simona/api/data/ExtDataContainer.java b/src/main/java/edu/ie3/simona/api/data/ExtDataContainer.java index 60a2e44..224b9de 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtDataContainer.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtDataContainer.java @@ -6,5 +6,5 @@ package edu.ie3.simona.api.data; -/** Interface for data format to exchange data with an external simulation */ +/** Interface for data that are exchanged between an external simulation and SimonaAPI */ public interface ExtDataContainer {} diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataContainer.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataContainer.java index e4de933..bec23e5 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtInputDataContainer.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataContainer.java @@ -24,7 +24,7 @@ public class ExtInputDataContainer implements ExtDataContainer { private final Optional maybeNextTick; /** - * Container class for input data for SIMONA + * Container class for input data for SIMONA which can be read by SimonaAPI * * @param tick The tick, the input data is meant for * @param dataMap data to be provided to SIMONA @@ -50,6 +50,10 @@ public ExtInputDataContainer(long tick, long nextTick) { this(tick, new HashMap<>(), nextTick); } + public long getTick() { + return tick; + } + public Map getSimonaInputMap() { return dataMap; } From a6b99ba8769855cd6b36ca486db956b4b764659d Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 21 Nov 2024 14:47:48 +0100 Subject: [PATCH 64/82] fix logger --- .../ie3/simona/api/simulation/ExtCoSimulation.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java index 228978d..153136c 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java @@ -16,7 +16,6 @@ import edu.ie3.simona.api.data.results.ExtResultData; import java.util.Map; import java.util.Optional; -import org.slf4j.LoggerFactory; /** * Abstract class for an external co-simulation with the structure: external api - ext-co-simulation @@ -25,10 +24,6 @@ */ public abstract class ExtCoSimulation extends ExtSimulation { - /** Logging for the external co simulation */ - protected final ch.qos.logback.classic.Logger log = - (Logger) LoggerFactory.getLogger(simulationName); - /** Queue for the data connection from the external co-simulation to SimonaAPI */ protected final DataQueueExtSimulationExtSimulator dataQueueExtCoSimulatorToSimonaApi; @@ -51,7 +46,7 @@ protected ExtCoSimulation(String simulationName, String extSimulatorName) { } /** Function to send primary data to SIMONA using ExtPrimaryData */ - protected void sendPrimaryDataToSimona(ExtPrimaryData extPrimaryData, long tick) { + protected void sendPrimaryDataToSimona(ExtPrimaryData extPrimaryData, long tick, Logger log) { try { log.debug("Wait for Primary Data from " + extSimulatorName); ExtInputDataContainer inputData = dataQueueExtCoSimulatorToSimonaApi.takeData(); @@ -70,7 +65,7 @@ protected void sendPrimaryDataToSimona(ExtPrimaryData extPrimaryData, long tick) * Function to send em data to SIMONA using ExtPrimaryData nextTick is necessary, because the em * agents have an own scheduler that should know, when the next set point arrives. */ - protected void sendEmDataToSimona(ExtEmData extEmData, long tick, long nextTick) { + protected void sendEmDataToSimona(ExtEmData extEmData, long tick, long nextTick, Logger log) { try { log.debug("Wait for EmData from " + extSimulatorName); ExtInputDataContainer inputData = dataQueueExtCoSimulatorToSimonaApi.takeData(); @@ -85,7 +80,7 @@ protected void sendEmDataToSimona(ExtEmData extEmData, long tick, long nextTick) /** Function to get result data from SIMONA using ExtResultData */ protected void sendResultsToExtCoSimulator( - ExtResultData extResultData, long tick, Optional nextTick) { + ExtResultData extResultData, long tick, Optional nextTick, Logger log) { try { log.debug("Request results from SIMONA!"); Map resultsToBeSend = extResultData.requestResults(tick); From 2a3b45b37c2be50708c3362d29894d819b7beca4 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 21 Nov 2024 14:59:40 +0100 Subject: [PATCH 65/82] fix sonarqube --- .../api/simulation/ExtCoSimulation.java | 61 ++++++++----------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java index 153136c..402f5f7 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java @@ -46,50 +46,41 @@ protected ExtCoSimulation(String simulationName, String extSimulatorName) { } /** Function to send primary data to SIMONA using ExtPrimaryData */ - protected void sendPrimaryDataToSimona(ExtPrimaryData extPrimaryData, long tick, Logger log) { - try { - log.debug("Wait for Primary Data from " + extSimulatorName); - ExtInputDataContainer inputData = dataQueueExtCoSimulatorToSimonaApi.takeData(); - log.debug("Received Primary Data from " + extSimulatorName); - extPrimaryData.providePrimaryData( - tick, - extPrimaryData.convertExternalInputToPrimaryData(inputData), - inputData.getMaybeNextTick()); - log.debug("Provided Primary Data to SIMONA!"); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } + protected void sendPrimaryDataToSimona(ExtPrimaryData extPrimaryData, long tick, Logger log) + throws InterruptedException { + log.debug("Wait for Primary Data from " + extSimulatorName); + ExtInputDataContainer inputData = dataQueueExtCoSimulatorToSimonaApi.takeData(); + log.debug("Received Primary Data from " + extSimulatorName); + extPrimaryData.providePrimaryData( + tick, + extPrimaryData.convertExternalInputToPrimaryData(inputData), + inputData.getMaybeNextTick()); + log.debug("Provided Primary Data to SIMONA!"); } /** * Function to send em data to SIMONA using ExtPrimaryData nextTick is necessary, because the em * agents have an own scheduler that should know, when the next set point arrives. */ - protected void sendEmDataToSimona(ExtEmData extEmData, long tick, long nextTick, Logger log) { - try { - log.debug("Wait for EmData from " + extSimulatorName); - ExtInputDataContainer inputData = dataQueueExtCoSimulatorToSimonaApi.takeData(); - log.debug("Received EmData from " + extSimulatorName); - extEmData.provideEmData( - tick, extEmData.convertExternalInputToEmSetPoints(inputData), Optional.of(nextTick)); - log.debug("Provided EmData to SIMONA!"); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } + protected void sendEmDataToSimona(ExtEmData extEmData, long tick, long nextTick, Logger log) + throws InterruptedException { + log.debug("Wait for EmData from " + extSimulatorName); + ExtInputDataContainer inputData = dataQueueExtCoSimulatorToSimonaApi.takeData(); + log.debug("Received EmData from " + extSimulatorName); + extEmData.provideEmData( + tick, extEmData.convertExternalInputToEmSetPoints(inputData), Optional.of(nextTick)); + log.debug("Provided EmData to SIMONA!"); } /** Function to get result data from SIMONA using ExtResultData */ protected void sendResultsToExtCoSimulator( - ExtResultData extResultData, long tick, Optional nextTick, Logger log) { - try { - log.debug("Request results from SIMONA!"); - Map resultsToBeSend = extResultData.requestResults(tick); - log.debug("Received results from SIMONA!"); - dataQueueSimonaApiToExtCoSimulator.queueData( - new ExtResultContainer(tick, resultsToBeSend, nextTick)); - log.debug("Sent results to " + extSimulatorName); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } + ExtResultData extResultData, long tick, Optional nextTick, Logger log) + throws InterruptedException { + log.debug("Request results from SIMONA!"); + Map resultsToBeSend = extResultData.requestResults(tick); + log.debug("Received results from SIMONA!"); + dataQueueSimonaApiToExtCoSimulator.queueData( + new ExtResultContainer(tick, resultsToBeSend, nextTick)); + log.debug("Sent results to " + extSimulatorName); } } From b67cf22b786edbf5b21a875fcd980a1bee17da43 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Wed, 27 Nov 2024 09:22:59 +0100 Subject: [PATCH 66/82] update logging --- build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle b/build.gradle index c57bbc9..a55f167 100644 --- a/build.gradle +++ b/build.gradle @@ -66,7 +66,6 @@ dependencies{ } // logging - implementation "com.typesafe.scala-logging:scala-logging_${scalaVersion}:3.9.5" // pekko scala logging implementation "ch.qos.logback:logback-classic:1.4.14" // pekko From cc0e634c5fb6b13bc7859fab528338dac6bd1ae7 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Wed, 27 Nov 2024 09:44:02 +0100 Subject: [PATCH 67/82] update logging --- build.gradle | 6 +++++- .../java/edu/ie3/simona/api/simulation/ExtCoSimulation.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index a55f167..1e05455 100644 --- a/build.gradle +++ b/build.gradle @@ -66,7 +66,11 @@ dependencies{ } // logging - implementation "ch.qos.logback:logback-classic:1.4.14" + //implementation "ch.qos.logback:logback-classic:1.4.14" + implementation platform('org.apache.logging.log4j:log4j-bom:2.24.1') + implementation 'org.apache.logging.log4j:log4j-api' // log4j + implementation 'org.apache.logging.log4j:log4j-core' // log4j + implementation 'org.apache.logging.log4j:log4j-slf4j-impl' // log4j -> slf4j // pekko implementation "org.apache.pekko:pekko-actor_${scalaVersion}:${pekkoVersion}" diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java index 402f5f7..6fdc548 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java @@ -6,7 +6,7 @@ package edu.ie3.simona.api.simulation; -import ch.qos.logback.classic.Logger; +import org.slf4j.Logger; import edu.ie3.datamodel.models.result.ModelResultEntity; import edu.ie3.simona.api.data.DataQueueExtSimulationExtSimulator; import edu.ie3.simona.api.data.ExtInputDataContainer; From 0e667581bddff06bb9faea00387cf2831d8e5454 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Wed, 27 Nov 2024 10:38:47 +0100 Subject: [PATCH 68/82] update logging --- build.gradle | 5 +++-- .../java/edu/ie3/simona/api/simulation/ExtCoSimulation.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 1e05455..4e9989b 100644 --- a/build.gradle +++ b/build.gradle @@ -51,13 +51,15 @@ dependencies{ // scala (needed for pekko) implementation "org.scala-lang:scala-library:${scalaBinaryVersion}" - //PSDM + //PSU implementation('com.github.ie3-institute:PowerSystemUtils:2.2.1') { exclude group: 'org.apache.logging.log4j' exclude group: 'org.slf4j' /* Exclude our own nested dependencies */ exclude group: 'com.github.ie3-institute' } + + //PSDM implementation('com.github.ie3-institute:PowerSystemDataModel:5.1.0') { exclude group: 'org.apache.logging.log4j' exclude group: 'org.slf4j' @@ -66,7 +68,6 @@ dependencies{ } // logging - //implementation "ch.qos.logback:logback-classic:1.4.14" implementation platform('org.apache.logging.log4j:log4j-bom:2.24.1') implementation 'org.apache.logging.log4j:log4j-api' // log4j implementation 'org.apache.logging.log4j:log4j-core' // log4j diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java index 6fdc548..c732b09 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java @@ -6,7 +6,6 @@ package edu.ie3.simona.api.simulation; -import org.slf4j.Logger; import edu.ie3.datamodel.models.result.ModelResultEntity; import edu.ie3.simona.api.data.DataQueueExtSimulationExtSimulator; import edu.ie3.simona.api.data.ExtInputDataContainer; @@ -16,6 +15,7 @@ import edu.ie3.simona.api.data.results.ExtResultData; import java.util.Map; import java.util.Optional; +import org.slf4j.Logger; /** * Abstract class for an external co-simulation with the structure: external api - ext-co-simulation From e72cfd0aff516ab423ae864ae2687e49326d21f2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Nov 2024 09:03:38 +0000 Subject: [PATCH 69/82] Bump org.sonarqube from 6.0.0.5145 to 6.0.1.5171 (#214) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 705c811..28f6f51 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { id 'com.diffplug.spotless' version '6.25.0'//code format id 'pmd' // code check, working on source code id 'com.github.spotbugs' version '6.0.26' // code check, working on byte code - id "org.sonarqube" version "6.0.0.5145" // sonarqube + id "org.sonarqube" version "6.0.1.5171" // sonarqube id 'signing' id 'maven-publish' // publish to a maven repo (local or mvn central, has to be defined) id 'jacoco' // java code coverage plugin From 094bcaf304267824e38c45aaa8c9e4e2e90c1134 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Nov 2024 09:11:09 +0000 Subject: [PATCH 70/82] Bump com.fasterxml.jackson.core:jackson-databind from 2.18.1 to 2.18.2 (#213) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 28f6f51..9ec3561 100644 --- a/build.gradle +++ b/build.gradle @@ -72,7 +72,7 @@ dependencies{ // TESTING testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0' - implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.18.1' + implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.18.2' } task printVersion { From 4fe25eb44a158fa584792063267f1e5474dc4927 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 28 Nov 2024 15:34:23 +0100 Subject: [PATCH 71/82] fix sonarqube --- .../java/edu/ie3/simona/api/simulation/ExtCoSimulation.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java index c732b09..6b5a497 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java @@ -64,9 +64,9 @@ protected void sendPrimaryDataToSimona(ExtPrimaryData extPrimaryData, long tick, */ protected void sendEmDataToSimona(ExtEmData extEmData, long tick, long nextTick, Logger log) throws InterruptedException { - log.debug("Wait for EmData from " + extSimulatorName); + log.debug("Wait for EmData from {}", extSimulatorName); ExtInputDataContainer inputData = dataQueueExtCoSimulatorToSimonaApi.takeData(); - log.debug("Received EmData from " + extSimulatorName); + log.debug("Received EmData from {}", extSimulatorName); extEmData.provideEmData( tick, extEmData.convertExternalInputToEmSetPoints(inputData), Optional.of(nextTick)); log.debug("Provided EmData to SIMONA!"); @@ -81,6 +81,6 @@ protected void sendResultsToExtCoSimulator( log.debug("Received results from SIMONA!"); dataQueueSimonaApiToExtCoSimulator.queueData( new ExtResultContainer(tick, resultsToBeSend, nextTick)); - log.debug("Sent results to " + extSimulatorName); + log.debug("Sent results to {}", extSimulatorName); } } From 48e5d3de9299a49fade003efef1db0096d8884e7 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 28 Nov 2024 15:55:07 +0100 Subject: [PATCH 72/82] fix sonarqube --- .../java/edu/ie3/simona/api/simulation/ExtCoSimulation.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java index 6b5a497..b8d08e5 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java @@ -32,9 +32,6 @@ public abstract class ExtCoSimulation extends ExtSimulation { protected final DataQueueExtSimulationExtSimulator dataQueueSimonaApiToExtCoSimulator; - /** Time resolution for the data exchange */ - private final long deltaT = 900L; - /** Name of the external co-simulation */ protected final String extSimulatorName; From ea9c05c1770b5324cc0c67c93d0783a305a97f95 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 28 Nov 2024 16:00:32 +0100 Subject: [PATCH 73/82] fix sonarqube --- .../edu/ie3/simona/api/data/results/ExtResultContainer.java | 4 ++++ .../java/edu/ie3/simona/api/simulation/ExtCoSimulation.java | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultContainer.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultContainer.java index 8d2efad..94303e4 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultContainer.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultContainer.java @@ -56,6 +56,10 @@ public Long getTick() { return tick; } + public Optional getNextTick() { + return maybeNextTick; + } + /** * Returns the voltage deviation for certain asset, if this asset provided a {@link NodeResult} */ diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java index b8d08e5..9d926d5 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java @@ -45,9 +45,9 @@ protected ExtCoSimulation(String simulationName, String extSimulatorName) { /** Function to send primary data to SIMONA using ExtPrimaryData */ protected void sendPrimaryDataToSimona(ExtPrimaryData extPrimaryData, long tick, Logger log) throws InterruptedException { - log.debug("Wait for Primary Data from " + extSimulatorName); + log.debug("Wait for Primary Data from {}", extSimulatorName); ExtInputDataContainer inputData = dataQueueExtCoSimulatorToSimonaApi.takeData(); - log.debug("Received Primary Data from " + extSimulatorName); + log.debug("Received Primary Data from {}", extSimulatorName); extPrimaryData.providePrimaryData( tick, extPrimaryData.convertExternalInputToPrimaryData(inputData), From 52bf491087151bf18dd0475453ad46fed8537d15 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Nov 2024 08:05:12 +0000 Subject: [PATCH 74/82] Bump org.apache.logging.log4j:log4j-bom from 2.24.1 to 2.24.2 (#215) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index c013d10..73d7b4b 100644 --- a/build.gradle +++ b/build.gradle @@ -68,7 +68,7 @@ dependencies{ } // logging - implementation platform('org.apache.logging.log4j:log4j-bom:2.24.1') + implementation platform('org.apache.logging.log4j:log4j-bom:2.24.2') implementation 'org.apache.logging.log4j:log4j-api' // log4j implementation 'org.apache.logging.log4j:log4j-core' // log4j implementation 'org.apache.logging.log4j:log4j-slf4j-impl' // log4j -> slf4j From 2aecc3216241e7913f850960f7a8dd676a0713d8 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Fri, 29 Nov 2024 09:48:02 +0100 Subject: [PATCH 75/82] ExtResultContainer returns resultmap --- CHANGELOG.md | 6 ++++-- .../edu/ie3/simona/api/data/results/ExtResultContainer.java | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d99a9ea..2a5642e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,17 +6,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased/Snapshot] +### Added +- Enable initialization of external data simulation [#167](https://github.com/ie3-institute/simonaAPI/issues/167) +- `ExtResultContainer` returns result map [#217](https://github.com/ie3-institute/simonaAPI/issues/217) + ### Changed - Renaming power fields in `EvModel` [#208](https://github.com/ie3-institute/simonaAPI/issues/208) - ## [0.5.0] - 2024-08-09 ### Added - Implemented `ExtPrimaryData` and `ExtResultsData` [#145](https://github.com/ie3-institute/simonaAPI/issues/145) - Have EV simulation communicate the next tick [#170](https://github.com/ie3-institute/simonaAPI/issues/170) - Only communicate the next tick of activation of EV simulation as a whole [#176](https://github.com/ie3-institute/simonaAPI/issues/176) -- Enable initialization of external data simulation [#167](https://github.com/ie3-institute/simonaAPI/issues/167) ## [0.4.0] - 2023-11-22 diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultContainer.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultContainer.java index 94303e4..531faf7 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultContainer.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultContainer.java @@ -52,6 +52,10 @@ public ExtResultContainer(long tick, Map simonaResult this(tick, simonaResultsMap, Optional.empty()); } + public Map getResults() { + return simonaResultsMap; + } + public Long getTick() { return tick; } From bb035119e821471368e4f9cbe75ff0b3e30e2591 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Fri, 29 Nov 2024 09:52:24 +0100 Subject: [PATCH 76/82] Enhancing external data connections --- CHANGELOG.md | 2 +- build.gradle | 2 +- .../edu/ie3/simona/api/ExtLinkInterface.java | 21 ++- .../{ExtData.java => ExtDataConnection.java} | 3 +- .../simona/api/data/ExtDataSimulation.java | 16 -- .../api/data/ExtInputDataConnection.java | 21 +++ .../ie3/simona/api/data/ExtOutputData.java | 13 -- .../api/data/ExtOutputDataConnection.java | 27 ++++ ...xtEmData.java => ExtEmDataConnection.java} | 51 +++---- ...xtEvData.java => ExtEvDataConnection.java} | 18 ++- .../simona/api/data/ev/ExtEvSimulation.java | 23 --- ...ata.java => ExtPrimaryDataConnection.java} | 52 ++++--- ...Data.java => ExtResultDataConnection.java} | 6 +- .../api/exceptions/ConversionException.java | 2 +- .../exceptions/NoExtSimulationException.java | 20 +++ .../api/simulation/ExtCoSimulation.java | 137 +++++++++++++++--- .../simona/api/simulation/ExtSimulation.java | 37 ++--- .../api/simulation/mapping/DataType.java | 32 ++++ .../simulation/mapping/ExtEntityEntry.java | 21 ++- .../simulation/mapping/ExtEntityFactory.java | 12 +- .../simulation/mapping/ExtEntityMapping.java | 30 ++-- .../mapping/ExtEntityMappingCsvSource.java | 100 ------------- .../mapping/ExtEntityMappingSource.java | 77 +++++++++- .../data/em/ExtEmDataConnectionTest.groovy | 98 +++++++++++++ .../simona/api/data/em/ExtEmDataTest.groovy | 86 ----------- ....groovy => ExtEvDataConnectionTest.groovy} | 45 +++--- .../ExtPrimaryDataConnectionTest.groovy | 93 ++++++++++++ .../primarydata/ExtPrimaryDataTest.groovy | 83 ----------- ...ovy => ExtResultDataConnectionTest.groovy} | 47 +++--- .../api/simulation/ExtCoSimulationTest.groovy | 93 ++++++++++++ .../api/simulation/ExtSimulationSpec.groovy | 94 ++++++------ .../mapping/ExtEntityMappingSourceTest.groovy | 36 +++++ .../mapping/ExtEntityMappingTest.groovy | 9 +- .../test/common/DataServiceTestData.groovy | 4 + .../simulation/mapping/ext_entity_mapping.csv | 5 + 35 files changed, 847 insertions(+), 569 deletions(-) rename src/main/java/edu/ie3/simona/api/data/{ExtData.java => ExtDataConnection.java} (61%) delete mode 100644 src/main/java/edu/ie3/simona/api/data/ExtDataSimulation.java create mode 100644 src/main/java/edu/ie3/simona/api/data/ExtInputDataConnection.java delete mode 100644 src/main/java/edu/ie3/simona/api/data/ExtOutputData.java create mode 100644 src/main/java/edu/ie3/simona/api/data/ExtOutputDataConnection.java rename src/main/java/edu/ie3/simona/api/data/em/{ExtEmData.java => ExtEmDataConnection.java} (65%) rename src/main/java/edu/ie3/simona/api/data/ev/{ExtEvData.java => ExtEvDataConnection.java} (93%) delete mode 100644 src/main/java/edu/ie3/simona/api/data/ev/ExtEvSimulation.java rename src/main/java/edu/ie3/simona/api/data/primarydata/{ExtPrimaryData.java => ExtPrimaryDataConnection.java} (66%) rename src/main/java/edu/ie3/simona/api/data/results/{ExtResultData.java => ExtResultDataConnection.java} (97%) create mode 100644 src/main/java/edu/ie3/simona/api/exceptions/NoExtSimulationException.java create mode 100644 src/main/java/edu/ie3/simona/api/simulation/mapping/DataType.java delete mode 100644 src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java create mode 100644 src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataConnectionTest.groovy delete mode 100644 src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy rename src/test/groovy/edu/ie3/simona/api/data/ev/{ExtEvDataTest.groovy => ExtEvDataConnectionTest.groovy} (66%) create mode 100644 src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnectionTest.groovy delete mode 100644 src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy rename src/test/groovy/edu/ie3/simona/api/data/results/{ExtResultDataTest.groovy => ExtResultDataConnectionTest.groovy} (64%) create mode 100644 src/test/groovy/edu/ie3/simona/api/simulation/ExtCoSimulationTest.groovy create mode 100644 src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSourceTest.groovy create mode 100644 src/test/resources/edu/ie3/simona/api/simulation/mapping/ext_entity_mapping.csv diff --git a/CHANGELOG.md b/CHANGELOG.md index d99a9ea..db46519 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Renaming power fields in `EvModel` [#208](https://github.com/ie3-institute/simonaAPI/issues/208) - +- Enhancing external data connections [#219](https://github.com/ie3-institute/simonaAPI/issues/219) ## [0.5.0] - 2024-08-09 diff --git a/build.gradle b/build.gradle index c013d10..73d7b4b 100644 --- a/build.gradle +++ b/build.gradle @@ -68,7 +68,7 @@ dependencies{ } // logging - implementation platform('org.apache.logging.log4j:log4j-bom:2.24.1') + implementation platform('org.apache.logging.log4j:log4j-bom:2.24.2') implementation 'org.apache.logging.log4j:log4j-api' // log4j implementation 'org.apache.logging.log4j:log4j-core' // log4j implementation 'org.apache.logging.log4j:log4j-slf4j-impl' // log4j -> slf4j diff --git a/src/main/java/edu/ie3/simona/api/ExtLinkInterface.java b/src/main/java/edu/ie3/simona/api/ExtLinkInterface.java index e69a27c..0761008 100644 --- a/src/main/java/edu/ie3/simona/api/ExtLinkInterface.java +++ b/src/main/java/edu/ie3/simona/api/ExtLinkInterface.java @@ -6,20 +6,25 @@ package edu.ie3.simona.api; -import edu.ie3.simona.api.data.ExtDataSimulation; +import edu.ie3.simona.api.exceptions.NoExtSimulationException; +import edu.ie3.simona.api.simulation.ExtSimAdapterData; import edu.ie3.simona.api.simulation.ExtSimulation; -import java.util.List; /** * Every external simulation has to provide a class {@code edu.ie3.simona.api.ExtLink} which * implements this interface. - * - *

{@link #getExtSimulation()} and {@link #getExtDataSimulations()} can return references to the - * same object, if that object implements both {@link ExtSimulation} and one or more variants of - * {@link ExtDataSimulation}. */ public interface ExtLinkInterface { - ExtSimulation getExtSimulation(); + /** Returns the external simulation. */ + default ExtSimulation getExtSimulation() { + throw new NoExtSimulationException(this.getClass()); + } - List getExtDataSimulations(); + /** + * Method to set up an external simulation. Everything that needs to be set up before the external + * simulation can be retrieved should be done here. + * + * @param data used for setting up the external simulation + */ + void setup(ExtSimAdapterData data); } diff --git a/src/main/java/edu/ie3/simona/api/data/ExtData.java b/src/main/java/edu/ie3/simona/api/data/ExtDataConnection.java similarity index 61% rename from src/main/java/edu/ie3/simona/api/data/ExtData.java rename to src/main/java/edu/ie3/simona/api/data/ExtDataConnection.java index fd35fe7..9de5c6a 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtData.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtDataConnection.java @@ -6,4 +6,5 @@ package edu.ie3.simona.api.data; -public interface ExtData {} +/** Interface that defines a data connection between SIMONA and an external simulation. */ +public interface ExtDataConnection {} diff --git a/src/main/java/edu/ie3/simona/api/data/ExtDataSimulation.java b/src/main/java/edu/ie3/simona/api/data/ExtDataSimulation.java deleted file mode 100644 index ffb06ec..0000000 --- a/src/main/java/edu/ie3/simona/api/data/ExtDataSimulation.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * © 2021. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation - */ - -package edu.ie3.simona.api.data; - -/** - * Represents a data flow inside the external simulation. An external simulation can operate - * multiple data flows of different types. For each data type, there needs to be an interface - * extending this interface which provides methods that receive a data adapter. - * - *

See {@link edu.ie3.simona.api.data.ev.ExtEvSimulation} for an example. - */ -public interface ExtDataSimulation {} diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataConnection.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataConnection.java new file mode 100644 index 0000000..d8a29a7 --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataConnection.java @@ -0,0 +1,21 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + +package edu.ie3.simona.api.data; + +import org.apache.pekko.actor.ActorRef; + +public interface ExtInputDataConnection extends ExtDataConnection { + + /** + * Sets the actor refs for data and control flow. + * + * @param dataService actor ref to the adapter of the data service for schedule activation + * messages + * @param extSimAdapter actor ref to the extSimAdapter + */ + void setActorRefs(ActorRef dataService, ActorRef extSimAdapter); +} diff --git a/src/main/java/edu/ie3/simona/api/data/ExtOutputData.java b/src/main/java/edu/ie3/simona/api/data/ExtOutputData.java deleted file mode 100644 index 80d949a..0000000 --- a/src/main/java/edu/ie3/simona/api/data/ExtOutputData.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * © 2024. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation - */ - -package edu.ie3.simona.api.data; - -/** - * Interface for a connection between SIMONA and an external simulation with data flow from SIMONA - * to external - */ -public interface ExtOutputData extends ExtData {} diff --git a/src/main/java/edu/ie3/simona/api/data/ExtOutputDataConnection.java b/src/main/java/edu/ie3/simona/api/data/ExtOutputDataConnection.java new file mode 100644 index 0000000..6ac15e7 --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/data/ExtOutputDataConnection.java @@ -0,0 +1,27 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + +package edu.ie3.simona.api.data; + +import org.apache.pekko.actor.ActorRef; + +/** + * Interface for a connection between SIMONA and an external simulation with data flow from SIMONA + * to external + */ +public interface ExtOutputDataConnection extends ExtDataConnection { + + /** + * Sets the actor refs for data and control flow + * + * @param extResultDataService actor ref to the adapter of the data service for data messages + * @param dataServiceActivation actor ref to the adapter of the data service for schedule + * activation messages + * @param extSimAdapter actor ref to the extSimAdapter + */ + void setActorRefs( + ActorRef extResultDataService, ActorRef dataServiceActivation, ActorRef extSimAdapter); +} diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataConnection.java similarity index 65% rename from src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java rename to src/main/java/edu/ie3/simona/api/data/em/ExtEmDataConnection.java index 3e80ddf..baaa0f3 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmData.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataConnection.java @@ -7,16 +7,18 @@ package edu.ie3.simona.api.data.em; import edu.ie3.datamodel.models.value.PValue; -import edu.ie3.simona.api.data.ExtData; -import edu.ie3.simona.api.data.ExtInputDataContainer; +import edu.ie3.datamodel.models.value.Value; +import edu.ie3.simona.api.data.ExtInputDataConnection; import edu.ie3.simona.api.data.em.ontology.EmDataMessageFromExt; import edu.ie3.simona.api.data.em.ontology.ProvideEmSetPointData; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import java.util.*; +import java.util.stream.Collectors; import org.apache.pekko.actor.ActorRef; +import org.slf4j.Logger; /** Enables data connection of em data between SIMONA and SimonaAPI */ -public class ExtEmData implements ExtData { +public class ExtEmDataConnection implements ExtInputDataConnection { /** Actor reference to service that handles ev data within SIMONA */ private ActorRef emDataService; @@ -27,16 +29,33 @@ public class ExtEmData implements ExtData { /** Assets that provide primary data to SIMONA */ private final Map extEmMapping; - public ExtEmData(Map extEmMapping) { + public ExtEmDataConnection(Map extEmMapping) { this.extEmMapping = extEmMapping; } - /** Sets the actor refs for data and control flow */ + @Override public void setActorRefs(ActorRef emDataService, ActorRef extSimAdapter) { this.emDataService = emDataService; this.extSimAdapter = extSimAdapter; } + public void convertAndSend( + long tick, Map data, Optional maybeNextTick, Logger log) { + // filtering and converting the data + Map convertedMap = + data.entrySet().stream() + .filter(e -> extEmMapping.containsKey(e.getKey())) + .collect( + Collectors.toMap(e -> extEmMapping.get(e.getKey()), e -> (PValue) e.getValue())); + + if (convertedMap.isEmpty()) { + log.warn("No em data found! Sending no em data to SIMONA for tick {}.", tick); + } else { + log.debug("Provided SIMONA with em data."); + provideEmData(tick, convertedMap, maybeNextTick); + } + } + /** Returns a list of the uuids of the em agents that expect external set points */ public List getControlledEms() { return extEmMapping.values().stream().toList(); @@ -59,26 +78,4 @@ public void sendExtMsg(EmDataMessageFromExt msg) { // we need to schedule data receiver activation with scheduler extSimAdapter.tell(new ScheduleDataServiceMessage(emDataService), ActorRef.noSender()); } - - /** Converts an input data package from an external simulation to a map of set points */ - public Map convertExternalInputToEmSetPoints( - ExtInputDataContainer extInputDataContainer) { - Map emDataForSimona = new HashMap<>(); - extInputDataContainer - .getSimonaInputMap() - .forEach( - (id, value) -> { - if (extEmMapping.containsKey(id)) { - if (value instanceof PValue pValue) { - emDataForSimona.put(extEmMapping.get(id), pValue); - } else { - throw new IllegalArgumentException("EmData can only handle PValue's!"); - } - } else { - throw new IllegalArgumentException( - "Input for asset with id " + id + " was provided, but it wasn't requested!"); - } - }); - return emDataForSimona; - } } diff --git a/src/main/java/edu/ie3/simona/api/data/ev/ExtEvData.java b/src/main/java/edu/ie3/simona/api/data/ev/ExtEvDataConnection.java similarity index 93% rename from src/main/java/edu/ie3/simona/api/data/ev/ExtEvData.java rename to src/main/java/edu/ie3/simona/api/data/ev/ExtEvDataConnection.java index 303ff1f..a1deb2f 100644 --- a/src/main/java/edu/ie3/simona/api/data/ev/ExtEvData.java +++ b/src/main/java/edu/ie3/simona/api/data/ev/ExtEvDataConnection.java @@ -6,28 +6,34 @@ package edu.ie3.simona.api.data.ev; -import edu.ie3.simona.api.data.ExtData; +import edu.ie3.simona.api.data.ExtInputDataConnection; import edu.ie3.simona.api.data.ev.model.EvModel; import edu.ie3.simona.api.data.ev.ontology.*; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; -import java.util.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; import java.util.concurrent.LinkedBlockingQueue; import org.apache.pekko.actor.ActorRef; -public class ExtEvData implements ExtData { +public class ExtEvDataConnection implements ExtInputDataConnection { /** Data message queue containing messages from SIMONA */ public final LinkedBlockingQueue receiveTriggerQueue = new LinkedBlockingQueue<>(); /** Actor reference to service that handles ev data within SIMONA */ - private final ActorRef dataService; + private ActorRef dataService; /** Actor reference to adapter that handles scheduler control flow in SIMONA */ - private final ActorRef extSimAdapter; + private ActorRef extSimAdapter; // important trigger queue must be the same as hold in actor // to make it safer one might consider asking the actor for ara reference on its trigger queue?! - public ExtEvData(ActorRef dataService, ActorRef extSimAdapter) { + public ExtEvDataConnection() {} + + @Override + public void setActorRefs(ActorRef dataService, ActorRef extSimAdapter) { this.dataService = dataService; this.extSimAdapter = extSimAdapter; } diff --git a/src/main/java/edu/ie3/simona/api/data/ev/ExtEvSimulation.java b/src/main/java/edu/ie3/simona/api/data/ev/ExtEvSimulation.java deleted file mode 100644 index b14fb1f..0000000 --- a/src/main/java/edu/ie3/simona/api/data/ev/ExtEvSimulation.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * © 2021. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation - */ - -package edu.ie3.simona.api.data.ev; - -import edu.ie3.simona.api.data.ExtDataSimulation; - -/** - * An external simulation that provides an ev mobility simulation should implement this interface - * and handle the ExtEvData that is handed over. - */ -public interface ExtEvSimulation extends ExtDataSimulation { - - /** - * Hand over an ExtEvData which enables communication regarding ev movements. - * - * @param evData the ev data - */ - void setExtEvData(ExtEvData evData); -} diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnection.java similarity index 66% rename from src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java rename to src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnection.java index 048353b..83b4c67 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryData.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnection.java @@ -7,18 +7,19 @@ package edu.ie3.simona.api.data.primarydata; import edu.ie3.datamodel.models.value.Value; -import edu.ie3.simona.api.data.ExtData; -import edu.ie3.simona.api.data.ExtInputDataContainer; +import edu.ie3.simona.api.data.ExtInputDataConnection; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import edu.ie3.simona.api.data.primarydata.ontology.PrimaryDataMessageFromExt; import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData; import java.util.*; +import java.util.stream.Collectors; import org.apache.pekko.actor.ActorRef; +import org.slf4j.Logger; /** Enables data connection of primary data between SIMONA and SimonaAPI */ -public class ExtPrimaryData implements ExtData { +public class ExtPrimaryDataConnection implements ExtInputDataConnection { - /** Actor reference to service that handles ev data within SIMONA */ + /** Actor reference to service that handles primary data within SIMONA */ private ActorRef dataService; /** Actor reference to adapter that handles scheduler control flow in SIMONA */ @@ -27,16 +28,37 @@ public class ExtPrimaryData implements ExtData { /** Assets that provide primary data to SIMONA */ private final Map extPrimaryDataMapping; - public ExtPrimaryData(Map extPrimaryDataMapping) { + public ExtPrimaryDataConnection() { + this(Map.of()); + } + + public ExtPrimaryDataConnection(Map extPrimaryDataMapping) { this.extPrimaryDataMapping = extPrimaryDataMapping; } - /** Sets the actor refs for data and control flow */ + @Override public void setActorRefs(ActorRef dataService, ActorRef extSimAdapter) { this.dataService = dataService; this.extSimAdapter = extSimAdapter; } + public void convertAndSend( + long tick, Map data, Optional maybeNextTick, Logger log) { + // filtering and converting the data + Map convertedMap = + data.entrySet().stream() + .filter(e -> extPrimaryDataMapping.containsKey(e.getKey())) + .collect( + Collectors.toMap(e -> extPrimaryDataMapping.get(e.getKey()), Map.Entry::getValue)); + + if (convertedMap.isEmpty()) { + log.warn("No primary data found! Sending no primary data to SIMONA for tick {}.", tick); + } else { + log.debug("Provided SIMONA with primary data."); + providePrimaryData(tick, convertedMap, maybeNextTick); + } + } + /** Returns a list of the uuids of the system participants that expect external primary data */ public List getPrimaryDataAssets() { return extPrimaryDataMapping.values().stream().toList(); @@ -60,22 +82,4 @@ public void sendExtMsg(PrimaryDataMessageFromExt msg) { // we need to schedule data receiver activation with scheduler extSimAdapter.tell(new ScheduleDataServiceMessage(dataService), ActorRef.noSender()); } - - /** Converts an input data package from an external simulation to a map of primary data */ - public Map convertExternalInputToPrimaryData( - ExtInputDataContainer extInputDataContainer) { - Map primaryDataForSimona = new HashMap<>(); - extInputDataContainer - .getSimonaInputMap() - .forEach( - (id, value) -> { - if (extPrimaryDataMapping.containsKey(id)) { - primaryDataForSimona.put(extPrimaryDataMapping.get(id), value); - } else { - throw new IllegalArgumentException( - "Input for asset with id " + id + " was provided, but it wasn't requested!"); - } - }); - return primaryDataForSimona; - } } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataConnection.java similarity index 97% rename from src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java rename to src/main/java/edu/ie3/simona/api/data/results/ExtResultDataConnection.java index 389d62b..de90fa4 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultData.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataConnection.java @@ -9,7 +9,7 @@ import edu.ie3.datamodel.models.result.ModelResultEntity; import edu.ie3.datamodel.models.result.NodeResult; import edu.ie3.datamodel.models.result.system.SystemParticipantResult; -import edu.ie3.simona.api.data.ExtOutputData; +import edu.ie3.simona.api.data.ExtOutputDataConnection; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import edu.ie3.simona.api.data.results.ontology.ProvideResultEntities; import edu.ie3.simona.api.data.results.ontology.RequestResultEntities; @@ -23,7 +23,7 @@ import org.apache.pekko.actor.ActorRef; /** Enables data connection of results between SIMONA and SimonaAPI */ -public class ExtResultData implements ExtOutputData { +public class ExtResultDataConnection implements ExtOutputDataConnection { /** Data message queue containing messages from SIMONA */ public final LinkedBlockingQueue receiveTriggerQueue = @@ -44,7 +44,7 @@ public class ExtResultData implements ExtOutputData { /** Map uuid to external id of system participants */ private final Map participantResultAssetMapping; - public ExtResultData( + public ExtResultDataConnection( Map participantResultAssetMapping, Map gridResultAssetMapping) { this.participantResultAssetMapping = participantResultAssetMapping; this.gridResultAssetMapping = gridResultAssetMapping; diff --git a/src/main/java/edu/ie3/simona/api/exceptions/ConversionException.java b/src/main/java/edu/ie3/simona/api/exceptions/ConversionException.java index c9fb547..50c75a7 100644 --- a/src/main/java/edu/ie3/simona/api/exceptions/ConversionException.java +++ b/src/main/java/edu/ie3/simona/api/exceptions/ConversionException.java @@ -6,7 +6,7 @@ package edu.ie3.simona.api.exceptions; -public class ConversionException extends Exception { +public class ConversionException extends RuntimeException { public ConversionException(final String message) { super(message); diff --git a/src/main/java/edu/ie3/simona/api/exceptions/NoExtSimulationException.java b/src/main/java/edu/ie3/simona/api/exceptions/NoExtSimulationException.java new file mode 100644 index 0000000..f4a242b --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/exceptions/NoExtSimulationException.java @@ -0,0 +1,20 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + +package edu.ie3.simona.api.exceptions; + +import edu.ie3.simona.api.ExtLinkInterface; + +public class NoExtSimulationException extends RuntimeException { + + public NoExtSimulationException(Class linkClass) { + this("No external simulation was set up in ExtLinkInterface: ." + linkClass.getSimpleName()); + } + + public NoExtSimulationException(final String message) { + super(message); + } +} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java index 9d926d5..a3080ce 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java @@ -7,15 +7,20 @@ package edu.ie3.simona.api.simulation; import edu.ie3.datamodel.models.result.ModelResultEntity; +import edu.ie3.datamodel.models.value.Value; import edu.ie3.simona.api.data.DataQueueExtSimulationExtSimulator; import edu.ie3.simona.api.data.ExtInputDataContainer; -import edu.ie3.simona.api.data.em.ExtEmData; -import edu.ie3.simona.api.data.primarydata.ExtPrimaryData; +import edu.ie3.simona.api.data.em.ExtEmDataConnection; +import edu.ie3.simona.api.data.primarydata.ExtPrimaryDataConnection; import edu.ie3.simona.api.data.results.ExtResultContainer; -import edu.ie3.simona.api.data.results.ExtResultData; +import edu.ie3.simona.api.data.results.ExtResultDataConnection; +import edu.ie3.simona.api.simulation.mapping.DataType; +import edu.ie3.simona.api.simulation.mapping.ExtEntityMapping; import java.util.Map; import java.util.Optional; +import java.util.UUID; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Abstract class for an external co-simulation with the structure: external api - ext-co-simulation @@ -24,6 +29,8 @@ */ public abstract class ExtCoSimulation extends ExtSimulation { + protected Logger log; + /** Queue for the data connection from the external co-simulation to SimonaAPI */ protected final DataQueueExtSimulationExtSimulator dataQueueExtCoSimulatorToSimonaApi; @@ -32,52 +39,138 @@ public abstract class ExtCoSimulation extends ExtSimulation { protected final DataQueueExtSimulationExtSimulator dataQueueSimonaApiToExtCoSimulator; + /** Time resolution for the data exchange */ + protected final long deltaT = 900L; + /** Name of the external co-simulation */ protected final String extSimulatorName; protected ExtCoSimulation(String simulationName, String extSimulatorName) { super(simulationName); this.extSimulatorName = extSimulatorName; + log = LoggerFactory.getLogger(simulationName); + this.dataQueueExtCoSimulatorToSimonaApi = new DataQueueExtSimulationExtSimulator<>(); this.dataQueueSimonaApiToExtCoSimulator = new DataQueueExtSimulationExtSimulator<>(); } - /** Function to send primary data to SIMONA using ExtPrimaryData */ - protected void sendPrimaryDataToSimona(ExtPrimaryData extPrimaryData, long tick, Logger log) - throws InterruptedException { + /** + * Builds an {@link ExtPrimaryDataConnection}. + * + * @param mapping between the external simulation and SIMONA. + * @return an ext primary data connection + */ + protected ExtPrimaryDataConnection buildPrimaryConnection(ExtEntityMapping mapping) { + Map primaryMapping = mapping.getExtId2UuidMapping(DataType.EXT_PRIMARY_INPUT); + ExtPrimaryDataConnection extPrimaryDataConnection = + new ExtPrimaryDataConnection(primaryMapping); + + if (primaryMapping.isEmpty()) { + log.warn("Primary with 0 entities created."); + } else { + log.info("Primary connection with {} entities created.", primaryMapping.size()); + } + + return extPrimaryDataConnection; + } + + /** + * Builds an {@link ExtEmDataConnection}. + * + * @param mapping between the external simulation and SIMONA. + * @return an ext em data connection + */ + protected ExtEmDataConnection buildEmConnection(ExtEntityMapping mapping) { + Map emMapping = mapping.getExtId2UuidMapping(DataType.EXT_EM_INPUT); + ExtEmDataConnection extEmDataConnection = new ExtEmDataConnection(emMapping); + + if (emMapping.isEmpty()) { + log.warn("Em connection with 0 entities created."); + } else { + log.info("Em connection with {} entities created.", emMapping.size()); + } + + return extEmDataConnection; + } + + /** + * Builds an {@link ExtResultDataConnection}. + * + * @param mapping between the external simulation and SIMONA. + * @return an ext result data connection + */ + protected ExtResultDataConnection buildResultConnection(ExtEntityMapping mapping) { + Map resultParticipantMapping = + mapping.getExtUuid2IdMapping(DataType.EXT_PARTICIPANT_RESULT); + Map resultGridMapping = mapping.getExtUuid2IdMapping(DataType.EXT_GRID_RESULT); + ExtResultDataConnection extResultDataConnection = + new ExtResultDataConnection(resultParticipantMapping, resultGridMapping); + + if (resultParticipantMapping.isEmpty() && resultGridMapping.isEmpty()) { + log.warn("Result connection with 0 participants and 0 grid assets created."); + } else { + log.info( + "Result connection with {} participants and {} grid assets created.", + resultParticipantMapping.size(), + resultGridMapping.size()); + } + + return extResultDataConnection; + } + + /** + * Function to send primary data to SIMONA using ExtPrimaryData + * + * @param extPrimaryDataConnection the connection to SIMONA + * @param tick for which data is sent + * @param dataMap map: id to value + * @param maybeNextTick option for the next tick data is sent + */ + protected void sendPrimaryDataToSimona( + ExtPrimaryDataConnection extPrimaryDataConnection, + long tick, + Map dataMap, + Optional maybeNextTick) { log.debug("Wait for Primary Data from {}", extSimulatorName); - ExtInputDataContainer inputData = dataQueueExtCoSimulatorToSimonaApi.takeData(); log.debug("Received Primary Data from {}", extSimulatorName); - extPrimaryData.providePrimaryData( - tick, - extPrimaryData.convertExternalInputToPrimaryData(inputData), - inputData.getMaybeNextTick()); + extPrimaryDataConnection.convertAndSend(tick, dataMap, maybeNextTick, log); log.debug("Provided Primary Data to SIMONA!"); } /** * Function to send em data to SIMONA using ExtPrimaryData nextTick is necessary, because the em * agents have an own scheduler that should know, when the next set point arrives. + * + * @param extEmDataConnection the connection to SIMONA + * @param tick for which data is sent + * @param dataMap map: id to value + * @param maybeNextTick option for the next tick data is sent */ - protected void sendEmDataToSimona(ExtEmData extEmData, long tick, long nextTick, Logger log) - throws InterruptedException { - log.debug("Wait for EmData from {}", extSimulatorName); - ExtInputDataContainer inputData = dataQueueExtCoSimulatorToSimonaApi.takeData(); + protected void sendEmDataToSimona( + ExtEmDataConnection extEmDataConnection, + long tick, + Map dataMap, + Optional maybeNextTick) { log.debug("Received EmData from {}", extSimulatorName); - extEmData.provideEmData( - tick, extEmData.convertExternalInputToEmSetPoints(inputData), Optional.of(nextTick)); + extEmDataConnection.convertAndSend(tick, dataMap, maybeNextTick, log); log.debug("Provided EmData to SIMONA!"); } - /** Function to get result data from SIMONA using ExtResultData */ - protected void sendResultsToExtCoSimulator( - ExtResultData extResultData, long tick, Optional nextTick, Logger log) + /** + * Function to get result data from SIMONA using the available {@link ExtResultDataConnection} + * + * @param connection the connection to SIMONA + * @param tick for which data is received + * @param maybeNextTick option for the next tick data is received + */ + protected void sendDataToExt( + ExtResultDataConnection connection, long tick, Optional maybeNextTick) throws InterruptedException { log.debug("Request results from SIMONA!"); - Map resultsToBeSend = extResultData.requestResults(tick); + Map resultsToBeSend = connection.requestResults(tick); log.debug("Received results from SIMONA!"); dataQueueSimonaApiToExtCoSimulator.queueData( - new ExtResultContainer(tick, resultsToBeSend, nextTick)); + new ExtResultContainer(tick, resultsToBeSend, maybeNextTick)); log.debug("Sent results to {}", extSimulatorName); } } diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java index 2be6855..0e52a81 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtSimulation.java @@ -6,13 +6,10 @@ package edu.ie3.simona.api.simulation; -import edu.ie3.simona.api.data.ExtData; -import edu.ie3.simona.api.data.ev.ExtEvData; -import edu.ie3.simona.api.data.ev.ExtEvSimulation; +import edu.ie3.simona.api.data.ExtDataConnection; import edu.ie3.simona.api.simulation.ontology.*; -import java.util.ArrayList; -import java.util.List; import java.util.Optional; +import java.util.Set; /** * Every external simulation must extend this class in order to get triggered by the main @@ -104,22 +101,14 @@ protected void terminate(Boolean simulationSuccessful) { // to be overwritten in subclass } - public final List> getRequiredAdapters() { - ArrayList> classes = new ArrayList<>(); - - if (this instanceof ExtEvSimulation) classes.add(ExtEvData.class); - - return classes; - } - - public final void setup(ExtSimAdapterData data, List adapters) { + /** + * Method to set the external simulation adapter data. This method should be called during {@link + * edu.ie3.simona.api.ExtLinkInterface#setup(ExtSimAdapterData)}. + * + * @param data to set up + */ + public final void setAdapterData(ExtSimAdapterData data) { this.data = data; - - // todo sanity check if all required data is available - for (ExtData adapter : adapters) { - if (adapter instanceof ExtEvData && this instanceof ExtEvSimulation) - ((ExtEvSimulation) this).setExtEvData((ExtEvData) adapter); - } } /** @@ -131,5 +120,11 @@ protected String[] getMainArgs() { return data.getMainArgs(); } - public abstract List getDataConnections(); + /** Returns the name of this external simulation. */ + public final String getSimulationName() { + return simulationName; + } + + /** Returns all {@link ExtDataConnection} of this simulation. */ + public abstract Set getDataConnections(); } diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/DataType.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/DataType.java new file mode 100644 index 0000000..67bfaa1 --- /dev/null +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/DataType.java @@ -0,0 +1,32 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + +package edu.ie3.simona.api.simulation.mapping; + +import edu.ie3.datamodel.exceptions.ParsingException; + +public enum DataType { + EXT_PRIMARY_INPUT("primary_input"), + EXT_EM_INPUT("em_input"), + EXT_GRID_RESULT("grid_result"), + EXT_PARTICIPANT_RESULT("participant_result"); + + public final String type; + + DataType(String type) { + this.type = type; + } + + public static DataType parse(String type) throws ParsingException { + return switch (type) { + case "primary_input" -> EXT_PRIMARY_INPUT; + case "em_input" -> EXT_EM_INPUT; + case "grid_result" -> EXT_GRID_RESULT; + case "participant_result" -> EXT_PARTICIPANT_RESULT; + default -> throw new ParsingException("Data type " + type + " is not supported!"); + }; + } +} diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityEntry.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityEntry.java index 2346023..1444c3e 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityEntry.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityEntry.java @@ -16,31 +16,28 @@ * @param uuid SIMONA uuid * @param id external id * @param columnScheme data types the external asset expects - * @param resultType data types the external asset expects + * @param dataType data types the external asset expects */ public record ExtEntityEntry( UUID uuid, String id, ColumnScheme columnScheme, // FIXME: placeholder -> ColumnScheme should handle more data types - String resultType) + DataType dataType) implements InputEntity { - public static final String EXT_INPUT = "input"; - public static final String EXT_RESULT_PARTICIPANT = "result_participant"; - public static final String EXT_RESULT_GRID = "result_grid"; public String toString() { return "ExtEntityEntry={" + "UUID=" - + uuid() + + uuid + ", " - + "ExtId=" - + id() + + "extId=" + + id + ", " - + "ColumnScheme=" - + columnScheme() + + "columnScheme=" + + columnScheme + ", " - + "ResultType=" - + resultType() + + "dataType=" + + dataType + "}"; } } diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java index 343c577..9a82025 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityFactory.java @@ -6,6 +6,8 @@ package edu.ie3.simona.api.simulation.mapping; +import edu.ie3.datamodel.exceptions.FactoryException; +import edu.ie3.datamodel.exceptions.ParsingException; import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.io.factory.EntityFactory; import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme; @@ -22,7 +24,7 @@ public class ExtEntityFactory extends EntityFactory public static final String DATA_TYPE = "dataType"; public ExtEntityFactory() { - super(new Class[] {ExtEntityEntry.class}); + super(ExtEntityEntry.class); } @Override @@ -36,7 +38,13 @@ protected ExtEntityEntry buildModel(EntityData data) { UUID simonaUuid = data.getUUID(SIMONA_UUID); String extId = data.getField(EXT_ID); Optional columnScheme = ColumnScheme.parse(data.getField(COLUMN_SCHEME)); - String inputType = data.getField(DATA_TYPE); + + DataType inputType; + try { + inputType = DataType.parse(data.getField(DATA_TYPE)); + } catch (ParsingException e) { + throw new FactoryException(e); + } return new ExtEntityEntry( simonaUuid, diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMapping.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMapping.java index a0826fd..8fd033e 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMapping.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMapping.java @@ -7,14 +7,16 @@ package edu.ie3.simona.api.simulation.mapping; import java.util.*; +import java.util.stream.Collectors; /** Contains the mapping between SIMONA uuid, the external id and the data type the assets hold */ public class ExtEntityMapping { - private final List extEntities; + private final Map> extEntities; public ExtEntityMapping(List extEntityEntryList) { - this.extEntities = extEntityEntryList; + this.extEntities = + extEntityEntryList.stream().collect(Collectors.groupingBy(ExtEntityEntry::dataType)); } /** @@ -23,15 +25,9 @@ public ExtEntityMapping(List extEntityEntryList) { * @param dataType data type the external asset expects * @return Mapping external id to SIMONA uuid */ - public Map getExtId2UuidMapping(String dataType) { - Map extId2UuidMapping = new HashMap<>(); - extEntities.forEach( - ent -> { - if (Objects.equals(ent.resultType(), dataType)) { - extId2UuidMapping.put(ent.id(), ent.uuid()); - } - }); - return extId2UuidMapping; + public Map getExtId2UuidMapping(DataType dataType) { + return extEntities.getOrDefault(dataType, Collections.emptyList()).stream() + .collect(Collectors.toMap(ExtEntityEntry::id, ExtEntityEntry::uuid)); } /** @@ -40,14 +36,8 @@ public Map getExtId2UuidMapping(String dataType) { * @param dataType data type the external asset expects * @return Mapping SIMONA uuid to external id */ - public Map getExtUuid2IdMapping(String dataType) { - Map extUuid2IdMapping = new HashMap<>(); - extEntities.forEach( - ent -> { - if (Objects.equals(ent.resultType(), dataType)) { - extUuid2IdMapping.put(ent.uuid(), ent.id()); - } - }); - return extUuid2IdMapping; + public Map getExtUuid2IdMapping(DataType dataType) { + return extEntities.getOrDefault(dataType, Collections.emptyList()).stream() + .collect(Collectors.toMap(ExtEntityEntry::uuid, ExtEntityEntry::id)); } } diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java deleted file mode 100644 index e1bf920..0000000 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingCsvSource.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * © 2024. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation - */ - -package edu.ie3.simona.api.simulation.mapping; - -import edu.ie3.datamodel.exceptions.SourceException; -import edu.ie3.datamodel.io.factory.EntityData; -import edu.ie3.datamodel.io.naming.FileNamingStrategy; -import edu.ie3.datamodel.io.source.csv.CsvDataSource; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.*; -import java.util.stream.Stream; - -/** Source that is capable of providing information around external mapping from csv files. */ -public class ExtEntityMappingCsvSource extends ExtEntityMappingSource { - - private final ExtEntityMapping extEntities; - - private final CsvDataSource dataSource; - - private final Path mappingPath; - - public ExtEntityMappingCsvSource( - String csvSep, Path folderPath, FileNamingStrategy fileNamingStrategy) { - super(); - this.dataSource = new CsvDataSource(csvSep, folderPath, fileNamingStrategy); - this.mappingPath = folderPath; - this.extEntities = buildExtEntityMapping(); - } - - public ExtEntityMapping getMapping() { - return extEntities; - } - - /** - * Method to retrieve the fields found in the source. - * - * @return an option for the found fields - */ - public Optional> getSourceFields() throws SourceException { - return dataSource.getSourceFields(ExtEntityEntry.class); - } - - /** - * Builds the mapping from CSV - * - * @return Mapping external id and SIMONA uuid - */ - protected final ExtEntityMapping buildExtEntityMapping() { - return new ExtEntityMapping(buildStream().map(this::createExtEntityEntry).toList()); - } - - private Stream> - buildStream() { // TODO: Interim version -> maybe it would be easier to use PSDM methods for - // reading the CSV - Path pathToCsv = mappingPath; - - try (Stream lines = Files.lines(pathToCsv)) { - // Read the header line - List headers = - lines - .findFirst() - .map(line -> Arrays.asList(line.split(","))) - .orElseThrow(() -> new RuntimeException("No header line found")); - - // Stream the rest of the lines - Stream> mapStream = - Files.lines(pathToCsv) - .skip(1) // Skip the header line - .map( - line -> { - String[] values = line.split(","); - Map map = new HashMap<>(); - for (int i = 0; i < headers.size(); i++) { - map.put(headers.get(i), values[i]); - } - return map; - }); - - return mapStream; - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - private ExtEntityEntry createExtEntityEntry(Map fieldToValues) { - return factory.get(new EntityData(fieldToValues, ExtEntityEntry.class)).getOrThrow(); - } - - public static ExtEntityMapping createExtEntityMapping(Path mappingPath) { - ExtEntityMappingCsvSource mappingSource = - new ExtEntityMappingCsvSource(",", mappingPath, new FileNamingStrategy()); - return mappingSource.getMapping(); - } -} diff --git a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSource.java b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSource.java index 8a56471..1d24d7f 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSource.java +++ b/src/main/java/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSource.java @@ -6,12 +6,83 @@ package edu.ie3.simona.api.simulation.mapping; -/** Interface definition of a source, that is able to provide external mapping. */ -public abstract class ExtEntityMappingSource { +import edu.ie3.datamodel.exceptions.SourceException; +import edu.ie3.datamodel.io.factory.EntityData; +import edu.ie3.datamodel.io.naming.EntityPersistenceNamingStrategy; +import edu.ie3.datamodel.io.naming.FileNamingStrategy; +import edu.ie3.datamodel.io.source.DataSource; +import edu.ie3.datamodel.io.source.csv.CsvDataSource; +import edu.ie3.datamodel.models.Entity; +import java.nio.file.Path; +import java.util.Map; +import java.util.Optional; +/** Source for external entity mapping. */ +public class ExtEntityMappingSource { + + protected final DataSource dataSource; protected final ExtEntityFactory factory; - protected ExtEntityMappingSource() { + protected ExtEntityMappingSource(DataSource dataSource) { + this.dataSource = dataSource; this.factory = new ExtEntityFactory(); } + + /** + * Creates an {@link ExtEntityMapping} from a given file. + * + * @param filepath path to the file including its name + * @return a new mapping + * @throws SourceException if an error occurred + */ + public static ExtEntityMapping fromFile(Path filepath) throws SourceException { + String filename = filepath.getFileName().toString(); + Path directoryPath; + + if (!filename.contains(".csv")) { + directoryPath = filepath; + } else { + directoryPath = filepath.getParent(); + } + + ExtEntityNaming naming = new ExtEntityNaming(filename); + CsvDataSource source = new CsvDataSource(",", directoryPath, new FileNamingStrategy(naming)); + + return new ExtEntityMappingSource(source).getMapping(); + } + + /** Return the mapping from a given {@link DataSource}. */ + public ExtEntityMapping getMapping() throws SourceException { + return new ExtEntityMapping( + dataSource.getSourceData(ExtEntityEntry.class).map(this::createExtEntityEntry).toList()); + } + + /** + * Creates an ext entity entry from a given map. + * + * @param fieldToValues map: field name to value + * @return a new {@link ExtEntityEntry} + */ + private ExtEntityEntry createExtEntityEntry(Map fieldToValues) { + return factory.get(new EntityData(fieldToValues, ExtEntityEntry.class)).getOrThrow(); + } + + /** Csv naming for ext entity mapping. */ + private static class ExtEntityNaming extends EntityPersistenceNamingStrategy { + + private final String filename; + + private ExtEntityNaming(String filename) { + this.filename = filename.replace(".csv", ""); + } + + @Override + public Optional getEntityName(Class cls) { + if (ExtEntityEntry.class.isAssignableFrom(cls)) { + return Optional.of(filename); + } else { + return super.getEntityName(cls); + } + } + } } diff --git a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataConnectionTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataConnectionTest.groovy new file mode 100644 index 0000000..d8f798f --- /dev/null +++ b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataConnectionTest.groovy @@ -0,0 +1,98 @@ +package edu.ie3.simona.api.data.em + +import edu.ie3.datamodel.models.value.PValue +import edu.ie3.datamodel.models.value.Value +import edu.ie3.simona.api.data.em.ontology.ProvideEmSetPointData +import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage +import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData +import edu.ie3.simona.api.test.common.DataServiceTestData +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.testkit.TestProbe +import org.apache.pekko.testkit.javadsl.TestKit +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import spock.lang.Shared +import spock.lang.Specification + +class ExtEmDataConnectionTest extends Specification implements DataServiceTestData { + + @Shared + ActorSystem actorSystem + + @Shared + Map extEmDataMapping = Map.of( + "Em", + inputUuid + ) + + def setupSpec() { + actorSystem = ActorSystem.create() + } + + def cleanupSpec() { + TestKit.shutdownActorSystem(actorSystem) + actorSystem = null + } + + def "ExtEmDataConnection should provide em data correctly"() { + given: + def dataService = new TestProbe(actorSystem) + def extSimAdapter = new TestProbe(actorSystem) + def extEmDataConnection = new ExtEmDataConnection(extEmDataMapping) + extEmDataConnection.setActorRefs( + dataService.ref(), + extSimAdapter.ref() + ) + + def emData = [:] as HashMap + def uuid = UUID.randomUUID() + emData.put(uuid.toString(), pValue) + + def convertedEmData = Map.of(uuid, pValue as PValue) + + when: + extEmDataConnection.provideEmData(0L, convertedEmData, Optional.of(900L)) + + then: + dataService.expectMsg(new ProvideEmSetPointData(0, convertedEmData, Optional.of(900L))) + extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) + } + + def "ExtEmDataConnection should convert input data correctly"() { + given: + def dataService = new TestProbe(actorSystem) + def extSimAdapter = new TestProbe(actorSystem) + def extEmDataConnection = new ExtEmDataConnection(extEmDataMapping) + extEmDataConnection.setActorRefs( + dataService.ref(), + extSimAdapter.ref() + ) + def inputDataMap = Map.of("Em", pValue) + + when: + extEmDataConnection.convertAndSend(0L, inputDataMap, Optional.of(900L), log) + + then: + dataService.expectMsg(new ProvideEmSetPointData(0L, Map.of(inputUuid, pValue), Optional.of(900L))) + extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) + } + + def "ExtEmDataConnection should send no message, if input data for a not requested asset was provided"() { + given: + def dataService = new TestProbe(actorSystem) + def extSimAdapter = new TestProbe(actorSystem) + def extEmDataConnection = new ExtEmDataConnection(extEmDataMapping) + extEmDataConnection.setActorRefs( + dataService.ref(), + extSimAdapter.ref() + ) + def inputDataMap = Map.of("Load", pValue) + + when: + extEmDataConnection.convertAndSend(0L, inputDataMap, Optional.of(900L), log) + + then: + dataService.expectNoMessage() + } + +} diff --git a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy deleted file mode 100644 index 8152e3c..0000000 --- a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataTest.groovy +++ /dev/null @@ -1,86 +0,0 @@ -package edu.ie3.simona.api.data.em - - -import edu.ie3.datamodel.models.value.PValue -import edu.ie3.datamodel.models.value.Value -import edu.ie3.simona.api.data.ExtInputDataContainer -import edu.ie3.simona.api.data.em.ontology.ProvideEmSetPointData -import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage -import edu.ie3.simona.api.test.common.DataServiceTestData -import org.apache.pekko.actor.ActorSystem -import org.apache.pekko.testkit.TestProbe -import org.apache.pekko.testkit.javadsl.TestKit -import spock.lang.Shared -import spock.lang.Specification - -class ExtEmDataTest extends Specification implements DataServiceTestData { - - @Shared - ActorSystem actorSystem - - @Shared - Map extEmDataMapping = Map.of( - "Em", - inputUuid - ) - - def setupSpec() { - actorSystem = ActorSystem.create() - } - - def cleanupSpec() { - TestKit.shutdownActorSystem(actorSystem) - actorSystem = null - } - - def "ExtEmData should provide em data correctly"() { - given: - def dataService = new TestProbe(actorSystem) - def extSimAdapter = new TestProbe(actorSystem) - def extEmData = new ExtEmData(extEmDataMapping) - extEmData.setActorRefs( - dataService.ref(), - extSimAdapter.ref() - ) - - def emData = [:] as HashMap - def uuid = UUID.randomUUID() - emData.put(uuid.toString(), pValue) - - def convertedEmData = Map.of(uuid, pValue as PValue) - - when: - extEmData.provideEmData(0L, convertedEmData, Optional.of(900L)) - - then: - dataService.expectMsg(new ProvideEmSetPointData(0, convertedEmData, Optional.of(900L))) - extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) - } - - def "ExtEmData should convert ExtInputDataPackage to a map"() { - given: - def extEmData = new ExtEmData(extEmDataMapping) - def inputDataMap = Map.of("Em", pValue) - def inputDataContainer = new ExtInputDataContainer(0L, inputDataMap, 900L) - - when: - def emDataMap = extEmData.convertExternalInputToEmSetPoints(inputDataContainer) - - then: - emDataMap.get(inputUuid) == pValue - } - - def "ExtEmData should throw an exception, if input data for a not requested asset was provided"() { - given: - def extEmData = new ExtEmData(extEmDataMapping) - def inputDataMap = Map.of("Load", pValue) - def inputDataContainer = new ExtInputDataContainer(0L, inputDataMap, 900L) - - when: - extEmData.convertExternalInputToEmSetPoints(inputDataContainer) - - then: - thrown IllegalArgumentException - } - -} diff --git a/src/test/groovy/edu/ie3/simona/api/data/ev/ExtEvDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/ev/ExtEvDataConnectionTest.groovy similarity index 66% rename from src/test/groovy/edu/ie3/simona/api/data/ev/ExtEvDataTest.groovy rename to src/test/groovy/edu/ie3/simona/api/data/ev/ExtEvDataConnectionTest.groovy index 63441e4..8487efc 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/ev/ExtEvDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/ev/ExtEvDataConnectionTest.groovy @@ -15,7 +15,7 @@ import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage import spock.lang.Shared import spock.lang.Specification -class ExtEvDataTest extends Specification { +class ExtEvDataConnectionTest extends Specification { @Shared ActorSystem actorSystem @@ -29,18 +29,19 @@ class ExtEvDataTest extends Specification { actorSystem = null } - def "ExtEvData should request and receive free evcs lots correctly"() { + def "ExtEvDataConnection should request and receive free evcs lots correctly"() { given: def dataService = new TestProbe(actorSystem) def extSimAdapter = new TestProbe(actorSystem) - def extEvData = new ExtEvData(dataService.ref(), extSimAdapter.ref()) + def extEvDataConnection = new ExtEvDataConnection() + extEvDataConnection.setActorRefs(dataService.ref(), extSimAdapter.ref()) def sentMsg = new ProvideEvcsFreeLots() when: // we need to queue the msg beforehand because the receive method is blocking - extEvData.queueExtResponseMsg(sentMsg) - def actualReceivedEvcs = extEvData.requestAvailablePublicEvcs() + extEvDataConnection.queueExtResponseMsg(sentMsg) + def actualReceivedEvcs = extEvDataConnection.requestAvailablePublicEvcs() then: dataService.expectMsg(new RequestEvcsFreeLots()) @@ -48,18 +49,19 @@ class ExtEvDataTest extends Specification { actualReceivedEvcs == sentMsg.evcs() } - def "ExtEvData should request and receive current charging prices correctly"() { + def "ExtEvDataConnection should request and receive current charging prices correctly"() { given: def dataService = new TestProbe(actorSystem) def extSimAdapter = new TestProbe(actorSystem) - def extEvData = new ExtEvData(dataService.ref(), extSimAdapter.ref()) + def extEvDataConnection = new ExtEvDataConnection() + extEvDataConnection.setActorRefs(dataService.ref(), extSimAdapter.ref()) def sentMsg = new ProvideCurrentPrices() when: // we need to queue the msg beforehand because the receive method is blocking - extEvData.queueExtResponseMsg(sentMsg) - def actualReceivedPrices = extEvData.requestCurrentPrices() + extEvDataConnection.queueExtResponseMsg(sentMsg) + def actualReceivedPrices = extEvDataConnection.requestCurrentPrices() then: dataService.expectMsg(new RequestCurrentPrices()) @@ -67,11 +69,12 @@ class ExtEvDataTest extends Specification { actualReceivedPrices == sentMsg.prices() } - def "ExtEvData should request and receive departing EVs correctly"() { + def "ExtEvDataConnection should request and receive departing EVs correctly"() { given: def dataService = new TestProbe(actorSystem) def extSimAdapter = new TestProbe(actorSystem) - def extEvData = new ExtEvData(dataService.ref(), extSimAdapter.ref()) + def extEvDataConnection = new ExtEvDataConnection() + extEvDataConnection.setActorRefs(dataService.ref(), extSimAdapter.ref()) def requestedDepartingEvs = new HashMap>() requestedDepartingEvs.put(UUID.randomUUID(), new ArrayList()) @@ -79,8 +82,8 @@ class ExtEvDataTest extends Specification { when: // we need to queue the msg beforehand because the receive method is blocking - extEvData.queueExtResponseMsg(sentMsg) - def actualReceivedEvs = extEvData.requestDepartingEvs(requestedDepartingEvs) + extEvDataConnection.queueExtResponseMsg(sentMsg) + def actualReceivedEvs = extEvDataConnection.requestDepartingEvs(requestedDepartingEvs) then: dataService.expectMsg(new RequestDepartingEvs(requestedDepartingEvs)) @@ -88,35 +91,37 @@ class ExtEvDataTest extends Specification { actualReceivedEvs == sentMsg.departedEvs() } - def "ExtEvData should provide arriving EVs correctly"() { + def "ExtEvDataConnection should provide arriving EVs correctly"() { given: def dataService = new TestProbe(actorSystem) def extSimAdapter = new TestProbe(actorSystem) - def extEvData = new ExtEvData(dataService.ref(), extSimAdapter.ref()) + def extEvDataConnection = new ExtEvDataConnection() + extEvDataConnection.setActorRefs(dataService.ref(), extSimAdapter.ref()) def arrivingEvs = new HashMap>() arrivingEvs.put(UUID.randomUUID(), new ArrayList()) when: - extEvData.provideArrivingEvs(arrivingEvs, Optional.of(60L)) + extEvDataConnection.provideArrivingEvs(arrivingEvs, Optional.of(60L)) then: dataService.expectMsg(new ProvideArrivingEvs(arrivingEvs, Optional.of(60L))) extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) } - def "ExtEvData should fail if wrong response is sent"() { + def "ExtEvDataConnection should fail if wrong response is sent"() { given: def dataService = new TestProbe(actorSystem) def extSimAdapter = new TestProbe(actorSystem) - def extEvData = new ExtEvData(dataService.ref(), extSimAdapter.ref()) + def extEvDataConnection = new ExtEvDataConnection() + extEvDataConnection.setActorRefs(dataService.ref(), extSimAdapter.ref()) def unexpectedMsg = new ProvideCurrentPrices() when: // we need to queue the msg beforehand because the receive method is blocking - extEvData.queueExtResponseMsg(unexpectedMsg) - extEvData.requestAvailablePublicEvcs() + extEvDataConnection.queueExtResponseMsg(unexpectedMsg) + extEvDataConnection.requestAvailablePublicEvcs() then: dataService.expectMsg(new RequestEvcsFreeLots()) diff --git a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnectionTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnectionTest.groovy new file mode 100644 index 0000000..5aba77d --- /dev/null +++ b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnectionTest.groovy @@ -0,0 +1,93 @@ +package edu.ie3.simona.api.data.primarydata + +import edu.ie3.datamodel.models.value.Value +import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage +import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData +import edu.ie3.simona.api.test.common.DataServiceTestData +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.testkit.TestProbe +import org.apache.pekko.testkit.javadsl.TestKit +import spock.lang.Shared +import spock.lang.Specification + +class ExtPrimaryDataConnectionTest extends Specification implements DataServiceTestData { + + @Shared + ActorSystem actorSystem + + @Shared + Map extPrimaryDataMapping = Map.of( + "Pv", + inputUuid + ) + + def setupSpec() { + actorSystem = ActorSystem.create() + } + + def cleanupSpec() { + TestKit.shutdownActorSystem(actorSystem) + actorSystem = null + } + + def "ExtPrimaryDataConnection should provide primary data correctly"() { + given: + def dataService = new TestProbe(actorSystem) + def extSimAdapter = new TestProbe(actorSystem) + def extPrimaryDataConnection = new ExtPrimaryDataConnection(extPrimaryDataMapping) + extPrimaryDataConnection.setActorRefs( + dataService.ref(), + extSimAdapter.ref() + ) + + def primaryData = [:] as HashMap + def uuid = UUID.randomUUID() + primaryData.put(uuid.toString(), pValue) + + def convertedPrimaryData = Map.of(uuid, pValue as Value) + + when: + extPrimaryDataConnection.providePrimaryData(0L, convertedPrimaryData, Optional.of(900L)) + + then: + dataService.expectMsg(new ProvidePrimaryData(0L, convertedPrimaryData, Optional.of(900L))) + extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) + } + + def "ExtPrimaryDataConnection should convert input data correctly"() { + given: + def dataService = new TestProbe(actorSystem) + def extSimAdapter = new TestProbe(actorSystem) + def extPrimaryDataConnection = new ExtPrimaryDataConnection(extPrimaryDataMapping) + extPrimaryDataConnection.setActorRefs( + dataService.ref(), + extSimAdapter.ref() + ) + def inputDataMap = Map.of("Pv", pValue) + + when: + extPrimaryDataConnection.convertAndSend(0L, inputDataMap, Optional.of(900L), log) + + then: + dataService.expectMsg(new ProvidePrimaryData(0L, Map.of(inputUuid, pValue), Optional.of(900L))) + extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) + } + + def "ExtPrimaryDataConnection should send no message, if input data for a not requested asset was provided"() { + given: + def dataService = new TestProbe(actorSystem) + def extSimAdapter = new TestProbe(actorSystem) + def extPrimaryDataConnection = new ExtPrimaryDataConnection(extPrimaryDataMapping) + extPrimaryDataConnection.setActorRefs( + dataService.ref(), + extSimAdapter.ref() + ) + def inputDataMap = Map.of("Load", pValue) + + when: + extPrimaryDataConnection.convertAndSend(0L, inputDataMap, Optional.empty(), log) + + then: + dataService.expectNoMessage() + } +} diff --git a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy deleted file mode 100644 index 099087f..0000000 --- a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataTest.groovy +++ /dev/null @@ -1,83 +0,0 @@ -package edu.ie3.simona.api.data.primarydata - -import edu.ie3.datamodel.models.value.Value -import edu.ie3.simona.api.data.ExtInputDataContainer -import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage -import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData -import edu.ie3.simona.api.test.common.DataServiceTestData -import org.apache.pekko.actor.ActorSystem -import org.apache.pekko.testkit.TestProbe -import org.apache.pekko.testkit.javadsl.TestKit -import spock.lang.Shared -import spock.lang.Specification - -class ExtPrimaryDataTest extends Specification implements DataServiceTestData { - - @Shared - ActorSystem actorSystem - - @Shared - Map extPrimaryDataMapping = Map.of( - "Pv", - inputUuid - ) - - def setupSpec() { - actorSystem = ActorSystem.create() - } - - def cleanupSpec() { - TestKit.shutdownActorSystem(actorSystem) - actorSystem = null - } - - def "ExtPrimaryData should provide primary data correctly"() { - given: - def dataService = new TestProbe(actorSystem) - def extSimAdapter = new TestProbe(actorSystem) - def extPrimaryData = new ExtPrimaryData(extPrimaryDataMapping) - extPrimaryData.setActorRefs( - dataService.ref(), - extSimAdapter.ref() - ) - - def primaryData = [:] as HashMap - def uuid = UUID.randomUUID() - primaryData.put(uuid.toString(), pValue) - - def convertedPrimaryData = Map.of(uuid, pValue as Value) - - when: - extPrimaryData.providePrimaryData(0L, convertedPrimaryData, Optional.of(900L)) - - then: - dataService.expectMsg(new ProvidePrimaryData(0L, convertedPrimaryData, Optional.of(900L))) - extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) - } - - def "ExtPrimaryData should convert ExtInputDataPackage to a map"() { - given: - def extPrimaryData = new ExtPrimaryData(extPrimaryDataMapping) - def inputDataMap = Map.of("Pv", pValue) - def inputDataContainer = new ExtInputDataContainer(0L, inputDataMap, 900L) - - when: - def primaryDataMap = extPrimaryData.convertExternalInputToPrimaryData(inputDataContainer) - - then: - primaryDataMap.get(inputUuid) == pValue - } - - def "ExtPrimaryData should throw an exception, if input data for a not requested asset was provided"() { - given: - def extPrimaryData = new ExtPrimaryData(extPrimaryDataMapping) - def inputDataMap = Map.of("Load", pValue) - def inputDataContainer = new ExtInputDataContainer(0L, inputDataMap, 900L) - - when: - extPrimaryData.convertExternalInputToPrimaryData(inputDataContainer) - - then: - thrown IllegalArgumentException - } -} diff --git a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataConnectionTest.groovy similarity index 64% rename from src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy rename to src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataConnectionTest.groovy index dd11182..7dc0dc2 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataConnectionTest.groovy @@ -2,7 +2,6 @@ package edu.ie3.simona.api.data.results import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.result.connector.LineResult -import edu.ie3.datamodel.models.result.system.LoadResult import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage import edu.ie3.simona.api.data.results.ontology.ProvideResultEntities import edu.ie3.simona.api.data.results.ontology.RequestResultEntities @@ -20,7 +19,7 @@ import javax.measure.quantity.Angle import javax.measure.quantity.ElectricCurrent import java.time.ZonedDateTime -class ExtResultDataTest extends Specification implements DataServiceTestData { +class ExtResultDataConnectionTest extends Specification implements DataServiceTestData { @Shared ActorSystem actorSystem @@ -47,8 +46,8 @@ class ExtResultDataTest extends Specification implements DataServiceTestData { def dataService = new TestProbe(actorSystem) def dataServiceActivation = new TestProbe(actorSystem) def extSimAdapter = new TestProbe(actorSystem) - def extResultData = new ExtResultData(participantResultAssetMapping, gridResultAssetMapping) - extResultData.setActorRefs( + def extResultDataConnection = new ExtResultDataConnection(participantResultAssetMapping, gridResultAssetMapping) + extResultDataConnection.setActorRefs( dataService.ref(), dataServiceActivation.ref(), extSimAdapter.ref() @@ -58,8 +57,8 @@ class ExtResultDataTest extends Specification implements DataServiceTestData { when: // we need to queue the msg beforehand because the receive method is blocking - extResultData.queueExtResponseMsg(sentMsg) - def receivedResults = extResultData.requestResults(0L) + extResultDataConnection.queueExtResponseMsg(sentMsg) + def receivedResults = extResultDataConnection.requestResults(0L) then: dataService.expectMsg(new RequestResultEntities(0L)) @@ -72,8 +71,8 @@ class ExtResultDataTest extends Specification implements DataServiceTestData { def dataService = new TestProbe(actorSystem) def dataServiceActivation = new TestProbe(actorSystem) def extSimAdapter = new TestProbe(actorSystem) - def extResultData = new ExtResultData(participantResultAssetMapping, gridResultAssetMapping) - extResultData.setActorRefs( + def extResultDataConnection = new ExtResultDataConnection(participantResultAssetMapping, gridResultAssetMapping) + extResultDataConnection.setActorRefs( dataService.ref(), dataServiceActivation.ref(), extSimAdapter.ref() @@ -83,8 +82,8 @@ class ExtResultDataTest extends Specification implements DataServiceTestData { when: // we need to queue the msg beforehand because the receive method is blocking - extResultData.queueExtResponseMsg(unexpectedMsg) - extResultData.requestResults(0L) + extResultDataConnection.queueExtResponseMsg(unexpectedMsg) + extResultDataConnection.requestResults(0L) then: dataService.expectMsg(new RequestResultEntities(0L)) @@ -94,31 +93,31 @@ class ExtResultDataTest extends Specification implements DataServiceTestData { def "ExtResultData should convert a list of result entities correctly to a map of resultAssetMappingId to result entity"() { given: - def extResultData = new ExtResultData(participantResultAssetMapping, gridResultAssetMapping) + def extResultDataConnection = new ExtResultDataConnection(participantResultAssetMapping, gridResultAssetMapping) when: - def mapOfResults = extResultData.createResultMap([loadResult]) + def mapOfResults = extResultDataConnection.createResultMap([loadResult]) then: - mapOfResults.size() == 1 - mapOfResults.get("Load") == loadResult + mapOfResults.size() == 1 + mapOfResults.get("Load") == loadResult } def "ExtResultData should throw an exception, if a result with a wrong data type was provided"() { given: - def extResultData = new ExtResultData(participantResultAssetMapping, gridResultAssetMapping) - Quantity iAMag = Quantities.getQuantity(100, StandardUnits.ELECTRIC_CURRENT_MAGNITUDE) - Quantity iAAng = Quantities.getQuantity(45, StandardUnits.ELECTRIC_CURRENT_ANGLE) - Quantity iBMag = Quantities.getQuantity(150, StandardUnits.ELECTRIC_CURRENT_MAGNITUDE) - Quantity iBAng = Quantities.getQuantity(30, StandardUnits.ELECTRIC_CURRENT_ANGLE) - def wrongResult = new LineResult( - ZonedDateTime.parse("2020-01-30T17:26:44Z"), inputUuid, iAMag, iAAng, iBMag, iBAng - ) + def extResultDataConnection = new ExtResultDataConnection(participantResultAssetMapping, gridResultAssetMapping) + Quantity iAMag = Quantities.getQuantity(100, StandardUnits.ELECTRIC_CURRENT_MAGNITUDE) + Quantity iAAng = Quantities.getQuantity(45, StandardUnits.ELECTRIC_CURRENT_ANGLE) + Quantity iBMag = Quantities.getQuantity(150, StandardUnits.ELECTRIC_CURRENT_MAGNITUDE) + Quantity iBAng = Quantities.getQuantity(30, StandardUnits.ELECTRIC_CURRENT_ANGLE) + def wrongResult = new LineResult( + ZonedDateTime.parse("2020-01-30T17:26:44Z"), inputUuid, iAMag, iAAng, iBMag, iBAng + ) when: - extResultData.createResultMap([wrongResult]) + extResultDataConnection.createResultMap([wrongResult]) then: - thrown IllegalArgumentException + thrown IllegalArgumentException } } \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/simona/api/simulation/ExtCoSimulationTest.groovy b/src/test/groovy/edu/ie3/simona/api/simulation/ExtCoSimulationTest.groovy new file mode 100644 index 0000000..f366ae8 --- /dev/null +++ b/src/test/groovy/edu/ie3/simona/api/simulation/ExtCoSimulationTest.groovy @@ -0,0 +1,93 @@ +package edu.ie3.simona.api.simulation + +import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme +import edu.ie3.simona.api.data.ExtDataConnection +import edu.ie3.simona.api.simulation.mapping.DataType +import edu.ie3.simona.api.simulation.mapping.ExtEntityEntry +import edu.ie3.simona.api.simulation.mapping.ExtEntityMapping +import spock.lang.Shared +import spock.lang.Specification + +class ExtCoSimulationTest extends Specification { + + @Shared + ExtCoSimulation coSimulation + + + def setupSpec() { + coSimulation = new ExtCoSimulation("ExtCoSimulation", "") { + @Override + protected Long initialize() { + return null + } + + @Override + protected Optional doActivity(long tick) { + return null + } + + @Override + Set getDataConnections() { + return null + } + } + } + + def "An ExtCoSimulation can build a primary data connection correctly"() { + given: + UUID uuid1 = UUID.randomUUID() + UUID uuid2 = UUID.randomUUID() + UUID uuid3 = UUID.randomUUID() + + ExtEntityMapping mapping = new ExtEntityMapping([ + new ExtEntityEntry(uuid1, "primary1", ColumnScheme.ACTIVE_POWER, DataType.EXT_PRIMARY_INPUT), + new ExtEntityEntry(uuid2, "em1", ColumnScheme.ACTIVE_POWER, DataType.EXT_EM_INPUT), + new ExtEntityEntry(uuid3, "primary2", ColumnScheme.ACTIVE_POWER, DataType.EXT_PRIMARY_INPUT), + ]) + + when: + def actual = coSimulation.buildPrimaryConnection(mapping) + + then: + actual.getPrimaryDataAssets() == [uuid3, uuid1] + } + + def "An ExtCoSimulation can build an em data connection correctly"() { + given: + UUID uuid1 = UUID.randomUUID() + UUID uuid2 = UUID.randomUUID() + UUID uuid3 = UUID.randomUUID() + + ExtEntityMapping mapping = new ExtEntityMapping([ + new ExtEntityEntry(uuid1, "em1", ColumnScheme.ACTIVE_POWER, DataType.EXT_EM_INPUT), + new ExtEntityEntry(uuid2, "em2", ColumnScheme.ACTIVE_POWER, DataType.EXT_EM_INPUT), + new ExtEntityEntry(uuid3, "primary1", ColumnScheme.ACTIVE_POWER, DataType.EXT_PRIMARY_INPUT), + ]) + + when: + def actual = coSimulation.buildEmConnection(mapping) + + then: + actual.getControlledEms() == [uuid1, uuid2] + } + + def "An ExtCoSimulation can build a result data connection correctly"() { + given: + UUID uuid1 = UUID.randomUUID() + UUID uuid2 = UUID.randomUUID() + UUID uuid3 = UUID.randomUUID() + + ExtEntityMapping mapping = new ExtEntityMapping([ + new ExtEntityEntry(uuid1, "grid_result", ColumnScheme.ACTIVE_POWER, DataType.EXT_GRID_RESULT), + new ExtEntityEntry(uuid2, "participant_result", ColumnScheme.ACTIVE_POWER, DataType.EXT_PARTICIPANT_RESULT), + new ExtEntityEntry(uuid3, "primary1", ColumnScheme.ACTIVE_POWER, DataType.EXT_PRIMARY_INPUT), + ]) + + when: + def actual = coSimulation.buildResultConnection(mapping) + + then: + actual.getGridResultDataAssets() == [uuid1] + actual.getParticipantResultDataAssets() == [uuid2] + } +} diff --git a/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy b/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy index 8c2724a..029056f 100644 --- a/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy +++ b/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy @@ -3,7 +3,7 @@ package edu.ie3.simona.api.simulation import org.apache.pekko.actor.ActorSystem import org.apache.pekko.testkit.TestProbe import org.apache.pekko.testkit.javadsl.TestKit -import edu.ie3.simona.api.data.ExtData +import edu.ie3.simona.api.data.ExtDataConnection import edu.ie3.simona.api.simulation.ontology.ActivationMessage import edu.ie3.simona.api.simulation.ontology.CompletionMessage import edu.ie3.simona.api.simulation.ontology.ControlMessageToExt @@ -48,7 +48,7 @@ class ExtSimulationSpec extends Specification { } @Override - List getDataConnections() { + Set getDataConnections() { return [] } } @@ -68,86 +68,86 @@ class ExtSimulationSpec extends Specification { def "An ExtSimulation should handle initialization"() { given: - def tick = -1L - def newTick = 0L - def extSimAdapter = new TestProbe(actorSystem) - def extSimData = new ExtSimAdapterData(extSimAdapter.ref(), new String[0]) - def extSim = new TestSimulation(newTick, Optional.of(-2L)) - extSim.setup(extSimData, new ArrayList()) + def tick = -1L + def newTick = 0L + def extSimAdapter = new TestProbe(actorSystem) + def extSimData = new ExtSimAdapterData(extSimAdapter.ref(), new String[0]) + def extSim = new TestSimulation(newTick, Optional.of(-2L)) + extSim.setAdapterData(extSimData) when: - extSimData.queueExtMsg(new ActivationMessage(tick)) - def finishedActual = handleMessage.invoke(extSim) + extSimData.queueExtMsg(new ActivationMessage(tick)) + def finishedActual = handleMessage.invoke(extSim) then: - finishedActual == false - extSimAdapter.expectMsg(new CompletionMessage(Optional.of(newTick))) + finishedActual == false + extSimAdapter.expectMsg(new CompletionMessage(Optional.of(newTick))) } def "An ExtSimulation should handle activation and return given new triggers"() { given: - def extSimAdapter = new TestProbe(actorSystem) - def extSimData = new ExtSimAdapterData(extSimAdapter.ref(), new String[0]) - def newTickOpt = newTick.isEmpty() ? + def extSimAdapter = new TestProbe(actorSystem) + def extSimData = new ExtSimAdapterData(extSimAdapter.ref(), new String[0]) + def newTickOpt = newTick.isEmpty() ? Optional.empty() : Optional.of(newTick.first()) - def extSim = new TestSimulation(-2L, newTickOpt) - extSim.setup(extSimData, new ArrayList()) + def extSim = new TestSimulation(-2L, newTickOpt) + extSim.setAdapterData(extSimData) when: - extSimData.queueExtMsg(new ActivationMessage(tick)) - def finishedActual = handleMessage.invoke(extSim) + extSimData.queueExtMsg(new ActivationMessage(tick)) + def finishedActual = handleMessage.invoke(extSim) then: - finishedActual == finished - extSimAdapter.expectMsg(new CompletionMessage(newTickOpt)) + finishedActual == finished + extSimAdapter.expectMsg(new CompletionMessage(newTickOpt)) where: - tick | newTick || finished - 0L | [900L] || false - 3600L | [7200L] || false - 7200L | [] || true - 10800L | [] || true + tick | newTick || finished + 0L | [900L] || false + 3600L | [7200L] || false + 7200L | [] || true + 10800L | [] || true } def "An ExtSimulation should handle termination properly"() { given: - def extSimAdapter = new TestProbe(actorSystem) + def extSimAdapter = new TestProbe(actorSystem) def extSimData = new ExtSimAdapterData(extSimAdapter.ref(), new String[0]) - def extSim = new TestSimulation(-1L, Optional.empty()) - extSim.setup(extSimData, new ArrayList()) + def extSim = new TestSimulation(-1L, Optional.empty()) + extSim.setAdapterData(extSimData) when: - extSimData.queueExtMsg(new TerminationMessage(simlulationSuccessful)) - def finishedActual = handleMessage.invoke(extSim) + extSimData.queueExtMsg(new TerminationMessage(simlulationSuccessful)) + def finishedActual = handleMessage.invoke(extSim) then: - finishedActual == finished - extSimAdapter.expectMsg(new TerminationCompleted()) + finishedActual == finished + extSimAdapter.expectMsg(new TerminationCompleted()) where: - simlulationSuccessful || finished - false || true - true || true + simlulationSuccessful || finished + false || true + true || true } class UnknownMessage implements ControlMessageToExt {} def "An ExtSimulation should handle unknown messages by throwing an exception"() { given: - def extSimAdapter = new TestProbe(actorSystem) - def extSimData = new ExtSimAdapterData(extSimAdapter.ref(), new String[0]) - def extSim = new TestSimulation(-1L, Optional.empty()) - extSim.setup(extSimData, new ArrayList()) + def extSimAdapter = new TestProbe(actorSystem) + def extSimData = new ExtSimAdapterData(extSimAdapter.ref(), new String[0]) + def extSim = new TestSimulation(-1L, Optional.empty()) + extSim.setAdapterData(extSimData) when: - extSimData.queueExtMsg(new UnknownMessage()) - handleMessage.invoke(extSim) + extSimData.queueExtMsg(new UnknownMessage()) + handleMessage.invoke(extSim) then: - Exception ex = thrown() - // since we call a private method through reflection, - // our expected exception is wrapped in an InvocationTargetException - ex.getCause().getClass() == IllegalArgumentException - extSimAdapter.expectNoMessage() + Exception ex = thrown() + // since we call a private method through reflection, + // our expected exception is wrapped in an InvocationTargetException + ex.getCause().getClass() == IllegalArgumentException + extSimAdapter.expectNoMessage() } } diff --git a/src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSourceTest.groovy b/src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSourceTest.groovy new file mode 100644 index 0000000..2589e21 --- /dev/null +++ b/src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingSourceTest.groovy @@ -0,0 +1,36 @@ +package edu.ie3.simona.api.simulation.mapping + +import edu.ie3.datamodel.models.input.NodeInput +import spock.lang.Specification + +import java.nio.file.Path + +class ExtEntityMappingSourceTest extends Specification { + + def "An ExtEntityMappingSource can create a naming correctly"() { + given: + def naming = new ExtEntityMappingSource.ExtEntityNaming("ext_entity_mapping") + + when: + def ext_entity_naming = naming.getEntityName(ExtEntityEntry) + def other = naming.getEntityName(NodeInput) + + then: + ext_entity_naming == Optional.of("ext_entity_mapping") + other == Optional.of("node_input") + } + + def "An ExtEntityMappingSource can read a mapping from file correctly"() { + given: + Path filePath = Path.of(ExtEntityMappingSourceTest.getResource("ext_entity_mapping.csv").toURI()) + + when: + def actual = ExtEntityMappingSource.fromFile(filePath) + + then: + actual.getExtUuid2IdMapping(DataType.EXT_PRIMARY_INPUT).size() == 2 + actual.getExtUuid2IdMapping(DataType.EXT_EM_INPUT).size() == 0 + actual.getExtUuid2IdMapping(DataType.EXT_GRID_RESULT).size() == 2 + actual.getExtUuid2IdMapping(DataType.EXT_PARTICIPANT_RESULT).size() == 0 + } +} \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingTest.groovy b/src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingTest.groovy index cd92e95..9f49f61 100644 --- a/src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/simulation/mapping/ExtEntityMappingTest.groovy @@ -13,7 +13,7 @@ class ExtEntityMappingTest extends Specification { loadUuid, "Load", ColumnScheme.parse("p").get(), - "result_participant" + DataType.EXT_PARTICIPANT_RESULT ) @Shared @@ -21,7 +21,7 @@ class ExtEntityMappingTest extends Specification { loadUuid, "Load", ColumnScheme.parse("p").get(), - "input" + DataType.EXT_PRIMARY_INPUT ) def "ExtEntityMapping should return SIMONA uuid mapping correctly"() { @@ -30,21 +30,20 @@ class ExtEntityMappingTest extends Specification { def extEntryMapping = new ExtEntityMapping(extAssetList) when: - def inputMap = extEntryMapping.getExtId2UuidMapping("input") + def inputMap = extEntryMapping.getExtId2UuidMapping(DataType.EXT_PRIMARY_INPUT) then: inputMap.size() == 1 inputMap.get("Load") == loadUuid } - def "ExtEntityMapping should return external id mapping correctly"() { given: def extAssetList = List.of(extResultEntry, extInputEntry) def extEntryMapping = new ExtEntityMapping(extAssetList) when: - def inputMap = extEntryMapping.getExtUuid2IdMapping("input") + def inputMap = extEntryMapping.getExtUuid2IdMapping(DataType.EXT_PRIMARY_INPUT) then: inputMap.size() == 1 diff --git a/src/test/groovy/edu/ie3/simona/api/test/common/DataServiceTestData.groovy b/src/test/groovy/edu/ie3/simona/api/test/common/DataServiceTestData.groovy index c589bc1..fa8e537 100644 --- a/src/test/groovy/edu/ie3/simona/api/test/common/DataServiceTestData.groovy +++ b/src/test/groovy/edu/ie3/simona/api/test/common/DataServiceTestData.groovy @@ -3,11 +3,15 @@ package edu.ie3.simona.api.test.common import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.result.system.LoadResult import edu.ie3.datamodel.models.value.PValue +import org.slf4j.Logger +import org.slf4j.LoggerFactory import tech.units.indriya.quantity.Quantities import java.time.ZonedDateTime trait DataServiceTestData { + Logger log = LoggerFactory.getLogger(DataServiceTestData) + UUID inputUuid = UUID.fromString("22bea5fc-2cb2-4c61-beb9-b476e0107f52") PValue pValue = new PValue(Quantities.getQuantity(500.0, StandardUnits.ACTIVE_POWER_IN)) diff --git a/src/test/resources/edu/ie3/simona/api/simulation/mapping/ext_entity_mapping.csv b/src/test/resources/edu/ie3/simona/api/simulation/mapping/ext_entity_mapping.csv new file mode 100644 index 0000000..2163547 --- /dev/null +++ b/src/test/resources/edu/ie3/simona/api/simulation/mapping/ext_entity_mapping.csv @@ -0,0 +1,5 @@ +uuid,id,column_scheme,data_type +00d03670-7833-47ee-ad52-04d18d1c64fd,NS_Node_1,p,grid_result +dfae9806-9b44-4995-ba27-d66d8e4a43e0,NS_Node_2,p,grid_result +4dca3b1d-5d24-444a-b4df-f4fa23b9ef1b,LOAD_NS_Node_1,pq,primary_input +9c5991bc-24df-496b-b4ce-5ec27657454c,LOAD_NS_Node_2,pq,primary_input \ No newline at end of file From ffa48d0fd21d269a126a05639b71caf672fa5ee1 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Fri, 29 Nov 2024 10:12:42 +0100 Subject: [PATCH 77/82] Fix code quality. --- .../api/simulation/ExtCoSimulation.java | 27 +++++++++------- .../api/simulation/ExtCoSimulationTest.groovy | 31 ++++--------------- 2 files changed, 22 insertions(+), 36 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java index a3080ce..a23042b 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java @@ -20,7 +20,6 @@ import java.util.Optional; import java.util.UUID; import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Abstract class for an external co-simulation with the structure: external api - ext-co-simulation @@ -29,8 +28,6 @@ */ public abstract class ExtCoSimulation extends ExtSimulation { - protected Logger log; - /** Queue for the data connection from the external co-simulation to SimonaAPI */ protected final DataQueueExtSimulationExtSimulator dataQueueExtCoSimulatorToSimonaApi; @@ -48,8 +45,6 @@ public abstract class ExtCoSimulation extends ExtSimulation { protected ExtCoSimulation(String simulationName, String extSimulatorName) { super(simulationName); this.extSimulatorName = extSimulatorName; - log = LoggerFactory.getLogger(simulationName); - this.dataQueueExtCoSimulatorToSimonaApi = new DataQueueExtSimulationExtSimulator<>(); this.dataQueueSimonaApiToExtCoSimulator = new DataQueueExtSimulationExtSimulator<>(); } @@ -58,9 +53,11 @@ protected ExtCoSimulation(String simulationName, String extSimulatorName) { * Builds an {@link ExtPrimaryDataConnection}. * * @param mapping between the external simulation and SIMONA. + * @param log logger * @return an ext primary data connection */ - protected ExtPrimaryDataConnection buildPrimaryConnection(ExtEntityMapping mapping) { + protected static ExtPrimaryDataConnection buildPrimaryConnection( + ExtEntityMapping mapping, Logger log) { Map primaryMapping = mapping.getExtId2UuidMapping(DataType.EXT_PRIMARY_INPUT); ExtPrimaryDataConnection extPrimaryDataConnection = new ExtPrimaryDataConnection(primaryMapping); @@ -78,9 +75,10 @@ protected ExtPrimaryDataConnection buildPrimaryConnection(ExtEntityMapping mappi * Builds an {@link ExtEmDataConnection}. * * @param mapping between the external simulation and SIMONA. + * @param log logger * @return an ext em data connection */ - protected ExtEmDataConnection buildEmConnection(ExtEntityMapping mapping) { + protected static ExtEmDataConnection buildEmConnection(ExtEntityMapping mapping, Logger log) { Map emMapping = mapping.getExtId2UuidMapping(DataType.EXT_EM_INPUT); ExtEmDataConnection extEmDataConnection = new ExtEmDataConnection(emMapping); @@ -97,9 +95,11 @@ protected ExtEmDataConnection buildEmConnection(ExtEntityMapping mapping) { * Builds an {@link ExtResultDataConnection}. * * @param mapping between the external simulation and SIMONA. + * @param log logger * @return an ext result data connection */ - protected ExtResultDataConnection buildResultConnection(ExtEntityMapping mapping) { + protected static ExtResultDataConnection buildResultConnection( + ExtEntityMapping mapping, Logger log) { Map resultParticipantMapping = mapping.getExtUuid2IdMapping(DataType.EXT_PARTICIPANT_RESULT); Map resultGridMapping = mapping.getExtUuid2IdMapping(DataType.EXT_GRID_RESULT); @@ -125,12 +125,14 @@ protected ExtResultDataConnection buildResultConnection(ExtEntityMapping mapping * @param tick for which data is sent * @param dataMap map: id to value * @param maybeNextTick option for the next tick data is sent + * @param log logger */ protected void sendPrimaryDataToSimona( ExtPrimaryDataConnection extPrimaryDataConnection, long tick, Map dataMap, - Optional maybeNextTick) { + Optional maybeNextTick, + Logger log) { log.debug("Wait for Primary Data from {}", extSimulatorName); log.debug("Received Primary Data from {}", extSimulatorName); extPrimaryDataConnection.convertAndSend(tick, dataMap, maybeNextTick, log); @@ -145,12 +147,14 @@ protected void sendPrimaryDataToSimona( * @param tick for which data is sent * @param dataMap map: id to value * @param maybeNextTick option for the next tick data is sent + * @param log logger */ protected void sendEmDataToSimona( ExtEmDataConnection extEmDataConnection, long tick, Map dataMap, - Optional maybeNextTick) { + Optional maybeNextTick, + Logger log) { log.debug("Received EmData from {}", extSimulatorName); extEmDataConnection.convertAndSend(tick, dataMap, maybeNextTick, log); log.debug("Provided EmData to SIMONA!"); @@ -162,9 +166,10 @@ protected void sendEmDataToSimona( * @param connection the connection to SIMONA * @param tick for which data is received * @param maybeNextTick option for the next tick data is received + * @param log logger */ protected void sendDataToExt( - ExtResultDataConnection connection, long tick, Optional maybeNextTick) + ExtResultDataConnection connection, long tick, Optional maybeNextTick, Logger log) throws InterruptedException { log.debug("Request results from SIMONA!"); Map resultsToBeSend = connection.requestResults(tick); diff --git a/src/test/groovy/edu/ie3/simona/api/simulation/ExtCoSimulationTest.groovy b/src/test/groovy/edu/ie3/simona/api/simulation/ExtCoSimulationTest.groovy index f366ae8..2903384 100644 --- a/src/test/groovy/edu/ie3/simona/api/simulation/ExtCoSimulationTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/simulation/ExtCoSimulationTest.groovy @@ -1,37 +1,18 @@ package edu.ie3.simona.api.simulation import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme -import edu.ie3.simona.api.data.ExtDataConnection import edu.ie3.simona.api.simulation.mapping.DataType import edu.ie3.simona.api.simulation.mapping.ExtEntityEntry import edu.ie3.simona.api.simulation.mapping.ExtEntityMapping +import org.slf4j.Logger +import org.slf4j.LoggerFactory import spock.lang.Shared import spock.lang.Specification class ExtCoSimulationTest extends Specification { @Shared - ExtCoSimulation coSimulation - - - def setupSpec() { - coSimulation = new ExtCoSimulation("ExtCoSimulation", "") { - @Override - protected Long initialize() { - return null - } - - @Override - protected Optional doActivity(long tick) { - return null - } - - @Override - Set getDataConnections() { - return null - } - } - } + private static final Logger log = LoggerFactory.getLogger(ExtCoSimulationTest) def "An ExtCoSimulation can build a primary data connection correctly"() { given: @@ -46,7 +27,7 @@ class ExtCoSimulationTest extends Specification { ]) when: - def actual = coSimulation.buildPrimaryConnection(mapping) + def actual = ExtCoSimulation.buildPrimaryConnection(mapping, log) then: actual.getPrimaryDataAssets() == [uuid3, uuid1] @@ -65,7 +46,7 @@ class ExtCoSimulationTest extends Specification { ]) when: - def actual = coSimulation.buildEmConnection(mapping) + def actual = ExtCoSimulation.buildEmConnection(mapping, log) then: actual.getControlledEms() == [uuid1, uuid2] @@ -84,7 +65,7 @@ class ExtCoSimulationTest extends Specification { ]) when: - def actual = coSimulation.buildResultConnection(mapping) + def actual = ExtCoSimulation.buildResultConnection(mapping, log) then: actual.getGridResultDataAssets() == [uuid1] From 1f84440eead717bfb8a2555436e2066b45488648 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Fri, 29 Nov 2024 11:56:04 +0100 Subject: [PATCH 78/82] Implementing reviewers requests. --- .../simona/api/data/em/ExtEmDataConnection.java | 2 +- .../simona/api/data/ev/ExtEvDataConnection.java | 4 ---- .../data/primarydata/ExtPrimaryDataConnection.java | 6 +----- .../simona/api/exceptions/ConversionException.java | 14 -------------- .../ie3/simona/api/simulation/ExtCoSimulation.java | 3 --- 5 files changed, 2 insertions(+), 27 deletions(-) delete mode 100644 src/main/java/edu/ie3/simona/api/exceptions/ConversionException.java diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataConnection.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataConnection.java index baaa0f3..5a0bbaa 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataConnection.java @@ -41,7 +41,7 @@ public void setActorRefs(ActorRef emDataService, ActorRef extSimAdapter) { public void convertAndSend( long tick, Map data, Optional maybeNextTick, Logger log) { - // filtering and converting the data + // filtering the data and converting the keys Map convertedMap = data.entrySet().stream() .filter(e -> extEmMapping.containsKey(e.getKey())) diff --git a/src/main/java/edu/ie3/simona/api/data/ev/ExtEvDataConnection.java b/src/main/java/edu/ie3/simona/api/data/ev/ExtEvDataConnection.java index a1deb2f..53a71e8 100644 --- a/src/main/java/edu/ie3/simona/api/data/ev/ExtEvDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/ev/ExtEvDataConnection.java @@ -28,10 +28,6 @@ public class ExtEvDataConnection implements ExtInputDataConnection { /** Actor reference to adapter that handles scheduler control flow in SIMONA */ private ActorRef extSimAdapter; - // important trigger queue must be the same as hold in actor - // to make it safer one might consider asking the actor for ara reference on its trigger queue?! - public ExtEvDataConnection() {} - @Override public void setActorRefs(ActorRef dataService, ActorRef extSimAdapter) { this.dataService = dataService; diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnection.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnection.java index 83b4c67..10fe184 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnection.java @@ -28,10 +28,6 @@ public class ExtPrimaryDataConnection implements ExtInputDataConnection { /** Assets that provide primary data to SIMONA */ private final Map extPrimaryDataMapping; - public ExtPrimaryDataConnection() { - this(Map.of()); - } - public ExtPrimaryDataConnection(Map extPrimaryDataMapping) { this.extPrimaryDataMapping = extPrimaryDataMapping; } @@ -44,7 +40,7 @@ public void setActorRefs(ActorRef dataService, ActorRef extSimAdapter) { public void convertAndSend( long tick, Map data, Optional maybeNextTick, Logger log) { - // filtering and converting the data + // filtering the data and converting the keys Map convertedMap = data.entrySet().stream() .filter(e -> extPrimaryDataMapping.containsKey(e.getKey())) diff --git a/src/main/java/edu/ie3/simona/api/exceptions/ConversionException.java b/src/main/java/edu/ie3/simona/api/exceptions/ConversionException.java deleted file mode 100644 index 50c75a7..0000000 --- a/src/main/java/edu/ie3/simona/api/exceptions/ConversionException.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * © 2024. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation - */ - -package edu.ie3.simona.api.exceptions; - -public class ConversionException extends RuntimeException { - - public ConversionException(final String message) { - super(message); - } -} diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java index a23042b..f07ec9b 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java @@ -36,9 +36,6 @@ public abstract class ExtCoSimulation extends ExtSimulation { protected final DataQueueExtSimulationExtSimulator dataQueueSimonaApiToExtCoSimulator; - /** Time resolution for the data exchange */ - protected final long deltaT = 900L; - /** Name of the external co-simulation */ protected final String extSimulatorName; From 034cab4c0a95f9618d4384f95e5ee400529027ba Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Mon, 2 Dec 2024 14:49:59 +0100 Subject: [PATCH 79/82] Adapting changelog for release --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e65bda..b8984b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased/Snapshot] +## [0.6.0] - 2024-12-02 + ### Added - Enable initialization of external data simulation [#167](https://github.com/ie3-institute/simonaAPI/issues/167) - `ExtResultContainer` returns result map [#217](https://github.com/ie3-institute/simonaAPI/issues/217) @@ -45,7 +47,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Renamed messages to ease understanding [#62](https://github.com/ie3-institute/simonaAPI/issues/62) - Separating departures and arrivals in message protocol, properly handling exceptions [#77](https://github.com/ie3-institute/simonaAPI/issues/77) -[Unreleased/Snapshot]: https://github.com/ie3-institute/simonaapi/compare/0.5.0...HEAD +[Unreleased/Snapshot]: https://github.com/ie3-institute/simonaapi/compare/0.6.0...HEAD +[0.6.0]: https://github.com/ie3-institute/powersystemdatamodel/compare/0.5.0...0.6.0 [0.5.0]: https://github.com/ie3-institute/powersystemdatamodel/compare/0.4.0...0.5.0 [0.4.0]: https://github.com/ie3-institute/powersystemdatamodel/compare/0.3.0...0.4.0 [0.3.0]: https://github.com/ie3-institute/powersystemdatamodel/compare/0.2.0...0.3.0 From d6ffc2c1fa2a1b7e2250689ab72c109914e5654c Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Mon, 2 Dec 2024 14:54:20 +0100 Subject: [PATCH 80/82] Upgrading gradle to 8.11.1 --- gradle/wrapper/gradle-wrapper.jar | Bin 63721 -> 43583 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 7 +++++-- gradlew.bat | 22 ++++++++++++---------- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7f93135c49b765f8051ef9d0a6055ff8e46073d8..a4b76b9530d66f5e68d973ea569d8e19de379189 100644 GIT binary patch literal 43583 zcma&N1CXTcmMvW9vTb(Rwr$&4wr$(C?dmSu>@vG-+vuvg^_??!{yS%8zW-#zn-LkA z5&1^$^{lnmUON?}LBF8_K|(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(CtS$CQbpq9|y1e zRSrN4;$Jyl{m5bZw`$8TGvb}(LpY{-cQ)fcyJv7l3S52TLXVDsphtv&aPuDk1OzCA z4A^QtC(!11`IsNx_HnSy?>EKpHJWT^wmS~hc^p^zIIh@9f6U@I2 zC=Mve{j2^)mS#U$e{@Q?SO6%LDsXz@SY+=cK_QMmXBIU)j!$ajc-zLx3V60EXJ!qC zi<%2x8Q24YN+&8U@CIlN zrZkcT9yh%LrlGS9`G)KdP(@9Eo-AQz@8GEFWcb7U=a0H^ZVbLmz{+&M7W(nXJ4sN8 zJLR7eeK(K8`2-}j(T7JsO`L!+CvbueT%izanm-^A1Dn{`1Nw`9P?cq;7no+XfC`K(GO9?O^5zNIt4M+M8LM0=7Gz8UA@Z0N+lg+cX)NfazRu z5D)~HA^(u%w^cz+@2@_#S|u>GpB+j4KzQ^&Wcl9f z&hG#bCA(Yk0D&t&aJE^xME^&E-&xGHhXn%}psEIj641H+Nl-}boj;)Zt*t(4wZ5DN z@GXF$bL=&pBq-#vkTkh>7hl%K5|3 z{`Vn9b$iR-SoGENp}bn4;fR3>9sA%X2@1L3aE9yTra;Wb#_`xWwLSLdfu+PAu+o3| zGVnpzPr=ch{uuoHjtw7+_!L_2;knQ!DuDl0R`|%jr+}jFzXtrHIKc323?JO{l&;VF z*L1+}JU7%QJOg|5|Tc|D8fN zJORAg=_vsy{ak|o);@)Yh8Lkcg@$FG3k@ep36BRa^>~UmnRPziS>Z=`Jb2x*Q#`%A zU*i3&Vg?TluO@X0O;r2Jl6LKLUOVhSqg1*qOt^|8*c7 zo(298@+r$k_wQNGHv{|$tW(T8L+4_`FQ{kEW5Jgg{yf7ey4ss_(SNKfz(N9lx&a;< je(UuV8hP?p&}TPdm1I$XmG#(RzlD&B2izSj9sl%y5~4qc diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 09523c0..e2847c8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a4..f5feea6 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,8 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 93e3f59..9d21a21 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail From b411dc9208cce27316b69b5fafc8d8e1540203e9 Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Mon, 2 Dec 2024 15:09:52 +0100 Subject: [PATCH 81/82] Removing unnecessary dependency --- build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle b/build.gradle index 73d7b4b..175b914 100644 --- a/build.gradle +++ b/build.gradle @@ -80,7 +80,6 @@ dependencies{ // TESTING testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0' - implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.18.2' } task printVersion { From 6ee4e5e09e2bcc50f049fbf142a76d7882843fb4 Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Mon, 2 Dec 2024 15:12:04 +0100 Subject: [PATCH 82/82] spotless --- build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle b/build.gradle index 175b914..6f31561 100644 --- a/build.gradle +++ b/build.gradle @@ -79,7 +79,6 @@ dependencies{ // TESTING testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0' - } task printVersion {