Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
thangqp committed Sep 27, 2024
1 parent 1823ef9 commit bab677c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,38 +65,46 @@ public static String getReferenceValue(Generator generator, String generatorFiel

public static void setNewValue(Generator generator, String generatorField, @NotNull String newValue) {
GeneratorField field = GeneratorField.valueOf(generatorField);
final AttributeModification<Double> attributeModification = new AttributeModification<>(Double.parseDouble(newValue), OperationType.SET);
switch (field) {
case MAXIMUM_ACTIVE_POWER -> modifyGeneratorActiveLimitsAttributes(
attributeModification, null, null, generator, null);
case MINIMUM_ACTIVE_POWER -> modifyGeneratorActiveLimitsAttributes(null, attributeModification, null, generator, null);
new AttributeModification<>(Double.parseDouble(newValue), OperationType.SET),
null, null, generator, null);
case MINIMUM_ACTIVE_POWER -> modifyGeneratorActiveLimitsAttributes(
null, new AttributeModification<>(Double.parseDouble(newValue), OperationType.SET), null, generator, null);
case ACTIVE_POWER_SET_POINT -> {
ModificationUtils.getInstance().checkActivePowerZeroOrBetweenMinAndMaxActivePower(
attributeModification, null, null,
generator.getMinP(), generator.getMaxP(), generator.getTargetP(),
MODIFY_GENERATOR_ERROR, "Generator '" + generator.getId() + "' : "
new AttributeModification<>(Double.parseDouble(newValue), OperationType.SET),
null, null, generator.getMinP(), generator.getMaxP(), generator.getTargetP(),
MODIFY_GENERATOR_ERROR, "Generator '" + generator.getId() + "' : "
);
generator.setTargetP(Double.parseDouble(newValue));
}
case RATED_NOMINAL_POWER -> modifyGeneratorActiveLimitsAttributes(null, null, attributeModification, generator, null);
case REACTIVE_POWER_SET_POINT -> modifyTargetQ(generator, attributeModification);
case VOLTAGE_SET_POINT -> modifyTargetV(generator, attributeModification);
case PLANNED_ACTIVE_POWER_SET_POINT ->
modifyGeneratorStartUpAttributes(attributeModification, null, null, null, generator, null, null);
case MARGINAL_COST ->
modifyGeneratorStartUpAttributes(null, attributeModification, null, null, generator, null, null);
case PLANNED_OUTAGE_RATE ->
modifyGeneratorStartUpAttributes(null, null, attributeModification, null, generator, null, null);
case RATED_NOMINAL_POWER -> modifyGeneratorActiveLimitsAttributes(
null, null, new AttributeModification<>(Double.parseDouble(newValue), OperationType.SET), generator, null);
case REACTIVE_POWER_SET_POINT -> modifyTargetQ(generator, new AttributeModification<>(Double.parseDouble(newValue), OperationType.SET));
case VOLTAGE_SET_POINT -> modifyTargetV(generator, new AttributeModification<>(Double.parseDouble(newValue), OperationType.SET));
case PLANNED_ACTIVE_POWER_SET_POINT -> modifyGeneratorStartUpAttributes(
new AttributeModification<>(Double.parseDouble(newValue), OperationType.SET), null,
null, null, generator, null, null);
case MARGINAL_COST -> modifyGeneratorStartUpAttributes(
null, new AttributeModification<>(Double.parseDouble(newValue), OperationType.SET),
null, null, generator, null, null);
case PLANNED_OUTAGE_RATE -> modifyGeneratorStartUpAttributes(
null, null, new AttributeModification<>(Double.parseDouble(newValue), OperationType.SET),
null, generator, null, null);
case FORCED_OUTAGE_RATE ->
modifyGeneratorStartUpAttributes(null, null, null, attributeModification, generator, null, null);
modifyGeneratorStartUpAttributes(null, null, null, new AttributeModification<>(Double.parseDouble(newValue), OperationType.SET), generator, null, null);
case DROOP -> {
ActivePowerControl<Generator> activePowerControl = generator.getExtension(ActivePowerControl.class);
ActivePowerControlAdder<Generator> activePowerControlAdder = generator.newExtension(ActivePowerControlAdder.class);
ModificationUtils.getInstance().modifyActivePowerControlAttributes(activePowerControl, activePowerControlAdder, null,
new AttributeModification<>(Float.parseFloat(newValue), OperationType.SET), null, null);
}
case TRANSIENT_REACTANCE -> modifyGeneratorShortCircuitAttributes(attributeModification, null, generator, null);
case STEP_UP_TRANSFORMER_REACTANCE -> modifyGeneratorShortCircuitAttributes(null, attributeModification, generator, null);
case TRANSIENT_REACTANCE -> modifyGeneratorShortCircuitAttributes(
new AttributeModification<>(Double.parseDouble(newValue), OperationType.SET),
null, generator, null);
case STEP_UP_TRANSFORMER_REACTANCE -> modifyGeneratorShortCircuitAttributes(
null, new AttributeModification<>(Double.parseDouble(newValue), OperationType.SET), generator, null);
case Q_PERCENT -> generator.newExtension(CoordinatedReactiveControlAdderImpl.class)
.withQPercent(Double.parseDouble(newValue))
.add();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ public static void setNewValue(TwoWindingsTransformer transformer, String twoWin
null, new AttributeModification<>((int) Double.parseDouble(newValue), OperationType.SET), null, null);
case RATIO_TARGET_DEADBAND -> modifyTargets(ratioTapChanger, null, true, null, attributeModification, null);
case REGULATION_VALUE -> processPhaseTapRegulation(
phaseTapChanger, null, regulationMode, true, attributeModification, null, null
);
phaseTapChanger, null, regulationMode, true, attributeModification, null, null);
case PHASE_LOW_TAP_POSITION -> processTapChangerPositionsAndSteps(phaseTapChanger, null, true,
new AttributeModification<>((int) Double.parseDouble(newValue), OperationType.SET), null, null, null);
case PHASE_TAP_POSITION -> processTapChangerPositionsAndSteps(phaseTapChanger, null, true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import org.gridsuite.filter.identifierlistfilter.IdentifierListFilter;
import org.gridsuite.filter.identifierlistfilter.IdentifierListFilterEquipmentAttributes;
import org.gridsuite.filter.utils.EquipmentType;
import org.gridsuite.modification.server.dto.byfilter.equipmentfield.BatteryField;
import org.gridsuite.modification.server.dto.byfilter.assignment.AssignmentInfos;
import org.gridsuite.modification.server.dto.byfilter.assignment.DoubleAssignmentInfos;
import org.gridsuite.modification.server.dto.byfilter.equipmentfield.BatteryField;
import org.gridsuite.modification.server.impacts.AbstractBaseImpact;
import org.junit.Test;

Expand Down Expand Up @@ -112,7 +112,7 @@ protected List<AssignmentInfos<?>> getAssignmentInfos() {
DoubleAssignmentInfos assignmentInfos3 = DoubleAssignmentInfos.builder()
.filters(List.of(filter5))
.editedField(BatteryField.ACTIVE_POWER_SET_POINT.name())
.value(30.)
.value(75.)
.build();

DoubleAssignmentInfos assignmentInfos4 = DoubleAssignmentInfos.builder()
Expand Down Expand Up @@ -165,9 +165,9 @@ protected void assertAfterNetworkModificationCreation() {
assertEquals(2, activePowerControl1.getDroop(), 0);

assertEquals(80, getNetwork().getBattery(BATTERY_ID_2).getMaxP(), 0);
assertEquals(30, getNetwork().getBattery(BATTERY_ID_2).getTargetP(), 0);
assertEquals(75, getNetwork().getBattery(BATTERY_ID_2).getTargetP(), 0);
assertEquals(80, getNetwork().getBattery(BATTERY_ID_3).getMaxP(), 0);
assertEquals(30, getNetwork().getBattery(BATTERY_ID_3).getTargetP(), 0);
assertEquals(75, getNetwork().getBattery(BATTERY_ID_3).getTargetP(), 0);
assertEquals(80, getNetwork().getBattery(BATTERY_ID_4).getMaxP(), 0);

assertEquals(30, getNetwork().getBattery(BATTERY_ID_5).getMinP(), 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ protected void assertAfterNetworkModificationCreation() {
assertThat(generator1.getProperty("propertyName")).isEqualTo("propertyValue");
assertEquals(100, generator1.getTargetP(), 0);
assertEquals(2, generatorStartup1.getMarginalCost(), 0);
assertEquals(55, generatorStartup1.getPlannedOutageRate(), 0);
assertEquals(0.1, generatorStartup1.getPlannedOutageRate(), 0);
assertEquals(0.05, generatorStartup1.getForcedOutageRate(), 0);
assertEquals(10, generatorStartup1.getPlannedActivePowerSetpoint(), 0);
assertEquals(50, generator1.getMaxP(), 0);
Expand All @@ -299,7 +299,7 @@ protected void assertAfterNetworkModificationCreation() {
assertThat(generator2.getProperty("propertyName")).isEqualTo("propertyValue");
assertEquals(200, generator2.getTargetP(), 0);
assertEquals(2, generatorStartup2.getMarginalCost(), 0);
assertEquals(55, generatorStartup2.getPlannedOutageRate(), 0);
assertEquals(0.1, generatorStartup2.getPlannedOutageRate(), 0);
assertEquals(0.05, generatorStartup2.getForcedOutageRate(), 0);
assertEquals(10, generatorStartup2.getPlannedActivePowerSetpoint(), 0);
assertEquals(50, generator2.getMaxP(), 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ protected void createEquipments() {
"trf1", 30, ConnectablePosition.Direction.TOP,
"trf1", 40, ConnectablePosition.Direction.BOTTOM);
twt4.setRatedS(15);
addPhaseTapChangerSteps(twt4.newPhaseTapChanger().setRegulationValue(45).setLowTapPosition(1).setTapPosition(2).setTargetDeadband(34));
addPhaseTapChangerSteps(twt4.newPhaseTapChanger()
.setRegulationValue(45)
.setLowTapPosition(1)
.setTapPosition(2)
.setTargetDeadband(34)
.setRegulationMode(PhaseTapChanger.RegulationMode.ACTIVE_POWER_CONTROL));

TwoWindingsTransformer twt5 = createTwoWindingsTransformer(s3, TWT_ID_5, TWT_ID_5, 50, 60, 70,
80, 30, 40, 101, 101,
Expand Down

0 comments on commit bab677c

Please sign in to comment.