diff --git a/src/main/java/com/powsybl/openloadflow/OpenLoadFlowParameters.java b/src/main/java/com/powsybl/openloadflow/OpenLoadFlowParameters.java index 77f4c9848b..e4b3e2d50b 100644 --- a/src/main/java/com/powsybl/openloadflow/OpenLoadFlowParameters.java +++ b/src/main/java/com/powsybl/openloadflow/OpenLoadFlowParameters.java @@ -54,6 +54,8 @@ public class OpenLoadFlowParameters extends AbstractExtension parameters .setSlackBusSelectionMode(config.getEnumProperty(SLACK_BUS_SELECTION_MODE_PARAM_NAME, SlackBusSelectionMode.class, SLACK_BUS_SELECTION_MODE_DEFAULT_VALUE)) .setSlackBusesIds(config.getStringListProperty(SLACK_BUSES_IDS_PARAM_NAME, Collections.emptyList())) diff --git a/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java b/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java index 8b92a03da3..ebcbc39813 100644 --- a/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java +++ b/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java @@ -9,6 +9,7 @@ import com.google.auto.service.AutoService; import com.google.common.base.Stopwatch; +import com.powsybl.commons.config.ModuleConfig; import com.powsybl.commons.config.PlatformConfig; import com.powsybl.commons.extensions.Extension; import com.powsybl.commons.extensions.ExtensionJsonSerializer; @@ -49,6 +50,8 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +import static com.powsybl.openloadflow.OpenLoadFlowParameters.MODULE_SPECIFIC_PARAMETERS; + /** * @author Sylvain Leclerc {@literal } */ @@ -329,4 +332,9 @@ public Map createMapFromSpecificParameters(Extension Objects.toString(e.getValue(), ""))); } + + @Override + public Optional getModuleConfig(PlatformConfig platformConfig) { + return platformConfig.getOptionalModuleConfig(MODULE_SPECIFIC_PARAMETERS); + } } diff --git a/src/test/java/com/powsybl/openloadflow/OpenLoadFlowParametersTest.java b/src/test/java/com/powsybl/openloadflow/OpenLoadFlowParametersTest.java index 826ae259ac..e0743a0126 100644 --- a/src/test/java/com/powsybl/openloadflow/OpenLoadFlowParametersTest.java +++ b/src/test/java/com/powsybl/openloadflow/OpenLoadFlowParametersTest.java @@ -14,6 +14,7 @@ import com.powsybl.commons.config.MapModuleConfig; import com.powsybl.commons.config.PlatformConfig; import com.powsybl.commons.config.YamlModuleConfigRepository; +import com.powsybl.commons.parameters.Parameter; import com.powsybl.commons.parameters.ParameterType; import com.powsybl.iidm.network.Network; import com.powsybl.iidm.network.extensions.SlackTerminal; @@ -39,6 +40,7 @@ import java.util.List; import java.util.Map; +import static com.powsybl.openloadflow.OpenLoadFlowParameters.MODULE_SPECIFIC_PARAMETERS; import static com.powsybl.openloadflow.util.LoadFlowAssert.assertVoltageEquals; import static org.junit.jupiter.api.Assertions.*; @@ -137,6 +139,16 @@ void testInvalidOpenLoadflowConfigNewtonRaphson() { assertThrows(IllegalArgumentException.class, () -> openLoadFlowParameters.setMaxReactivePowerMismatch(-1)); } + @Test + void testConfigSpecificParameters() { + MapModuleConfig olfModuleConfig = platformConfig.createModuleConfig(MODULE_SPECIFIC_PARAMETERS); + olfModuleConfig.setStringProperty("slackBusSelectionMode", "FIRST"); + + List olfParameters = new OpenLoadFlowProvider().getSpecificParameters(platformConfig); + + assertEquals(SlackBusSelectionMode.FIRST.toString(), olfParameters.get(0).getDefaultValue()); + } + @Test void testFirstSlackBusSelector() throws IOException { Path cfgDir = Files.createDirectory(fileSystem.getPath("config"));