Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @author Franck Lecuyer <franck.lecuyer at rte-france.com>
*/
public enum ModificationType {
EQUIPMENT_ATTRIBUTE_MODIFICATION(PreloadingStrategy.NONE),
EQUIPMENT_ATTRIBUTE_MODIFICATION(PreloadingStrategy.COLLECTION),
LOAD_CREATION(PreloadingStrategy.NONE),
LOAD_MODIFICATION(PreloadingStrategy.NONE),
BALANCES_ADJUSTMENT_MODIFICATION(PreloadingStrategy.ALL_COLLECTIONS_NEEDED_FOR_BUS_VIEW),
Expand All @@ -24,9 +24,9 @@ public enum ModificationType {
EQUIPMENT_DELETION(PreloadingStrategy.NONE),
BY_FILTER_DELETION(PreloadingStrategy.COLLECTION),
LINE_CREATION(PreloadingStrategy.NONE),
LINE_MODIFICATION(PreloadingStrategy.NONE),
LINE_MODIFICATION(PreloadingStrategy.COLLECTION),
TWO_WINDINGS_TRANSFORMER_CREATION(PreloadingStrategy.NONE),
TWO_WINDINGS_TRANSFORMER_MODIFICATION(PreloadingStrategy.NONE),
TWO_WINDINGS_TRANSFORMER_MODIFICATION(PreloadingStrategy.COLLECTION),
GROOVY_SCRIPT(PreloadingStrategy.COLLECTION),
SUBSTATION_CREATION(PreloadingStrategy.NONE),
SUBSTATION_MODIFICATION(PreloadingStrategy.NONE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ private Measurement getExistingMeasurement(Measurements<?> measurements, Measure
private void updateConnections(Branch<?> branch, BranchModificationInfos branchModificationInfos) {
List<TwoSides> errorSides = new ArrayList<>();
List<String> errorTypes = new ArrayList<>();

boolean terminalModifiedToConnected = branchModificationInfos.getTerminal1Connected() != null
&& branchModificationInfos.getTerminal1Connected().getValue()
|| branchModificationInfos.getTerminal2Connected() != null
&& branchModificationInfos.getTerminal2Connected().getValue();

if (branchModificationInfos.getTerminal1Connected() != null && !updateConnection(branch, TwoSides.ONE, modificationInfos.getTerminal1Connected().getValue())) {
errorSides.add(TwoSides.ONE);
errorTypes.add(Boolean.TRUE.equals(modificationInfos.getTerminal1Connected().getValue()) ? "connect" : "disconnect");
Expand All @@ -177,6 +183,10 @@ private void updateConnections(Branch<?> branch, BranchModificationInfos branchM
branch.getId(),
errorSides.stream().map(Enum::toString).collect(Collectors.joining("/"))));
}

if (terminalModifiedToConnected) {
ModificationUtils.changeOperatingStatusBranches(branch.getNetwork());
}
}

private boolean updateConnection(Branch<?> branch, TwoSides side, Boolean connectionChange) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.powsybl.iidm.network.extensions.OperatingStatusAdder;
import org.gridsuite.modification.NetworkModificationException;
import org.gridsuite.modification.dto.EquipmentAttributeModificationInfos;
import org.gridsuite.modification.utils.ModificationUtils;

import static org.gridsuite.modification.NetworkModificationException.Type.EQUIPMENT_NOT_FOUND;
import static org.gridsuite.modification.NetworkModificationException.Type.WRONG_EQUIPMENT_TYPE;
Expand Down Expand Up @@ -42,8 +43,11 @@ public void check(Network network) throws NetworkModificationException {
@Override
public void apply(Network network, ReportNode subReportNode) {
Identifiable<?> identifiable = network.getIdentifiable(modificationInfos.getEquipmentId());
if (identifiable instanceof Switch) {
changeSwitchAttribute((Switch) identifiable, modificationInfos.getEquipmentAttributeName(), modificationInfos.getEquipmentAttributeValue(), subReportNode);
if (identifiable instanceof Switch aSwitch) {
changeSwitchAttribute(aSwitch, modificationInfos.getEquipmentAttributeName(), modificationInfos.getEquipmentAttributeValue(), subReportNode);
if (!aSwitch.isOpen()) {
ModificationUtils.changeOperatingStatusBranches(network);
}
} else if (identifiable instanceof Injection) {
if (identifiable instanceof Generator) {
changeGeneratorAttribute((Generator) identifiable, modificationInfos.getEquipmentAttributeName(), modificationInfos.getEquipmentAttributeValue(), subReportNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1798,5 +1798,22 @@ public static void checkIsInInterval(String errorMessage, Float valueToCheck, Pa
throw new NetworkModificationException(exceptionType, errorMessage + "must have " + valueName + " " + interval.getFirst() + " and " + interval.getSecond());
}
}

public static void changeOperatingStatusBranches(Network network) {
List<Branch> branches = network.getBranchStream().filter(branch -> branch.getExtension(OperatingStatus.class) != null).toList();
for (Branch branchline : branches) {
System.out.println("Changing operating status branch " + branchline + " to " + OperatingStatus.class);
//code here
OperatingStatus<?> operatingStatus = (OperatingStatus<?>) branchline.getExtension(OperatingStatus.class);
if (operatingStatus.getStatus() != OperatingStatus.Status.IN_OPERATION) {
Bus bus1 = branchline.getTerminal1().getBusView().getBus();
Bus bus2 = branchline.getTerminal2().getBusView().getBus();

if (bus1 != null && bus1.isInMainConnectedComponent() && bus2 != null && bus2.isInMainConnectedComponent()) {
operatingStatus.setStatus(OperatingStatus.Status.IN_OPERATION);
}
}
}
}
}