diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/CgmesReports.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/CgmesReports.java index f23b5d74f2d..d410c73be34 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/CgmesReports.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/CgmesReports.java @@ -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.") @@ -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) @@ -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) @@ -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()) @@ -63,7 +114,7 @@ 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) @@ -71,6 +122,40 @@ 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(); + } + + 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() @@ -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(); + } } diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/Context.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/Context.java index bcab5e0a9da..df7f1f4acdd 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/Context.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/Context.java @@ -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 @@ -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 { @@ -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; diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/Conversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/Conversion.java index 869455c855a..125828f147e 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/Conversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/Conversion.java @@ -36,7 +36,6 @@ import java.util.function.Supplier; import java.util.stream.Stream; -import static com.powsybl.cgmes.conversion.CgmesReports.importedCgmesNetworkReport; import static com.powsybl.cgmes.conversion.Conversion.Config.StateProfile.SSH; import static java.util.stream.Collectors.groupingBy; @@ -141,130 +140,141 @@ public Network convert() { } public Network convert(ReportNode reportNode) { + // Check presence of report node for functional logs and EQ profile in the data source Objects.requireNonNull(reportNode); + if (!cgmes.hasEquipmentCore()) { + throw new CgmesModelException("Data source does not contain EquipmentCore data"); + } - // apply pre-processors before starting the conversion + // Apply preprocessors, which mainly create missing containers + ReportNode preProcessorsNode = CgmesReports.applyingPreprocessorsReport(reportNode); for (CgmesImportPreProcessor preProcessor : preProcessors) { + CgmesReports.applyingProcessorReport(preProcessorsNode, preProcessor.getName()); preProcessor.process(cgmes); } - if (LOG.isTraceEnabled() && cgmes.baseVoltages() != null) { LOG.trace("{}{}{}", "BaseVoltages", System.lineSeparator(), cgmes.baseVoltages().tabulate()); } - // Check that at least we have an EquipmentCore profile - if (!cgmes.hasEquipmentCore()) { - throw new CgmesModelException("Data source does not contain EquipmentCore data"); - } + + // Create base network with metadata information Network network = createNetwork(); Context context = createContext(network, reportNode); assignNetworkProperties(context); addMetadataModels(network, context); addCimCharacteristics(network); + + // Build mappings + context.pushReportNode(CgmesReports.buildingMappingsReport(reportNode)); + context.substationIdMapping().build(); BaseVoltageMappingAdder bvAdder = network.newExtension(BaseVoltageMappingAdder.class); cgmes.baseVoltages().forEach(bv -> bvAdder.addBaseVoltage(bv.getId("BaseVoltage"), bv.asDouble("nominalVoltage"), isBoundaryBaseVoltage(bv.getLocal("graph")))); bvAdder.add(); - - Function convf; - cgmes.computedTerminals().forEach(t -> context.terminalMapping().buildTopologicalNodeCgmesTerminalsMapping(t)); cgmes.regulatingControls().forEach(p -> context.regulatingControlMapping().cacheRegulatingControls(p)); + context.popReportNode(); - // First build all the containers - convert(cgmes.substations(), s -> new SubstationConversion(s, context)); - convert(cgmes.voltageLevels(), vl -> new VoltageLevelConversion(vl, context)); + // Convert containers + convert(cgmes.substations(), CgmesNames.SUBSTATION, context); + convert(cgmes.voltageLevels(), CgmesNames.VOLTAGE_LEVEL, context); createFictitiousVoltageLevelsForLineContainers(context); - PropertyBags nodes = context.nodeBreaker() - ? cgmes.connectivityNodes() - : cgmes.topologicalNodes(); - String nodeTypeName = context.nodeBreaker() - ? "ConnectivityNode" - : "TopologicalNode"; - convert(nodes, n -> new NodeConversion(nodeTypeName, n, context)); + // Convert topology + PropertyBags nodes = context.nodeBreaker() ? cgmes.connectivityNodes() : cgmes.topologicalNodes(); + if (context.nodeBreaker()) { + convert(nodes, CgmesNames.CONNECTIVITY_NODE, context); + } else { + convert(nodes, CgmesNames.TOPOLOGICAL_NODE, context); + } if (!context.config().createBusbarSectionForEveryConnectivityNode()) { - convert(cgmes.busBarSections(), bbs -> new BusbarSectionConversion(bbs, context)); - } - - convert(cgmes.grounds(), g -> new GroundConversion(g, context)); - convert(cgmes.energyConsumers(), ec -> new EnergyConsumerConversion(ec, context)); - convert(cgmes.energySources(), es -> new EnergySourceConversion(es, context)); - convf = eqi -> new EquivalentInjectionConversion(eqi, context); - convert(cgmes.equivalentInjections(), convf); - convf = eni -> new ExternalNetworkInjectionConversion(eni, context); - convert(cgmes.externalNetworkInjections(), convf); - convert(cgmes.shuntCompensators(), sh -> new ShuntConversion(sh, context)); - convert(cgmes.equivalentShunts(), es -> new EquivalentShuntConversion(es, context)); - convf = svc -> new StaticVarCompensatorConversion(svc, context); - convert(cgmes.staticVarCompensators(), convf); - convf = asm -> new AsynchronousMachineConversion(asm, context); - convert(cgmes.asynchronousMachines(), convf); - convert(cgmes.synchronousMachinesGenerators(), sm -> new SynchronousMachineConversion(sm, context)); - convert(cgmes.synchronousMachinesCondensers(), sm -> new SynchronousMachineConversion(sm, context)); - + convert(cgmes.busBarSections(), CgmesNames.BUSBAR_SECTION, context); + } + + // Convert single terminal equipments + convert(cgmes.grounds(), CgmesNames.GROUND, context); + convert(cgmes.energyConsumers(), CgmesNames.ENERGY_CONSUMER, context); + convert(cgmes.energySources(), CgmesNames.ENERGY_SOURCE, context); + convert(cgmes.equivalentInjections(), CgmesNames.EQUIVALENT_INJECTION, context); + convert(cgmes.externalNetworkInjections(), CgmesNames.EXTERNAL_NETWORK_INJECTION, context); + convert(cgmes.shuntCompensators(), CgmesNames.SHUNT_COMPENSATOR, context); + convert(cgmes.equivalentShunts(), CgmesNames.EQUIVALENT_SHUNT, context); + convert(cgmes.staticVarCompensators(), CgmesNames.STATIC_VAR_COMPENSATOR, context); + convert(cgmes.asynchronousMachines(), CgmesNames.ASYNCHRONOUS_MACHINE, context); + convert(cgmes.synchronousMachinesAll(), CgmesNames.SYNCHRONOUS_MACHINE, context); + + // Convert multiple terminals equipments // We will delay the conversion of some lines/switches that have an end at boundary // They have to be processed after all lines/switches have been reviewed // FIXME(Luma) store delayedBoundaryNodes in context Set delayedBoundaryNodes = new HashSet<>(); convertSwitches(context, delayedBoundaryNodes); convertACLineSegmentsToLines(context, delayedBoundaryNodes); - convertEquivalentBranchesToLines(context, delayedBoundaryNodes); - convert(cgmes.seriesCompensators(), sc -> new SeriesCompensatorConversion(sc, context)); - + convert(cgmes.seriesCompensators(), CgmesNames.SERIES_COMPENSATOR, context); convertTransformers(context, delayedBoundaryNodes); + context.pushReportNode(CgmesReports.convertingElementTypeReport(reportNode, "equipments at boundaries")); delayedBoundaryNodes.forEach(node -> convertEquipmentAtBoundaryNode(context, node)); + context.popReportNode(); + // Convert DC equipments, limits, SV injections, control areas, regulating controls + context.pushReportNode(CgmesReports.convertingElementTypeReport(reportNode, "DC network")); CgmesDcConversion cgmesDcConversion = new CgmesDcConversion(cgmes, context); cgmesDcConversion.convert(); + clearUnattachedHvdcConverterStations(network, context); + context.popReportNode(); - convert(cgmes.operationalLimits(), l -> new OperationalLimitConversion(l, context)); + convert(cgmes.operationalLimits(), CgmesNames.OPERATIONAL_LIMIT, context); context.loadingLimitsMapping().addAll(); if (config.convertSvInjections()) { - convert(cgmes.svInjections(), si -> new SvInjectionConversion(si, context)); + convert(cgmes.svInjections(), CgmesNames.SV_INJECTION, context); } - clearUnattachedHvdcConverterStations(network, context); // in case of faulty CGMES files, remove HVDC Converter Stations without HVDC lines - voltageAngles(nodes, context); - if (config.importControlAreas()) { + context.pushReportNode(CgmesReports.convertingElementTypeReport(reportNode, CgmesNames.CONTROL_AREA)); network.newExtension(CgmesControlAreasAdder.class).add(); CgmesControlAreas cgmesControlAreas = network.getExtension(CgmesControlAreas.class); cgmes.controlAreas().forEach(ca -> createControlArea(cgmesControlAreas, ca)); cgmes.tieFlows().forEach(tf -> addTieFlow(context, cgmesControlAreas, tf)); cgmesControlAreas.cleanIfEmpty(); + context.popReportNode(); } - // set all regulating controls + context.pushReportNode(CgmesReports.convertingElementTypeReport(reportNode, CgmesNames.REGULATING_CONTROL)); context.regulatingControlMapping().setAllRegulatingControls(network); - if (context.config().debugTopology()) { + context.popReportNode(); + + // Fix dangling lines issues + context.pushReportNode(CgmesReports.fixingDanglingLinesIssuesReport(reportNode)); + handleDangingLineDisconnectedAtBoundary(network, context); + adjustMultipleUnpairedDanglingLinesAtSameBoundaryNode(network, context); + context.popReportNode(); + + // Set voltages and angles + context.pushReportNode(CgmesReports.settingVoltagesAndAnglesReport(reportNode)); + voltageAngles(nodes, context); + completeVoltagesAndAngles(network); + context.popReportNode(); + + // Save/store data for debug or external validation + if (config.debugTopology()) { debugTopology(context); } - if (config.storeCgmesModelAsNetworkExtension()) { - // Store a reference to the original CGMES model inside the IIDM network network.newExtension(CgmesModelExtensionAdder.class).withModel(cgmes).add(); } + if (config.storeCgmesConversionContextAsNetworkExtension()) { + network.newExtension(CgmesConversionContextExtensionAdder.class).withContext(context).add(); + } - // apply post-processors - handleDangingLineDisconnectedAtBoundary(network, context); - adjustMultipleUnpairedDanglingLinesAtSameBoundaryNode(network, context); + ReportNode postProcessorsNode = CgmesReports.applyingPostprocessorsReport(reportNode); for (CgmesImportPostProcessor postProcessor : postProcessors) { // FIXME generic cgmes models may not have an underlying triplestore // TODO maybe pass the properties to the post processors + CgmesReports.applyingProcessorReport(postProcessorsNode, postProcessor.getName()); postProcessor.process(network, cgmes.tripleStore()); } - // Complete Voltages and angles in starBus as properties - // Complete Voltages and angles in boundary buses - completeVoltagesAndAngles(network); - - if (config.storeCgmesConversionContextAsNetworkExtension()) { - // Store the terminal mapping in an extension for external validation - network.newExtension(CgmesConversionContextExtensionAdder.class).withContext(context).add(); - } - - importedCgmesNetworkReport(context.getReportNode(), network.getId()); + CgmesReports.importedCgmesNetworkReport(reportNode, network.getId()); return network; } @@ -378,25 +388,39 @@ private static void addTieFlow(Context context, CgmesControlAreas cgmesControlAr RegulatingTerminalMapper.mapForTieFlow(terminalId, context).ifPresent(cgmesControlArea::add); } - private void convert( - PropertyBags elements, - Function f) { - String logTitle = null; + private void convert(PropertyBags elements, String elementType, Context context) { + context.pushReportNode(CgmesReports.convertingElementTypeReport(context.getReportNode(), elementType)); for (PropertyBag element : elements) { - AbstractObjectConversion c = f.apply(element); if (LOG.isTraceEnabled()) { - if (logTitle == null) { - logTitle = c.getClass().getSimpleName(); - logTitle = logTitle.replace("Conversion", ""); - } - LOG.trace(element.tabulateLocals(logTitle)); + LOG.trace(element.tabulateLocals(elementType)); } + AbstractObjectConversion c = switch (elementType) { + case CgmesNames.SUBSTATION -> new SubstationConversion(element, context); + case CgmesNames.VOLTAGE_LEVEL -> new VoltageLevelConversion(element, context); + case CgmesNames.CONNECTIVITY_NODE, CgmesNames.TOPOLOGICAL_NODE -> new NodeConversion(elementType, element, context); + case CgmesNames.BUSBAR_SECTION -> new BusbarSectionConversion(element, context); + case CgmesNames.GROUND -> new GroundConversion(element, context); + case CgmesNames.ENERGY_CONSUMER -> new EnergyConsumerConversion(element, context); + case CgmesNames.ENERGY_SOURCE -> new EnergySourceConversion(element, context); + case CgmesNames.EQUIVALENT_INJECTION -> new EquivalentInjectionConversion(element, context); + case CgmesNames.EXTERNAL_NETWORK_INJECTION -> new ExternalNetworkInjectionConversion(element, context); + case CgmesNames.SHUNT_COMPENSATOR -> new ShuntConversion(element, context); + case CgmesNames.EQUIVALENT_SHUNT -> new EquivalentShuntConversion(element, context); + case CgmesNames.STATIC_VAR_COMPENSATOR -> new StaticVarCompensatorConversion(element, context); + case CgmesNames.ASYNCHRONOUS_MACHINE -> new AsynchronousMachineConversion(element, context); + case CgmesNames.SYNCHRONOUS_MACHINE -> new SynchronousMachineConversion(element, context); + case CgmesNames.SERIES_COMPENSATOR -> new SeriesCompensatorConversion(element, context); + case CgmesNames.OPERATIONAL_LIMIT -> new OperationalLimitConversion(element, context); + case CgmesNames.SV_INJECTION -> new SvInjectionConversion(element, context); + default -> throw new IllegalArgumentException("Invalid elementType."); + }; if (c.insideBoundary()) { c.convertInsideBoundary(); } else if (c.valid()) { c.convert(); } } + context.popReportNode(); } private Network createNetwork() { @@ -407,7 +431,6 @@ private Network createNetwork() { private Context createContext(Network network, ReportNode reportNode) { Context context = new Context(cgmes, config, network, reportNode); - context.substationIdMapping().build(); context.dc().initialize(); context.loadRatioTapChangers(); context.loadPhaseTapChangers(); @@ -530,9 +553,9 @@ private void putVoltageLevelRefByLineContainerIdIfPresent(String lineContainerId Supplier terminalId2, Map nominalVoltageByLineContainerId, Context context) { - String vlId = Optional.ofNullable(context.namingStrategy().getIidmId(VOLTAGE_LEVEL, + String vlId = Optional.ofNullable(context.namingStrategy().getIidmId(CgmesNames.VOLTAGE_LEVEL, context.cgmes().voltageLevel(cgmes.terminal(terminalId1.get()), context.nodeBreaker()))) - .orElseGet(() -> context.namingStrategy().getIidmId(VOLTAGE_LEVEL, + .orElseGet(() -> context.namingStrategy().getIidmId(CgmesNames.VOLTAGE_LEVEL, context.cgmes().voltageLevel(cgmes.terminal(terminalId2.get()), context.nodeBreaker()))); if (vlId != null) { VoltageLevel vl = context.network().getVoltageLevel(vlId); @@ -543,9 +566,10 @@ private void putVoltageLevelRefByLineContainerIdIfPresent(String lineContainerId } private void convertACLineSegmentsToLines(Context context, Set delayedBoundaryNodes) { + context.pushReportNode(CgmesReports.convertingElementTypeReport(context.getReportNode(), CgmesNames.AC_LINE_SEGMENT)); for (PropertyBag line : cgmes.acLineSegments()) { if (LOG.isTraceEnabled()) { - LOG.trace(line.tabulateLocals("ACLineSegment")); + LOG.trace(line.tabulateLocals(CgmesNames.AC_LINE_SEGMENT)); } ACLineSegmentConversion c = new ACLineSegmentConversion(line, context); if (c.valid()) { @@ -558,6 +582,7 @@ private void convertACLineSegmentsToLines(Context context, Set delayedBo } } } + context.popReportNode(); } private void createFictitiousVoltageLevelsForLineContainers(Context context) { @@ -606,7 +631,7 @@ private LineContainerFictitiousVoltageLevelData voltageLevelDataForACLSinLineCon vldata.lineName = lineSegment.get("lineName"); CgmesTerminal t = cgmes.terminal(lineSegment.getId(terminalRef)); vldata.nodeId = context.nodeBreaker() ? t.connectivityNode() : t.topologicalNode(); - String vlId = context.namingStrategy().getIidmId(VOLTAGE_LEVEL, context.cgmes().voltageLevel(t, context.nodeBreaker())); + String vlId = context.namingStrategy().getIidmId(CgmesNames.VOLTAGE_LEVEL, context.cgmes().voltageLevel(t, context.nodeBreaker())); vldata.vl = context.network().getVoltageLevel( Objects.requireNonNullElseGet(vlId, () -> getFictitiousVoltageLevelForNodeInContainer(vldata.lineId, vldata.nodeId))); return vldata; @@ -646,6 +671,7 @@ private void createLineContainerFictitiousVoltageLevel(Context context, LineCont } private void convertSwitches(Context context, Set delayedBoundaryNodes) { + context.pushReportNode(CgmesReports.convertingElementTypeReport(context.getReportNode(), CgmesNames.SWITCH)); for (PropertyBag sw : cgmes.switches()) { if (LOG.isTraceEnabled()) { LOG.trace(sw.tabulateLocals("Switch")); @@ -661,9 +687,11 @@ private void convertSwitches(Context context, Set delayedBoundaryNodes) } } } + context.popReportNode(); } private void convertEquivalentBranchesToLines(Context context, Set delayedBoundaryNodes) { + context.pushReportNode(CgmesReports.convertingElementTypeReport(context.getReportNode(), CgmesNames.EQUIVALENT_BRANCH)); for (PropertyBag equivalentBranch : cgmes.equivalentBranches()) { if (LOG.isTraceEnabled()) { LOG.trace(equivalentBranch.tabulateLocals("EquivalentBranch")); @@ -679,9 +707,11 @@ private void convertEquivalentBranchesToLines(Context context, Set delay } } } + context.popReportNode(); } private void convertTransformers(Context context, Set delayedBoundaryNodes) { + context.pushReportNode(CgmesReports.convertingElementTypeReport(context.getReportNode(), CgmesNames.POWER_TRANSFORMER)); cgmes.groupedTransformerEnds().forEach((t, ends) -> { if (LOG.isTraceEnabled()) { LOG.trace("Transformer {}, {}-winding", t, ends.size()); @@ -697,6 +727,7 @@ private void convertTransformers(Context context, Set delayedBoundaryNod context.invalid(what, reason); } }); + context.popReportNode(); } private static void convertTwoWindingsTransformers(Context context, PropertyBags ends, Set delayedBoundaryNodes) { @@ -803,7 +834,7 @@ private void voltageAngles(PropertyBags nodes, Context context) { // In node-breaker conversion, // set (voltage, angle) values after all nodes have been created and connected for (PropertyBag n : nodes) { - NodeConversion nc = new NodeConversion("ConnectivityNode", n, context); + NodeConversion nc = new NodeConversion(CgmesNames.CONNECTIVITY_NODE, n, context); if (!nc.insideBoundary() || nc.insideBoundary() && context.config().convertBoundary()) { nc.setVoltageAngleNodeBreaker(); } @@ -812,9 +843,11 @@ private void voltageAngles(PropertyBags nodes, Context context) { } private void clearUnattachedHvdcConverterStations(Network network, Context context) { + // In case of faulty CGMES files, remove HVDC Converter Stations without HVDC lines network.getHvdcConverterStationStream() .filter(converter -> converter.getHvdcLine() == null) .forEach(converter -> { + CgmesReports.removingUnattachedHvdcConverterStationReport(context.getReportNode(), converter.getId()); context.ignored("HVDC Converter Station " + converter.getId(), "No correct linked HVDC line found."); converter.remove(); }); @@ -1072,8 +1105,6 @@ public boolean disconnectNetworkSideOfDanglingLinesIfBoundaryIsDisconnected() { private static final Logger LOG = LoggerFactory.getLogger(Conversion.class); - private static final String VOLTAGE_LEVEL = "VoltageLevel"; - public static final String NETWORK_PS_CGMES_MODEL_DETAIL = "CGMESModelDetail"; public static final String NETWORK_PS_CGMES_MODEL_DETAIL_BUS_BRANCH = "bus-branch"; public static final String NETWORK_PS_CGMES_MODEL_DETAIL_NODE_BREAKER = "node-breaker"; diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/SubstationIdMapping.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/SubstationIdMapping.java index ee32343f002..e1b46bcc55c 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/SubstationIdMapping.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/SubstationIdMapping.java @@ -225,6 +225,7 @@ private void buildVoltageLevel(Map> voltageLevelAdjacency) { } } if (!voltageLevelMapping.isEmpty()) { + CgmesReports.voltageLevelMappingReport(context.getReportNode(), voltageLevelMapping.size(), voltageLevelMapping.toString()); LOG.warn("Original {} VoltageLevel container(s) connected by switches have been merged in IIDM. Map of original VoltageLevel to IIDM: {}", voltageLevelMapping.size(), voltageLevelMapping); } @@ -240,6 +241,7 @@ private void buildSubstation(Map> substationAdjacency) { } } if (!substationMapping.isEmpty()) { + CgmesReports.substationMappingReport(context.getReportNode(), substationMapping.size(), substationMapping.toString()); LOG.warn("Original {} Substation container(s) connected by transformers have been merged in IIDM. Map of original Substation to IIDM: {}", substationMapping.size(), substationMapping); } diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/BusbarSectionConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/BusbarSectionConversion.java index 4538681d0ac..7071d970495 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/BusbarSectionConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/BusbarSectionConversion.java @@ -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; @@ -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 diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/EnergyConsumerConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/EnergyConsumerConversion.java index 68e5b3faf05..099d0a6eb17 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/EnergyConsumerConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/EnergyConsumerConversion.java @@ -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; @@ -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"); } diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/EquivalentBranchConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/EquivalentBranchConversion.java index 23451b5a45a..08a187ba39c 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/EquivalentBranchConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/EquivalentBranchConversion.java @@ -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; @@ -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 diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/EquivalentShuntConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/EquivalentShuntConversion.java index 9831645dea8..9cb78963993 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/EquivalentShuntConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/EquivalentShuntConversion.java @@ -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; @@ -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 diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/ExternalNetworkInjectionConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/ExternalNetworkInjectionConversion.java index 23af2be6588..50f0507f676 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/ExternalNetworkInjectionConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/ExternalNetworkInjectionConversion.java @@ -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 } */ 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 @@ -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)); diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/GroundConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/GroundConversion.java index 182cdca67f6..a9e892b9d22 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/GroundConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/GroundConversion.java @@ -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; @@ -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 diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/OperationalLimitConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/OperationalLimitConversion.java index 01ddb9b76ce..a81322504bd 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/OperationalLimitConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/OperationalLimitConversion.java @@ -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; @@ -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"); diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/ShuntConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/ShuntConversion.java index 551a3061847..826bfcdbdf0 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/ShuntConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/ShuntConversion.java @@ -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) { diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/StaticVarCompensatorConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/StaticVarCompensatorConversion.java index f37c6368ece..3640007c29d 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/StaticVarCompensatorConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/StaticVarCompensatorConversion.java @@ -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; @@ -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 diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SubstationConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SubstationConversion.java index 1edcddcfde2..2d1a0d00760 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SubstationConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SubstationConversion.java @@ -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; @@ -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 diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SwitchConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SwitchConversion.java index dc6c528e858..60b3ef99b7b 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SwitchConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SwitchConversion.java @@ -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; @@ -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 diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SynchronousMachineConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SynchronousMachineConversion.java index 24b3e876ec7..9f44b011066 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SynchronousMachineConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SynchronousMachineConversion.java @@ -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; /** @@ -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"); } @@ -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.", "")); diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/VoltageLevelConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/VoltageLevelConversion.java index b42fbc072f4..167f707eff6 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/VoltageLevelConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/VoltageLevelConversion.java @@ -8,8 +8,10 @@ package com.powsybl.cgmes.conversion.elements; +import com.powsybl.cgmes.conversion.CgmesReports; 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; @@ -20,8 +22,9 @@ * @author Luma ZamarreƱo {@literal } */ 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); @@ -31,10 +34,12 @@ public VoltageLevelConversion(PropertyBag vl, Context context) { public boolean valid() { double nominalVoltage = p.asDouble("nominalVoltage"); if (nominalVoltage == 0) { + CgmesReports.nominalVoltageIsZeroReport(context.getReportNode(), id); ignored("Voltage level", () -> String.format("nominal voltage of %s is equal to 0", id)); return false; } if (substation == null) { + CgmesReports.missingMandatoryAttributeReport(context.getReportNode(), "Substation", CgmesNames.VOLTAGE_LEVEL, id); missing(String.format("Substation %s (IIDM id: %s)", cgmesSubstationId, iidmSubstationId)); diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/hvdc/AcDcConverterConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/hvdc/AcDcConverterConversion.java index e48bf6d16e2..449e0e99b11 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/hvdc/AcDcConverterConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/hvdc/AcDcConverterConversion.java @@ -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; @@ -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; diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/hvdc/DcLineSegmentConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/hvdc/DcLineSegmentConversion.java index b8d36190b7b..432a34c0fec 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/hvdc/DcLineSegmentConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/hvdc/DcLineSegmentConversion.java @@ -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); diff --git a/cgmes/cgmes-conversion/src/test/resources/functional-logs/microGridBaseCaseBE-invalid-voltage-bus.txt b/cgmes/cgmes-conversion/src/test/resources/functional-logs/microGridBaseCaseBE-invalid-voltage-bus.txt index 508a7edd6b4..ba2c1eafac1 100644 --- a/cgmes/cgmes-conversion/src/test/resources/functional-logs/microGridBaseCaseBE-invalid-voltage-bus.txt +++ b/cgmes/cgmes-conversion/src/test/resources/functional-logs/microGridBaseCaseBE-invalid-voltage-bus.txt @@ -7,7 +7,37 @@ Instance file MicroGridTestConfiguration_BC_BE_SV_V2.xml Instance file MicroGridTestConfiguration_BC_BE_SSH_V2.xml + Importing CGMES file(s) - Node e44141af-f1dc-44d3-bfa4-b674e5c953d7 in substation PP_Brussels, voltageLevel 380.0, bus e44141af-f1dc-44d3-bfa4-b674e5c953d7 has invalid value for voltage and/or angle. Voltage magnitude is 0.0, angle is 0.0 - Equipment 955d9cd0-4a10-4031-b008-60c0dc340a07 has a regulating control with bad target value for voltage: 0.0 - Equipment fe25f43a-7341-446e-a71a-8ab7119ba806 has a regulating control with bad target value for voltage: 0.0 + Applying preprocessors. + Building mappings. + Converting Substation. + Converting VoltageLevel. + + Converting TopologicalNode. + Node e44141af-f1dc-44d3-bfa4-b674e5c953d7 in substation PP_Brussels, voltageLevel 380.0, bus e44141af-f1dc-44d3-bfa4-b674e5c953d7 has invalid value for voltage and/or angle. Voltage magnitude is 0.0, angle is 0.0. + Converting BusbarSection. + Converting Ground. + Converting EnergyConsumer. + Converting EnergySource. + Converting EquivalentInjection. + Converting ExternalNetworkInjection. + Converting ShuntCompensator. + Converting EquivalentShunt. + Converting StaticVarCompensator. + Converting AsynchronousMachine. + Converting SynchronousMachine. + Converting Switch. + Converting ACLineSegment. + Converting EquivalentBranch. + Converting SeriesCompensator. + Converting PowerTransformer. + Converting equipments at boundaries. + Converting DC network. + Converting OperationalLimit. + Converting SvInjection. + Converting ControlArea. + + Converting RegulatingControl. + Equipment 955d9cd0-4a10-4031-b008-60c0dc340a07 has a regulating control with bad target value for voltage: 0.0. + Equipment fe25f43a-7341-446e-a71a-8ab7119ba806 has a regulating control with bad target value for voltage: 0.0. + Fixing issues with dangling lines. + Setting voltages and angles. + Applying postprocessors. CGMES network urn:uuid:d400c631-75a0-4c30-8aed-832b0d282e73 is imported. diff --git a/cgmes/cgmes-conversion/src/test/resources/functional-logs/microGridBaseCaseBE-target-deadband.txt b/cgmes/cgmes-conversion/src/test/resources/functional-logs/microGridBaseCaseBE-target-deadband.txt index 8c37f9aad3d..d81410a9eda 100644 --- a/cgmes/cgmes-conversion/src/test/resources/functional-logs/microGridBaseCaseBE-target-deadband.txt +++ b/cgmes/cgmes-conversion/src/test/resources/functional-logs/microGridBaseCaseBE-target-deadband.txt @@ -6,8 +6,38 @@ Instance file MicroGridTestConfiguration_BC_BE_EQ_V2.xml Instance file MicroGridTestConfiguration_BC_BE_SSH_V2.xml + Importing CGMES file(s) - Equipment 955d9cd0-4a10-4031-b008-60c0dc340a07 has a regulating control with bad target value for voltage: 0.0 - Equipment 955d9cd0-4a10-4031-b008-60c0dc340a07 has a regulating control with bad target deadband: -0.5 - Equipment 6ebbef67-3061-4236-a6fd-6ccc4595f6c3 has a regulating control with bad target deadband: -35.0 - Equipment fe25f43a-7341-446e-a71a-8ab7119ba806 has a regulating control with bad target value for voltage: 0.0 + Applying preprocessors. + Building mappings. + Converting Substation. + Converting VoltageLevel. + Converting TopologicalNode. + Converting BusbarSection. + Converting Ground. + Converting EnergyConsumer. + Converting EnergySource. + Converting EquivalentInjection. + Converting ExternalNetworkInjection. + Converting ShuntCompensator. + Converting EquivalentShunt. + Converting StaticVarCompensator. + Converting AsynchronousMachine. + Converting SynchronousMachine. + Converting Switch. + Converting ACLineSegment. + Converting EquivalentBranch. + Converting SeriesCompensator. + Converting PowerTransformer. + Converting equipments at boundaries. + Converting DC network. + Converting OperationalLimit. + Converting SvInjection. + Converting ControlArea. + + Converting RegulatingControl. + Equipment 955d9cd0-4a10-4031-b008-60c0dc340a07 has a regulating control with bad target value for voltage: 0.0. + Equipment 955d9cd0-4a10-4031-b008-60c0dc340a07 has a regulating control with bad target deadband: -0.5. + Equipment 6ebbef67-3061-4236-a6fd-6ccc4595f6c3 has a regulating control with bad target deadband: -35.0. + Equipment fe25f43a-7341-446e-a71a-8ab7119ba806 has a regulating control with bad target value for voltage: 0.0. + Fixing issues with dangling lines. + Setting voltages and angles. + Applying postprocessors. CGMES network urn:uuid:d400c631-75a0-4c30-8aed-832b0d282e73 is imported. diff --git a/cgmes/cgmes-conversion/src/test/resources/functional-logs/microGridBaseCaseBE.txt b/cgmes/cgmes-conversion/src/test/resources/functional-logs/microGridBaseCaseBE.txt index 8fa229ce210..178ad6e4db5 100644 --- a/cgmes/cgmes-conversion/src/test/resources/functional-logs/microGridBaseCaseBE.txt +++ b/cgmes/cgmes-conversion/src/test/resources/functional-logs/microGridBaseCaseBE.txt @@ -10,6 +10,36 @@ Instance file MicroGridTestConfiguration_BC_BE_SSH_V2.xml Instance file MicroGridTestConfiguration_BC_BE_DY_V2.xml + Importing CGMES file(s) - Equipment 955d9cd0-4a10-4031-b008-60c0dc340a07 has a regulating control with bad target value for voltage: 0.0 - Equipment fe25f43a-7341-446e-a71a-8ab7119ba806 has a regulating control with bad target value for voltage: 0.0 + Applying preprocessors. + Building mappings. + Converting Substation. + Converting VoltageLevel. + Converting TopologicalNode. + Converting BusbarSection. + Converting Ground. + Converting EnergyConsumer. + Converting EnergySource. + Converting EquivalentInjection. + Converting ExternalNetworkInjection. + Converting ShuntCompensator. + Converting EquivalentShunt. + Converting StaticVarCompensator. + Converting AsynchronousMachine. + Converting SynchronousMachine. + Converting Switch. + Converting ACLineSegment. + Converting EquivalentBranch. + Converting SeriesCompensator. + Converting PowerTransformer. + Converting equipments at boundaries. + Converting DC network. + Converting OperationalLimit. + Converting SvInjection. + Converting ControlArea. + + Converting RegulatingControl. + Equipment 955d9cd0-4a10-4031-b008-60c0dc340a07 has a regulating control with bad target value for voltage: 0.0. + Equipment fe25f43a-7341-446e-a71a-8ab7119ba806 has a regulating control with bad target value for voltage: 0.0. + Fixing issues with dangling lines. + Setting voltages and angles. + Applying postprocessors. CGMES network urn:uuid:d400c631-75a0-4c30-8aed-832b0d282e73 is imported. diff --git a/cgmes/cgmes-conversion/src/test/resources/functional-logs/miniGridNodeBreaker.txt b/cgmes/cgmes-conversion/src/test/resources/functional-logs/miniGridNodeBreaker.txt index 244ba75ce15..153490be383 100644 --- a/cgmes/cgmes-conversion/src/test/resources/functional-logs/miniGridNodeBreaker.txt +++ b/cgmes/cgmes-conversion/src/test/resources/functional-logs/miniGridNodeBreaker.txt @@ -7,6 +7,36 @@ Instance file MiniGridTestConfiguration_BC_SV_v3.0.0.xml Instance file MiniGridTestConfiguration_BC_TP_v3.0.0.xml + Importing CGMES file(s) - Node 183d126d-2522-4ff2-a8cd-c5016cf09c1b has invalid value for voltage and/or angle. Voltage magnitude is 0.0, angle is 0.0 - Node 49831d24-33e9-4233-8424-3f88186a924e has invalid value for voltage and/or angle. Voltage magnitude is 0.0, angle is 0.0 + Applying preprocessors. + Building mappings. + Converting Substation. + Converting VoltageLevel. + Converting ConnectivityNode. + Converting BusbarSection. + Converting Ground. + Converting EnergyConsumer. + Converting EnergySource. + Converting EquivalentInjection. + Converting ExternalNetworkInjection. + Converting ShuntCompensator. + Converting EquivalentShunt. + Converting StaticVarCompensator. + Converting AsynchronousMachine. + Converting SynchronousMachine. + Converting Switch. + Converting ACLineSegment. + Converting EquivalentBranch. + Converting SeriesCompensator. + Converting PowerTransformer. + Converting equipments at boundaries. + Converting DC network. + Converting OperationalLimit. + Converting SvInjection. + Converting ControlArea. + Converting RegulatingControl. + Fixing issues with dangling lines. + + Setting voltages and angles. + Node 183d126d-2522-4ff2-a8cd-c5016cf09c1b has invalid value for voltage and/or angle. Voltage magnitude is 0.0, angle is 0.0. + Node 49831d24-33e9-4233-8424-3f88186a924e has invalid value for voltage and/or angle. Voltage magnitude is 0.0, angle is 0.0. + Applying postprocessors. CGMES network urn:uuid:239ecbd2-9a39-11e0-aa80-0800200c9a66 is imported. diff --git a/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/CgmesModel.java b/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/CgmesModel.java index 78adf4c0ec1..84057f5c4e1 100644 --- a/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/CgmesModel.java +++ b/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/CgmesModel.java @@ -130,6 +130,12 @@ default PropertyBags synchronousMachinesCondensers() { return new PropertyBags(); } + default PropertyBags synchronousMachinesAll() { + PropertyBags p = new PropertyBags(synchronousMachinesGenerators()); + p.addAll(synchronousMachinesCondensers()); + return p; + } + PropertyBags equivalentInjections(); PropertyBags externalNetworkInjections(); diff --git a/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/CgmesNames.java b/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/CgmesNames.java index 43dd42986da..fa0776dacd6 100644 --- a/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/CgmesNames.java +++ b/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/CgmesNames.java @@ -107,6 +107,14 @@ public final class CgmesNames { public static final Set SWITCH_TYPES = Set.of(SWITCH, "Breaker", "Disconnector", "LoadBreakSwitch", "ProtectedSwitch", "GroundDisconnector"); + public static final String BUSBAR_SECTION = "BusbarSection"; + public static final String GROUND = "Ground"; + public static final String SHUNT_COMPENSATOR = "ShuntCompensator"; + public static final String EQUIVALENT_SHUNT = "EquivalentShunt"; + public static final String EQUIVALENT_BRANCH = "EquivalentBranch"; + public static final String STATIC_VAR_COMPENSATOR = "StaticVarCompensator"; + public static final String REGULATING_CONTROL = "RegulatingControl"; + public static final String CONTROL_AREA = "ControlArea"; public static final String CONFORM_LOAD = "ConformLoad"; public static final String NONCONFORM_LOAD = "NonConformLoad"; public static final String ENERGY_CONSUMER = "EnergyConsumer"; @@ -117,6 +125,8 @@ public final class CgmesNames { public static final String SV_INJECTION = "SvInjection"; public static final String CONFORM_LOAD_GROUP = "ConformLoadGroup"; public static final String NONCONFORM_LOAD_GROUP = "NonConformLoadGroup"; + public static final String ACDC_CONVERTER = "ACDCConverter"; + public static final String DC_LINE_SEGMENT = "DCLineSegment"; public static final String CONNECTIVITY_NODE_BOUNDARY = "ConnectivityNode_Boundary"; public static final String TOPOLOGICAL_NODE_BOUNDARY = "TopologicalNode_Boundary"; @@ -129,6 +139,8 @@ public final class CgmesNames { public static final String EQUIVALENT_INJECTION_TERMINAL = "EquivalentInjectionTerminal"; public static final String EXTERNAL_NETWORK_INJECTION = "ExternalNetworkInjection"; + public static final String OPERATIONAL_LIMIT = "OperationalLimit"; + private CgmesNames() { } }