Skip to content

Commit

Permalink
fix hvdc modification and creation logs (#504)
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne LESOT <[email protected]>
  • Loading branch information
EtienneLt authored Jul 26, 2024
1 parent 0377cd6 commit 0b2ee7c
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
* @author Slimane Amar <slimane.amar at rte-france.com>
*/
public abstract class AbstractModification extends AbstractNetworkModification {

public static final String CHARACTERISTICS = "Characteristics";
public static final String SETPOINTS = "Setpoints";

@Override
public void apply(Network network, NamingStrategy namingStrategy, boolean throwException, ComputationManager computationManager, ReportNode reportNode) {
apply(network, reportNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,13 @@ public <T> void applyElementaryModifications(Consumer<T> setter, Supplier<T> get
}
}

public <T> ReportNode applyAndBuildModificationReport(Consumer<T> setter, Supplier<T> getter, AttributeModification<T> modification, String fieldName) {
T oldValue = getter.get();
T newValue = modification.applyModification(oldValue);
setter.accept(newValue);
return buildModificationReport(oldValue, newValue, fieldName, 1, TypedValue.INFO_SEVERITY);
}

public <T> ReportNode buildModificationReport(T oldValue, T newValue, String fieldName) {
return buildModificationReport(oldValue, newValue, fieldName, 1, TypedValue.INFO_SEVERITY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ private PropertiesUtils() {

public static void applyProperties(Identifiable<?> identifiable, ReportNode subReportNode, @Nullable List<FreePropertyInfos> properties, String propertiesLabelKey) {
List<ReportNode> reportNodes = new ArrayList<>();
ReportNode propertiesReporter = subReportNode.newReportNode().withMessageTemplate(PROPERTIES, PROPERTIES).add();
Optional.ofNullable(properties).ifPresent(props ->
props.forEach(prop ->
Optional.ofNullable(PropertiesUtils.applyProperty(identifiable, prop))
.ifPresent(reportNodes::add)
)
);
ModificationUtils.getInstance().reportModifications(propertiesReporter, reportNodes,
propertiesLabelKey, PROPERTIES, Map.of());
if (!reportNodes.isEmpty()) {
ModificationUtils.getInstance().reportModifications(subReportNode, reportNodes,
propertiesLabelKey, PROPERTIES, Map.of());
}
}

private static ReportNode applyProperty(Identifiable<?> identifiable, FreePropertyInfos prop) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
*/

public class VscCreation extends AbstractModification {
public static final String CHARACTERISTICS = "Characteristics";
public static final String SETPOINTS = "Setpoints";

public static final String VSC_SETPOINTS = "vscSetPoints";
public static final String VSC_CHARACTERISTICS = "vscCharacteristics";

private final VscCreationInfos modificationInfos;

public VscCreation(VscCreationInfos modificationInfos) {
Expand Down Expand Up @@ -130,24 +132,21 @@ public void apply(Network network, ReportNode subReportNode) {

private void reportHvdcLineInfos(ReportNode subReportNode) {
List<ReportNode> characteristicsReports = new ArrayList<>();
ReportNode characteristicReport = subReportNode.newReportNode().withMessageTemplate("vscCharacteristics", CHARACTERISTICS).add();
characteristicsReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getNominalV(), "DC nominal voltage"));
characteristicsReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getR(), "DC resistance"));
characteristicsReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getMaxP(), "Pmax"));
ModificationUtils.getInstance().reportModifications(characteristicReport, characteristicsReports, "vscCharacteristics", CHARACTERISTICS, Map.of());
ModificationUtils.getInstance().reportModifications(subReportNode, characteristicsReports, VSC_CHARACTERISTICS, CHARACTERISTICS, Map.of());

List<ReportNode> limitsReports = new ArrayList<>();
ReportNode limitsReport = subReportNode.newReportNode().withMessageTemplate("vscLimits", "Limits").add();
limitsReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getOperatorActivePowerLimitFromSide1ToSide2(), "Operator active power limit (Side1 -> Side 2)"));
limitsReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getOperatorActivePowerLimitFromSide2ToSide1(), "Operator active power limit (Side2 -> Side 1)"));
ModificationUtils.getInstance().reportModifications(limitsReport, limitsReports, "vscLimits", "Limits", Map.of());
ModificationUtils.getInstance().reportModifications(subReportNode, limitsReports, "vscLimits", "Limits", Map.of());

List<ReportNode> setPointsReports = new ArrayList<>();
ReportNode setPointsReporter = subReportNode.newReportNode().withMessageTemplate("vscSetPoints", SETPOINTS).add();
ReportNode setPointsReporter = subReportNode.newReportNode().withMessageTemplate(VSC_SETPOINTS, SETPOINTS).add();
setPointsReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getConvertersMode(), "Converters mode"));
setPointsReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getActivePowerSetpoint(), "Active power"));
setPointsReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getMaxP(), "Pmax"));
ModificationUtils.getInstance().reportModifications(setPointsReporter, setPointsReports, "vscSetPoints", SETPOINTS, Map.of());
ModificationUtils.getInstance().reportModifications(setPointsReporter, setPointsReports, VSC_SETPOINTS, SETPOINTS, Map.of());

List<ReportNode> angleDroopActivePowerControlReports = new ArrayList<>();
angleDroopActivePowerControlReports.add(ModificationUtils.getInstance()
Expand All @@ -173,7 +172,6 @@ private VscConverterStation createConverterStation(Network network,
VscConverterStation vscConverterStation = voltageLevel.getTopologyKind() == TopologyKind.NODE_BREAKER ?
createConverterStationInNodeBreaker(network, voltageLevel, converterStationCreationInfos, converterStationReporter) :
createConverterStationInBusBreaker(voltageLevel, converterStationCreationInfos, converterStationReporter);

converterStationReporter.newReportNode()
.withMessageTemplate("converterStationCreated" + logFieldName, "New converter station with id=${id} created")
.withUntypedValue("id", converterStationCreationInfos.getEquipmentId())
Expand Down
Loading

0 comments on commit 0b2ee7c

Please sign in to comment.