Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ion-server into share-code-for-network-modifications

Signed-off-by: Mathieu DEHARBE <[email protected]>

# Conflicts:
#	src/main/java/org/gridsuite/modification/server/modifications/GeneratorModification.java
#	src/main/java/org/gridsuite/modification/server/modifications/ModificationUtils.java
#	src/main/java/org/gridsuite/modification/server/modifications/TwoWindingsTransformerModification.java
  • Loading branch information
Mathieu-Deharbe committed Sep 18, 2024
2 parents e758123 + e9fad04 commit 0a92daf
Show file tree
Hide file tree
Showing 25 changed files with 342 additions and 309 deletions.
14 changes: 14 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-network-store-client</artifactId>
<!-- FIXME: network-store modules' version is overloaded in the dependencies section. The overloads and this property below have to be removed at next gridsuite-dependencies.version upgrade -->
<version>1.17.1</version>
</dependency>
<!-- FIXME: network-store modules' version is overloaded in the dependencies section. This section have to be removed at next gridsuite-dependencies.version upgrade -->
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-network-store-iidm-impl</artifactId>
<version>1.17.1</version>
</dependency>
<!-- FIXME: network-store modules' version is overloaded in the dependencies section. This section have to be removed at next gridsuite-dependencies.version upgrade -->
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-network-store-model</artifactId>
<version>1.17.1</version>
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

import static org.gridsuite.modification.server.NetworkModificationException.Type.BRANCH_MODIFICATION_ERROR;
Expand All @@ -44,7 +44,7 @@ protected void modifyBranch(Branch<?> branch, BranchModificationInfos branchModi
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
if (branchModificationInfos.getEquipmentName() != null) {
insertReportNode(subReportNode, ModificationUtils.getInstance().buildModificationReportWithIndentation(branch.getOptionalName().isEmpty() ? null : branch.getOptionalName().get(), branchModificationInfos.getEquipmentName().getValue(), "Name", 0));
insertReportNode(subReportNode, ModificationUtils.getInstance().buildModificationReport(Optional.of(branch.getOptionalName()).orElse(null), branchModificationInfos.getEquipmentName().getValue(), "Name", 0));
branch.setName(branchModificationInfos.getEquipmentName().getValue());
}

Expand All @@ -66,14 +66,10 @@ protected void modifyBranch(Branch<?> branch, BranchModificationInfos branchModi
}
if (!side1LimitsReports.isEmpty() || !side2LimitsReports.isEmpty()) {
ReportNode limitsReportNode = subReportNode.newReportNode().withMessageTemplate("limits", "Limits").add();
limitsReportNode.newReportNode()
.withMessageTemplate("limitsModification", "Limits")
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
ModificationUtils.getInstance().reportModifications(limitsReportNode, side1LimitsReports, "side1LimitsModification",
" Side 1", Map.of());
" Side 1");
ModificationUtils.getInstance().reportModifications(limitsReportNode, side2LimitsReports, "side2LimitsModification",
" Side 2", Map.of());
" Side 2");
}

updateConnections(branch, branchModificationInfos);
Expand Down Expand Up @@ -118,7 +114,7 @@ private boolean updateConnection(Branch<?> branch, TwoSides side, Boolean connec
protected void modifyCurrentLimits(CurrentLimitsModificationInfos currentLimitsInfos, CurrentLimitsAdder limitsAdder, CurrentLimits currentLimits, List<ReportNode> limitsReports) {
boolean hasPermanent = currentLimitsInfos.getPermanentLimit() != null;
if (hasPermanent) {
limitsReports.add(ModificationUtils.getInstance().buildModificationReportWithIndentation(currentLimits != null ? currentLimits.getPermanentLimit() : Double.NaN,
limitsReports.add(ModificationUtils.getInstance().buildModificationReport(currentLimits != null ? currentLimits.getPermanentLimit() : Double.NaN,
currentLimitsInfos.getPermanentLimit(), "IST", 2));
limitsAdder.setPermanentLimit(currentLimitsInfos.getPermanentLimit());
} else {
Expand Down Expand Up @@ -206,7 +202,7 @@ protected void modifyTemporaryLimits(CurrentLimitsModificationInfos currentLimit
}
}
if (!temporaryLimitsReports.isEmpty()) {
temporaryLimitsReports.add(ReportNode.newRootReportNode()
temporaryLimitsReports.add(0, ReportNode.newRootReportNode()
.withMessageTemplate("temporaryLimitsModification", " Temporary current limits :")
.withSeverity(TypedValue.INFO_SEVERITY)
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static org.gridsuite.modification.server.NetworkModificationException.Type.BATTERY_ALREADY_EXISTS;
import static org.gridsuite.modification.server.modifications.ModificationUtils.nanIfNull;
Expand Down Expand Up @@ -147,7 +146,7 @@ private ReportNode reportBatterySetPoints(BatteryCreationInfos batteryCreationIn
setPointReports.add(ModificationUtils.getInstance()
.buildCreationReport(batteryCreationInfos.getTargetQ(), "Reactive power"));
}
return ModificationUtils.getInstance().reportModifications(subReportNode, setPointReports, "SetPointCreated", "Setpoints", Map.of());
return ModificationUtils.getInstance().reportModifications(subReportNode, setPointReports, "SetPointCreated", "Setpoints");
}

private void reportBatteryConnectivity(BatteryCreationInfos batteryCreationInfos, ReportNode subReportNode) {
Expand Down Expand Up @@ -178,24 +177,18 @@ private void reportBatteryConnectivity(BatteryCreationInfos batteryCreationInfos
.withSeverity(TypedValue.INFO_SEVERITY)
.build());
}
ModificationUtils.getInstance().reportModifications(subReportNode, connectivityReports, "ConnectivityCreated", CONNECTIVITY, Map.of());
ModificationUtils.getInstance().reportModifications(subReportNode, connectivityReports, "ConnectivityCreated", CONNECTIVITY);
}
}

private ReportNode reportBatteryActiveLimits(BatteryCreationInfos batteryCreationInfos, ReportNode subReportNode) {
List<ReportNode> limitsReports = new ArrayList<>();
ReportNode subReportNodeLimits = subReportNode.newReportNode().withMessageTemplate(LIMITS, LIMITS).add();
subReportNodeLimits.newReportNode()
.withMessageTemplate(LIMITS, LIMITS)
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
List<ReportNode> limitsReports = new ArrayList<>();
limitsReports.add(ModificationUtils.getInstance().buildCreationReport(
batteryCreationInfos.getMinP(), "Min active power"));

limitsReports.add(ModificationUtils.getInstance().buildCreationReport(
batteryCreationInfos.getMaxP(), "Max active power"));

ModificationUtils.getInstance().reportModifications(subReportNodeLimits, limitsReports, "ActiveLimitsCreated", ACTIVE_LIMITS, Map.of());
ModificationUtils.getInstance().reportModifications(subReportNodeLimits, limitsReports, "ActiveLimitsCreated", ACTIVE_LIMITS);
return subReportNodeLimits;
}

Expand All @@ -221,7 +214,7 @@ private void createBatteryActivePowerControl(BatteryCreationInfos batteryCreatio
.withSeverity(TypedValue.ERROR_SEVERITY)
.build());
}
ModificationUtils.getInstance().reportModifications(subReporter, activePowerRegulationReports, "ActivePowerRegulationCreated", "Active power regulation", Map.of());
ModificationUtils.getInstance().reportModifications(subReporter, activePowerRegulationReports, "ActivePowerRegulationCreated", "Active power regulation");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ public static void modifyBatterySetpointsAttributes(AttributeModification<Double
ReportNode subReporterSetpoints = null;
if (subReportNode != null && (reportActivePower != null || reportReactivePower != null)) {
subReporterSetpoints = subReportNode.newReportNode().withMessageTemplate(SETPOINTS, SETPOINTS).add();
subReporterSetpoints.newReportNode()
.withMessageTemplate(SETPOINTS, SETPOINTS)
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
if (reportActivePower != null) {
insertReportNode(subReporterSetpoints, reportActivePower);
}
Expand Down Expand Up @@ -143,16 +139,7 @@ public static ReportNode modifyBatteryActiveLimitsAttributes(AttributeModificati
ReportNode reportMinActivePower = ModificationUtils.getInstance().applyElementaryModificationsAndReturnReport(battery::setMinP, battery::getMinP, minP, "Min active power");
if (subReportNode != null && (reportMaxActivePower != null || reportMinActivePower != null)) {
subReportNodeLimits = subReportNode.newReportNode().withMessageTemplate(LIMITS, LIMITS).add();
subReportNodeLimits.newReportNode()
.withMessageTemplate(LIMITS, LIMITS)
.withSeverity(TypedValue.INFO_SEVERITY)
.add();

ReportNode subReporterActiveLimits = subReportNodeLimits.newReportNode().withMessageTemplate(ACTIVE_LIMITS, ACTIVE_LIMITS).add();
subReporterActiveLimits.newReportNode()
.withMessageTemplate(ACTIVE_LIMITS, ACTIVE_LIMITS)
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
if (reportMaxActivePower != null) {
insertReportNode(subReporterActiveLimits, reportMaxActivePower);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ public void apply(Network network, ReportNode subReportNode) {
}

private void report(ReportNode formulaSubReportNode, List<ReportNode> formulaReports) {
formulaSubReportNode.newReportNode()
.withMessageTemplate("appliedFormulasModifications", " Formulas")
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
formulaReports.forEach(report -> insertReportNode(formulaSubReportNode, report));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static org.gridsuite.modification.server.NetworkModificationException.Type.GENERATOR_ALREADY_EXISTS;
import static org.gridsuite.modification.server.modifications.ModificationUtils.nanIfNull;
Expand Down Expand Up @@ -190,7 +189,7 @@ private ReportNode reportGeneratorSetPoints(GeneratorCreationInfos generatorCrea
setPointReports.add(ModificationUtils.getInstance()
.buildCreationReport(generatorCreationInfos.getTargetQ(), "Reactive power"));
}
return ModificationUtils.getInstance().reportModifications(subReportNode, setPointReports, "SetPointCreated", "Setpoints", Map.of());
return ModificationUtils.getInstance().reportModifications(subReportNode, setPointReports, "SetPointCreated", "Setpoints");
}

private void createGeneratorVoltageRegulation(GeneratorCreationInfos generatorCreationInfos, Generator generator, VoltageLevel voltageLevel, ReportNode subReportNode) {
Expand Down Expand Up @@ -222,7 +221,7 @@ private void createGeneratorVoltageRegulation(GeneratorCreationInfos generatorCr
.build());
}
}
ModificationUtils.getInstance().reportModifications(subReportNode, voltageReports, "VoltageRegulationCreated", "Voltage regulation", Map.of());
ModificationUtils.getInstance().reportModifications(subReportNode, voltageReports, "VoltageRegulationCreated", "Voltage regulation");

}

Expand Down Expand Up @@ -270,29 +269,22 @@ private void reportGeneratorConnectivity(GeneratorCreationInfos generatorCreatio
.withSeverity(TypedValue.INFO_SEVERITY)
.build());
}
ModificationUtils.getInstance().reportModifications(subReporter, connectivityReports, "ConnectivityCreated", CONNECTIVITY, Map.of());
ModificationUtils.getInstance().reportModifications(subReporter, connectivityReports, "ConnectivityCreated", CONNECTIVITY);
}
}

private ReportNode reportGeneratorActiveLimits(GeneratorCreationInfos generatorCreationInfos, ReportNode subReportNode) {
List<ReportNode> limitsReports = new ArrayList<>();
ReportNode subReportNodeLimits = subReportNode.newReportNode().withMessageTemplate(LIMITS, LIMITS).add();
subReportNodeLimits.newReportNode()
.withMessageTemplate(LIMITS, LIMITS)
.withSeverity(TypedValue.INFO_SEVERITY)
.add();

List<ReportNode> limitsReports = new ArrayList<>();
limitsReports.add(ModificationUtils.getInstance().buildCreationReport(
generatorCreationInfos.getMinP(), "Min active power"));

limitsReports.add(ModificationUtils.getInstance().buildCreationReport(
generatorCreationInfos.getMaxP(), "Max active power"));

if (generatorCreationInfos.getRatedS() != null) {
limitsReports.add(ModificationUtils.getInstance().buildCreationReport(
generatorCreationInfos.getRatedS(), "Rated nominal power"));
}
ModificationUtils.getInstance().reportModifications(subReportNodeLimits, limitsReports, "ActiveLimitsCreated", ACTIVE_LIMITS, Map.of());
ModificationUtils.getInstance().reportModifications(subReportNodeLimits, limitsReports, "ActiveLimitsCreated", ACTIVE_LIMITS);
return subReportNodeLimits;
}

Expand All @@ -319,7 +311,7 @@ private void createGeneratorActivePowerControl(GeneratorCreationInfos generatorC
.build());

}
ModificationUtils.getInstance().reportModifications(subReportNode, activePowerRegulationReports, "ActivePowerRegulationCreated", "Active power regulation", Map.of());
ModificationUtils.getInstance().reportModifications(subReportNode, activePowerRegulationReports, "ActivePowerRegulationCreated", "Active power regulation");
}
}

Expand All @@ -345,7 +337,7 @@ private void createGeneratorShortCircuit(GeneratorCreationInfos generatorCreatio
.withSeverity(TypedValue.ERROR_SEVERITY)
.build());
}
ModificationUtils.getInstance().reportModifications(subReportNode, shortCircuitReports, "shortCircuitCreated", "Short-circuit", Map.of());
ModificationUtils.getInstance().reportModifications(subReportNode, shortCircuitReports, "shortCircuitCreated", "Short-circuit");
}
}

Expand Down Expand Up @@ -386,7 +378,7 @@ private void createGeneratorStartUp(GeneratorCreationInfos generatorCreationInfo
.withSeverity(TypedValue.ERROR_SEVERITY)
.build());
}
ModificationUtils.getInstance().reportModifications(subReportNode, startupReports, "startUpAttributesCreated", "Start up", Map.of());
ModificationUtils.getInstance().reportModifications(subReportNode, startupReports, "startUpAttributesCreated", "Start up");
}
}
}
Loading

0 comments on commit 0a92daf

Please sign in to comment.