Skip to content

Commit

Permalink
Merge pull request #393 from ie3-institute/sp/#392-fix-extevdataservi…
Browse files Browse the repository at this point in the history
…ce-departures

Fix awaited evcs departure responses
  • Loading branch information
danielfeismann authored Oct 24, 2022
2 parents c2ee2bb + 8ebee4f commit 8a162c7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed config of vn_146_lv_small [#290](https://github.com/ie3-institute/simona/issues/290)
- Adapted to changes of EvcsInput in PSDM [#377](https://github.com/ie3-institute/simona/pull/377)
- Fix breaking SIMONA caused by changes in simonaAPI [#384] (https://github.com/ie3-institute/simona/issues/384)
- Fixed awaiting departed EVs in ExtEvDataService [#392](https://github.com/ie3-institute/simona/issues/392)

### Removed
- Remove workaround for tscfg tmp directory [#178](https://github.com/ie3-institute/simona/issues/178)
Expand Down
33 changes: 17 additions & 16 deletions src/main/scala/edu/ie3/simona/service/ev/ExtEvDataService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -227,26 +227,27 @@ class ExtEvDataService(override val scheduler: ActorRef)
serviceStateData: ExtEvStateData
): (ExtEvStateData, Option[Seq[ScheduleTriggerMessage]]) = {

requestedDepartingEvs.asScala.foreach { case (evcs, departingEvs) =>
serviceStateData.uuidToActorRef.get(evcs) match {
case Some(evcsActor) =>
evcsActor ! DepartingEvsRequest(tick, departingEvs.asScala.toSeq)
case None =>
log.warning(
"A corresponding actor ref for UUID {} could not be found",
evcs
)
}
}

val departingEvResponses: Map[UUID, Option[Seq[EvModel]]] =
serviceStateData.uuidToActorRef.map { case (evcs, _) =>
evcs -> None
}
requestedDepartingEvs.asScala.flatMap { case (evcs, departingEvs) =>
serviceStateData.uuidToActorRef.get(evcs) match {
case Some(evcsActor) =>
evcsActor ! DepartingEvsRequest(tick, departingEvs.asScala.toSeq)

Some(evcs -> None)

case None =>
log.warning(
"A corresponding actor ref for UUID {} could not be found",
evcs
)

None
}
}.toMap

// if there are no departing evs during this tick,
// we're sending response right away
if (requestedDepartingEvs.isEmpty)
if (departingEvResponses.isEmpty)
serviceStateData.extEvData.queueExtResponseMsg(new ProvideDepartingEvs())

(
Expand Down

0 comments on commit 8a162c7

Please sign in to comment.