Skip to content

Commit

Permalink
Moving code
Browse files Browse the repository at this point in the history
  • Loading branch information
thangqp committed Aug 28, 2024
1 parent ec49408 commit 82f383b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ public final class ModificationUtils {
public static final String CONNECTION_DIRECTION_FIELD_NAME = "Connection direction";
public static final String CONNECTION_POSITION_FIELD_NAME = "Connection position";

public static final String ACTIVE_POWER_CONTROL_DROOP_P0_REQUIRED_ERROR_MSG = "Angle droop active power control, Droop and P0 must be provided together";

private ModificationUtils() {
}

Expand Down Expand Up @@ -1307,20 +1305,5 @@ public static void insertReportNode(ReportNode parent, ReportNode child) {
}
}

public static void checkHvdcDroop(boolean isPresentAngleDroopActivePowerControl, boolean isPresentDroop, boolean isPresentP0) {
// all fields should be filled => OK extension will be created
if (isPresentAngleDroopActivePowerControl && isPresentDroop && isPresentP0) {
return;
}
// at least one field is filled but not for others => NOT OK
if (isPresentAngleDroopActivePowerControl || isPresentDroop || isPresentP0) {
throw new NetworkModificationException(WRONG_HVDC_ANGLE_DROOP_ACTIVE_POWER_CONTROL, ACTIVE_POWER_CONTROL_DROOP_P0_REQUIRED_ERROR_MSG);
}
// all fields are not filled => OK extension will not be created
}

public static boolean shouldCreateHvdcDroopActivePowerControlExtension(boolean isPresentAngleDroopActivePowerControl, boolean isPresentDroop, boolean isPresentP0) {
return isPresentAngleDroopActivePowerControl && isPresentDroop && isPresentP0;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

import static org.gridsuite.modification.server.NetworkModificationException.Type.CREATE_VSC_ERROR;
import static org.gridsuite.modification.server.NetworkModificationException.Type.HVDC_LINE_ALREADY_EXISTS;
import static org.gridsuite.modification.server.modifications.ModificationUtils.checkHvdcDroop;
import static org.gridsuite.modification.server.modifications.ModificationUtils.shouldCreateHvdcDroopActivePowerControlExtension;
import static org.gridsuite.modification.server.modifications.VscModification.checkHvdcDroop;
import static org.gridsuite.modification.server.modifications.VscModification.shouldCreateHvdcDroopActivePowerControlExtension;

/**
* @author Seddik Yengui <seddik.yengui at rte-france.com>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
import javax.annotation.Nonnull;
import java.util.*;

import static org.gridsuite.modification.server.NetworkModificationException.Type.MODIFY_BATTERY_ERROR;
import static org.gridsuite.modification.server.NetworkModificationException.Type.MODIFY_VSC_ERROR;
import static org.gridsuite.modification.server.modifications.ModificationUtils.checkHvdcDroop;
import static org.gridsuite.modification.server.modifications.ModificationUtils.shouldCreateHvdcDroopActivePowerControlExtension;
import static org.gridsuite.modification.server.NetworkModificationException.Type.*;
import static org.gridsuite.modification.server.modifications.VscCreation.VSC_CHARACTERISTICS;
import static org.gridsuite.modification.server.modifications.VscCreation.VSC_SETPOINTS;

Expand All @@ -37,13 +34,30 @@ public class VscModification extends AbstractModification {
public static final String ANGLE_DROOP_ACTIVE_POWER_CONTROL_FIELD = "AngleDroopActivePowerControl";
public static final String DROOP_FIELD = "Droop";
public static final String P0_FIELD = "P0";
public static final String ACTIVE_POWER_CONTROL_DROOP_P0_REQUIRED_ERROR_MSG = "Angle droop active power control, Droop and P0 must be provided together";

private final VscModificationInfos modificationInfos;

public VscModification(VscModificationInfos vscModificationInfos) {
this.modificationInfos = vscModificationInfos;
}

public static void checkHvdcDroop(boolean isPresentAngleDroopActivePowerControl, boolean isPresentDroop, boolean isPresentP0) {
// all fields should be filled => OK extension will be created
if (isPresentAngleDroopActivePowerControl && isPresentDroop && isPresentP0) {
return;
}
// at least one field is filled but not for others => NOT OK
if (isPresentAngleDroopActivePowerControl || isPresentDroop || isPresentP0) {
throw new NetworkModificationException(WRONG_HVDC_ANGLE_DROOP_ACTIVE_POWER_CONTROL, ACTIVE_POWER_CONTROL_DROOP_P0_REQUIRED_ERROR_MSG);
}
// all fields are not filled => OK extension will not be created
}

public static boolean shouldCreateHvdcDroopActivePowerControlExtension(boolean isPresentAngleDroopActivePowerControl, boolean isPresentDroop, boolean isPresentP0) {
return isPresentAngleDroopActivePowerControl && isPresentDroop && isPresentP0;
}

protected void checkConverterStation(@Nonnull ConverterStationModificationInfos converterStationModificationInfos, @Nonnull VscConverterStation vscConverterStation) {
String errorMessage = "Converter station '" + converterStationModificationInfos.getEquipmentId() + "' : ";
ModificationUtils.getInstance().checkReactiveLimit(vscConverterStation, converterStationModificationInfos.getMinQ(), converterStationModificationInfos.getMaxQ(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.gridsuite.modification.server.NetworkModificationException.Type.*;
import static org.gridsuite.modification.server.modifications.ModificationUtils.ACTIVE_POWER_CONTROL_DROOP_P0_REQUIRED_ERROR_MSG;
import static org.gridsuite.modification.server.modifications.VscModification.ACTIVE_POWER_CONTROL_DROOP_P0_REQUIRED_ERROR_MSG;
import static org.gridsuite.modification.server.utils.TestUtils.assertLogMessage;
import static org.junit.Assert.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.gridsuite.modification.server.NetworkModificationException.Type.WRONG_HVDC_ANGLE_DROOP_ACTIVE_POWER_CONTROL;
import static org.gridsuite.modification.server.modifications.ModificationUtils.ACTIVE_POWER_CONTROL_DROOP_P0_REQUIRED_ERROR_MSG;
import static org.gridsuite.modification.server.modifications.VscModification.ACTIVE_POWER_CONTROL_DROOP_P0_REQUIRED_ERROR_MSG;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
Expand Down Expand Up @@ -244,39 +244,6 @@ public void testActivateHvdcAngleDroopActivePowerControl() throws Exception {
Assert.assertTrue(activePowerControl.isEnabled());
}

// @ParameterizedTest(name = "Test modification with absent droop infos when extension does not yet exist [{index}] {0}, {1}, {2}")
// @CsvSource({
// "true,false,false",
// "true,true,false",
// "true,false,true",
// "false,true,false",
// "false,true,true",
// "false,false,true",
// })
// void testHvdcAngleDroopActivePowerControlWithAbsentInfos(boolean isPresentAngleDroopActivePowerControl, boolean isPresentDroop, boolean isPresentP0) {
// var networkuuid = UUID.randomUUID();
// Network networkWithoutExt = NetworkCreation.createWithVSC(networkuuid, false);
// VscModificationInfos modificationInfos = (VscModificationInfos) buildModification();
//
// // reset null depending to test arguments
// if (!isPresentAngleDroopActivePowerControl) {
// modificationInfos.setAngleDroopActivePowerControl(null);
// }
// if (!isPresentDroop) {
// modificationInfos.setDroop(null);
// }
// if (!isPresentP0) {
// modificationInfos.setP0(null);
// }
//
// VscModification wrongVscModification = new VscModification(modificationInfos);
// String message = Assert.assertThrows(NetworkModificationException.class,
// () -> wrongVscModification.check(networkWithoutExt))
// .getMessage();
// assertThat(message).isEqualTo(WRONG_HVDC_ANGLE_DROOP_ACTIVE_POWER_CONTROL.name() + " : "
// + ACTIVE_POWER_CONTROL_DROOP_P0_REQUIRED_ERROR_MSG);
// }

@Test
public void testAngleDroopActivePowerControlWithAbsentInfos() {
var networkuuid = UUID.randomUUID();
Expand Down

0 comments on commit 82f383b

Please sign in to comment.