Skip to content
Merged
3 changes: 3 additions & 0 deletions src/main/java/edu/ie3/datamodel/io/extractor/Extractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public static Set<UniqueInputEntity> extractElements(NestedEntity nestedEntity)
if (nestedEntity instanceof HasLine nestedHasLine) {
resultingList.add(nestedHasLine.getLine());
}
if (nestedEntity instanceof HasEm nestedHasEms) {
nestedHasEms.getControllingEm().ifPresent(resultingList::add);
}

if (resultingList.contains(null)) {
log.warn(
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/edu/ie3/datamodel/io/extractor/HasEm.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* © 2024. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.io.extractor;

import edu.ie3.datamodel.models.input.EmInput;
import java.util.Optional;

/**
* Interface that should be implemented by all elements that can be controlled by {@link
* edu.ie3.datamodel.models.input.EmInput} elements and should be processable by the {@link
* Extractor}.
*/
public interface HasEm extends NestedEntity {
Optional<EmInput> getControllingEm();
}
38 changes: 20 additions & 18 deletions src/main/java/edu/ie3/datamodel/models/input/EmInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
*/
package edu.ie3.datamodel.models.input;

import edu.ie3.datamodel.io.extractor.HasEm;
import edu.ie3.datamodel.models.OperationTime;
import edu.ie3.datamodel.models.UniqueEntity;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;

public class EmInput extends AssetInput {
public class EmInput extends AssetInput implements HasEm {

/** Reference to the control strategy to be used for this model */
private final String controlStrategy;
Expand All @@ -20,7 +21,7 @@ public class EmInput extends AssetInput {
* Optional UUID of the parent {@link EmInput} that is controlling this em unit. If null, this em
* unit is not em-controlled.
*/
private final EmInput parentEm;
private final EmInput controllingEm;

/**
* Constructor for an operated energy management system
Expand All @@ -30,18 +31,18 @@ public class EmInput extends AssetInput {
* @param operator of the asset
* @param operationTime time for which the entity is operated
* @param emControlStrategy the control strategy
* @param parentEm The {@link EmInput} controlling this em unit. Null, if not applicable.
* @param controllingEm The {@link EmInput} controlling this em unit. Null, if not applicable.
*/
public EmInput(
UUID uuid,
String id,
OperatorInput operator,
OperationTime operationTime,
String emControlStrategy,
EmInput parentEm) {
EmInput controllingEm) {
super(uuid, id, operator, operationTime);
this.controlStrategy = emControlStrategy;
this.parentEm = parentEm;
this.controllingEm = controllingEm;
}

/**
Expand All @@ -50,22 +51,18 @@ public EmInput(
* @param uuid of the input entity
* @param id of the asset
* @param emControlStrategy the control strategy
* @param parentEm The {@link EmInput} controlling this em unit. Null, if not applicable.
* @param controllingEm The {@link EmInput} controlling this em unit. Null, if not applicable.
*/
public EmInput(UUID uuid, String id, String emControlStrategy, EmInput parentEm) {
public EmInput(UUID uuid, String id, String emControlStrategy, EmInput controllingEm) {
super(uuid, id);
this.controlStrategy = emControlStrategy;
this.parentEm = parentEm;
this.controllingEm = controllingEm;
}

public String getControlStrategy() {
return controlStrategy;
}

public Optional<EmInput> getParentEm() {
return Optional.ofNullable(parentEm);
}

@Override
public EmInputCopyBuilder copy() {
return new EmInputCopyBuilder(this);
Expand All @@ -77,12 +74,12 @@ public boolean equals(Object o) {
if (!(o instanceof EmInput emInput)) return false;
if (!super.equals(o)) return false;
return Objects.equals(controlStrategy, emInput.controlStrategy)
&& Objects.equals(parentEm, emInput.parentEm);
&& Objects.equals(controllingEm, emInput.controllingEm);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), controlStrategy, parentEm);
return Objects.hash(super.hashCode(), controlStrategy, controllingEm);
}

@Override
Expand All @@ -92,15 +89,20 @@ public String toString() {
+ getUuid()
+ ", id='"
+ getId()
+ ", operator="
+ "', operator="
+ getOperator().getUuid()
+ ", operationTime="
+ getOperationTime()
+ ", controlStrategy="
+ getControlStrategy()
+ ", parentEm="
+ getParentEm().map(UniqueEntity::getUuid).map(UUID::toString).orElse("")
+ '}';
+ getControllingEm().map(UniqueEntity::getUuid).map(UUID::toString).orElse("")
+ "}";
}

@Override
public Optional<EmInput> getControllingEm() {
return Optional.ofNullable(controllingEm);
}

public static class EmInputCopyBuilder extends AssetInputCopyBuilder<EmInputCopyBuilder> {
Expand All @@ -112,7 +114,7 @@ public static class EmInputCopyBuilder extends AssetInputCopyBuilder<EmInputCopy
protected EmInputCopyBuilder(EmInput entity) {
super(entity);
this.controlStrategy = entity.getControlStrategy();
this.parentEm = entity.parentEm;
this.parentEm = entity.controllingEm;
}

public EmInputCopyBuilder controlStrategy(String controlStrategy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public String toString() {
+ ", qCharacteristics='"
+ getqCharacteristics()
+ "', em="
+ getEm()
+ getControllingEm()
+ ", type="
+ type.getUuid()
+ ", marketReaction="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public String toString() {
+ ", qCharacteristics='"
+ getqCharacteristics()
+ "', em="
+ getEm()
+ getControllingEm()
+ ", thermalBus="
+ thermalBus.getUuid()
+ ", type="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public String toString() {
+ ", qCharacteristics='"
+ getqCharacteristics()
+ "', em="
+ getEm()
+ getControllingEm()
+ ", type="
+ type.getUuid()
+ '}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public String toString() {
+ ", qCharacteristics='"
+ getqCharacteristics()
+ "', em="
+ getEm()
+ getControllingEm()
+ ", type="
+ type
+ ", chargingPoints="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public String toString() {
+ ", qCharacteristics='"
+ getqCharacteristics()
+ "', em="
+ getEm()
+ getControllingEm()
+ ", sRated="
+ sRated
+ ", cosphiRated="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public String toString() {
+ ", qCharacteristics='"
+ getqCharacteristics()
+ "', em="
+ getEm()
+ getControllingEm()
+ ", type="
+ type.getUuid()
+ ", thermalBus="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public String toString() {
+ ", qCharacteristics='"
+ getqCharacteristics()
+ "', em="
+ getEm()
+ getControllingEm()
+ ", dsm="
+ dsm
+ ", eConsAnnual="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public String toString() {
+ ", qCharacteristics='"
+ getqCharacteristics()
+ "', em="
+ getEm()
+ getControllingEm()
+ ", albedo="
+ albedo
+ ", azimuth="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public String toString() {
+ ", qCharacteristics='"
+ getqCharacteristics()
+ "', em="
+ getEm()
+ getControllingEm()
+ ", type="
+ type.getUuid()
+ '}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
package edu.ie3.datamodel.models.input.system;

import edu.ie3.datamodel.io.extractor.HasEm;
import edu.ie3.datamodel.io.extractor.HasNodes;
import edu.ie3.datamodel.models.OperationTime;
import edu.ie3.datamodel.models.UniqueEntity;
Expand All @@ -16,7 +17,7 @@
import java.util.*;

/** Describes a system asset that is connected to a node */
public abstract class SystemParticipantInput extends AssetInput implements HasNodes {
public abstract class SystemParticipantInput extends AssetInput implements HasNodes, HasEm {

/** The node that the asset is connected to */
private final NodeInput node;
Expand All @@ -28,7 +29,7 @@ public abstract class SystemParticipantInput extends AssetInput implements HasNo
* Optional {@link EmInput} that is controlling this system participant. If null, this system
* participant is not em-controlled.
*/
private final EmInput em;
private final EmInput controllingEm;

/**
* Constructor for an operated system participant
Expand All @@ -52,7 +53,7 @@ protected SystemParticipantInput(
super(uuid, id, operator, operationTime);
this.node = node;
this.qCharacteristics = qCharacteristics;
this.em = em;
this.controllingEm = em;
}

/**
Expand All @@ -73,7 +74,7 @@ protected SystemParticipantInput(
super(uuid, id);
this.node = node;
this.qCharacteristics = qCharacteristics;
this.em = em;
this.controllingEm = em;
}

public NodeInput getNode() {
Expand All @@ -84,15 +85,16 @@ public ReactivePowerCharacteristic getqCharacteristics() {
return qCharacteristics;
}

public Optional<EmInput> getEm() {
return Optional.ofNullable(em);
}

@Override
public List<NodeInput> allNodes() {
return Collections.singletonList(node);
}

@Override
public Optional<EmInput> getControllingEm() {
return Optional.ofNullable(controllingEm);
}

@Override
public abstract SystemParticipantInputCopyBuilder<?> copy();

Expand All @@ -103,12 +105,12 @@ public boolean equals(Object o) {
if (!super.equals(o)) return false;
return Objects.equals(node, that.node)
&& Objects.equals(qCharacteristics, that.qCharacteristics)
&& Objects.equals(em, that.em);
&& Objects.equals(controllingEm, that.controllingEm);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), node, qCharacteristics, em);
return Objects.hash(super.hashCode(), node, qCharacteristics, controllingEm);
}

@Override
Expand All @@ -126,8 +128,8 @@ public String toString() {
+ node.getUuid()
+ ", qCharacteristics='"
+ qCharacteristics
+ "', em="
+ getEm().map(UniqueEntity::getUuid).map(UUID::toString).orElse("")
+ "', controllingEm="
+ getControllingEm().map(UniqueEntity::getUuid).map(UUID::toString).orElse("")
+ '}';
}

Expand All @@ -150,7 +152,7 @@ protected SystemParticipantInputCopyBuilder(SystemParticipantInput entity) {
super(entity);
this.node = entity.getNode();
this.qCharacteristics = entity.getqCharacteristics();
this.em = entity.getEm().orElse(null);
this.em = entity.getControllingEm().orElse(null);
}

public B node(NodeInput node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public String toString() {
+ ", qCharacteristics='"
+ getqCharacteristics()
+ "', em="
+ getEm()
+ getControllingEm()
+ ", type="
+ type.getUuid()
+ ", marketReaction="
Expand Down
Loading