@@ -41,21 +41,22 @@ private void createVoltageLevel() {
41
41
var busbarIndex = new AtomicInteger (1 );
42
42
voltageLevel .getBays ().stream ()
43
43
.filter (GenericBay ::isBusbar )
44
- .forEach (busbar -> processBusbarNode (busbar , busbarIndex ));
44
+ .forEach (busbar -> processBusbarNode (busbar , busbarIndex . getAndIncrement () ));
45
45
46
46
// Next process the other bays.
47
+ var bayIndex = new AtomicInteger (1 );
47
48
voltageLevel .getBays ().stream ()
48
49
.filter (bay -> !bay .isBusbar ())
49
- .forEach (this :: processBayNode );
50
+ .forEach (bay -> processBayNode ( bay , bayIndex . getAndIncrement ()) );
50
51
}
51
52
52
53
private void processBusbarNode (GenericBay busbar ,
53
- AtomicInteger busbarIndex ) {
54
+ int busbarIndex ) {
54
55
busbar .getConnectivityNodes ()
55
56
.stream ().findFirst ()
56
57
.ifPresent (connectivityNode ->
57
58
addNode (connectivityNode .getPathName (),
58
- createBusbarNode (busbar .getFullName (), busbarIndex . getAndIncrement () , 1 )));
59
+ createBusbarNode (busbar .getFullName (), busbarIndex , 1 )));
59
60
}
60
61
61
62
public BusNode createBusbarNode (String id , int busbarIndex , int sectionIndex ) {
@@ -64,9 +65,10 @@ public BusNode createBusbarNode(String id, int busbarIndex, int sectionIndex) {
64
65
return busNode ;
65
66
}
66
67
67
- private void processBayNode (GenericBay bay ) {
68
+ private void processBayNode (GenericBay bay , int bayIndex ) {
68
69
bay .getConnectivityNodes ().forEach (this ::createConnectivityNode );
69
- bay .getConductingEquipments ().forEach (this ::processConductingEquipment );
70
+ bay .getConductingEquipments ().forEach (conductingEquipment ->
71
+ processConductingEquipment (conductingEquipment , bayIndex ));
70
72
}
71
73
72
74
private void createConnectivityNode (GenericConnectivityNode connectivityNode ) {
@@ -94,36 +96,39 @@ private Optional<GenericPowerTransformer> getPowerTransformer(String pathName) {
94
96
return Optional .empty ();
95
97
}
96
98
97
- private void processConductingEquipment (GenericConductingEquipment conductingEquipment ) {
99
+ private void processConductingEquipment (GenericConductingEquipment conductingEquipment , int order ) {
98
100
var terminals = conductingEquipment .getTerminals ();
99
101
var fullName = conductingEquipment .getFullName ();
100
- var node = createSwitchNode (fullName );
102
+ var node = createSwitchNode (fullName , order );
101
103
102
104
if (!terminals .isEmpty ()) {
103
- Node node1 = terminalToNode (terminals .get (0 ));
105
+ Node node1 = terminalToNode (terminals .get (0 ), order );
104
106
Node node2 = null ;
105
107
var termNb = terminals .size ();
106
108
if (termNb == 1 ) {
107
- node2 = createLoad (fullName + "/Grounded" );
109
+ node2 = createLoad (fullName + "/Grounded" , order );
108
110
} else if (termNb == 2 ) {
109
- node2 = terminalToNode (terminals .get (1 ));
111
+ node2 = terminalToNode (terminals .get (1 ), order );
110
112
}
111
113
connectNode (node , node1 );
112
114
connectNode (node , node2 );
113
115
}
114
116
}
115
117
116
- private Node terminalToNode (GenericTerminal terminal ) {
118
+ private Node terminalToNode (GenericTerminal terminal , int order ) {
117
119
var pathName = terminal .getConnectivityNode ();
118
120
if (pathName != null ) {
119
121
return getNodeByPath (pathName );
120
122
}
121
- return createLoad (terminal .getCNodeName ());
123
+ return createLoad (terminal .getCNodeName (), order );
122
124
}
123
125
124
- private SwitchNode createSwitchNode (String id ) {
125
- return NodeFactory .createSwitchNode (getGraph (), id , id , SwitchNode .SwitchKind .BREAKER .name (),
126
+ private SwitchNode createSwitchNode (String id , int order ) {
127
+ var switchNode = NodeFactory .createSwitchNode (getGraph (), id , id , SwitchNode .SwitchKind .BREAKER .name (),
126
128
false , SwitchNode .SwitchKind .BREAKER , false );
129
+ switchNode .setOrder (order );
130
+ switchNode .setDirection (Direction .TOP );
131
+ return switchNode ;
127
132
}
128
133
129
134
private void connectNode (Node node1 , Node node2 ) {
@@ -134,9 +139,9 @@ private FictitiousNode createFictitiousNode(String id) {
134
139
return NodeFactory .createFictitiousNode (getGraph (), id , id , id , ComponentTypeName .LINE );
135
140
}
136
141
137
- private FeederNode createLoad (String id ) {
142
+ private FeederNode createLoad (String id , int order ) {
138
143
FeederNode fn = NodeFactory .createLoad (getGraph (), id , id );
139
- commonFeederSetting (fn , id , 0 , null );
144
+ commonFeederSetting (fn , id , order , Direction . TOP );
140
145
return fn ;
141
146
}
142
147
0 commit comments