powsybl-diagram
powsybl-diagram copied to clipboard
Fix HighlightLineState feeder bug
-
Do you want to request a feature or report a bug? Bug
-
What is the current behavior? HighlightLineState only applies to the FeederPrimaryBlock, it stops at its fictitious node
-
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem Use NominalVoltageDiagramStyleProvider or TopologicalStyleProvider with LayoutParameters::highlightLineState set to true (default value).
-
What is the expected behavior? Style applied from feeder to the first component
Thanks for reporting this issue , I have the same need to apply HighlightLineState to the all wires between feeder node and the breaker node .
Like this :
As a workaround that works perfect, is to apply a custom class in the NominalVoltageDiagramStyleProvider on the edges between feeder node and the breaked node, thoses edges selected using two criteria :
private boolean edgeHasAdjacentDisconnector(Edge edge) { boolean node1HasAdjacentDisconnector = edge.getNode1().getAdjacentNodes().stream().anyMatch(n -> DISCONNECTOR.equals(n.getComponentType())); boolean node2HasAdjacentDisconnector = edge.getNode2().getAdjacentNodes().stream().anyMatch(n -> DISCONNECTOR.equals(n.getComponentType())); return node1HasAdjacentDisconnector || node2HasAdjacentDisconnector; }
private boolean edgeConnectedToBusbarSection(Edge edge) { return edge.getNodes().stream().anyMatch(n -> BUSBAR_SECTION.equals(n.getComponentType())); }
I've improved the criteria to define wire and node between the Breaker and Feeder node to to be more generic (we had a bug in a particular case of SAB Disconnector between the feeder node and the breaker node) :
At the CustomVoltageDiagramStyleProvider.java
:
private boolean nodeIsNotBreaker(Node node) {
return !ComponentTypeEnum.BREAKER.name().equals(node.getComponentType());
}
private boolean edgeHasAdjacentBusbarSection(Edge edge) {
final Node node1 = edge.getNode1();
final Node node2 = edge.getNode2();
List<Node> allAdjacentNodes = ListUtils.union(node1.getAdjacentNodes(), node2.getAdjacentNodes());
for (Node node : allAdjacentNodes) {
if (node.getAdjacentNodes().stream().anyMatch(n -> BUSBAR_SECTION.equals(n.getComponentType()))) {
return true;
}
}
return false;
}
private boolean nodeHasAdjacentBusbarSection(Node node) {
List<Node> adjacentNodes = node.getAdjacentNodes();
for (Node elm : adjacentNodes) {
if (BUSBAR_SECTION.equals(elm.getComponentType()) || elm.getAdjacentNodes().stream().anyMatch(n -> BUSBAR_SECTION.equals(n.getComponentType()))) {
return true;
}
}
return false;
}