-
Notifications
You must be signed in to change notification settings - Fork 7
To/#585 ems data model #591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
7efe007
implement em input
t-ober abfa857
rename eminput
t-ober 270d2d7
make file sink work
t-ober 583e065
fix sp source
t-ober f183f7b
Merge branch 'dev' into to/#585-ems-data-model
t-ober a775bbd
adapt jgc test
t-ober e0e3c6c
Merge remote-tracking branch 'origin/dev' into to/#585-ems-data-model
t-ober 4c5fb90
use empty participants method
t-ober 962e8ca
rmv unused imports
t-ober 3dcb0b7
use replace
t-ober 2a93a8a
add copy builder test
t-ober 3a68b79
fix test
t-ober a13b9e7
em control strategy tests
t-ober eef0dc3
more tests
t-ober 66f79d9
add tests
t-ober 92c2df7
fix to string
t-ober c983d38
fix codacy issues
t-ober f2dc540
more codacy fixes
t-ober 8fccb1b
Merge branch 'dev' into to/#585-ems-data-model
t-ober cb57d6a
Merge branch 'dev' into to/#585-ems-data-model
t-ober 3ad67e5
Merge branch 'dev' into to/#585-ems-data-model
sebastian-peter cc59554
Fixing tests
sebastian-peter 1fa2437
address reviewers comments
t-ober 108e8a1
Merge branch 'dev' into to/#585-ems-data-model
sebastian-peter 145d0d4
Fixing merge error
sebastian-peter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/java/edu/ie3/datamodel/io/factory/input/participant/EmInputFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /* | ||
| * © 2022. TU Dortmund University, | ||
| * Institute of Energy Systems, Energy Efficiency and Energy Economics, | ||
| * Research group Distribution grid planning and operation | ||
| */ | ||
| package edu.ie3.datamodel.io.factory.input.participant; | ||
|
|
||
| import edu.ie3.datamodel.exceptions.ParsingException; | ||
| import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData; | ||
| import edu.ie3.datamodel.models.ControlStrategy; | ||
| import edu.ie3.datamodel.models.OperationTime; | ||
| import edu.ie3.datamodel.models.input.NodeInput; | ||
| import edu.ie3.datamodel.models.input.OperatorInput; | ||
| import edu.ie3.datamodel.models.input.system.EmInput; | ||
| import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; | ||
| import java.util.UUID; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| public class EmInputFactory | ||
| extends SystemParticipantInputEntityFactory<EmInput, NodeAssetInputEntityData> { | ||
| private static final Logger logger = LoggerFactory.getLogger(EmInputFactory.class); | ||
|
|
||
| private static final String CONNECTED_ASSETS = "connectedassets"; | ||
|
|
||
| private static final String CONTROL_STRATEGY = "controlstrategy"; | ||
|
|
||
| public EmInputFactory() { | ||
| super(EmInput.class); | ||
| } | ||
|
|
||
| @Override | ||
| protected String[] getAdditionalFields() { | ||
| return new String[] {CONNECTED_ASSETS, CONTROL_STRATEGY}; | ||
| } | ||
|
|
||
| @Override | ||
| protected EmInput buildModel( | ||
| NodeAssetInputEntityData data, | ||
| UUID uuid, | ||
| String id, | ||
| NodeInput node, | ||
| ReactivePowerCharacteristic qCharacteristics, | ||
| OperatorInput operator, | ||
| OperationTime operationTime) { | ||
| ControlStrategy controlStrategy; | ||
| try { | ||
| controlStrategy = ControlStrategy.parse(data.getField(CONTROL_STRATEGY)); | ||
| } catch (ParsingException e) { | ||
| logger.warn( | ||
| "Cannot parse control strategy \"{}\" of energy management system \"{}\". Assign no control strategy instead.", | ||
| data.getField(CONTROL_STRATEGY), | ||
| id); | ||
| controlStrategy = ControlStrategy.DefaultControlStrategies.NO_CONTROL_STRATEGY; | ||
| } | ||
| final UUID[] connectedAssets = data.getUUIDs(data.getField(CONNECTED_ASSETS)); | ||
| return new EmInput( | ||
| uuid, | ||
| id, | ||
| operator, | ||
| operationTime, | ||
| node, | ||
| qCharacteristics, | ||
| connectedAssets, | ||
| controlStrategy); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/edu/ie3/datamodel/models/ControlStrategy.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /* | ||
| * © 2022. TU Dortmund University, | ||
| * Institute of Energy Systems, Energy Efficiency and Energy Economics, | ||
| * Research group Distribution grid planning and operation | ||
| */ | ||
| package edu.ie3.datamodel.models; | ||
|
|
||
| import edu.ie3.datamodel.exceptions.ParsingException; | ||
| import java.io.Serializable; | ||
| import java.util.Arrays; | ||
|
|
||
| public interface ControlStrategy extends Serializable { | ||
| String getKey(); | ||
|
|
||
| static ControlStrategy parse(String key) throws ParsingException { | ||
| if (key == null || key.isEmpty()) | ||
| return ControlStrategy.DefaultControlStrategies.NO_CONTROL_STRATEGY; | ||
|
|
||
| String filterKey = key.toLowerCase().replace("-", "_"); | ||
| return Arrays.stream(EmControlStrategy.values()) | ||
| .filter(profile -> profile.getKey().equals(filterKey)) | ||
| .findFirst() | ||
| .orElseThrow( | ||
| () -> new ParsingException("Cannot parse \"" + key + "\" to a valid control strategy")); | ||
| } | ||
|
|
||
| enum DefaultControlStrategies implements ControlStrategy { | ||
| NO_CONTROL_STRATEGY; | ||
|
|
||
| @Override | ||
| public String getKey() { | ||
| return "No control strategy assigned"; | ||
| } | ||
| } | ||
| } |
45 changes: 45 additions & 0 deletions
45
src/main/java/edu/ie3/datamodel/models/EmControlStrategy.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * © 2022. TU Dortmund University, | ||
| * Institute of Energy Systems, Energy Efficiency and Energy Economics, | ||
| * Research group Distribution grid planning and operation | ||
| */ | ||
| package edu.ie3.datamodel.models; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.Locale; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| public enum EmControlStrategy implements ControlStrategy { | ||
| SELF_OPTIMIZATION("self_optimization"); | ||
|
|
||
| private final String key; | ||
|
|
||
| EmControlStrategy(String key) { | ||
| this.key = key.toLowerCase(Locale.ROOT); | ||
| } | ||
|
|
||
| public static EmControlStrategy get(String key) { | ||
| return Arrays.stream(EmControlStrategy.values()) | ||
| .filter(controlStrategy -> controlStrategy.key.equalsIgnoreCase(key)) | ||
| .findFirst() | ||
| .orElseThrow( | ||
| () -> | ||
| new IllegalArgumentException( | ||
| "No predefined energy management control strategy '" | ||
| + key | ||
| + "' found. Please provide one of the following keys: " | ||
| + Arrays.stream(EmControlStrategy.values()) | ||
| .map(EmControlStrategy::getKey) | ||
| .collect(Collectors.joining(", ")))); | ||
| } | ||
|
|
||
| @Override | ||
| public String getKey() { | ||
| return key; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "EmControlStrategy{" + "key='" + key + '\'' + '}'; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.