Skip to content

Commit

Permalink
Retrieve specific parameters overrides from PlatformConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinebhs committed Sep 27, 2024
1 parent cf20f8f commit 2e73409
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -137,6 +138,11 @@ public List<Parameter> getSpecificParameters() {
return DynaFlowParameters.SPECIFIC_PARAMETERS;
}

@Override
public Optional<ModuleConfig> getModuleConfig(PlatformConfig platformConfig) {
return platformConfig.getOptionalModuleConfig(MODULE_SPECIFIC_PARAMETERS);
}

@Override
public Optional<ExtensionJsonSerializer> getSpecificParametersSerializer() {
return Optional.of(new JsonDynaFlowParametersSerializer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -132,6 +133,16 @@ void checkDefaultParameters() {
assertTrue(parametersExt.isMergeLoads());
}

@Test
void testConfigSpecificParameters() {
MapModuleConfig moduleConfig = platformConfig.createModuleConfig(MODULE_SPECIFIC_PARAMETERS);
moduleConfig.setStringProperty("svcRegulationOn", "false");

List<Parameter> parameters = new DynaFlowProvider().getSpecificParameters(platformConfig);

assertEquals(false, parameters.get(0).getDefaultValue());
}

@Test
void checkAllParametersAssignedToString() {
LoadFlowParameters parameters = LoadFlowParameters.load(platformConfig);
Expand Down

0 comments on commit 2e73409

Please sign in to comment.