Skip to content

Commit

Permalink
Merge pull request #37 from ie3-institute/sp/#36-tscfg-serialization
Browse files Browse the repository at this point in the history
Make BaseRuntimeConfig serializable
  • Loading branch information
johanneshiry authored Jan 3, 2022
2 parents 1677448 + e6f7e9d commit 61605df
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/main/resources/config/config-template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RefSystemConfig {
gridIds: [string] # Sub grid numbers to apply to, expl.: 1,2,4..10
}

#@define abstract
#@define abstract extends !java.io.Serializable
BaseRuntimeConfig {
uuids: [string] # Unique id to identify the system participant models this config applies for
scaling: double # General scaling factor of the system participant model
Expand Down
58 changes: 26 additions & 32 deletions src/main/scala/edu/ie3/simona/config/SimonaConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object SimonaConfig {
val calculateMissingReactivePowerWithModel: scala.Boolean,
val scaling: scala.Double,
val uuids: scala.List[java.lang.String]
)
) extends java.io.Serializable

final case class EvcsRuntimeConfig(
override val calculateMissingReactivePowerWithModel: scala.Boolean,
Expand Down Expand Up @@ -208,12 +208,10 @@ object SimonaConfig {
nodes = c.hasPathOrNull("nodes") && c.getBoolean("nodes"),
notifier = $_reqStr(parentPath, c, "notifier", $tsCfgValidator),
switches = c.hasPathOrNull("switches") && c.getBoolean("switches"),
transformers2w = c.hasPathOrNull("transformers2w") && c.getBoolean(
"transformers2w"
),
transformers3w = c.hasPathOrNull("transformers3w") && c.getBoolean(
"transformers3w"
)
transformers2w =
c.hasPathOrNull("transformers2w") && c.getBoolean("transformers2w"),
transformers3w =
c.hasPathOrNull("transformers3w") && c.getBoolean("transformers3w")
)
}
private def $_reqStr(
Expand Down Expand Up @@ -974,12 +972,11 @@ object SimonaConfig {
csvParams =
if (c.hasPathOrNull("csvParams"))
scala.Some(
SimonaConfig.Simona.Input.Primary
.CsvParams(
c.getConfig("csvParams"),
parentPath + "csvParams.",
$tsCfgValidator
)
SimonaConfig.Simona.Input.Primary.CsvParams(
c.getConfig("csvParams"),
parentPath + "csvParams.",
$tsCfgValidator
)
)
else None,
influxDb1xParams =
Expand All @@ -995,12 +992,11 @@ object SimonaConfig {
sqlParams =
if (c.hasPathOrNull("sqlParams"))
scala.Some(
SimonaConfig.Simona.Input.Primary
.SqlParams(
c.getConfig("sqlParams"),
parentPath + "sqlParams.",
$tsCfgValidator
)
SimonaConfig.Simona.Input.Primary.SqlParams(
c.getConfig("sqlParams"),
parentPath + "sqlParams.",
$tsCfgValidator
)
)
else None
)
Expand Down Expand Up @@ -1371,7 +1367,8 @@ object SimonaConfig {
)
else None,
resolution =
if (c.hasPathOrNull("resolution")) Some(c.getLong("resolution"))
if (c.hasPathOrNull("resolution"))
Some(c.getLong("resolution").longValue())
else None,
sampleParams =
if (c.hasPathOrNull("sampleParams"))
Expand Down Expand Up @@ -1469,9 +1466,7 @@ object SimonaConfig {
SimonaConfig.Simona.Output.Base(
addTimestampToOutputDir = !c.hasPathOrNull(
"addTimestampToOutputDir"
) || c.getBoolean(
"addTimestampToOutputDir"
),
) || c.getBoolean("addTimestampToOutputDir"),
dir = $_reqStr(parentPath, c, "dir", $tsCfgValidator)
)
}
Expand Down Expand Up @@ -1627,12 +1622,11 @@ object SimonaConfig {
csv =
if (c.hasPathOrNull("csv"))
scala.Some(
SimonaConfig.Simona.Output.Sink
.Csv(
c.getConfig("csv"),
parentPath + "csv.",
$tsCfgValidator
)
SimonaConfig.Simona.Output.Sink.Csv(
c.getConfig("csv"),
parentPath + "csv.",
$tsCfgValidator
)
)
else None,
influxDb1x =
Expand Down Expand Up @@ -1686,8 +1680,8 @@ object SimonaConfig {
final case class Powerflow(
maxSweepPowerDeviation: scala.Double,
newtonraphson: SimonaConfig.Simona.Powerflow.Newtonraphson,
sweepTimeout: java.time.Duration,
resolution: java.time.Duration
resolution: java.time.Duration,
sweepTimeout: java.time.Duration
)
object Powerflow {
final case class Newtonraphson(
Expand Down Expand Up @@ -2276,7 +2270,7 @@ object SimonaConfig {
java.lang.String.valueOf(cv.unwrapped())
}

private final class $TsCfgValidator {
final class $TsCfgValidator {
private val badPaths =
scala.collection.mutable.ArrayBuffer[java.lang.String]()

Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/edu/ie3/simona/config/ConfigFailFastSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ class ConfigFailFastSpec extends UnitSpec with ConfigTestData {
List(10, 30),
100
),
Duration.of(3600, ChronoUnit.SECONDS),
Duration.of(3600, ChronoUnit.NANOS)
resolution = Duration.of(3600, ChronoUnit.NANOS),
sweepTimeout = Duration.of(3600, ChronoUnit.SECONDS)
)
)
}.getMessage shouldBe "Invalid time resolution. Please ensure, that the time resolution for power flow calculation is at least rounded to a full second!"
Expand Down

0 comments on commit 61605df

Please sign in to comment.