Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 61 additions & 45 deletions src/main/java/org/gridsuite/network/map/NetworkMapService.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,12 @@ private static LineMapData toMapData(Line line) {
CurrentLimits limits2 = line.getCurrentLimits2().orElse(null);

if (limits1 != null && !Double.isNaN(limits1.getPermanentLimit())) {
builder.permanentLimit1(limits1.getPermanentLimit());
builder.currentLimits1(CurrentLimitsData.builder()
.permanentLimit(limits1.getPermanentLimit()).build());
}
if (limits2 != null && !Double.isNaN(limits2.getPermanentLimit())) {
builder.permanentLimit2(limits2.getPermanentLimit());
builder.currentLimits2(CurrentLimitsData.builder()
.permanentLimit(limits2.getPermanentLimit()).build());
}
BranchStatus<Line> branchStatus = line.getExtension(BranchStatus.class);
if (branchStatus != null) {
Expand All @@ -182,16 +184,18 @@ private static LineMapData toMapData(Line line) {
if (connectablePosition != null) {
if (connectablePosition.getFeeder1() != null) {
builder
.connectionDirection1(connectablePosition.getFeeder1().getDirection())
.connectionName1(connectablePosition.getFeeder1().getName().orElse(null))
.connectionPosition1(connectablePosition.getFeeder1().getOrder().orElse(null));
.position1(ConnectablePositionData.builder()
.direction(connectablePosition.getFeeder1().getDirection())
.label(connectablePosition.getFeeder1().getName().orElse(null))
.order(connectablePosition.getFeeder1().getOrder().orElse(null)).build());
}

if (connectablePosition.getFeeder2() != null) {
builder
.connectionDirection2(connectablePosition.getFeeder2().getDirection())
.connectionName2(connectablePosition.getFeeder2().getName().orElse(null))
.connectionPosition2(connectablePosition.getFeeder2().getOrder().orElse(null));
.position2(ConnectablePositionData.builder()
.direction(connectablePosition.getFeeder2().getDirection())
.label(connectablePosition.getFeeder2().getName().orElse(null))
.order(connectablePosition.getFeeder2().getOrder().orElse(null)).build());
}
}
return builder.build();
Expand Down Expand Up @@ -220,10 +224,12 @@ private static LineMapData toBasicMapData(Line line) {
CurrentLimits limits2 = line.getCurrentLimits2().orElse(null);

if (limits1 != null && !Double.isNaN(limits1.getPermanentLimit())) {
builder.permanentLimit1(limits1.getPermanentLimit());
builder.currentLimits1(CurrentLimitsData.builder()
.permanentLimit(limits1.getPermanentLimit()).build());
}
if (limits2 != null && !Double.isNaN(limits2.getPermanentLimit())) {
builder.permanentLimit2(limits2.getPermanentLimit());
builder.currentLimits2(CurrentLimitsData.builder()
.permanentLimit(limits2.getPermanentLimit()).build());
}
BranchStatus<Line> branchStatus = line.getExtension(BranchStatus.class);
if (branchStatus != null) {
Expand Down Expand Up @@ -334,13 +340,13 @@ private static GeneratorMapData toMapData(Generator generator) {
}

private static List<ReactiveCapabilityCurveMapData> toMapData(Collection<ReactiveCapabilityCurve.Point> points) {
return points.stream()
.map(point -> ReactiveCapabilityCurveMapData.builder()
.p(point.getP())
.qmaxP(point.getMaxQ())
.qminP(point.getMinQ())
.build())
.collect(Collectors.toList());
return points.stream()
.map(point -> ReactiveCapabilityCurveMapData.builder()
.p(point.getP())
.qmaxP(point.getMaxQ())
.qminP(point.getMinQ())
.build())
.collect(Collectors.toList());
}

private static Double nullIfNan(double d) {
Expand Down Expand Up @@ -382,10 +388,12 @@ private static TwoWindingsTransformerMapData toMapData(TwoWindingsTransformer tr
CurrentLimits limits1 = transformer.getCurrentLimits1().orElse(null);
CurrentLimits limits2 = transformer.getCurrentLimits2().orElse(null);
if (limits1 != null && !Double.isNaN(limits1.getPermanentLimit())) {
builder.permanentLimit1(limits1.getPermanentLimit());
builder.currentLimits1(CurrentLimitsData.builder()
.permanentLimit(limits1.getPermanentLimit()).build());
}
if (limits2 != null && !Double.isNaN(limits2.getPermanentLimit())) {
builder.permanentLimit2(limits2.getPermanentLimit());
builder.currentLimits2(CurrentLimitsData.builder()
.permanentLimit(limits2.getPermanentLimit()).build());
}
BranchStatus<TwoWindingsTransformer> branchStatus = transformer.getExtension(BranchStatus.class);
if (branchStatus != null) {
Expand All @@ -395,16 +403,18 @@ private static TwoWindingsTransformerMapData toMapData(TwoWindingsTransformer tr
if (connectablePosition != null) {
if (connectablePosition.getFeeder1() != null) {
builder
.connectionDirection1(connectablePosition.getFeeder1().getDirection())
.connectionName1(connectablePosition.getFeeder1().getName().orElse(null))
.connectionPosition1(connectablePosition.getFeeder1().getOrder().orElse(null));
.position1(ConnectablePositionData.builder()
.direction(connectablePosition.getFeeder1().getDirection())
.label(connectablePosition.getFeeder1().getName().orElse(null))
.order(connectablePosition.getFeeder1().getOrder().orElse(null)).build());
}

if (connectablePosition.getFeeder2() != null) {
builder
.connectionDirection2(connectablePosition.getFeeder2().getDirection())
.connectionName2(connectablePosition.getFeeder2().getName().orElse(null))
.connectionPosition2(connectablePosition.getFeeder2().getOrder().orElse(null));
.position2(ConnectablePositionData.builder()
.direction(connectablePosition.getFeeder2().getDirection())
.label(connectablePosition.getFeeder2().getName().orElse(null))
.order(connectablePosition.getFeeder2().getOrder().orElse(null)).build());
}
}
return builder.build();
Expand All @@ -416,15 +426,18 @@ private static TapChangerData toMapData(RatioTapChanger tapChanger) {
}

TapChangerData.TapChangerDataBuilder builder = TapChangerData.builder()
.lowTapPosition(tapChanger.getLowTapPosition())
.highTapPosition(tapChanger.getHighTapPosition())
.tapPosition(tapChanger.getTapPosition())
.regulating(tapChanger.isRegulating())
.loadTapChangingCapabilities(tapChanger.hasLoadTapChangingCapabilities())
.regulatingTerminalConnectableId(tapChanger.getRegulationTerminal() != null ? tapChanger.getRegulationTerminal().getConnectable().getId() : null)
.regulatingTerminalConnectableType(tapChanger.getRegulationTerminal() != null ? tapChanger.getRegulationTerminal().getConnectable().getType().name() : null)
.regulatingTerminalVlId(tapChanger.getRegulationTerminal() != null ? tapChanger.getRegulationTerminal().getVoltageLevel().getId() : null)
.steps(toMapDataRatioStep(tapChanger.getAllSteps()));
.lowTapPosition(tapChanger.getLowTapPosition())
.highTapPosition(tapChanger.getHighTapPosition())
.tapPosition(tapChanger.getTapPosition())
.regulating(tapChanger.isRegulating())
.loadTapChangingCapabilities(tapChanger.hasLoadTapChangingCapabilities())
.regulatingTerminal(tapChanger.getRegulationTerminal() != null ? RegulatingTerminalData.builder()
.id(tapChanger.getRegulationTerminal().getConnectable().getId())
.vlId(tapChanger.getRegulationTerminal().getVoltageLevel().getId())
.type(tapChanger.getRegulationTerminal().getConnectable().getType().name())
.build()
: null)
.steps(toMapDataRatioStep(tapChanger.getAllSteps()));

builder.targetV(nullIfNan(tapChanger.getTargetV()));
builder.targetDeadBand(nullIfNan(tapChanger.getTargetDeadband()));
Expand All @@ -437,17 +450,20 @@ private static TapChangerData toMapData(PhaseTapChanger tapChanger) {
}

TapChangerData.TapChangerDataBuilder builder = TapChangerData.builder()
.lowTapPosition(tapChanger.getLowTapPosition())
.highTapPosition(tapChanger.getHighTapPosition())
.tapPosition(tapChanger.getTapPosition())
.regulating(tapChanger.isRegulating())
.regulationMode(tapChanger.getRegulationMode())
.regulationValue(tapChanger.getRegulationValue())
.targetDeadBand(tapChanger.getTargetDeadband())
.regulatingTerminalConnectableId(tapChanger.getRegulationTerminal() != null ? tapChanger.getRegulationTerminal().getConnectable().getId() : null)
.regulatingTerminalConnectableType(tapChanger.getRegulationTerminal() != null ? tapChanger.getRegulationTerminal().getConnectable().getType().name() : null)
.regulatingTerminalVlId(tapChanger.getRegulationTerminal() != null ? tapChanger.getRegulationTerminal().getVoltageLevel().getId() : null)
.steps(toMapDataPhaseStep(tapChanger.getAllSteps()));
.lowTapPosition(tapChanger.getLowTapPosition())
.highTapPosition(tapChanger.getHighTapPosition())
.tapPosition(tapChanger.getTapPosition())
.regulating(tapChanger.isRegulating())
.regulationMode(tapChanger.getRegulationMode())
.regulationValue(tapChanger.getRegulationValue())
.targetDeadBand(tapChanger.getTargetDeadband())
.regulatingTerminal(tapChanger.getRegulationTerminal() != null ? RegulatingTerminalData.builder()
.id(tapChanger.getRegulationTerminal().getConnectable().getId())
.vlId(tapChanger.getRegulationTerminal().getVoltageLevel().getId())
.type(tapChanger.getRegulationTerminal().getConnectable().getType().name())
.build()
: null)
.steps(toMapDataPhaseStep(tapChanger.getAllSteps()));

builder.targetDeadBand(nullIfNan(tapChanger.getTargetDeadband()));
return builder.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (c) 2023, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.gridsuite.network.map.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.powsybl.iidm.network.extensions.ConnectablePosition;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;

/**
* @author Franck Lecuyer <franck.lecuyer at rte-france.com>
*/
@Builder
@Getter
@EqualsAndHashCode
public class ConnectablePositionData {

@JsonInclude(JsonInclude.Include.NON_NULL)
private String label;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer order;

@JsonInclude(JsonInclude.Include.NON_NULL)
private ConnectablePosition.Direction direction;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (c) 2023, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.gridsuite.network.map.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;

/**
* @author Franck Lecuyer <franck.lecuyer at rte-france.com>
*/

@Builder
@Getter
@EqualsAndHashCode
public class CurrentLimitsData {

@JsonInclude(JsonInclude.Include.NON_NULL)
private Double permanentLimit;
}
21 changes: 4 additions & 17 deletions src/main/java/org/gridsuite/network/map/model/LineMapData.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package org.gridsuite.network.map.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.powsybl.iidm.network.extensions.ConnectablePosition;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand Down Expand Up @@ -57,10 +56,10 @@ public class LineMapData {
private Double i2;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Double permanentLimit1;
private CurrentLimitsData currentLimits1;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Double permanentLimit2;
private CurrentLimitsData currentLimits2;

@JsonInclude(JsonInclude.Include.NON_NULL)
private String branchStatus;
Expand All @@ -84,22 +83,10 @@ public class LineMapData {
private Double b2;

@JsonInclude(JsonInclude.Include.NON_NULL)
private String connectionName1;
private ConnectablePositionData position1;

@JsonInclude(JsonInclude.Include.NON_NULL)
private ConnectablePosition.Direction connectionDirection1;

@JsonInclude(JsonInclude.Include.NON_NULL)
private String connectionName2;

@JsonInclude(JsonInclude.Include.NON_NULL)
private ConnectablePosition.Direction connectionDirection2;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer connectionPosition1;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer connectionPosition2;
private ConnectablePositionData position2;

@JsonInclude(JsonInclude.Include.NON_NULL)
private String busOrBusbarSectionId1;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright (c) 2023, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.gridsuite.network.map.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;

/**
* @author Franck Lecuyer <franck.lecuyer at rte-france.com>
*/
@Builder
@Getter
@EqualsAndHashCode
public class RegulatingTerminalData {

@JsonInclude(JsonInclude.Include.NON_NULL)
private String id;

@JsonInclude(JsonInclude.Include.NON_NULL)
private String type;

@JsonInclude(JsonInclude.Include.NON_NULL)
private String vlId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,9 @@ public class TapChangerData {
private Double regulationValue;

@JsonInclude(JsonInclude.Include.NON_NULL)
private String regulatingTerminalConnectableId;

@JsonInclude(JsonInclude.Include.NON_NULL)
private String regulatingTerminalConnectableType;

@JsonInclude(JsonInclude.Include.NON_NULL)
private String regulatingTerminalVlId;
private RegulatingTerminalData regulatingTerminal;

@JsonInclude(JsonInclude.Include.NON_NULL)
private List<TapChangerStepData> steps;

}

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package org.gridsuite.network.map.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.powsybl.iidm.network.extensions.ConnectablePosition;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand Down Expand Up @@ -55,10 +54,10 @@ public class TwoWindingsTransformerMapData {
private Double i2;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Double permanentLimit1;
private CurrentLimitsData currentLimits1;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Double permanentLimit2;
private CurrentLimitsData currentLimits2;

@JsonInclude(JsonInclude.Include.NON_NULL)
private TapChangerData phaseTapChanger;
Expand All @@ -82,20 +81,10 @@ public class TwoWindingsTransformerMapData {
private Double ratedS;

@JsonInclude(JsonInclude.Include.NON_NULL)
private String connectionName1;

private ConnectablePosition.Direction connectionDirection1;

@JsonInclude(JsonInclude.Include.NON_NULL)
private String connectionName2;

private ConnectablePosition.Direction connectionDirection2;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer connectionPosition1;
private ConnectablePositionData position1;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer connectionPosition2;
private ConnectablePositionData position2;

@JsonInclude(JsonInclude.Include.NON_NULL)
private String busOrBusbarSectionId1;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Copyright (c) 2023, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.gridsuite.network.map;

import nl.jqno.equalsverifier.EqualsVerifier;
import org.gridsuite.network.map.model.ConnectablePositionData;
import org.junit.Test;

/**
* @author Franck Lecuyer <franck.lecuyer at rte-france.com>
*/
public class ConnectablePositionDataTest {

@Test
public void equalsContract() {
EqualsVerifier.simple().forClass(ConnectablePositionData.class).verify();
}
}
Loading