Skip to content

Commit

Permalink
Merge branch 'main' into remove_iidm_converter_api
Browse files Browse the repository at this point in the history
Signed-off-by: VEDELAGO MIORA <miora.ralambotiana@rte-france.com>
  • Loading branch information
miovd committed Nov 3, 2022
2 parents fb89c75 + 7012399 commit de7b9ca
Show file tree
Hide file tree
Showing 19 changed files with 554 additions and 244 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,7 @@ public interface Connectable<I extends Connectable<I>> extends Identifiable<I> {
List<? extends Terminal> getTerminals();

/**
* Remove the connectable from the voltage level.
*
* @param removeDanglingSwitches if true, also remove dangling switches in addition to isolated nodes
* Remove the connectable from the voltage level (dangling switches are kept).
*/
void remove(boolean removeDanglingSwitches);

/**
* Remove the connectable from the voltage level and keep dangling switches.
*/
default void remove() {
remove(false);
}
void remove();
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ public NetworkImpl getNetwork() {
}

@Override
public void remove(boolean removeDanglingSwitches) {
public void remove() {
NetworkImpl network = getNetwork();

network.getListeners().notifyBeforeRemoval(this);

network.getIndex().remove(this);
for (TerminalExt terminal : terminals) {
VoltageLevelExt vl = terminal.getVoltageLevel();
vl.detach(terminal, removeDanglingSwitches);
vl.detach(terminal);
}

network.getListeners().notifyAfterRemoval(id);
Expand Down Expand Up @@ -170,7 +170,7 @@ private void attachTerminal(TerminalExt oldTerminal, String oldConnectionInfo, V
voltageLevel.attach(terminalExt, false);

// then we can detach the old terminal, as we now know that the new terminal is valid
oldTerminal.getVoltageLevel().detach(oldTerminal, false);
oldTerminal.getVoltageLevel().detach(oldTerminal);

// replace the old terminal by the new terminal in the connectable
int iSide = terminals.indexOf(oldTerminal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ public Optional<? extends HvdcConverterStation<?>> getOtherConverterStation() {
}

@Override
public void remove(boolean removeDanglingSwitches) {
public void remove() {
if (hvdcLine != null) {
throw new ValidationException(this, "Impossible to remove this converter station (still attached to '" + hvdcLine.getId() + "')");
}
super.remove(removeDanglingSwitches);
super.remove();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ public void attach(final TerminalExt terminal, boolean test) {
}

@Override
public void detach(final TerminalExt terminal, boolean removeDanglingSwitches) {
public void detach(final TerminalExt terminal) {
if (!(terminal instanceof BusTerminal)) {
throw new IllegalArgumentException("Incorrect terminal type");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void setConnectableBus(String busId) {
// Assert that the new bus exists
vl.getBus(busId, true);

vl.detach(BusTerminal.this, false);
vl.detach(BusTerminal.this);
int variantIndex = network.get().getVariantIndex();
String oldValue = BusTerminal.this.connectableBusId.set(variantIndex, busId);
vl.attach(BusTerminal.this, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ public void removeInternalConnections(int node1, int node2) {
for (int ic : internalConnectionsToBeRemoved) {
graph.removeEdge(ic);
}
graph.removeIsolatedVertices(false);
graph.removeIsolatedVertices();
invalidateCache();
}

Expand Down Expand Up @@ -882,7 +882,7 @@ public void removeSwitch(String switchId) {
+ "' not found in voltage level '" + id + "'");
}
graph.removeEdge(e);
graph.removeIsolatedVertices(false);
graph.removeIsolatedVertices();
}

@Override
Expand Down Expand Up @@ -1131,7 +1131,7 @@ public void attach(TerminalExt terminal, boolean test) {
}

@Override
public void detach(TerminalExt terminal, boolean removeDanglingSwitches) {
public void detach(TerminalExt terminal) {
if (!(terminal instanceof NodeTerminal)) {
throw new IllegalArgumentException("Incorrect terminal type");
}
Expand All @@ -1145,7 +1145,7 @@ public void detach(TerminalExt terminal, boolean removeDanglingSwitches) {
// remove the link terminal -> voltage level
terminal.setVoltageLevel(null);

graph.removeIsolatedVertices(removeDanglingSwitches);
graph.removeIsolatedVertices();
}

private static boolean isBusbarSection(Terminal t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ interface BusViewExt extends BusView {
/**
* Detach an equipment from the topology.
*/
void detach(TerminalExt terminal, boolean removeDanglingSwitches);
void detach(TerminalExt terminal);

boolean connect(TerminalExt terminal);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public final List<? extends Terminal> getTerminals() {
}

@Override
public final void remove(boolean removeDanglingSwitches) {
public final void remove() {
throw MergingView.createNotImplementedException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ public boolean removeProperty(String key) {
// Not implemented methods -------
// -------------------------------
@Override
public void remove(boolean removeDanglingSwitches) {
public void remove() {
throw MergingView.createNotImplementedException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public double getRatedU0() {
// Not implemented methods -------
// -------------------------------
@Override
public void remove(boolean removeDanglingSwitches) {
public void remove() {
throw MergingView.createNotImplementedException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,24 @@ static void notFoundLineReport(Reporter reporter, String lineId) {
.build());
}

static void notFoundConnectableReport(Reporter reporter, String connectableId) {
reporter.report(Report.builder()
.withKey("connectableNotFound")
.withDefaultMessage("Connectable ${connectableId} is not found")
.withValue("connectableId", connectableId)
.withSeverity(TypedValue.ERROR_SEVERITY)
.build());
}

static void removeFeederBayBusbarSectionReport(Reporter reporter, String busbarSectionConnectableId) {
reporter.report(Report.builder()
.withKey("removeBayBusbarSectionConnectable")
.withDefaultMessage("Cannot remove feeder bay for connectable ${busbarSectionConnectableId}, as it is a busbarSection")
.withValue("connectableId", busbarSectionConnectableId)
.withSeverity(TypedValue.ERROR_SEVERITY)
.build());
}

static void noVoltageLevelInCommonReport(Reporter reporter, String line1Id, String line2Id) {
reporter.report(Report.builder()
.withKey("noVoltageLevelInCommon")
Expand Down Expand Up @@ -268,6 +286,45 @@ static void createdNewSymmetricalTopology(Reporter reporter, String voltageLevel
.build());
}

public static void removedSwitchReport(Reporter reporter, String switchId) {
reporter.report(Report.builder()
.withKey("SwitchRemoved")
.withDefaultMessage("Switch ${switchId} removed")
.withValue("switchId", switchId)
.withSeverity(TypedValue.INFO_SEVERITY)
.build());
}

public static void removedInternalConnectionReport(Reporter reporter, int node1, int node2) {
reporter.report(Report.builder()
.withKey("InternalConnectionRemoved")
.withDefaultMessage("Internal connection between ${node1} and ${node2} removed")
.withValue("node1", node1)
.withValue("node2", node2)
.withSeverity(TypedValue.INFO_SEVERITY)
.build());
}

public static void removedConnectableReport(Reporter reporter, String connectableId) {
reporter.report(Report.builder()
.withKey("ConnectableRemoved")
.withDefaultMessage("Connectable ${connectableId} removed")
.withValue("connectableId", connectableId)
.withSeverity(TypedValue.INFO_SEVERITY)
.build());
}

public static void removeFeederBayAborted(Reporter reporter, String connectableId, int node, String otherConnectableId) {
reporter.report(Report.builder()
.withKey("RemoveFeederBayAborted")
.withDefaultMessage("Remove feeder bay of ${connectableId} cannot go further node ${node}, as it is connected to ${otherConnectableId}")
.withValue("connectableId", connectableId)
.withValue("node", node)
.withValue("otherConnectableId", otherConnectableId)
.withSeverity(TypedValue.INFO_SEVERITY)
.build());
}

private ModificationReports() {
}
}
Loading

0 comments on commit de7b9ca

Please sign in to comment.