Skip to content

Commit

Permalink
review
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 7, 2023
1 parent 26e68d7 commit 2eac0f5
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ public class HvdcAction extends AbstractAction {
private final Double p0;
private final Boolean relativeValue;

public HvdcAction(String id, String hvdcId, Double activePowerSetpoint, HvdcLine.ConvertersMode converterMode, Boolean relativeValue) {
this(id, hvdcId, false, activePowerSetpoint, converterMode, null, null, relativeValue);
}

public HvdcAction(String id, String hvdcId, Double droop, Double p0) {
this(id, hvdcId, true, null, null, droop, p0, null);
}

public HvdcAction(String id, String hvdcId, boolean acEmulationEnabled, Double activePowerSetpoint, HvdcLine.ConvertersMode converterMode, Double droop, Double p0, Boolean relativeValue) {
super(id);
this.hvdcId = hvdcId;
Expand All @@ -58,19 +50,19 @@ public HvdcAction(String id, String hvdcId, boolean acEmulationEnabled, Double a
}

public static HvdcAction activateAcEmulationMode(String id, String hvdcId) {
return activateAcEmulationMode(id, hvdcId, null, null);
}

public static HvdcAction activateAcEmulationMode(String id, String hvdcId, Double droop, Double p0) {
return new HvdcAction(id, hvdcId, droop, p0);
return new HvdcActionBuilder()
.withId(id)
.withHvdcId(hvdcId)
.withAcEmulationEnabled(true)
.build();
}

public static HvdcAction activateActivePowerSetpointMode(String id, String hvdcId) {
return activateActivePowerSetpointMode(id, hvdcId, null, null, null);
}

public static HvdcAction activateActivePowerSetpointMode(String id, String hvdcId, Double activePowerSetpoint, HvdcLine.ConvertersMode converterMode, Boolean relativeValue) {
return new HvdcAction(id, hvdcId, activePowerSetpoint, converterMode, relativeValue);
return new HvdcActionBuilder()
.withId(id)
.withHvdcId(hvdcId)
.withAcEmulationEnabled(false)
.build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Copyright (c) 2023, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* SPDX-License-Identifier: MPL-2.0
*/
package com.powsybl.security.action;

import com.powsybl.iidm.network.HvdcLine;

/**
*
* @author Etienne Lesot <etienne.lesot@rte-france.com>
*/
public class HvdcActionBuilder {

private String id;
private String hvdcId;
private boolean acEmulationEnabled;
private Double activePowerSetpoint = null;
private HvdcLine.ConvertersMode converterMode = null;
private Double droop = null;
private Double p0 = null;
private Boolean relativeValue = null;

public HvdcAction build() {
return new HvdcAction(id, hvdcId, acEmulationEnabled, activePowerSetpoint, converterMode, droop, p0, relativeValue);
}

public HvdcActionBuilder withId(String id) {
this.id = id;
return this;
}

public HvdcActionBuilder withHvdcId(String hvdcId) {
this.hvdcId = hvdcId;
return this;
}

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

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

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

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

public HvdcActionBuilder withRelativeValue(boolean relativeValue) {
this.relativeValue = relativeValue;
return this;
}

public HvdcActionBuilder withConverterMode(HvdcLine.ConvertersMode converterMode) {
this.converterMode = converterMode;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.powsybl.commons.test.AbstractConverterTest;
import com.powsybl.commons.test.ComparisonUtils;
import com.powsybl.contingency.ContingencyContext;
import com.powsybl.iidm.network.HvdcLine;
import com.powsybl.iidm.network.PhaseTapChanger;
import com.powsybl.iidm.network.ThreeWindingsTransformer;
import com.powsybl.security.action.*;
Expand Down Expand Up @@ -66,10 +65,8 @@ 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", "hvdc1", 100.0, HvdcLine.ConvertersMode.SIDE_1_RECTIFIER_SIDE_2_INVERTER, false));
actions.add(HvdcAction.activateAcEmulationMode("id23", "hvdc1", 1.1, 120.0));
actions.add(HvdcAction.activateActivePowerSetpointMode("id24", "hvdc2"));
actions.add(HvdcAction.activateAcEmulationMode("id25", "hvdc2"));
actions.add(HvdcAction.activateActivePowerSetpointMode("id22", "hvdc2"));
actions.add(HvdcAction.activateAcEmulationMode("id23", "hvdc2"));
ActionList actionList = new ActionList(actions);
roundTripTest(actionList, ActionList::writeJsonFile, ActionList::readJsonFile, "/ActionFileTest.json");
}
Expand All @@ -96,7 +93,7 @@ void operatorStrategyReadV10() throws IOException {
void operatorStrategyRoundTrip() throws IOException {
List<OperatorStrategy> operatorStrategies = new ArrayList<>();
operatorStrategies.add(new OperatorStrategy("id1", ContingencyContext.specificContingency("contingencyId1"), new TrueCondition(), Arrays.asList("actionId1", "actionId2", "actionId3")));
operatorStrategies.add(new OperatorStrategy("id1", ContingencyContext.specificContingency("contingencyId1"), new TrueCondition(), Arrays.asList("actionId1", "actionId2", "actionId3")));
operatorStrategies.add(new OperatorStrategy("id2", ContingencyContext.specificContingency("contingencyId2"), new TrueCondition(), Arrays.asList("actionId4", "actionId5")));
OperatorStrategyList operatorStrategyList = new OperatorStrategyList(operatorStrategies);
roundTripTest(operatorStrategyList, OperatorStrategyList::write, OperatorStrategyList::read, "/OperatorStrategyFileTest.json");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,26 +139,11 @@
}, {
"type" : "HVDC",
"id" : "id22",
"hvdcId" : "hvdc1",
"acEmulationEnabled" : false,
"activePowerSetpoint" : 100.0,
"converterMode" : "SIDE_1_RECTIFIER_SIDE_2_INVERTER",
"relativeValue" : false
}, {
"type" : "HVDC",
"id" : "id23",
"hvdcId" : "hvdc1",
"acEmulationEnabled" : true,
"droop" : 1.1,
"p0" : 120.0
}, {
"type" : "HVDC",
"id" : "id24",
"hvdcId" : "hvdc2",
"acEmulationEnabled" : false
}, {
"type" : "HVDC",
"id" : "id25",
"id" : "id23",
"hvdcId" : "hvdc2",
"acEmulationEnabled" : true
} ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,26 +139,11 @@
}, {
"type" : "HVDC",
"id" : "id22",
"hvdcId" : "hvdc1",
"acEmulationEnabled" : false,
"activePowerSetpoint" : 100.0,
"converterMode" : "SIDE_1_RECTIFIER_SIDE_2_INVERTER",
"relativeValue" : false
}, {
"type" : "HVDC",
"id" : "id23",
"hvdcId" : "hvdc1",
"acEmulationEnabled" : true,
"droop" : 1.1,
"p0" : 120.0
}, {
"type" : "HVDC",
"id" : "id24",
"hvdcId" : "hvdc2",
"acEmulationEnabled" : false
}, {
"type" : "HVDC",
"id" : "id25",
"id" : "id23",
"hvdcId" : "hvdc2",
"acEmulationEnabled" : true
} ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
},
"actionIds" : [ "actionId1", "actionId2", "actionId3" ]
}, {
"id" : "id1",
"id" : "id2",
"contingencyContextType" : "SPECIFIC",
"contingencyId" : "contingencyId1",
"contingencyId" : "contingencyId2",
"condition" : {
"type" : "TRUE_CONDITION"
},
"actionIds" : [ "actionId1", "actionId2", "actionId3" ]
"actionIds" : [ "actionId4", "actionId5" ]
} ]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
},
"actionIds" : [ "actionId1", "actionId2", "actionId3" ]
}, {
"id" : "id1",
"contingencyId" : "contingencyId1",
"id" : "id2",
"contingencyId" : "contingencyId2",
"condition" : {
"type" : "TRUE_CONDITION"
},
"actionIds" : [ "actionId1", "actionId2", "actionId3" ]
"actionIds" : [ "actionId4", "actionId5" ]
} ]
}

0 comments on commit 2eac0f5

Please sign in to comment.