From 8396236220a1ab4745d34cf51fa4ce64e894bfd2 Mon Sep 17 00:00:00 2001 From: Lisrte Date: Thu, 23 Nov 2023 13:51:50 +0100 Subject: [PATCH] Add a reporter to dynamic simulation and its models suppliers (#300) * Use reporter instead of logger in DSL instantiation * Replace dynawaltz logger with reporter * Add dynamic model ID to instantiation logs Signed-off-by: lisrte --- .../AbstractEquipmentGroovyExtension.groovy | 17 +- .../AbstractPureDynamicGroovyExtension.groovy | 13 +- ...tractSimpleEquipmentGroovyExtension.groovy | 17 +- .../powsybl/dynawaltz/dsl/DslEquipment.groovy | 8 +- .../dsl/DynaWaltzCurveGroovyExtension.groovy | 5 +- .../powsybl/dynawaltz/dsl/Reporters.groovy | 111 ++++++++++++ .../AbstractPhaseShifterModelBuilder.groovy | 7 +- ...urrentLimitAutomatonGroovyExtension.groovy | 21 ++- ...itTwoLevelsAutomatonGroovyExtension.groovy | 17 +- ...aseShifterIAutomatonGroovyExtension.groovy | 9 +- ...aseShifterPAutomatonGroovyExtension.groovy | 9 +- .../TapChangerAutomatonGroovyExtension.groovy | 11 +- ...gerBlockingAutomatonGroovyExtension.groovy | 20 ++- ...nderVoltageAutomatonGroovyExtension.groovy | 11 +- .../AbstractDynamicModelBuilder.groovy | 18 +- .../AbstractEquipmentModelBuilder.groovy | 15 +- .../builders/AbstractEventModelBuilder.groovy | 15 +- .../AbstractPureDynamicModelBuilder.groovy | 14 +- ...ActivePowerVariationGroovyExtension.groovy | 16 +- .../EventDisconnectionGroovyExtension.groovy | 19 ++- .../NodeFaultEventGroovyExtension.groovy | 16 +- .../models/buses/AbstractBusBuilder.groovy | 5 +- .../models/buses/BusGroovyExtension.groovy | 12 +- .../buses/InfiniteBusGroovyExtension.groovy | 12 +- .../AbstractGeneratorBuilder.groovy | 5 +- .../GeneratorFictitiousGroovyExtension.groovy | 12 +- ...GridFormingConverterGroovyExtension.groovy | 12 +- ...ynchronizedGeneratorGroovyExtension.groovy | 12 +- ...SynchronousGeneratorGroovyExtension.groovy | 12 +- .../generators/WeccGenGroovyExtension.groovy | 12 +- .../models/hvdc/AbstractHvdcBuilder.groovy | 10 +- .../models/hvdc/HvdcPGroovyExtension.groovy | 12 +- .../models/hvdc/HvdcVscGroovyExtension.groovy | 12 +- .../models/lines/LineGroovyExtension.groovy | 12 +- .../loads/AbstractLoadModelBuilder.groovy | 5 +- .../loads/BaseLoadGroovyExtension.groovy | 12 +- .../LoadOneTransformerGroovyExtension.groovy | 12 +- ...ransformerTapChangerGroovyExtension.groovy | 12 +- .../LoadTwoTransformersGroovyExtension.groovy | 12 +- ...nsformersTapChangersGroovyExtension.groovy | 12 +- .../models/svarcs/SvarcGroovyExtension.groovy | 12 +- ...ransformerFixedRatioGroovyExtension.groovy | 12 +- .../dsl/AbstractModelSupplierTest.java | 14 ++ .../dsl/DynamicModelsSupplierTest.java | 158 +++++++++++++++--- .../dsl/EventModelsSupplierTest.java | 61 ++++++- .../dynawaltz/dsl/ieee/AbstractIeeeTest.java | 5 +- .../eventWarnings/missingAPVParameters.groovy | 2 +- .../powsybl/dynawaltz/DynaWaltzContext.java | 25 ++- .../powsybl/dynawaltz/DynaWaltzProvider.java | 12 +- .../powsybl/dynawaltz/DynawaltzReports.java | 71 ++++++++ .../automatons/TapChangerAutomaton.java | 7 +- .../TapChangerBlockingAutomaton.java | 6 +- .../models/events/AbstractEvent.java | 4 +- .../dynawaltz/DynaWaltzProviderTest.java | 11 +- .../ieee14/disconnectline/eventModels.groovy | 2 +- 55 files changed, 710 insertions(+), 286 deletions(-) create mode 100644 dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/Reporters.groovy create mode 100644 dynawaltz/src/main/java/com/powsybl/dynawaltz/DynawaltzReports.java diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/AbstractEquipmentGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/AbstractEquipmentGroovyExtension.groovy index 16caa0de9..c28430e5b 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/AbstractEquipmentGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/AbstractEquipmentGroovyExtension.groovy @@ -7,14 +7,18 @@ */ package com.powsybl.dynawaltz.dsl +import com.powsybl.commons.reporter.Reporter +import com.powsybl.dynamicsimulation.DynamicModel +import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.DynaWaltzProvider import com.powsybl.iidm.network.Network import java.util.function.Consumer + /** * @author Laurent Issertial {@literal } */ -abstract class AbstractEquipmentGroovyExtension { +abstract class AbstractEquipmentGroovyExtension implements DynamicModelGroovyExtension { protected static final String MODELS_CONFIG = "models.json" @@ -28,21 +32,26 @@ abstract class AbstractEquipmentGroovyExtension { equipmentConfigs = ModelsSlurper.instance.getEquipmentConfigs(modelConfigUrl, modelTag) } - abstract protected ModelBuilder createBuilder(Network network, EquipmentConfig equipmentConfig) + abstract protected ModelBuilder createBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) + @Override String getName() { DynaWaltzProvider.NAME } + @Override List getModelNames() { equipmentConfigs.collect(eq -> eq.lib) } - void load(Binding binding, Consumer consumer) { + @Override + void load(Binding binding, Consumer consumer, Reporter reporter) { equipmentConfigs.forEach { binding.setVariable(it.lib, { Closure closure -> def cloned = closure.clone() - ModelBuilder builder = createBuilder(binding.getVariable("network") as Network, it) + ModelBuilder builder = createBuilder(binding.getVariable("network") as Network, + it, + Reporters.createModelBuilderReporter(reporter, it.lib)) cloned.delegate = builder cloned() builder.build()?.tap { diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/AbstractPureDynamicGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/AbstractPureDynamicGroovyExtension.groovy index 493a2ba46..b0658bf45 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/AbstractPureDynamicGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/AbstractPureDynamicGroovyExtension.groovy @@ -7,6 +7,8 @@ */ package com.powsybl.dynawaltz.dsl +import com.powsybl.commons.reporter.Reporter +import com.powsybl.dynamicsimulation.groovy.GroovyExtension import com.powsybl.dynawaltz.DynaWaltzProvider import com.powsybl.iidm.network.Network @@ -16,12 +18,13 @@ import java.util.function.Consumer * Superclass for automaton & event groovy extensions * @author Laurent Issertial {@literal } */ -abstract class AbstractPureDynamicGroovyExtension { +abstract class AbstractPureDynamicGroovyExtension implements GroovyExtension { protected List modelTags - abstract protected ModelBuilder createBuilder(Network network) + abstract protected ModelBuilder createBuilder(Network network, Reporter reporter) + @Override String getName() { DynaWaltzProvider.NAME } @@ -30,11 +33,13 @@ abstract class AbstractPureDynamicGroovyExtension { modelTags } - void load(Binding binding, Consumer consumer) { + @Override + void load(Binding binding, Consumer consumer, Reporter reporter) { modelTags.forEach { binding.setVariable(it, { Closure closure -> def cloned = closure.clone() - ModelBuilder builder = createBuilder(binding.getVariable("network") as Network) + ModelBuilder builder = createBuilder(binding.getVariable("network") as Network, + Reporters.createModelBuilderReporter(reporter, it)) cloned.delegate = builder cloned() builder.build()?.tap { diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/AbstractSimpleEquipmentGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/AbstractSimpleEquipmentGroovyExtension.groovy index 4c5eed638..f24e36ed0 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/AbstractSimpleEquipmentGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/AbstractSimpleEquipmentGroovyExtension.groovy @@ -7,6 +7,9 @@ */ package com.powsybl.dynawaltz.dsl +import com.powsybl.commons.reporter.Reporter +import com.powsybl.dynamicsimulation.DynamicModel +import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.DynaWaltzProvider import com.powsybl.iidm.network.Network @@ -15,7 +18,7 @@ import java.util.function.Consumer /** * @author Laurent Issertial {@literal } */ -abstract class AbstractSimpleEquipmentGroovyExtension { +abstract class AbstractSimpleEquipmentGroovyExtension implements DynamicModelGroovyExtension { protected EquipmentConfig equipmentConfig @@ -23,21 +26,25 @@ abstract class AbstractSimpleEquipmentGroovyExtension { equipmentConfig = new EquipmentConfig(modelTag) } + abstract protected ModelBuilder createBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) - abstract protected ModelBuilder createBuilder(Network network, EquipmentConfig equipmentConfig) - + @Override String getName() { DynaWaltzProvider.NAME } + @Override List getModelNames() { List.of(equipmentConfig.lib) } - void load(Binding binding, Consumer consumer) { + @Override + void load(Binding binding, Consumer consumer, Reporter reporter) { binding.setVariable(equipmentConfig.lib, { Closure closure -> def cloned = closure.clone() - ModelBuilder builder = createBuilder(binding.getVariable("network") as Network, equipmentConfig) + ModelBuilder builder = createBuilder(binding.getVariable("network") as Network, + equipmentConfig, + Reporters.createModelBuilderReporter(reporter, equipmentConfig.lib)) cloned.delegate = builder cloned() builder.build()?.tap { diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DslEquipment.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DslEquipment.groovy index a6046e488..c45e322ce 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DslEquipment.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DslEquipment.groovy @@ -7,9 +7,9 @@ */ package com.powsybl.dynawaltz.dsl +import com.powsybl.commons.reporter.Reporter import com.powsybl.iidm.network.Identifiable import com.powsybl.iidm.network.IdentifiableType -import org.slf4j.Logger import java.util.function.Function @@ -48,12 +48,12 @@ class DslEquipment { equipment = equipmentSupplier(staticId) } - boolean checkEquipmentData(Logger logger, String lib) { + boolean checkEquipmentData(Reporter reporter) { if (!staticId) { - logger.warn("$lib: '$fieldName' field is not set") + Reporters.reportFieldNotSet(reporter, fieldName) return false } else if (!equipment) { - logger.warn("$lib: $equipmentType static id unknown : $staticId") + Reporters.reportStaticIdUnknown(reporter, fieldName, staticId, equipmentType) return false } true diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DynaWaltzCurveGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DynaWaltzCurveGroovyExtension.groovy index 717166fcd..63f698aba 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DynaWaltzCurveGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DynaWaltzCurveGroovyExtension.groovy @@ -7,6 +7,7 @@ package com.powsybl.dynawaltz.dsl import com.google.auto.service.AutoService +import com.powsybl.commons.reporter.Reporter import com.powsybl.dsl.DslException import com.powsybl.dynamicsimulation.Curve import com.powsybl.dynamicsimulation.groovy.CurveGroovyExtension @@ -51,6 +52,7 @@ class DynaWaltzCurveGroovyExtension implements CurveGroovyExtension { } } + @Override String getName() { DynaWaltzProvider.NAME } @@ -76,7 +78,8 @@ class DynaWaltzCurveGroovyExtension implements CurveGroovyExtension { } } - void load(Binding binding, Consumer consumer) { + @Override + void load(Binding binding, Consumer consumer, Reporter reporter) { binding.curve = { Closure closure -> def cloned = closure.clone() CurvesSpec curveSpec = new CurvesSpec() diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/Reporters.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/Reporters.groovy new file mode 100644 index 000000000..8828e3961 --- /dev/null +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/Reporters.groovy @@ -0,0 +1,111 @@ +/** + * Copyright (c) 2023, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * SPDX-License-Identifier: MPL-2.0 + */ +package com.powsybl.dynawaltz.dsl + +import com.powsybl.commons.reporter.Report +import com.powsybl.commons.reporter.Reporter +import com.powsybl.commons.reporter.TypedValue +import com.powsybl.iidm.network.IdentifiableType + +/** + * @author Laurent Issertial + */ +final class Reporters { + + private Reporters() { + } + + static Reporter createModelBuilderReporter(Reporter reporter, String lib) { + reporter.createSubReporter("DSLModelBuilder", + 'DSL model builder for ${lib}', + "lib", lib) + } + + static void reportModelInstantiation(Reporter reporter, String dynamicId) { + reporter.report(Report.builder() + .withKey("modelInstantiation") + .withDefaultMessage('Model ${dynamicId} instantiation successful') + .withValue("dynamicId", dynamicId) + .withSeverity(TypedValue.TRACE_SEVERITY) + .build()) + } + + static void reportModelInstantiationFailure(Reporter reporter, String dynamicId) { + reporter.report(Report.builder() + .withKey("modelInstantiation") + .withDefaultMessage('Model ${dynamicId} cannot be instantiated') + .withValue("dynamicId", dynamicId) + .withSeverity(TypedValue.WARN_SEVERITY) + .build()) + } + + static void reportFieldReplacement(Reporter reporter, String fieldName, String replacementName, String replacement) { + reporter.report(Report.builder() + .withKey("fieldReplacement") + .withDefaultMessage('\'${fieldName}\' field is not set, ${replacementName} ${replacement} will be used instead') + .withValue("fieldName", fieldName) + .withValue("replacementName", replacementName) + .withValue("replacement", replacement) + .withSeverity(TypedValue.TRACE_SEVERITY) + .build()) + } + + static void reportFieldNotSet(Reporter reporter, String fieldName) { + reporter.report(Report.builder() + .withKey("fieldNotSet") + .withDefaultMessage('\'${fieldName}\' field is not set') + .withValue("fieldName", fieldName) + .withSeverity(TypedValue.WARN_SEVERITY) + .build()) + } + + static void reportStaticIdUnknown(Reporter reporter, String fieldName, String staticId, String equipmentType) { + reporter.report(Report.builder() + .withKey("fieldNotSet") + .withDefaultMessage('\'${fieldName}\' field value \'${staticId}\' not found for equipment type(s) ${equipmentType}') + .withValue("equipmentType", equipmentType) + .withValue("fieldName", fieldName) + .withValue("staticId", staticId) + .withSeverity(TypedValue.WARN_SEVERITY) + .build()) + } + + static void reportCrossThreshold(Reporter reporter, String fieldName, double fieldValue, String threshold) { + reporter.report(Report.builder() + .withKey("crossThreshold") + .withDefaultMessage('${fieldName} should be ${threshold} (${fieldValue})') + .withValue("fieldName", fieldName) + .withValue("fieldValue", fieldValue) + .withValue("threshold", threshold) + .withSeverity(TypedValue.WARN_SEVERITY) + .build()) + } + + static void reportEmptyList(Reporter reporter, String fieldName) { + reporter.report(Report.builder() + .withKey("emptyList") + .withDefaultMessage('\'${fieldName}\' list is empty') + .withValue("fieldName", fieldName) + .withSeverity(TypedValue.WARN_SEVERITY) + .build()) + } + + static void reportFieldSetWithWrongEquipment(Reporter reporter, String fieldName, IdentifiableType equipmentType, String staticId) { + reportFieldSetWithWrongEquipment(reporter, fieldName, equipmentType.toString() + " " + staticId) + } + + static void reportFieldSetWithWrongEquipment(Reporter reporter, String fieldName, String equipment) { + reporter.report(Report.builder() + .withKey("fieldSetWithWrongEquipment") + .withDefaultMessage('\'${fieldName}\' field is set but ${equipment} does not possess this option') + .withValue("fieldName", fieldName) + .withValue("equipment", equipment) + .withSeverity(TypedValue.WARN_SEVERITY) + .build()) + } +} diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/AbstractPhaseShifterModelBuilder.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/AbstractPhaseShifterModelBuilder.groovy index 686acbed4..766242183 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/AbstractPhaseShifterModelBuilder.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/AbstractPhaseShifterModelBuilder.groovy @@ -7,6 +7,7 @@ */ package com.powsybl.dynawaltz.dsl.automatons +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynawaltz.dsl.DslEquipment import com.powsybl.dynawaltz.dsl.builders.AbstractPureDynamicModelBuilder import com.powsybl.iidm.network.IdentifiableType @@ -20,8 +21,8 @@ abstract class AbstractPhaseShifterModelBuilder extends AbstractPureDynamicModel protected final DslEquipment dslTransformer - AbstractPhaseShifterModelBuilder(Network network, String lib) { - super(network, lib) + AbstractPhaseShifterModelBuilder(Network network, String lib, Reporter reporter) { + super(network, lib, reporter) dslTransformer = new DslEquipment<>(IdentifiableType.TWO_WINDINGS_TRANSFORMER, "transformer") } @@ -32,6 +33,6 @@ abstract class AbstractPhaseShifterModelBuilder extends AbstractPureDynamicModel @Override protected void checkData() { super.checkData() - isInstantiable &= dslTransformer.checkEquipmentData(LOGGER, getLib()) + isInstantiable &= dslTransformer.checkEquipmentData(reporter) } } diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/CurrentLimitAutomatonGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/CurrentLimitAutomatonGroovyExtension.groovy index a7edb0814..00439dd46 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/CurrentLimitAutomatonGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/CurrentLimitAutomatonGroovyExtension.groovy @@ -8,15 +8,18 @@ package com.powsybl.dynawaltz.dsl.automatons import com.google.auto.service.AutoService +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.DynamicModel import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractPureDynamicGroovyExtension import com.powsybl.dynawaltz.dsl.DslEquipment +import com.powsybl.dynawaltz.dsl.Reporters import com.powsybl.dynawaltz.dsl.builders.AbstractPureDynamicModelBuilder import com.powsybl.dynawaltz.models.Side import com.powsybl.dynawaltz.models.automatons.CurrentLimitAutomaton import com.powsybl.dynawaltz.models.utils.SideConverter import com.powsybl.iidm.network.Branch +import com.powsybl.iidm.network.IdentifiableType import com.powsybl.iidm.network.Network import com.powsybl.iidm.network.TwoSides @@ -33,8 +36,8 @@ class CurrentLimitAutomatonGroovyExtension extends AbstractPureDynamicGroovyExte } @Override - protected CurrentLimitAutomatonBuilder createBuilder(Network network) { - new CurrentLimitAutomatonBuilder(network, getLib()) + protected CurrentLimitAutomatonBuilder createBuilder(Network network, Reporter reporter) { + new CurrentLimitAutomatonBuilder(network, getLib(), reporter) } protected String getLib() { @@ -47,10 +50,10 @@ class CurrentLimitAutomatonGroovyExtension extends AbstractPureDynamicGroovyExte protected Side iMeasurementSide protected final DslEquipment controlledEquipment - CurrentLimitAutomatonBuilder(Network network, String lib) { - super(network, lib) - iMeasurement = new DslEquipment<>("I measurement quadripole", "iMeasurement") - controlledEquipment = new DslEquipment<>("Controlled quadripole", "controlledQuadripole") + CurrentLimitAutomatonBuilder(Network network, String lib, Reporter reporter) { + super(network, lib, reporter) + iMeasurement = new DslEquipment<>("Quadripole", "iMeasurement") + controlledEquipment = new DslEquipment<>("Quadripole", "controlledQuadripole") } void iMeasurement(String staticId) { @@ -68,10 +71,10 @@ class CurrentLimitAutomatonGroovyExtension extends AbstractPureDynamicGroovyExte @Override void checkData() { super.checkData() - isInstantiable &= controlledEquipment.checkEquipmentData(LOGGER, getLib()) - isInstantiable &= iMeasurement.checkEquipmentData(LOGGER, getLib()) + isInstantiable &= controlledEquipment.checkEquipmentData(reporter) + isInstantiable &= iMeasurement.checkEquipmentData(reporter) if (!iMeasurementSide) { - LOGGER.warn("${getLib()}: 'iMeasurementSide' field is not set") + Reporters.reportFieldNotSet(reporter, "iMeasurementSide") isInstantiable = false } } diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/CurrentLimitTwoLevelsAutomatonGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/CurrentLimitTwoLevelsAutomatonGroovyExtension.groovy index 387b384ea..56aa888cc 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/CurrentLimitTwoLevelsAutomatonGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/CurrentLimitTwoLevelsAutomatonGroovyExtension.groovy @@ -8,11 +8,12 @@ package com.powsybl.dynawaltz.dsl.automatons import com.google.auto.service.AutoService -import com.powsybl.dsl.DslException +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.DynamicModel import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractPureDynamicGroovyExtension import com.powsybl.dynawaltz.dsl.DslEquipment +import com.powsybl.dynawaltz.dsl.Reporters import com.powsybl.dynawaltz.models.Side import com.powsybl.dynawaltz.models.automatons.CurrentLimitTwoLevelsAutomaton import com.powsybl.dynawaltz.models.utils.SideConverter @@ -35,8 +36,8 @@ class CurrentLimitTwoLevelsAutomatonGroovyExtension extends AbstractPureDynamicG } @Override - protected CurrentLimitAutomatonTwoLevelBuilder createBuilder(Network network) { - new CurrentLimitAutomatonTwoLevelBuilder(network, getLib()) + protected CurrentLimitAutomatonTwoLevelBuilder createBuilder(Network network, Reporter reporter) { + new CurrentLimitAutomatonTwoLevelBuilder(network, getLib(), reporter) } static class CurrentLimitAutomatonTwoLevelBuilder extends CurrentLimitAutomatonGroovyExtension.CurrentLimitAutomatonBuilder { @@ -44,9 +45,9 @@ class CurrentLimitTwoLevelsAutomatonGroovyExtension extends AbstractPureDynamicG protected final DslEquipment iMeasurement2 protected Side iMeasurement2Side - CurrentLimitAutomatonTwoLevelBuilder(Network network, String lib) { - super(network, lib) - iMeasurement2 = new DslEquipment<>("I measurement 2 quadripole", "iMeasurement2") + CurrentLimitAutomatonTwoLevelBuilder(Network network, String lib, Reporter reporter) { + super(network, lib, reporter) + iMeasurement2 = new DslEquipment<>("Quadripole", "iMeasurement2") } void iMeasurement1(String staticId) { @@ -68,9 +69,9 @@ class CurrentLimitTwoLevelsAutomatonGroovyExtension extends AbstractPureDynamicG @Override void checkData() { super.checkData() - isInstantiable &= iMeasurement2.checkEquipmentData(LOGGER, getLib()) + isInstantiable &= iMeasurement2.checkEquipmentData(reporter) if (!iMeasurement2Side) { - LOGGER.warn("${getLib()}: 'iMeasurement2Side' field is not set") + Reporters.reportFieldNotSet(reporter, "iMeasurement2Side") isInstantiable = false } } diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/PhaseShifterIAutomatonGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/PhaseShifterIAutomatonGroovyExtension.groovy index 6a8614a68..a35512e94 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/PhaseShifterIAutomatonGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/PhaseShifterIAutomatonGroovyExtension.groovy @@ -8,6 +8,7 @@ package com.powsybl.dynawaltz.dsl.automatons import com.google.auto.service.AutoService +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.DynamicModel import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractPureDynamicGroovyExtension @@ -27,14 +28,14 @@ class PhaseShifterIAutomatonGroovyExtension extends AbstractPureDynamicGroovyExt } @Override - protected PhaseShifterPAutomatonBuilder createBuilder(Network network) { - new PhaseShifterPAutomatonBuilder(network, LIB) + protected PhaseShifterPAutomatonBuilder createBuilder(Network network, Reporter reporter) { + new PhaseShifterPAutomatonBuilder(network, LIB, reporter) } static class PhaseShifterPAutomatonBuilder extends AbstractPhaseShifterModelBuilder { - PhaseShifterPAutomatonBuilder(Network network, String lib) { - super(network, lib) + PhaseShifterPAutomatonBuilder(Network network, String lib, Reporter reporter) { + super(network, lib, reporter) } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/PhaseShifterPAutomatonGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/PhaseShifterPAutomatonGroovyExtension.groovy index 716d04875..e13c64ce3 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/PhaseShifterPAutomatonGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/PhaseShifterPAutomatonGroovyExtension.groovy @@ -8,6 +8,7 @@ package com.powsybl.dynawaltz.dsl.automatons import com.google.auto.service.AutoService +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.DynamicModel import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractPureDynamicGroovyExtension @@ -27,14 +28,14 @@ class PhaseShifterPAutomatonGroovyExtension extends AbstractPureDynamicGroovyExt } @Override - protected PhaseShifterPAutomatonBuilder createBuilder(Network network) { - new PhaseShifterPAutomatonBuilder(network, LIB) + protected PhaseShifterPAutomatonBuilder createBuilder(Network network, Reporter reporter) { + new PhaseShifterPAutomatonBuilder(network, LIB, reporter) } static class PhaseShifterPAutomatonBuilder extends AbstractPhaseShifterModelBuilder { - PhaseShifterPAutomatonBuilder(Network network, String lib) { - super(network, lib) + PhaseShifterPAutomatonBuilder(Network network, String lib, Reporter reporter) { + super(network, lib, reporter) } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/TapChangerAutomatonGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/TapChangerAutomatonGroovyExtension.groovy index 654da0b1e..d6afcc29e 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/TapChangerAutomatonGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/TapChangerAutomatonGroovyExtension.groovy @@ -8,6 +8,7 @@ package com.powsybl.dynawaltz.dsl.automatons import com.google.auto.service.AutoService +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.DynamicModel import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractPureDynamicGroovyExtension @@ -30,8 +31,8 @@ class TapChangerAutomatonGroovyExtension extends AbstractPureDynamicGroovyExtens } @Override - protected TapChangerAutomatonBuilder createBuilder(Network network) { - new TapChangerAutomatonBuilder(network, LIB) + protected TapChangerAutomatonBuilder createBuilder(Network network, Reporter reporter) { + new TapChangerAutomatonBuilder(network, LIB, reporter) } static class TapChangerAutomatonBuilder extends AbstractPureDynamicModelBuilder { @@ -39,8 +40,8 @@ class TapChangerAutomatonGroovyExtension extends AbstractPureDynamicGroovyExtens protected final DslEquipment dslLoad protected TransformerSide side = TransformerSide.NONE - TapChangerAutomatonBuilder(Network network, String lib) { - super(network, lib) + TapChangerAutomatonBuilder(Network network, String lib, Reporter reporter) { + super(network, lib, reporter) dslLoad = new DslEquipment<>(IdentifiableType.LOAD) } @@ -55,7 +56,7 @@ class TapChangerAutomatonGroovyExtension extends AbstractPureDynamicGroovyExtens @Override protected void checkData() { super.checkData() - isInstantiable &= dslLoad.checkEquipmentData(LOGGER, getLib()) + isInstantiable &= dslLoad.checkEquipmentData(reporter) } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/TapChangerBlockingAutomatonGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/TapChangerBlockingAutomatonGroovyExtension.groovy index 3cd89b287..376f81cf4 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/TapChangerBlockingAutomatonGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/TapChangerBlockingAutomatonGroovyExtension.groovy @@ -8,9 +8,11 @@ package com.powsybl.dynawaltz.dsl.automatons import com.google.auto.service.AutoService +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.DynamicModel import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractPureDynamicGroovyExtension +import com.powsybl.dynawaltz.dsl.Reporters import com.powsybl.dynawaltz.dsl.builders.AbstractPureDynamicModelBuilder import com.powsybl.dynawaltz.models.automatons.TapChangerBlockingAutomaton import com.powsybl.iidm.network.Bus @@ -33,8 +35,8 @@ class TapChangerBlockingAutomatonGroovyExtension extends AbstractPureDynamicGroo } @Override - protected TCBAutomatonBuilder createBuilder(Network network) { - new TCBAutomatonBuilder(network, LIB) + protected TCBAutomatonBuilder createBuilder(Network network, Reporter reporter) { + new TCBAutomatonBuilder(network, LIB, reporter) } static class TCBAutomatonBuilder extends AbstractPureDynamicModelBuilder { @@ -44,8 +46,8 @@ class TapChangerBlockingAutomatonGroovyExtension extends AbstractPureDynamicGroo List uMeasurements = [] List tapChangerAutomatonIds = [] - TCBAutomatonBuilder(Network network, String lib) { - super(network, lib) + TCBAutomatonBuilder(Network network, String lib, Reporter reporter) { + super(network, lib, reporter) } void transformers(String[] staticIds) { @@ -69,7 +71,7 @@ class TapChangerBlockingAutomatonGroovyExtension extends AbstractPureDynamicGroo Identifiable checkEquipment(String staticId) { network.getIdentifiable(staticId)?.tap { if (!TapChangerBlockingAutomaton.isCompatibleEquipment(type)) { - LOGGER.warn("${getLib()}: $type $staticId is not compatible") + Reporters.reportStaticIdUnknown(reporter, "uMeasurements", staticId, "LOAD/TWO_WINDINGS_TRANSFORMER") } } } @@ -78,7 +80,7 @@ class TapChangerBlockingAutomatonGroovyExtension extends AbstractPureDynamicGroo uMeasurements = staticIds.collect { def bus = network.busBreakerView.getBus(it) if (!bus) { - LOGGER.warn("${getLib()}: $IdentifiableType.BUS static id unknown : $it") + Reporters.reportStaticIdUnknown(reporter, "uMeasurements", it, IdentifiableType.BUS.toString()) } bus } @@ -87,17 +89,17 @@ class TapChangerBlockingAutomatonGroovyExtension extends AbstractPureDynamicGroo @Override protected void checkData() { if (!uMeasurements) { - LOGGER.warn("${getLib()}: 'uMeasurements' field is not set") + Reporters.reportFieldNotSet(reporter, "uMeasurements") isInstantiable = false } else { uMeasurements -= null if (!uMeasurements) { - LOGGER.warn("${getLib()}: 'uMeasurements' is empty") + Reporters.reportEmptyList(reporter, "uMeasurements") isInstantiable = false } } if(!loads && !transformers && !tapChangerAutomatonIds) { - LOGGER.warn("${getLib()}: 'transformers' field is empty") + Reporters.reportEmptyList(reporter, "transformers") isInstantiable = false } } diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/UnderVoltageAutomatonGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/UnderVoltageAutomatonGroovyExtension.groovy index b9e83c6fa..52d90a182 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/UnderVoltageAutomatonGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/automatons/UnderVoltageAutomatonGroovyExtension.groovy @@ -8,6 +8,7 @@ package com.powsybl.dynawaltz.dsl.automatons import com.google.auto.service.AutoService +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.DynamicModel import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractPureDynamicGroovyExtension @@ -31,16 +32,16 @@ class UnderVoltageAutomatonGroovyExtension extends AbstractPureDynamicGroovyExte } @Override - protected UnderVoltageAutomatonBuilder createBuilder(Network network) { - new UnderVoltageAutomatonBuilder(network, LIB) + protected UnderVoltageAutomatonBuilder createBuilder(Network network, Reporter reporter) { + new UnderVoltageAutomatonBuilder(network, LIB, reporter) } static class UnderVoltageAutomatonBuilder extends AbstractPureDynamicModelBuilder { protected final DslEquipment dslGenerator - UnderVoltageAutomatonBuilder(Network network, String lib) { - super(network, lib) + UnderVoltageAutomatonBuilder(Network network, String lib, Reporter reporter) { + super(network, lib, reporter) dslGenerator = new DslEquipment<>(IdentifiableType.GENERATOR, "generator") } @@ -51,7 +52,7 @@ class UnderVoltageAutomatonGroovyExtension extends AbstractPureDynamicGroovyExte @Override protected void checkData() { super.checkData() - isInstantiable &= dslGenerator.checkEquipmentData(LOGGER, getLib()) + isInstantiable &= dslGenerator.checkEquipmentData(reporter) } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/builders/AbstractDynamicModelBuilder.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/builders/AbstractDynamicModelBuilder.groovy index 80f863af7..34074ddde 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/builders/AbstractDynamicModelBuilder.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/builders/AbstractDynamicModelBuilder.groovy @@ -7,32 +7,36 @@ */ package com.powsybl.dynawaltz.dsl.builders +import com.powsybl.commons.reporter.Reporter +import com.powsybl.dynawaltz.dsl.Reporters import com.powsybl.iidm.network.Network -import org.slf4j.Logger -import org.slf4j.LoggerFactory /** * @author Laurent Issertial {@literal } */ abstract class AbstractDynamicModelBuilder { - protected static final Logger LOGGER = LoggerFactory.getLogger("DynamicModelBuilder") - protected final Network network + protected final Reporter reporter protected boolean isInstantiable = true + protected AbstractDynamicModelBuilder(Network network, Reporter reporter) { + this.network = network + this.reporter = reporter + } + protected AbstractDynamicModelBuilder(Network network) { this.network = network + this.reporter = null } abstract protected void checkData() protected final boolean isInstantiable() { checkData() - isInstantiable ? LOGGER.debug("${getLib()} instanciation successful") - : LOGGER.warn("${getLib()} cannot be instantiated") + isInstantiable ? Reporters.reportModelInstantiation(reporter, getModelId()) : Reporters.reportModelInstantiationFailure(reporter, getModelId()) isInstantiable } - abstract protected String getLib() + abstract protected String getModelId() } diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/builders/AbstractEquipmentModelBuilder.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/builders/AbstractEquipmentModelBuilder.groovy index 89269a4b0..4008d0356 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/builders/AbstractEquipmentModelBuilder.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/builders/AbstractEquipmentModelBuilder.groovy @@ -7,10 +7,12 @@ */ package com.powsybl.dynawaltz.dsl.builders +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.DynamicModel import com.powsybl.dynawaltz.dsl.DslEquipment import com.powsybl.dynawaltz.dsl.EquipmentConfig import com.powsybl.dynawaltz.dsl.ModelBuilder +import com.powsybl.dynawaltz.dsl.Reporters import com.powsybl.iidm.network.Identifiable import com.powsybl.iidm.network.IdentifiableType import com.powsybl.iidm.network.Network @@ -25,8 +27,8 @@ abstract class AbstractEquipmentModelBuilder extends Abs protected final EquipmentConfig equipmentConfig protected final DslEquipment dslEquipment - protected AbstractEquipmentModelBuilder(Network network, EquipmentConfig equipmentConfig, IdentifiableType equipmentType) { - super(network) + protected AbstractEquipmentModelBuilder(Network network, EquipmentConfig equipmentConfig, IdentifiableType equipmentType, Reporter reporter) { + super(network, reporter) this.equipmentConfig = equipmentConfig this.dslEquipment = new DslEquipment(equipmentType) } @@ -45,12 +47,13 @@ abstract class AbstractEquipmentModelBuilder extends Abs @Override protected void checkData() { - isInstantiable = dslEquipment.checkEquipmentData(LOGGER, getLib()) + isInstantiable = dslEquipment.checkEquipmentData(reporter) if (!parameterSetId) { - LOGGER.warn("${getLib()}: 'parameterSetId' field is not set") + Reporters.reportFieldNotSet(reporter, "parameterSetId") isInstantiable = false } if (!dynamicModelId) { + Reporters.reportFieldReplacement(reporter, "dynamicModelId", "staticId", dslEquipment.staticId ?: "(unknown staticId)") dynamicModelId = dslEquipment.staticId } } @@ -62,8 +65,8 @@ abstract class AbstractEquipmentModelBuilder extends Abs } @Override - String getLib() { - equipmentConfig.getLib() + String getModelId() { + dynamicModelId ?: "unknownDynamicId" } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/builders/AbstractEventModelBuilder.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/builders/AbstractEventModelBuilder.groovy index 36ad3aeea..115e991ec 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/builders/AbstractEventModelBuilder.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/builders/AbstractEventModelBuilder.groovy @@ -8,9 +8,12 @@ package com.powsybl.dynawaltz.dsl.builders +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.EventModel import com.powsybl.dynawaltz.dsl.DslEquipment import com.powsybl.dynawaltz.dsl.ModelBuilder +import com.powsybl.dynawaltz.dsl.Reporters +import com.powsybl.dynawaltz.models.events.AbstractEvent import com.powsybl.iidm.network.Identifiable import com.powsybl.iidm.network.Network @@ -24,8 +27,8 @@ abstract class AbstractEventModelBuilder extends Abstrac protected String staticId protected double startTime - AbstractEventModelBuilder(Network network, DslEquipment dslEquipment, String tag) { - super(network) + AbstractEventModelBuilder(Network network, DslEquipment dslEquipment, String tag, Reporter reporter) { + super(network, reporter) this.dslEquipment = dslEquipment this.tag = tag } @@ -40,9 +43,9 @@ abstract class AbstractEventModelBuilder extends Abstrac @Override protected void checkData() { - isInstantiable &= dslEquipment.checkEquipmentData(LOGGER, getLib()) + isInstantiable &= dslEquipment.checkEquipmentData(reporter) if (!startTime) { - LOGGER.warn("${getLib()}: 'startTime' field is not set") + Reporters.reportFieldNotSet(reporter, "startTime") isInstantiable = false } } @@ -50,8 +53,8 @@ abstract class AbstractEventModelBuilder extends Abstrac abstract protected Identifiable findEquipment(String staticId) @Override - protected String getLib() { - tag + String getModelId() { + AbstractEvent.generateEventId(tag + "_", dslEquipment.staticId ?: "unknownStaticId") } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/builders/AbstractPureDynamicModelBuilder.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/builders/AbstractPureDynamicModelBuilder.groovy index 454d4ae02..866f4e69a 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/builders/AbstractPureDynamicModelBuilder.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/builders/AbstractPureDynamicModelBuilder.groovy @@ -7,8 +7,10 @@ */ package com.powsybl.dynawaltz.dsl.builders +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.DynamicModel import com.powsybl.dynawaltz.dsl.ModelBuilder +import com.powsybl.dynawaltz.dsl.Reporters import com.powsybl.iidm.network.Network /** @@ -21,8 +23,8 @@ abstract class AbstractPureDynamicModelBuilder extends AbstractDynamicModelBuild protected String parameterSetId protected final String lib - AbstractPureDynamicModelBuilder(Network network, String lib) { - super(network) + AbstractPureDynamicModelBuilder(Network network, String lib, Reporter reporter) { + super(network, reporter) this.lib = lib } @@ -37,18 +39,18 @@ abstract class AbstractPureDynamicModelBuilder extends AbstractDynamicModelBuild @Override protected void checkData() { if (!dynamicModelId) { - LOGGER.warn("${getLib()}: 'dynamicModelId' field is not set") + Reporters.reportFieldNotSet(reporter, "dynamicModelId") isInstantiable = false } if (!parameterSetId) { - LOGGER.warn("${getLib()}: 'parameterSetId' field is not set") + Reporters.reportFieldNotSet(reporter, "dynamicModelId") isInstantiable = false } } @Override - protected String getLib() { - lib + String getModelId() { + dynamicModelId ?: "unknownDynamicId" } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/EventActivePowerVariationGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/EventActivePowerVariationGroovyExtension.groovy index 038875a18..36cbae18c 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/EventActivePowerVariationGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/EventActivePowerVariationGroovyExtension.groovy @@ -8,10 +8,12 @@ package com.powsybl.dynawaltz.dsl.events import com.google.auto.service.AutoService +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.EventModel import com.powsybl.dynamicsimulation.groovy.EventModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractPureDynamicGroovyExtension import com.powsybl.dynawaltz.dsl.DslFilteredEquipment +import com.powsybl.dynawaltz.dsl.Reporters import com.powsybl.dynawaltz.dsl.builders.AbstractEventModelBuilder import com.powsybl.dynawaltz.models.events.EventActivePowerVariation import com.powsybl.iidm.network.Identifiable @@ -31,16 +33,16 @@ class EventActivePowerVariationGroovyExtension extends AbstractPureDynamicGroovy } @Override - protected EventAPVBuilder createBuilder(Network network) { - new EventAPVBuilder(network, TAG) + protected EventAPVBuilder createBuilder(Network network, Reporter reporter) { + new EventAPVBuilder(network, TAG, reporter) } static class EventAPVBuilder extends AbstractEventModelBuilder { protected double deltaP - EventAPVBuilder(Network network, String tag) { - super(network, new DslFilteredEquipment("Generator/Load", EventActivePowerVariation::isConnectable), tag) + EventAPVBuilder(Network network, String tag, Reporter reporter) { + super(network, new DslFilteredEquipment("GENERATOR/LOAD", EventActivePowerVariation::isConnectable), tag, reporter) } void deltaP(double deltaP) { @@ -49,12 +51,8 @@ class EventActivePowerVariationGroovyExtension extends AbstractPureDynamicGroovy void checkData() { super.checkData() - if (dslEquipment.equipment && !EventActivePowerVariation.isConnectable(dslEquipment.equipment.type)) { - LOGGER.warn("${getLib()}: ${dslEquipment.equipment?.type} ${dslEquipment.staticId} cannot be disconnected") - isInstantiable = false - } if (!deltaP) { - LOGGER.warn("${getLib()}: 'deltaP' field is not set") + Reporters.reportFieldNotSet(reporter, "deltaP") isInstantiable = false } } diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/EventDisconnectionGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/EventDisconnectionGroovyExtension.groovy index 0ec229aec..d9d8a3d2d 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/EventDisconnectionGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/EventDisconnectionGroovyExtension.groovy @@ -8,10 +8,12 @@ package com.powsybl.dynawaltz.dsl.events import com.google.auto.service.AutoService +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.EventModel import com.powsybl.dynamicsimulation.groovy.EventModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractPureDynamicGroovyExtension import com.powsybl.dynawaltz.dsl.DslEquipment +import com.powsybl.dynawaltz.dsl.Reporters import com.powsybl.dynawaltz.dsl.builders.AbstractEventModelBuilder import com.powsybl.dynawaltz.models.events.AbstractEvent import com.powsybl.dynawaltz.models.events.EventHvdcDisconnection @@ -36,8 +38,8 @@ class EventDisconnectionGroovyExtension extends AbstractPureDynamicGroovyExtensi } @Override - protected EventQuadripoleDisconnectionBuilder createBuilder(Network network) { - new EventQuadripoleDisconnectionBuilder(network, TAG) + protected EventQuadripoleDisconnectionBuilder createBuilder(Network network, Reporter reporter) { + new EventQuadripoleDisconnectionBuilder(network, TAG, reporter) } static class EventQuadripoleDisconnectionBuilder extends AbstractEventModelBuilder { @@ -50,8 +52,8 @@ class EventDisconnectionGroovyExtension extends AbstractPureDynamicGroovyExtensi private enum DisconnectionType {INJECTION, QUADRIPOLE, HVDC, NONE} - EventQuadripoleDisconnectionBuilder(Network network, String tag) { - super(network, new DslEquipment("Disconnectable equipment"), tag) + EventQuadripoleDisconnectionBuilder(Network network, String tag, Reporter reporter) { + super(network, new DslEquipment("Disconnectable equipment"), tag, reporter) } void disconnectOnly(TwoSides side) { @@ -70,20 +72,20 @@ class EventDisconnectionGroovyExtension extends AbstractPureDynamicGroovyExtensi void checkData() { super.checkData() - disconnectionType(dslEquipment?.equipment?.type) + setDisconnectionType(dslEquipment?.equipment?.type) if(dslEquipment.equipment) { if (disconnectionType == DisconnectionType.NONE) { - LOGGER.warn("${getLib()}: ${dslEquipment.equipment?.type} ${dslEquipment.staticId} cannot be disconnected") + Reporters.reportStaticIdUnknown(reporter, "staticId", dslEquipment.staticId, "Disconnectable equipment") isInstantiable = false } if (DisconnectionType.INJECTION == disconnectionType && disconnectSide) { - LOGGER.warn("'${getLib()}: disconnectSide' has been set but ${dslEquipment.equipment?.type} ${dslEquipment.staticId} is not a quadripole with a disconnectable side") + Reporters.reportFieldSetWithWrongEquipment(reporter, "disconnectSide", dslEquipment.equipment?.type, dslEquipment.staticId) isInstantiable = false } } } - boolean disconnectionType(IdentifiableType type) { + void setDisconnectionType(IdentifiableType type) { if (type) { if (CONNECTABLE_INJECTIONS.contains(type)) { disconnectionType = DisconnectionType.INJECTION @@ -93,7 +95,6 @@ class EventDisconnectionGroovyExtension extends AbstractPureDynamicGroovyExtensi disconnectionType = DisconnectionType.HVDC } } - disconnectionType != DisconnectionType.NONE } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/NodeFaultEventGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/NodeFaultEventGroovyExtension.groovy index 31c4e6a5c..f839f869c 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/NodeFaultEventGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/NodeFaultEventGroovyExtension.groovy @@ -8,10 +8,12 @@ package com.powsybl.dynawaltz.dsl.events import com.google.auto.service.AutoService +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.EventModel import com.powsybl.dynamicsimulation.groovy.EventModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractPureDynamicGroovyExtension import com.powsybl.dynawaltz.dsl.DslEquipment +import com.powsybl.dynawaltz.dsl.Reporters import com.powsybl.dynawaltz.dsl.builders.AbstractEventModelBuilder import com.powsybl.dynawaltz.models.events.NodeFaultEvent import com.powsybl.iidm.network.Bus @@ -31,8 +33,8 @@ class NodeFaultEventGroovyExtension extends AbstractPureDynamicGroovyExtension { @@ -41,8 +43,8 @@ class NodeFaultEventGroovyExtension extends AbstractPureDynamicGroovyExtension(IdentifiableType.BUS), tag) + NodeFaultEventBuilder(Network network,String tag, Reporter reporter) { + super(network, new DslEquipment(IdentifiableType.BUS), tag, reporter) } void faultTime(double faultTime) { @@ -65,15 +67,15 @@ class NodeFaultEventGroovyExtension extends AbstractPureDynamicGroovyExtension { - AbstractBusBuilder(Network network, EquipmentConfig equipmentConfig) { - super(network, equipmentConfig, IdentifiableType.BUS) + AbstractBusBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + super(network, equipmentConfig, IdentifiableType.BUS, reporter) } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/buses/BusGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/buses/BusGroovyExtension.groovy index 971ef9e90..1e3c3efa0 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/buses/BusGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/buses/BusGroovyExtension.groovy @@ -8,7 +8,7 @@ package com.powsybl.dynawaltz.dsl.models.buses import com.google.auto.service.AutoService -import com.powsybl.dynamicsimulation.DynamicModel +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractSimpleEquipmentGroovyExtension import com.powsybl.dynawaltz.dsl.EquipmentConfig @@ -21,21 +21,21 @@ import com.powsybl.iidm.network.Network * @author Dimitri Baudrier {@literal } */ @AutoService(DynamicModelGroovyExtension.class) -class BusGroovyExtension extends AbstractSimpleEquipmentGroovyExtension implements DynamicModelGroovyExtension { +class BusGroovyExtension extends AbstractSimpleEquipmentGroovyExtension { BusGroovyExtension() { super("Bus") } @Override - protected BusBuilder createBuilder(Network network, EquipmentConfig equipmentConfig) { - new BusBuilder(network, equipmentConfig) + protected BusBuilder createBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + new BusBuilder(network, equipmentConfig, reporter) } static class BusBuilder extends AbstractBusBuilder { - BusBuilder(Network network, EquipmentConfig equipmentConfig) { - super(network, equipmentConfig) + BusBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + super(network, equipmentConfig, reporter) } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/buses/InfiniteBusGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/buses/InfiniteBusGroovyExtension.groovy index 1db7922d4..9964d19a0 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/buses/InfiniteBusGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/buses/InfiniteBusGroovyExtension.groovy @@ -8,7 +8,7 @@ package com.powsybl.dynawaltz.dsl.models.buses import com.google.auto.service.AutoService -import com.powsybl.dynamicsimulation.DynamicModel +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractEquipmentGroovyExtension import com.powsybl.dynawaltz.dsl.EquipmentConfig @@ -19,7 +19,7 @@ import com.powsybl.iidm.network.Network * @author Laurent Issertial {@literal } */ @AutoService(DynamicModelGroovyExtension.class) -class InfiniteBusGroovyExtension extends AbstractEquipmentGroovyExtension implements DynamicModelGroovyExtension { +class InfiniteBusGroovyExtension extends AbstractEquipmentGroovyExtension { protected static final String BUSES = "infiniteBuses" @@ -28,14 +28,14 @@ class InfiniteBusGroovyExtension extends AbstractEquipmentGroovyExtension { - AbstractGeneratorBuilder(Network network, EquipmentConfig equipmentConfig) { - super(network, equipmentConfig, IdentifiableType.GENERATOR) + AbstractGeneratorBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + super(network, equipmentConfig, IdentifiableType.GENERATOR, reporter) } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/GeneratorFictitiousGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/GeneratorFictitiousGroovyExtension.groovy index 0cbec26c8..c0a34a798 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/GeneratorFictitiousGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/GeneratorFictitiousGroovyExtension.groovy @@ -7,7 +7,7 @@ package com.powsybl.dynawaltz.dsl.models.generators import com.google.auto.service.AutoService -import com.powsybl.dynamicsimulation.DynamicModel +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractSimpleEquipmentGroovyExtension import com.powsybl.dynawaltz.dsl.EquipmentConfig @@ -18,21 +18,21 @@ import com.powsybl.iidm.network.Network * @author Dimitri Baudrier {@literal } */ @AutoService(DynamicModelGroovyExtension.class) -class GeneratorFictitiousGroovyExtension extends AbstractSimpleEquipmentGroovyExtension implements DynamicModelGroovyExtension { +class GeneratorFictitiousGroovyExtension extends AbstractSimpleEquipmentGroovyExtension { GeneratorFictitiousGroovyExtension() { super("GeneratorFictitious") } @Override - protected GeneratorFictitiousBuilder createBuilder(Network network, EquipmentConfig equipmentConfig) { - new GeneratorFictitiousBuilder(network, equipmentConfig) + protected GeneratorFictitiousBuilder createBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + new GeneratorFictitiousBuilder(network, equipmentConfig, reporter) } static class GeneratorFictitiousBuilder extends AbstractGeneratorBuilder { - GeneratorFictitiousBuilder(Network network, EquipmentConfig equipmentConfig) { - super(network, equipmentConfig) + GeneratorFictitiousBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + super(network, equipmentConfig, reporter) } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/GridFormingConverterGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/GridFormingConverterGroovyExtension.groovy index 082f80e51..dc376c2a8 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/GridFormingConverterGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/GridFormingConverterGroovyExtension.groovy @@ -8,7 +8,7 @@ package com.powsybl.dynawaltz.dsl.models.generators import com.google.auto.service.AutoService -import com.powsybl.dynamicsimulation.DynamicModel +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractEquipmentGroovyExtension import com.powsybl.dynawaltz.dsl.EquipmentConfig @@ -19,7 +19,7 @@ import com.powsybl.iidm.network.Network * @author Laurent Issertial {@literal } */ @AutoService(DynamicModelGroovyExtension.class) -class GridFormingConverterGroovyExtension extends AbstractEquipmentGroovyExtension implements DynamicModelGroovyExtension { +class GridFormingConverterGroovyExtension extends AbstractEquipmentGroovyExtension { private static final String GRID_FORMING_CONVERTER = "gridFormingConverter" @@ -28,14 +28,14 @@ class GridFormingConverterGroovyExtension extends AbstractEquipmentGroovyExtensi } @Override - protected GridFormingConverterBuilder createBuilder(Network network, EquipmentConfig equipmentConfig) { - new GridFormingConverterBuilder(network, equipmentConfig) + protected GridFormingConverterBuilder createBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + new GridFormingConverterBuilder(network, equipmentConfig, reporter) } static class GridFormingConverterBuilder extends AbstractGeneratorBuilder { - GridFormingConverterBuilder(Network network, EquipmentConfig equipmentConfig) { - super(network, equipmentConfig) + GridFormingConverterBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + super(network, equipmentConfig, reporter) } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/SynchronizedGeneratorGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/SynchronizedGeneratorGroovyExtension.groovy index ab9e5c0a7..899277d45 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/SynchronizedGeneratorGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/SynchronizedGeneratorGroovyExtension.groovy @@ -8,7 +8,7 @@ package com.powsybl.dynawaltz.dsl.models.generators import com.google.auto.service.AutoService -import com.powsybl.dynamicsimulation.DynamicModel +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractEquipmentGroovyExtension import com.powsybl.dynawaltz.dsl.EquipmentConfig @@ -21,7 +21,7 @@ import com.powsybl.iidm.network.Network * @author Dimitri Baudrier {@literal } */ @AutoService(DynamicModelGroovyExtension.class) -class SynchronizedGeneratorGroovyExtension extends AbstractEquipmentGroovyExtension implements DynamicModelGroovyExtension { +class SynchronizedGeneratorGroovyExtension extends AbstractEquipmentGroovyExtension { private static final String SYNCHRONIZED_GENERATORS = "synchronizedGenerators" @@ -34,14 +34,14 @@ class SynchronizedGeneratorGroovyExtension extends AbstractEquipmentGroovyExtens } @Override - protected SynchronizedGeneratorBuilder createBuilder(Network network, EquipmentConfig equipmentConfig) { - new SynchronizedGeneratorBuilder(network, equipmentConfig) + protected SynchronizedGeneratorBuilder createBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + new SynchronizedGeneratorBuilder(network, equipmentConfig, reporter) } static class SynchronizedGeneratorBuilder extends AbstractGeneratorBuilder { - SynchronizedGeneratorBuilder(Network network, EquipmentConfig equipmentConfig) { - super(network, equipmentConfig) + SynchronizedGeneratorBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + super(network, equipmentConfig, reporter) } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/SynchronousGeneratorGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/SynchronousGeneratorGroovyExtension.groovy index 132920b2d..7b094e7c4 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/SynchronousGeneratorGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/SynchronousGeneratorGroovyExtension.groovy @@ -7,8 +7,8 @@ package com.powsybl.dynawaltz.dsl.models.generators import com.google.auto.service.AutoService +import com.powsybl.commons.reporter.Reporter import com.powsybl.dsl.DslException -import com.powsybl.dynamicsimulation.DynamicModel import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractEquipmentGroovyExtension import com.powsybl.dynawaltz.dsl.EquipmentConfig @@ -21,7 +21,7 @@ import com.powsybl.iidm.network.Network * @author Marcos de Miguel {@literal } */ @AutoService(DynamicModelGroovyExtension.class) -class SynchronousGeneratorGroovyExtension extends AbstractEquipmentGroovyExtension implements DynamicModelGroovyExtension { +class SynchronousGeneratorGroovyExtension extends AbstractEquipmentGroovyExtension { protected static final String SYNCHRONOUS_GENERATORS = "synchronousGenerators" @@ -34,14 +34,14 @@ class SynchronousGeneratorGroovyExtension extends AbstractEquipmentGroovyExtensi } @Override - protected SynchronousGeneratorBuilder createBuilder(Network network, EquipmentConfig equipmentConfig) { - new SynchronousGeneratorBuilder(network, equipmentConfig) + protected SynchronousGeneratorBuilder createBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + new SynchronousGeneratorBuilder(network, equipmentConfig, reporter) } static class SynchronousGeneratorBuilder extends AbstractGeneratorBuilder { - SynchronousGeneratorBuilder(Network network, EquipmentConfig equipmentConfig) { - super(network, equipmentConfig) + SynchronousGeneratorBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + super(network, equipmentConfig, reporter) } protected EnumGeneratorComponent getGeneratorComponent() { diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/WeccGenGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/WeccGenGroovyExtension.groovy index fed1d3bca..9a30a019a 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/WeccGenGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/WeccGenGroovyExtension.groovy @@ -8,7 +8,7 @@ package com.powsybl.dynawaltz.dsl.models.generators import com.google.auto.service.AutoService -import com.powsybl.dynamicsimulation.DynamicModel +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractEquipmentGroovyExtension import com.powsybl.dynawaltz.dsl.EquipmentConfig @@ -20,7 +20,7 @@ import com.powsybl.iidm.network.Network * @author Laurent Issertial {@literal } */ @AutoService(DynamicModelGroovyExtension.class) -class WeccGenGroovyExtension extends AbstractEquipmentGroovyExtension implements DynamicModelGroovyExtension { +class WeccGenGroovyExtension extends AbstractEquipmentGroovyExtension { private static final String WECC = "wecc" @@ -29,14 +29,14 @@ class WeccGenGroovyExtension extends AbstractEquipmentGroovyExtension} */ @AutoService(DynamicModelGroovyExtension.class) -class HvdcPGroovyExtension extends AbstractEquipmentGroovyExtension implements DynamicModelGroovyExtension { +class HvdcPGroovyExtension extends AbstractEquipmentGroovyExtension { protected static final String HVDC_P = "hvdcP" @@ -33,14 +33,14 @@ class HvdcPGroovyExtension extends AbstractEquipmentGroovyExtension} */ @AutoService(DynamicModelGroovyExtension.class) -class HvdcVscGroovyExtension extends AbstractEquipmentGroovyExtension implements DynamicModelGroovyExtension { +class HvdcVscGroovyExtension extends AbstractEquipmentGroovyExtension { protected static final String HVDC_VSC = "hvdcVsc" @@ -29,14 +29,14 @@ class HvdcVscGroovyExtension extends AbstractEquipmentGroovyExtension} */ @AutoService(DynamicModelGroovyExtension.class) -class LineGroovyExtension extends AbstractSimpleEquipmentGroovyExtension implements DynamicModelGroovyExtension { +class LineGroovyExtension extends AbstractSimpleEquipmentGroovyExtension { LineGroovyExtension() { super("Line") } @Override - protected LineBuilder createBuilder(Network network, EquipmentConfig equipmentConfig) { - new LineBuilder(network, equipmentConfig) + protected LineBuilder createBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + new LineBuilder(network, equipmentConfig, reporter) } static class LineBuilder extends AbstractEquipmentModelBuilder { - LineBuilder(Network network, EquipmentConfig equipmentConfig) { - super(network, equipmentConfig, IdentifiableType.LINE) + LineBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + super(network, equipmentConfig, IdentifiableType.LINE, reporter) } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/AbstractLoadModelBuilder.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/AbstractLoadModelBuilder.groovy index b34399cf4..c6abe1649 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/AbstractLoadModelBuilder.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/AbstractLoadModelBuilder.groovy @@ -7,6 +7,7 @@ */ package com.powsybl.dynawaltz.dsl.models.loads +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynawaltz.dsl.EquipmentConfig import com.powsybl.dynawaltz.dsl.builders.AbstractEquipmentModelBuilder import com.powsybl.iidm.network.IdentifiableType @@ -18,8 +19,8 @@ import com.powsybl.iidm.network.Network */ abstract class AbstractLoadModelBuilder extends AbstractEquipmentModelBuilder { - AbstractLoadModelBuilder(Network network, EquipmentConfig equipmentConfig) { - super(network, equipmentConfig, IdentifiableType.LOAD) + AbstractLoadModelBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + super(network, equipmentConfig, IdentifiableType.LOAD, reporter) } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/BaseLoadGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/BaseLoadGroovyExtension.groovy index a80a6168e..b7a69a1de 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/BaseLoadGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/BaseLoadGroovyExtension.groovy @@ -7,7 +7,7 @@ package com.powsybl.dynawaltz.dsl.models.loads import com.google.auto.service.AutoService -import com.powsybl.dynamicsimulation.DynamicModel +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractEquipmentGroovyExtension import com.powsybl.dynawaltz.dsl.EquipmentConfig @@ -21,7 +21,7 @@ import com.powsybl.iidm.network.Network * @author Marcos de Miguel {@literal } */ @AutoService(DynamicModelGroovyExtension.class) -class BaseLoadGroovyExtension extends AbstractEquipmentGroovyExtension implements DynamicModelGroovyExtension { +class BaseLoadGroovyExtension extends AbstractEquipmentGroovyExtension { private static final String LOADS = "baseLoads" @@ -30,14 +30,14 @@ class BaseLoadGroovyExtension extends AbstractEquipmentGroovyExtension} */ @AutoService(DynamicModelGroovyExtension.class) -class LoadOneTransformerGroovyExtension extends AbstractSimpleEquipmentGroovyExtension implements DynamicModelGroovyExtension { +class LoadOneTransformerGroovyExtension extends AbstractSimpleEquipmentGroovyExtension { LoadOneTransformerGroovyExtension() { super("LoadOneTransformer") } @Override - protected LoadOneTransformerBuilder createBuilder(Network network, EquipmentConfig equipmentConfig) { - new LoadOneTransformerBuilder(network, equipmentConfig) + protected LoadOneTransformerBuilder createBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + new LoadOneTransformerBuilder(network, equipmentConfig, reporter) } static class LoadOneTransformerBuilder extends AbstractLoadModelBuilder { - LoadOneTransformerBuilder(Network network, EquipmentConfig equipmentConfig) { - super(network, equipmentConfig) + LoadOneTransformerBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + super(network, equipmentConfig, reporter) } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadOneTransformerTapChangerGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadOneTransformerTapChangerGroovyExtension.groovy index 96660215b..e0d01d9a8 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadOneTransformerTapChangerGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadOneTransformerTapChangerGroovyExtension.groovy @@ -8,7 +8,7 @@ package com.powsybl.dynawaltz.dsl.models.loads import com.google.auto.service.AutoService -import com.powsybl.dynamicsimulation.DynamicModel +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractSimpleEquipmentGroovyExtension import com.powsybl.dynawaltz.dsl.EquipmentConfig @@ -19,21 +19,21 @@ import com.powsybl.iidm.network.Network * @author Laurent Issertial {@literal } */ @AutoService(DynamicModelGroovyExtension.class) -class LoadOneTransformerTapChangerGroovyExtension extends AbstractSimpleEquipmentGroovyExtension implements DynamicModelGroovyExtension { +class LoadOneTransformerTapChangerGroovyExtension extends AbstractSimpleEquipmentGroovyExtension { LoadOneTransformerTapChangerGroovyExtension() { super("LoadOneTransformerTapChanger") } @Override - protected LoadOneTransformerTapChangerBuilder createBuilder(Network network, EquipmentConfig equipmentConfig) { - new LoadOneTransformerTapChangerBuilder(network, equipmentConfig) + protected LoadOneTransformerTapChangerBuilder createBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + new LoadOneTransformerTapChangerBuilder(network, equipmentConfig, reporter) } static class LoadOneTransformerTapChangerBuilder extends AbstractLoadModelBuilder { - LoadOneTransformerTapChangerBuilder(Network network, EquipmentConfig equipmentConfig) { - super(network, equipmentConfig) + LoadOneTransformerTapChangerBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + super(network, equipmentConfig, reporter) } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadTwoTransformersGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadTwoTransformersGroovyExtension.groovy index 5d0e7a758..bd85b2aaf 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadTwoTransformersGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadTwoTransformersGroovyExtension.groovy @@ -8,7 +8,7 @@ package com.powsybl.dynawaltz.dsl.models.loads import com.google.auto.service.AutoService -import com.powsybl.dynamicsimulation.DynamicModel +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractSimpleEquipmentGroovyExtension import com.powsybl.dynawaltz.dsl.EquipmentConfig @@ -19,21 +19,21 @@ import com.powsybl.iidm.network.Network * @author Laurent Issertial {@literal } */ @AutoService(DynamicModelGroovyExtension.class) -class LoadTwoTransformersGroovyExtension extends AbstractSimpleEquipmentGroovyExtension implements DynamicModelGroovyExtension { +class LoadTwoTransformersGroovyExtension extends AbstractSimpleEquipmentGroovyExtension { LoadTwoTransformersGroovyExtension() { super("LoadTwoTransformers") } @Override - protected LoadTwoTransformersBuilder createBuilder(Network network, EquipmentConfig equipmentConfig) { - new LoadTwoTransformersBuilder(network, equipmentConfig) + protected LoadTwoTransformersBuilder createBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + new LoadTwoTransformersBuilder(network, equipmentConfig, reporter) } static class LoadTwoTransformersBuilder extends AbstractLoadModelBuilder { - LoadTwoTransformersBuilder(Network network, EquipmentConfig equipmentConfig) { - super(network, equipmentConfig) + LoadTwoTransformersBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + super(network, equipmentConfig, reporter) } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadTwoTransformersTapChangersGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadTwoTransformersTapChangersGroovyExtension.groovy index 642db1859..18bf77353 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadTwoTransformersTapChangersGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadTwoTransformersTapChangersGroovyExtension.groovy @@ -8,7 +8,7 @@ package com.powsybl.dynawaltz.dsl.models.loads import com.google.auto.service.AutoService -import com.powsybl.dynamicsimulation.DynamicModel +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractSimpleEquipmentGroovyExtension import com.powsybl.dynawaltz.dsl.EquipmentConfig @@ -19,21 +19,21 @@ import com.powsybl.iidm.network.Network * @author Laurent Issertial {@literal } */ @AutoService(DynamicModelGroovyExtension.class) -class LoadTwoTransformersTapChangersGroovyExtension extends AbstractSimpleEquipmentGroovyExtension implements DynamicModelGroovyExtension { +class LoadTwoTransformersTapChangersGroovyExtension extends AbstractSimpleEquipmentGroovyExtension { LoadTwoTransformersTapChangersGroovyExtension() { super("LoadTwoTransformersTapChangers") } @Override - protected LoadTwoTransformersTapChangersBuilder createBuilder(Network network, EquipmentConfig equipmentConfig) { - new LoadTwoTransformersTapChangersBuilder(network, equipmentConfig) + protected LoadTwoTransformersTapChangersBuilder createBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + new LoadTwoTransformersTapChangersBuilder(network, equipmentConfig, reporter) } static class LoadTwoTransformersTapChangersBuilder extends AbstractLoadModelBuilder { - LoadTwoTransformersTapChangersBuilder(Network network, EquipmentConfig equipmentConfig) { - super(network, equipmentConfig) + LoadTwoTransformersTapChangersBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + super(network, equipmentConfig, reporter) } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/svarcs/SvarcGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/svarcs/SvarcGroovyExtension.groovy index ae11ab92f..dab946e13 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/svarcs/SvarcGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/svarcs/SvarcGroovyExtension.groovy @@ -8,7 +8,7 @@ package com.powsybl.dynawaltz.dsl.models.svarcs import com.google.auto.service.AutoService -import com.powsybl.dynamicsimulation.DynamicModel +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.builders.AbstractEquipmentModelBuilder import com.powsybl.dynawaltz.models.svarcs.StaticVarCompensator as DynamicSvarc @@ -22,7 +22,7 @@ import com.powsybl.iidm.network.StaticVarCompensator as StaticSvarc * @author Laurent Issertial {@literal } */ @AutoService(DynamicModelGroovyExtension.class) -class SvarcGroovyExtension extends AbstractEquipmentGroovyExtension implements DynamicModelGroovyExtension { +class SvarcGroovyExtension extends AbstractEquipmentGroovyExtension { protected static final String SVARC = "staticVarCompensators" @@ -31,14 +31,14 @@ class SvarcGroovyExtension extends AbstractEquipmentGroovyExtension { - SvcBuilder(Network network, EquipmentConfig equipmentConfig) { - super(network, equipmentConfig, IdentifiableType.STATIC_VAR_COMPENSATOR) + SvcBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + super(network, equipmentConfig, IdentifiableType.STATIC_VAR_COMPENSATOR, reporter) } @Override diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/transformers/TransformerFixedRatioGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/transformers/TransformerFixedRatioGroovyExtension.groovy index 84c4e0288..9e67b4a3a 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/transformers/TransformerFixedRatioGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/transformers/TransformerFixedRatioGroovyExtension.groovy @@ -8,7 +8,7 @@ package com.powsybl.dynawaltz.dsl.models.transformers import com.google.auto.service.AutoService -import com.powsybl.dynamicsimulation.DynamicModel +import com.powsybl.commons.reporter.Reporter import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension import com.powsybl.dynawaltz.dsl.AbstractEquipmentGroovyExtension import com.powsybl.dynawaltz.dsl.EquipmentConfig @@ -22,7 +22,7 @@ import com.powsybl.iidm.network.TwoWindingsTransformer * @author Laurent Issertial {@literal } */ @AutoService(DynamicModelGroovyExtension.class) -class TransformerFixedRatioGroovyExtension extends AbstractEquipmentGroovyExtension implements DynamicModelGroovyExtension { +class TransformerFixedRatioGroovyExtension extends AbstractEquipmentGroovyExtension { private static final String TRANSFORMERS = "transformers" @@ -31,14 +31,14 @@ class TransformerFixedRatioGroovyExtension extends AbstractEquipmentGroovyExtens } @Override - protected TransformerBuilder createBuilder(Network network, EquipmentConfig equipmentConfig) { - new TransformerBuilder(network, equipmentConfig) + protected TransformerBuilder createBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + new TransformerBuilder(network, equipmentConfig, reporter) } static class TransformerBuilder extends AbstractEquipmentModelBuilder { - TransformerBuilder(Network network, EquipmentConfig equipmentConfig) { - super(network, equipmentConfig, IdentifiableType.TWO_WINDINGS_TRANSFORMER) + TransformerBuilder(Network network, EquipmentConfig equipmentConfig, Reporter reporter) { + super(network, equipmentConfig, IdentifiableType.TWO_WINDINGS_TRANSFORMER, reporter) } @Override diff --git a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/AbstractModelSupplierTest.java b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/AbstractModelSupplierTest.java index efafba9a6..7776a7b20 100644 --- a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/AbstractModelSupplierTest.java +++ b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/AbstractModelSupplierTest.java @@ -7,15 +7,29 @@ */ package com.powsybl.dynawaltz.dsl; +import com.powsybl.commons.reporter.ReporterModel; +import com.powsybl.commons.test.TestUtil; + import java.io.InputStream; +import java.io.StringWriter; import java.util.Objects; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * @author Laurent Issertial {@literal } */ abstract class AbstractModelSupplierTest { + protected final ReporterModel reporter = new ReporterModel("dslTests", "DSL tests"); + protected InputStream getResourceAsStream(String name) { return Objects.requireNonNull(AbstractModelSupplierTest.class.getResourceAsStream(name)); } + + protected void checkReporter(String report) { + StringWriter sw = new StringWriter(); + reporter.export(sw); + assertEquals(report, TestUtil.normalizeLineSeparator(sw.toString())); + } } diff --git a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynamicModelsSupplierTest.java b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynamicModelsSupplierTest.java index 1241f0cd5..063ce9a59 100644 --- a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynamicModelsSupplierTest.java +++ b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynamicModelsSupplierTest.java @@ -74,19 +74,22 @@ void testAutomatonDynamicModels(String groovyScriptName, Class modelClass, Network network, String terminalVarName) { + void testGeneratorPrefixes(String groovyScriptName, Class modelClass, Network network, String terminalVarName, String report) { DynamicModelsSupplier supplier = new GroovyDynamicModelsSupplier(getResourceAsStream(groovyScriptName), EXTENSIONS); - List dynamicModels = supplier.get(network); + List dynamicModels = supplier.get(network, reporter); assertEquals(1, dynamicModels.size()); assertTrue(modelClass.isInstance(dynamicModels.get(0))); assertEquals(terminalVarName, modelClass.cast(dynamicModels.get(0)).getTerminalVarName()); + checkReporter(report); + } void assertEquipmentBlackBoxModel(EquipmentBlackBoxModel bbm, String dynamicId, String staticId, String parameterId, String lib) { @@ -144,27 +147,142 @@ private static Stream provideAutomatonModelData() { private static Stream provideWarningsModel() { return Stream.of( - Arguments.of("/warnings/missingStaticId.groovy", EurostagTutorialExample1Factory.create()), - Arguments.of("/warnings/missingParameterId.groovy", EurostagTutorialExample1Factory.create()), - Arguments.of("/warnings/missingEquipment.groovy", EurostagTutorialExample1Factory.create()), - Arguments.of("/warnings/missingDangling.groovy", HvdcTestNetwork.createVsc()), - Arguments.of("/warnings/missingDanglingProperty.groovy", HvdcTestNetwork.createVsc()), - Arguments.of("/warnings/underVoltageMissingGenerator.groovy", EurostagTutorialExample1Factory.create()), - Arguments.of("/warnings/phaseShifterMissingTransformer.groovy", EurostagTutorialExample1Factory.create()), - Arguments.of("/warnings/claMissingMeasurement.groovy", EurostagTutorialExample1Factory.create()), - Arguments.of("/warnings/claMissingMeasurementSide.groovy", EurostagTutorialExample1Factory.create()), - Arguments.of("/warnings/claMissingControlled.groovy", EurostagTutorialExample1Factory.create()), - Arguments.of("/warnings/cla2MissingMeasurement2.groovy", EurostagTutorialExample1Factory.create()), - Arguments.of("/warnings/cla2MissingMeasurementSide2.groovy", EurostagTutorialExample1Factory.create()), - Arguments.of("/warnings/tapChangerMissingBus.groovy", EurostagTutorialExample1Factory.create()), - Arguments.of("/warnings/tapChangerCompatible.groovy", EurostagTutorialExample1Factory.create()) + Arguments.of("/warnings/missingStaticId.groovy", EurostagTutorialExample1Factory.create(), + """ + + DSL tests + + Groovy Dynamic Models Supplier + + DSL model builder for LoadAlphaBeta + 'staticId' field is not set + 'dynamicModelId' field is not set, staticId (unknown staticId) will be used instead + Model unknownDynamicId cannot be instantiated + """), + Arguments.of("/warnings/missingParameterId.groovy", EurostagTutorialExample1Factory.create(), + """ + + DSL tests + + Groovy Dynamic Models Supplier + + DSL model builder for LoadAlphaBeta + 'parameterSetId' field is not set + 'dynamicModelId' field is not set, staticId LOAD will be used instead + Model LOAD cannot be instantiated + """), + Arguments.of("/warnings/missingEquipment.groovy", EurostagTutorialExample1Factory.create(), + """ + + DSL tests + + Groovy Dynamic Models Supplier + + DSL model builder for LoadAlphaBeta + 'staticId' field value 'GEN' not found for equipment type(s) LOAD + 'dynamicModelId' field is not set, staticId GEN will be used instead + Model GEN cannot be instantiated + """), + Arguments.of("/warnings/missingDangling.groovy", HvdcTestNetwork.createVsc(), + """ + + DSL tests + + Groovy Dynamic Models Supplier + + DSL model builder for HvdcPVDangling + 'dangling' field is not set + Model BBM_HVDC_L cannot be instantiated + """), + Arguments.of("/warnings/missingDanglingProperty.groovy", HvdcTestNetwork.createVsc(), + """ + + DSL tests + + Groovy Dynamic Models Supplier + + DSL model builder for HvdcPV + 'dangling' field is set but HvdcPV does not possess this option + Model BBM_HVDC_L cannot be instantiated + """), + Arguments.of("/warnings/underVoltageMissingGenerator.groovy", EurostagTutorialExample1Factory.create(), + """ + + DSL tests + + Groovy Dynamic Models Supplier + + DSL model builder for UnderVoltage + 'generator' field value 'NGEN' not found for equipment type(s) GENERATOR + Model UV_GEN cannot be instantiated + """), + Arguments.of("/warnings/phaseShifterMissingTransformer.groovy", EurostagTutorialExample1Factory.create(), + """ + + DSL tests + + Groovy Dynamic Models Supplier + + DSL model builder for PhaseShifterI + 'transformer' field value 'NGEN' not found for equipment type(s) TWO_WINDINGS_TRANSFORMER + Model PS_NGEN_NHV1 cannot be instantiated + """), + Arguments.of("/warnings/claMissingMeasurement.groovy", EurostagTutorialExample1Factory.create(), + """ + + DSL tests + + Groovy Dynamic Models Supplier + + DSL model builder for CurrentLimitAutomaton + 'iMeasurement' field value 'NGEN' not found for equipment type(s) Quadripole + Model CLA_NGEN cannot be instantiated + """), + Arguments.of("/warnings/claMissingMeasurementSide.groovy", EurostagTutorialExample1Factory.create(), + """ + + DSL tests + + Groovy Dynamic Models Supplier + + DSL model builder for CurrentLimitAutomaton + 'iMeasurementSide' field is not set + Model CLA_NGEN cannot be instantiated + """), + Arguments.of("/warnings/claMissingControlled.groovy", EurostagTutorialExample1Factory.create(), + """ + + DSL tests + + Groovy Dynamic Models Supplier + + DSL model builder for CurrentLimitAutomaton + 'controlledQuadripole' field value 'GEN' not found for equipment type(s) Quadripole + Model CLA_NGEN cannot be instantiated + """), + Arguments.of("/warnings/cla2MissingMeasurement2.groovy", EurostagTutorialExample1Factory.create(), + """ + + DSL tests + + Groovy Dynamic Models Supplier + + DSL model builder for CurrentLimitAutomatonTwoLevels + 'iMeasurement2' field value 'NGEN' not found for equipment type(s) Quadripole + Model CLA_NGEN cannot be instantiated + """), + Arguments.of("/warnings/cla2MissingMeasurementSide2.groovy", EurostagTutorialExample1Factory.create(), + """ + + DSL tests + + Groovy Dynamic Models Supplier + + DSL model builder for CurrentLimitAutomatonTwoLevels + 'iMeasurement2Side' field is not set + Model CLA_NGEN cannot be instantiated + """), + Arguments.of("/warnings/tapChangerMissingBus.groovy", EurostagTutorialExample1Factory.create(), + """ + + DSL tests + + Groovy Dynamic Models Supplier + + DSL model builder for TapChangerBlockingAutomaton + 'uMeasurements' field value 'LOAD' not found for equipment type(s) BUS + 'uMeasurements' list is empty + Model ZAB cannot be instantiated + """), + Arguments.of("/warnings/tapChangerCompatible.groovy", EurostagTutorialExample1Factory.create(), + """ + + DSL tests + + Groovy Dynamic Models Supplier + + DSL model builder for TapChangerBlockingAutomaton + 'uMeasurements' field value 'GEN' not found for equipment type(s) LOAD/TWO_WINDINGS_TRANSFORMER + 'transformers' list is empty + Model ZAB cannot be instantiated + """) ); } private static Stream provideGenerator() { return Stream.of( - Arguments.of("/dynamicModels/gen.groovy", SynchronousGenerator.class, EurostagTutorialExample1Factory.create(), "generator_terminal"), - Arguments.of("/dynamicModels/genTfo.groovy", SynchronousGenerator.class, EurostagTutorialExample1Factory.create(), "transformer_terminal1") + Arguments.of("/dynamicModels/gen.groovy", SynchronousGenerator.class, EurostagTutorialExample1Factory.create(), "generator_terminal", + """ + + DSL tests + + Groovy Dynamic Models Supplier + + DSL model builder for GeneratorSynchronousThreeWindings + Model BBM_GEN instantiation successful + """), + Arguments.of("/dynamicModels/genTfo.groovy", SynchronousGenerator.class, EurostagTutorialExample1Factory.create(), "transformer_terminal1", + """ + + DSL tests + + Groovy Dynamic Models Supplier + + DSL model builder for GeneratorSynchronousThreeWindingsPmConstVRNordicTfo + Model BBM_GEN instantiation successful + """) ); } } diff --git a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/EventModelsSupplierTest.java b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/EventModelsSupplierTest.java index 27702044d..0a37595ad 100644 --- a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/EventModelsSupplierTest.java +++ b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/EventModelsSupplierTest.java @@ -18,6 +18,7 @@ import com.powsybl.iidm.network.Network; import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; import com.powsybl.iidm.network.test.HvdcTestNetwork; +import com.powsybl.iidm.network.test.SvcTestCaseFactory; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -46,9 +47,10 @@ void testEventModels(String groovyScriptName, Class mod @ParameterizedTest(name = "{0}") @MethodSource("provideWarningsModel") - void testDslWarnings(String groovyScriptName, Network network) { + void testDslWarnings(String groovyScriptName, Network network, String report) { EventModelsSupplier supplier = new GroovyEventModelsSupplier(getResourceAsStream(groovyScriptName), EXTENSIONS); - assertTrue(supplier.get(network).isEmpty()); + assertTrue(supplier.get(network, reporter).isEmpty()); + checkReporter(report); } void assertEventModel(AbstractEvent em, String dynamicId, String equipmentStaticId, String lib, double startTime) { @@ -76,12 +78,55 @@ private static Stream provideEventModelData() { private static Stream provideWarningsModel() { return Stream.of( - Arguments.of("/eventWarnings/missingStaticId.groovy", EurostagTutorialExample1Factory.create()), - Arguments.of("/eventWarnings/missingStartTime.groovy", EurostagTutorialExample1Factory.create()), - Arguments.of("/eventWarnings/missingNodeFaultParameters.groovy", EurostagTutorialExample1Factory.create()), - Arguments.of("/eventWarnings/missingAPVParameters.groovy", EurostagTutorialExample1Factory.create()), - Arguments.of("/eventWarnings/missingDisconnectionEquipment.groovy", EurostagTutorialExample1Factory.create()), - Arguments.of("/eventWarnings/missingDisconnectionSide.groovy", EurostagTutorialExample1Factory.create()) + Arguments.of("/eventWarnings/missingStaticId.groovy", EurostagTutorialExample1Factory.create(), + """ + + DSL tests + + Groovy Event Models Supplier + + DSL model builder for NodeFault + 'staticId' field value 'GEN' not found for equipment type(s) BUS + Model NodeFault_GEN cannot be instantiated + """), + Arguments.of("/eventWarnings/missingStartTime.groovy", EurostagTutorialExample1Factory.create(), + """ + + DSL tests + + Groovy Event Models Supplier + + DSL model builder for NodeFault + 'startTime' field is not set + Model NodeFault_NGEN cannot be instantiated + """), + Arguments.of("/eventWarnings/missingNodeFaultParameters.groovy", EurostagTutorialExample1Factory.create(), + """ + + DSL tests + + Groovy Event Models Supplier + + DSL model builder for NodeFault + faultTime should be strictly positive (0.0) + Model NodeFault_NGEN cannot be instantiated + """), + Arguments.of("/eventWarnings/missingAPVParameters.groovy", SvcTestCaseFactory.create(), + """ + + DSL tests + + Groovy Event Models Supplier + + DSL model builder for Step + 'staticId' field value 'SVC2' not found for equipment type(s) GENERATOR/LOAD + 'deltaP' field is not set + Model Step_SVC2 cannot be instantiated + """), + Arguments.of("/eventWarnings/missingDisconnectionEquipment.groovy", EurostagTutorialExample1Factory.create(), + """ + + DSL tests + + Groovy Event Models Supplier + + DSL model builder for Disconnect + 'staticId' field value 'NGEN' not found for equipment type(s) Disconnectable equipment + Model Disconnect_NGEN cannot be instantiated + """), + Arguments.of("/eventWarnings/missingDisconnectionSide.groovy", EurostagTutorialExample1Factory.create(), + """ + + DSL tests + + Groovy Event Models Supplier + + DSL model builder for Disconnect + 'disconnectSide' field is set but GENERATOR GEN does not possess this option + Model Disconnect_GEN cannot be instantiated + """) ); } } diff --git a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/ieee/AbstractIeeeTest.java b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/ieee/AbstractIeeeTest.java index 0e5c8c374..3824017fa 100644 --- a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/ieee/AbstractIeeeTest.java +++ b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/ieee/AbstractIeeeTest.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.concurrent.ForkJoinPool; +import static com.powsybl.commons.reporter.Reporter.NO_OP; import static org.junit.jupiter.api.Assertions.assertEquals; /** @@ -69,7 +70,7 @@ protected void setup(String parametersFile, String networkParametersFile, String List dynamicModelGroovyExtensions = GroovyExtension.find(DynamicModelGroovyExtension.class, DynaWaltzProvider.NAME); dynamicModelsSupplier = new GroovyDynamicModelsSupplier(workingDir.resolve("dynamicModels.groovy"), dynamicModelGroovyExtensions); } else { - dynamicModelsSupplier = n -> Collections.emptyList(); + dynamicModelsSupplier = (n, NO_OP) -> Collections.emptyList(); } // Event models @@ -116,7 +117,7 @@ public DynamicSimulationResult runSimulation(LocalCommandExecutor commandExecuto assertEquals(DynaWaltzProvider.NAME, dynawoSimulation.getName()); return dynawoSimulation.run(network, dynamicModelsSupplier, eventModelsSupplier, curvesSupplier, network.getVariantManager().getWorkingVariantId(), - computationManager, parameters); + computationManager, parameters, NO_OP); } } diff --git a/dynawaltz-dsl/src/test/resources/eventWarnings/missingAPVParameters.groovy b/dynawaltz-dsl/src/test/resources/eventWarnings/missingAPVParameters.groovy index 7c95a02fd..94afd90f9 100644 --- a/dynawaltz-dsl/src/test/resources/eventWarnings/missingAPVParameters.groovy +++ b/dynawaltz-dsl/src/test/resources/eventWarnings/missingAPVParameters.groovy @@ -9,6 +9,6 @@ package eventWarnings Step { - staticId "NGEN" + staticId "SVC2" startTime 2 } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzContext.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzContext.java index 8f214d55d..bdf4ed3ab 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzContext.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzContext.java @@ -7,6 +7,7 @@ package com.powsybl.dynawaltz; import com.powsybl.commons.PowsyblException; +import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynamicsimulation.Curve; import com.powsybl.dynamicsimulation.DynamicSimulationParameters; import com.powsybl.dynawaltz.models.*; @@ -44,6 +45,7 @@ public class DynaWaltzContext { private static final String MODEL_ID_EXCEPTION = "The model identified by the static id %s does not match the expected model (%s)"; private static final String MODEL_ID_LOG = "The model identified by the static id {} does not match the expected model ({})"; + private final Reporter reporter; private final Network network; private final String workingVariantId; private final DynamicSimulationParameters parameters; @@ -61,13 +63,20 @@ public class DynaWaltzContext { public DynaWaltzContext(Network network, String workingVariantId, List dynamicModels, List eventModels, List curves, DynamicSimulationParameters parameters, DynaWaltzParameters dynaWaltzParameters) { + this(network, workingVariantId, dynamicModels, eventModels, curves, parameters, dynaWaltzParameters, Reporter.NO_OP); + } + + public DynaWaltzContext(Network network, String workingVariantId, List dynamicModels, List eventModels, + List curves, DynamicSimulationParameters parameters, DynaWaltzParameters dynaWaltzParameters, Reporter reporter) { + + this.reporter = DynawaltzReports.createDynaWaltzContextReporter(reporter); this.network = Objects.requireNonNull(network); this.workingVariantId = Objects.requireNonNull(workingVariantId); this.dynamicModels = Objects.requireNonNull(dynamicModels).stream() - .filter(distinctByDynamicId().and(distinctByStaticId())) + .filter(distinctByDynamicId(reporter).and(distinctByStaticId(reporter))) .toList(); this.eventModels = Objects.requireNonNull(eventModels).stream() - .filter(distinctByDynamicId()) + .filter(distinctByDynamicId(reporter)) .toList(); this.staticIdBlackBoxModelMap = getInputBlackBoxDynamicModelStream() .filter(EquipmentBlackBoxModel.class::isInstance) @@ -184,22 +193,22 @@ public EquipmentConnectionPoint getConnectionPointDynamicModel(String staticId) throw new PowsyblException(String.format(MODEL_ID_EXCEPTION, staticId, "ConnectionPoint")); } - protected static Predicate distinctByStaticId() { + protected static Predicate distinctByStaticId(Reporter reporter) { Set seen = new HashSet<>(); return bbm -> { if (bbm instanceof EquipmentBlackBoxModel eBbm && !seen.add(eBbm.getStaticId())) { - LOGGER.warn("Duplicate static id found: {} -> dynamic model {} {} will be skipped", eBbm.getStaticId(), eBbm.getLib(), eBbm.getDynamicModelId()); + DynawaltzReports.reportDuplicateStaticId(reporter, eBbm.getStaticId(), eBbm.getLib(), eBbm.getDynamicModelId()); return false; } return true; }; } - protected static Predicate distinctByDynamicId() { + protected static Predicate distinctByDynamicId(Reporter reporter) { Set seen = new HashSet<>(); return bbm -> { if (!seen.add(bbm.getDynamicModelId())) { - LOGGER.warn("Duplicate dynamic id found: {} -> model {} will be skipped", bbm.getDynamicModelId(), bbm.getName()); + DynawaltzReports.reportDuplicateDynamicId(reporter, bbm.getDynamicModelId(), bbm.getName()); return false; } return true; @@ -283,4 +292,8 @@ public List getDynamicModelsParameters() { public String getSimulationParFile() { return getNetwork().getId() + ".par"; } + + public Reporter getReporter() { + return reporter; + } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzProvider.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzProvider.java index ea7fabecb..2699ed989 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzProvider.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzProvider.java @@ -107,8 +107,9 @@ public CompletableFuture run(Network network, DynamicMo Objects.requireNonNull(curvesSupplier); Objects.requireNonNull(workingVariantId); Objects.requireNonNull(parameters); + Objects.requireNonNull(reporter); DynaWaltzParameters dynaWaltzParameters = getDynaWaltzSimulationParameters(parameters); - return run(network, dynamicModelsSupplier, eventModelsSupplier, curvesSupplier, workingVariantId, computationManager, parameters, dynaWaltzParameters); + return run(network, dynamicModelsSupplier, eventModelsSupplier, curvesSupplier, workingVariantId, computationManager, parameters, dynaWaltzParameters, reporter); } private DynaWaltzParameters getDynaWaltzSimulationParameters(DynamicSimulationParameters parameters) { @@ -120,22 +121,23 @@ private DynaWaltzParameters getDynaWaltzSimulationParameters(DynamicSimulationPa } private CompletableFuture run(Network network, DynamicModelsSupplier dynamicModelsSupplier, EventModelsSupplier eventsModelsSupplier, CurvesSupplier curvesSupplier, - String workingVariantId, ComputationManager computationManager, DynamicSimulationParameters parameters, DynaWaltzParameters dynaWaltzParameters) { + String workingVariantId, ComputationManager computationManager, DynamicSimulationParameters parameters, DynaWaltzParameters dynaWaltzParameters, Reporter reporter) { + Reporter dsReporter = DynawaltzReports.createDynaWaltzReporter(reporter, network.getId()); network.getVariantManager().setWorkingVariant(workingVariantId); ExecutionEnvironment execEnv = new ExecutionEnvironment(Collections.emptyMap(), WORKING_DIR_PREFIX, dynaWaltzConfig.isDebug()); Command versionCmd = getVersionCommand(dynaWaltzConfig); DynawoUtil.requireDynaMinVersion(execEnv, computationManager, versionCmd, DynawoConstants.DYNAWO_CMD_NAME, false); - List blackBoxModels = dynamicModelsSupplier.get(network).stream() + List blackBoxModels = dynamicModelsSupplier.get(network, dsReporter).stream() .filter(BlackBoxModel.class::isInstance) .map(BlackBoxModel.class::cast) .collect(Collectors.toList()); - List blackBoxEventModels = eventsModelsSupplier.get(network).stream() + List blackBoxEventModels = eventsModelsSupplier.get(network, dsReporter).stream() .filter(BlackBoxModel.class::isInstance) .map(BlackBoxModel.class::cast) .collect(Collectors.toList()); - DynaWaltzContext context = new DynaWaltzContext(network, workingVariantId, blackBoxModels, blackBoxEventModels, curvesSupplier.get(network), parameters, dynaWaltzParameters); + DynaWaltzContext context = new DynaWaltzContext(network, workingVariantId, blackBoxModels, blackBoxEventModels, curvesSupplier.get(network, dsReporter), parameters, dynaWaltzParameters, reporter); return computationManager.execute(execEnv, new DynaWaltzHandler(context)); } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynawaltzReports.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynawaltzReports.java new file mode 100644 index 000000000..e6aafb366 --- /dev/null +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynawaltzReports.java @@ -0,0 +1,71 @@ +/** + * Copyright (c) 2023, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * SPDX-License-Identifier: MPL-2.0 + */ +package com.powsybl.dynawaltz; + +import com.powsybl.commons.reporter.Report; +import com.powsybl.commons.reporter.Reporter; +import com.powsybl.commons.reporter.TypedValue; + +/** + * @author Laurent Issertial + */ +public final class DynawaltzReports { + + private DynawaltzReports() { + } + + public static Reporter createDynaWaltzReporter(Reporter reporter, String networkId) { + return reporter.createSubReporter("dynawaltz", + "Dynawaltz dynamic simulation on network '${networkId}'", + "networkId", networkId); + } + + public static Reporter createDynaWaltzContextReporter(Reporter reporter) { + return reporter.createSubReporter("dynawaltzContext", + "Dynawaltz models processing"); + } + + public static void reportDuplicateStaticId(Reporter reporter, String duplicateId, String modelName, String dynamicId) { + reporter.report(Report.builder() + .withKey("duplicateId") + .withDefaultMessage("Duplicate static id found: ${duplicateId} -> model ${modelName} ${dynamicId} will be skipped") + .withValue("duplicateId", duplicateId) + .withValue("modelName", modelName) + .withValue("dynamicId", dynamicId) + .withSeverity(TypedValue.WARN_SEVERITY) + .build()); + } + + public static void reportDuplicateDynamicId(Reporter reporter, String duplicateId, String modelName) { + reporter.report(Report.builder() + .withKey("duplicateId") + .withDefaultMessage("Duplicate dynamic id found: ${duplicateId} -> model ${modelName} will be skipped") + .withValue("duplicateId", duplicateId) + .withValue("modelName", modelName) + .withSeverity(TypedValue.WARN_SEVERITY) + .build()); + } + + public static void reportEmptyTapChanger(Reporter reporter, String dynamicId) { + reporter.report(Report.builder() + .withKey("emptyTC") + .withDefaultMessage("TapChangerAutomaton ${dynamicId} load does not possess a transformer, the automaton will be skipped") + .withValue("dynamicId", dynamicId) + .withSeverity(TypedValue.WARN_SEVERITY) + .build()); + } + + public static void reportEmptyTapChangerBlockingAutomaton(Reporter reporter, String dynamicId) { + reporter.report(Report.builder() + .withKey("emptyTCB") + .withDefaultMessage("None of TapChangerBlockingAutomaton {} equipments are TapChangerModel, the automaton will be skipped") + .withValue("dynamicId", dynamicId) + .withSeverity(TypedValue.WARN_SEVERITY) + .build()); + } +} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerAutomaton.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerAutomaton.java index 516d1c2d4..a1e8780fe 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerAutomaton.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerAutomaton.java @@ -8,14 +8,13 @@ package com.powsybl.dynawaltz.models.automatons; import com.powsybl.dynawaltz.DynaWaltzContext; +import com.powsybl.dynawaltz.DynawaltzReports; import com.powsybl.dynawaltz.models.AbstractPureDynamicBlackBoxModel; import com.powsybl.dynawaltz.models.TransformerSide; import com.powsybl.dynawaltz.models.VarConnection; import com.powsybl.dynawaltz.models.loads.LoadWithTransformers; import com.powsybl.dynawaltz.models.transformers.TapChangerModel; import com.powsybl.iidm.network.Load; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; @@ -27,8 +26,6 @@ */ public class TapChangerAutomaton extends AbstractPureDynamicBlackBoxModel implements TapChangerModel { - private static final Logger LOGGER = LoggerFactory.getLogger(TapChangerAutomaton.class); - private final Load load; private final TransformerSide side; @@ -66,7 +63,7 @@ public void createMacroConnections(DynaWaltzContext context) { boolean isSkipped = createMacroConnectionsOrSkip(load, LoadWithTransformers.class, this::getVarConnectionsWith, context); if (isSkipped) { connection = ConnectionState.NOT_CONNECTED; - LOGGER.warn("TapChangerAutomaton {} load does not possess a transformer, the automaton will be skipped", getDynamicModelId()); + DynawaltzReports.reportEmptyTapChanger(context.getReporter(), getDynamicModelId()); } else { connection = ConnectionState.CONNECTED; } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerBlockingAutomaton.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerBlockingAutomaton.java index 78777cf85..7ed93890c 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerBlockingAutomaton.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerBlockingAutomaton.java @@ -9,6 +9,7 @@ import com.powsybl.commons.PowsyblException; import com.powsybl.dynawaltz.DynaWaltzContext; +import com.powsybl.dynawaltz.DynawaltzReports; import com.powsybl.dynawaltz.models.AbstractPureDynamicBlackBoxModel; import com.powsybl.dynawaltz.models.MeasurementPointSuffix; import com.powsybl.dynawaltz.models.VarConnection; @@ -18,8 +19,6 @@ import com.powsybl.iidm.network.IdentifiableType; import com.powsybl.iidm.network.Load; import com.powsybl.iidm.network.TwoWindingsTransformer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; @@ -30,7 +29,6 @@ */ public class TapChangerBlockingAutomaton extends AbstractPureDynamicBlackBoxModel { - private static final Logger LOGGER = LoggerFactory.getLogger(TapChangerBlockingAutomaton.class); private static final Set COMPATIBLE_EQUIPMENTS = EnumSet.of(IdentifiableType.LOAD, IdentifiableType.TWO_WINDINGS_TRANSFORMER); private static final int MAX_MEASUREMENTS = 5; @@ -104,7 +102,7 @@ public void createMacroConnections(DynaWaltzContext context) { } } else { isConnected = false; - LOGGER.warn("None of TapChangerBlockingAutomaton {} equipments are TapChangerModel, the automaton will be skipped", getDynamicModelId()); + DynawaltzReports.reportEmptyTapChangerBlockingAutomaton(context.getReporter(), getDynamicModelId()); } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/AbstractEvent.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/AbstractEvent.java index 1891db848..813643272 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/AbstractEvent.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/AbstractEvent.java @@ -25,12 +25,12 @@ public abstract class AbstractEvent extends AbstractPureDynamicBlackBoxModel imp private final double startTime; protected AbstractEvent(Identifiable equipment, double startTime, String eventPrefix) { - super(generateEventId(equipment.getId(), eventPrefix)); + super(generateEventId(eventPrefix, equipment.getId())); this.equipment = equipment; this.startTime = startTime; } - private static String generateEventId(String equipmentStaticId, String eventPrefix) { + public static String generateEventId(String eventPrefix, String equipmentStaticId) { return eventPrefix + equipmentStaticId; } diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/DynaWaltzProviderTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/DynaWaltzProviderTest.java index 4f54899cc..c6dbbe031 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/DynaWaltzProviderTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/DynaWaltzProviderTest.java @@ -32,6 +32,7 @@ import java.util.Map; import java.util.concurrent.ForkJoinPool; +import static com.powsybl.commons.reporter.Reporter.NO_OP; import static org.junit.jupiter.api.Assertions.*; /** @@ -88,7 +89,7 @@ void testWithMergeLoads() throws Exception { assertEquals(DynaWaltzProvider.NAME, dynawoSimulation.getName()); DynamicSimulationResult result = dynawoSimulation.run(network, (n, r) -> Collections.emptyList(), EventModelsSupplier.empty(), CurvesSupplier.empty(), network.getVariantManager().getWorkingVariantId(), - computationManager, DynamicSimulationParameters.load()); + computationManager, DynamicSimulationParameters.load(), NO_OP); assertNotNull(result); } @@ -130,7 +131,7 @@ void testWithDump() throws Exception { assertEquals(DynaWaltzProvider.NAME, dynawoSimulation.getName()); DynamicSimulationResult result = dynawoSimulation.run(network, (n, r) -> Collections.emptyList(), EventModelsSupplier.empty(), CurvesSupplier.empty(), network.getVariantManager().getWorkingVariantId(), - computationManager, dynamicSimulationParameters); + computationManager, dynamicSimulationParameters, NO_OP); assertNotNull(result); } @@ -143,7 +144,7 @@ void testFail() throws Exception { assertEquals(DynaWaltzProvider.NAME, dynawoSimulation.getName()); DynamicSimulationResult result = dynawoSimulation.run(network, (n, r) -> Collections.emptyList(), EventModelsSupplier.empty(), CurvesSupplier.empty(), network.getVariantManager().getWorkingVariantId(), - computationManager, DynamicSimulationParameters.load()); + computationManager, DynamicSimulationParameters.load(), NO_OP); assertNotNull(result); assertFalse(result.isOk()); } @@ -157,7 +158,7 @@ void testWithoutCurves() throws Exception { assertEquals(DynaWaltzProvider.NAME, dynawoSimulation.getName()); DynamicSimulationResult result = dynawoSimulation.run(network, (n, r) -> Collections.emptyList(), EventModelsSupplier.empty(), new CurvesSupplierMock(), network.getVariantManager().getWorkingVariantId(), - computationManager, DynamicSimulationParameters.load()); + computationManager, DynamicSimulationParameters.load(), NO_OP); assertNotNull(result); assertFalse(result.isOk()); } @@ -194,7 +195,7 @@ void testCallingBadVersionDynawo() throws Exception { CurvesSupplier cs = CurvesSupplier.empty(); String wvId = network.getVariantManager().getWorkingVariantId(); DynamicSimulationParameters dsp = DynamicSimulationParameters.load(); - PowsyblException e = assertThrows(PowsyblException.class, () -> dynawoSimulation.run(network, dms, ems, cs, wvId, computationManager, dsp)); + PowsyblException e = assertThrows(PowsyblException.class, () -> dynawoSimulation.run(network, dms, ems, cs, wvId, computationManager, dsp, NO_OP)); assertEquals("dynawo version not supported. Must be >= " + DynawoConstants.VERSION_MIN, e.getMessage()); } diff --git a/dynawo-integration-tests/src/test/resources/ieee14/disconnectline/eventModels.groovy b/dynawo-integration-tests/src/test/resources/ieee14/disconnectline/eventModels.groovy index 675dc0b3d..f15f829a7 100644 --- a/dynawo-integration-tests/src/test/resources/ieee14/disconnectline/eventModels.groovy +++ b/dynawo-integration-tests/src/test/resources/ieee14/disconnectline/eventModels.groovy @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import com.powsybl.iidm.network.Branch +import com.powsybl.iidm.network.TwoSides Disconnect { staticId "_BUS____1-BUS____5-1_AC"