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 index 735d48608..8828e3961 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/Reporters.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/Reporters.groovy @@ -26,18 +26,20 @@ final class Reporters { "lib", lib) } - static void reportModelInstantiation(Reporter reporter) { + static void reportModelInstantiation(Reporter reporter, String dynamicId) { reporter.report(Report.builder() .withKey("modelInstantiation") - .withDefaultMessage('Instantiation successful') + .withDefaultMessage('Model ${dynamicId} instantiation successful') + .withValue("dynamicId", dynamicId) .withSeverity(TypedValue.TRACE_SEVERITY) .build()) } - static void reportModelInstantiationFailure(Reporter reporter) { + static void reportModelInstantiationFailure(Reporter reporter, String dynamicId) { reporter.report(Report.builder() .withKey("modelInstantiation") - .withDefaultMessage('Model cannot be instantiated') + .withDefaultMessage('Model ${dynamicId} cannot be instantiated') + .withValue("dynamicId", dynamicId) .withSeverity(TypedValue.WARN_SEVERITY) .build()) } 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 85fc2d91c..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 @@ -34,7 +34,9 @@ abstract class AbstractDynamicModelBuilder { protected final boolean isInstantiable() { checkData() - isInstantiable ? Reporters.reportModelInstantiation(reporter) : Reporters.reportModelInstantiationFailure(reporter) + isInstantiable ? Reporters.reportModelInstantiation(reporter, getModelId()) : Reporters.reportModelInstantiationFailure(reporter, getModelId()) isInstantiable } + + 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 82d91e0bf..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 @@ -64,6 +64,11 @@ abstract class AbstractEquipmentModelBuilder extends Abs dslEquipment.equipment } + @Override + String getModelId() { + dynamicModelId ?: "unknownDynamicId" + } + @Override abstract DynamicModel build() } 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 1483b4343..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 @@ -13,6 +13,7 @@ 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 @@ -51,6 +52,11 @@ abstract class AbstractEventModelBuilder extends Abstrac abstract protected Identifiable findEquipment(String staticId) + @Override + String getModelId() { + AbstractEvent.generateEventId(tag + "_", dslEquipment.staticId ?: "unknownStaticId") + } + @Override abstract EventModel build() } 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 904c1e97e..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 @@ -48,6 +48,11 @@ abstract class AbstractPureDynamicModelBuilder extends AbstractDynamicModelBuild } } + @Override + String getModelId() { + dynamicModelId ?: "unknownDynamicId" + } + @Override abstract DynamicModel build() } 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 62262d8af..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 @@ -154,7 +154,7 @@ private static Stream provideWarningsModel() { + DSL model builder for LoadAlphaBeta 'staticId' field is not set 'dynamicModelId' field is not set, staticId (unknown staticId) will be used instead - Model cannot be instantiated + Model unknownDynamicId cannot be instantiated """), Arguments.of("/warnings/missingParameterId.groovy", EurostagTutorialExample1Factory.create(), """ @@ -163,7 +163,7 @@ private static Stream provideWarningsModel() { + DSL model builder for LoadAlphaBeta 'parameterSetId' field is not set 'dynamicModelId' field is not set, staticId LOAD will be used instead - Model cannot be instantiated + Model LOAD cannot be instantiated """), Arguments.of("/warnings/missingEquipment.groovy", EurostagTutorialExample1Factory.create(), """ @@ -172,7 +172,7 @@ private static Stream provideWarningsModel() { + 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 cannot be instantiated + Model GEN cannot be instantiated """), Arguments.of("/warnings/missingDangling.groovy", HvdcTestNetwork.createVsc(), """ @@ -180,7 +180,7 @@ private static Stream provideWarningsModel() { + Groovy Dynamic Models Supplier + DSL model builder for HvdcPVDangling 'dangling' field is not set - Model cannot be instantiated + Model BBM_HVDC_L cannot be instantiated """), Arguments.of("/warnings/missingDanglingProperty.groovy", HvdcTestNetwork.createVsc(), """ @@ -188,7 +188,7 @@ private static Stream provideWarningsModel() { + Groovy Dynamic Models Supplier + DSL model builder for HvdcPV 'dangling' field is set but HvdcPV does not possess this option - Model cannot be instantiated + Model BBM_HVDC_L cannot be instantiated """), Arguments.of("/warnings/underVoltageMissingGenerator.groovy", EurostagTutorialExample1Factory.create(), """ @@ -196,7 +196,7 @@ private static Stream provideWarningsModel() { + Groovy Dynamic Models Supplier + DSL model builder for UnderVoltage 'generator' field value 'NGEN' not found for equipment type(s) GENERATOR - Model cannot be instantiated + Model UV_GEN cannot be instantiated """), Arguments.of("/warnings/phaseShifterMissingTransformer.groovy", EurostagTutorialExample1Factory.create(), """ @@ -204,7 +204,7 @@ private static Stream provideWarningsModel() { + Groovy Dynamic Models Supplier + DSL model builder for PhaseShifterI 'transformer' field value 'NGEN' not found for equipment type(s) TWO_WINDINGS_TRANSFORMER - Model cannot be instantiated + Model PS_NGEN_NHV1 cannot be instantiated """), Arguments.of("/warnings/claMissingMeasurement.groovy", EurostagTutorialExample1Factory.create(), """ @@ -212,7 +212,7 @@ private static Stream provideWarningsModel() { + Groovy Dynamic Models Supplier + DSL model builder for CurrentLimitAutomaton 'iMeasurement' field value 'NGEN' not found for equipment type(s) Quadripole - Model cannot be instantiated + Model CLA_NGEN cannot be instantiated """), Arguments.of("/warnings/claMissingMeasurementSide.groovy", EurostagTutorialExample1Factory.create(), """ @@ -220,7 +220,7 @@ private static Stream provideWarningsModel() { + Groovy Dynamic Models Supplier + DSL model builder for CurrentLimitAutomaton 'iMeasurementSide' field is not set - Model cannot be instantiated + Model CLA_NGEN cannot be instantiated """), Arguments.of("/warnings/claMissingControlled.groovy", EurostagTutorialExample1Factory.create(), """ @@ -228,7 +228,7 @@ private static Stream provideWarningsModel() { + Groovy Dynamic Models Supplier + DSL model builder for CurrentLimitAutomaton 'controlledQuadripole' field value 'GEN' not found for equipment type(s) Quadripole - Model cannot be instantiated + Model CLA_NGEN cannot be instantiated """), Arguments.of("/warnings/cla2MissingMeasurement2.groovy", EurostagTutorialExample1Factory.create(), """ @@ -236,7 +236,7 @@ private static Stream provideWarningsModel() { + Groovy Dynamic Models Supplier + DSL model builder for CurrentLimitAutomatonTwoLevels 'iMeasurement2' field value 'NGEN' not found for equipment type(s) Quadripole - Model cannot be instantiated + Model CLA_NGEN cannot be instantiated """), Arguments.of("/warnings/cla2MissingMeasurementSide2.groovy", EurostagTutorialExample1Factory.create(), """ @@ -244,7 +244,7 @@ private static Stream provideWarningsModel() { + Groovy Dynamic Models Supplier + DSL model builder for CurrentLimitAutomatonTwoLevels 'iMeasurement2Side' field is not set - Model cannot be instantiated + Model CLA_NGEN cannot be instantiated """), Arguments.of("/warnings/tapChangerMissingBus.groovy", EurostagTutorialExample1Factory.create(), """ @@ -253,7 +253,7 @@ private static Stream provideWarningsModel() { + DSL model builder for TapChangerBlockingAutomaton 'uMeasurements' field value 'LOAD' not found for equipment type(s) BUS 'uMeasurements' list is empty - Model cannot be instantiated + Model ZAB cannot be instantiated """), Arguments.of("/warnings/tapChangerCompatible.groovy", EurostagTutorialExample1Factory.create(), """ @@ -262,7 +262,7 @@ private static Stream provideWarningsModel() { + DSL model builder for TapChangerBlockingAutomaton 'uMeasurements' field value 'GEN' not found for equipment type(s) LOAD/TWO_WINDINGS_TRANSFORMER 'transformers' list is empty - Model cannot be instantiated + Model ZAB cannot be instantiated """) ); } @@ -274,14 +274,14 @@ private static Stream provideGenerator() { + DSL tests + Groovy Dynamic Models Supplier + DSL model builder for GeneratorSynchronousThreeWindings - Instantiation successful + 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 - Instantiation successful + 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 1a15577ac..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 @@ -84,7 +84,7 @@ private static Stream provideWarningsModel() { + Groovy Event Models Supplier + DSL model builder for NodeFault 'staticId' field value 'GEN' not found for equipment type(s) BUS - Model cannot be instantiated + Model NodeFault_GEN cannot be instantiated """), Arguments.of("/eventWarnings/missingStartTime.groovy", EurostagTutorialExample1Factory.create(), """ @@ -92,7 +92,7 @@ private static Stream provideWarningsModel() { + Groovy Event Models Supplier + DSL model builder for NodeFault 'startTime' field is not set - Model cannot be instantiated + Model NodeFault_NGEN cannot be instantiated """), Arguments.of("/eventWarnings/missingNodeFaultParameters.groovy", EurostagTutorialExample1Factory.create(), """ @@ -100,7 +100,7 @@ private static Stream provideWarningsModel() { + Groovy Event Models Supplier + DSL model builder for NodeFault faultTime should be strictly positive (0.0) - Model cannot be instantiated + Model NodeFault_NGEN cannot be instantiated """), Arguments.of("/eventWarnings/missingAPVParameters.groovy", SvcTestCaseFactory.create(), """ @@ -109,7 +109,7 @@ faultTime should be strictly positive (0.0) + DSL model builder for Step 'staticId' field value 'SVC2' not found for equipment type(s) GENERATOR/LOAD 'deltaP' field is not set - Model cannot be instantiated + Model Step_SVC2 cannot be instantiated """), Arguments.of("/eventWarnings/missingDisconnectionEquipment.groovy", EurostagTutorialExample1Factory.create(), """ @@ -117,7 +117,7 @@ faultTime should be strictly positive (0.0) + Groovy Event Models Supplier + DSL model builder for Disconnect 'staticId' field value 'NGEN' not found for equipment type(s) Disconnectable equipment - Model cannot be instantiated + Model Disconnect_NGEN cannot be instantiated """), Arguments.of("/eventWarnings/missingDisconnectionSide.groovy", EurostagTutorialExample1Factory.create(), """ @@ -125,7 +125,7 @@ faultTime should be strictly positive (0.0) + Groovy Event Models Supplier + DSL model builder for Disconnect 'disconnectSide' field is set but GENERATOR GEN does not possess this option - Model cannot be instantiated + Model Disconnect_GEN cannot be instantiated """) ); } 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; }