Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CGMES functional logs (first steps) #3161

Merged
merged 3 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,42 @@ private CgmesReports() {
}

// INFO
public static void applyingPreprocessorsReport(ReportNode reportNode) {
reportNode.newReportNode()
.withMessageTemplate("applyingPreprocessors", "Applying preprocessors.")
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
}

public static ReportNode convertingElementTypeReport(ReportNode reportNode, String elementType) {
return reportNode.newReportNode()
.withMessageTemplate("convertingElementType", "Converting ${elementType}.")
.withUntypedValue("elementType", elementType)
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
}

public static ReportNode fixingDanglingLinesIssuesReport(ReportNode reportNode) {
return reportNode.newReportNode()
.withMessageTemplate("fixingDanglingLinesIssues", "Fixing issues with dangling lines.")
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
}

public static ReportNode settingVoltagesAndAnglesReport(ReportNode reportNode) {
return reportNode.newReportNode()
.withMessageTemplate("settingVoltagesAndAngles", "Setting voltages and angles.")
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
}

public static void applyingPostprocessorsReport(ReportNode reportNode) {
reportNode.newReportNode()
.withMessageTemplate("applyingPostprocessors", "Applying postprocessors.")
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
}

public static void importedCgmesNetworkReport(ReportNode reportNode, String networkId) {
reportNode.newReportNode()
.withMessageTemplate("importedCgmesNetwork", "CGMES network ${networkId} is imported.")
Expand Down Expand Up @@ -71,6 +107,14 @@ public static void invalidAngleVoltageNodeReport(ReportNode reportNode, String n
.add();
}

public static void removingUnattachedHvdcConverterStationReport(ReportNode reportNode, String converterId) {
reportNode.newReportNode()
.withMessageTemplate("removingUnattachedHvdcConverterStation", "HVDC Converter Station ${converterId} will be removed since it has no attached HVDC line.")
.withUntypedValue("converterId", converterId)
.withSeverity(TypedValue.WARN_SEVERITY)
.add();
}

// ERROR
public static void inconsistentProfilesTPRequiredReport(ReportNode reportNode, String networkId) {
reportNode.newReportNode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public Context(CgmesModel cgmes, Config config, Network network, ReportNode repo
this.config = Objects.requireNonNull(config);
this.network = Objects.requireNonNull(network);
this.reportNode = Objects.requireNonNull(reportNode);
pushReportNode(reportNode);

// Even if the CGMES model is node-breaker,
// we could decide to ignore the connectivity nodes and
Expand Down Expand Up @@ -207,10 +208,22 @@ public PropertyBags phaseTapChangerTable(String tableId) {

// Handling issues found during conversion

public ReportNode getReportNode() {
public ReportNode getRootReportNode() {
rcourtier marked this conversation as resolved.
Show resolved Hide resolved
return reportNode;
}

public ReportNode getReportNode() {
return network.getReportNodeContext().getReportNode();
}

public void pushReportNode(ReportNode node) {
network.getReportNodeContext().pushReportNode(node);
}

public ReportNode popReportNode() {
return network.getReportNodeContext().popReportNode();
}

private enum ConversionIssueCategory {
INVALID("Invalid"),
IGNORED("Ignored"),
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package com.powsybl.cgmes.conversion.elements;

import com.powsybl.cgmes.conversion.Context;
import com.powsybl.cgmes.model.CgmesNames;
import com.powsybl.iidm.network.Bus;
import com.powsybl.iidm.network.BusbarSection;
import com.powsybl.iidm.network.BusbarSectionAdder;
Expand All @@ -23,7 +24,7 @@
public class BusbarSectionConversion extends AbstractConductingEquipmentConversion {

public BusbarSectionConversion(PropertyBag bbs, Context context) {
super("BusbarSection", bbs, context);
super(CgmesNames.BUSBAR_SECTION, bbs, context);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import com.powsybl.cgmes.conversion.Context;
import com.powsybl.cgmes.conversion.Conversion;
import com.powsybl.cgmes.model.CgmesNames;
import com.powsybl.iidm.network.Load;
import com.powsybl.iidm.network.LoadAdder;
import com.powsybl.iidm.network.LoadType;
Expand All @@ -23,7 +24,7 @@
public class EnergyConsumerConversion extends AbstractConductingEquipmentConversion {

public EnergyConsumerConversion(PropertyBag ec, Context context) {
super("EnergyConsumer", ec, context);
super(CgmesNames.ENERGY_CONSUMER, ec, context);
loadKind = ec.getLocal("type");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import com.powsybl.cgmes.conversion.Context;
import com.powsybl.cgmes.conversion.ConversionException;
import com.powsybl.cgmes.model.CgmesNames;
import com.powsybl.commons.PowsyblException;
import com.powsybl.iidm.network.DanglingLine;
import com.powsybl.iidm.network.Line;
Expand All @@ -26,7 +27,7 @@ public class EquivalentBranchConversion extends AbstractBranchConversion impleme
private DanglingLine danglingLine;

public EquivalentBranchConversion(PropertyBag b, Context context) {
super("EquivalentBranch", b, context);
super(CgmesNames.EQUIVALENT_BRANCH, b, context);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import com.powsybl.cgmes.conversion.Context;
import com.powsybl.cgmes.conversion.Conversion;
import com.powsybl.cgmes.model.CgmesNames;
import com.powsybl.iidm.network.ShuntCompensator;
import com.powsybl.iidm.network.ShuntCompensatorAdder;
import com.powsybl.triplestore.api.PropertyBag;
Expand All @@ -19,7 +20,7 @@
public class EquivalentShuntConversion extends AbstractConductingEquipmentConversion {

public EquivalentShuntConversion(PropertyBag p, Context context) {
super("EquivalentShunt", p, context);
super(CgmesNames.EQUIVALENT_SHUNT, p, context);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,20 @@
import com.powsybl.cgmes.conversion.Context;
import com.powsybl.cgmes.conversion.Conversion;
import com.powsybl.cgmes.conversion.RegulatingControlMappingForGenerators;
import com.powsybl.cgmes.model.CgmesNames;
import com.powsybl.cgmes.model.PowerFlow;
import com.powsybl.iidm.network.EnergySource;
import com.powsybl.iidm.network.Generator;
import com.powsybl.iidm.network.GeneratorAdder;
import com.powsybl.triplestore.api.PropertyBag;

import static com.powsybl.cgmes.model.CgmesNames.EXTERNAL_NETWORK_INJECTION;

/**
* @author Luma Zamarreño {@literal <zamarrenolm at aia.es>}
*/
public class ExternalNetworkInjectionConversion extends AbstractReactiveLimitsOwnerConversion {

public ExternalNetworkInjectionConversion(PropertyBag sm, Context context) {
super(EXTERNAL_NETWORK_INJECTION, sm, context);
super(CgmesNames.EXTERNAL_NETWORK_INJECTION, sm, context);
}

@Override
Expand Down Expand Up @@ -59,7 +58,7 @@ public void convert() {
}

private static void addSpecificProperties(Generator generator, PropertyBag p) {
generator.setProperty(Conversion.PROPERTY_CGMES_ORIGINAL_CLASS, EXTERNAL_NETWORK_INJECTION);
generator.setProperty(Conversion.PROPERTY_CGMES_ORIGINAL_CLASS, CgmesNames.EXTERNAL_NETWORK_INJECTION);
double governorSCD = p.asDouble("governorSCD");
if (!Double.isNaN(governorSCD)) {
generator.setProperty(Conversion.PROPERTY_CGMES_GOVERNOR_SCD, String.valueOf(governorSCD));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package com.powsybl.cgmes.conversion.elements;

import com.powsybl.cgmes.conversion.Context;
import com.powsybl.cgmes.model.CgmesNames;
import com.powsybl.iidm.network.*;
import com.powsybl.triplestore.api.PropertyBag;

Expand All @@ -17,7 +18,7 @@
public class GroundConversion extends AbstractConductingEquipmentConversion {

public GroundConversion(PropertyBag ec, Context context) {
super("Ground", ec, context);
super(CgmesNames.GROUND, ec, context);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package com.powsybl.cgmes.conversion.elements;

import com.powsybl.cgmes.conversion.Context;
import com.powsybl.cgmes.model.CgmesNames;
import com.powsybl.iidm.network.*;
import com.powsybl.triplestore.api.PropertyBag;

Expand All @@ -32,7 +33,7 @@ public class OperationalLimitConversion extends AbstractIdentifiedObjectConversi
private static final String TEMPORARY_LIMIT = "Temporary Limit";

public OperationalLimitConversion(PropertyBag l, Context context) {
super("OperationalLimit", l, context);
super(CgmesNames.OPERATIONAL_LIMIT, l, context);
String limitSubclass = p.getLocal(OPERATIONAL_LIMIT_SUBCLASS);
// Limit can associated to a Terminal or to an Equipment
terminalId = l.getId("Terminal");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ShuntConversion extends AbstractConductingEquipmentConversion {
private static final String SECTION_NUMBER = "sectionNumber";

public ShuntConversion(PropertyBag sh, Context context) {
super("ShuntCompensator", sh, context);
super(CgmesNames.SHUNT_COMPENSATOR, sh, context);
}

private int getSections(PropertyBag p, int normalSections) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import com.powsybl.cgmes.conversion.Context;
import com.powsybl.cgmes.conversion.RegulatingControlMappingForStaticVarCompensators;
import com.powsybl.cgmes.model.CgmesNames;
import com.powsybl.iidm.network.StaticVarCompensator;
import com.powsybl.iidm.network.StaticVarCompensatorAdder;
import com.powsybl.iidm.network.extensions.VoltagePerReactivePowerControlAdder;
Expand All @@ -21,7 +22,7 @@
public class StaticVarCompensatorConversion extends AbstractConductingEquipmentConversion {

public StaticVarCompensatorConversion(PropertyBag svc, Context context) {
super("StaticVarCompensator", svc, context);
super(CgmesNames.STATIC_VAR_COMPENSATOR, svc, context);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.powsybl.cgmes.conversion.Context;
import com.powsybl.cgmes.conversion.Conversion;
import com.powsybl.cgmes.conversion.CountryConversion;
import com.powsybl.cgmes.model.CgmesNames;
import com.powsybl.iidm.network.Country;
import com.powsybl.iidm.network.Substation;
import com.powsybl.iidm.network.SubstationAdder;
Expand All @@ -22,7 +23,7 @@
public class SubstationConversion extends AbstractIdentifiedObjectConversion {

public SubstationConversion(PropertyBag s, Context context) {
super("Substation", s, context);
super(CgmesNames.SUBSTATION, s, context);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package com.powsybl.cgmes.conversion.elements;

import com.powsybl.cgmes.conversion.Conversion;
import com.powsybl.cgmes.model.CgmesNames;
import com.powsybl.iidm.network.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -27,7 +28,7 @@ public class SwitchConversion extends AbstractConductingEquipmentConversion impl
private DanglingLine danglingLine;

public SwitchConversion(PropertyBag sw, Context context) {
super("Switch", sw, context, 2);
super(CgmesNames.SWITCH, sw, context, 2);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
import com.powsybl.cgmes.conversion.Context;
import com.powsybl.cgmes.conversion.Conversion;
import com.powsybl.cgmes.conversion.RegulatingControlMappingForGenerators;
import com.powsybl.cgmes.model.CgmesNames;
import com.powsybl.cgmes.model.PowerFlow;
import com.powsybl.iidm.network.*;
import com.powsybl.iidm.network.extensions.ActivePowerControlAdder;
import com.powsybl.iidm.network.extensions.ReferencePriority;

import com.powsybl.triplestore.api.PropertyBag;
import static com.powsybl.cgmes.model.CgmesNames.SYNCHRONOUS_MACHINE;
import java.util.Arrays;

/**
Expand All @@ -28,7 +28,7 @@ public class SynchronousMachineConversion extends AbstractReactiveLimitsOwnerCon
private final boolean isCondenser;

public SynchronousMachineConversion(PropertyBag sm, Context context) {
super(SYNCHRONOUS_MACHINE, sm, context);
super(CgmesNames.SYNCHRONOUS_MACHINE, sm, context);
String type = p.getLocal("type");
isCondenser = type != null && type.endsWith("Kind.condenser");
}
Expand Down Expand Up @@ -78,7 +78,7 @@ public void convert() {
}

private static void addSpecificProperties(Generator generator, PropertyBag p) {
generator.setProperty(Conversion.PROPERTY_CGMES_ORIGINAL_CLASS, SYNCHRONOUS_MACHINE);
generator.setProperty(Conversion.PROPERTY_CGMES_ORIGINAL_CLASS, CgmesNames.SYNCHRONOUS_MACHINE);
String type = p.getLocal("type");
if (type != null) {
generator.setProperty(Conversion.PROPERTY_CGMES_SYNCHRONOUS_MACHINE_TYPE, type.replace("SynchronousMachineKind.", ""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import com.powsybl.cgmes.conversion.Context;
import com.powsybl.cgmes.model.CgmesModelException;
import com.powsybl.cgmes.model.CgmesNames;
import com.powsybl.iidm.network.Substation;
import com.powsybl.iidm.network.TopologyKind;
import com.powsybl.iidm.network.VoltageLevel;
Expand All @@ -20,8 +21,9 @@
* @author Luma Zamarreño {@literal <zamarrenolm at aia.es>}
*/
public class VoltageLevelConversion extends AbstractIdentifiedObjectConversion {

public VoltageLevelConversion(PropertyBag vl, Context context) {
super("VoltageLevel", vl, context);
super(CgmesNames.VOLTAGE_LEVEL, vl, context);
cgmesSubstationId = p.getId("Substation");
iidmSubstationId = context.substationIdMapping().substationIidm(cgmesSubstationId);
substation = context.network().getSubstation(iidmSubstationId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.powsybl.cgmes.conversion.Conversion;
import com.powsybl.cgmes.conversion.RegulatingControlMappingForVscConverters;
import com.powsybl.cgmes.conversion.elements.AbstractReactiveLimitsOwnerConversion;
import com.powsybl.cgmes.model.CgmesNames;
import com.powsybl.iidm.network.*;
import com.powsybl.iidm.network.HvdcConverterStation.HvdcType;
import com.powsybl.triplestore.api.PropertyBag;
Expand All @@ -28,7 +29,7 @@ public class AcDcConverterConversion extends AbstractReactiveLimitsOwnerConversi
private static final double DEFAULT_POWER_FACTOR = 0.8;

public AcDcConverterConversion(PropertyBag c, HvdcType converterType, double lossFactor, String acDcConverterDcTerminalId, Context context) {
super("ACDCConverter", c, context);
super(CgmesNames.ACDC_CONVERTER, c, context);

this.converterType = Objects.requireNonNull(converterType);
this.lossFactor = lossFactor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public class DcLineSegmentConversion extends AbstractIdentifiedObjectConversion
}

DcLineSegmentConversion(PropertyBag l, HvdcLine.ConvertersMode mode, double r, double ratedUdc,
DcLineSegmentConverter converter1, DcLineSegmentConverter converter2, boolean isDuplicated, Context context) {
super("DCLineSegment", l, context);
DcLineSegmentConverter converter1, DcLineSegmentConverter converter2, boolean isDuplicated, Context context) {
super(CgmesNames.DC_LINE_SEGMENT, l, context);

Objects.requireNonNull(converter1);
Objects.requireNonNull(converter2);
Expand Down
Loading