Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
  • Loading branch information
EtienneLt committed Mar 9, 2023
1 parent db12f51 commit cf0fc3a
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class HvdcAction extends AbstractAction {
private final Double p0;
private final Boolean relativeValue;

public HvdcAction(String id, String hvdcId, boolean acEmulationEnabled, Double activePowerSetpoint, HvdcLine.ConvertersMode converterMode, Double droop, Double p0, Boolean relativeValue) {
protected HvdcAction(String id, String hvdcId, boolean acEmulationEnabled, Double activePowerSetpoint, HvdcLine.ConvertersMode converterMode, Double droop, Double p0, Boolean relativeValue) {
super(id);
this.hvdcId = hvdcId;
this.acEmulationEnabled = acEmulationEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@ public HvdcActionBuilder withHvdcId(String hvdcId) {
return this;
}

public HvdcActionBuilder withAcEmulationEnabled(boolean acEmulationEnabled) {
public HvdcActionBuilder withAcEmulationEnabled(Boolean acEmulationEnabled) {
this.acEmulationEnabled = acEmulationEnabled;
return this;
}

public HvdcActionBuilder withActivePowerSetpoint(double activePowerSetpoint) {
public HvdcActionBuilder withActivePowerSetpoint(Double activePowerSetpoint) {
this.activePowerSetpoint = activePowerSetpoint;
return this;
}

public HvdcActionBuilder withDroop(double droop) {
public HvdcActionBuilder withDroop(Double droop) {
this.droop = droop;
return this;
}

public HvdcActionBuilder withP0(double p0) {
public HvdcActionBuilder withP0(Double p0) {
this.p0 = p0;
return this;
}

public HvdcActionBuilder withRelativeValue(boolean relativeValue) {
public HvdcActionBuilder withRelativeValue(Boolean relativeValue) {
this.relativeValue = relativeValue;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.powsybl.commons.json.JsonUtil;
import com.powsybl.iidm.network.HvdcLine;
import com.powsybl.security.action.HvdcAction;
import com.powsybl.security.action.HvdcActionBuilder;

import java.io.IOException;

Expand Down Expand Up @@ -80,7 +81,15 @@ public HvdcAction deserialize(JsonParser jsonParser, DeserializationContext dese
return false;
}
});
return new HvdcAction(context.id, context.hvdcId, context.acEmulationEnabled, context.activePowerSetpoint, context.converterMode,
context.droop, context.p0, context.relativeValue);
return new HvdcActionBuilder()
.withId(context.id)
.withHvdcId(context.hvdcId)
.withAcEmulationEnabled(context.acEmulationEnabled)
.withActivePowerSetpoint(context.activePowerSetpoint)
.withConverterMode(context.converterMode)
.withDroop(context.droop)
.withP0(context.p0)
.withRelativeValue(context.relativeValue)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.Collections;
import java.util.List;

import static com.powsybl.iidm.network.HvdcLine.ConvertersMode.SIDE_1_RECTIFIER_SIDE_2_INVERTER;
import static org.junit.jupiter.api.Assertions.*;
import static com.powsybl.security.LimitViolationType.*;

Expand Down Expand Up @@ -68,8 +69,24 @@ void actionRoundTrip() throws IOException {
PhaseTapChanger.RegulationMode.ACTIVE_POWER_CONTROL, 15.0));
actions.add(RatioTapChangerRegulationAction.activateRegulationAndChangeTargetV("id20", "transformerId5", 90.0));
actions.add(RatioTapChangerRegulationAction.deactivateRegulation("id21", "transformerId5", ThreeWindingsTransformer.Side.THREE));
actions.add(HvdcAction.activateActivePowerSetpointMode("id22", "hvdc2"));
actions.add(HvdcAction.activateActivePowerSetpointMode("id22", "hvdc1"));
actions.add(HvdcAction.activateAcEmulationMode("id23", "hvdc2"));
actions.add(new HvdcActionBuilder()
.withId("id24")
.withHvdcId("hvdc2")
.withAcEmulationEnabled(true)
.withDroop(121.0)
.withP0(42.0)
.withConverterMode(SIDE_1_RECTIFIER_SIDE_2_INVERTER)
.withRelativeValue(false)
.build());
actions.add(new HvdcActionBuilder()
.withId("id25")
.withHvdcId("hvdc1")
.withAcEmulationEnabled(false)
.withActivePowerSetpoint(12.0)
.withRelativeValue(true)
.build());
ActionList actionList = new ActionList(actions);
roundTripTest(actionList, ActionList::writeJsonFile, ActionList::readJsonFile, "/ActionFileTest.json");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,28 @@
}, {
"type" : "HVDC",
"id" : "id22",
"hvdcId" : "hvdc2",
"hvdcId" : "hvdc1",
"acEmulationEnabled" : false
}, {
"type" : "HVDC",
"id" : "id23",
"hvdcId" : "hvdc2",
"acEmulationEnabled" : true
}, {
"type" : "HVDC",
"id" : "id24",
"hvdcId" : "hvdc2",
"acEmulationEnabled" : true,
"converterMode" : "SIDE_1_RECTIFIER_SIDE_2_INVERTER",
"droop" : 121.0,
"p0" : 42.0,
"relativeValue" : false
}, {
"type" : "HVDC",
"id" : "id25",
"hvdcId" : "hvdc1",
"acEmulationEnabled" : false,
"activePowerSetpoint" : 12.0,
"relativeValue" : true
} ]
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,28 @@
}, {
"type" : "HVDC",
"id" : "id22",
"hvdcId" : "hvdc2",
"hvdcId" : "hvdc1",
"acEmulationEnabled" : false
}, {
"type" : "HVDC",
"id" : "id23",
"hvdcId" : "hvdc2",
"acEmulationEnabled" : true
}, {
"type" : "HVDC",
"id" : "id24",
"hvdcId" : "hvdc2",
"acEmulationEnabled" : true,
"converterMode" : "SIDE_1_RECTIFIER_SIDE_2_INVERTER",
"droop" : 121.0,
"p0" : 42.0,
"relativeValue" : false
}, {
"type" : "HVDC",
"id" : "id25",
"hvdcId" : "hvdc1",
"acEmulationEnabled" : false,
"activePowerSetpoint" : 12.0,
"relativeValue" : true
} ]
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}, {
"id" : "id3",
"contingencyContextType" : "SPECIFIC",
"contingencyId" : "contingencyId2",
"contingencyId" : "contingencyId1",
"condition" : {
"type" : "ANY_VIOLATION_CONDITION",
"filters" : [ "CURRENT" ]
Expand Down

0 comments on commit cf0fc3a

Please sign in to comment.