Skip to content

Commit

Permalink
correct tests
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu DEHARBE <[email protected]>
  • Loading branch information
Mathieu-Deharbe committed Sep 3, 2024
1 parent c37e5a0 commit a8ae013
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
package org.gridsuite.modification.server.dto.formula.equipmentfield;

import com.powsybl.iidm.network.Load;
import org.gridsuite.modification.server.dto.AttributeModification;
import org.gridsuite.modification.server.dto.OperationType;

import static org.gridsuite.modification.server.modifications.LoadModification.modifyP0;
import static org.gridsuite.modification.server.modifications.LoadModification.modifyQ0;

/**
* @author Seddik Yengui <Seddik.yengui at rte-france.com>
Expand All @@ -28,8 +33,8 @@ public static Double getReferenceValue(Load load, String loadField) {
public static void setNewValue(Load load, String loadField, Double newValue) {
LoadField field = LoadField.valueOf(loadField);
switch (field) {
case ACTIVE_POWER -> load.setP0(newValue);
case REACTIVE_POWER -> load.setQ0(newValue);
case ACTIVE_POWER -> modifyP0(load, new AttributeModification<>(newValue, OperationType.SET), null);
case REACTIVE_POWER -> modifyQ0(load, new AttributeModification<>(newValue, OperationType.SET), null);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.powsybl.iidm.network.extensions.ConnectablePosition;
import com.powsybl.iidm.network.extensions.ConnectablePositionAdder;
import org.gridsuite.modification.server.NetworkModificationException;
import org.gridsuite.modification.server.dto.AttributeModification;
import org.gridsuite.modification.server.dto.LoadModificationInfos;

import static org.gridsuite.modification.server.NetworkModificationException.Type.LOAD_NOT_FOUND;
Expand Down Expand Up @@ -53,13 +54,21 @@ private void modifyLoad(Load load, ReportNode subReportNode) {

ModificationUtils.getInstance().applyElementaryModifications(load::setName, () -> load.getOptionalName().orElse("No value"), modificationInfos.getEquipmentName(), subReportNode, "Name");
ModificationUtils.getInstance().applyElementaryModifications(load::setLoadType, load::getLoadType, modificationInfos.getLoadType(), subReportNode, "Type");
ModificationUtils.getInstance().applyElementaryModifications(load::setP0, load::getP0, modificationInfos.getP0(), subReportNode, "Constant active power");
ModificationUtils.getInstance().applyElementaryModifications(load::setQ0, load::getQ0, modificationInfos.getQ0(), subReportNode, "Constant reactive power");
modifyP0(load, modificationInfos.getP0(), subReportNode);
modifyQ0(load, modificationInfos.getQ0(), subReportNode);
modifyLoadConnectivityAttributes(modificationInfos, load, subReportNode);
// properties
PropertiesUtils.applyProperties(load, subReportNode, modificationInfos.getProperties(), "LoadProperties");
}

public static void modifyQ0(Load load, AttributeModification<Double> q0, ReportNode subReportNode) {
ModificationUtils.getInstance().applyElementaryModifications(load::setQ0, load::getQ0, q0, subReportNode, "Constant reactive power");
}

public static void modifyP0(Load load, AttributeModification<Double> p0, ReportNode subReportNode) {
ModificationUtils.getInstance().applyElementaryModifications(load::setP0, load::getP0, p0, subReportNode, "Constant active power");
}

private ReportNode modifyLoadConnectivityAttributes(LoadModificationInfos modificationInfos,
Load load, ReportNode subReportNode) {
ConnectablePosition<Load> connectablePosition = load.getExtension(ConnectablePosition.class);
Expand Down

0 comments on commit a8ae013

Please sign in to comment.