Skip to content

Commit 8e4170a

Browse files
authored
fix isRetrievedBusbarSections computation (#280)
Signed-off-by: Rehili Ghazwa <[email protected]>
1 parent 6c7787c commit 8e4170a

10 files changed

+56
-24
lines changed

src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private static VoltageLevelTopologyInfos getTopologyInfos(VoltageLevel voltageLe
5858
int sectionIndex = extension.getSectionIndex();
5959
maxBusbarIndex = Math.max(maxBusbarIndex, busbarIndex);
6060
maxSectionIndex = Math.max(maxSectionIndex, sectionIndex);
61-
nbSectionsPerBusbar.merge(busbarIndex, sectionIndex, Math::max);
61+
nbSectionsPerBusbar.merge(busbarIndex, 1, Integer::sum);
6262
busbarSectionInfos.add(BusBarSectionFormInfos.builder()
6363
.id(bbs.getId())
6464
.vertPos(sectionIndex)
@@ -73,10 +73,9 @@ private static VoltageLevelTopologyInfos getTopologyInfos(VoltageLevel voltageLe
7373
voltageLevelTopologyInfos.setBusbarSections(busbarSectionInfos);
7474
voltageLevelTopologyInfos.setBusbarSectionPositionFound(true);
7575

76-
int finalMaxSectionIndex = maxSectionIndex;
77-
boolean isSymmetrical = nbSectionsPerBusbar.values()
78-
.stream()
79-
.allMatch(v -> v == finalMaxSectionIndex);
76+
boolean isSymmetrical = maxBusbarIndex == 1 ||
77+
nbSectionsPerBusbar.values().stream().distinct().count() == 1
78+
&& nbSectionsPerBusbar.values().stream().findFirst().orElse(0).equals(maxSectionIndex);
8079

8180
if (isSymmetrical) {
8281
voltageLevelTopologyInfos.setBusbarCount(maxBusbarIndex);

src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,16 +1062,27 @@ void setUp() {
10621062
.withSectionIndex(2)
10631063
.add();
10641064
vlgen5.getNodeBreakerView().newBusbarSection()
1065-
.setId("NGEN5_2")
1066-
.setName("NGEN5_2")
1065+
.setId("NGEN5_2_1")
1066+
.setName("NGEN5_2_1")
10671067
.setNode(1)
10681068
.add();
10691069
vlgen5.getNodeBreakerView()
1070-
.getBusbarSection("NGEN5_2")
1070+
.getBusbarSection("NGEN5_2_1")
10711071
.newExtension(BusbarSectionPositionAdder.class)
10721072
.withBusbarIndex(2)
10731073
.withSectionIndex(1)
10741074
.add();
1075+
vlgen5.getNodeBreakerView().newBusbarSection()
1076+
.setId("NGEN5_2_2")
1077+
.setName("NGEN5_2_2")
1078+
.setNode(0)
1079+
.add();
1080+
vlgen5.getNodeBreakerView()
1081+
.getBusbarSection("NGEN5_2_2")
1082+
.newExtension(BusbarSectionPositionAdder.class)
1083+
.withBusbarIndex(2)
1084+
.withSectionIndex(2)
1085+
.add();
10751086

10761087
// Create a connected shunt compensator on a NODE_BREAKER voltage level
10771088
ShuntCompensator shunt4 = vlgen4.newShuntCompensator().setId("SHUNT_VLNB")

src/test/resources/all-data-in-variant.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,8 +2367,13 @@
23672367
"voltageLevelId": "VLGEN5"
23682368
},
23692369
{
2370-
"id": "NGEN5_2",
2371-
"name": "NGEN5_2",
2370+
"id": "NGEN5_2_1",
2371+
"name": "NGEN5_2_1",
2372+
"voltageLevelId": "VLGEN5"
2373+
},
2374+
{
2375+
"id": "NGEN5_2_2",
2376+
"name": "NGEN5_2_2",
23722377
"voltageLevelId": "VLGEN5"
23732378
}
23742379
]

src/test/resources/all-data.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,8 +2355,13 @@
23552355
"voltageLevelId": "VLGEN5"
23562356
},
23572357
{
2358-
"id": "NGEN5_2",
2359-
"name": "NGEN5_2",
2358+
"id": "NGEN5_2_1",
2359+
"name": "NGEN5_2_1",
2360+
"voltageLevelId": "VLGEN5"
2361+
},
2362+
{
2363+
"id": "NGEN5_2_2",
2364+
"name": "NGEN5_2_2",
23602365
"voltageLevelId": "VLGEN5"
23612366
}
23622367
]

src/test/resources/bus-bar-section-form-data.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@
1212
"horizPos": 2
1313
},
1414
{
15-
"id": "NGEN5_2",
16-
"name": "NGEN5_2",
15+
"id": "NGEN5_2_1",
16+
"name": "NGEN5_2_1",
1717
"vertPos": 2,
1818
"horizPos": 1
19+
},
20+
{
21+
"id": "NGEN5_2_2",
22+
"name": "NGEN5_2_2",
23+
"vertPos": 2,
24+
"horizPos": 2
1925
}
2026
]

src/test/resources/bus-bar-section-list-data.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
"name": "NGEN5"
99
},
1010
{
11-
"id": "NGEN5_2",
12-
"name": "NGEN5_2"
11+
"id": "NGEN5_2_1",
12+
"name": "NGEN5_2_1"
13+
},
14+
{
15+
"id": "NGEN5_2_2",
16+
"name": "NGEN5_2_2"
1317
}
1418
]

src/test/resources/bus-bar-section-operating-status-data.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
"operatingStatus": "FORCED_OUTAGE"
1010
},
1111
{
12-
"id": "NGEN5_2",
13-
"name": "NGEN5_2"
12+
"id": "NGEN5_2_1",
13+
"name": "NGEN5_2_1"
14+
},
15+
{
16+
"id": "NGEN5_2_2",
17+
"name": "NGEN5_2_2"
1418
}
1519
]

src/test/resources/substations-form-data.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@
100100
"nominalV": 24.0,
101101
"busbarCount": 1,
102102
"sectionCount": 2,
103-
"switchKinds": [
104-
"DISCONNECTOR"
105-
],
103+
"switchKinds": ["DISCONNECTOR"],
106104
"isRetrievedBusbarSections": true,
107105
"isBusbarSectionPositionFound": true,
108106
"busBarSectionInfos" : {
@@ -133,7 +131,7 @@
133131
"isBusbarSectionPositionFound": true,
134132
"busBarSectionInfos" : {
135133
"1" : [ "NGEN5"],
136-
"2" : [ "NGEN5_2"]
134+
"2" : [ "NGEN5_2_1", "NGEN5_2_2"]
137135
}
138136
}
139137
]

src/test/resources/voltage-level-non-symmetrical-busbars-form-data.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
"isBusbarSectionPositionFound": true,
1717
"busBarSectionInfos" : {
1818
"1" : [ "NGEN5"],
19-
"2" : [ "NGEN5_2"]
19+
"2" : [ "NGEN5_2_1","NGEN5_2_2"]
2020
}
2121
}

src/test/resources/voltage-levels-form-data.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"isBusbarSectionPositionFound": true,
8787
"busBarSectionInfos" : {
8888
"1" : [ "NGEN5"],
89-
"2" : [ "NGEN5_2"]
89+
"2" : [ "NGEN5_2_1", "NGEN5_2_2" ]
9090
}
9191
},
9292
{

0 commit comments

Comments
 (0)