Skip to content

Commit

Permalink
Add check for shunt compensator on section count
Browse files Browse the repository at this point in the history
Signed-off-by: Lilian Houdelet <lhoudelet@oxyl.fr>
  • Loading branch information
lilian-houdelet committed Dec 28, 2023
1 parent 31a56b5 commit 8377135
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public void check(Network network) throws NetworkModificationException {
if (network.getShuntCompensator(modificationInfos.getEquipmentId()) != null) {
throw new NetworkModificationException(SHUNT_COMPENSATOR_ALREADY_EXISTS, modificationInfos.getEquipmentId());
}
if (modificationInfos.getMaximumSectionCount() < 1 || modificationInfos.getSectionCount() < 1 || modificationInfos.getSectionCount() > modificationInfos.getMaximumSectionCount()) {
throw new NetworkModificationException(CREATE_SHUNT_COMPENSATOR_ERROR, modificationInfos.getEquipmentId());
}
ModificationUtils.getInstance().controlConnectivity(network, modificationInfos.getVoltageLevelId(),
modificationInfos.getBusOrBusbarSectionId(), modificationInfos.getConnectionPosition());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import java.util.ArrayList;
import java.util.List;

import static org.gridsuite.modification.server.NetworkModificationException.Type.SHUNT_COMPENSATOR_NOT_FOUND;
import static org.gridsuite.modification.server.NetworkModificationException.Type.VOLTAGE_LEVEL_NOT_FOUND;
import static org.gridsuite.modification.server.NetworkModificationException.Type.*;

/**
* @author Seddik Yengui <Seddik.yengui at rte-france.com>
Expand Down Expand Up @@ -51,6 +50,19 @@ public void check(Network network) throws NetworkModificationException {
throw new NetworkModificationException(VOLTAGE_LEVEL_NOT_FOUND,
String.format("Voltage level %s does not exist in network", modificationInfos.getVoltageLevelId()));
}

int maximumSectionCount = modificationInfos.getMaximumSectionCount() != null
? modificationInfos.getMaximumSectionCount().getValue()
: shuntCompensator.getMaximumSectionCount();

int sectionCount = modificationInfos.getSectionCount() != null
? modificationInfos.getSectionCount().getValue()
: shuntCompensator.getSectionCount();

if (sectionCount < 1 || maximumSectionCount < 1 || sectionCount > maximumSectionCount) {
throw new NetworkModificationException(MODIFY_SHUNT_COMPENSATOR_ERROR, modificationInfos.getEquipmentId());
}

}

@Override
Expand Down

0 comments on commit 8377135

Please sign in to comment.