Skip to content

Commit

Permalink
Merge branch 'sp/#204-EmAgent' into sp/#000-em-combined
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-peter committed Nov 9, 2022
2 parents 7948b75 + e3120ee commit 9e6f7d1
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/main/scala/edu/ie3/simona/agent/participant/em/EmAgent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -591,17 +591,32 @@ class EmAgent(
(spi, flexOption)
}.toSeq
)

// TODO sanity checks after strat calculation
.toMap

val issueCtrlMsgsComplete = flexData.flatMap {
case (spi, correspondence, dataTick) =>
issueCtrlMsgs
.find { case (uuid, _) =>
uuid.equals(spi.getUuid)
}
.map { case (uuid, power) =>
uuid -> IssuePowerCtrl(tick, power)
.get(spi.getUuid)
.map { power =>
correspondence.receivedFlexOptions.getOrElse(
throw new RuntimeException(
s"FlexOptions not found for ${spi.getUuid}"
)
) match {
case ProvideMinMaxFlexOptions(uuid, _, minPower, maxPower) =>
// sanity checks after strat calculation
if (power.isLessThan(minPower))
throw new RuntimeException(
s"The set power $power for $uuid must not be lower than the minimum power $minPower!"
)
if (power.isGreaterThan(maxPower)) {
throw new RuntimeException(
s"The set power $power for $uuid must not be greater than the maximum power $maxPower!"
)
}
}

spi.getUuid -> IssuePowerCtrl(tick, power)
}
.orElse {
// no power ctrl message has been set for this participant.
Expand Down

0 comments on commit 9e6f7d1

Please sign in to comment.