diff --git a/data/crac/crac-api/src/main/java/com/powsybl/openrao/data/cracapi/networkaction/SingleNetworkElementActionAdder.java b/data/crac/crac-api/src/main/java/com/powsybl/openrao/data/cracapi/networkaction/SingleNetworkElementActionAdder.java index a21e3fbbd5..687753c0ca 100644 --- a/data/crac/crac-api/src/main/java/com/powsybl/openrao/data/cracapi/networkaction/SingleNetworkElementActionAdder.java +++ b/data/crac/crac-api/src/main/java/com/powsybl/openrao/data/cracapi/networkaction/SingleNetworkElementActionAdder.java @@ -9,6 +9,8 @@ package com.powsybl.openrao.data.cracapi.networkaction; public interface SingleNetworkElementActionAdder> { + T withId(String id); + T withNetworkElement(String networkElementId); T withNetworkElement(String networkElementId, String networkElementName); diff --git a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/AbstractSingleNetworkElementActionAdderImpl.java b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/AbstractSingleNetworkElementActionAdderImpl.java index 3e872da084..0bd9d6cb42 100644 --- a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/AbstractSingleNetworkElementActionAdderImpl.java +++ b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/AbstractSingleNetworkElementActionAdderImpl.java @@ -19,6 +19,7 @@ */ public abstract class AbstractSingleNetworkElementActionAdderImpl { protected NetworkActionAdderImpl ownerAdder; + protected String id; protected String networkElementId; private String networkElementName; @@ -26,6 +27,11 @@ public abstract class AbstractSingleNetworkElementActionAdderImpl { this.ownerAdder = ownerAdder; } + public I withId(String id) { + this.id = id; + return (I) this; + } + public I withNetworkElement(String networkElementId) { this.networkElementId = networkElementId; return (I) this; @@ -38,7 +44,7 @@ public I withNetworkElement(String networkElementId, String networkElementName) } public NetworkActionAdder add() { - assertAttributeNotNull(networkElementId, getActionName(), "network element", "withNetworkElement()"); + assertAttributeNotNull(networkElementId, getActionTypeName(), "network element", "withNetworkElement()"); assertSpecificAttributes(); NetworkElement networkElement = this.ownerAdder.getCrac().addNetworkElement(networkElementId, networkElementName); ownerAdder.addElementaryAction(buildAction(), networkElement); @@ -49,5 +55,9 @@ public NetworkActionAdder add() { protected abstract void assertSpecificAttributes(); - protected abstract String getActionName(); + protected abstract String getActionTypeName(); + + protected String createActionName(Object specificAttribute) { + return id == null ? String.format("%s_%s_%s", getActionTypeName(), networkElementId, specificAttribute) : id; + } } diff --git a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/DanglingLineActionAdderImpl.java b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/DanglingLineActionAdderImpl.java index 185114a68c..57d66c6e02 100644 --- a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/DanglingLineActionAdderImpl.java +++ b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/DanglingLineActionAdderImpl.java @@ -33,7 +33,7 @@ public DanglingLineActionAdder withActivePowerValue(double activePowerValue) { protected Action buildAction() { return new DanglingLineActionBuilder() - .withId(String.format("%s_%s_%s", getActionName(), networkElementId, activePowerValue)) + .withId(createActionName(activePowerValue)) .withNetworkElementId(networkElementId) .withRelativeValue(false) .withActivePowerValue(activePowerValue) @@ -41,10 +41,10 @@ protected Action buildAction() { } protected void assertSpecificAttributes() { - assertAttributeNotNull(activePowerValue, getActionName(), "activePowerValue", "withActivePowerValue()"); + assertAttributeNotNull(activePowerValue, getActionTypeName(), "activePowerValue", "withActivePowerValue()"); } - protected String getActionName() { + protected String getActionTypeName() { return "DanglingLineAction"; } } diff --git a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/GeneratorActionAdderImpl.java b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/GeneratorActionAdderImpl.java index 1fe8ee6c19..5283a312ce 100644 --- a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/GeneratorActionAdderImpl.java +++ b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/GeneratorActionAdderImpl.java @@ -32,7 +32,7 @@ public GeneratorActionAdder withActivePowerValue(double activePowerValue) { protected Action buildAction() { return new GeneratorActionBuilder() - .withId(String.format("%s_%s_%s", getActionName(), networkElementId, activePowerValue)) + .withId(createActionName(activePowerValue)) .withNetworkElementId(networkElementId) .withActivePowerRelativeValue(false) .withActivePowerValue(activePowerValue) @@ -40,10 +40,10 @@ protected Action buildAction() { } protected void assertSpecificAttributes() { - assertAttributeNotNull(activePowerValue, getActionName(), "activePowerValue", "withActivePowerValue()"); + assertAttributeNotNull(activePowerValue, getActionTypeName(), "activePowerValue", "withActivePowerValue()"); } - protected String getActionName() { + protected String getActionTypeName() { return "GeneratorAction"; } } diff --git a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/LoadActionAdderImpl.java b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/LoadActionAdderImpl.java index c841ee1a40..636e3030a1 100644 --- a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/LoadActionAdderImpl.java +++ b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/LoadActionAdderImpl.java @@ -33,7 +33,7 @@ public LoadActionAdder withActivePowerValue(double activePowerValue) { protected Action buildAction() { return new LoadActionBuilder() - .withId(String.format("%s_%s_%s", getActionName(), networkElementId, activePowerValue)) + .withId(createActionName(activePowerValue)) .withNetworkElementId(networkElementId) .withRelativeValue(false) .withActivePowerValue(activePowerValue) @@ -41,10 +41,10 @@ protected Action buildAction() { } protected void assertSpecificAttributes() { - assertAttributeNotNull(activePowerValue, getActionName(), "activePowerValue", "withActivePowerValue()"); + assertAttributeNotNull(activePowerValue, getActionTypeName(), "activePowerValue", "withActivePowerValue()"); } - protected String getActionName() { + protected String getActionTypeName() { return "LoadAction"; } } diff --git a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/PhaseTapChangerTapPositionActionAdderImpl.java b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/PhaseTapChangerTapPositionActionAdderImpl.java index 6ea7fcd791..db83639054 100644 --- a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/PhaseTapChangerTapPositionActionAdderImpl.java +++ b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/PhaseTapChangerTapPositionActionAdderImpl.java @@ -33,7 +33,7 @@ public PhaseTapChangerTapPositionActionAdder withTapPosition(int tapPosition) { protected Action buildAction() { return new PhaseTapChangerTapPositionActionBuilder() - .withId(String.format("%s_%s_%s", getActionName(), networkElementId, tapPosition)) + .withId(createActionName(tapPosition)) .withNetworkElementId(networkElementId) .withTapPosition(tapPosition) .withRelativeValue(false) @@ -41,10 +41,10 @@ protected Action buildAction() { } protected void assertSpecificAttributes() { - assertAttributeNotNull(tapPosition, getActionName(), "tapPosition", "withTapPosition()"); + assertAttributeNotNull(tapPosition, getActionTypeName(), "tapPosition", "withTapPosition()"); } - protected String getActionName() { + protected String getActionTypeName() { return "PhaseTapChangerTapPositionAction"; } } diff --git a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/ShuntCompensatorPositionActionAdderImpl.java b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/ShuntCompensatorPositionActionAdderImpl.java index cbec96f4da..809abd34e8 100644 --- a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/ShuntCompensatorPositionActionAdderImpl.java +++ b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/ShuntCompensatorPositionActionAdderImpl.java @@ -34,20 +34,20 @@ public ShuntCompensatorPositionActionAdder withSectionCount(int sectionCount) { protected Action buildAction() { return new ShuntCompensatorPositionActionBuilder() - .withId(String.format("%s_%s_%s", getActionName(), networkElementId, sectionCount)) + .withId(createActionName(sectionCount)) .withNetworkElementId(networkElementId) .withSectionCount(sectionCount) .build(); } protected void assertSpecificAttributes() { - assertAttributeNotNull(sectionCount, getActionName(), "sectionCount", "withSectionCount()"); + assertAttributeNotNull(sectionCount, getActionTypeName(), "sectionCount", "withSectionCount()"); if (sectionCount < 0) { throw new OpenRaoException("Section count should be a positive integer"); } } - protected String getActionName() { + protected String getActionTypeName() { return "ShuntCompensatorPositionAction"; } } diff --git a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/SwitchActionAdderImpl.java b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/SwitchActionAdderImpl.java index 15581f30c0..daeca920ff 100644 --- a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/SwitchActionAdderImpl.java +++ b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/SwitchActionAdderImpl.java @@ -34,17 +34,17 @@ public SwitchActionAdder withActionType(ActionType actionType) { protected Action buildAction() { return new SwitchActionBuilder() - .withId(String.format("%s_%s_%s", getActionName(), networkElementId, actionType)) + .withId(createActionName(actionType)) .withNetworkElementId(networkElementId) .withOpen(actionType == ActionType.OPEN) .build(); } protected void assertSpecificAttributes() { - assertAttributeNotNull(actionType, getActionName(), "actionType", "withActionType()"); + assertAttributeNotNull(actionType, getActionTypeName(), "actionType", "withActionType()"); } - protected String getActionName() { + protected String getActionTypeName() { return "SwitchAction"; } } diff --git a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/TerminalsConnectionActionAdderImpl.java b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/TerminalsConnectionActionAdderImpl.java index 8ccf173d37..e34c019e4c 100644 --- a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/TerminalsConnectionActionAdderImpl.java +++ b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/TerminalsConnectionActionAdderImpl.java @@ -33,17 +33,17 @@ public TerminalsConnectionActionAdder withActionType(ActionType actionType) { protected Action buildAction() { return new TerminalsConnectionActionBuilder() - .withId(String.format("%s_%s_%s", getActionName(), networkElementId, actionType)) + .withId(createActionName(actionType)) .withNetworkElementId(networkElementId) .withOpen(actionType == ActionType.OPEN) .build(); } protected void assertSpecificAttributes() { - assertAttributeNotNull(actionType, getActionName(), "actionType", "withActionType()"); + assertAttributeNotNull(actionType, getActionTypeName(), "actionType", "withActionType()"); } - protected String getActionName() { + protected String getActionTypeName() { return "TerminalsConnectionAction"; } } diff --git a/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/DanglingLineActionAdderImplTest.java b/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/DanglingLineActionAdderImplTest.java index 56d9562463..07241ade5c 100644 --- a/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/DanglingLineActionAdderImplTest.java +++ b/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/DanglingLineActionAdderImplTest.java @@ -43,6 +43,26 @@ void testOk() { .add(); DanglingLineAction danglingLineAction = (DanglingLineAction) networkAction.getElementaryActions().iterator().next(); + assertEquals("DanglingLineAction_groupNetworkElementId_100.0", danglingLineAction.getId()); + assertEquals("groupNetworkElementId", danglingLineAction.getDanglingLineId()); + assertEquals(100., danglingLineAction.getActivePowerValue().getAsDouble(), 1e-3); + + // check that network element have been added to CracImpl + assertEquals(1, ((CracImpl) crac).getNetworkElements().size()); + assertNotNull(((CracImpl) crac).getNetworkElement("groupNetworkElementId")); + } + + @Test + void testOkWithId() { + NetworkAction networkAction = networkActionAdder.newDanglingLineAction() + .withId("danglingLineAction") + .withNetworkElement("groupNetworkElementId") + .withActivePowerValue(100.) + .add() + .add(); + + DanglingLineAction danglingLineAction = (DanglingLineAction) networkAction.getElementaryActions().iterator().next(); + assertEquals("danglingLineAction", danglingLineAction.getId()); assertEquals("groupNetworkElementId", danglingLineAction.getDanglingLineId()); assertEquals(100., danglingLineAction.getActivePowerValue().getAsDouble(), 1e-3); diff --git a/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/GeneratorActionAdderImplTest.java b/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/GeneratorActionAdderImplTest.java index 8b32b52043..120fa6d580 100644 --- a/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/GeneratorActionAdderImplTest.java +++ b/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/GeneratorActionAdderImplTest.java @@ -43,6 +43,26 @@ void testOk() { .add(); GeneratorAction generatorAction = (GeneratorAction) networkAction.getElementaryActions().iterator().next(); + assertEquals("GeneratorAction_groupNetworkElementId_100.0", generatorAction.getId()); + assertEquals("groupNetworkElementId", generatorAction.getGeneratorId()); + assertEquals(100., generatorAction.getActivePowerValue().getAsDouble(), 1e-3); + + // check that network element have been added to CracImpl + assertEquals(1, ((CracImpl) crac).getNetworkElements().size()); + assertNotNull(((CracImpl) crac).getNetworkElement("groupNetworkElementId")); + } + + @Test + void testOkWithId() { + NetworkAction networkAction = networkActionAdder.newGeneratorAction() + .withId("generatorAction") + .withNetworkElement("groupNetworkElementId") + .withActivePowerValue(100.) + .add() + .add(); + + GeneratorAction generatorAction = (GeneratorAction) networkAction.getElementaryActions().iterator().next(); + assertEquals("generatorAction", generatorAction.getId()); assertEquals("groupNetworkElementId", generatorAction.getGeneratorId()); assertEquals(100., generatorAction.getActivePowerValue().getAsDouble(), 1e-3); diff --git a/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/LoadActionAdderImplTest.java b/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/LoadActionAdderImplTest.java index d48f7c0d22..edf188266a 100644 --- a/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/LoadActionAdderImplTest.java +++ b/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/LoadActionAdderImplTest.java @@ -43,6 +43,26 @@ void testOk() { .add(); LoadAction loadAction = (LoadAction) networkAction.getElementaryActions().iterator().next(); + assertEquals("LoadAction_groupNetworkElementId_100.0", loadAction.getId()); + assertEquals("groupNetworkElementId", loadAction.getLoadId()); + assertEquals(100., loadAction.getActivePowerValue().getAsDouble(), 1e-3); + + // check that network element have been added to CracImpl + assertEquals(1, ((CracImpl) crac).getNetworkElements().size()); + assertNotNull(((CracImpl) crac).getNetworkElement("groupNetworkElementId")); + } + + @Test + void testOkWithId() { + NetworkAction networkAction = networkActionAdder.newLoadAction() + .withId("loadAction") + .withNetworkElement("groupNetworkElementId") + .withActivePowerValue(100.) + .add() + .add(); + + LoadAction loadAction = (LoadAction) networkAction.getElementaryActions().iterator().next(); + assertEquals("loadAction", loadAction.getId()); assertEquals("groupNetworkElementId", loadAction.getLoadId()); assertEquals(100., loadAction.getActivePowerValue().getAsDouble(), 1e-3); diff --git a/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/PhaseTapChangerTapPositionActionAdderImplTest.java b/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/PhaseTapChangerTapPositionActionAdderImplTest.java index a3b0ebb194..fe783588ab 100644 --- a/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/PhaseTapChangerTapPositionActionAdderImplTest.java +++ b/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/PhaseTapChangerTapPositionActionAdderImplTest.java @@ -44,6 +44,27 @@ void testOk() { .add(); PhaseTapChangerTapPositionAction phaseTapChangerTapPositionAction = (PhaseTapChangerTapPositionAction) networkAction.getElementaryActions().iterator().next(); + assertEquals("PhaseTapChangerTapPositionAction_pstNetworkElementId_0", phaseTapChangerTapPositionAction.getId()); + assertEquals("pstNetworkElementId", phaseTapChangerTapPositionAction.getTransformerId()); + assertEquals(0, phaseTapChangerTapPositionAction.getTapPosition(), 1e-3); + + // check that network element has been created in CracImpl + assertEquals(1, ((CracImpl) crac).getNetworkElements().size()); + assertNotNull(((CracImpl) crac).getNetworkElement("pstNetworkElementId")); + } + + @Test + void testOkWithId() { + + NetworkAction networkAction = networkActionAdder.newPhaseTapChangerTapPositionAction() + .withId("phaseTapChangerTapPositionAction") + .withNetworkElement("pstNetworkElementId") + .withTapPosition(0) + .add() + .add(); + + PhaseTapChangerTapPositionAction phaseTapChangerTapPositionAction = (PhaseTapChangerTapPositionAction) networkAction.getElementaryActions().iterator().next(); + assertEquals("phaseTapChangerTapPositionAction", phaseTapChangerTapPositionAction.getId()); assertEquals("pstNetworkElementId", phaseTapChangerTapPositionAction.getTransformerId()); assertEquals(0, phaseTapChangerTapPositionAction.getTapPosition(), 1e-3); diff --git a/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/ShuntCompensatorPositionActionAdderImplTest.java b/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/ShuntCompensatorPositionActionAdderImplTest.java index ab0a50455a..88453d943d 100644 --- a/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/ShuntCompensatorPositionActionAdderImplTest.java +++ b/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/ShuntCompensatorPositionActionAdderImplTest.java @@ -43,6 +43,26 @@ void testOk() { .add(); ShuntCompensatorPositionAction shuntCompensatorPositionAction = (ShuntCompensatorPositionAction) networkAction.getElementaryActions().iterator().next(); + assertEquals("ShuntCompensatorPositionAction_groupNetworkElementId_3", shuntCompensatorPositionAction.getId()); + assertEquals("groupNetworkElementId", shuntCompensatorPositionAction.getShuntCompensatorId()); + assertEquals(3, shuntCompensatorPositionAction.getSectionCount()); + + // check that network element have been added to CracImpl + assertEquals(1, ((CracImpl) crac).getNetworkElements().size()); + assertNotNull(((CracImpl) crac).getNetworkElement("groupNetworkElementId")); + } + + @Test + void testOkWithId() { + NetworkAction networkAction = networkActionAdder.newShuntCompensatorPositionAction() + .withId("shuntCompensatorPositionAction") + .withNetworkElement("groupNetworkElementId") + .withSectionCount(3) + .add() + .add(); + + ShuntCompensatorPositionAction shuntCompensatorPositionAction = (ShuntCompensatorPositionAction) networkAction.getElementaryActions().iterator().next(); + assertEquals("shuntCompensatorPositionAction", shuntCompensatorPositionAction.getId()); assertEquals("groupNetworkElementId", shuntCompensatorPositionAction.getShuntCompensatorId()); assertEquals(3, shuntCompensatorPositionAction.getSectionCount()); diff --git a/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/SwitchActionAdderImplTest.java b/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/SwitchActionAdderImplTest.java index 5db861dd84..de89c700f7 100644 --- a/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/SwitchActionAdderImplTest.java +++ b/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/SwitchActionAdderImplTest.java @@ -43,6 +43,26 @@ void testOk() { .add(); SwitchAction switchAction = (SwitchAction) networkAction.getElementaryActions().iterator().next(); + assertEquals("SwitchAction_branchNetworkElementId_OPEN", switchAction.getId()); + assertEquals("branchNetworkElementId", switchAction.getSwitchId()); + assertTrue(switchAction.isOpen()); + + // check that network element has been added in CracImpl + assertEquals(1, ((CracImpl) crac).getNetworkElements().size()); + assertNotNull(((CracImpl) crac).getNetworkElement("branchNetworkElementId")); + } + + @Test + void testOkWithId() { + NetworkAction networkAction = networkActionAdder.newSwitchAction() + .withId("switchAction") + .withNetworkElement("branchNetworkElementId") + .withActionType(ActionType.OPEN) + .add() + .add(); + + SwitchAction switchAction = (SwitchAction) networkAction.getElementaryActions().iterator().next(); + assertEquals("switchAction", switchAction.getId()); assertEquals("branchNetworkElementId", switchAction.getSwitchId()); assertTrue(switchAction.isOpen()); diff --git a/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/TerminalsConnectionActionAdderImplTest.java b/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/TerminalsConnectionActionAdderImplTest.java index 0ffdf4c7cb..6e17ef5e27 100644 --- a/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/TerminalsConnectionActionAdderImplTest.java +++ b/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/TerminalsConnectionActionAdderImplTest.java @@ -43,6 +43,26 @@ void testOk() { .add(); TerminalsConnectionAction terminalsConnectionAction = (TerminalsConnectionAction) networkAction.getElementaryActions().iterator().next(); + assertEquals("TerminalsConnectionAction_branchNetworkElementId_OPEN", terminalsConnectionAction.getId()); + assertEquals("branchNetworkElementId", terminalsConnectionAction.getElementId()); + assertTrue(terminalsConnectionAction.isOpen()); + + // check that network element has been added in CracImpl + assertEquals(1, ((CracImpl) crac).getNetworkElements().size()); + assertNotNull(((CracImpl) crac).getNetworkElement("branchNetworkElementId")); + } + + @Test + void testOkWithId() { + NetworkAction networkAction = networkActionAdder.newTerminalsConnectionAction() + .withId("terminalsConnectionAction") + .withNetworkElement("branchNetworkElementId") + .withActionType(ActionType.OPEN) + .add() + .add(); + + TerminalsConnectionAction terminalsConnectionAction = (TerminalsConnectionAction) networkAction.getElementaryActions().iterator().next(); + assertEquals("terminalsConnectionAction", terminalsConnectionAction.getId()); assertEquals("branchNetworkElementId", terminalsConnectionAction.getElementId()); assertTrue(terminalsConnectionAction.isOpen()); diff --git a/data/crac/crac-io/crac-io-csa-profiles/src/main/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/remedialaction/ElementaryActionsHelper.java b/data/crac/crac-io/crac-io-csa-profiles/src/main/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/remedialaction/ElementaryActionsHelper.java index af957e48b7..e45b6f355c 100644 --- a/data/crac/crac-io/crac-io-csa-profiles/src/main/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/remedialaction/ElementaryActionsHelper.java +++ b/data/crac/crac-io/crac-io-csa-profiles/src/main/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/remedialaction/ElementaryActionsHelper.java @@ -12,13 +12,10 @@ import com.powsybl.openrao.data.cracio.csaprofiles.craccreator.NcAggregator; import com.powsybl.openrao.data.cracio.csaprofiles.nc.ContingencyWithRemedialAction; import com.powsybl.openrao.data.cracio.csaprofiles.nc.GridStateAlterationCollection; -import com.powsybl.openrao.data.cracio.csaprofiles.nc.GridStateAlterationRemedialAction; -import com.powsybl.openrao.data.cracio.csaprofiles.nc.RemedialAction; import com.powsybl.openrao.data.cracio.csaprofiles.nc.RemedialActionDependency; import com.powsybl.openrao.data.cracio.csaprofiles.nc.RemedialActionGroup; import com.powsybl.openrao.data.cracio.csaprofiles.nc.RemedialActionScheme; import com.powsybl.openrao.data.cracio.csaprofiles.nc.RotatingMachineAction; -import com.powsybl.openrao.data.cracio.csaprofiles.nc.SchemeRemedialAction; import com.powsybl.openrao.data.cracio.csaprofiles.nc.ShuntCompensatorModification; import com.powsybl.openrao.data.cracio.csaprofiles.nc.Stage; import com.powsybl.openrao.data.cracio.csaprofiles.nc.StaticPropertyRange; @@ -35,8 +32,6 @@ */ public class ElementaryActionsHelper { private final Set nativeRemedialActionGroups; - private final Set nativeGridStateAlterationRemedialActions; - private final Set nativeSchemeRemedialActions; private final Set nativeRemedialActionSchemes; private final Set nativeStages; private final Set nativeGridStateAlterationCollections; @@ -54,8 +49,6 @@ public class ElementaryActionsHelper { public ElementaryActionsHelper(CsaProfileCrac nativeCrac) { this.nativeRemedialActionGroups = nativeCrac.getRemedialActionGroups(); - this.nativeGridStateAlterationRemedialActions = nativeCrac.getGridStateAlterationRemedialActions(); - this.nativeSchemeRemedialActions = nativeCrac.getSchemeRemedialActions(); this.nativeRemedialActionSchemes = nativeCrac.getRemedialActionSchemes(); this.nativeStages = nativeCrac.getStages(); this.nativeGridStateAlterationCollections = nativeCrac.getGridStateAlterationCollections(); @@ -105,10 +98,6 @@ public Map> getTapPositionActions(boolean isSchem return isSchemeRemedialAction ? nativeTapPositionActionsPerNativeRemedialActionAuto : nativeTapPositionActionsPerNativeRemedialAction; } - public Set getParentRemedialAction(boolean isSchemeRemedialAction) { - return isSchemeRemedialAction ? nativeSchemeRemedialActions : nativeGridStateAlterationRemedialActions; - } - public String getGridStateAlterationCollection(String remedialActionId) { String remedialActionSchemeId = getAssociatedRemedialActionScheme(remedialActionId); return getAssociatedGridStateAlterationCollectionUsingStage(remedialActionId, remedialActionSchemeId); diff --git a/data/crac/crac-io/crac-io-csa-profiles/src/main/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/remedialaction/NetworkActionCreator.java b/data/crac/crac-io/crac-io-csa-profiles/src/main/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/remedialaction/NetworkActionCreator.java index 69545cb5a4..45ad8bccbd 100644 --- a/data/crac/crac-io/crac-io-csa-profiles/src/main/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/remedialaction/NetworkActionCreator.java +++ b/data/crac/crac-io/crac-io-csa-profiles/src/main/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/remedialaction/NetworkActionCreator.java @@ -133,7 +133,7 @@ private boolean addInjectionSetPointFromRotatingMachineAction(Set staticPr throw new OpenRaoImportException(ImportStatus.INCONSISTENCY_IN_DATA, String.format("CSA remedial action %s is a topological action and should be on switch only, not on %s", remedialActionId, networkElement.getType())); } networkActionAdder.newSwitchAction() + .withId(nativeTopologyAction.mrid()) .withNetworkElement(switchId) .withActionType(nativeStaticPropertyRange.normalValue() == 0d ? ActionType.CLOSE : ActionType.OPEN).add(); return true; diff --git a/data/crac/crac-io/crac-io-csa-profiles/src/test/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/CsaProfileCracCreationTestUtil.java b/data/crac/crac-io/crac-io-csa-profiles/src/test/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/CsaProfileCracCreationTestUtil.java index 467b7840cc..a2eaeeb2c7 100644 --- a/data/crac/crac-io/crac-io-csa-profiles/src/test/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/CsaProfileCracCreationTestUtil.java +++ b/data/crac/crac-io/crac-io-csa-profiles/src/test/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/CsaProfileCracCreationTestUtil.java @@ -194,45 +194,49 @@ public static void assertRaNotImported(CsaProfileCracCreationContext cracCreatio assertEquals(importStatus, context.getImportStatus()); } - public static void assertSimpleTopologicalActionImported(NetworkAction networkAction, String raId, String raName, String switchId, ActionType actionType, String expectedOperator) { + public static void assertSimpleTopologicalActionImported(NetworkAction networkAction, String raId, String raName, String topologyActionId, String switchId, ActionType actionType, String expectedOperator) { assertEquals(raId, networkAction.getId()); assertEquals(raName, networkAction.getName()); assertEquals(1, networkAction.getElementaryActions().size()); Action elementaryAction = networkAction.getElementaryActions().iterator().next(); assertTrue(elementaryAction instanceof SwitchAction); + assertEquals(topologyActionId, elementaryAction.getId()); assertEquals(switchId, ((SwitchAction) elementaryAction).getSwitchId()); assertEquals(actionType == ActionType.OPEN, ((SwitchAction) elementaryAction).isOpen()); assertEquals(expectedOperator, networkAction.getOperator()); } - public static void assertSimpleGeneratorActionImported(NetworkAction networkAction, String raId, String raName, String networkElementId, double setpoint, String expectedOperator) { + public static void assertSimpleGeneratorActionImported(NetworkAction networkAction, String raId, String raName, String rotatingMachineActionId, String networkElementId, double setpoint, String expectedOperator) { assertEquals(raId, networkAction.getId()); assertEquals(raName, networkAction.getName()); assertEquals(1, networkAction.getElementaryActions().size()); Action elementaryAction = networkAction.getElementaryActions().iterator().next(); assertTrue(elementaryAction instanceof GeneratorAction); + assertEquals(rotatingMachineActionId, elementaryAction.getId()); assertEquals(networkElementId, ((GeneratorAction) elementaryAction).getGeneratorId()); assertEquals(setpoint, ((GeneratorAction) elementaryAction).getActivePowerValue().getAsDouble()); assertEquals(expectedOperator, networkAction.getOperator()); } - public static void assertSimpleLoadActionImported(NetworkAction networkAction, String raId, String raName, String networkElementId, double setpoint, String expectedOperator) { + public static void assertSimpleLoadActionImported(NetworkAction networkAction, String raId, String raName, String rotatingMachineActionId, String networkElementId, double setpoint, String expectedOperator) { assertEquals(raId, networkAction.getId()); assertEquals(raName, networkAction.getName()); assertEquals(1, networkAction.getElementaryActions().size()); Action elementaryAction = networkAction.getElementaryActions().iterator().next(); assertTrue(elementaryAction instanceof LoadAction); + assertEquals(rotatingMachineActionId, elementaryAction.getId()); assertEquals(networkElementId, ((LoadAction) elementaryAction).getLoadId()); assertEquals(setpoint, ((LoadAction) elementaryAction).getActivePowerValue().getAsDouble()); assertEquals(expectedOperator, networkAction.getOperator()); } - public static void assertSimpleShuntCompensatorActionImported(NetworkAction networkAction, String raId, String raName, String networkElementId, double setpoint, String expectedOperator) { + public static void assertSimpleShuntCompensatorActionImported(NetworkAction networkAction, String raId, String raName, String shuntCompensatorModificationId, String networkElementId, double setpoint, String expectedOperator) { assertEquals(raId, networkAction.getId()); assertEquals(raName, networkAction.getName()); assertEquals(1, networkAction.getElementaryActions().size()); Action elementaryAction = networkAction.getElementaryActions().iterator().next(); assertTrue(elementaryAction instanceof ShuntCompensatorPositionAction); + assertEquals(shuntCompensatorModificationId, elementaryAction.getId()); assertEquals(networkElementId, ((ShuntCompensatorPositionAction) elementaryAction).getShuntCompensatorId()); assertEquals(setpoint, ((ShuntCompensatorPositionAction) elementaryAction).getSectionCount()); assertEquals(expectedOperator, networkAction.getOperator()); diff --git a/data/crac/crac-io/crac-io-csa-profiles/src/test/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/remedialaction/InjectionSetPointActionCreationTest.java b/data/crac/crac-io/crac-io-csa-profiles/src/test/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/remedialaction/InjectionSetPointActionCreationTest.java index 937af7a8cd..3814cd6a7f 100644 --- a/data/crac/crac-io/crac-io-csa-profiles/src/test/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/remedialaction/InjectionSetPointActionCreationTest.java +++ b/data/crac/crac-io/crac-io-csa-profiles/src/test/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/remedialaction/InjectionSetPointActionCreationTest.java @@ -35,23 +35,23 @@ void importRotatingMachineActions() { List importedInjectionSetpointActions = cracCreationContext.getCrac().getNetworkActions().stream().sorted(Comparator.comparing(NetworkAction::getId)).toList(); assertEquals(5, importedInjectionSetpointActions.size()); - assertSimpleGeneratorActionImported(importedInjectionSetpointActions.get(0), "remedial-action-1", "RTE_RA1", "FFR1AA1 _generator", 1500d, "RTE"); + assertSimpleGeneratorActionImported(importedInjectionSetpointActions.get(0), "remedial-action-1", "RTE_RA1", "rotating-machine-action-1", "FFR1AA1 _generator", 1500d, "RTE"); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-1", PREVENTIVE_INSTANT_ID, UsageMethod.AVAILABLE); - assertSimpleGeneratorActionImported(importedInjectionSetpointActions.get(1), "remedial-action-2", "RTE_RA2", "FFR2AA1 _generator", 2350d, "RTE"); + assertSimpleGeneratorActionImported(importedInjectionSetpointActions.get(1), "remedial-action-2", "RTE_RA2", "rotating-machine-action-2", "FFR2AA1 _generator", 2350d, "RTE"); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-2", CURATIVE_1_INSTANT_ID, UsageMethod.AVAILABLE); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-2", CURATIVE_2_INSTANT_ID, UsageMethod.AVAILABLE); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-2", CURATIVE_3_INSTANT_ID, UsageMethod.AVAILABLE); - assertSimpleGeneratorActionImported(importedInjectionSetpointActions.get(2), "remedial-action-3", "RTE_RA3", "FFR2AA1 _generator", 1790d, "RTE"); + assertSimpleGeneratorActionImported(importedInjectionSetpointActions.get(2), "remedial-action-3", "RTE_RA3", "rotating-machine-action-3", "FFR2AA1 _generator", 1790d, "RTE"); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-3", CURATIVE_1_INSTANT_ID, UsageMethod.AVAILABLE); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-3", CURATIVE_2_INSTANT_ID, UsageMethod.AVAILABLE); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-3", CURATIVE_3_INSTANT_ID, UsageMethod.AVAILABLE); - assertSimpleLoadActionImported(importedInjectionSetpointActions.get(3), "remedial-action-4", "RTE_RA4", "FFR1AA1 _load", 1150d, "RTE"); + assertSimpleLoadActionImported(importedInjectionSetpointActions.get(3), "remedial-action-4", "RTE_RA4", "rotating-machine-action-4", "FFR1AA1 _load", 1150d, "RTE"); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-4", PREVENTIVE_INSTANT_ID, UsageMethod.AVAILABLE); - assertSimpleLoadActionImported(importedInjectionSetpointActions.get(4), "remedial-action-5", "RTE_RA5", "FFR1AA1 _load", 900d, "RTE"); + assertSimpleLoadActionImported(importedInjectionSetpointActions.get(4), "remedial-action-5", "RTE_RA5", "rotating-machine-action-5", "FFR1AA1 _load", 900d, "RTE"); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-5", PREVENTIVE_INSTANT_ID, UsageMethod.AVAILABLE); assertEquals(10, cracCreationContext.getRemedialActionCreationContexts().stream().filter(context -> !context.isImported()).toList().size()); @@ -75,23 +75,23 @@ void importShuntCompensatorModifications() { List importedInjectionSetpointActions = cracCreationContext.getCrac().getNetworkActions().stream().sorted(Comparator.comparing(NetworkAction::getId)).toList(); assertEquals(5, importedInjectionSetpointActions.size()); - assertSimpleShuntCompensatorActionImported(importedInjectionSetpointActions.get(0), "remedial-action-1", "RTE_RA1", "shunt-compensator", 3d, "RTE"); + assertSimpleShuntCompensatorActionImported(importedInjectionSetpointActions.get(0), "remedial-action-1", "RTE_RA1", "shunt-compensator-modification-1", "shunt-compensator", 3d, "RTE"); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-1", PREVENTIVE_INSTANT_ID, UsageMethod.AVAILABLE); - assertSimpleShuntCompensatorActionImported(importedInjectionSetpointActions.get(1), "remedial-action-2", "RTE_RA2", "shunt-compensator", 3d, "RTE"); + assertSimpleShuntCompensatorActionImported(importedInjectionSetpointActions.get(1), "remedial-action-2", "RTE_RA2", "shunt-compensator-modification-2", "shunt-compensator", 3d, "RTE"); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-2", CURATIVE_1_INSTANT_ID, UsageMethod.AVAILABLE); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-2", CURATIVE_2_INSTANT_ID, UsageMethod.AVAILABLE); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-2", CURATIVE_3_INSTANT_ID, UsageMethod.AVAILABLE); - assertSimpleShuntCompensatorActionImported(importedInjectionSetpointActions.get(2), "remedial-action-3", "RTE_RA3", "shunt-compensator", 0d, "RTE"); + assertSimpleShuntCompensatorActionImported(importedInjectionSetpointActions.get(2), "remedial-action-3", "RTE_RA3", "shunt-compensator-modification-3", "shunt-compensator", 0d, "RTE"); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-3", CURATIVE_1_INSTANT_ID, UsageMethod.AVAILABLE); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-3", CURATIVE_2_INSTANT_ID, UsageMethod.AVAILABLE); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-3", CURATIVE_3_INSTANT_ID, UsageMethod.AVAILABLE); - assertSimpleShuntCompensatorActionImported(importedInjectionSetpointActions.get(3), "remedial-action-4", "RTE_RA4", "shunt-compensator", 2d, "RTE"); + assertSimpleShuntCompensatorActionImported(importedInjectionSetpointActions.get(3), "remedial-action-4", "RTE_RA4", "shunt-compensator-modification-4", "shunt-compensator", 2d, "RTE"); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-4", PREVENTIVE_INSTANT_ID, UsageMethod.AVAILABLE); - assertSimpleShuntCompensatorActionImported(importedInjectionSetpointActions.get(4), "remedial-action-5", "RTE_RA5", "shunt-compensator", 0d, "RTE"); + assertSimpleShuntCompensatorActionImported(importedInjectionSetpointActions.get(4), "remedial-action-5", "RTE_RA5", "shunt-compensator-modification-5", "shunt-compensator", 0d, "RTE"); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-4", PREVENTIVE_INSTANT_ID, UsageMethod.AVAILABLE); assertEquals(17, cracCreationContext.getRemedialActionCreationContexts().stream().filter(context -> !context.isImported()).toList().size()); diff --git a/data/crac/crac-io/crac-io-csa-profiles/src/test/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/remedialaction/TopologicalActionCreationTest.java b/data/crac/crac-io/crac-io-csa-profiles/src/test/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/remedialaction/TopologicalActionCreationTest.java index 9aa9ab5e46..5ac8003fec 100644 --- a/data/crac/crac-io/crac-io-csa-profiles/src/test/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/remedialaction/TopologicalActionCreationTest.java +++ b/data/crac/crac-io/crac-io-csa-profiles/src/test/java/com/powsybl/openrao/data/cracio/csaprofiles/craccreator/remedialaction/TopologicalActionCreationTest.java @@ -28,10 +28,10 @@ void importTopologicalActions() { List importedTopologicalActions = cracCreationContext.getCrac().getNetworkActions().stream().sorted(Comparator.comparing(NetworkAction::getId)).toList(); assertEquals(2, importedTopologicalActions.size()); - assertSimpleTopologicalActionImported(importedTopologicalActions.get(0), "remedial-action-1", "RTE_RA1", "BBE1AA1 BBE4AA1 1", ActionType.OPEN, "RTE"); + assertSimpleTopologicalActionImported(importedTopologicalActions.get(0), "remedial-action-1", "RTE_RA1", "topology-action-1", "BBE1AA1 BBE4AA1 1", ActionType.OPEN, "RTE"); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-1", PREVENTIVE_INSTANT_ID, UsageMethod.AVAILABLE); - assertSimpleTopologicalActionImported(importedTopologicalActions.get(1), "remedial-action-2", "RTE_RA2", "DDE3AA1 DDE4AA1 1", ActionType.CLOSE, "RTE"); + assertSimpleTopologicalActionImported(importedTopologicalActions.get(1), "remedial-action-2", "RTE_RA2", "topology-action-2", "DDE3AA1 DDE4AA1 1", ActionType.CLOSE, "RTE"); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-2", CURATIVE_1_INSTANT_ID, UsageMethod.AVAILABLE); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-2", CURATIVE_2_INSTANT_ID, UsageMethod.AVAILABLE); assertHasOnInstantUsageRule(cracCreationContext, "remedial-action-2", CURATIVE_3_INSTANT_ID, UsageMethod.AVAILABLE); diff --git a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/JsonSerializationConstants.java b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/JsonSerializationConstants.java index 3be3b315f2..63f95442a9 100644 --- a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/JsonSerializationConstants.java +++ b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/JsonSerializationConstants.java @@ -33,7 +33,7 @@ public final class JsonSerializationConstants { private JsonSerializationConstants() { } - public static final String CRAC_IO_VERSION = "2.5"; + public static final String CRAC_IO_VERSION = "2.6"; /* v1.1: addition of switchPairs v1.2: addition of injectionRangeAction @@ -50,6 +50,7 @@ private JsonSerializationConstants() { v2.3: addition of RELATIVE_TO_PREVIOUS_TIME_STEP RangeType, and border attribute for cnecs v2.4: new names for onConstraint and cnecId, side left/right -> one/two v2.5: elementary actions have new type coming from core remedial actions + v2.6: addition of elementary actions id */ // headers @@ -116,6 +117,7 @@ private JsonSerializationConstants() { public static final String SHUNTCOMPENSATOR_POSITION_ACTIONS = "shuntCompensatorPositionActions"; public static final String PHASETAPCHANGER_TAPPOSITION_ACTIONS = "phaseTapChangerTapPositionActions"; public static final String SWITCH_PAIRS = "switchPairs"; + public static final String ACTION_ID = "actionId"; public static final String USAGE_METHOD = "usageMethod"; public static final String ON_INSTANT_USAGE_RULES = "onInstantUsageRules"; diff --git a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/DanglingLineActionArrayDeserializer.java b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/DanglingLineActionArrayDeserializer.java index 28d1f17f79..7065a1aed0 100644 --- a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/DanglingLineActionArrayDeserializer.java +++ b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/DanglingLineActionArrayDeserializer.java @@ -34,6 +34,9 @@ public static void deserialize(JsonParser jsonParser, NetworkActionAdder ownerAd DanglingLineActionAdder adder = ownerAdder.newDanglingLineAction(); while (!jsonParser.nextToken().isStructEnd()) { switch (jsonParser.getCurrentName()) { + case ACTION_ID: + adder.withId(jsonParser.nextTextValue()); + break; case NETWORK_ELEMENT_ID: deserializeNetworkElement(jsonParser.nextTextValue(), networkElementsNamesPerId, adder); break; diff --git a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/GeneratorActionArrayDeserializer.java b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/GeneratorActionArrayDeserializer.java index 1213fedfc2..1296d71d8e 100644 --- a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/GeneratorActionArrayDeserializer.java +++ b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/GeneratorActionArrayDeserializer.java @@ -34,6 +34,9 @@ public static void deserialize(JsonParser jsonParser, NetworkActionAdder ownerAd GeneratorActionAdder adder = ownerAdder.newGeneratorAction(); while (!jsonParser.nextToken().isStructEnd()) { switch (jsonParser.getCurrentName()) { + case ACTION_ID: + adder.withId(jsonParser.nextTextValue()); + break; case NETWORK_ELEMENT_ID: deserializeNetworkElement(jsonParser.nextTextValue(), networkElementsNamesPerId, adder); break; diff --git a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/LoadActionArrayDeserializer.java b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/LoadActionArrayDeserializer.java index aa91614e9b..7d229536e9 100644 --- a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/LoadActionArrayDeserializer.java +++ b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/LoadActionArrayDeserializer.java @@ -34,6 +34,9 @@ public static void deserialize(JsonParser jsonParser, NetworkActionAdder ownerAd LoadActionAdder adder = ownerAdder.newLoadAction(); while (!jsonParser.nextToken().isStructEnd()) { switch (jsonParser.getCurrentName()) { + case ACTION_ID: + adder.withId(jsonParser.nextTextValue()); + break; case NETWORK_ELEMENT_ID: deserializeNetworkElement(jsonParser.nextTextValue(), networkElementsNamesPerId, adder); break; diff --git a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/PhaseTapChangerTapPositionActionArrayDeserializer.java b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/PhaseTapChangerTapPositionActionArrayDeserializer.java index 4cb36947c2..9526af2d3b 100644 --- a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/PhaseTapChangerTapPositionActionArrayDeserializer.java +++ b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/PhaseTapChangerTapPositionActionArrayDeserializer.java @@ -34,6 +34,9 @@ public static void deserialize(JsonParser jsonParser, NetworkActionAdder ownerAd PhaseTapChangerTapPositionActionAdder adder = ownerAdder.newPhaseTapChangerTapPositionAction(); while (!jsonParser.nextToken().isStructEnd()) { switch (jsonParser.getCurrentName()) { + case ACTION_ID: + adder.withId(jsonParser.nextTextValue()); + break; case NETWORK_ELEMENT_ID: deserializeNetworkElement(jsonParser.nextTextValue(), networkElementsNamesPerId, adder); break; diff --git a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/ShuntCompensatorPositionActionArrayDeserializer.java b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/ShuntCompensatorPositionActionArrayDeserializer.java index 65631040e3..ca2932e676 100644 --- a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/ShuntCompensatorPositionActionArrayDeserializer.java +++ b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/ShuntCompensatorPositionActionArrayDeserializer.java @@ -34,6 +34,9 @@ public static void deserialize(JsonParser jsonParser, NetworkActionAdder ownerAd ShuntCompensatorPositionActionAdder adder = ownerAdder.newShuntCompensatorPositionAction(); while (!jsonParser.nextToken().isStructEnd()) { switch (jsonParser.getCurrentName()) { + case ACTION_ID: + adder.withId(jsonParser.nextTextValue()); + break; case NETWORK_ELEMENT_ID: deserializeNetworkElement(jsonParser.nextTextValue(), networkElementsNamesPerId, adder); break; diff --git a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/SwitchActionArrayDeserializer.java b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/SwitchActionArrayDeserializer.java index 4c382ce308..0af3414f32 100644 --- a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/SwitchActionArrayDeserializer.java +++ b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/SwitchActionArrayDeserializer.java @@ -34,6 +34,9 @@ public static void deserialize(JsonParser jsonParser, NetworkActionAdder ownerAd SwitchActionAdder adder = ownerAdder.newSwitchAction(); while (!jsonParser.nextToken().isStructEnd()) { switch (jsonParser.getCurrentName()) { + case ACTION_ID: + adder.withId(jsonParser.nextTextValue()); + break; case NETWORK_ELEMENT_ID: deserializeNetworkElement(jsonParser.nextTextValue(), networkElementsNamesPerId, adder); break; diff --git a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/TerminalsConnectionActionArrayDeserializer.java b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/TerminalsConnectionActionArrayDeserializer.java index 4f708ad7b2..7a23d39b69 100644 --- a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/TerminalsConnectionActionArrayDeserializer.java +++ b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/deserializers/TerminalsConnectionActionArrayDeserializer.java @@ -33,6 +33,9 @@ public static void deserialize(JsonParser jsonParser, NetworkActionAdder ownerAd TerminalsConnectionActionAdder adder = ownerAdder.newTerminalsConnectionAction(); while (!jsonParser.nextToken().isStructEnd()) { switch (jsonParser.getCurrentName()) { + case ACTION_ID: + adder.withId(jsonParser.nextTextValue()); + break; case NETWORK_ELEMENT_ID: deserializeNetworkElement(jsonParser.nextTextValue(), networkElementsNamesPerId, adder); break; diff --git a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/DanglingLineActionSerializer.java b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/DanglingLineActionSerializer.java index 8fe19d8a17..0cfb8eabc4 100644 --- a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/DanglingLineActionSerializer.java +++ b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/DanglingLineActionSerializer.java @@ -23,6 +23,7 @@ public class DanglingLineActionSerializer extends AbstractJsonSerializer { @Override public void serialize(LoadAction value, JsonGenerator gen, SerializerProvider serializers) throws IOException { gen.writeStartObject(); + gen.writeStringField(ACTION_ID, value.getId()); gen.writeStringField(NETWORK_ELEMENT_ID, value.getLoadId()); gen.writeNumberField(ACTIVE_POWER_VALUE, value.getActivePowerValue().getAsDouble()); gen.writeEndObject(); diff --git a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/PhaseTapChangerTapPositionActionSerializer.java b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/PhaseTapChangerTapPositionActionSerializer.java index 73b028793f..3ea66a7588 100644 --- a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/PhaseTapChangerTapPositionActionSerializer.java +++ b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/PhaseTapChangerTapPositionActionSerializer.java @@ -22,6 +22,7 @@ public class PhaseTapChangerTapPositionActionSerializer extends AbstractJsonSeri @Override public void serialize(PhaseTapChangerTapPositionAction value, JsonGenerator gen, SerializerProvider serializers) throws IOException { gen.writeStartObject(); + gen.writeStringField(ACTION_ID, value.getId()); gen.writeStringField(NETWORK_ELEMENT_ID, value.getTransformerId()); gen.writeNumberField(TAP_POSITION, value.getTapPosition()); gen.writeEndObject(); diff --git a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/ShuntCompensatorPositionActionSerializer.java b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/ShuntCompensatorPositionActionSerializer.java index ac9dafd2cd..90ec13c229 100644 --- a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/ShuntCompensatorPositionActionSerializer.java +++ b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/ShuntCompensatorPositionActionSerializer.java @@ -23,6 +23,7 @@ public class ShuntCompensatorPositionActionSerializer extends AbstractJsonSerial @Override public void serialize(ShuntCompensatorPositionAction value, JsonGenerator gen, SerializerProvider serializers) throws IOException { gen.writeStartObject(); + gen.writeStringField(ACTION_ID, value.getId()); gen.writeStringField(NETWORK_ELEMENT_ID, value.getShuntCompensatorId()); gen.writeNumberField(SECTION_COUNT, value.getSectionCount()); gen.writeEndObject(); diff --git a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/SwitchActionSerializer.java b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/SwitchActionSerializer.java index 31456e33e6..24c5280105 100644 --- a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/SwitchActionSerializer.java +++ b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/SwitchActionSerializer.java @@ -23,6 +23,7 @@ public class SwitchActionSerializer extends AbstractJsonSerializer @Override public void serialize(SwitchAction value, JsonGenerator gen, SerializerProvider serializers) throws IOException { gen.writeStartObject(); + gen.writeStringField(ACTION_ID, value.getId()); gen.writeStringField(NETWORK_ELEMENT_ID, value.getSwitchId()); gen.writeStringField(ACTION_TYPE, serializeActionType(value.isOpen() ? ActionType.OPEN : ActionType.CLOSE)); gen.writeEndObject(); diff --git a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/TerminalsConnectionActionSerializer.java b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/TerminalsConnectionActionSerializer.java index 6d5de4d72f..218a09d9e9 100644 --- a/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/TerminalsConnectionActionSerializer.java +++ b/data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/cracio/json/serializers/TerminalsConnectionActionSerializer.java @@ -24,6 +24,7 @@ public class TerminalsConnectionActionSerializer extends AbstractJsonSerializer< @Override public void serialize(TerminalsConnectionAction value, JsonGenerator gen, SerializerProvider serializers) throws IOException { gen.writeStartObject(); + gen.writeStringField(ACTION_ID, value.getId()); gen.writeStringField(NETWORK_ELEMENT_ID, value.getElementId()); gen.writeStringField(ACTION_TYPE, serializeActionType(value.isOpen() ? ActionType.OPEN : ActionType.CLOSE)); gen.writeEndObject(); diff --git a/data/crac/crac-io/crac-io-json/src/test/java/com/powsybl/openrao/data/cracio/json/JsonRetrocompatibilityTest.java b/data/crac/crac-io/crac-io-json/src/test/java/com/powsybl/openrao/data/cracio/json/JsonRetrocompatibilityTest.java index b1e9e0cb72..0ea18c9da2 100644 --- a/data/crac/crac-io/crac-io-json/src/test/java/com/powsybl/openrao/data/cracio/json/JsonRetrocompatibilityTest.java +++ b/data/crac/crac-io/crac-io-json/src/test/java/com/powsybl/openrao/data/cracio/json/JsonRetrocompatibilityTest.java @@ -16,6 +16,7 @@ import com.powsybl.openrao.data.cracapi.cnec.AngleCnec; import com.powsybl.openrao.data.cracapi.cnec.FlowCnec; import com.powsybl.openrao.data.cracapi.cnec.VoltageCnec; +import com.powsybl.openrao.data.cracapi.networkaction.NetworkAction; import com.powsybl.openrao.data.cracapi.networkaction.SwitchPair; import com.powsybl.openrao.data.cracapi.parameters.CracCreationParameters; import com.powsybl.openrao.data.cracapi.range.RangeType; @@ -337,6 +338,16 @@ void importV2Point5Test() { testContentOfV2Point5Crac(crac); } + @Test + void importV2Point6Test() { + // ElementaryAction are now Action from powsybl-core (more different types and fields name changes) + InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v2/crac-v2.6.json"); + + Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network, null).getCrac(); + assertEquals(7, crac.getNetworkActions().size()); + testContentOfV2Point6Crac(crac); + } + private void testContentOfV1Point0Crac(Crac crac) { Instant preventiveInstant = crac.getInstant("preventive"); Instant autoInstant = crac.getInstant("auto"); @@ -830,4 +841,17 @@ private void testContentOfV2Point4Crac(Crac crac) { private void testContentOfV2Point5Crac(Crac crac) { testContentOfV2Point4Crac(crac); } + + private void testContentOfV2Point6Crac(Crac crac) { + testContentOfV2Point5Crac(crac); + NetworkAction networkAction = crac.getNetworkAction("complexNetworkAction2Id"); + LoadAction loadAction = (LoadAction) networkAction.getElementaryActions().stream().filter(action -> action instanceof LoadAction).findAny().get(); + assertEquals("loadActionLD1", loadAction.getId()); + DanglingLineAction danglingLineAction = (DanglingLineAction) networkAction.getElementaryActions().stream().filter(action -> action instanceof DanglingLineAction).findAny().get(); + assertEquals("DanglingLineAction_DL1_-120.0", danglingLineAction.getId()); + ShuntCompensatorPositionAction shuntCompensatorPositionAction = (ShuntCompensatorPositionAction) networkAction.getElementaryActions().stream().filter(action -> action instanceof ShuntCompensatorPositionAction).findAny().get(); + assertEquals("ShuntCompensatorPositionAction_SC1_13", shuntCompensatorPositionAction.getId()); + SwitchAction switchAction = (SwitchAction) networkAction.getElementaryActions().stream().filter(action -> action instanceof SwitchAction).findAny().get(); + assertEquals("switchActionBR1", switchAction.getId()); + } } diff --git a/data/crac/crac-io/crac-io-json/src/test/resources/retrocompatibility/v2/crac-v2.6.json b/data/crac/crac-io/crac-io-json/src/test/resources/retrocompatibility/v2/crac-v2.6.json new file mode 100644 index 0000000000..863b73407e --- /dev/null +++ b/data/crac/crac-io/crac-io-json/src/test/resources/retrocompatibility/v2/crac-v2.6.json @@ -0,0 +1,533 @@ +{ + "type" : "CRAC", + "version" : "2.5", + "info" : "Generated by FARAO http://farao-community.github.io", + "id" : "exhaustiveCracId", + "name" : "exhaustiveCracName", + "instants" : [ { + "id": "preventive", + "kind": "PREVENTIVE" + }, { + "id": "outage", + "kind": "OUTAGE" + }, { + "id": "auto", + "kind": "AUTO" + }, { + "id": "toto", + "kind": "CURATIVE" + }, { + "id": "curative", + "kind": "CURATIVE" + } ], + "networkElementsNamePerId" : { + "ne5Id" : "ne5Name", + "ne2Id" : "ne2Name", + "to-close" : "to-close-name", + "generator2Id" : "generator2Name" + }, + "contingencies" : [ { + "id" : "contingency1Id", + "networkElementsIds" : [ "ne1Id" ] + }, { + "id" : "contingency2Id", + "networkElementsIds" : [ "ne2Id", "ne3Id" ] + } ], + "flowCnecs" : [ { + "id" : "cnec1outageId", + "name" : "cnec1outageId", + "networkElementId" : "ne4Id", + "operator" : "operator1", + "border" : "border1", + "instant" : "outage", + "contingencyId" : "contingency1Id", + "optimized" : true, + "monitored" : false, + "reliabilityMargin" : 0.0, + "iMax" : [ NaN ], + "nominalV" : [ 220.0 ], + "thresholds" : [ { + "unit" : "ampere", + "min" : -800.0, + "side" : 1 + } ] + }, { + "id" : "cnec1prevId", + "name" : "cnec1prevId", + "networkElementId" : "ne4Id", + "operator" : "operator1", + "border" : "border1", + "instant" : "preventive", + "optimized" : true, + "monitored" : false, + "reliabilityMargin" : 0.0, + "iMax" : [ NaN, 1000.0 ], + "nominalV" : [ 220.0 ], + "thresholds" : [ { + "unit" : "ampere", + "min" : -500.0, + "side" : 2 + } ] + }, { + "id" : "cnec2prevId", + "name" : "cnec2prevId", + "networkElementId" : "ne5Id", + "operator" : "operator2", + "border" : "border2", + "instant" : "preventive", + "optimized" : true, + "monitored" : false, + "reliabilityMargin" : 0.0, + "iMax" : [ 2000.0 ], + "nominalV" : [ 380.0, 220.0 ], + "thresholds" : [ { + "unit" : "ampere", + "min" : -800.0, + "side" : 1 + }, { + "unit" : "ampere", + "min" : -800.0, + "side" : 1 + }, { + "unit" : "ampere", + "max" : 1200.0, + "side" : 2 + }, { + "unit" : "percent_imax", + "min" : -0.3, + "side" : 1 + } ] + }, { + "id" : "cnec3autoId", + "name" : "cnec3autoName", + "networkElementId" : "ne2Id", + "operator" : "operator3", + "border" : "border3", + "instant" : "auto", + "contingencyId" : "contingency2Id", + "optimized" : false, + "monitored" : true, + "reliabilityMargin" : 20.0, + "iMax" : [ NaN ], + "nominalV" : [ NaN ], + "thresholds" : [ { + "unit" : "megawatt", + "max" : 500.0, + "side" : 1 + } ] + }, { + "id" : "cnec3curId", + "name" : "cnec3curId", + "networkElementId" : "ne2Id", + "operator" : "operator3", + "border" : "border3", + "instant" : "curative", + "contingencyId" : "contingency2Id", + "optimized" : false, + "monitored" : true, + "reliabilityMargin" : 20.0, + "iMax" : [ NaN ], + "nominalV" : [ NaN ], + "thresholds" : [ { + "unit" : "megawatt", + "max" : 500.0, + "side" : 1 + } ] + }, { + "id" : "cnec3prevId", + "name" : "cnec3prevName", + "networkElementId" : "ne2Id", + "operator" : "operator3", + "border" : "border3", + "instant" : "preventive", + "optimized" : false, + "monitored" : true, + "reliabilityMargin" : 20.0, + "iMax" : [ NaN ], + "nominalV" : [ NaN ], + "thresholds" : [ { + "unit" : "megawatt", + "max" : 500.0, + "side" : 1 + } ] + }, { + "id" : "cnec4prevId", + "name" : "cnec4prevName", + "networkElementId" : "ne3Id", + "operator" : "operator4", + "border" : "border1", + "instant" : "preventive", + "optimized" : true, + "monitored" : true, + "reliabilityMargin" : 0.0, + "iMax" : [ NaN ], + "nominalV" : [ NaN ], + "thresholds" : [ { + "unit" : "megawatt", + "max" : 500.0, + "side" : 1 + } ] + } ], + "angleCnecs" : [ { + "id" : "angleCnecId", + "name" : "angleCnecName", + "exportingNetworkElementId" : "eneId", + "importingNetworkElementId" : "ineId", + "operator" : "operator1", + "border" : "border4", + "instant" : "curative", + "contingencyId" : "contingency1Id", + "optimized" : false, + "monitored" : true, + "reliabilityMargin" : 0.0, + "thresholds" : [ { + "unit" : "degree", + "min" : -100.0 + } ] + } ], + "voltageCnecs" : [ { + "id" : "voltageCnecId", + "name" : "voltageCnecName", + "networkElementId" : "voltageCnecNeId", + "operator" : "operator1", + "border" : "border5", + "instant" : "curative", + "contingencyId" : "contingency1Id", + "optimized" : false, + "monitored" : true, + "reliabilityMargin" : 0.0, + "thresholds" : [ { + "unit" : "kilovolt", + "min" : 380.0 + } ] + } ], + "pstRangeActions" : [ { + "id" : "pstRange1Id", + "name" : "pstRange1Name", + "operator" : "RTE", + "speed" : 10, + "onInstantUsageRules" : [ { + "instant" : "preventive", + "usageMethod" : "available" + } ], + "networkElementId" : "pst", + "initialTap" : 2, + "tapToAngleConversionMap" : { + "-1" : 1.0, + "0" : 1.5, + "1" : 2.0, + "2" : 2.5, + "3" : 3.0, + "-3" : 0.0, + "-2" : 0.5 + }, + "ranges" : [ { + "min" : 1, + "max" : 7, + "rangeType" : "absolute" + }, { + "min" : -3, + "max" : 3, + "rangeType" : "relativeToInitialNetwork" + } ] + }, { + "id" : "pstRange2Id", + "name" : "pstRange2Name", + "operator" : "RTE", + "onConstraintUsageRules" : [ { + "instant" : "preventive", + "cnecId" : "cnec3prevId", + "usageMethod" : "available" + } ], + "networkElementId" : "pst2", + "groupId" : "group-1-pst", + "initialTap" : 1, + "tapToAngleConversionMap" : { + "-1" : 1.0, + "0" : 1.5, + "1" : 2.0, + "2" : 2.5, + "3" : 3.0, + "-3" : 0.0, + "-2" : 0.5 + }, + "ranges" : [ { + "min" : 1, + "max" : 7, + "rangeType" : "absolute" + }, { + "min" : -3, + "max" : 3, + "rangeType" : "relativeToInitialNetwork" + } ] + }, { + "id" : "pstRange3Id", + "name" : "pstRange3Name", + "operator" : "RTE", + "onConstraintUsageRules" : [ { + "instant" : "curative", + "cnecId" : "angleCnecId", + "usageMethod" : "available" + } ], + "networkElementId" : "pst3", + "groupId" : "group-3-pst", + "initialTap" : 1, + "tapToAngleConversionMap" : { + "-1" : 1.0, + "0" : 1.5, + "1" : 2.0, + "2" : 2.5, + "3" : 3.0, + "-3" : 0.0, + "-2" : 0.5 + }, + "ranges" : [ { + "min" : 1, + "max" : 7, + "rangeType" : "absolute" + }, { + "min" : -3, + "max" : 3, + "rangeType" : "relativeToInitialNetwork" + } ] + },{ + "id" : "pstRange4Id", + "name" : "pstRange4Name", + "operator" : "RTE", + "onConstraintUsageRules" : [ { + "instant" : "curative", + "cnecId" : "voltageCnecId", + "usageMethod" : "available" + } ], + "networkElementId" : "pst4", + "groupId" : "group-3-pst", + "initialTap" : 1, + "tapToAngleConversionMap" : { + "-1" : 1.0, + "0" : 1.5, + "1" : 2.0, + "2" : 2.5, + "3" : 3.0, + "-3" : 0.0, + "-2" : 0.5 + }, + "ranges" : [ { + "min" : -2, + "max" : 7, + "rangeType" : "absolute" + }, { + "min" : -1, + "max" : 4, + "rangeType" : "relativeToPreviousTimeStep" + } ] + } ], + "hvdcRangeActions" : [ { + "id" : "hvdcRange1Id", + "name" : "hvdcRange1Name", + "operator" : "RTE", + "speed" : 20, + "onInstantUsageRules" : [ { + "instant" : "preventive", + "usageMethod" : "available" + } ], + "networkElementId" : "hvdc", + "initialSetpoint" : 100, + "ranges" : [ { + "min" : -1000.0, + "max" : 1000.0 + } ] + }, { + "id" : "hvdcRange2Id", + "name" : "hvdcRange2Name", + "operator" : "RTE", + "onConstraintUsageRules" : [ { + "instant" : "preventive", + "cnecId" : "cnec3curId", + "usageMethod" : "available" + } ], + "networkElementId" : "hvdc2", + "groupId" : "group-1-hvdc", + "initialSetpoint" : -100, + "ranges" : [ { + "min" : -1000.0, + "max" : 1000.0 + } ] + } ], + "injectionRangeActions" : [ { + "id" : "injectionRange1Id", + "name" : "injectionRange1Name", + "operator" : null, + "speed" : 30, + "onContingencyStateUsageRules" : [ { + "instant" : "curative", + "contingencyId" : "contingency1Id", + "usageMethod" : "available" + } ], + "networkElementIdsAndKeys" : { + "generator1Id" : 1.0, + "generator2Id" : -1.0 + }, + "initialSetpoint" : 50, + "ranges" : [ { + "min" : -500.0, + "max" : 500.0 + }, { + "min" : -1000.0, + "max" : 1000.0 + } ] + } ], + "counterTradeRangeActions" : [ { + "id" : "counterTradeRange1Id", + "name" : "counterTradeRange1Name", + "operator" : null, + "speed" : 30, + "onInstantUsageRules" : [ { + "instant" : "preventive", + "usageMethod" : "available" + } ], + "onConstraintUsageRules" : [ { + "instant" : "preventive", + "cnecId" : "cnec3curId", + "usageMethod" : "available" + }, { + "instant" : "curative", + "cnecId" : "voltageCnecId", + "usageMethod" : "available" + }, { + "instant" : "curative", + "cnecId" : "angleCnecId", + "usageMethod" : "available" + } ], + "onContingencyStateUsageRules" : [ { + "instant" : "curative", + "contingencyId" : "contingency1Id", + "usageMethod" : "available" + } ], + "exportingCountry" : "FR", + "importingCountry" : "DE", + "initialSetpoint" : 50, + "ranges" : [ { + "min" : -500.0, + "max" : 500.0 + }, { + "min" : -1000.0, + "max" : 1000.0 + } ] + } ], + "networkActions" : [ { + "id" : "complexNetworkActionId", + "name" : "complexNetworkActionName", + "operator" : "RTE", + "speed" : 40, + "onInstantUsageRules" : [ { + "instant" : "preventive", + "usageMethod" : "available" + } ], + "terminalsConnectionActions" : [ { + "networkElementId" : "ne1Id", + "actionType" : "close" + } ], + "phaseTapChangerTapPositionActions" : [ { + "networkElementId" : "pst", + "tapPosition" : 5 + } ] + }, { + "id" : "injectionSetpointRaId", + "name" : "injectionSetpointRaName", + "operator" : "RTE", + "onConstraintUsageRules" : [ { + "instant" : "auto", + "cnecId" : "cnec3autoId", + "usageMethod" : "forced" + } ], + "generatorActions" : [ { + "networkElementId" : "injection", + "activePowerValue" : 260.0 + }] + }, { + "id" : "injectionSetpointRa2Id", + "name" : "injectionSetpointRa2Name", + "operator" : "RTE", + "onFlowConstraintInCountryUsageRules" : [ { + "instant" : "curative", + "contingencyId" : "contingency2Id", + "country" : "FR", + "usageMethod" : "available" + } ], + "generatorActions" : [ { + "networkElementId" : "injection", + "activePowerValue" : 260.0 + }] + }, { + "id" : "injectionSetpointRa3Id", + "name" : "injectionSetpointRa3Name", + "operator" : "RTE", + "onFlowConstraintInCountryUsageRules" : [ { + "instant" : "curative", + "country" : "FR", + "usageMethod" : "available" + } ], + "generatorActions" : [ { + "networkElementId" : "injection", + "activePowerValue" : 260.0 + }] + }, { + "id" : "complexNetworkAction2Id", + "name" : "complexNetworkAction2Name", + "operator" : "RTE", + "onFlowConstraintInCountryUsageRules" : [ { + "instant" : "curative", + "contingencyId" : "contingency2Id", + "country" : "FR", + "usageMethod" : "available" + } ], + "loadActions" : [ { + "actionId": "loadActionLD1", + "networkElementId" : "LD1", + "activePowerValue" : 260.0 + } ], + "danglingLineActions" : [ { + "networkElementId" : "DL1", + "activePowerValue" : -120.0 + } ], + "shuntCompensatorPositionActions" : [ { + "networkElementId" : "SC1", + "sectionCount" : 13 + }], + "switchActions" : [ { + "actionId": "switchActionBR1", + "networkElementId" : "BR1", + "actionType" : "open" + } ] + }, { + "id" : "pstSetpointRaId", + "name" : "pstSetpointRaName", + "operator" : "RTE", + "onInstantUsageRules" : [ { + "instant" : "preventive", + "usageMethod" : "available" + } ], + "onContingencyStateUsageRules" : [ { + "instant" : "curative", + "contingencyId" : "contingency1Id", + "usageMethod" : "forced" + } ], + "phaseTapChangerTapPositionActions" : [ { + "networkElementId" : "pst", + "tapPosition" : 15 + } ] + }, { + "id" : "switchPairRaId", + "name" : "switchPairRaName", + "operator" : "RTE", + "onContingencyStateUsageRules" : [ { + "instant" : "curative", + "contingencyId" : "contingency2Id", + "usageMethod" : "available" + } ], + "switchPairs" : [ { + "open" : "to-open", + "close" : "to-close" + } ] + } ] +} \ No newline at end of file