Skip to content

Commit

Permalink
Sending results
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Peter <[email protected]>
  • Loading branch information
sebastian-peter committed Nov 1, 2024
1 parent a3a1fc0 commit 33e5a95
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import edu.ie3.simona.agent.grid.GridAgentMessages.{
}
import edu.ie3.simona.agent.participant.data.Data
import edu.ie3.simona.agent.participant.data.Data.SecondaryData
import edu.ie3.simona.event.ResultEvent
import edu.ie3.simona.event.ResultEvent.ParticipantResultEvent
import edu.ie3.simona.exceptions.CriticalFailureException
import edu.ie3.simona.model.participant2.ParticipantModelShell
import edu.ie3.simona.ontology.messages.SchedulerMessage.Completion
Expand Down Expand Up @@ -142,13 +144,20 @@ object ParticipantAgent {
modelShell: ParticipantModelShell[_, _, _],
inputHandler: ParticipantInputHandler,
gridAdapter: ParticipantGridAdapter,
resultListener: Iterable[ActorRef[ResultEvent]],
parentData: Either[SchedulerData, FlexControlledData],
): Behavior[Request] =
Behaviors.receivePartial {
case (ctx, request: ParticipantRequest) =>
val updatedShell = modelShell.handleRequest(ctx, request)

ParticipantAgent(updatedShell, inputHandler, gridAdapter, parentData)
ParticipantAgent(
updatedShell,
inputHandler,
gridAdapter,
resultListener,
parentData,
)

case (_, activation: ActivationRequest) =>
val coreWithActivation = inputHandler.handleActivation(activation)
Expand All @@ -158,26 +167,35 @@ object ParticipantAgent {
modelShell,
coreWithActivation,
gridAdapter,
resultListener,
parentData,
)

ParticipantAgent(
updatedShell,
updatedCore,
updatedGridAdapter,
resultListener,
parentData,
)

case (_, msg: ProvisionMessage[Data]) =>
val coreWithData = inputHandler.handleDataProvision(msg)

val (updatedShell, updatedCore, updatedGridAdapter) =
maybeCalculate(modelShell, coreWithData, gridAdapter, parentData)
maybeCalculate(
modelShell,
coreWithData,
gridAdapter,
resultListener,
parentData,
)

ParticipantAgent(
updatedShell,
updatedCore,
updatedGridAdapter,
resultListener,
parentData,
)

Expand Down Expand Up @@ -224,6 +242,7 @@ object ParticipantAgent {
modelShell,
inputHandler,
updatedGridAdapter,
resultListener,
parentData,
)

Expand All @@ -235,6 +254,7 @@ object ParticipantAgent {
modelShell,
inputHandler,
updatedGridAdapter,
resultListener,
parentData,
)
}
Expand All @@ -243,6 +263,7 @@ object ParticipantAgent {
modelShell: ParticipantModelShell[_, _, _],
inputHandler: ParticipantInputHandler,
gridAdapter: ParticipantGridAdapter,
listener: Iterable[ActorRef[ResultEvent]],
parentData: Either[SchedulerData, FlexControlledData],
): (
ParticipantModelShell[_, _, _],
Expand Down Expand Up @@ -281,7 +302,8 @@ object ParticipantAgent {
val results =
modelWithOP.determineResults(tick, gridAdapter.nodalVoltage)

results.modelResults.foreach { res => // todo send out results
results.modelResults.foreach { res =>
listener.foreach(_ ! ParticipantResultEvent(res))
}

val gridAdapterWithResult =
Expand Down Expand Up @@ -326,7 +348,8 @@ object ParticipantAgent {
gridAdapter.nodalVoltage,
)

results.modelResults.foreach { res => // todo send out results
results.modelResults.foreach { res =>
listener.foreach(_ ! ParticipantResultEvent(res))
}

val gridAdapterWithResult =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ object ParticipantAgentInit {
modelShell,
ParticipantInputHandler(expectedData),
ParticipantGridAdapter(gridAgentRef, expectedPowerRequestTick),
???,
parentData,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ object ParticipantModelInit {
}).build()

(scaledParticipantInput, modelConfig) match {
// fixme ticks not scheduled for fixed feed-in/load models
case (input: FixedFeedInInput, _) =>
val model = FixedFeedInModel(input)
val state = model.getInitialState
Expand Down

0 comments on commit 33e5a95

Please sign in to comment.