Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void sendFlexRequests(
log.debug("No em flex requests found! Sending no em data to SIMONA for tick {}.", tick);
} else {
log.debug("Provided SIMONA with em flex requests.");
sendExtMsg(new ProvideFlexRequestData(tick, data, maybeNextTick));
sendExtMsg(new ProvideFlexRequest(tick, data, maybeNextTick));
}
}

Expand All @@ -67,7 +67,7 @@ public void sendFlexOptions(
log.debug("No em flex options found! Sending no em data to SIMONA for tick {}.", tick);
} else {
log.debug("Provided SIMONA with em flex options.");
sendExtMsg(new ProvideEmFlexOptionData(tick, data, maybeNextTick));
sendExtMsg(new ProvideEmFlexOption(tick, data, maybeNextTick));
}
}

Expand All @@ -85,7 +85,7 @@ public void sendSetPoints(
log.debug("No em set points found! Sending no em data to SIMONA for tick {}.", tick);
} else {
log.debug("Provided SIMONA with em set points.");
sendExtMsg(new ProvideEmSetPointData(tick, setPoints, maybeNextTick));
sendExtMsg(new ProvideEmSetPoint(tick, setPoints, maybeNextTick));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.Map;

/** Interface for data that are exchanged between an external simulation and SimonaAPI */
public sealed interface ExtDataContainer permits ExtInputContainer, ExtResultContainer {
public sealed interface ExtDataContainer permits ExtInputContainer, ExtOutputContainer {

/** Returns true, if the container is empty. */
boolean isEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ public void addPrimaryValue(UUID asset, Value value) {
* Method for adding flex option requests.
*
* @param receiver the uuid of the agent, that will receive the request
* @param sender option for the uuid of the sender
* @param sender uuid of the sender
*/
public void addRequest(UUID receiver, Optional<UUID> sender) {
public void addRequest(UUID receiver, UUID sender) {
flexRequests.put(receiver, new FlexOptionRequest(receiver, sender));
}

Expand Down Expand Up @@ -117,8 +117,8 @@ public void addFlexOptions(UUID receiver, List<FlexOptions> flexOption) {
* @param asset that will receive the set point
* @param power of the set point
*/
public void addSetPoint(UUID asset, PValue power) {
setPoints.put(asset, new EmSetPoint(asset, power));
public void addSetPoint(UUID asset, UUID sender, PValue power) {
setPoints.put(asset, new EmSetPoint(asset, sender, power));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
package edu.ie3.simona.api.data.container;

import edu.ie3.datamodel.models.result.ResultEntity;
import edu.ie3.simona.api.data.model.em.EmData;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;

/** Contains all SIMONA results for a certain tick. */
public final class ExtResultContainer implements ExtDataContainer {
public final class ExtOutputContainer implements ExtDataContainer {

/** Tick for which the results are meant for. */
private final long tick;
Expand All @@ -22,40 +23,63 @@ public final class ExtResultContainer implements ExtDataContainer {
private final Optional<Long> maybeNextTick;

/**
* Map uuid to result from SIMONA.
* Map receiver uuid to result from SIMONA.
*
* <p>ATTENTION: The time stamp of the result entities is not necessarily corresponding to the
* tick
*/
private final Map<UUID, ResultEntity> resultMap;

/** Map receiver uuid to {@link EmData} from SIMONA. */
private final Map<UUID, EmData> emDataMap;

/**
* Container class for result data from SIMONA.
*
* @param tick current tick
* @param resultMap results from SIMONA with external id as key
* @param nextTick tick the external simulation can expect the next results
*/
public ExtResultContainer(long tick, Map<UUID, ResultEntity> resultMap, Optional<Long> nextTick) {
public ExtOutputContainer(long tick, Optional<Long> nextTick) {
this.tick = tick;
this.resultMap = resultMap;
this.resultMap = new HashMap<>();
this.emDataMap = new HashMap<>();
this.maybeNextTick = nextTick;
}

public ExtResultContainer(long tick, Map<UUID, ResultEntity> resultMap) {
this(tick, resultMap, Optional.empty());
public ExtOutputContainer(long tick) {
this(tick, Optional.empty());
}

@Override
public boolean isEmpty() {
return resultMap.isEmpty();
return resultMap.isEmpty() && emDataMap.isEmpty();
}

public void addResult(UUID receiver, ResultEntity result) {
resultMap.put(receiver, result);
}

public void addResults(Map<UUID, ResultEntity> result) {
this.resultMap.putAll(result);
}

public void addEmData(UUID receiver, EmData emData) {
emDataMap.put(receiver, emData);
}

public void addEmData(Map<UUID, EmData> emData) {
this.emDataMap.putAll(emData);
}

/** Returns a map: uuid to result. */
public Map<UUID, ResultEntity> getResults() {
return resultMap;
}

public Map<UUID, EmData> getEmData() {
return emDataMap;
}

/**
* Method to extract results of a specific type.
*
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/edu/ie3/simona/api/data/model/em/EmData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* © 2025. 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.model.em;

import java.util.UUID;

public interface EmData {

UUID getReceiver();

UUID getSender();
}
36 changes: 25 additions & 11 deletions src/main/java/edu/ie3/simona/api/data/model/em/EmSetPoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,52 @@
/**
* Energy management set point that will be sent to SIMONA
*
* @param receiver The receiver of the message.
* @param power An option for the em set point.
* @param receiver of the message
* @param sender of the message
* @param power an option for the em set point
*/
public record EmSetPoint(UUID receiver, Optional<PValue> power) {
public record EmSetPoint(UUID receiver, UUID sender, Optional<PValue> power) implements EmData {
/**
* Constructor for {@link EmSetPoint}.
*
* <p>Note: Using this constructor will signal SIMONA, that the current set point should be kept.
*
* @param receiver of the set point.
* @param sender of the set point.
*/
public EmSetPoint(UUID receiver) {
this(receiver, Optional.empty());
public EmSetPoint(UUID receiver, UUID sender) {
this(receiver, sender, Optional.empty());
}

/**
* Constructor for {@link EmSetPoint}.
*
* @param receiver of the set point.
* @param receiver of the set point
* @param sender of the set point
* @param p power value of the set point
*/
public EmSetPoint(UUID receiver, ComparableQuantity<Power> p) {
this(receiver, Optional.of(new PValue(p)));
public EmSetPoint(UUID receiver, UUID sender, ComparableQuantity<Power> p) {
this(receiver, sender, Optional.of(new PValue(p)));
}

/**
* Constructor for {@link EmSetPoint}.
*
* @param receiver of the set point.
* @param receiver of the set point
* @param sender of the set point
* @param power value of the set point
*/
public EmSetPoint(UUID receiver, PValue power) {
this(receiver, Optional.ofNullable(power));
public EmSetPoint(UUID receiver, UUID sender, PValue power) {
this(receiver, sender, Optional.ofNullable(power));
}

@Override
public UUID getReceiver() {
return receiver;
}

@Override
public UUID getSender() {
return sender;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,23 @@

package edu.ie3.simona.api.data.model.em;

import java.util.Optional;
import java.util.UUID;

/**
* Energy management flex option request that will be sent to SIMONA
* Energy management flex option request that will be sent to SIMONA.
*
* @param receiver The receiver of the message.
* @param sender The sender of the request.
* @param receiver of the message
* @param sender of the request
*/
public record FlexOptionRequest(UUID receiver, Optional<UUID> sender) {
/**
* Constructor for {@link FlexOptionRequest}. Equals {@code new FlexOptionRequest(receiver,
* Optional.empty())}.
*
* @param receiver of the request
*/
public FlexOptionRequest(UUID receiver) {
this(receiver, Optional.empty());
public record FlexOptionRequest(UUID receiver, UUID sender) implements EmData {

@Override
public UUID getReceiver() {
return receiver;
}

/**
* Constructor for {@link FlexOptionRequest}.
*
* @param receiver of the request
* @param sender of the request
*/
public FlexOptionRequest(UUID receiver, UUID sender) {
this(receiver, Optional.ofNullable(sender));
@Override
public UUID getSender() {
return sender;
}
}
Loading