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 Jan 31, 2023
1 parent e3dbbb9 commit dbb60c5
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* droop and p0 are parameters used for ac emulation only.
* targetP is for fix target mode only.
* ac emulation works only with vsc technology.
* attribute relative value if true add target p to the previous target p if false it replaces it
*
* @author Etienne Lesot <etienne.lesot@rte-france.com>
*/
Expand All @@ -25,28 +26,38 @@ public class HvdcAction extends AbstractAction {
public static final String NAME = "HVDC";

private final String hvdcId;
private final boolean enabled;
private final boolean acEmulationEnabled;
private final Double targetP;
private final HvdcLine.ConvertersMode converterMode;
private final Double droop;
private final Double p0;
private final boolean relativeValue;

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

public HvdcAction(String id, String hvdcId, HvdcLine.ConvertersMode converterMode, Double droop, Double p0) {
this(id, hvdcId, true, null, converterMode, droop, p0);
public HvdcAction(String id, String hvdcId, HvdcLine.ConvertersMode converterMode, Double droop, Double p0, boolean relativeValue) {
this(id, hvdcId, true, null, converterMode, droop, p0, relativeValue);
}

public HvdcAction(String id, String hvdcId, boolean enabled, Double targetP, HvdcLine.ConvertersMode converterMode, Double droop, Double p0) {
public HvdcAction(String id, String hvdcId, boolean acEmulationEnabled, Double targetP, HvdcLine.ConvertersMode converterMode, Double droop, Double p0, boolean relativeValue) {
super(id);
this.hvdcId = hvdcId;
this.enabled = enabled;
this.acEmulationEnabled = acEmulationEnabled;
this.targetP = targetP;
this.converterMode = converterMode;
this.droop = droop;
this.p0 = p0;
this.relativeValue = relativeValue;
}

public static HvdcAction activateAcEmulationMode(String id, String hvdcId, HvdcLine.ConvertersMode converterMode, Double droop, Double p0, boolean relativeValue) {
return new HvdcAction(id, hvdcId, converterMode, droop, p0, relativeValue);
}

public static HvdcAction activateFixTargetMode(String id, String hvdcId, Double targetP, HvdcLine.ConvertersMode converterMode, boolean relativeValue) {
return new HvdcAction(id, hvdcId, targetP, converterMode, relativeValue);
}

@Override
Expand Down Expand Up @@ -74,7 +85,11 @@ public OptionalDouble getP0() {
return p0 == null ? OptionalDouble.empty() : OptionalDouble.of(p0);
}

public boolean isEnabled() {
return enabled;
public boolean isAcEmulationEnabled() {
return acEmulationEnabled;
}

public boolean isRelativeValue() {
return relativeValue;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ public HvdcActionDeserializer() {
private static class ParsingContext {
String id;
String hvdcId;
boolean enabled;
boolean acEmulationEnabled;
Double targetP;
HvdcLine.ConvertersMode converterMode;
Double droop;
Double p0;
boolean relativeValue;
}

@Override
Expand All @@ -52,9 +53,9 @@ public HvdcAction deserialize(JsonParser jsonParser, DeserializationContext dese
case "hvdcId":
context.hvdcId = jsonParser.nextTextValue();
return true;
case "enabled":
case "acEmulationEnabled":
jsonParser.nextToken();
context.enabled = jsonParser.getValueAsBoolean();
context.acEmulationEnabled = jsonParser.getValueAsBoolean();
return true;
case "targetP":
jsonParser.nextToken();
Expand All @@ -71,11 +72,15 @@ public HvdcAction deserialize(JsonParser jsonParser, DeserializationContext dese
jsonParser.nextToken();
context.p0 = jsonParser.getValueAsDouble();
return true;
case "relativeValue":
jsonParser.nextToken();
context.relativeValue = jsonParser.getValueAsBoolean();
return true;
default:
return false;
}
});
return new HvdcAction(context.id, context.hvdcId, context.enabled, context.targetP, context.converterMode,
context.droop, context.p0);
return new HvdcAction(context.id, context.hvdcId, context.acEmulationEnabled, context.targetP, context.converterMode,
context.droop, context.p0, context.relativeValue);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ public void serialize(HvdcAction action, JsonGenerator jsonGenerator, Serializer
jsonGenerator.writeStringField("type", action.getType());
jsonGenerator.writeStringField("id", action.getId());
jsonGenerator.writeStringField("hvdcId", action.getHvdcId());
jsonGenerator.writeBooleanField("enabled", action.isEnabled());
jsonGenerator.writeBooleanField("acEmulationEnabled", action.isAcEmulationEnabled());
JsonUtil.writeOptionalDouble(jsonGenerator, "targetP", action.getTargetP());
jsonGenerator.writeStringField("converterMode", action.getConverterMode().toString());
JsonUtil.writeOptionalDouble(jsonGenerator, "droop", action.getDroop());
JsonUtil.writeOptionalDouble(jsonGenerator, "p0", action.getP0());
jsonGenerator.writeBooleanField("relativeValue", action.isRelativeValue());
jsonGenerator.writeEndObject();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ public 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(new HvdcAction("id22", "hvdc1", 100.0, SIDE_1_RECTIFIER_SIDE_2_INVERTER));
actions.add(new HvdcAction("id23", "hvdc1", SIDE_1_INVERTER_SIDE_2_RECTIFIER, 1.1, 120.0));
actions.add(HvdcAction.activateFixTargetMode("id22", "hvdc1", 100.0, SIDE_1_RECTIFIER_SIDE_2_INVERTER, false));
actions.add(HvdcAction.activateAcEmulationMode("id23", "hvdc1", SIDE_1_INVERTER_SIDE_2_RECTIFIER, 1.1, 120.0, true));
ActionList actionList = new ActionList(actions);
roundTripTest(actionList, ActionList::writeJsonFile, ActionList::readJsonFile, "/ActionFileTest.json");
}

@Test
public void actionsReadV10() throws IOException {
public void actionsRedV10() throws IOException {
ActionList actionList = ActionList.readJsonInputStream(getClass().getResourceAsStream("/ActionFileTestV1.0.json"));
try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
actionList.writeJsonOutputStream(bos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,18 @@
"type" : "HVDC",
"id" : "id22",
"hvdcId" : "hvdc1",
"enabled" : false,
"acEmulationEnabled" : false,
"targetP" : 100.0,
"converterMode" : "SIDE_1_RECTIFIER_SIDE_2_INVERTER"
"converterMode" : "SIDE_1_RECTIFIER_SIDE_2_INVERTER",
"relativeValue" : false
}, {
"type" : "HVDC",
"id" : "id23",
"hvdcId" : "hvdc1",
"enabled" : true,
"acEmulationEnabled" : true,
"converterMode" : "SIDE_1_INVERTER_SIDE_2_RECTIFIER",
"droop" : 1.1,
"p0" : 120.0
"p0" : 120.0,
"relativeValue" : true
} ]
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,18 @@
"type" : "HVDC",
"id" : "id22",
"hvdcId" : "hvdc1",
"enabled" : false,
"acEmulationEnabled" : false,
"targetP" : 100.0,
"converterMode" : "SIDE_1_RECTIFIER_SIDE_2_INVERTER"
"converterMode" : "SIDE_1_RECTIFIER_SIDE_2_INVERTER",
"relativeValue" : false
}, {
"type" : "HVDC",
"id" : "id23",
"hvdcId" : "hvdc1",
"enabled" : true,
"acEmulationEnabled" : true,
"converterMode" : "SIDE_1_INVERTER_SIDE_2_RECTIFIER",
"droop" : 1.1,
"p0" : 120.0
"p0" : 120.0,
"relativeValue" : true
} ]
}

0 comments on commit dbb60c5

Please sign in to comment.