Skip to content

Commit 6cda87a

Browse files
committed
Including reviewer's comments.
1 parent aac91bf commit 6cda87a

File tree

6 files changed

+20
-148
lines changed

6 files changed

+20
-148
lines changed

src/main/java/edu/ie3/simona/api/data/connection/ExtEmDataConnection.java

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,6 @@ public List<UUID> getControlledEms() {
3232
return new ArrayList<>(controlled);
3333
}
3434

35-
/**
36-
* Tries to send flex option requests to SIMONA. A message is sent, if at least one entity is
37-
* given.
38-
*
39-
* @param tick current tick
40-
* @param entities for which flex options should be requested
41-
* @param disaggregated if disaggregated flex option should be returned
42-
* @return true, if data was sent
43-
*/
44-
public boolean sendFlexRequest(long tick, Collection<UUID> entities, boolean disaggregated) {
45-
// create requests
46-
Map<UUID, FlexOptionRequest> requests = new HashMap<>();
47-
entities.forEach(
48-
emEntity -> requests.put(emEntity, new FlexOptionRequest(emEntity, disaggregated)));
49-
50-
// send message only if at least one value is present
51-
if (!entities.isEmpty()) {
52-
sendExtMsg(new ProvideEmData(tick, requests, Collections.emptyMap(), Collections.emptyMap()));
53-
return true;
54-
}
55-
return false;
56-
}
57-
5835
/**
5936
* Tries to send em data to SIMONA. A message is sent, if the map is not empty.
6037
*
@@ -116,13 +93,18 @@ public boolean sendCommunicationMessage(
11693
* Method to request em flexibility options from SIMONA.
11794
*
11895
* @param tick for which set points are requested
119-
* @param emEntities for which set points are requested
96+
* @param entities for which set points are requested
12097
* @return a map: uuid to list of flex options
12198
* @throws InterruptedException - on interruptions
12299
*/
123100
public Map<UUID, List<FlexOptions>> requestEmFlexResults(
124-
long tick, List<UUID> emEntities, boolean disaggregated) throws InterruptedException {
125-
sendFlexRequest(tick, emEntities, disaggregated);
101+
long tick, List<UUID> entities, boolean disaggregated) throws InterruptedException {
102+
// create requests
103+
Map<UUID, FlexOptionRequest> requests = new HashMap<>();
104+
entities.forEach(
105+
emEntity -> requests.put(emEntity, new FlexOptionRequest(emEntity, disaggregated)));
106+
107+
sendExtMsg(new ProvideEmData(tick, requests, Collections.emptyMap(), Collections.emptyMap()));
126108
return receiveWithType(FlexOptionsResponse.class).receiverToFlexOptions();
127109
}
128110

src/main/java/edu/ie3/simona/api/data/model/em/GeneralFlexOptions.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ public GeneralFlexOptions(
6060
new HashMap<>());
6161
}
6262

63-
@Override
64-
public UUID receiver() {
65-
return receiver;
66-
}
67-
6863
@Override
6964
public void addDisaggregated(UUID model, FlexOptions flexOptions) {
7065
disaggregated.put(model, flexOptions);

src/main/java/edu/ie3/simona/api/data/model/em/PowerLimitFlexOptions.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ public PowerLimitFlexOptions(
4444
this(receiver, model, pRef, pMin, pMax, new HashMap<>());
4545
}
4646

47-
@Override
48-
public UUID receiver() {
49-
return receiver;
50-
}
51-
5247
@Override
5348
public void addDisaggregated(UUID model, FlexOptions flexOptions) {
5449
disaggregated.put(model, flexOptions);

src/main/java/edu/ie3/simona/api/simulation/ExtCoSimulation.java

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import edu.ie3.simona.api.data.connection.ExtResultDataConnection;
1515
import edu.ie3.simona.api.data.container.ExtInputContainer;
1616
import edu.ie3.simona.api.data.container.ExtOutputContainer;
17-
import edu.ie3.simona.api.data.model.em.EmSetPoint;
1817
import edu.ie3.simona.api.exceptions.ExtDataConnectionException;
1918
import java.util.List;
2019
import java.util.Map;
@@ -131,49 +130,6 @@ protected void sendPrimaryDataToSimona(
131130
log.debug("Provided Primary Data to SIMONA!");
132131
}
133132

134-
// energy management data methods
135-
136-
/**
137-
* Function to send em set point data to SIMONA using the given {@link ExtEmDataConnection}. This
138-
* method will take a value from the {@link #queueToSimona}.
139-
*
140-
* <p>{@code nextTick} is necessary, because the em agents have an own scheduler that should know,
141-
* when the next set point arrives.
142-
*
143-
* @param extEmDataConnection the connection to SIMONA
144-
* @param tick for which data is sent
145-
* @param log logger
146-
* @throws InterruptedException if the fetching of data is interrupted
147-
*/
148-
protected void sendEmSetPointsToSimona(
149-
ExtEmDataConnection extEmDataConnection, long tick, Logger log) throws InterruptedException {
150-
Map<UUID, EmSetPoint> inputData = queueToSimona.takeData(ExtInputContainer::extractSetPoints);
151-
152-
sendEmSetPointsToSimona(extEmDataConnection, tick, inputData, log);
153-
}
154-
155-
/**
156-
* Function to send em data to SIMONA using ExtPrimaryData nextTick is necessary, because the em
157-
* agents have an own scheduler that should know, when the next set point arrives.
158-
*
159-
* @param extEmDataConnection the connection to SIMONA
160-
* @param tick for which data is sent
161-
* @param setPoints map: id to set point
162-
* @param log logger
163-
*/
164-
protected void sendEmSetPointsToSimona(
165-
ExtEmDataConnection extEmDataConnection,
166-
long tick,
167-
Map<UUID, EmSetPoint> setPoints,
168-
Logger log) {
169-
log.debug("Received em set points from {}", extSimulatorName);
170-
boolean wasSent = extEmDataConnection.sendEmData(tick, setPoints, log);
171-
if (!wasSent) {
172-
log.debug("No set point data was sent to SIMONA!");
173-
}
174-
log.debug("Provided em set points to SIMONA!");
175-
}
176-
177133
// result data methods
178134

179135
/**

src/test/groovy/edu/ie3/simona/api/data/connection/ExtEmDataConnectionTest.groovy

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package edu.ie3.simona.api.data.connection
22

33
import edu.ie3.simona.api.data.connection.ExtEmDataConnection.EmMode
44
import edu.ie3.simona.api.data.model.em.EmCommunicationMessage
5+
import edu.ie3.simona.api.data.model.em.EmSetPoint
56
import edu.ie3.simona.api.data.model.em.FlexOptionRequest
67
import edu.ie3.simona.api.data.model.em.PowerLimitFlexOptions
78
import edu.ie3.simona.api.ontology.DataMessageFromExt
@@ -72,24 +73,6 @@ class ExtEmDataConnectionTest extends Specification implements DataServiceTestDa
7273
extSimAdapter.expectMessage(new ScheduleDataServiceMessage(dataService.ref()))
7374
}
7475

75-
def "ExtEmDataConnection should send no message, if no flex requests are given"() {
76-
given:
77-
def dataService = testKit.createTestProbe(DataMessageFromExt)
78-
def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage)
79-
def extEmDataConnection = new ExtEmDataConnection(controlled, EmMode.BASE)
80-
extEmDataConnection.setActorRefs(
81-
dataService.ref(),
82-
extSimAdapter.ref()
83-
)
84-
85-
when:
86-
def wasSent = extEmDataConnection.sendEmData(0L, [:], [:], [:])
87-
88-
then:
89-
!wasSent
90-
dataService.expectNoMessage()
91-
}
92-
9376
def "ExtEmDataConnection should provide em flex options correctly"() {
9477
given:
9578
def dataService = testKit.createTestProbe(DataMessageFromExt)
@@ -111,7 +94,7 @@ class ExtEmDataConnectionTest extends Specification implements DataServiceTestDa
11194
extSimAdapter.expectMessage(new ScheduleDataServiceMessage(dataService.ref()))
11295
}
11396

114-
def "ExtEmDataConnection should send no message, if no flex options are given"() {
97+
def "ExtEmDataConnection should provide em set points correctly"() {
11598
given:
11699
def dataService = testKit.createTestProbe(DataMessageFromExt)
117100
def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage)
@@ -121,15 +104,18 @@ class ExtEmDataConnectionTest extends Specification implements DataServiceTestDa
121104
extSimAdapter.ref()
122105
)
123106

107+
def emData = Map.of(inputUuid, new EmSetPoint(inputUuid, power))
108+
124109
when:
125-
def wasSent = extEmDataConnection.sendEmData(0L, [:], [:], [:])
110+
def wasSent = extEmDataConnection.sendEmData(0L, [:], [:], emData)
126111

127112
then:
128-
!wasSent
129-
dataService.expectNoMessage()
113+
wasSent
114+
dataService.expectMessage(new ProvideEmData(0, [:], [:], emData))
115+
extSimAdapter.expectMessage(new ScheduleDataServiceMessage(dataService.ref()))
130116
}
131117

132-
def "ExtEmDataConnection should provide flex option requests correctly"() {
118+
def "ExtEmDataConnection should send no message, if no em data is given"() {
133119
given:
134120
def dataService = testKit.createTestProbe(DataMessageFromExt)
135121
def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage)
@@ -140,12 +126,11 @@ class ExtEmDataConnectionTest extends Specification implements DataServiceTestDa
140126
)
141127

142128
when:
143-
def wasSent = extEmDataConnection.sendFlexRequest(0L, [inputUuid], true)
129+
def wasSent = extEmDataConnection.sendEmData(0L, [:], [:], [:])
144130

145131
then:
146-
wasSent
147-
dataService.expectMessage( new ProvideEmData(0, [(inputUuid): new FlexOptionRequest(inputUuid, true)], [:], [:]))
148-
extSimAdapter.expectMessage(new ScheduleDataServiceMessage(dataService.ref()))
132+
!wasSent
133+
dataService.expectNoMessage()
149134
}
150135

151136
def "ExtEmDataConnection should provide communication messages correctly"() {

src/test/groovy/edu/ie3/simona/api/simulation/ExtCoSimulationTest.groovy

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -133,45 +133,4 @@ class ExtCoSimulationTest extends Specification {
133133
ex.message == "The external data connection 'ExtResultDataConnection' could not be build!"
134134
}
135135

136-
def "An ExtCoSimulation should sent em set point data correctly"() {
137-
given:
138-
def extEmDataConnection = new ExtEmDataConnection([], EmMode.BASE)
139-
def dataService = testKit.createTestProbe(DataMessageFromExt)
140-
141-
def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage)
142-
extEmDataConnection.setActorRefs(
143-
dataService.ref(),
144-
extSimAdapter.ref()
145-
)
146-
147-
def data = [(UUID.randomUUID()): new EmSetPoint(UUID.randomUUID())]
148-
149-
when:
150-
sim.sendEmSetPointsToSimona(extEmDataConnection, 0L, data, log)
151-
152-
then:
153-
dataService.expectMessage(new ProvideEmData(0L, [:], [:], data))
154-
}
155-
156-
def "An ExtCoSimulation should not sent empty em set point data"() {
157-
given:
158-
def extEmDataConnection = new ExtEmDataConnection([], EmMode.BASE)
159-
def dataService = testKit.createTestProbe(DataMessageFromExt)
160-
161-
def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage)
162-
extEmDataConnection.setActorRefs(
163-
dataService.ref(),
164-
extSimAdapter.ref()
165-
)
166-
167-
def data = [:]
168-
169-
when:
170-
sim.sendEmSetPointsToSimona(extEmDataConnection, 0L, data, log)
171-
172-
then:
173-
dataService.expectNoMessage()
174-
extSimAdapter.expectNoMessage()
175-
}
176-
177136
}

0 commit comments

Comments
 (0)