Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the possibility to trip a busbar section. #493

Merged
merged 9 commits into from
Sep 5, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.powsybl.commons.report.ReportNode;
import com.powsybl.commons.report.TypedValue;
import com.powsybl.iidm.modification.tripping.BranchTripping;
import com.powsybl.iidm.modification.tripping.BusbarSectionTripping;
import com.powsybl.iidm.modification.tripping.HvdcLineTripping;
import com.powsybl.iidm.modification.tripping.ThreeWindingsTransformerTripping;
import com.powsybl.iidm.modification.tripping.Tripping;
Expand Down Expand Up @@ -178,6 +179,8 @@ private boolean connectOneTerminal(Terminal terminal) {
public Tripping getTrippingFromIdentifiable(Identifiable<?> identifiable) {
if (identifiable instanceof Branch<?> branch) {
return new BranchTripping(branch.getId());
} else if (identifiable instanceof BusbarSection bbs) {
return new BusbarSectionTripping(bbs.getId());
} else if (identifiable instanceof ThreeWindingsTransformer w3t) {
return new ThreeWindingsTransformerTripping(w3t.getId());
} else if (identifiable instanceof HvdcLine hvdcLine) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**
* Copyright (c) 2022, RTE (http://www.rte-france.com)
EstherDarkish marked this conversation as resolved.
Show resolved Hide resolved
* 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/.
*/
package org.gridsuite.modification.server.modifications;

import com.fasterxml.jackson.core.type.TypeReference;
import com.powsybl.iidm.network.*;
import com.powsybl.iidm.network.extensions.OperatingStatus;
import lombok.SneakyThrows;
import org.gridsuite.modification.server.dto.ModificationInfos;
import org.gridsuite.modification.server.dto.OperatingStatusModificationInfos;
import org.gridsuite.modification.server.utils.NetworkCreation;
import org.gridsuite.modification.server.utils.TestUtils;
import org.junit.Assert;
import org.junit.jupiter.api.Tag;

import java.util.Map;
import java.util.UUID;

import static com.powsybl.iidm.network.extensions.OperatingStatus.Status.FORCED_OUTAGE;
import static com.powsybl.iidm.network.extensions.OperatingStatus.Status.PLANNED_OUTAGE;
import static org.junit.jupiter.api.Assertions.assertEquals;

@Tag("IntegrationTest")
public class OperatingStatusModificationTripBusBarTest extends AbstractNetworkModificationTest {

private static final String TARGET_BUSBAR_ID = "1.A";
private static final String UPDATE_BRANCH_ID = "line1";
antoinebhs marked this conversation as resolved.
Show resolved Hide resolved
private static final OperatingStatus.Status TARGET_BRANCH_STATUS = FORCED_OUTAGE;
EstherDarkish marked this conversation as resolved.
Show resolved Hide resolved
private static final OperatingStatus.Status OTHER_BRANCH_STATUS = PLANNED_OUTAGE;
EstherDarkish marked this conversation as resolved.
Show resolved Hide resolved

@Override
protected Network createNetwork(UUID networkUuid) {
Network network = NetworkCreation.create(networkUuid, true);
// force a branch status different from the expected one, after testCreate
TestUtils.setOperatingStatus(network, TARGET_BUSBAR_ID, OTHER_BRANCH_STATUS);
return network;
}

@Override
protected ModificationInfos buildModification() {
return OperatingStatusModificationInfos.builder()
.stashed(false)
.equipmentId(TARGET_BUSBAR_ID)
.energizedVoltageLevelId("energizedVoltageLevelId")
EstherDarkish marked this conversation as resolved.
Show resolved Hide resolved
.action(OperatingStatusModificationInfos.ActionType.TRIP).build();
}

@Override
protected ModificationInfos buildModificationUpdate() {
return OperatingStatusModificationInfos.builder()
.stashed(false)
.equipmentId(UPDATE_BRANCH_ID)
.energizedVoltageLevelId("energizedVoltageLevelIdEdited")
EstherDarkish marked this conversation as resolved.
Show resolved Hide resolved
.action(OperatingStatusModificationInfos.ActionType.SWITCH_ON).build();
}

@Override
protected void assertAfterNetworkModificationCreation() {
TestUtils.assertOperatingStatus(getNetwork(), TARGET_BUSBAR_ID, TARGET_BRANCH_STATUS);
assertTerminalsStatusAfterNetworkModification(false);
}

@Override
protected void assertAfterNetworkModificationDeletion() {
// back to init status
TestUtils.assertOperatingStatus(getNetwork(), TARGET_BUSBAR_ID, OTHER_BRANCH_STATUS);
assertTerminalsStatusAfterNetworkModification(true);
}

@Override
@SneakyThrows
protected void testCreationModificationMessage(ModificationInfos modificationInfos) {
assertEquals("OPERATING_STATUS_MODIFICATION", modificationInfos.getMessageType());
Map<String, String> createdValues = mapper.readValue(modificationInfos.getMessageValues(), new TypeReference<>() { });
assertEquals("energizedVoltageLevelId", createdValues.get("energizedVoltageLevelId"));
EstherDarkish marked this conversation as resolved.
Show resolved Hide resolved
assertEquals("TRIP", createdValues.get("action"));
assertEquals("1.A", createdValues.get("equipmentId"));
}

@Override
@SneakyThrows
protected void testUpdateModificationMessage(ModificationInfos modificationInfos) {
assertEquals("OPERATING_STATUS_MODIFICATION", modificationInfos.getMessageType());
Map<String, String> updatedValues = mapper.readValue(modificationInfos.getMessageValues(), new TypeReference<>() { });
assertEquals("energizedVoltageLevelIdEdited", updatedValues.get("energizedVoltageLevelId"));
EstherDarkish marked this conversation as resolved.
Show resolved Hide resolved
assertEquals("SWITCH_ON", updatedValues.get("action"));
assertEquals("line1", updatedValues.get("equipmentId"));
}

private void assertTerminalsStatusAfterNetworkModification(boolean shouldBeConnected) {
BusbarSection busbarSection = getNetwork().getBusbarSection(TARGET_BUSBAR_ID);
Assert.assertEquals(busbarSection.getTerminal().isConnected(), shouldBeConnected);
}
}
Loading