Skip to content

Commit

Permalink
Merge branch 'refs/heads/dev' into df/#878-thermalGridIT
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
danielfeismann committed Aug 8, 2024
2 parents 14d2b05 + 1538700 commit ca0179a
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Implementation of StorageAgent [#309](https://github.com/ie3-institute/simona/issues/309)
- Enhanced Newton-Raphson-PowerFlow failures with more information [#815](https://github.com/ie3-institute/simona/issues/815)
- Update RTD references and bibliography [#868](https://github.com/ie3-institute/simona/issues/868)
- Add gradle application plugin for command line execution with gradle run [#890](https://github.com/ie3-institute/simona/issues/890)
- Integration test for thermal grids [#878](https://github.com/ie3-institute/simona/issues/878)

### Changed
Expand Down Expand Up @@ -90,6 +91,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed result output for thermal houses and cylindrical storages [#844](https://github.com/ie3-institute/simona/issues/844)
- Fixed FixedFeedModelSpec [#861](https://github.com/ie3-institute/simona/issues/861)
- Fixing duration calculation in result events [#801](https://github.com/ie3-institute/simona/issues/801)
- Handle MobSim requests for current prices [#892](https://github.com/ie3-institute/simona/issues/892)
- Fixed Hp results leading to overheating house and other effects [#827](https://github.com/ie3-institute/simona/issues/827)
- Fixed thermal storage getting recharged when empty [#827](https://github.com/ie3-institute/simona/issues/827)
- Provide actual ambient temperature of tick to HpModel when calculate state [#882](https://github.com/ie3-institute/simona/issues/882)
Expand Down
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ plugins {
id "com.github.maiflai.scalatest" version "0.32" // run scalatest without specific spec task
id 'org.hidetake.ssh' version '2.11.2'
id 'net.thauvin.erik.gradle.semver' version '1.0.4' // semantic versioning
id "application"
}

ext {
Expand Down Expand Up @@ -166,6 +167,11 @@ jar {
}
}

// Run with ./gradlew run --args='--config /path/to/simona.conf'
application {
mainClassName = jar.manifest.attributes.get('Main-Class')
}

//////////////////////////////////////////////////////////////////////
// Build pekko'able fat jar using the gradle shadow plugin
// see http://www.sureshpw.com/2015/10/building-akka-bundle-with-all.html
Expand Down
2 changes: 1 addition & 1 deletion docs/readthedocs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Sphinx==7.3.7
sphinx-rtd-theme==2.0.0
sphinxcontrib-plantuml==0.30
myst-parser==3.0.1
myst-parser==4.0.0
markdown-it-py==3.0.0
sphinx-hoverxref==1.4.0
sphinxcontrib-bibtex==2.6.2
24 changes: 23 additions & 1 deletion src/main/scala/edu/ie3/simona/service/ev/ExtEvDataService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ class ExtEvDataService(override val scheduler: ActorRef)
"ExtEvDataService was triggered without ExtEvMessage available"
)
) match {
case _: RequestCurrentPrices =>
requestCurrentPrices()
case _: RequestEvcsFreeLots =>
requestFreeLots(tick)
case departingEvsRequest: RequestDepartingEvs =>
Expand All @@ -192,6 +194,26 @@ class ExtEvDataService(override val scheduler: ActorRef)
}
}

private def requestCurrentPrices()(implicit
serviceStateData: ExtEvStateData
): (ExtEvStateData, Option[Long]) = {
// currently not supported, return dummy
val dummyPrice = double2Double(0d)
val prices = serviceStateData.uuidToActorRef.map { case (evcs, _) =>
evcs -> dummyPrice
}
serviceStateData.extEvData.queueExtResponseMsg(
new ProvideCurrentPrices(prices.asJava)
)

(
serviceStateData.copy(
extEvMessage = None
),
None,
)
}

private def requestFreeLots(tick: Long)(implicit
serviceStateData: ExtEvStateData
): (ExtEvStateData, Option[Long]) = {
Expand Down Expand Up @@ -351,7 +373,7 @@ class ExtEvDataService(override val scheduler: ActorRef)
freeLotsCount > 0
}
.map { case (evcs, freeLotsCount) =>
evcs -> Integer.valueOf(freeLotsCount)
evcs -> int2Integer(freeLotsCount)
}

serviceStateData.extEvData.queueExtResponseMsg(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,70 @@ class ExtEvDataServiceSpec
extData.receiveTriggerQueue.size() shouldBe 1
// only evcs 1 should be included, the other one is full
extData.receiveTriggerQueue.take() shouldBe new ProvideEvcsFreeLots(
Map(evcs1UUID -> Integer.valueOf(2)).asJava
Map(evcs1UUID -> int2Integer(2)).asJava
)
}

"handle price requests correctly by returning dummy values" in {
val evService = TestActorRef(new ExtEvDataService(scheduler.ref))

val extData = extEvData(evService)

val key =
ScheduleLock.singleKey(TSpawner, scheduler.ref.toTyped, INIT_SIM_TICK)
scheduler.expectMsgType[ScheduleActivation] // lock activation scheduled

scheduler.send(
evService,
SimonaService.Create(InitExtEvData(extData), key),
)
scheduler.expectMsgType[ScheduleActivation]

scheduler.send(evService, Activation(INIT_SIM_TICK))
scheduler.expectMsg(Completion(evService.toTyped))

val evcs1 = TestProbe("evcs1")
val evcs2 = TestProbe("evcs2")

evcs1.send(evService, RegisterForEvDataMessage(evcs1UUID))
evcs1.expectMsgType[RegistrationSuccessfulMessage]

evcs2.send(evService, RegisterForEvDataMessage(evcs2UUID))
evcs2.expectMsgType[RegistrationSuccessfulMessage]

extData.sendExtMsg(new RequestCurrentPrices())

// ev service should receive request at this moment
// scheduler should receive schedule msg
extSimAdapter.expectMsg(new ScheduleDataServiceMessage(evService))

val tick = 0L

// we trigger ev service
scheduler.send(evService, Activation(tick))

evcs1.expectNoMessage()
evcs2.expectNoMessage()

// ev service should recognize that all evcs that are expected are returned,
// thus should send ProvideEvcsFreeLots
awaitCond(
!extData.receiveTriggerQueue.isEmpty,
max = 3.seconds,
message = "No message received",
)
extData.receiveTriggerQueue.size() shouldBe 1
// only evcs 1 should be included, the other one is full
extData.receiveTriggerQueue.take() shouldBe new ProvideCurrentPrices(
Map(
evcs1UUID -> double2Double(0d),
evcs2UUID -> double2Double(0d),
).asJava
)

scheduler.expectMsg(Completion(evService.toTyped))
}

"return free lots requests right away if there are no evcs registered" in {
val evService = TestActorRef(new ExtEvDataService(scheduler.ref))

Expand Down

0 comments on commit ca0179a

Please sign in to comment.