7
7
package org .gridsuite .network .map .dto .definition .extension ;
8
8
9
9
import com .powsybl .iidm .network .*;
10
- import com .powsybl .iidm .network .extensions .BusbarSectionPosition ;
11
10
import com .powsybl .math .graph .TraversalType ;
12
11
import com .powsybl .math .graph .TraverseResult ;
13
12
@@ -33,7 +32,6 @@ public static String findBusbarSectionId(Terminal terminal) {
33
32
}
34
33
35
34
public static BusbarSectionResult getBusbarSectionResult (Terminal terminal ) {
36
- VoltageLevel .NodeBreakerView view = terminal .getVoltageLevel ().getNodeBreakerView ();
37
35
int startNode = terminal .getNodeBreakerView ().getNode ();
38
36
List <BusbarSectionResult > allResults = searchAllBusbars (terminal .getVoltageLevel (), startNode );
39
37
if (allResults .isEmpty ()) {
@@ -48,12 +46,12 @@ private static BusbarSectionResult selectBestBusbar(List<BusbarSectionResult> re
48
46
return withoutSwitch .stream ().min (Comparator .comparingInt (BusbarSectionResult ::depth )
49
47
.thenComparing (BusbarSectionResult ::busbarSectionId )).orElse (null );
50
48
}
51
- List <BusbarSectionResult > withClosedSwitch = results .stream ().filter (r -> r .lastSwitch () != null && ! r . lastSwitch (). isOpen () ).toList ();
49
+ List <BusbarSectionResult > withClosedSwitch = results .stream ().filter (r -> r .allSwitchesClosed ).toList ();
52
50
if (!withClosedSwitch .isEmpty ()) {
53
51
return withClosedSwitch .stream ().min (Comparator .comparingInt (BusbarSectionResult ::depth )
54
52
.thenComparing (BusbarSectionResult ::busbarSectionId )).orElse (null );
55
53
}
56
- List <BusbarSectionResult > withOpenSwitch = results .stream ().filter (r -> r .lastSwitch () != null && r .lastSwitch ().isOpen ()).toList ();
54
+ List <BusbarSectionResult > withOpenSwitch = results .stream ().filter (r -> r .lastSwitch () != null && ! r .lastSwitch ().isOpen ()).toList ();
57
55
if (!withOpenSwitch .isEmpty ()) {
58
56
return withOpenSwitch .stream ().min (Comparator .comparingInt (BusbarSectionResult ::depth )
59
57
.thenComparing (BusbarSectionResult ::busbarSectionId )).orElse (null );
@@ -70,21 +68,25 @@ private static List<BusbarSectionResult> searchAllBusbars(VoltageLevel voltageLe
70
68
SwitchInfo lastSwitch = null ;
71
69
@ Override
72
70
public TraverseResult traverse (Terminal terminal , boolean connected ) {
73
- if (terminal .getVoltageLevel () != voltageLevel )
71
+ if (terminal .getVoltageLevel () != voltageLevel ) {
74
72
return TraverseResult .TERMINATE_PATH ;
73
+ }
75
74
76
75
if (terminal .getConnectable () instanceof BusbarSection busbarSection ) {
77
- results .add (new BusbarSectionResult (busbarSection .getId (), currentDepth , lastSwitch ,allSwitchesClosed ));
76
+ results .add (new BusbarSectionResult (busbarSection .getId (), currentDepth , lastSwitch , allSwitchesClosed ));
78
77
return TraverseResult .TERMINATE_PATH ;
79
78
}
80
79
return TraverseResult .CONTINUE ;
81
80
}
82
81
83
82
@ Override
84
83
public TraverseResult traverse (Switch aSwitch ) {
84
+ if (aSwitch .getVoltageLevel () != voltageLevel ) {
85
+ return TraverseResult .TERMINATE_PATH ;
86
+ }
85
87
currentDepth ++;
86
88
lastSwitch = new SwitchInfo (aSwitch .getId (), aSwitch .isOpen ());
87
- if (! aSwitch .isOpen ()) {
89
+ if (aSwitch .isOpen ()) {
88
90
allSwitchesClosed = false ;
89
91
}
90
92
return TraverseResult .CONTINUE ;
0 commit comments