-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete DynaFlowParameters.Sa inner class and replace it with a proper…
… DynaFlowSecurityAnalysisParameters class extension of SecurityAnalysisParameter Signed-off-by: lisrte <[email protected]>
- Loading branch information
Showing
23 changed files
with
618 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
dynaflow/src/main/java/com/powsybl/dynaflow/DynaFlowSecurityAnalysisParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** | ||
* Copyright (c) 2024, RTE (http://www.rte-france.com/) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package com.powsybl.dynaflow; | ||
|
||
import com.google.common.base.MoreObjects; | ||
import com.powsybl.commons.config.ModuleConfig; | ||
import com.powsybl.commons.config.PlatformConfig; | ||
import com.powsybl.commons.extensions.AbstractExtension; | ||
import com.powsybl.security.SecurityAnalysisParameters; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
import static com.powsybl.dynaflow.DynaFlowSecurityAnalysisProvider.MODULE_SPECIFIC_PARAMETERS; | ||
|
||
/** | ||
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>} | ||
*/ | ||
public class DynaFlowSecurityAnalysisParameters extends AbstractExtension<SecurityAnalysisParameters> { | ||
|
||
private static final double DEFAULT_TIME_OF_EVENT = 10d; | ||
private static final String TIME_OF_EVENT = "timeOfEvent"; | ||
public static final List<String> SPECIFIC_PARAMETER_NAMES = List.of(TIME_OF_EVENT); | ||
|
||
private Double timeOfEvent = DEFAULT_TIME_OF_EVENT; | ||
|
||
public Double getTimeOfEvent() { | ||
return timeOfEvent; | ||
} | ||
|
||
public DynaFlowSecurityAnalysisParameters setTimeOfEvent(Double timeOfEvent) { | ||
this.timeOfEvent = timeOfEvent; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "DynaFlowSecurityAnalysisParameters"; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return MoreObjects.toStringHelper("").omitNullValues() | ||
.add(TIME_OF_EVENT, timeOfEvent).toString(); | ||
} | ||
|
||
public static DynaFlowSecurityAnalysisParameters load(PlatformConfig platformConfig) { | ||
Objects.requireNonNull(platformConfig); | ||
DynaFlowSecurityAnalysisParameters parameters = new DynaFlowSecurityAnalysisParameters(); | ||
platformConfig.getOptionalModuleConfig(MODULE_SPECIFIC_PARAMETERS) | ||
.ifPresent(config -> load(parameters, config)); | ||
return parameters; | ||
} | ||
|
||
public static DynaFlowSecurityAnalysisParameters load(ModuleConfig config) { | ||
DynaFlowSecurityAnalysisParameters parameters = new DynaFlowSecurityAnalysisParameters(); | ||
if (config != null) { | ||
load(parameters, config); | ||
} | ||
return parameters; | ||
} | ||
|
||
public static DynaFlowSecurityAnalysisParameters load(Map<String, String> properties) { | ||
DynaFlowSecurityAnalysisParameters parameters = new DynaFlowSecurityAnalysisParameters(); | ||
parameters.update(properties); | ||
return parameters; | ||
} | ||
|
||
private static void load(DynaFlowSecurityAnalysisParameters parameters, ModuleConfig config) { | ||
config.getOptionalDoubleProperty(TIME_OF_EVENT).ifPresent(parameters::setTimeOfEvent); | ||
} | ||
|
||
public void update(Map<String, String> properties) { | ||
Objects.requireNonNull(properties); | ||
Optional.ofNullable(properties.get(TIME_OF_EVENT)).ifPresent(prop -> setTimeOfEvent(Double.parseDouble(prop))); | ||
} | ||
} |
Oops, something went wrong.