Skip to content

Commit

Permalink
CGMES functional logs (first steps) (#3161)
Browse files Browse the repository at this point in the history
* Add multiple ReportNode to the root node of the CGMES import conversion, and attach already existing CgmesReports to these subnodes
* Add some more functional logs and fix issues reported in comments

Signed-off-by: Romain Courtier <romain.courtier@rte-france.com>
  • Loading branch information
rcourtier authored Sep 27, 2024
1 parent d8ccc84 commit bfee0f0
Show file tree
Hide file tree
Showing 25 changed files with 408 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,57 @@ private CgmesReports() {
}

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

public static void applyingProcessorReport(ReportNode reportNode, String processorName) {
reportNode.newReportNode()
.withMessageTemplate("applyingProcessor", "Applying processor: {processorName}.")
.withUntypedValue("processorName", processorName)
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
}

public static ReportNode buildingMappingsReport(ReportNode reportNode) {
return reportNode.newReportNode()
.withMessageTemplate("buildingMappings", "Building mappings.")
.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 ReportNode applyingPostprocessorsReport(ReportNode reportNode) {
return 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 All @@ -32,7 +83,7 @@ public static void importedCgmesNetworkReport(ReportNode reportNode, String netw
// WARN
public static void badVoltageTargetValueRegulatingControlReport(ReportNode reportNode, String eqId, double targetValue) {
reportNode.newReportNode()
.withMessageTemplate("badVoltageTargetValueRegulatingControl", "Equipment ${equipmentId} has a regulating control with bad target value for voltage: ${targetValue}")
.withMessageTemplate("badVoltageTargetValueRegulatingControl", "Equipment ${equipmentId} has a regulating control with bad target value for voltage: ${targetValue}.")
.withUntypedValue("equipmentId", eqId)
.withTypedValue("targetValue", targetValue, TypedValue.VOLTAGE)
.withSeverity(TypedValue.WARN_SEVERITY)
Expand All @@ -41,7 +92,7 @@ public static void badVoltageTargetValueRegulatingControlReport(ReportNode repor

public static void badTargetDeadbandRegulatingControlReport(ReportNode reportNode, String eqId, double targetDeadband) {
reportNode.newReportNode()
.withMessageTemplate("badTargetDeadbandRegulatingControl", "Equipment ${equipmentId} has a regulating control with bad target deadband: ${targetDeadband}")
.withMessageTemplate("badTargetDeadbandRegulatingControl", "Equipment ${equipmentId} has a regulating control with bad target deadband: ${targetDeadband}.")
.withUntypedValue("equipmentId", eqId)
.withTypedValue("targetDeadband", targetDeadband, TypedValue.VOLTAGE)
.withSeverity(TypedValue.WARN_SEVERITY)
Expand All @@ -50,7 +101,7 @@ public static void badTargetDeadbandRegulatingControlReport(ReportNode reportNod

public static void invalidAngleVoltageBusReport(ReportNode reportNode, Bus bus, String nodeId, double v, double angle) {
reportNode.newReportNode()
.withMessageTemplate("invalidAngleVoltageBus", "Node ${nodeId} in substation ${substation}, voltageLevel ${voltageLevel}, bus ${bus} has invalid value for voltage and/or angle. Voltage magnitude is ${voltage}, angle is ${angle}")
.withMessageTemplate("invalidAngleVoltageBus", "Node ${nodeId} in substation ${substation}, voltageLevel ${voltageLevel}, bus ${bus} has invalid value for voltage and/or angle. Voltage magnitude is ${voltage}, angle is ${angle}.")
.withUntypedValue("substation", bus.getVoltageLevel().getSubstation().map(Substation::getNameOrId).orElse("unknown"))
.withUntypedValue("voltageLevel", bus.getVoltageLevel().getNameOrId())
.withUntypedValue("bus", bus.getId())
Expand All @@ -63,14 +114,48 @@ public static void invalidAngleVoltageBusReport(ReportNode reportNode, Bus bus,

public static void invalidAngleVoltageNodeReport(ReportNode reportNode, String nodeId, double v, double angle) {
reportNode.newReportNode()
.withMessageTemplate("invalidAngleVoltageNode", "Node ${nodeId} has invalid value for voltage and/or angle. Voltage magnitude is ${voltage}, angle is ${angle}")
.withMessageTemplate("invalidAngleVoltageNode", "Node ${nodeId} has invalid value for voltage and/or angle. Voltage magnitude is ${voltage}, angle is ${angle}.")
.withUntypedValue("nodeId", nodeId)
.withTypedValue("voltage", v, TypedValue.VOLTAGE)
.withTypedValue("angle", angle, TypedValue.ANGLE)
.withSeverity(TypedValue.WARN_SEVERITY)
.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();
}

public static void voltageLevelMappingReport(ReportNode reportNode, int voltageLevelMappingSize, String mapAsString) {
reportNode.newReportNode()
.withMessageTemplate("voltageLevelMapping", "Original ${voltageLevelMappingSize} VoltageLevel container(s) connected by switches have been merged in IIDM. Map of original VoltageLevel to IIDM: ${mapAsString}.")
.withUntypedValue("voltageLevelMappingSize", voltageLevelMappingSize)
.withUntypedValue("mapAsString", mapAsString)
.withSeverity(TypedValue.WARN_SEVERITY)
.add();
}

public static void substationMappingReport(ReportNode reportNode, int substationMappingSize, String mapAsString) {
reportNode.newReportNode()
.withMessageTemplate("substationMapping", "Original ${substationMappingSize} Substation container(s) connected by transformers have been merged in IIDM. Map of original Substation to IIDM: ${mapAsString}.")
.withUntypedValue("substationMappingSize", substationMappingSize)
.withUntypedValue("mapAsString", mapAsString)
.withSeverity(TypedValue.WARN_SEVERITY)
.add();
}

public static void nominalVoltageIsZeroReport(ReportNode reportNode, String voltageLevelId) {
reportNode.newReportNode()
.withMessageTemplate("nominalVoltageIsZero", "Ignoring VoltageLevel: ${voltageLevelId} for its nominal voltage is equal to 0.")
.withUntypedValue("voltageLevelId", voltageLevelId)
.withSeverity(TypedValue.WARN_SEVERITY)
.add();
}

// ERROR
public static void inconsistentProfilesTPRequiredReport(ReportNode reportNode, String networkId) {
reportNode.newReportNode()
Expand Down Expand Up @@ -99,4 +184,14 @@ public static void multipleUnpairedDanglingLinesAtSameBoundaryReport(ReportNode
.withSeverity(TypedValue.WARN_SEVERITY)
.add();
}

public static void missingMandatoryAttributeReport(ReportNode reportNode, String attributeName, String objectClass, String objectId) {
reportNode.newReportNode()
.withMessageTemplate("missingMandatoryAttribute", "Could't retrieve mandatory attribute: ${attributeName} of ${objectClass}: ${objectId}.")
.withUntypedValue("attributeName", attributeName)
.withUntypedValue("objectClass", objectClass)
.withUntypedValue("objectId", objectId)
.withSeverity(TypedValue.ERROR_SEVERITY)
.add();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public Context(CgmesModel cgmes, Config config, Network network, ReportNode repo
this.cgmes = Objects.requireNonNull(cgmes);
this.config = Objects.requireNonNull(config);
this.network = Objects.requireNonNull(network);
this.reportNode = Objects.requireNonNull(reportNode);
pushReportNode(Objects.requireNonNull(reportNode));

// Even if the CGMES model is node-breaker,
// we could decide to ignore the connectivity nodes and
Expand Down Expand Up @@ -208,7 +208,15 @@ public PropertyBags phaseTapChangerTable(String tableId) {
// Handling issues found during conversion

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

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

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

private enum ConversionIssueCategory {
Expand Down Expand Up @@ -295,8 +303,6 @@ private static void logIssue(ConversionIssueCategory category, String what, Supp
private final Network network;
private final Config config;

private final ReportNode reportNode;

private final boolean nodeBreaker;
private final NamingStrategy namingStrategy;
private final SubstationIdMapping substationIdMapping;
Expand Down
Loading

0 comments on commit bfee0f0

Please sign in to comment.