diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/AbstractHvdcBuilder.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/AbstractHvdcBuilder.java index 6f4c147ee..b9ed2252d 100644 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/AbstractHvdcBuilder.java +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/AbstractHvdcBuilder.java @@ -13,26 +13,24 @@ import com.powsybl.dynawo.builders.BuilderReports; import com.powsybl.iidm.network.*; -import java.util.function.Function; - /** * @author Laurent Issertial {@literal } */ public abstract class AbstractHvdcBuilder> extends AbstractEquipmentModelBuilder { protected TwoSides danglingSide; - private final Function eventVarNameSupplier; + private final HvdcVarNameHandler varNameHandler; protected AbstractHvdcBuilder(Network network, ModelConfig modelConfig, IdentifiableType identifiableType, - ReportNode reportNode, Function eventVarNameSupplier) { + ReportNode reportNode, HvdcVarNameHandler varNameHandler) { super(network, modelConfig, identifiableType, reportNode); - this.eventVarNameSupplier = eventVarNameSupplier; + this.varNameHandler = varNameHandler; } protected AbstractHvdcBuilder(Network network, ModelConfig modelConfig, String equipmentType, ReportNode reportNode, - Function eventVarNameSupplier) { + HvdcVarNameHandler varNameHandler) { super(network, modelConfig, equipmentType, reportNode); - this.eventVarNameSupplier = eventVarNameSupplier; + this.varNameHandler = varNameHandler; } public R dangling(TwoSides danglingSide) { @@ -57,9 +55,9 @@ protected void checkData() { public BaseHvdc build() { if (isInstantiable()) { if (modelConfig.isDangling()) { - return new HvdcDangling(dynamicModelId, getEquipment(), parameterSetId, modelConfig, eventVarNameSupplier, danglingSide); + return new HvdcDangling(dynamicModelId, getEquipment(), parameterSetId, modelConfig, varNameHandler, danglingSide); } else { - return new BaseHvdc(dynamicModelId, getEquipment(), parameterSetId, modelConfig, eventVarNameSupplier); + return new BaseHvdc(dynamicModelId, getEquipment(), parameterSetId, modelConfig, varNameHandler); } } return null; diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/BaseHvdc.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/BaseHvdc.java index 755cf5b23..c40475134 100644 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/BaseHvdc.java +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/BaseHvdc.java @@ -13,7 +13,6 @@ import com.powsybl.dynawo.models.AbstractEquipmentBlackBoxModel; import com.powsybl.dynawo.models.VarConnection; import com.powsybl.dynawo.models.VarMapping; -import com.powsybl.dynawo.models.utils.SideUtils; import com.powsybl.iidm.network.HvdcConverterStation; import com.powsybl.iidm.network.HvdcLine; import com.powsybl.iidm.network.TwoSides; @@ -21,7 +20,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.function.Function; /** * @author Laurent Issertial {@literal } @@ -38,11 +36,11 @@ public class BaseHvdc extends AbstractEquipmentBlackBoxModel implement protected static final String TERMINAL_PREFIX = "hvdc_terminal"; - private final Function eventVarNameSupplier; + private final HvdcVarNameHandler varNameHandler; - protected BaseHvdc(String dynamicModelId, HvdcLine hvdc, String parameterSetId, ModelConfig modelConfig, Function eventVarNameSupplier) { + protected BaseHvdc(String dynamicModelId, HvdcLine hvdc, String parameterSetId, ModelConfig modelConfig, HvdcVarNameHandler varNameHandler) { super(dynamicModelId, parameterSetId, hvdc, modelConfig); - this.eventVarNameSupplier = eventVarNameSupplier; + this.varNameHandler = varNameHandler; } @Override @@ -60,7 +58,7 @@ protected List getVarConnectionsWith(EquipmentConnectionPoint con List varConnections = new ArrayList<>(2); varConnections.add(getSimpleVarConnectionWithBus(connected, side)); connected.getSwitchOffSignalVarName(side) - .map(switchOff -> new VarConnection("hvdc_switchOffSignal1" + SideUtils.getSideSuffix(side), switchOff)) + .map(switchOff -> new VarConnection(varNameHandler.getConnectionPointVarName(side), switchOff)) .ifPresent(varConnections::add); return varConnections; } @@ -75,6 +73,6 @@ public List> getConnectedStations() { @Override public String getSwitchOffSignalEventVarName(TwoSides side) { - return eventVarNameSupplier.apply(side); + return varNameHandler.getEventVarName(side); } } diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcDangling.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcDangling.java index 5619e425d..48b16464d 100644 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcDangling.java +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcDangling.java @@ -18,7 +18,6 @@ import com.powsybl.iidm.network.TwoSides; import java.util.List; -import java.util.function.Function; /** * @author Laurent Issertial {@literal } @@ -28,8 +27,8 @@ public class HvdcDangling extends BaseHvdc { private final TwoSides danglingSide; protected HvdcDangling(String dynamicModelId, HvdcLine hvdc, String parameterSetId, ModelConfig modelConfig, - Function eventVarNameSupplier, TwoSides danglingSide) { - super(dynamicModelId, hvdc, parameterSetId, modelConfig, eventVarNameSupplier); + HvdcVarNameHandler varNameHandler, TwoSides danglingSide) { + super(dynamicModelId, hvdc, parameterSetId, modelConfig, varNameHandler); this.danglingSide = danglingSide; } diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcPBuilder.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcPBuilder.java index 8cb597dbb..d1896c343 100644 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcPBuilder.java +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcPBuilder.java @@ -10,14 +10,11 @@ import com.powsybl.commons.report.ReportNode; import com.powsybl.dynawo.builders.*; import com.powsybl.dynawo.commons.DynawoVersion; -import com.powsybl.dynawo.models.utils.SideUtils; import com.powsybl.iidm.network.HvdcLine; import com.powsybl.iidm.network.IdentifiableType; import com.powsybl.iidm.network.Network; -import com.powsybl.iidm.network.TwoSides; import java.util.Collection; -import java.util.function.Function; /** * @author Laurent Issertial {@literal } @@ -26,7 +23,7 @@ public class HvdcPBuilder extends AbstractHvdcBuilder { public static final String CATEGORY = "HVDC_P"; private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); - private static final Function EVENT_VAR_NAME_SUPPLIER = ts -> String.format("hvdc_switchOffSignal2%s", SideUtils.getSideSuffix(ts)); + private static final HvdcVarNameHandler P_NAME_HANDLER = new HvdcPVarNameHandler(); public static HvdcPBuilder of(Network network) { return of(network, ReportNode.NO_OP); @@ -61,7 +58,7 @@ public static Collection getSupportedModelInfos(DynawoVersion dynawoV } protected HvdcPBuilder(Network network, ModelConfig modelConfig, ReportNode reportNode) { - super(network, modelConfig, IdentifiableType.HVDC_LINE, reportNode, EVENT_VAR_NAME_SUPPLIER); + super(network, modelConfig, IdentifiableType.HVDC_LINE, reportNode, P_NAME_HANDLER); } @Override diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcPVarNameHandler.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcPVarNameHandler.java new file mode 100644 index 000000000..dd6114816 --- /dev/null +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcPVarNameHandler.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2024, 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.dynawo.models.hvdc; + +import com.powsybl.dynawo.models.utils.SideUtils; +import com.powsybl.iidm.network.TwoSides; + +/** + * @author Laurent Issertial {@literal } + */ +public final class HvdcPVarNameHandler implements HvdcVarNameHandler { + + @Override + public String getConnectionPointVarName(TwoSides side) { + return String.format("hvdc_switchOffSignal1%s", SideUtils.getSideSuffix(side)); + } + + @Override + public String getEventVarName(TwoSides side) { + return String.format("hvdc_switchOffSignal2%s", SideUtils.getSideSuffix(side)); + } +} diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcVarNameHandler.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcVarNameHandler.java new file mode 100644 index 000000000..5c5e6f12b --- /dev/null +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcVarNameHandler.java @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2024, 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.dynawo.models.hvdc; + +import com.powsybl.iidm.network.TwoSides; + +/** + * @author Laurent Issertial {@literal } + */ +public interface HvdcVarNameHandler { + + String getConnectionPointVarName(TwoSides side); + + String getEventVarName(TwoSides side); +} diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcVscBuilder.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcVscBuilder.java index 283f382e9..17450af5c 100644 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcVscBuilder.java +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcVscBuilder.java @@ -13,7 +13,6 @@ import com.powsybl.iidm.network.*; import java.util.Collection; -import java.util.function.Function; import java.util.function.Predicate; /** @@ -23,7 +22,7 @@ public class HvdcVscBuilder extends AbstractHvdcBuilder { public static final String CATEGORY = "HVDC_VSC"; private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); - private static final Function EVENT_VAR_NAME_SUPPLIER = ts -> String.format("hvdc_Conv%s_switchOffSignal2", ts.getNum()); + private static final HvdcVarNameHandler VSC_NAME_HANDLER = new VscVarNameHandler(); private static final Predicate IS_VSC = eq -> HvdcConverterStation.HvdcType.VSC == eq.getConverterStation1().getHvdcType(); public static HvdcVscBuilder of(Network network) { @@ -59,7 +58,7 @@ public static Collection getSupportedModelInfos(DynawoVersion dynawoV } protected HvdcVscBuilder(Network network, ModelConfig modelConfig, ReportNode reportNode) { - super(network, modelConfig, "VSC " + IdentifiableType.HVDC_LINE, reportNode, EVENT_VAR_NAME_SUPPLIER); + super(network, modelConfig, "VSC " + IdentifiableType.HVDC_LINE, reportNode, VSC_NAME_HANDLER); addEquipmentPredicate(IS_VSC); } diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/VscVarNameHandler.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/VscVarNameHandler.java new file mode 100644 index 000000000..37b5abe0f --- /dev/null +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/VscVarNameHandler.java @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2024, 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.dynawo.models.hvdc; + +import com.powsybl.iidm.network.TwoSides; + +/** + * @author Laurent Issertial {@literal } + */ +public final class VscVarNameHandler implements HvdcVarNameHandler { + + @Override + public String getConnectionPointVarName(TwoSides side) { + return String.format("hvdc_Conv%s_switchOffSignal1", side.getNum()); + } + + @Override + public String getEventVarName(TwoSides side) { + return String.format("hvdc_Conv%s_switchOffSignal2", side.getNum()); + } +} diff --git a/dynawo-simulation/src/test/resources/disconnect_hvdc_vsc_dangling_dyd.xml b/dynawo-simulation/src/test/resources/disconnect_hvdc_vsc_dangling_dyd.xml index 7e50bb8d7..44563548c 100644 --- a/dynawo-simulation/src/test/resources/disconnect_hvdc_vsc_dangling_dyd.xml +++ b/dynawo-simulation/src/test/resources/disconnect_hvdc_vsc_dangling_dyd.xml @@ -9,7 +9,7 @@ - + diff --git a/dynawo-simulation/src/test/resources/disconnect_hvdc_vsc_dyd.xml b/dynawo-simulation/src/test/resources/disconnect_hvdc_vsc_dyd.xml index 28aaf84a3..a05a87811 100644 --- a/dynawo-simulation/src/test/resources/disconnect_hvdc_vsc_dyd.xml +++ b/dynawo-simulation/src/test/resources/disconnect_hvdc_vsc_dyd.xml @@ -6,11 +6,11 @@ - + - + diff --git a/dynawo-simulation/src/test/resources/hvdc_vsc_dangling_dyd.xml b/dynawo-simulation/src/test/resources/hvdc_vsc_dangling_dyd.xml index b39158a80..290e45d07 100644 --- a/dynawo-simulation/src/test/resources/hvdc_vsc_dangling_dyd.xml +++ b/dynawo-simulation/src/test/resources/hvdc_vsc_dangling_dyd.xml @@ -8,7 +8,7 @@ - + diff --git a/dynawo-simulation/src/test/resources/hvdc_vsc_dyd.xml b/dynawo-simulation/src/test/resources/hvdc_vsc_dyd.xml index d23b6b45a..db1f00196 100644 --- a/dynawo-simulation/src/test/resources/hvdc_vsc_dyd.xml +++ b/dynawo-simulation/src/test/resources/hvdc_vsc_dyd.xml @@ -5,11 +5,11 @@ - + - +