Skip to content

Commit

Permalink
refactor providing controllingEm to reviewers comments
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfeismann committed Jul 4, 2024
1 parent b37d99c commit bc214b6
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,16 @@ class GridAgentController(
val node = participant.getNode

val controllingEm =
participant.getControllingEm.toScala.flatMap(em => Option(em.getUuid))
val emActorRef = controllingEm.flatMap(uuid => allEms.get(uuid))
participant.getControllingEm.toScala
.map(_.getUuid)
.map(uuid =>
allEms.getOrElse(
uuid,
throw new CriticalFailureException(
s"EM actor with UUID $uuid not found."
),
)
)

val actorRef = buildParticipantActor(
participantsConfig.requestVoltageDeviationThreshold,
Expand All @@ -212,7 +220,7 @@ class GridAgentController(
participant,
thermalIslandGridsByBusId,
environmentRefs,
emActorRef,
controllingEm,
)
introduceAgentToEnvironment(actorRef)
// return uuid to actorRef
Expand Down

0 comments on commit bc214b6

Please sign in to comment.