diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/CurrentLimitAutomatonGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/CurrentLimitAutomatonGroovyExtension.groovy index 00439dd46..ee1b82bf5 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/CurrentLimitAutomatonGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/CurrentLimitAutomatonGroovyExtension.groovy @@ -15,11 +15,8 @@ import com.powsybl.dynawaltz.dsl.AbstractPureDynamicGroovyExtension import com.powsybl.dynawaltz.dsl.DslEquipment import com.powsybl.dynawaltz.dsl.Reporters import com.powsybl.dynawaltz.dsl.builders.AbstractPureDynamicModelBuilder -import com.powsybl.dynawaltz.models.Side import com.powsybl.dynawaltz.models.automatons.CurrentLimitAutomaton -import com.powsybl.dynawaltz.models.utils.SideConverter import com.powsybl.iidm.network.Branch -import com.powsybl.iidm.network.IdentifiableType import com.powsybl.iidm.network.Network import com.powsybl.iidm.network.TwoSides @@ -47,7 +44,7 @@ class CurrentLimitAutomatonGroovyExtension extends AbstractPureDynamicGroovyExte static class CurrentLimitAutomatonBuilder extends AbstractPureDynamicModelBuilder { protected final DslEquipment iMeasurement - protected Side iMeasurementSide + protected TwoSides iMeasurementSide protected final DslEquipment controlledEquipment CurrentLimitAutomatonBuilder(Network network, String lib, Reporter reporter) { @@ -61,7 +58,7 @@ class CurrentLimitAutomatonGroovyExtension extends AbstractPureDynamicGroovyExte } void iMeasurementSide(TwoSides side) { - this.iMeasurementSide = SideConverter.convert(side) + this.iMeasurementSide = side } void controlledQuadripole(String staticId) { diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/CurrentLimitTwoLevelsAutomatonGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/CurrentLimitTwoLevelsAutomatonGroovyExtension.groovy index 56aa888cc..aa510b6cb 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/CurrentLimitTwoLevelsAutomatonGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/CurrentLimitTwoLevelsAutomatonGroovyExtension.groovy @@ -14,9 +14,7 @@ import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractPureDynamicGroovyExtension import com.powsybl.dynawaltz.dsl.DslEquipment import com.powsybl.dynawaltz.dsl.Reporters -import com.powsybl.dynawaltz.models.Side import com.powsybl.dynawaltz.models.automatons.CurrentLimitTwoLevelsAutomaton -import com.powsybl.dynawaltz.models.utils.SideConverter import com.powsybl.iidm.network.Branch import com.powsybl.iidm.network.Network import com.powsybl.iidm.network.TwoSides @@ -43,7 +41,7 @@ class CurrentLimitTwoLevelsAutomatonGroovyExtension extends AbstractPureDynamicG static class CurrentLimitAutomatonTwoLevelBuilder extends CurrentLimitAutomatonGroovyExtension.CurrentLimitAutomatonBuilder { protected final DslEquipment iMeasurement2 - protected Side iMeasurement2Side + protected TwoSides iMeasurement2Side CurrentLimitAutomatonTwoLevelBuilder(Network network, String lib, Reporter reporter) { super(network, lib, reporter) @@ -63,7 +61,7 @@ class CurrentLimitTwoLevelsAutomatonGroovyExtension extends AbstractPureDynamicG } void iMeasurement2Side(TwoSides side) { - this.iMeasurement2Side = SideConverter.convert(side) + this.iMeasurement2Side = side } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/hvdc/AbstractHvdcBuilder.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/hvdc/AbstractHvdcBuilder.groovy index 1c3b7da02..e1de17971 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/hvdc/AbstractHvdcBuilder.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/hvdc/AbstractHvdcBuilder.groovy @@ -11,8 +11,6 @@ import com.powsybl.commons.reporter.Reporter import com.powsybl.dynawaltz.dsl.EquipmentConfig import com.powsybl.dynawaltz.dsl.Reporters import com.powsybl.dynawaltz.dsl.builders.AbstractEquipmentModelBuilder -import com.powsybl.dynawaltz.models.Side -import com.powsybl.dynawaltz.models.utils.SideConverter import com.powsybl.iidm.network.HvdcLine import com.powsybl.iidm.network.IdentifiableType import com.powsybl.iidm.network.Network @@ -23,14 +21,14 @@ import com.powsybl.iidm.network.TwoSides */ abstract class AbstractHvdcBuilder extends AbstractEquipmentModelBuilder { - protected Side danglingSide + protected TwoSides danglingSide AbstractHvdcBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { super(network, equipmentConfig, IdentifiableType.HVDC_LINE, reporter) } void dangling(TwoSides danglingSide) { - this.danglingSide = SideConverter.convert(danglingSide) + this.danglingSide = danglingSide } @Override diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzContext.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzContext.java index bdf4ed3ab..3d90a8626 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzContext.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzContext.java @@ -26,6 +26,7 @@ import com.powsybl.dynawaltz.xml.MacroStaticReference; import com.powsybl.iidm.network.Identifiable; import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.TwoSides; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -229,7 +230,7 @@ public String addMacroConnector(String name1, String name2, List return macroConnectorId; } - public String addMacroConnector(String name1, String name2, Side side, List varConnections) { + public String addMacroConnector(String name1, String name2, TwoSides side, List varConnections) { String macroConnectorId = MacroConnector.createMacroConnectorId(name1, name2, side); macroConnectorsMap.computeIfAbsent(macroConnectorId, k -> new MacroConnector(macroConnectorId, varConnections)); return macroConnectorId; diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/AbstractBlackBoxModel.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/AbstractBlackBoxModel.java index 2e4079c41..7fb758d9b 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/AbstractBlackBoxModel.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/AbstractBlackBoxModel.java @@ -8,13 +8,11 @@ import com.powsybl.dynawaltz.DynaWaltzContext; import com.powsybl.dynawaltz.DynaWaltzParameters; +import com.powsybl.dynawaltz.models.buses.EquipmentConnectionPoint; import com.powsybl.dynawaltz.models.macroconnections.MacroConnectAttribute; import com.powsybl.dynawaltz.models.macroconnections.MacroConnectionSuffix; -import com.powsybl.dynawaltz.parameters.ParametersSet; -import com.powsybl.iidm.network.Identifiable; -import com.powsybl.dynawaltz.models.buses.EquipmentConnectionPoint; import com.powsybl.dynawaltz.models.utils.BusUtils; -import com.powsybl.dynawaltz.models.utils.SideConverter; +import com.powsybl.dynawaltz.parameters.ParametersSet; import com.powsybl.iidm.network.*; import javax.xml.stream.XMLStreamException; @@ -142,13 +140,13 @@ protected boolean createMacroConnectionsOrSkip(Identifiable /** * Suffixes MacroConnector id with side name */ - protected final void createMacroConnections(String modelStaticId, Class modelClass, BiFunction> varConnectionsSupplier, DynaWaltzContext context, Side side) { + protected final void createMacroConnections(String modelStaticId, Class modelClass, BiFunction> varConnectionsSupplier, DynaWaltzContext context, TwoSides side) { T connectedModel = context.getDynamicModel(modelStaticId, modelClass); String macroConnectorId = context.addMacroConnector(getName(), connectedModel.getName(), side, varConnectionsSupplier.apply(connectedModel, side)); context.addMacroConnect(macroConnectorId, getMacroConnectFromAttributes(), connectedModel.getMacroConnectToAttributes()); } - protected final void createMacroConnections(Identifiable equipment, Class modelClass, BiFunction> varConnectionsSupplier, DynaWaltzContext context, Side side) { + protected final void createMacroConnections(Identifiable equipment, Class modelClass, BiFunction> varConnectionsSupplier, DynaWaltzContext context, TwoSides side) { T connectedModel = context.getDynamicModel(equipment, modelClass); String macroConnectorId = context.addMacroConnector(getName(), connectedModel.getName(), side, varConnectionsSupplier.apply(connectedModel, side)); context.addMacroConnect(macroConnectorId, getMacroConnectFromAttributes(), connectedModel.getMacroConnectToAttributes()); @@ -182,14 +180,14 @@ protected void createTerminalMacroConnections(Injection equipment, Function> varConnectionsSupplier, DynaWaltzContext context, Side side) { + protected final void createTerminalMacroConnections(Terminal terminal, BiFunction> varConnectionsSupplier, DynaWaltzContext context, TwoSides side) { EquipmentConnectionPoint connectedModel = context.getConnectionPointDynamicModel(BusUtils.getConnectableBusStaticId(terminal)); String macroConnectorId = context.addMacroConnector(getName(), connectedModel.getName(), side, varConnectionsSupplier.apply(connectedModel, side)); context.addMacroConnect(macroConnectorId, getMacroConnectFromAttributes(), connectedModel.getMacroConnectToAttributes()); } - protected final void createTerminalMacroConnections(HvdcLine hvdc, BiFunction> varConnectionsSupplier, DynaWaltzContext context, Side side) { - HvdcConverterStation station = hvdc.getConverterStation(SideConverter.convert(side)); + protected final void createTerminalMacroConnections(HvdcLine hvdc, BiFunction> varConnectionsSupplier, DynaWaltzContext context, TwoSides side) { + HvdcConverterStation station = hvdc.getConverterStation(side); createTerminalMacroConnections(station.getTerminal(), varConnectionsSupplier, context, side); } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/Side.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/Side.java deleted file mode 100644 index 24183d522..000000000 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/Side.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * 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.dynawaltz.models; - -/** - * @author Laurent Issertial {@literal } - */ -public enum Side { - - ONE("Side1"), - TWO("Side2"); - - private final String sideSuffix; - - Side(String sideSuffix) { - this.sideSuffix = sideSuffix; - } - - public String getSideSuffix() { - return sideSuffix; - } - - public int getSideNumber() { - return ordinal() + 1; - } - - public Side getOppositeSide() { - return this == ONE ? TWO : ONE; - } -} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/CurrentLimitAutomaton.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/CurrentLimitAutomaton.java index d743b08ec..e454863cd 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/CurrentLimitAutomaton.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/CurrentLimitAutomaton.java @@ -8,9 +8,10 @@ import com.powsybl.dynawaltz.DynaWaltzContext; import com.powsybl.dynawaltz.models.AbstractPureDynamicBlackBoxModel; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.dynawaltz.models.VarConnection; +import com.powsybl.dynawaltz.models.utils.SideUtils; import com.powsybl.iidm.network.Branch; +import com.powsybl.iidm.network.TwoSides; import java.util.Arrays; import java.util.List; @@ -26,11 +27,11 @@ public class CurrentLimitAutomaton extends AbstractPureDynamicBlackBoxModel { protected static final String CONTROL_SUFFIX = "Control"; protected final Branch measuredQuadripole; - protected final Side measuredSide; + protected final TwoSides measuredSide; protected final Branch controlledQuadripole; protected final String lib; - public CurrentLimitAutomaton(String dynamicModelId, String parameterSetId, Branch measuredQuadripole, Side measuredSide, Branch controlledQuadripole, String lib) { + public CurrentLimitAutomaton(String dynamicModelId, String parameterSetId, Branch measuredQuadripole, TwoSides measuredSide, Branch controlledQuadripole, String lib) { super(dynamicModelId, parameterSetId); this.measuredQuadripole = Objects.requireNonNull(measuredQuadripole); this.measuredSide = Objects.requireNonNull(measuredSide); @@ -38,7 +39,7 @@ public CurrentLimitAutomaton(String dynamicModelId, String parameterSetId, Branc this.lib = lib; } - public CurrentLimitAutomaton(String dynamicModelId, String parameterSetId, Branch measuredQuadripole, Side measuredSide, String lib) { + public CurrentLimitAutomaton(String dynamicModelId, String parameterSetId, Branch measuredQuadripole, TwoSides measuredSide, String lib) { this(dynamicModelId, parameterSetId, measuredQuadripole, measuredSide, measuredQuadripole, lib); } @@ -49,7 +50,7 @@ public String getLib() { @Override public void createMacroConnections(DynaWaltzContext context) { - createMacroConnections(measuredQuadripole, QuadripoleModel.class, this::getVarConnectionsWithMeasuredQuadripole, context, MEASURE_SUFFIX + measuredSide.getSideSuffix()); + createMacroConnections(measuredQuadripole, QuadripoleModel.class, this::getVarConnectionsWithMeasuredQuadripole, context, MEASURE_SUFFIX + SideUtils.getSideSuffix(measuredSide)); createMacroConnections(controlledQuadripole, QuadripoleModel.class, this::getVarConnectionsWithControlledQuadripole, context, CONTROL_SUFFIX); } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/CurrentLimitTwoLevelsAutomaton.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/CurrentLimitTwoLevelsAutomaton.java index 8aa8bfc49..645480229 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/CurrentLimitTwoLevelsAutomaton.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/CurrentLimitTwoLevelsAutomaton.java @@ -8,9 +8,10 @@ package com.powsybl.dynawaltz.models.automatons; import com.powsybl.dynawaltz.DynaWaltzContext; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.dynawaltz.models.VarConnection; +import com.powsybl.dynawaltz.models.utils.SideUtils; import com.powsybl.iidm.network.Branch; +import com.powsybl.iidm.network.TwoSides; import java.util.Arrays; import java.util.List; @@ -25,9 +26,9 @@ public class CurrentLimitTwoLevelsAutomaton extends CurrentLimitAutomaton { protected static final String SECOND_MEASURE_SUFFIX = MEASURE_SUFFIX + "2"; private final Branch secondMeasuredQuadripole; - private final Side secondMeasuredSide; + private final TwoSides secondMeasuredSide; - public CurrentLimitTwoLevelsAutomaton(String dynamicModelId, String parameterSetId, Branch measuredQuadripole, Side measuredSide, Branch secondMeasuredQuadripole, Side secondMeasuredSide, Branch controlledQuadripole, String lib) { + public CurrentLimitTwoLevelsAutomaton(String dynamicModelId, String parameterSetId, Branch measuredQuadripole, TwoSides measuredSide, Branch secondMeasuredQuadripole, TwoSides secondMeasuredSide, Branch controlledQuadripole, String lib) { super(dynamicModelId, parameterSetId, measuredQuadripole, measuredSide, controlledQuadripole, lib); this.secondMeasuredQuadripole = Objects.requireNonNull(secondMeasuredQuadripole); this.secondMeasuredSide = Objects.requireNonNull(secondMeasuredSide); @@ -35,8 +36,8 @@ public CurrentLimitTwoLevelsAutomaton(String dynamicModelId, String parameterSet @Override public void createMacroConnections(DynaWaltzContext context) { - createMacroConnections(measuredQuadripole, QuadripoleModel.class, this::getVarConnectionsWithMeasuredQuadripole, context, FIRST_MEASURE_SUFFIX + measuredSide.getSideSuffix()); - createMacroConnections(secondMeasuredQuadripole, QuadripoleModel.class, this::getVarConnectionsWithSecondMeasuredQuadripole, context, SECOND_MEASURE_SUFFIX + secondMeasuredSide.getSideSuffix()); + createMacroConnections(measuredQuadripole, QuadripoleModel.class, this::getVarConnectionsWithMeasuredQuadripole, context, FIRST_MEASURE_SUFFIX + SideUtils.getSideSuffix(measuredSide)); + createMacroConnections(secondMeasuredQuadripole, QuadripoleModel.class, this::getVarConnectionsWithSecondMeasuredQuadripole, context, SECOND_MEASURE_SUFFIX + SideUtils.getSideSuffix(secondMeasuredSide)); createMacroConnections(controlledQuadripole, QuadripoleModel.class, this::getVarConnectionsWithControlledQuadripole, context, CONTROL_SUFFIX); } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/QuadripoleModel.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/QuadripoleModel.java index f68af7969..bafd17e32 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/QuadripoleModel.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/QuadripoleModel.java @@ -8,14 +8,14 @@ package com.powsybl.dynawaltz.models.automatons; import com.powsybl.dynawaltz.models.Model; -import com.powsybl.dynawaltz.models.Side; +import com.powsybl.iidm.network.TwoSides; /** * @author Laurent Issertial {@literal } */ public interface QuadripoleModel extends Model { - String getIVarName(Side side); + String getIVarName(TwoSides side); String getStateVarName(); diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/DefaultEquipmentConnectionPoint.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/DefaultEquipmentConnectionPoint.java index 2e073767e..7d61ec881 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/DefaultEquipmentConnectionPoint.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/DefaultEquipmentConnectionPoint.java @@ -7,9 +7,9 @@ */ package com.powsybl.dynawaltz.models.buses; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.dynawaltz.models.macroconnections.MacroConnectAttribute; import com.powsybl.dynawaltz.xml.DynaWaltzXmlConstants; +import com.powsybl.iidm.network.TwoSides; import java.util.List; import java.util.Optional; @@ -42,8 +42,8 @@ public String getTerminalVarName() { } @Override - public String getTerminalVarName(Side side) { - return "@STATIC_ID@@NODE" + side.getSideNumber() + "@_ACPIN"; + public String getTerminalVarName(TwoSides side) { + return "@STATIC_ID@@NODE" + side.getNum() + "@_ACPIN"; } @Override @@ -52,8 +52,8 @@ public Optional getSwitchOffSignalVarName() { } @Override - public Optional getSwitchOffSignalVarName(Side side) { - return Optional.of("@STATIC_ID@@NODE" + side.getSideNumber() + "@_switchOff"); + public Optional getSwitchOffSignalVarName(TwoSides side) { + return Optional.of("@STATIC_ID@@NODE" + side.getNum() + "@_switchOff"); } @Override diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/EquipmentConnectionPoint.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/EquipmentConnectionPoint.java index 3b48d3509..03f2d30ec 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/EquipmentConnectionPoint.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/EquipmentConnectionPoint.java @@ -8,7 +8,7 @@ package com.powsybl.dynawaltz.models.buses; import com.powsybl.dynawaltz.models.Model; -import com.powsybl.dynawaltz.models.Side; +import com.powsybl.iidm.network.TwoSides; import java.util.Optional; @@ -20,13 +20,13 @@ public interface EquipmentConnectionPoint extends Model { String getTerminalVarName(); - default String getTerminalVarName(Side side) { + default String getTerminalVarName(TwoSides side) { return getTerminalVarName(); } Optional getSwitchOffSignalVarName(); - default Optional getSwitchOffSignalVarName(Side side) { + default Optional getSwitchOffSignalVarName(TwoSides side) { return getSwitchOffSignalVarName(); } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventHvdcDisconnection.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventHvdcDisconnection.java index b9c07cccb..9eb25ca59 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventHvdcDisconnection.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventHvdcDisconnection.java @@ -8,10 +8,10 @@ package com.powsybl.dynawaltz.models.events; import com.powsybl.dynawaltz.DynaWaltzContext; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.dynawaltz.models.VarConnection; import com.powsybl.dynawaltz.models.hvdc.HvdcModel; import com.powsybl.iidm.network.HvdcLine; +import com.powsybl.iidm.network.TwoSides; import java.util.List; @@ -34,11 +34,11 @@ public EventHvdcDisconnection(HvdcLine equipment, double startTime) { } private List getVarConnectionsWithHvdcModel(HvdcModel connected) { - return List.of(new VarConnection(DISCONNECTION_VAR_CONNECT, connected.getSwitchOffSignalEventVarName(Side.ONE)), - new VarConnection(DISCONNECTION_VAR_CONNECT, connected.getSwitchOffSignalEventVarName(Side.TWO))); + return List.of(new VarConnection(DISCONNECTION_VAR_CONNECT, connected.getSwitchOffSignalEventVarName(TwoSides.ONE)), + new VarConnection(DISCONNECTION_VAR_CONNECT, connected.getSwitchOffSignalEventVarName(TwoSides.TWO))); } - private List getVarConnectionsWithHvdcModelSide(HvdcModel connected, Side side) { + private List getVarConnectionsWithHvdcModelSide(HvdcModel connected, TwoSides side) { return List.of(new VarConnection(DISCONNECTION_VAR_CONNECT, connected.getSwitchOffSignalEventVarName(side))); } @@ -47,9 +47,9 @@ public void createMacroConnections(DynaWaltzContext context) { if (disconnectOrigin && disconnectExtremity) { createMacroConnections(getEquipment(), HvdcModel.class, this::getVarConnectionsWithHvdcModel, context); } else if (disconnectOrigin) { - createMacroConnections(getEquipment(), HvdcModel.class, this::getVarConnectionsWithHvdcModelSide, context, Side.ONE); + createMacroConnections(getEquipment(), HvdcModel.class, this::getVarConnectionsWithHvdcModelSide, context, TwoSides.ONE); } else if (disconnectExtremity) { - createMacroConnections(getEquipment(), HvdcModel.class, this::getVarConnectionsWithHvdcModelSide, context, Side.TWO); + createMacroConnections(getEquipment(), HvdcModel.class, this::getVarConnectionsWithHvdcModelSide, context, TwoSides.TWO); } } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/AbstractHvdc.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/AbstractHvdc.java index 2c79c41e6..d442f4d30 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/AbstractHvdc.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/AbstractHvdc.java @@ -9,11 +9,12 @@ import com.powsybl.dynawaltz.DynaWaltzContext; import com.powsybl.dynawaltz.models.AbstractEquipmentBlackBoxModel; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.dynawaltz.models.VarConnection; import com.powsybl.dynawaltz.models.VarMapping; import com.powsybl.dynawaltz.models.buses.EquipmentConnectionPoint; +import com.powsybl.dynawaltz.models.utils.SideUtils; import com.powsybl.iidm.network.HvdcLine; +import com.powsybl.iidm.network.TwoSides; import java.util.ArrayList; import java.util.Arrays; @@ -40,8 +41,8 @@ protected AbstractHvdc(String dynamicModelId, HvdcLine hvdc, String parameterSet @Override public void createMacroConnections(DynaWaltzContext context) { - createTerminalMacroConnections(equipment, this::getVarConnectionsWith, context, Side.ONE); - createTerminalMacroConnections(equipment, this::getVarConnectionsWith, context, Side.TWO); + createTerminalMacroConnections(equipment, this::getVarConnectionsWith, context, TwoSides.ONE); + createTerminalMacroConnections(equipment, this::getVarConnectionsWith, context, TwoSides.TWO); } @Override @@ -49,16 +50,16 @@ public List getVarsMapping() { return VAR_MAPPING; } - protected List getVarConnectionsWith(EquipmentConnectionPoint connected, Side side) { + protected List getVarConnectionsWith(EquipmentConnectionPoint connected, TwoSides side) { List varConnections = new ArrayList<>(2); varConnections.add(getSimpleVarConnectionWithBus(connected, side)); connected.getSwitchOffSignalVarName(side) - .map(switchOff -> new VarConnection("hvdc_switchOffSignal1" + side.getSideSuffix(), switchOff)) + .map(switchOff -> new VarConnection("hvdc_switchOffSignal1" + SideUtils.getSideSuffix(side), switchOff)) .ifPresent(varConnections::add); return varConnections; } - protected final VarConnection getSimpleVarConnectionWithBus(EquipmentConnectionPoint connected, Side side) { - return new VarConnection(TERMINAL_PREFIX + side.getSideNumber(), connected.getTerminalVarName(side)); + protected final VarConnection getSimpleVarConnectionWithBus(EquipmentConnectionPoint connected, TwoSides side) { + return new VarConnection(TERMINAL_PREFIX + side.getNum(), connected.getTerminalVarName(side)); } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/DanglingSide.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/DanglingSide.java index 86d93f717..c4a7e1e48 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/DanglingSide.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/DanglingSide.java @@ -1,8 +1,9 @@ package com.powsybl.dynawaltz.models.hvdc; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.dynawaltz.models.VarConnection; import com.powsybl.dynawaltz.models.buses.EquipmentConnectionPoint; +import com.powsybl.dynawaltz.models.utils.SideUtils; +import com.powsybl.iidm.network.TwoSides; import java.util.List; import java.util.Objects; @@ -12,28 +13,28 @@ public final class DanglingSide { private final String prefix; - private final Side side; + private final TwoSides side; - public DanglingSide(String prefix, Side side) { + public DanglingSide(String prefix, TwoSides side) { this.prefix = Objects.requireNonNull(prefix); this.side = Objects.requireNonNull(side); } - boolean isDangling(Side side) { + boolean isDangling(TwoSides side) { return this.side == side; } public int getSideNumber() { - return side.getSideNumber(); + return side.getNum(); } - public void createMacroConnections(BiFunction> basicVarConnectionsSupplier, - BiConsumer>, Side> connectionCreator) { + public void createMacroConnections(BiFunction> basicVarConnectionsSupplier, + BiConsumer>, TwoSides> connectionCreator) { connectionCreator.accept(this::getVarConnectionsWith, side); - connectionCreator.accept(basicVarConnectionsSupplier, side.getOppositeSide()); + connectionCreator.accept(basicVarConnectionsSupplier, SideUtils.getOppositeSide(side)); } - private List getVarConnectionsWith(EquipmentConnectionPoint connected, Side side) { - return List.of(new VarConnection(prefix + side.getSideNumber(), connected.getTerminalVarName(side))); + private List getVarConnectionsWith(EquipmentConnectionPoint connected, TwoSides side) { + return List.of(new VarConnection(prefix + side.getNum(), connected.getTerminalVarName(side))); } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/DefaultHvdc.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/DefaultHvdc.java index 9bc165212..6e2b4a339 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/DefaultHvdc.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/DefaultHvdc.java @@ -8,7 +8,7 @@ package com.powsybl.dynawaltz.models.hvdc; import com.powsybl.dynawaltz.models.defaultmodels.AbstractDefaultModel; -import com.powsybl.dynawaltz.models.Side; +import com.powsybl.iidm.network.TwoSides; /** * @author Laurent Issertial {@literal } @@ -25,7 +25,7 @@ public String getName() { } @Override - public String getSwitchOffSignalEventVarName(Side side) { - return "@NAME@_state" + side.getSideNumber() + "_value"; + public String getSwitchOffSignalEventVarName(TwoSides side) { + return "@NAME@_state" + side.getNum() + "_value"; } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcModel.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcModel.java index 782d1af78..82104b67e 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcModel.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcModel.java @@ -8,12 +8,12 @@ package com.powsybl.dynawaltz.models.hvdc; import com.powsybl.dynawaltz.models.Model; -import com.powsybl.dynawaltz.models.Side; +import com.powsybl.iidm.network.TwoSides; /** * @author Laurent Issertial {@literal } */ public interface HvdcModel extends Model { - String getSwitchOffSignalEventVarName(Side side); + String getSwitchOffSignalEventVarName(TwoSides side); } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcP.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcP.java index 0baf4ed3d..22733d2a2 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcP.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcP.java @@ -7,8 +7,9 @@ */ package com.powsybl.dynawaltz.models.hvdc; -import com.powsybl.dynawaltz.models.Side; +import com.powsybl.dynawaltz.models.utils.SideUtils; import com.powsybl.iidm.network.HvdcLine; +import com.powsybl.iidm.network.TwoSides; /** * @author Laurent Issertial {@literal } @@ -20,7 +21,7 @@ public HvdcP(String dynamicModelId, HvdcLine hvdc, String parameterSetId, String } @Override - public String getSwitchOffSignalEventVarName(Side side) { - return "hvdc_switchOffSignal2" + side.getSideSuffix(); + public String getSwitchOffSignalEventVarName(TwoSides side) { + return "hvdc_switchOffSignal2" + SideUtils.getSideSuffix(side); } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcPDangling.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcPDangling.java index 39dea79a3..8c9042a8d 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcPDangling.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcPDangling.java @@ -9,9 +9,8 @@ import com.powsybl.commons.PowsyblException; import com.powsybl.dynawaltz.DynaWaltzContext; -import com.powsybl.dynawaltz.models.Side; -import com.powsybl.dynawaltz.models.utils.SideConverter; import com.powsybl.iidm.network.HvdcLine; +import com.powsybl.iidm.network.TwoSides; /** * @author Laurent Issertial {@literal } @@ -20,7 +19,7 @@ public class HvdcPDangling extends HvdcP { private final DanglingSide danglingSide; - public HvdcPDangling(String dynamicModelId, HvdcLine hvdc, String parameterSetId, String hvdcLib, Side danglingSide) { + public HvdcPDangling(String dynamicModelId, HvdcLine hvdc, String parameterSetId, String hvdcLib, TwoSides danglingSide) { super(dynamicModelId, hvdc, parameterSetId, hvdcLib); this.danglingSide = new DanglingSide(TERMINAL_PREFIX, danglingSide); } @@ -29,12 +28,12 @@ public HvdcPDangling(String dynamicModelId, HvdcLine hvdc, String parameterSetId public void createMacroConnections(DynaWaltzContext context) { danglingSide.createMacroConnections( this::getVarConnectionsWith, - (varCoSupplier, side) -> createTerminalMacroConnections(equipment.getConverterStation(SideConverter.convert(side)).getTerminal(), varCoSupplier, context, side) + (varCoSupplier, side) -> createTerminalMacroConnections(equipment.getConverterStation(side).getTerminal(), varCoSupplier, context, side) ); } @Override - public String getSwitchOffSignalEventVarName(Side side) { + public String getSwitchOffSignalEventVarName(TwoSides side) { if (danglingSide.isDangling(side)) { throw new PowsyblException(String.format("Equipment %s side %s is dangling and can't be disconnected with an event", getLib(), danglingSide.getSideNumber())); } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcVsc.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcVsc.java index 3102a17ee..515525cbc 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcVsc.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcVsc.java @@ -7,8 +7,8 @@ */ package com.powsybl.dynawaltz.models.hvdc; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.iidm.network.HvdcLine; +import com.powsybl.iidm.network.TwoSides; /** * @author Laurent Issertial {@literal } @@ -20,7 +20,7 @@ public HvdcVsc(String dynamicModelId, HvdcLine hvdc, String parameterSetId, Stri } @Override - public String getSwitchOffSignalEventVarName(Side side) { - return "hvdc_Conv" + side.getSideNumber() + "_switchOffSignal2"; + public String getSwitchOffSignalEventVarName(TwoSides side) { + return "hvdc_Conv" + side.getNum() + "_switchOffSignal2"; } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcVscDangling.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcVscDangling.java index 2eb39236e..f6773b32f 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcVscDangling.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcVscDangling.java @@ -9,8 +9,8 @@ import com.powsybl.commons.PowsyblException; import com.powsybl.dynawaltz.DynaWaltzContext; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.iidm.network.HvdcLine; +import com.powsybl.iidm.network.TwoSides; /** * @author Laurent Issertial {@literal } @@ -19,7 +19,7 @@ public class HvdcVscDangling extends HvdcVsc { private final DanglingSide danglingSide; - public HvdcVscDangling(String dynamicModelId, HvdcLine hvdc, String parameterSetId, String hvdcLib, Side danglingSide) { + public HvdcVscDangling(String dynamicModelId, HvdcLine hvdc, String parameterSetId, String hvdcLib, TwoSides danglingSide) { super(dynamicModelId, hvdc, parameterSetId, hvdcLib); this.danglingSide = new DanglingSide(TERMINAL_PREFIX, danglingSide); } @@ -33,7 +33,7 @@ public void createMacroConnections(DynaWaltzContext context) { } @Override - public String getSwitchOffSignalEventVarName(Side side) { + public String getSwitchOffSignalEventVarName(TwoSides side) { if (danglingSide.isDangling(side)) { throw new PowsyblException(String.format("Equipment %s side %s is dangling and can't be disconnected with an event", getLib(), danglingSide.getSideNumber())); } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/lines/DefaultLine.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/lines/DefaultLine.java index 4fd1caf6a..bd42d9628 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/lines/DefaultLine.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/lines/DefaultLine.java @@ -7,7 +7,8 @@ package com.powsybl.dynawaltz.models.lines; import com.powsybl.dynawaltz.models.defaultmodels.AbstractDefaultModel; -import com.powsybl.dynawaltz.models.Side; +import com.powsybl.dynawaltz.models.utils.SideUtils; +import com.powsybl.iidm.network.TwoSides; /** * @author Florian Dupuy {@literal } @@ -24,8 +25,8 @@ public String getName() { } @Override - public String getIVarName(Side side) { - return "@NAME@_i" + side.getSideSuffix(); + public String getIVarName(TwoSides side) { + return "@NAME@_i" + SideUtils.getSideSuffix(side); } @Override diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/lines/StandardLine.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/lines/StandardLine.java index 58ffcba6b..7747930f5 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/lines/StandardLine.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/lines/StandardLine.java @@ -9,11 +9,10 @@ import com.powsybl.dynawaltz.DynaWaltzContext; import com.powsybl.dynawaltz.models.AbstractEquipmentBlackBoxModel; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.dynawaltz.models.VarConnection; import com.powsybl.dynawaltz.models.buses.EquipmentConnectionPoint; -import com.powsybl.dynawaltz.models.utils.SideConverter; import com.powsybl.iidm.network.Line; +import com.powsybl.iidm.network.TwoSides; import java.util.List; @@ -26,17 +25,17 @@ public StandardLine(String dynamicModelId, Line line, String parameterSetId) { super(dynamicModelId, parameterSetId, line, "Line"); } - private List getVarConnectionsWith(EquipmentConnectionPoint connected, Side side) { + private List getVarConnectionsWith(EquipmentConnectionPoint connected, TwoSides side) { return List.of(new VarConnection(getTerminalVarName(side), connected.getTerminalVarName())); } - private String getTerminalVarName(Side side) { - return "line_terminal" + side.getSideNumber(); + private String getTerminalVarName(TwoSides side) { + return "line_terminal" + side.getNum(); } @Override public void createMacroConnections(DynaWaltzContext context) { - equipment.getTerminals().forEach(t -> createTerminalMacroConnections(t, this::getVarConnectionsWith, context, SideConverter.convert(equipment.getSide(t)))); + equipment.getTerminals().forEach(t -> createTerminalMacroConnections(t, this::getVarConnectionsWith, context, equipment.getSide(t))); } @Override @@ -55,7 +54,7 @@ public String getStateValueVarName() { } @Override - public String getIVarName(Side side) { + public String getIVarName(TwoSides side) { throw new UnsupportedOperationException("i variable not implemented in StandardLine dynawo's model"); } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/macroconnections/MacroConnector.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/macroconnections/MacroConnector.java index 626549eae..44b7b3255 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/macroconnections/MacroConnector.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/macroconnections/MacroConnector.java @@ -6,8 +6,9 @@ */ package com.powsybl.dynawaltz.models.macroconnections; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.dynawaltz.models.VarConnection; +import com.powsybl.dynawaltz.models.utils.SideUtils; +import com.powsybl.iidm.network.TwoSides; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; @@ -38,8 +39,8 @@ public static String createMacroConnectorId(String name1, String name2) { return MACRO_CONNECTOR_PREFIX + name1 + "-" + name2; } - public static String createMacroConnectorId(String name1, String name2, Side side) { - return MACRO_CONNECTOR_PREFIX + name1 + side.getSideSuffix() + "-" + name2; + public static String createMacroConnectorId(String name1, String name2, TwoSides side) { + return MACRO_CONNECTOR_PREFIX + name1 + SideUtils.getSideSuffix(side) + "-" + name2; } public static String createMacroConnectorId(String name1, String name2, String name1Suffix) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/transformers/DefaultTransformer.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/transformers/DefaultTransformer.java index 41a15eef2..d55b89f49 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/transformers/DefaultTransformer.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/transformers/DefaultTransformer.java @@ -8,8 +8,9 @@ package com.powsybl.dynawaltz.models.transformers; import com.powsybl.dynawaltz.models.defaultmodels.AbstractDefaultModel; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.dynawaltz.models.VarConnection; +import com.powsybl.dynawaltz.models.utils.SideUtils; +import com.powsybl.iidm.network.TwoSides; import java.util.List; @@ -60,8 +61,8 @@ public List getTapChangerBlockerVarConnections() { } @Override - public String getIVarName(Side side) { - return "@NAME@_i" + side.getSideSuffix(); + public String getIVarName(TwoSides side) { + return "@NAME@_i" + SideUtils.getSideSuffix(side); } @Override diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/transformers/TransformerFixedRatio.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/transformers/TransformerFixedRatio.java index 7055409ab..679d8a0f1 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/transformers/TransformerFixedRatio.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/transformers/TransformerFixedRatio.java @@ -9,10 +9,10 @@ import com.powsybl.dynawaltz.DynaWaltzContext; import com.powsybl.dynawaltz.models.AbstractEquipmentBlackBoxModel; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.dynawaltz.models.VarConnection; import com.powsybl.dynawaltz.models.buses.EquipmentConnectionPoint; -import com.powsybl.dynawaltz.models.utils.SideConverter; +import com.powsybl.dynawaltz.models.utils.SideUtils; +import com.powsybl.iidm.network.TwoSides; import com.powsybl.iidm.network.TwoWindingsTransformer; import java.util.List; @@ -28,17 +28,17 @@ public TransformerFixedRatio(String dynamicModelId, TwoWindingsTransformer trans super(dynamicModelId, parameterSetId, transformer, lib); } - private List getVarConnectionsWith(EquipmentConnectionPoint connected, Side side) { + private List getVarConnectionsWith(EquipmentConnectionPoint connected, TwoSides side) { return List.of(new VarConnection(getTerminalVarName(side), connected.getTerminalVarName())); } - private String getTerminalVarName(Side side) { - return "transformer_terminal" + side.getSideNumber(); + private String getTerminalVarName(TwoSides side) { + return "transformer_terminal" + side.getNum(); } @Override public void createMacroConnections(DynaWaltzContext context) { - equipment.getTerminals().forEach(t -> createTerminalMacroConnections(t, this::getVarConnectionsWith, context, SideConverter.convert(equipment.getSide(t)))); + equipment.getTerminals().forEach(t -> createTerminalMacroConnections(t, this::getVarConnectionsWith, context, equipment.getSide(t))); } @Override @@ -72,8 +72,8 @@ public List getTapChangerBlockerVarConnections() { } @Override - public String getIVarName(Side side) { - return "transformer_i" + side.getSideSuffix(); + public String getIVarName(TwoSides side) { + return "transformer_i" + SideUtils.getSideSuffix(side); } @Override diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/utils/SideConverter.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/utils/SideUtils.java similarity index 62% rename from dynawaltz/src/main/java/com/powsybl/dynawaltz/models/utils/SideConverter.java rename to dynawaltz/src/main/java/com/powsybl/dynawaltz/models/utils/SideUtils.java index b98214c53..671d700b7 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/utils/SideConverter.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/utils/SideUtils.java @@ -7,28 +7,28 @@ */ package com.powsybl.dynawaltz.models.utils; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.iidm.network.TwoSides; /** * @author Laurent Issertial {@literal } */ -public final class SideConverter { +public final class SideUtils { - private SideConverter() { + private SideUtils() { } - public static Side convert(TwoSides side) { + public static String getSideSuffix(TwoSides side) { return switch (side) { - case ONE -> Side.ONE; - case TWO -> Side.TWO; + case ONE -> "Side1"; + case TWO -> "Side2"; }; } - public static TwoSides convert(Side side) { + public static TwoSides getOppositeSide(TwoSides side) { return switch (side) { - case ONE -> TwoSides.ONE; - case TWO -> TwoSides.TWO; + case ONE -> TwoSides.TWO; + case TWO -> TwoSides.ONE; }; } + } diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/lines/StandardLineTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/lines/StandardLineTest.java index 9ec9353b2..7ba3f1ab7 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/lines/StandardLineTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/lines/StandardLineTest.java @@ -12,7 +12,6 @@ import com.powsybl.dynawaltz.DynaWaltzContext; import com.powsybl.dynawaltz.DynaWaltzParameters; import com.powsybl.dynawaltz.models.BlackBoxModel; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.dynawaltz.models.automatons.CurrentLimitAutomaton; import com.powsybl.iidm.network.*; import org.junit.jupiter.api.Test; @@ -42,7 +41,7 @@ void connectionToCurrentLimitAutomatonException() { List dynamicModels = new ArrayList<>(); dynamicModels.add(new StandardLine("BBM_l", l, "SL")); - dynamicModels.add(new CurrentLimitAutomaton("BBM_CLA", "CLA", l, Side.ONE, "CurrentLimitAutomaton")); + dynamicModels.add(new CurrentLimitAutomaton("BBM_CLA", "CLA", l, TwoSides.ONE, "CurrentLimitAutomaton")); DynamicSimulationParameters parameters = DynamicSimulationParameters.load(); DynaWaltzParameters dynawoParameters = DynaWaltzParameters.load(); String workingVariantId = network.getVariantManager().getWorkingVariantId(); diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/CurrentLimitModelXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/CurrentLimitModelXmlTest.java index 3d8970272..041a8c232 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/CurrentLimitModelXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/CurrentLimitModelXmlTest.java @@ -7,9 +7,9 @@ */ package com.powsybl.dynawaltz.xml; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.dynawaltz.models.automatons.CurrentLimitAutomaton; import com.powsybl.dynawaltz.models.transformers.TransformerFixedRatio; +import com.powsybl.iidm.network.TwoSides; import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; @@ -29,10 +29,10 @@ protected void setupNetwork() { @Override protected void addDynamicModels() { - dynamicModels.add(new CurrentLimitAutomaton("BBM_CLA_LINE", "cla", network.getLine("NHV1_NHV2_1"), Side.ONE, "CurrentLimitAutomaton")); - dynamicModels.add(new CurrentLimitAutomaton("BBM_CLA_TRANSFORMER", "cla", network.getTwoWindingsTransformer("NGEN_NHV1"), Side.TWO, "CurrentLimitAutomaton")); + dynamicModels.add(new CurrentLimitAutomaton("BBM_CLA_LINE", "cla", network.getLine("NHV1_NHV2_1"), TwoSides.ONE, "CurrentLimitAutomaton")); + dynamicModels.add(new CurrentLimitAutomaton("BBM_CLA_TRANSFORMER", "cla", network.getTwoWindingsTransformer("NGEN_NHV1"), TwoSides.TWO, "CurrentLimitAutomaton")); dynamicModels.add(new TransformerFixedRatio("BBM_TRANSFORMER", network.getTwoWindingsTransformer("NHV2_NLOAD"), "tf", "TransformerFixedRatio")); - dynamicModels.add(new CurrentLimitAutomaton("BBM_CLA_TRANSFORMER2", "cla", network.getTwoWindingsTransformer("NHV2_NLOAD"), Side.TWO, network.getLine("NHV1_NHV2_1"), "CurrentLimitAutomaton")); + dynamicModels.add(new CurrentLimitAutomaton("BBM_CLA_TRANSFORMER2", "cla", network.getTwoWindingsTransformer("NHV2_NLOAD"), TwoSides.TWO, network.getLine("NHV1_NHV2_1"), "CurrentLimitAutomaton")); } @Test diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/CurrentLimitTwoLevelsModelXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/CurrentLimitTwoLevelsModelXmlTest.java index 813835f8b..9afffaa5d 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/CurrentLimitTwoLevelsModelXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/CurrentLimitTwoLevelsModelXmlTest.java @@ -7,8 +7,8 @@ */ package com.powsybl.dynawaltz.xml; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.dynawaltz.models.automatons.CurrentLimitTwoLevelsAutomaton; +import com.powsybl.iidm.network.TwoSides; import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; @@ -28,7 +28,7 @@ protected void setupNetwork() { @Override protected void addDynamicModels() { - dynamicModels.add(new CurrentLimitTwoLevelsAutomaton("BBM_CLA_TWO_LEVELS", "cla", network.getLine("NHV1_NHV2_1"), Side.TWO, network.getLine("NHV1_NHV2_2"), Side.ONE, network.getTwoWindingsTransformer("NGEN_NHV1"), "CurrentLimitAutomatonTwoLevels")); + dynamicModels.add(new CurrentLimitTwoLevelsAutomaton("BBM_CLA_TWO_LEVELS", "cla", network.getLine("NHV1_NHV2_1"), TwoSides.TWO, network.getLine("NHV1_NHV2_2"), TwoSides.ONE, network.getTwoWindingsTransformer("NGEN_NHV1"), "CurrentLimitAutomatonTwoLevels")); } @Test diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DisconnectHvdcEventXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DisconnectHvdcEventXmlTest.java index c51021bc5..8cd7d3d02 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DisconnectHvdcEventXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DisconnectHvdcEventXmlTest.java @@ -8,13 +8,13 @@ package com.powsybl.dynawaltz.xml; import com.powsybl.dynawaltz.models.BlackBoxModel; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.dynawaltz.models.events.EventHvdcDisconnection; import com.powsybl.dynawaltz.models.hvdc.HvdcP; import com.powsybl.dynawaltz.models.hvdc.HvdcPDangling; import com.powsybl.dynawaltz.models.hvdc.HvdcVsc; import com.powsybl.dynawaltz.models.hvdc.HvdcVscDangling; import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.TwoSides; import com.powsybl.iidm.network.test.HvdcTestNetwork; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; @@ -77,10 +77,10 @@ private static Stream provideModels() { (Function) n -> new HvdcVsc(DYN_HVDC_NAME, n.getHvdcLine(HVDC_NAME), "hvdc", "HvdcVsc"), (Function) n -> new EventHvdcDisconnection(n.getHvdcLine(HVDC_NAME), 1, false, true)), Arguments.of("disconnect_hvdc_pv_dangling_dyd.xml", - (Function) n -> new HvdcPDangling(DYN_HVDC_NAME, n.getHvdcLine(HVDC_NAME), "hvdc", "HvdcPVDangling", Side.TWO), + (Function) n -> new HvdcPDangling(DYN_HVDC_NAME, n.getHvdcLine(HVDC_NAME), "hvdc", "HvdcPVDangling", TwoSides.TWO), (Function) n -> new EventHvdcDisconnection(n.getHvdcLine(HVDC_NAME), 1, true, false)), Arguments.of("disconnect_hvdc_vsc_dangling_dyd.xml", - (Function) n -> new HvdcVscDangling(DYN_HVDC_NAME, n.getHvdcLine(HVDC_NAME), "hvdc", "HvdcVSCDanglingUdc", Side.ONE), + (Function) n -> new HvdcVscDangling(DYN_HVDC_NAME, n.getHvdcLine(HVDC_NAME), "hvdc", "HvdcVSCDanglingUdc", TwoSides.ONE), (Function) n -> new EventHvdcDisconnection(n.getHvdcLine(HVDC_NAME), 1, false, true)) ); } diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DisconnectionExceptionXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DisconnectionExceptionXmlTest.java index 1e7b3cc0e..d90a149d7 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DisconnectionExceptionXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DisconnectionExceptionXmlTest.java @@ -9,11 +9,11 @@ import com.powsybl.commons.PowsyblException; import com.powsybl.dynawaltz.models.BlackBoxModel; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.dynawaltz.models.events.EventHvdcDisconnection; import com.powsybl.dynawaltz.models.hvdc.HvdcPDangling; import com.powsybl.dynawaltz.models.hvdc.HvdcVscDangling; import com.powsybl.iidm.network.HvdcLine; +import com.powsybl.iidm.network.TwoSides; import com.powsybl.iidm.network.test.HvdcTestNetwork; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; @@ -34,7 +34,7 @@ class DisconnectionExceptionXmlTest extends AbstractParametrizedDynamicModelXmlTest { @BeforeEach - void setup(String exception, Side side, BiFunction constructor) { + void setup(String exception, TwoSides side, BiFunction constructor) { setupNetwork(); addDynamicModels(side, constructor); } @@ -43,16 +43,16 @@ protected void setupNetwork() { network = HvdcTestNetwork.createVsc(); } - protected void addDynamicModels(Side side, BiFunction constructor) { + protected void addDynamicModels(TwoSides side, BiFunction constructor) { HvdcLine hvdc = network.getHvdcLine("L"); dynamicModels.add(constructor.apply(hvdc, side)); - boolean disconnectOrigin = Side.ONE == side; + boolean disconnectOrigin = TwoSides.ONE == side; eventModels.add(new EventHvdcDisconnection(hvdc, 1, disconnectOrigin, !disconnectOrigin)); } @ParameterizedTest(name = "{0}") @MethodSource("provideModels") - void disconnectionOnDanglingSide(String exception, Side side, BiFunction constructor) { + void disconnectionOnDanglingSide(String exception, TwoSides side, BiFunction constructor) { Exception e = assertThrows(PowsyblException.class, this::setupDynawaltzContext); assertEquals(exception, e.getMessage()); } @@ -60,11 +60,11 @@ void disconnectionOnDanglingSide(String exception, Side side, BiFunction provideModels() { return Stream.of( Arguments.of("Equipment HvdcPVDangling side 1 is dangling and can't be disconnected with an event", - Side.ONE, - (BiFunction) (hvdc, side) -> new HvdcPDangling("BBM_L", hvdc, "hvdc", "HvdcPVDangling", side)), + TwoSides.ONE, + (BiFunction) (hvdc, side) -> new HvdcPDangling("BBM_L", hvdc, "hvdc", "HvdcPVDangling", side)), Arguments.of("Equipment HvdcVSCDanglingUdc side 2 is dangling and can't be disconnected with an event", - Side.TWO, - (BiFunction) (hvdc, side) -> new HvdcVscDangling("BBM_L", hvdc, "hvdc", "HvdcVSCDanglingUdc", side)) + TwoSides.TWO, + (BiFunction) (hvdc, side) -> new HvdcVscDangling("BBM_L", hvdc, "hvdc", "HvdcVSCDanglingUdc", side)) ); } } diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DynaWaltzTestUtil.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DynaWaltzTestUtil.java index cc1f12c23..69cebbc11 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DynaWaltzTestUtil.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DynaWaltzTestUtil.java @@ -10,13 +10,12 @@ import com.powsybl.dynamicsimulation.Curve; import com.powsybl.dynawaltz.DynaWaltzCurve; import com.powsybl.dynawaltz.models.BlackBoxModel; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.dynawaltz.models.automatons.CurrentLimitAutomaton; import com.powsybl.dynawaltz.models.events.EventInjectionDisconnection; import com.powsybl.dynawaltz.models.events.EventQuadripoleDisconnection; import com.powsybl.dynawaltz.models.generators.GeneratorFictitious; -import com.powsybl.dynawaltz.models.generators.SynchronousGenerator; import com.powsybl.dynawaltz.models.generators.SynchronizedGenerator; +import com.powsybl.dynawaltz.models.generators.SynchronousGenerator; import com.powsybl.dynawaltz.models.lines.StandardLine; import com.powsybl.dynawaltz.models.loads.BaseLoad; import com.powsybl.dynawaltz.models.loads.LoadOneTransformer; @@ -107,7 +106,7 @@ void setup() { // Automatons network.getLineStream().filter(line -> line != standardLine) - .forEach(l -> dynamicModels.add(new CurrentLimitAutomaton("BBM_" + l.getId(), "CLA", l, Side.ONE, "CurrentLimitAutomaton"))); + .forEach(l -> dynamicModels.add(new CurrentLimitAutomaton("BBM_" + l.getId(), "CLA", l, TwoSides.ONE, "CurrentLimitAutomaton"))); } public void validate(String schemaDefinition, String expectedResourceName, Path xmlFile) throws SAXException, IOException { diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/HvdcXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/HvdcXmlTest.java index 1a017930a..8cf9a40c6 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/HvdcXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/HvdcXmlTest.java @@ -8,12 +8,12 @@ package com.powsybl.dynawaltz.xml; import com.powsybl.dynawaltz.models.BlackBoxModel; -import com.powsybl.dynawaltz.models.Side; import com.powsybl.dynawaltz.models.hvdc.HvdcP; import com.powsybl.dynawaltz.models.hvdc.HvdcPDangling; import com.powsybl.dynawaltz.models.hvdc.HvdcVsc; import com.powsybl.dynawaltz.models.hvdc.HvdcVscDangling; import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.TwoSides; import com.powsybl.iidm.network.test.HvdcTestNetwork; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; @@ -62,8 +62,8 @@ private static Stream provideHvdc() { return Stream.of( Arguments.of("hvdc_p_dyd.xml", (Function) n -> new HvdcP(DYN_NAME, n.getHvdcLine(HVDC_NAME), "hv", "HvdcPV")), Arguments.of("hvdc_vsc_dyd.xml", (Function) n -> new HvdcVsc(DYN_NAME, n.getHvdcLine(HVDC_NAME), "hv", "HvdcVSC")), - Arguments.of("hvdc_p_dangling_dyd.xml", (Function) n -> new HvdcPDangling(DYN_NAME, n.getHvdcLine(HVDC_NAME), "hv", "HvdcPVDangling", Side.ONE)), - Arguments.of("hvdc_vsc_dangling_dyd.xml", (Function) n -> new HvdcVscDangling(DYN_NAME, n.getHvdcLine(HVDC_NAME), "hv", "HvdcVSCDanglingP", Side.TWO)) + Arguments.of("hvdc_p_dangling_dyd.xml", (Function) n -> new HvdcPDangling(DYN_NAME, n.getHvdcLine(HVDC_NAME), "hv", "HvdcPVDangling", TwoSides.ONE)), + Arguments.of("hvdc_vsc_dangling_dyd.xml", (Function) n -> new HvdcVscDangling(DYN_NAME, n.getHvdcLine(HVDC_NAME), "hv", "HvdcVSCDanglingP", TwoSides.TWO)) ); } }