Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,19 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete

private static HvdcMapInfos toMapInfos(Identifiable<?> identifiable) {
HvdcLine hvdcLine = (HvdcLine) identifiable;
Terminal terminal1 = hvdcLine.getConverterStation1().getTerminal();
Terminal terminal2 = hvdcLine.getConverterStation2().getTerminal();
return HvdcMapInfos.builder()
.id(hvdcLine.getId())
.name(hvdcLine.getOptionalName().orElse(null))
.voltageLevelId1(hvdcLine.getConverterStation1().getTerminal().getVoltageLevel().getId())
.voltageLevelId2(hvdcLine.getConverterStation2().getTerminal().getVoltageLevel().getId())
.terminal1Connected(hvdcLine.getConverterStation1().getTerminal().isConnected())
.terminal2Connected(hvdcLine.getConverterStation2().getTerminal().isConnected())
.p1(nullIfNan(hvdcLine.getConverterStation1().getTerminal().getP()))
.p2(nullIfNan(hvdcLine.getConverterStation2().getTerminal().getP()))
.voltageLevelId1(terminal1.getVoltageLevel().getId())
.voltageLevelId2(terminal2.getVoltageLevel().getId())
.terminal1Connected(terminal1.isConnected())
.terminal2Connected(terminal2.isConnected())
.p1(nullIfNan(terminal1.getP()))
.p2(nullIfNan(terminal2.getP()))
.hvdcType(hvdcLine.getConverterStation1().getHvdcType())
.operatingStatus(ExtensionUtils.toOperatingStatus(hvdcLine))
.operatingStatus(ExtensionUtils.toOperatingStatus(hvdcLine, List.of(terminal1.isConnected(), terminal2.isConnected())))
.build();
}

Expand All @@ -72,7 +74,7 @@ private static HvdcOperatingStatusInfos toOperatingStatusInfos(Identifiable<?> i
.name(hvdcLine.getOptionalName().orElse(null))
.voltageLevelId1(terminal1.getVoltageLevel().getId())
.voltageLevelId2(terminal2.getVoltageLevel().getId())
.operatingStatus(ExtensionUtils.toOperatingStatus(hvdcLine))
.operatingStatus(ExtensionUtils.toOperatingStatus(hvdcLine, List.of(terminal1.isConnected(), terminal2.isConnected())))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.gridsuite.network.map.dto.definition.branch.line.LineTabInfos.LineTabInfosBuilder;
import org.gridsuite.network.map.dto.utils.ExtensionUtils;

import java.util.List;
import java.util.Optional;

import static org.gridsuite.network.map.dto.InfoTypeParameters.QUERY_PARAM_DC_POWERFACTOR;
Expand Down Expand Up @@ -106,7 +107,7 @@ private static LineOperatingStatusInfos toOperatingStatusInfos(Identifiable<?> i
.voltageLevelName2(terminal2.getVoltageLevel().getOptionalName().orElse(null))
.terminal1Connected(terminal1.isConnected())
.terminal2Connected(terminal2.isConnected())
.operatingStatus(ExtensionUtils.toOperatingStatus(line))
.operatingStatus(ExtensionUtils.toOperatingStatus(line, List.of(terminal1.isConnected(), terminal2.isConnected())))
.build();
}

Expand All @@ -128,8 +129,7 @@ private static LineMapInfos toMapInfos(Identifiable<?> identifiable, Double dcPo
.p2(nullIfNan(terminal2.getP()))
.i1(nullIfNan(computeIntensity(terminal1, dcPowerFactor)))
.i2(nullIfNan(computeIntensity(terminal2, dcPowerFactor)))
// TODO - lock and strip are hidden on map temporarly
//.operatingStatus(ExtensionUtils.toOperatingStatus(line))
.operatingStatus(ExtensionUtils.toOperatingStatus(line, List.of(terminal1.isConnected(), terminal2.isConnected())))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private static ThreeWindingsTransformerOperatingStatusInfos toOperatingStatusInf
.voltageLevelId1(terminal1.getVoltageLevel().getId())
.voltageLevelId2(terminal2.getVoltageLevel().getId())
.voltageLevelId3(terminal3.getVoltageLevel().getId())
.operatingStatus(ExtensionUtils.toOperatingStatus(threeWT))
.operatingStatus(ExtensionUtils.toOperatingStatus(threeWT, List.of(terminal1.isConnected(), terminal2.isConnected(), terminal3.isConnected())))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import org.gridsuite.network.map.dto.utils.ElementUtils;
import org.gridsuite.network.map.dto.utils.ExtensionUtils;

import java.util.List;

import static org.gridsuite.network.map.dto.InfoTypeParameters.QUERY_PARAM_DC_POWERFACTOR;
import static org.gridsuite.network.map.dto.utils.ElementUtils.*;

Expand Down Expand Up @@ -56,7 +58,7 @@ private static TieLineMapInfos toMapInfos(Identifiable<?> identifiable, Double d
.p2(nullIfNan(terminal2.getP()))
.i1(nullIfNan(computeIntensity(terminal1, dcPowerFactor)))
.i2(nullIfNan(computeIntensity(terminal2, dcPowerFactor)))
.operatingStatus(ExtensionUtils.toOperatingStatus(tieLine));
.operatingStatus(ExtensionUtils.toOperatingStatus(tieLine, List.of(terminal1.isConnected(), terminal2.isConnected())));

tieLine.getSelectedOperationalLimitsGroup1().ifPresent(limitsGrp -> limitsGrp.getCurrentLimits().ifPresent(limits -> builder.currentLimits1(toMapDataCurrentLimits(limits, limitsGrp.getId()))));
tieLine.getSelectedOperationalLimitsGroup2().ifPresent(limitsGrp -> limitsGrp.getCurrentLimits().ifPresent(limits -> builder.currentLimits2(toMapDataCurrentLimits(limits, limitsGrp.getId()))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private static TwoWindingsTransformerOperatingStatusInfos toOperatingStatusInfos
.name(twoWT.getOptionalName().orElse(null))
.voltageLevelId1(terminal1.getVoltageLevel().getId())
.voltageLevelId2(terminal2.getVoltageLevel().getId())
.operatingStatus(ExtensionUtils.toOperatingStatus(twoWT))
.operatingStatus(ExtensionUtils.toOperatingStatus(twoWT, List.of(terminal1.isConnected(), terminal2.isConnected())))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;

import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;

Expand Down Expand Up @@ -47,17 +49,24 @@ public static Optional<ShortCircuitInfos> toShortCircuit(@NonNull final Supplier
.build());
}

public static String toOperatingStatus(@NonNull final Extendable<?> extendable) {
public static String toOperatingStatus(@NonNull final Extendable<?> extendable, List<Boolean> terminalConnections) {
if (extendable instanceof Branch<?>
|| extendable instanceof ThreeWindingsTransformer
|| extendable instanceof HvdcLine
|| extendable instanceof BusbarSection) {
var operatingStatus = extendable.getExtension(OperatingStatus.class);
return operatingStatus == null ? null : operatingStatus.getStatus().name();
if (operatingStatus == null) {
return null;
}
return terminalConnections.stream().noneMatch(Boolean::booleanValue) ? operatingStatus.getStatus().name() : null;
}
return null;
}

public static String toOperatingStatus(@NonNull final Extendable<?> extendable) {
return toOperatingStatus(extendable, Collections.emptyList());
}

public static Optional<IdentifiableShortCircuitInfos> toIdentifiableShortCircuit(@NonNull final VoltageLevel voltageLevel) {
return Optional.ofNullable((IdentifiableShortCircuit<VoltageLevel>) voltageLevel.getExtension(IdentifiableShortCircuit.class))
.map(identifiableShortCircuit -> IdentifiableShortCircuitInfos.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ void setUp() {
l1.newOperationalLimitsGroup2("limit set 1");
l1.setSelectedOperationalLimitsGroup1("limit set 1");
l1.setSelectedOperationalLimitsGroup2("limit set 1");
l1.newExtension(OperatingStatusAdder.class).withStatus(OperatingStatus.Status.PLANNED_OUTAGE).add();
l1.newCurrentLimits1().setPermanentLimit(700.4)
.beginTemporaryLimit()
.setName("IT5")
Expand Down Expand Up @@ -198,6 +199,7 @@ void setUp() {
.setQ(8.88);
t1.getRatioTapChanger().setTapPosition(2);
t1.newExtension(OperatingStatusAdder.class).withStatus(OperatingStatus.Status.PLANNED_OUTAGE).add();
t1.getTerminal1().disconnect();
t1.newExtension(ConnectablePositionAdder.class)
.newFeeder1()
.withName("feederName1")
Expand All @@ -210,6 +212,8 @@ void setUp() {
.add();

TwoWindingsTransformer t2 = network.getTwoWindingsTransformer("NGEN_NHV1");
t2.getTerminal1().disconnect();
t2.getTerminal2().disconnect();
t2.getTerminal1().setP(11.1)
.setQ(12.2);
t2.getTerminal2().setP(13.33)
Expand Down Expand Up @@ -304,6 +308,7 @@ void setUp() {
.add();

TwoWindingsTransformer t3 = network.getTwoWindingsTransformer("NGEN_NHV2");
t3.newExtension(OperatingStatusAdder.class).withStatus(OperatingStatus.Status.PLANNED_OUTAGE).add();
t3.newCurrentLimits1().setPermanentLimit(300.4)
.beginTemporaryLimit()
.setName("IT20")
Expand Down Expand Up @@ -436,6 +441,13 @@ void setUp() {
make3WindingsTransformer(p1, "TWT", ThreeWindingsTransformer::getLeg1, ThreeWindingsTransformer::getLeg3);
make3WindingsTransformer(p1, "TWT21", ThreeWindingsTransformer::getLeg2, ThreeWindingsTransformer::getLeg1);
make3WindingsTransformer(p1, "TWT32", ThreeWindingsTransformer::getLeg3, ThreeWindingsTransformer::getLeg2);
ThreeWindingsTransformer threeWindingsTransformer = network.getThreeWindingsTransformer("TWT");
threeWindingsTransformer.getLeg1().getTerminal().disconnect();
threeWindingsTransformer.getLeg2().getTerminal().disconnect();
threeWindingsTransformer.getLeg3().getTerminal().disconnect();
ThreeWindingsTransformer threeWindingsTransformer21 = network.getThreeWindingsTransformer("TWT21");
threeWindingsTransformer21.getLeg1().getTerminal().disconnect();
threeWindingsTransformer21.getLeg2().getTerminal().disconnect();

Substation p3 = network.newSubstation()
.setId("P3")
Expand Down Expand Up @@ -480,6 +492,8 @@ void setUp() {
.add();
line3.getTerminal1().setP(200.);
line3.getTerminal2().setP(100.);
line3.getTerminal1().disconnect();
line3.getTerminal2().disconnect();
line3.newExtension(MeasurementsAdder.class).add();
Measurements<Line> line3Measurements = line3.getExtension(Measurements.class);
line3Measurements.newMeasurement().setType(Measurement.Type.ACTIVE_POWER).setSide(ThreeSides.ONE).setValid(true).setValue(11).add();
Expand Down Expand Up @@ -561,7 +575,8 @@ void setUp() {
.endTemporaryLimit()
.add();
line4.setSelectedOperationalLimitsGroup2("group1");

line4.newExtension(OperatingStatusAdder.class).withStatus(OperatingStatus.Status.PLANNED_OUTAGE).add();
line4.getTerminal1().disconnect();
Battery b1 = vlnew2.newBattery()
.setId("BATTERY1")
.setName("BATTERY1")
Expand Down Expand Up @@ -667,7 +682,7 @@ void setUp() {
.withStandardDeviationV(2.93)
.withRedundantV(true)
.add();

dl.newExtension(OperatingStatusAdder.class).withStatus(OperatingStatus.Status.PLANNED_OUTAGE).add();
DanglingLine dl2 = vlgen3.newDanglingLine()
.setId("DL2")
.setName("DL2")
Expand All @@ -689,6 +704,8 @@ void setUp() {
.setDanglingLine1("DL1")
.setDanglingLine2("DL2")
.add();
TieLine tieLine = network.getTieLine("TL1");
tieLine.newExtension(OperatingStatusAdder.class).withStatus(OperatingStatus.Status.PLANNED_OUTAGE).add();
VscConverterStation vsc1 = vlnew2.newVscConverterStation()
.setId("VSC1")
.setName("VSC1")
Expand Down Expand Up @@ -914,7 +931,7 @@ void setUp() {
.withDroop(180F)
.withEnabled(true)
.add();

hvdcLineWithExtension.newExtension(OperatingStatusAdder.class).withStatus(OperatingStatus.Status.PLANNED_OUTAGE).add();
ShuntCompensator shunt1 = vlnew2.newShuntCompensator()
.setId("SHUNT1")
.setName("SHUNT1")
Expand Down Expand Up @@ -1064,12 +1081,11 @@ void setUp() {
.setLowVoltageLimit(20)
.setTopologyKind(TopologyKind.NODE_BREAKER)
.add();
BusbarSection bbs1 = vlgen5.getNodeBreakerView().newBusbarSection()
vlgen5.getNodeBreakerView().newBusbarSection()
.setId("NGEN5")
.setName("NGEN5")
.setNode(0)
.add();
bbs1.newExtension(OperatingStatusAdder.class).withStatus(OperatingStatus.Status.FORCED_OUTAGE).add();
vlgen5.newExtension(IdentifiableShortCircuitAdder.class).withIpMin(0.0).withIpMax(100.0).add();
vlgen5.getNodeBreakerView()
.getBusbarSection("NGEN5")
Expand Down Expand Up @@ -2521,6 +2537,12 @@ void shouldReturnThreeWindingsTransformerOperatingStatusData() throws Exception
succeedingTestForElementsInfos(NETWORK_UUID, VARIANT_ID, ElementType.THREE_WINDINGS_TRANSFORMER, InfoType.OPERATING_STATUS, null, resourceToString("/3-windings-transformer-operating-status-data.json"));
}

@Test
void shouldReturnHvdcLinesOperatingStatusData() throws Exception {
succeedingTestForElementsInfos(NETWORK_UUID, null, ElementType.HVDC_LINE, InfoType.OPERATING_STATUS, null, resourceToString("/hvdc-lines-operating-status-data.json"));
succeedingTestForElementsInfos(NETWORK_UUID, VARIANT_ID, ElementType.HVDC_LINE, InfoType.OPERATING_STATUS, null, resourceToString("/hvdc-lines-operating-status-data.json"));
}

@Test
void shouldReturnGeneratorsFormData() throws Exception {
succeedingTestForElementInfosWithElementId(NETWORK_UUID, null, ElementType.GENERATOR, InfoType.FORM, "GEN", resourceToString("/generator-map-data.json"));
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/2-windings-transformer-map-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"voltageLevelId2": "VLHV1",
"voltageLevelName1": "VLGEN_Name",
"voltageLevelName2": null,
"terminal1Connected": true,
"terminal2Connected": true,
"terminal1Connected": false,
"terminal2Connected": false,
"operatingStatus": "PLANNED_OUTAGE",
"p1": 11.1,
"q1": 12.2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
},
{
"id": "NHV2_NLOAD",
"operatingStatus": "PLANNED_OUTAGE",
"voltageLevelId1": "VLHV2",
"voltageLevelId2": "VLLOAD"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
"substationId2": "P1",
"country1": "FR",
"country2": "FR",
"terminal1Connected": true,
"terminal2Connected": true,
"terminal1Connected": false,
"terminal2Connected": false,
"operatingStatus": "PLANNED_OUTAGE",
"p1": 11.1,
"q1": 12.2,
"p2": 13.33,
Expand Down Expand Up @@ -59,7 +60,6 @@
"substationProperties2": {
"Country": "FR"
},
"operatingStatus": "PLANNED_OUTAGE",
"country": "FR",
"phaseTapChanger": {
"lowTapPosition": 0,
Expand Down Expand Up @@ -117,15 +117,15 @@
"nominalVoltage2": 150.0,
"substationId1": "P2",
"substationId2": "P2",
"terminal1Connected": true,
"terminal1Connected": false,
"terminal2Connected": true,
"operatingStatus": "PLANNED_OUTAGE",
"p1": 5.5,
"q1": 6.6,
"p2": 7.77,
"q2": 8.88,
"r": 0.04724999999999999,
"x": 4.049724365620455,
"operatingStatus": "PLANNED_OUTAGE",
"ratioTapChanger": {
"lowTapPosition": 0,
"tapPosition": 2,
Expand Down Expand Up @@ -193,6 +193,7 @@
"country2": "FR",
"terminal1Connected": true,
"terminal2Connected": true,
"operatingStatus": "PLANNED_OUTAGE",
"r": 47.0,
"x": 23.0,
"selectedOperationalLimitsGroup1": {
Expand Down
11 changes: 6 additions & 5 deletions src/test/resources/2-windings-transformers-tab-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
"substationId2": "P1",
"country1": "FR",
"country2": "FR",
"terminal1Connected": true,
"terminal2Connected": true,
"terminal1Connected": false,
"terminal2Connected": false,
"operatingStatus": "PLANNED_OUTAGE",
"p1": 11.1,
"q1": 12.2,
"p2": 13.33,
Expand Down Expand Up @@ -98,7 +99,6 @@
"substationProperties2": {
"Country": "FR"
},
"operatingStatus": "PLANNED_OUTAGE",
"country": "FR",
"phaseTapChanger": {
"lowTapPosition": 0,
Expand Down Expand Up @@ -156,15 +156,15 @@
"nominalVoltage2": 150.0,
"substationId1": "P2",
"substationId2": "P2",
"terminal1Connected": true,
"terminal1Connected": false,
"terminal2Connected": true,
"operatingStatus": "PLANNED_OUTAGE",
"p1": 5.5,
"q1": 6.6,
"p2": 7.77,
"q2": 8.88,
"r": 0.04724999999999999,
"x": 4.049724365620455,
"operatingStatus": "PLANNED_OUTAGE",
"ratioTapChanger": {
"lowTapPosition": 0,
"tapPosition": 2,
Expand Down Expand Up @@ -232,6 +232,7 @@
"country2": "FR",
"terminal1Connected": true,
"terminal2Connected": true,
"operatingStatus": "PLANNED_OUTAGE",
"r": 47.0,
"x": 23.0,
"operationalLimitsGroup1": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@
{
"id": "TWT21",
"name": "TWT21",
"operatingStatus": "PLANNED_OUTAGE",
"voltageLevelId1": "VLHV1",
"voltageLevelId2": "VLNEW2",
"voltageLevelId3": "VLGEN"
},
{
"id": "TWT32",
"name": "TWT32",
"operatingStatus": "PLANNED_OUTAGE",
"voltageLevelId1": "VLHV1",
"voltageLevelId2": "VLNEW2",
"voltageLevelId3": "VLGEN"
Expand Down
Loading