powsybl / powsybl-diagram

SVG diagrams generation: single-line substation diagrams and network graph diagrams
Mozilla Public License 2.0
73 stars 13 forks source link

Fix HighlightLineState feeder bug #251

Open flo-dup opened 3 years ago

flo-dup commented 3 years ago
yasstec commented 2 years ago

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 :

image

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())); }

yasstec commented 2 years ago

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;
    }