From 8fb90d5f51f44b0a3bcd3674baf7b9be1aa81215 Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Tue, 22 Oct 2024 11:15:47 +0200 Subject: [PATCH] add report for regulation mode and type --- .../modifications/ModificationUtils.java | 6 ++--- .../StaticVarCompensatorCreation.java | 10 +++++--- ...rCompensatorCreationInNodeBreakerTest.java | 25 ++++++++++++++++--- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/gridsuite/modification/server/modifications/ModificationUtils.java b/src/main/java/org/gridsuite/modification/server/modifications/ModificationUtils.java index 90652193e..ed69f35ae 100644 --- a/src/main/java/org/gridsuite/modification/server/modifications/ModificationUtils.java +++ b/src/main/java/org/gridsuite/modification/server/modifications/ModificationUtils.java @@ -1338,7 +1338,7 @@ public void checkReactivePowerLimitsAndSetPointsCreation(StaticVarCompensatorCre throw makeEquipmentException(creationInfos.getErrorType(), creationInfos.getEquipmentId(), equipmentName, "maximum susceptance is expected to be greater than or equal to minimum susceptance"); } if (Objects.nonNull(creationInfos.getMaxQAtNominalV()) && Objects.nonNull(creationInfos.getMinQAtNominalV()) && creationInfos.getMaxQAtNominalV() < creationInfos.getMinQAtNominalV()) { - throw makeEquipmentException(creationInfos.getErrorType(), creationInfos.getEquipmentId(), equipmentName, "maximum Q is expected to be greater than or equal to minimum Q"); + throw makeEquipmentException(creationInfos.getErrorType(), creationInfos.getEquipmentId(), equipmentName, "maximum Q at nominal voltage is expected to be greater than or equal to minimum Q"); } // check set points @@ -1358,12 +1358,12 @@ public void checkStandbyAutomatonCreation(StaticVarCompensatorCreationInfos crea if (Objects.nonNull(creationInfos.getB0()) && Objects.nonNull(creationInfos.getMinSusceptance()) && Objects.nonNull(creationInfos.getMaxSusceptance()) && (creationInfos.getB0() < creationInfos.getMinSusceptance() || creationInfos.getB0() > creationInfos.getMaxSusceptance())) { throw makeEquipmentException(creationInfos.getErrorType(), creationInfos.getEquipmentId(), equipmentName, - "b0 must be within the range of minimun susceptance and maximum susceptance"); + "b0 must be within the range of minimum susceptance and maximum susceptance"); } if (Objects.nonNull(creationInfos.getQ0()) && Objects.nonNull(creationInfos.getMinQAtNominalV()) && Objects.nonNull(creationInfos.getMaxQAtNominalV()) && (creationInfos.getQ0() < creationInfos.getMinQAtNominalV() || creationInfos.getQ0() > creationInfos.getMaxQAtNominalV())) { throw makeEquipmentException(creationInfos.getErrorType(), creationInfos.getEquipmentId(), equipmentName, - "q0 must be within the range of minimun Q and maximum Q"); + "q0 must be within the range of minimum Q and maximum Q"); } } diff --git a/src/main/java/org/gridsuite/modification/server/modifications/StaticVarCompensatorCreation.java b/src/main/java/org/gridsuite/modification/server/modifications/StaticVarCompensatorCreation.java index 2bba579e8..13e94948d 100644 --- a/src/main/java/org/gridsuite/modification/server/modifications/StaticVarCompensatorCreation.java +++ b/src/main/java/org/gridsuite/modification/server/modifications/StaticVarCompensatorCreation.java @@ -13,7 +13,6 @@ import com.powsybl.iidm.network.extensions.StandbyAutomatonAdder; import org.gridsuite.modification.server.NetworkModificationException; import org.gridsuite.modification.server.dto.StaticVarCompensatorCreationInfos; -import org.gridsuite.modification.server.dto.VoltageRegulationType; import java.util.ArrayList; import java.util.List; @@ -212,15 +211,18 @@ private void reportStaticVarCompensatorLimitsAndSetpoints(StaticVarCompensatorCr if (Objects.nonNull(staticVarCompensatorCreationInfos.getMaxQAtNominalV())) { voltageReports.add(ModificationUtils.getInstance().buildCreationReport(staticVarCompensatorCreationInfos.getMaxQAtNominalV(), "Q max at nominal voltage")); } + if (Objects.nonNull(staticVarCompensatorCreationInfos.getRegulationMode())) { + voltageReports.add(ModificationUtils.getInstance().buildCreationReport(staticVarCompensatorCreationInfos.getRegulationMode(), "regulation mode")); + } if (Objects.nonNull(staticVarCompensatorCreationInfos.getVoltageSetpoint())) { voltageReports.add(ModificationUtils.getInstance().buildCreationReport(staticVarCompensatorCreationInfos.getVoltageSetpoint(), "Voltage set point")); } if (Objects.nonNull(staticVarCompensatorCreationInfos.getReactivePowerSetpoint())) { voltageReports.add(ModificationUtils.getInstance().buildCreationReport(staticVarCompensatorCreationInfos.getReactivePowerSetpoint(), "Reactive power set point")); } - voltageReports.add(ModificationUtils.getInstance() - .createEnabledDisabledReport("VoltageRegulationOn", modificationInfos.getVoltageRegulationType() == VoltageRegulationType.DISTANT && - modificationInfos.getRegulationMode() == StaticVarCompensator.RegulationMode.VOLTAGE)); + if (Objects.nonNull(staticVarCompensatorCreationInfos.getVoltageRegulationType())) { + voltageReports.add(ModificationUtils.getInstance().buildCreationReport(staticVarCompensatorCreationInfos.getVoltageRegulationType(), "Voltage Regulation type")); + } if (staticVarCompensatorCreationInfos.getRegulatingTerminalVlId() != null && staticVarCompensatorCreationInfos.getRegulatingTerminalId() != null && staticVarCompensatorCreationInfos.getRegulatingTerminalType() != null) { Terminal terminal = ModificationUtils.getInstance().getTerminalFromIdentifiable(voltageLevel.getNetwork(), diff --git a/src/test/java/org/gridsuite/modification/server/modifications/StaticVarCompensatorCreationInNodeBreakerTest.java b/src/test/java/org/gridsuite/modification/server/modifications/StaticVarCompensatorCreationInNodeBreakerTest.java index 461765166..63f19e1e2 100644 --- a/src/test/java/org/gridsuite/modification/server/modifications/StaticVarCompensatorCreationInNodeBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/server/modifications/StaticVarCompensatorCreationInNodeBreakerTest.java @@ -184,6 +184,14 @@ public void testCreateWithErrors() throws Exception { compensatorCreationInfos.setMaxSusceptance(null); compensatorCreationInfos.setMinSusceptance(null); compensatorCreationInfos.setMaxQAtNominalV(200.0); + compensatorCreationInfos.setMinQAtNominalV(300.0); + compensatorCreationInfosJson = mapper.writeValueAsString(compensatorCreationInfos); + mockMvc.perform(post(getNetworkModificationUri()).content(compensatorCreationInfosJson).contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()); + assertLogMessage("CREATE_STATIC_VAR_COMPENSATOR_ERROR : " + + "StaticVarCompensator 'idStaticVarCompensator2' : maximum Q at nominal voltage is expected to be greater than or equal to minimum Q", + compensatorCreationInfos.getErrorType().name(), reportService); + compensatorCreationInfos.setMaxQAtNominalV(200.0); compensatorCreationInfos.setMinQAtNominalV(100.0); compensatorCreationInfos.setRegulationMode(StaticVarCompensator.RegulationMode.REACTIVE_POWER); compensatorCreationInfos.setReactivePowerSetpoint(null); @@ -213,7 +221,7 @@ public void testCreateWithErrors() throws Exception { }); assertTrue(networkModificationResult.isEmpty()); assertNull(getNetwork().getStaticVarCompensator("idStaticVarCompensator3")); - testNetworkModificationsCount(getGroupId(), 10); + testNetworkModificationsCount(getGroupId(), 11); } @Test @@ -234,11 +242,20 @@ public void testCreateWithStandbyAutomatonErrors() throws Exception { mockMvc.perform(post(getNetworkModificationUri()).content(compensatorCreationInfosJson).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); assertLogMessage("CREATE_STATIC_VAR_COMPENSATOR_ERROR : " + - "StaticVarCompensator 'idStaticVarCompensator1' : q0 must be within the range of minimun Q and maximum Q", + "StaticVarCompensator 'idStaticVarCompensator1' : q0 must be within the range of minimum Q and maximum Q", compensatorCreationInfos.getErrorType().name(), reportService); - - compensatorCreationInfos.setB0(200.0); + compensatorCreationInfos.setMinQAtNominalV(null); + compensatorCreationInfos.setMaxQAtNominalV(null); + compensatorCreationInfos.setMaxSusceptance(300.0); + compensatorCreationInfos.setMinSusceptance(200.0); + compensatorCreationInfos.setB0(400.0); compensatorCreationInfos.setQ0(null); + compensatorCreationInfosJson = mapper.writeValueAsString(compensatorCreationInfos); + mockMvc.perform(post(getNetworkModificationUri()).content(compensatorCreationInfosJson).contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()); + assertLogMessage("CREATE_STATIC_VAR_COMPENSATOR_ERROR : " + + "StaticVarCompensator 'idStaticVarCompensator1' : b0 must be within the range of minimum susceptance and maximum susceptance", + compensatorCreationInfos.getErrorType().name(), reportService); compensatorCreationInfos.setRegulationMode(OFF); compensatorCreationInfos.setStandby(true);