-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into jb/#671-externaldatase…
…rvice # Conflicts: # src/main/scala/edu/ie3/simona/event/listener/ResultEventListener.scala # src/main/scala/edu/ie3/simona/sim/SimonaSim.scala # src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala # src/main/scala/edu/ie3/simona/sim/setup/SimonaStandaloneSetup.scala # src/test/scala/edu/ie3/simona/sim/SimonaSimFailSpec.scala # src/test/scala/edu/ie3/simona/sim/setup/SimonaSetupSpec.scala
- Loading branch information
Showing
38 changed files
with
1,121 additions
and
922 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/scala/edu/ie3/simona/event/listener/DelayedStopHelper.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* © 2024. TU Dortmund University, | ||
* Institute of Energy Systems, Energy Efficiency and Energy Economics, | ||
* Research group Distribution grid planning and operation | ||
*/ | ||
|
||
package edu.ie3.simona.event.listener | ||
|
||
import org.apache.pekko.actor.typed.Behavior | ||
import org.apache.pekko.actor.typed.scaladsl.{ActorContext, Behaviors} | ||
|
||
import scala.concurrent.duration.DurationInt | ||
|
||
/** Helper that provides functionality for delayed stopping of actors, i.e. upon | ||
* receiving [[FlushAndStop]], the actor is stopped after a fixed amount of | ||
* time after the last message has been received | ||
*/ | ||
object DelayedStopHelper { | ||
|
||
/** Note: Needs to extend be message traits for actors that want to use this | ||
* functionality | ||
*/ | ||
sealed trait StoppingMsg | ||
extends ResultEventListener.Request | ||
with RuntimeEventListener.Request | ||
|
||
/** Message indicating that [[RuntimeEventListener]] should stop. Instead of | ||
* using [[org.apache.pekko.actor.typed.scaladsl.ActorContext.stop]], this | ||
* way of stopping allows the current mailbox to be processed, plus more | ||
* messages that are pending to be received. | ||
*/ | ||
case object FlushAndStop extends StoppingMsg | ||
|
||
private case object StopTimeout extends StoppingMsg | ||
|
||
def handleMsg[T >: StoppingMsg] | ||
: PartialFunction[(ActorContext[T], StoppingMsg), Behavior[T]] = { | ||
|
||
case (ctx, FlushAndStop) => | ||
ctx.log.debug( | ||
s"Received FlushAndStop message, shutting down once no message has been received for 5 seconds." | ||
) | ||
ctx.setReceiveTimeout(5.seconds, StopTimeout) | ||
Behaviors.same | ||
|
||
case (ctx, StopTimeout) => | ||
// there have been no messages for 5 seconds, let's end this | ||
ctx.log.debug(s"${getClass.getSimpleName} is now stopped.") | ||
Behaviors.stopped | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.