Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public class BranchCreationInfos extends EquipmentCreationInfos {
private List<OperationalLimitsGroupInfos> operationalLimitsGroups;

@Schema(description = "Selected operational limits group on Side 1")
private String selectedOperationalLimitsGroup1;
private String selectedOperationalLimitsGroupId1;

@Schema(description = "Selected operational limits group on Side 2")
private String selectedOperationalLimitsGroup2;
private String selectedOperationalLimitsGroupId2;

@Schema(description = "Connection Name 1")
private String connectionName1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public class BranchModificationInfos extends BasicEquipmentModificationInfos {
private List<OperationalLimitsGroupModificationInfos> operationalLimitsGroups;

@Schema(description = "Selected operational limits group on Side 1")
private AttributeModification<String> selectedOperationalLimitsGroup1;
private AttributeModification<String> selectedOperationalLimitsGroupId1;

@Schema(description = "Selected operational limits group on Side 2")
private AttributeModification<String> selectedOperationalLimitsGroup2;
private AttributeModification<String> selectedOperationalLimitsGroupId2;

@Schema(description = "Voltage level id modification 1")
private AttributeModification<String> voltageLevelId1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public enum LineField {
G2,
B1,
B2,
SELECTED_OPERATIONAL_LIMITS_GROUP_1,
SELECTED_OPERATIONAL_LIMITS_GROUP_2;
SELECTED_OPERATIONAL_LIMITS_GROUP_ID1,
SELECTED_OPERATIONAL_LIMITS_GROUP_ID2;

public static String getReferenceValue(Line line, String lineField) {
LineField field = LineField.valueOf(lineField);
Expand All @@ -40,8 +40,8 @@ public static String getReferenceValue(Line line, String lineField) {
case G2 -> String.valueOf(line.getG2());
case B1 -> String.valueOf(line.getB1());
case B2 -> String.valueOf(line.getB2());
case SELECTED_OPERATIONAL_LIMITS_GROUP_1 -> String.valueOf(line.getSelectedOperationalLimitsGroupId1().orElse(null));
case SELECTED_OPERATIONAL_LIMITS_GROUP_2 -> String.valueOf(line.getSelectedOperationalLimitsGroupId2().orElse(null));
case SELECTED_OPERATIONAL_LIMITS_GROUP_ID1 -> String.valueOf(line.getSelectedOperationalLimitsGroupId1().orElse(null));
case SELECTED_OPERATIONAL_LIMITS_GROUP_ID2 -> String.valueOf(line.getSelectedOperationalLimitsGroupId2().orElse(null));
};
}

Expand All @@ -50,7 +50,7 @@ public static void setNewValue(Line line, String lineField, @NotNull String newV
String errorMessage = String.format(ERROR_MESSAGE, line.getId());
switch (field) {
case R, X, G1, G2, B1, B2 -> setNewDoubleValue(line, field, newValue, errorMessage);
case SELECTED_OPERATIONAL_LIMITS_GROUP_1, SELECTED_OPERATIONAL_LIMITS_GROUP_2 -> setNewStringValue(line, field, newValue, errorMessage);
case SELECTED_OPERATIONAL_LIMITS_GROUP_ID1, SELECTED_OPERATIONAL_LIMITS_GROUP_ID2 -> setNewStringValue(line, field, newValue, errorMessage);
}
}

Expand Down Expand Up @@ -80,15 +80,15 @@ private static void setNewDoubleValue(Line line, LineField field, String newValu
private static void setNewStringValue(Line line, LineField field, String newValue, String errorMessage) {
final AttributeModification<String> attributeModification = new AttributeModification<>(newValue, OperationType.SET);
switch (field) {
case SELECTED_OPERATIONAL_LIMITS_GROUP_1 -> {
case SELECTED_OPERATIONAL_LIMITS_GROUP_ID1 -> {
ModificationUtils.checkLimitsGroupExist(errorMessage, newValue, MODIFY_LINE_ERROR,
line.getOperationalLimitsGroups1()
.stream()
.map(OperationalLimitsGroup::getId)
.toList(), 1);
modifySelectedOperationalLimitsGroup(line, attributeModification, TwoSides.ONE, null);
}
case SELECTED_OPERATIONAL_LIMITS_GROUP_2 -> {
case SELECTED_OPERATIONAL_LIMITS_GROUP_ID2 -> {
ModificationUtils.checkLimitsGroupExist(errorMessage, newValue, MODIFY_LINE_ERROR,
line.getOperationalLimitsGroups2()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public enum TwoWindingsTransformerField {
PHASE_LOW_TAP_POSITION,
PHASE_TAP_POSITION,
PHASE_TARGET_DEADBAND,
SELECTED_OPERATIONAL_LIMITS_GROUP_1,
SELECTED_OPERATIONAL_LIMITS_GROUP_2;
SELECTED_OPERATIONAL_LIMITS_GROUP_ID1,
SELECTED_OPERATIONAL_LIMITS_GROUP_ID2;

public static final String VALUE_KEY_FIELD_NAME = "fieldName";
public static final String VALUE_KEY_EQUIPMENT_NAME = "equipmentName";
Expand Down Expand Up @@ -115,9 +115,9 @@ public static String getReferenceValue(TwoWindingsTransformer transformer, Strin
phaseTapChanger != null ? String.valueOf(phaseTapChanger.getTapPosition()) : null;
case PHASE_TARGET_DEADBAND ->
phaseTapChanger != null ? String.valueOf(phaseTapChanger.getTargetDeadband()) : null;
case SELECTED_OPERATIONAL_LIMITS_GROUP_1 ->
case SELECTED_OPERATIONAL_LIMITS_GROUP_ID1 ->
String.valueOf(transformer.getSelectedOperationalLimitsGroupId1().orElse(null));
case SELECTED_OPERATIONAL_LIMITS_GROUP_2 ->
case SELECTED_OPERATIONAL_LIMITS_GROUP_ID2 ->
String.valueOf(transformer.getSelectedOperationalLimitsGroupId2().orElse(null));
};
}
Expand All @@ -130,7 +130,7 @@ public static void setNewValue(TwoWindingsTransformer transformer, String twoWin
case R, X, G, B, RATED_U1, RATED_U2, RATED_S, TARGET_V, RATIO_LOW_TAP_POSITION, RATIO_TAP_POSITION,
RATIO_TARGET_DEADBAND, REGULATION_VALUE, PHASE_LOW_TAP_POSITION, PHASE_TAP_POSITION,
PHASE_TARGET_DEADBAND -> setNewDoubleValue(transformer, field, newValue, errorMessage);
case SELECTED_OPERATIONAL_LIMITS_GROUP_1, SELECTED_OPERATIONAL_LIMITS_GROUP_2 ->
case SELECTED_OPERATIONAL_LIMITS_GROUP_ID1, SELECTED_OPERATIONAL_LIMITS_GROUP_ID2 ->
setNewStringValue(transformer, field, newValue, errorMessage);
}
}
Expand Down Expand Up @@ -188,15 +188,15 @@ private static void setNewDoubleValue(TwoWindingsTransformer transformer, TwoWin
private static void setNewStringValue(TwoWindingsTransformer transformer, TwoWindingsTransformerField field, String newValue, String errorMessage) {
final AttributeModification<String> attributeModification = new AttributeModification<>(newValue, OperationType.SET);
switch (field) {
case SELECTED_OPERATIONAL_LIMITS_GROUP_1 -> {
case SELECTED_OPERATIONAL_LIMITS_GROUP_ID1 -> {
ModificationUtils.checkLimitsGroupExist(errorMessage, newValue, MODIFY_LINE_ERROR,
transformer.getOperationalLimitsGroups1()
.stream()
.map(OperationalLimitsGroup::getId)
.toList(), 1);
modifySelectedOperationalLimitsGroup(transformer, attributeModification, TwoSides.ONE, null);
}
case SELECTED_OPERATIONAL_LIMITS_GROUP_2 -> {
case SELECTED_OPERATIONAL_LIMITS_GROUP_ID2 -> {
ModificationUtils.checkLimitsGroupExist(errorMessage, newValue, MODIFY_LINE_ERROR,
transformer.getOperationalLimitsGroups2()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,18 @@ protected void modifyBranch(Branch<?> branch, BranchModificationInfos branchModi
}

private void applySelectedOLGs(Branch<?> branch, List<ReportNode> activeOLGReports) {
if (modificationInfos.getSelectedOperationalLimitsGroup1() != null) {
if (modificationInfos.getSelectedOperationalLimitsGroupId1() != null) {
modifySelectedOperationalLimitsGroup(
branch,
modificationInfos.getSelectedOperationalLimitsGroup1(),
modificationInfos.getSelectedOperationalLimitsGroupId1(),
TwoSides.ONE,
activeOLGReports
);
}
if (modificationInfos.getSelectedOperationalLimitsGroup2() != null) {
if (modificationInfos.getSelectedOperationalLimitsGroupId2() != null) {
modifySelectedOperationalLimitsGroup(
branch,
modificationInfos.getSelectedOperationalLimitsGroup2(),
modificationInfos.getSelectedOperationalLimitsGroupId2(),
TwoSides.TWO,
activeOLGReports);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.gridsuite.modification.utils.PropertiesUtils;

import static org.gridsuite.modification.NetworkModificationException.Type.*;
import static org.gridsuite.modification.modifications.LineCreation.addLimits;

/**
* @author David Braquart <david.braquart at rte-france.com>
Expand Down Expand Up @@ -97,6 +98,12 @@ public void apply(Network network, ReportNode subReportNode) {
.build();

algo.apply(network, true, subReportNode);

// add extra information on attachment line
Line createdAttachmentLine = network.getLine(attachmentLineInfos.getEquipmentId());
addLimits(attachmentLineInfos, subReportNode, createdAttachmentLine);
PropertiesUtils.applyProperties(createdAttachmentLine, subReportNode, attachmentLineInfos.getProperties(), "network.modification.LineProperties");

// override attachment point
if (modificationInfos.getAttachmentPointDetailInformation() != null) {
// override voltage level
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ public void check(Network network) throws NetworkModificationException {
checkIsNotNegativeValue(errorMessage, modificationInfos.getG2(), CREATE_LINE_ERROR, "Conductance on side 2 G2");
}

private ReportNode addLimitSetReportNode(ReportNode limitsReporter) {
return limitsReporter.newReportNode()
.withSeverity(TypedValue.INFO_SEVERITY)
.withMessageTemplate("network.modification.LimitSets")
.add();
}

@Override
public void apply(Network network, ReportNode subReportNode) {
VoltageLevel voltageLevel1 = ModificationUtils.getInstance().getVoltageLevel(network, modificationInfos.getVoltageLevelId1());
Expand All @@ -75,6 +68,13 @@ public void apply(Network network, ReportNode subReportNode) {
ModificationUtils.getInstance().disconnectBranch(modificationInfos, network.getLine(modificationInfos.getEquipmentId()), characteristicsReporter);
Line line = network.getLine(modificationInfos.getEquipmentId());

addLimits(modificationInfos, subReportNode, line);

// properties
PropertiesUtils.applyProperties(line, characteristicsReporter, modificationInfos.getProperties(), "network.modification.LineProperties");
}

public static void addLimits(LineCreationInfos modificationInfos, ReportNode subReportNode, Line line) {
// Set permanent and temporary current limits
ReportNode limitsReporter = null;
List<OperationalLimitsGroupInfos> opLimitsGroupSide1 = ModificationUtils.getOperationalLimitsGroupsOnSide(modificationInfos.getOperationalLimitsGroups(), Applicability.SIDE1);
Expand All @@ -101,36 +101,36 @@ public void apply(Network network, ReportNode subReportNode) {
}

List<ReportNode> limitSetsOnSideReportNodes = new ArrayList<>();
if (modificationInfos.getSelectedOperationalLimitsGroup1() != null) {
if (!ModificationUtils.hasLimitSet(opLimitsGroupSide1, modificationInfos.getSelectedOperationalLimitsGroup1())) {
if (modificationInfos.getSelectedOperationalLimitsGroupId1() != null) {
if (!ModificationUtils.hasLimitSet(opLimitsGroupSide1, modificationInfos.getSelectedOperationalLimitsGroupId1())) {
limitSetsOnSideReportNodes.add(ReportNode.newRootReportNode()
.withMessageTemplate("network.modification.limitSetAbsentOnSide1")
.withUntypedValue("selectedOperationalLimitsGroup", modificationInfos.getSelectedOperationalLimitsGroup1())
.withSeverity(TypedValue.WARN_SEVERITY)
.build());
.withMessageTemplate("network.modification.limitSetAbsentOnSide1")
.withUntypedValue("selectedOperationalLimitsGroup", modificationInfos.getSelectedOperationalLimitsGroupId1())
.withSeverity(TypedValue.WARN_SEVERITY)
.build());
} else {
line.setSelectedOperationalLimitsGroup1(modificationInfos.getSelectedOperationalLimitsGroup1());
line.setSelectedOperationalLimitsGroup1(modificationInfos.getSelectedOperationalLimitsGroupId1());
limitSetsOnSideReportNodes.add(ReportNode.newRootReportNode()
.withMessageTemplate("network.modification.limitSetSelectedOnSide1")
.withUntypedValue("selectedOperationalLimitsGroup1", modificationInfos.getSelectedOperationalLimitsGroup1())
.withSeverity(TypedValue.INFO_SEVERITY)
.build());
.withMessageTemplate("network.modification.limitSetSelectedOnSide1")
.withUntypedValue("selectedOperationalLimitsGroup1", modificationInfos.getSelectedOperationalLimitsGroupId1())
.withSeverity(TypedValue.INFO_SEVERITY)
.build());
}
}
if (modificationInfos.getSelectedOperationalLimitsGroup2() != null) {
if (!ModificationUtils.hasLimitSet(opLimitsGroupSide2, modificationInfos.getSelectedOperationalLimitsGroup2())) {
if (modificationInfos.getSelectedOperationalLimitsGroupId2() != null) {
if (!ModificationUtils.hasLimitSet(opLimitsGroupSide2, modificationInfos.getSelectedOperationalLimitsGroupId2())) {
limitSetsOnSideReportNodes.add(ReportNode.newRootReportNode()
.withMessageTemplate("network.modification.limitSetAbsentOnSide2")
.withUntypedValue("selectedOperationalLimitsGroup", modificationInfos.getSelectedOperationalLimitsGroup2())
.withSeverity(TypedValue.WARN_SEVERITY)
.build());
.withMessageTemplate("network.modification.limitSetAbsentOnSide2")
.withUntypedValue("selectedOperationalLimitsGroup", modificationInfos.getSelectedOperationalLimitsGroupId2())
.withSeverity(TypedValue.WARN_SEVERITY)
.build());
} else {
line.setSelectedOperationalLimitsGroup2(modificationInfos.getSelectedOperationalLimitsGroup2());
line.setSelectedOperationalLimitsGroup2(modificationInfos.getSelectedOperationalLimitsGroupId2());
limitSetsOnSideReportNodes.add(ReportNode.newRootReportNode()
.withMessageTemplate("network.modification.limitSetSelectedOnSide2")
.withUntypedValue("selectedOperationalLimitsGroup2", modificationInfos.getSelectedOperationalLimitsGroup2())
.withSeverity(TypedValue.INFO_SEVERITY)
.build());
.withMessageTemplate("network.modification.limitSetSelectedOnSide2")
.withUntypedValue("selectedOperationalLimitsGroup2", modificationInfos.getSelectedOperationalLimitsGroupId2())
.withSeverity(TypedValue.INFO_SEVERITY)
.build());
}
}

Expand All @@ -139,11 +139,15 @@ public void apply(Network network, ReportNode subReportNode) {
limitsReporter = subReportNode.newReportNode().withMessageTemplate("network.modification.limitsCreated").add();
}
ModificationUtils.getInstance().reportModifications(limitsReporter, limitSetsOnSideReportNodes,
"network.modification.ActiveLimitSets");
"network.modification.ActiveLimitSets");
}
}

// properties
PropertiesUtils.applyProperties(line, characteristicsReporter, modificationInfos.getProperties(), "network.modification.LineProperties");
private static ReportNode addLimitSetReportNode(ReportNode limitsReporter) {
return limitsReporter.newReportNode()
.withSeverity(TypedValue.INFO_SEVERITY)
.withMessageTemplate("network.modification.LimitSets")
.add();
}

@Override
Expand Down
Loading