Skip to content

Commit

Permalink
Traverser: get switches and internal connections directly from node (#…
Browse files Browse the repository at this point in the history
…343)

* NodeBreakerTraverser: get switches directly from node
* NodeBreakerTraverser: get internal connections directly from node

Signed-off-by: Florian Dupuy <[email protected]>
  • Loading branch information
flo-dup authored Sep 16, 2021
1 parent 07776a0 commit b7bcfe7
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private static boolean isEquivalentToStopAfterSwitch(Switch sw, int nodeAfter) {
if (endNodeAfter) { // check that there isn't another (closed) switch or internal connection at node after
VoltageLevel.NodeBreakerView nbv = sw.getVoltageLevel().getNodeBreakerView();
return noInternalConnectionAtNode(nodeAfter, nbv)
&& nbv.getSwitchStream().noneMatch(s -> s != sw && switchAtNode(s, nodeAfter, nbv) && !s.isOpen());
&& nbv.getSwitchStream(nodeAfter).noneMatch(s -> s != sw && !s.isOpen());
}
}
return false;
Expand All @@ -112,15 +112,11 @@ private boolean traverserStopsAtOtherStartEdges(Switch aSwitch, int initNode) {
}

private static boolean allOtherSwitchesOpenOrOpenable(Switch aSwitch, int node, VoltageLevel.NodeBreakerView nbv) {
return nbv.getSwitchStream().filter(s -> s != aSwitch && switchAtNode(s, node, nbv)).allMatch(NodeBreakerTraverser::isOpenOrOpenable);
return nbv.getSwitchStream(node).filter(s -> s != aSwitch).allMatch(NodeBreakerTraverser::isOpenOrOpenable);
}

private static boolean noInternalConnectionAtNode(int node, VoltageLevel.NodeBreakerView nbv) {
return nbv.getInternalConnectionStream().noneMatch(ic -> ic.getNode1() == node || ic.getNode2() == node);
}

private static boolean switchAtNode(Switch s, int nodeAfter, VoltageLevel.NodeBreakerView nbv) {
return s != null && (nbv.getNode1(s.getId()) == nodeAfter || nbv.getNode2(s.getId()) == nodeAfter);
return nbv.getNodeInternalConnectedToStream(node).findFirst().isEmpty();
}

private static boolean isOpenable(Switch aSwitch) {
Expand Down

0 comments on commit b7bcfe7

Please sign in to comment.