Skip to content

Commit f578174

Browse files
committed
Enhanced ExtEmDataConnection with simulateInternal method
1 parent 2fb79ba commit f578174

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased/Snapshot]
88

99
### Added
10+
- Enhanced `ExtEmDataConnection` with `simulateInternal` method [#398](https://github.com/ie3-institute/simonaAPI/issues/398)
1011

1112
### Changed
1213

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

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

35+
/**
36+
* Tells the em service in SIMONA to simulate the given tick internally. This should be used, when
37+
* the external simulation will not provide data for the tick.
38+
*
39+
* @param tick that should be simulated internally
40+
*/
41+
public void simulateInternal(long tick) {
42+
sendExtMsg(new EmSimulationInternal(tick));
43+
}
44+
3545
/**
3646
* Tries to send em data to SIMONA. A message is sent, if the map is not empty.
3747
*
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* © 2025. TU Dortmund University,
3+
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
4+
* Research group Distribution grid planning and operation
5+
*/
6+
7+
package edu.ie3.simona.api.ontology.em;
8+
9+
/**
10+
* Request send to SIMONA to simulate ems internally for the given tick.
11+
*
12+
* @param tick for which the em service should simulate internally
13+
*/
14+
public record EmSimulationInternal(long tick) implements EmDataMessageFromExt {}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,24 @@ class ExtEmDataConnectionTest extends Specification implements DataServiceTestDa
3030
testKit = null
3131
}
3232

33+
def "ExtEmDataConnection should sent request to simulate internally correctly"() {
34+
given:
35+
def dataService = testKit.createTestProbe(DataMessageFromExt)
36+
def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage)
37+
def extEmDataConnection = new ExtEmDataConnection(controlled, EmMode.BASE)
38+
extEmDataConnection.setActorRefs(
39+
dataService.ref(),
40+
extSimAdapter.ref()
41+
)
42+
43+
when:
44+
extEmDataConnection.simulateInternal(800L)
45+
46+
then:
47+
dataService.expectMessage(new EmSimulationInternal(800L))
48+
extSimAdapter.expectMessage(new ScheduleDataServiceMessage(dataService.ref()))
49+
}
50+
3351
def "ExtEmDataConnection should provide em data correctly"() {
3452
given:
3553
def dataService = testKit.createTestProbe(DataMessageFromExt)

0 commit comments

Comments
 (0)