Skip to content

Commit

Permalink
fix reports
Browse files Browse the repository at this point in the history
  • Loading branch information
Seddik Yengui committed Sep 21, 2023
1 parent 1128c91 commit 6abe41b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,9 @@ private Reporter reportGeneratorSetPoints(GeneratorCreationInfos generatorCreati

private void createGeneratorVoltageRegulation(GeneratorCreationInfos generatorCreationInfos, Generator generator, VoltageLevel voltageLevel, Reporter subReporter) {
List<Report> voltageReports = new ArrayList<>();
voltageReports.add(ModificationUtils.getInstance()
.createEnabledDisabledReport("VoltageRegulationOn", modificationInfos.isVoltageRegulationOn()));
voltageReports.add(ModificationUtils.getInstance().buildCreationReport(generatorCreationInfos.getVoltageSetpoint(), "Voltage"));
voltageReports.add(ModificationUtils.getInstance().buildCreationReport(generatorCreationInfos.isVoltageRegulationOn(), "VoltageRegulationOn"));
if (generatorCreationInfos.getRegulatingTerminalVlId() != null && generatorCreationInfos.getRegulatingTerminalId() != null &&
generatorCreationInfos.getRegulatingTerminalType() != null) {
Terminal terminal = ModificationUtils.getInstance().getTerminalFromIdentifiable(voltageLevel.getNetwork(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,13 @@ public <T> Report applyElementaryModificationsAndReturnReport(Consumer<T> setter
return null;
}

public Report createEnabledDisabledReport(String key, boolean enabled) {
return Report.builder().withKey(key)
.withDefaultMessage(enabled ? " Enabled" : " Disables")
.withSeverity(TypedValue.INFO_SEVERITY)
.build();
}

public Reporter reportModifications(Reporter subReporter, List<Report> reports, String subReporterKey,
String subReporterDefaultMessage) {
List<Report> validReports = reports.stream().filter(Objects::nonNull).toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,9 @@ private void reportHvdcLineInfos(Reporter subReporter) {
ModificationUtils.getInstance().reportModifications(setPointsReporter, setPointsReports, "vscSetPoints", "Setpoints");

List<Report> angleDroopActivePowerControlReports = new ArrayList<>();
angleDroopActivePowerControlReports.add(Report.builder().withKey("angleDroopActivePowerControl")
.withDefaultMessage(modificationInfos.getAngleDroopActivePowerControl() ? "enabled" : "disabled")
.withSeverity(TypedValue.INFO_SEVERITY)
.build());
angleDroopActivePowerControlReports.add(ModificationUtils.getInstance()
.createEnabledDisabledReport("angleDroopActivePowerControl", modificationInfos.getAngleDroopActivePowerControl()));

if (modificationInfos.getP0() != null) {
angleDroopActivePowerControlReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getP0(), "P0"));
}
Expand All @@ -167,30 +166,24 @@ private VscConverterStation createConverterStation(Network network,
Reporter subReporter,
String logFieldName) {
Reporter converterStationReporter = subReporter.createSubReporter("converterStationCreated" + logFieldName, logFieldName);
List<Report> converterStationReports = new ArrayList<>();
VoltageLevel voltageLevel = ModificationUtils.getInstance().getVoltageLevel(network, converterStationCreationInfos.getVoltageLevelId());
VscConverterStation vscConverterStation = voltageLevel.getTopologyKind() == TopologyKind.NODE_BREAKER ?
createConverterStationInNodeBreaker(network, voltageLevel, converterStationCreationInfos, converterStationReports, converterStationReporter) :
createConverterStationInBusBreaker(voltageLevel, converterStationCreationInfos, converterStationReports, converterStationReporter);
createConverterStationInNodeBreaker(network, voltageLevel, converterStationCreationInfos, converterStationReporter) :
createConverterStationInBusBreaker(voltageLevel, converterStationCreationInfos, converterStationReporter);

converterStationReporter.report(Report.builder()
.withKey("converterStationCreated" + logFieldName)
.withDefaultMessage("New converter station with id=${id} created")
.withValue("id", converterStationCreationInfos.getEquipmentId())
.withSeverity(TypedValue.INFO_SEVERITY)
.build());
ModificationUtils.getInstance().reportModifications(converterStationReporter,
converterStationReports,
logFieldName,
logFieldName);

return vscConverterStation;
}

private VscConverterStation createConverterStationInNodeBreaker(Network network,
VoltageLevel voltageLevel,
ConverterStationCreationInfos converterStationCreationInfos,
List<Report> converterStationReports,
Reporter subReporter) {
VscConverterStationAdder converterStationAdder = voltageLevel.newVscConverterStation()
.setId(converterStationCreationInfos.getEquipmentId())
Expand Down Expand Up @@ -227,9 +220,8 @@ private VscConverterStation createConverterStationInNodeBreaker(Network network,
VscConverterStation vscConverterStation = ModificationUtils.getInstance()
.getVscConverterStation(network, converterStationCreationInfos.getEquipmentId());

addExtensions(vscConverterStation,
addExtensionsAndReports(vscConverterStation,
converterStationCreationInfos,
converterStationReports,
subReporter);

return vscConverterStation;
Expand All @@ -238,7 +230,6 @@ private VscConverterStation createConverterStationInNodeBreaker(Network network,

private VscConverterStation createConverterStationInBusBreaker(VoltageLevel voltageLevel,
ConverterStationCreationInfos converterStationCreationInfos,
List<Report> converterStationReports,
Reporter subReporter) {
Bus bus = ModificationUtils.getInstance().getBusBreakerBus(voltageLevel, converterStationCreationInfos.getBusOrBusbarSectionId());
VscConverterStation vscConverterStation = voltageLevel.newVscConverterStation()
Expand All @@ -251,15 +242,14 @@ private VscConverterStation createConverterStationInBusBreaker(VoltageLevel volt
.setVoltageSetpoint(converterStationCreationInfos.getVoltage())
.add();

addExtensions(vscConverterStation, converterStationCreationInfos, converterStationReports, subReporter);
addExtensionsAndReports(vscConverterStation, converterStationCreationInfos, subReporter);

return vscConverterStation;
}

private void addExtensions(VscConverterStation vscConverterStation,
ConverterStationCreationInfos converterStationCreationInfos,
List<Report> converterStationReports,
Reporter subReporter) {
private void addExtensionsAndReports(VscConverterStation vscConverterStation,
ConverterStationCreationInfos converterStationCreationInfos,
Reporter subReporter) {
reportConnectivity(converterStationCreationInfos, subReporter);

ModificationUtils.getInstance().reportModifications(subReporter,
Expand All @@ -269,21 +259,34 @@ private void addExtensions(VscConverterStation vscConverterStation,

ModificationUtils.getInstance().createReactiveLimits(converterStationCreationInfos, vscConverterStation, subReporter);

List<Report> setPointsReports = new ArrayList<>();
setPointsReports.add(Report.builder().withKey("voltageRegulationOn")
.withDefaultMessage(converterStationCreationInfos.getVoltageRegulationOn() ? "Enabled" : "Disables")
reportConverterStationSetPoints(converterStationCreationInfos, subReporter);
}

private void reportConverterStationSetPoints(ConverterStationCreationInfos converterStationCreationInfos, Reporter subReporter) {
Reporter setPointReporter = subReporter.createSubReporter("converterStationSetPoint", "Setpoints");
setPointReporter.report(Report.builder()
.withKey("Setpoints")
.withDefaultMessage("Setpoints")
.withSeverity(TypedValue.INFO_SEVERITY)
.build());

if (converterStationCreationInfos.getReactivePower() != null) {
setPointsReports.add(ModificationUtils.getInstance()
.buildCreationReport(converterStationCreationInfos.getReactivePower(), "Reactive power"));
ModificationUtils.getInstance().reportElementaryCreation(setPointReporter,
converterStationCreationInfos.getReactivePower(),
"Reactive power");
}

List<Report> setPointsVoltageReports = new ArrayList<>();
setPointsVoltageReports.add(ModificationUtils.getInstance().createEnabledDisabledReport("voltageRegulationOn",
converterStationCreationInfos.getVoltageRegulationOn()));
if (converterStationCreationInfos.getVoltage() != null) {
setPointsReports.add(ModificationUtils.getInstance().buildCreationReport(converterStationCreationInfos.getReactivePower(), "Voltage"));
setPointsVoltageReports.add(ModificationUtils.getInstance().buildCreationReport(converterStationCreationInfos.getReactivePower(), "Voltage"));
}

ModificationUtils.getInstance().reportModifications(subReporter, setPointsReports, "converterStationSetPoints", "Setpoints");
ModificationUtils.getInstance().reportModifications(setPointReporter,
setPointsVoltageReports,
"converterStationSetPointsVoltageRegulation",
"Voltage regulation");
}

private void reportConnectivity(ConverterStationCreationInfos converterStationCreationInfos, Reporter subReporter) {
Expand Down

0 comments on commit 6abe41b

Please sign in to comment.