From 55537b44324ad47f95a1e4e4dcaf848bbbf830ae Mon Sep 17 00:00:00 2001 From: BOUHOURS Antoine Date: Fri, 27 Sep 2024 12:19:15 +0200 Subject: [PATCH] Retrieve specific parameters overrides from PlatformConfig Signed-off-by: BOUHOURS Antoine --- .../java/com/powsybl/dynaflow/DynaFlowProvider.java | 6 ++++++ .../com/powsybl/dynaflow/DynaFlowParametersTest.java | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/dynaflow/src/main/java/com/powsybl/dynaflow/DynaFlowProvider.java b/dynaflow/src/main/java/com/powsybl/dynaflow/DynaFlowProvider.java index b580df72b..6e5b97e8d 100644 --- a/dynaflow/src/main/java/com/powsybl/dynaflow/DynaFlowProvider.java +++ b/dynaflow/src/main/java/com/powsybl/dynaflow/DynaFlowProvider.java @@ -9,6 +9,7 @@ import com.google.auto.service.AutoService; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; +import com.powsybl.commons.config.ModuleConfig; import com.powsybl.commons.config.PlatformConfig; import com.powsybl.commons.extensions.Extension; import com.powsybl.commons.extensions.ExtensionJsonSerializer; @@ -137,6 +138,11 @@ public List getSpecificParameters() { return DynaFlowParameters.SPECIFIC_PARAMETERS; } + @Override + public Optional getModuleConfig(PlatformConfig platformConfig) { + return platformConfig.getOptionalModuleConfig(MODULE_SPECIFIC_PARAMETERS); + } + @Override public Optional getSpecificParametersSerializer() { return Optional.of(new JsonDynaFlowParametersSerializer()); diff --git a/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowParametersTest.java b/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowParametersTest.java index e690e54f6..d5d299fc6 100644 --- a/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowParametersTest.java +++ b/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowParametersTest.java @@ -10,6 +10,7 @@ import com.google.common.jimfs.Jimfs; import com.powsybl.commons.config.InMemoryPlatformConfig; import com.powsybl.commons.config.MapModuleConfig; +import com.powsybl.commons.parameters.Parameter; import com.powsybl.commons.test.AbstractSerDeTest; import com.powsybl.dynaflow.DynaFlowConstants.ActivePowerCompensation; import com.powsybl.dynaflow.DynaFlowConstants.OutputTypes; @@ -132,6 +133,16 @@ void checkDefaultParameters() { assertTrue(parametersExt.isMergeLoads()); } + @Test + void testConfigSpecificParameters() { + MapModuleConfig moduleConfig = platformConfig.createModuleConfig(MODULE_SPECIFIC_PARAMETERS); + moduleConfig.setStringProperty("svcRegulationOn", "false"); + + List parameters = new DynaFlowProvider().getSpecificParameters(platformConfig); + + assertEquals(false, parameters.get(0).getDefaultValue()); + } + @Test void checkAllParametersAssignedToString() { LoadFlowParameters parameters = LoadFlowParameters.load(platformConfig);