Skip to content

Commit

Permalink
Merge pull request #406 from ie3-institute/ms/#405-fixing-small-bugs-…
Browse files Browse the repository at this point in the history
…that-prevent-OSMoGrid-from-running

Fixing some small bugs.
  • Loading branch information
danielfeismann committed Apr 25, 2024
2 parents f83190d + 60bd292 commit 72e045c
Show file tree
Hide file tree
Showing 27 changed files with 866 additions and 1,093 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -36,12 +36,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Workaround for `spotless`: Add module exports to `gradle.properties`
- Update to PSDM 4.1.0
- Replaced akka with pekko [#345](https://github.com/ie3-institute/OSMoGrid/issues/345)
- Improved `SubGridHandling` [#397](https://github.com/ie3-institute/OSMoGrid/issues/397)

### Fixed
- Fixed bug in `LvGridGeneratorSupport` [#388](https://github.com/ie3-institute/OSMoGrid/issues/388)
- `getConnection` in `Connections` will return an option [#392](https://github.com/ie3-institute/OSMoGrid/issues/392)
- Changed some `ParSeq` in `LvGraphGeneratorSupport` to Seq [#387](https://github.com/ie3-institute/OSMoGrid/issues/387)
- LV Coordinator dies unexpectedly [#361](https://github.com/ie3-institute/OSMoGrid/issues/361)
- Some bugs fixed [#405](https://github.com/ie3-institute/OSMoGrid/issues/405)

### Removed
- Legacy Java code
Expand Down
1 change: 1 addition & 0 deletions input/fuerweiler/assets/transformer_2_w_type_input.csv
@@ -1,3 +1,4 @@
"uuid","b_m","d_phi","d_v","g_m","id","r_sc","s_rated","tap_max","tap_min","tap_neutr","tap_side","v_rated_a","v_rated_b","x_sc"
4984f493-d6e5-4201-a040-c10722b30362,0.0,0.0,0.5,0.0,MS-NS_1,10.078,630.0,10,-10,0,false,20.0,0.4,23.312
a0cbd90a-4e9f-47db-8dca-041d3a288f77,145.8952227629774,0.0,2.5,16500.0,0.63 MVA 10/0.4 kV Dyn5 ASEA,1.7384731670445954,630.0,2,-2,0,false,10.0,0.4,9.36379511166658
b49db20f-b8b5-4265-8318-f669b9d121e9,1015.6886939330394,0.0,1.5,1818.181818181818,63 MVA 110/10 kV YNd5,0.6146031746031745,63000.0,9,-9,0,false,110.0,10.0,34.56596500037509
10 changes: 4 additions & 6 deletions src/main/scala/edu/ie3/osmogrid/cfg/ConfigFailFast.scala
Expand Up @@ -36,13 +36,11 @@ object ConfigFailFast extends LazyLogging {
generation match {
case Generation(lv, mv) =>
/* Check, that at least one config is set */
if (Vector(lv).count(_.isDefined) < 1)
throw IllegalConfigException(
"At least one lv voltage level generation config has to be defined."
)
if (Vector(mv).count(_.isDefined) < 1)
val defined = Seq(lv, mv).count(_.isDefined)

if (defined < 1)
throw IllegalConfigException(
"At least one mv voltage level generation config has to be defined."
"At least one generation config has to be defined."
)

/* Check single configs */
Expand Down
48 changes: 35 additions & 13 deletions src/main/scala/edu/ie3/osmogrid/guardian/run/RunGuardian.scala
Expand Up @@ -115,61 +115,82 @@ object RunGuardian
case (
ctx,
WrappedLvCoordinatorResponse(
RepLvGrids(subGridContainers, streetGraph)
RepLvGrids(subGridContainer, streetGraph)
)
) =>
ctx.log.info(s"Received lv grids.")

// lv coordinator is now allowed to die in peace
childReferences.lvCoordinator.foreach(ctx.unwatch)
val updatedChildReferences = childReferences.copy(lvCoordinator = None)

// if a mv coordinator is present, send the lv results to the mv coordinator
childReferences.mvCoordinator.foreach { mv =>
mv ! WrappedMvResponse(
ProvidedLvData(subGridContainers, streetGraph)
ProvidedLvData(subGridContainer, streetGraph)
)
}

val updated = finishedGridData.copy(lvData = Some(subGridContainers))
// store sub grids if they should be put out
val option = if (finishedGridData.lvExpected) {
Some(subGridContainer)
} else None

val updated = finishedGridData.copy(lvData = option)

// check if all possible data was received
if (updated.receivedAllData) {

// if all data was received,
ctx.self ! HandleGridResults
Behaviors.same
running(runGuardianData, updatedChildReferences, updated)
} else {

// if some expected data is still missing, keep waiting for missing data
running(runGuardianData, childReferences, updated)
running(runGuardianData, updatedChildReferences, updated)
}

case (
ctx,
WrappedMvCoordinatorResponse(
RepMvGrids(subGridContainer, nodeChanges, assetInformation)
RepMvGrids(
subGridContainer,
dummyHvGrid,
nodeChanges,
assetInformation
)
)
) =>
ctx.log.info(s"Received mv grids.")

// mv coordinator is now allowed to die in peace
childReferences.mvCoordinator.foreach(ctx.unwatch)
val updatedChildReferences = childReferences.copy(mvCoordinator = None)

// store sub grids if they should be put out
val option = if (finishedGridData.mvExpected) {
Some(subGridContainer)
} else None

val nodeUpdates = Option.when(nodeChanges.nonEmpty)(nodeChanges)

val updated = finishedGridData.copy(
mvData = Some(subGridContainer),
toBeUpdated = Some((nodeChanges, assetInformation))
mvData = option,
hvData = dummyHvGrid.map(Seq(_)), // converting to sequence
mvNodeChanges = nodeUpdates,
assetInformation = Some(assetInformation)
)

// check if all possible data was received
if (updated.receivedAllData) {

// if all data was received,
ctx.self ! HandleGridResults
Behaviors.same
running(runGuardianData, updatedChildReferences, updated)
} else {

// if some expected data is still missing, keep waiting for missing data
running(runGuardianData, childReferences, updated)
running(runGuardianData, updatedChildReferences, updated)
}

case (ctx, HandleGridResults) =>
Expand All @@ -178,13 +199,14 @@ object RunGuardian
handleResults(
finishedGridData.lvData,
finishedGridData.mvData,
None,
finishedGridData.toBeUpdated,
finishedGridData.hvData,
finishedGridData.mvNodeChanges,
finishedGridData.assetInformation,
childReferences.resultListeners,
runGuardianData.msgAdapters
)(ctx.log)

Behaviors.same
stopping(stopChildren(runGuardianData.runId, childReferences, ctx))
case (ctx, ResultEventListenerDied) =>
// we wait for exact one listener as we only started one
/* Start coordinated shutdown */
Expand Down

0 comments on commit 72e045c

Please sign in to comment.