From 64cfff71813d14c9b5673055f30a53914ae53956 Mon Sep 17 00:00:00 2001 From: Pauline Jean-Marie Date: Tue, 4 Jun 2024 16:33:57 +0200 Subject: [PATCH] Use core Action to apply the injection range action Signed-off-by: Pauline Jean-Marie --- .../cracimpl/InjectionRangeActionImpl.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/InjectionRangeActionImpl.java b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/InjectionRangeActionImpl.java index 277fe488e7..b9a30bd51a 100644 --- a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/InjectionRangeActionImpl.java +++ b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/InjectionRangeActionImpl.java @@ -6,6 +6,8 @@ */ package com.powsybl.openrao.data.cracimpl; +import com.powsybl.action.GeneratorActionBuilder; +import com.powsybl.action.LoadActionBuilder; import com.powsybl.openrao.commons.OpenRaoException; import com.powsybl.openrao.data.cracapi.NetworkElement; import com.powsybl.openrao.data.cracapi.range.StandardRange; @@ -76,14 +78,29 @@ public void apply(Network network, double targetSetpoint) { private void applyInjection(Network network, String injectionId, double targetSetpoint) { Generator generator = network.getGenerator(injectionId); if (generator != null) { - generator.setTargetP(targetSetpoint); + new GeneratorActionBuilder() + .withId("id") + .withGeneratorId(injectionId) + .withActivePowerRelativeValue(false) + .withActivePowerValue(targetSetpoint) + .build() + .toModification() + .apply(network); return; } Load load = network.getLoad(injectionId); if (load != null) { - load.setP0(-targetSetpoint); + new LoadActionBuilder() + .withId("id") + .withLoadId(injectionId) + .withRelativeValue(false) + .withActivePowerValue(-targetSetpoint) + .build() + .toModification() + .apply(network); return; + } if (network.getIdentifiable(injectionId) == null) {