diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/AbstractDynamicModelBuilder.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/AbstractDynamicModelBuilder.groovy new file mode 100644 index 000000000..15b76403e --- /dev/null +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/AbstractDynamicModelBuilder.groovy @@ -0,0 +1,49 @@ +/* + * 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.dsl.DslException +import com.powsybl.dynamicsimulation.DynamicModel + +/** + * @author Laurent Issertial + */ +abstract class AbstractDynamicModelBuilder implements ModelBuilder { + + String dynamicModelId + String staticId + String parameterSetId + + void dynamicModelId(String dynamicModelId) { + this.dynamicModelId = dynamicModelId + } + + void staticId(String staticId) { + this.staticId = staticId + } + + void parameterSetId(String parameterSetId) { + this.parameterSetId = parameterSetId + } + + void checkData() { + if (!staticId) { + throw new DslException("'staticId' field is not set") + } + if (!parameterSetId) { + throw new DslException("'parameterSetId' field is not set") + } + if (!dynamicModelId) { + dynamicModelId = staticId + } + } + + @Override + abstract DynamicModel build(); +} diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/AbstractPowsyblDynawoGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/AbstractPowsyblDynawoGroovyExtension.groovy new file mode 100644 index 000000000..727a78f4d --- /dev/null +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/AbstractPowsyblDynawoGroovyExtension.groovy @@ -0,0 +1,40 @@ +/* + * 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.dynawaltz.DynaWaltzProvider + +import java.util.function.Consumer + +/** + * @author Laurent Issertial + */ +abstract class AbstractPowsyblDynawoGroovyExtension { + + protected List modelTags + + abstract protected ModelBuilder createBuilder(String currentTag) + + String getName() { + return DynaWaltzProvider.NAME + } + + void load(Binding binding, Consumer consumer) { + modelTags.forEach { + binding.setVariable(it, { Closure closure -> + def cloned = closure.clone() + ModelBuilder builder = createBuilder(it) + cloned.delegate = builder + cloned() + consumer.accept(builder.build()) + }) + } + } + +} diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/ModelBuilder.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/ModelBuilder.groovy new file mode 100644 index 000000000..d85e949d6 --- /dev/null +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/ModelBuilder.groovy @@ -0,0 +1,17 @@ +/* + * 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 + +/** + * @author Laurent Issertial + */ +interface ModelBuilder { + + T build() +} \ No newline at end of file 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 e6d8ef0bb..2cc6c6d2c 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 @@ -6,17 +6,14 @@ */ package com.powsybl.dynawaltz.dsl.automatons -import com.powsybl.iidm.network.Branch - -import com.powsybl.dynawaltz.DynaWaltzProvider -import com.powsybl.dynawaltz.models.automatons.CurrentLimitAutomaton - -import java.util.function.Consumer - import com.google.auto.service.AutoService import com.powsybl.dsl.DslException import com.powsybl.dynamicsimulation.DynamicModel import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension +import com.powsybl.dynawaltz.dsl.AbstractDynamicModelBuilder +import com.powsybl.dynawaltz.dsl.AbstractPowsyblDynawoGroovyExtension +import com.powsybl.dynawaltz.models.automatons.CurrentLimitAutomaton +import com.powsybl.iidm.network.Branch /** * An implementation of {@link DynamicModelGroovyExtension} that adds the
CurrentLimitAutomaton
keyword to the DSL @@ -24,56 +21,37 @@ import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension * @author Marcos de Miguel */ @AutoService(DynamicModelGroovyExtension.class) -class CurrentLimitAutomatonGroovyExtension implements DynamicModelGroovyExtension { +class CurrentLimitAutomatonGroovyExtension extends AbstractPowsyblDynawoGroovyExtension implements DynamicModelGroovyExtension { - static class CurrentLimitAutomatonSpec { - String dynamicModelId - String staticId - Branch.Side side - String parameterSetId + CurrentLimitAutomatonGroovyExtension() { + modelTags = ["CurrentLimitAutomaton"] + } - void dynamicModelId(String dynamicModelId) { - this.dynamicModelId = dynamicModelId - } + @Override + protected CurrentLimitAutomatonBuilder createBuilder(String currentTag) { + new CurrentLimitAutomatonBuilder() + } - void staticId(String staticId) { - this.staticId = staticId - } + static class CurrentLimitAutomatonBuilder extends AbstractDynamicModelBuilder { - void parameterSetId(String parameterSetId) { - this.parameterSetId = parameterSetId - } + Branch.Side side void side(Branch.Side side) { this.side = side } - } - - String getName() { - return DynaWaltzProvider.NAME - } - - void load(Binding binding, Consumer consumer) { - binding.CurrentLimitAutomaton = { Closure closure -> - def cloned = closure.clone() - CurrentLimitAutomatonSpec currentLimitAutomatonSpec = new CurrentLimitAutomatonSpec() - - cloned.delegate = currentLimitAutomatonSpec - cloned() - if (!currentLimitAutomatonSpec.staticId) { - throw new DslException("'staticId' field is not set"); - } - if (!currentLimitAutomatonSpec.parameterSetId) { - throw new DslException("'parameterSetId' field is not set") - } - if (!currentLimitAutomatonSpec.side) { - throw new DslException("'side' field is not set"); + @Override + void checkData() { + super.checkData() + if (!side) { + throw new DslException("'side' field is not set") } + } - String dynamicModelId = currentLimitAutomatonSpec.dynamicModelId ? currentLimitAutomatonSpec.dynamicModelId : currentLimitAutomatonSpec.staticId - consumer.accept(new CurrentLimitAutomaton(dynamicModelId, currentLimitAutomatonSpec.staticId, currentLimitAutomatonSpec.parameterSetId, currentLimitAutomatonSpec.side)) + @Override + CurrentLimitAutomaton build() { + checkData() + new CurrentLimitAutomaton(dynamicModelId, staticId, parameterSetId, side) } } - } diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/AbstractEventModelBuilder.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/AbstractEventModelBuilder.groovy new file mode 100644 index 000000000..4b158f0af --- /dev/null +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/AbstractEventModelBuilder.groovy @@ -0,0 +1,50 @@ +/* + * 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.events + +import com.powsybl.dsl.DslException +import com.powsybl.dynamicsimulation.EventModel +import com.powsybl.dynawaltz.dsl.ModelBuilder + +/** + * @author Laurent Issertial + */ +abstract class AbstractEventModelBuilder implements ModelBuilder { + + String eventModelId + String staticId + double startTime + + void eventModelId(String eventModelId) { + this.eventModelId = eventModelId + } + + void staticId(String staticId) { + this.staticId = staticId + } + + void startTime(double startTime) { + this.startTime = startTime + } + + void checkData() { + if (!staticId) { + throw new DslException("'staticId' field is not set") + } + if (!startTime) { + throw new DslException("'startTime' field is not set") + } + if (!eventModelId) { + eventModelId = staticId + } + } + + @Override + abstract EventModel build(); +} diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/EventQuadripoleDisconnectionGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/EventQuadripoleDisconnectionGroovyExtension.groovy index fa5b6bb8e..1795be9cf 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/EventQuadripoleDisconnectionGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/EventQuadripoleDisconnectionGroovyExtension.groovy @@ -6,14 +6,10 @@ */ package com.powsybl.dynawaltz.dsl.events -import java.util.function.Consumer - import com.google.auto.service.AutoService -import com.powsybl.dsl.DslException import com.powsybl.dynamicsimulation.EventModel import com.powsybl.dynamicsimulation.groovy.EventModelGroovyExtension - -import com.powsybl.dynawaltz.DynaWaltzProvider +import com.powsybl.dynawaltz.dsl.AbstractPowsyblDynawoGroovyExtension import com.powsybl.dynawaltz.models.events.EventQuadripoleDisconnection /** @@ -22,26 +18,21 @@ import com.powsybl.dynawaltz.models.events.EventQuadripoleDisconnection * @author Marcos de Miguel */ @AutoService(EventModelGroovyExtension.class) -class EventQuadripoleDisconnectionGroovyExtension implements EventModelGroovyExtension { +class EventQuadripoleDisconnectionGroovyExtension extends AbstractPowsyblDynawoGroovyExtension implements EventModelGroovyExtension { - static class EventQuadripoleDisconnectionSpec { - String eventModelId - String staticId - double startTime - boolean disconnectOrigin - boolean disconnectExtremity + EventQuadripoleDisconnectionGroovyExtension() { + modelTags = ["EventQuadripoleDisconnection"] + } - void eventModelId(String eventModelId) { - this.eventModelId = eventModelId - } + @Override + protected EventQuadripoleDisconnectionBuilder createBuilder(String currentTag) { + new EventQuadripoleDisconnectionBuilder() + } - void staticId(String staticId) { - this.staticId = staticId - } + static class EventQuadripoleDisconnectionBuilder extends AbstractEventModelBuilder { - void startTime(double startTime) { - this.startTime = startTime - } + boolean disconnectOrigin + boolean disconnectExtremity void disconnectOrigin(boolean disconnectOrigin) { this.disconnectOrigin = disconnectOrigin @@ -50,32 +41,11 @@ class EventQuadripoleDisconnectionGroovyExtension implements EventModelGroovyExt void disconnectExtremity(boolean disconnectExtremity) { this.disconnectExtremity = disconnectExtremity } - } - String getName() { - return DynaWaltzProvider.NAME - } - - void load(Binding binding, Consumer consumer) { - binding.EventQuadripoleDisconnection = { Closure closure -> - def cloned = closure.clone() - EventQuadripoleDisconnectionSpec eventQuadripoleDisconnectionSpec = new EventQuadripoleDisconnectionSpec() - - cloned.delegate = eventQuadripoleDisconnectionSpec - cloned() - - if (!eventQuadripoleDisconnectionSpec.staticId) { - throw new DslException("'staticId' field is not set"); - } - if (!eventQuadripoleDisconnectionSpec.startTime) { - throw new DslException("'startTime' field is not set") - } - - String eventModelId = eventQuadripoleDisconnectionSpec.eventModelId ? eventQuadripoleDisconnectionSpec.eventModelId : eventQuadripoleDisconnectionSpec.staticId - consumer.accept(new EventQuadripoleDisconnection(eventModelId, eventQuadripoleDisconnectionSpec.staticId, - eventQuadripoleDisconnectionSpec.startTime, eventQuadripoleDisconnectionSpec.disconnectOrigin, - eventQuadripoleDisconnectionSpec.disconnectExtremity)) + @Override + EventQuadripoleDisconnection build() { + checkData() + new EventQuadripoleDisconnection(eventModelId, staticId, startTime, disconnectOrigin, disconnectExtremity) } } - } diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/EventSetPointBooleanGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/EventSetPointBooleanGroovyExtension.groovy index 13abc500b..1d4a2b793 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/EventSetPointBooleanGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/events/EventSetPointBooleanGroovyExtension.groovy @@ -7,68 +7,40 @@ package com.powsybl.dynawaltz.dsl.events import com.google.auto.service.AutoService -import com.powsybl.dsl.DslException import com.powsybl.dynamicsimulation.EventModel import com.powsybl.dynamicsimulation.groovy.EventModelGroovyExtension - -import com.powsybl.dynawaltz.DynaWaltzProvider +import com.powsybl.dynawaltz.dsl.AbstractPowsyblDynawoGroovyExtension import com.powsybl.dynawaltz.models.events.EventSetPointBoolean -import java.util.function.Consumer - /** * An implementation of {@link EventModelGroovyExtension} that adds the
EventSetPointBoolean
keyword to the DSL * * @author Mathieu BAGUE {@literal } */ @AutoService(EventModelGroovyExtension.class) -class EventSetPointBooleanGroovyExtension implements EventModelGroovyExtension { +class EventSetPointBooleanGroovyExtension extends AbstractPowsyblDynawoGroovyExtension implements EventModelGroovyExtension { - static class EventSetPointBooleanSpec { - String eventModelId - String staticId - double startTime - boolean stateEvent + EventSetPointBooleanGroovyExtension() { + modelTags = ["EventSetPointBoolean"] + } - void eventModelId(String eventModelId) { - this.eventModelId = eventModelId - } + @Override + protected EventSetPointBooleanBuilder createBuilder(String currentTag) { + new EventSetPointBooleanBuilder() + } - void staticId(String staticId) { - this.staticId = staticId - } + static class EventSetPointBooleanBuilder extends AbstractEventModelBuilder { - void startTime(double startTime) { - this.startTime = startTime - } + boolean stateEvent void stateEvent(boolean stateEvent) { this.stateEvent = stateEvent } - } - - String getName() { - return DynaWaltzProvider.NAME - } - - void load(Binding binding, Consumer consumer) { - binding.EventSetPointBoolean = { Closure closure -> - def cloned = closure.clone() - EventSetPointBooleanSpec eventSetPointBooleanSpec = new EventSetPointBooleanSpec() - - cloned.delegate = eventSetPointBooleanSpec - cloned() - - if (!eventSetPointBooleanSpec.staticId) { - throw new DslException("'staticId' field is not set"); - } - if (!eventSetPointBooleanSpec.startTime) { - throw new DslException("'startTime' field is not set") - } - String eventModelId = eventSetPointBooleanSpec.eventModelId ? eventSetPointBooleanSpec.eventModelId : eventSetPointBooleanSpec.staticId - consumer.accept(new EventSetPointBoolean(eventModelId, eventSetPointBooleanSpec.staticId, - eventSetPointBooleanSpec.startTime, eventSetPointBooleanSpec.stateEvent)) + @Override + EventModel build() { + checkData() + new EventSetPointBoolean(eventModelId, staticId, startTime, stateEvent) } } } 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 544192790..1c5c4aa12 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,62 +8,35 @@ package com.powsybl.dynawaltz.dsl.models.buses import com.google.auto.service.AutoService -import com.powsybl.dsl.DslException import com.powsybl.dynamicsimulation.DynamicModel import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension -import com.powsybl.dynawaltz.DynaWaltzProvider +import com.powsybl.dynawaltz.dsl.AbstractDynamicModelBuilder +import com.powsybl.dynawaltz.dsl.AbstractPowsyblDynawoGroovyExtension import com.powsybl.dynawaltz.models.buses.StandardBus -import java.util.function.Consumer - /** * An implementation of {@link DynamicModelGroovyExtension} that adds the
Bus
keyword to the DSL * * @author Dimitri Baudrier */ @AutoService(DynamicModelGroovyExtension.class) -class BusGroovyExtension implements DynamicModelGroovyExtension { - - static class BusSpec { - String dynamicModelId - String staticId - String parameterSetId - - void dynamicModelId(String dynamicModelId) { - this.dynamicModelId = dynamicModelId - } +class BusGroovyExtension extends AbstractPowsyblDynawoGroovyExtension implements DynamicModelGroovyExtension { - void staticId(String staticId) { - this.staticId = staticId - } - - void parameterSetId(String parameterSetId) { - this.parameterSetId = parameterSetId - } + BusGroovyExtension() { + modelTags = ["Bus"] } - String getName() { - return DynaWaltzProvider.NAME + @Override + protected BusBuilder createBuilder(String currentTag) { + new BusBuilder() } - - void load(Binding binding, Consumer consumer) { - binding.Bus = { Closure closure -> - def cloned = closure.clone() - BusSpec busSpec = new BusSpec() - - cloned.delegate = busSpec - cloned() - if (!busSpec.staticId) { - throw new DslException("'staticId' field is not set"); - } - if (!busSpec.parameterSetId) { - throw new DslException("'parameterSetId' field is not set") - } + static class BusBuilder extends AbstractDynamicModelBuilder { - String dynamicModelId = busSpec.dynamicModelId ? busSpec.dynamicModelId : busSpec.staticId - consumer.accept(new StandardBus(dynamicModelId, busSpec.staticId, busSpec.parameterSetId)) + @Override + StandardBus build() { + checkData() + new StandardBus(dynamicModelId, staticId, parameterSetId) } } - } 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 0c0186785..033c89a63 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,37 +7,33 @@ package com.powsybl.dynawaltz.dsl.models.generators import com.google.auto.service.AutoService -import com.powsybl.dsl.DslException import com.powsybl.dynamicsimulation.DynamicModel import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension +import com.powsybl.dynawaltz.dsl.AbstractDynamicModelBuilder +import com.powsybl.dynawaltz.dsl.AbstractPowsyblDynawoGroovyExtension import com.powsybl.dynawaltz.models.generators.GeneratorFictitious -import java.util.function.Consumer - /** * @author Dimitri Baudrier */ @AutoService(DynamicModelGroovyExtension.class) -class GeneratorFictitiousGroovyExtension extends GeneratorModelGroovyExtension { +class GeneratorFictitiousGroovyExtension extends AbstractPowsyblDynawoGroovyExtension implements DynamicModelGroovyExtension { - void load(Binding binding, Consumer consumer) { - binding.GeneratorFictitious = { Closure closure -> - def cloned = closure.clone() - GeneratorModelSpec generatorModelSpec = new GeneratorModelSpec() + GeneratorFictitiousGroovyExtension() { + modelTags = ["GeneratorFictitious"] + } - cloned.delegate = generatorModelSpec - cloned() + @Override + protected GeneratorFictitiousBuilder createBuilder(String currentTag) { + new GeneratorFictitiousBuilder() + } - if (!generatorModelSpec.staticId) { - throw new DslException("'staticId' field is not set") - } - if (!generatorModelSpec.parameterSetId) { - throw new DslException("'parameterSetId' field is not set") - } + static class GeneratorFictitiousBuilder extends AbstractDynamicModelBuilder { - String dynamicModelId = generatorModelSpec.dynamicModelId ? generatorModelSpec.dynamicModelId : generatorModelSpec.staticId - consumer.accept(new GeneratorFictitious(dynamicModelId, generatorModelSpec.staticId, generatorModelSpec.parameterSetId)) + @Override + GeneratorFictitious build() { + checkData() + new GeneratorFictitious(dynamicModelId, staticId, parameterSetId) } } - } diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/GeneratorModelGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/GeneratorModelGroovyExtension.groovy deleted file mode 100644 index a3fe635a8..000000000 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/GeneratorModelGroovyExtension.groovy +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright (c) 2020, 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/. - */ -package com.powsybl.dynawaltz.dsl.models.generators - -import com.powsybl.dynawaltz.models.generators.GeneratorSynchronous - -import java.util.function.Consumer - -import com.google.auto.service.AutoService -import com.powsybl.dsl.DslException -import com.powsybl.dynamicsimulation.DynamicModel -import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension - -import com.powsybl.dynawaltz.DynaWaltzProvider - -/** - * @author Marcos de Miguel - */ -@AutoService(DynamicModelGroovyExtension.class) -class GeneratorModelGroovyExtension implements DynamicModelGroovyExtension { - - private static final String GENERATORS_CONFIG = "synchronous_generators.cfg"; - private static final String SYNCHRONOUS_GENERATORS_LIBS = "synchronousGeneratorsLibs"; - - static class GeneratorModelSpec { - String dynamicModelId - String staticId - String parameterSetId - - void dynamicModelId(String dynamicModelId) { - this.dynamicModelId = dynamicModelId - } - - void staticId(String staticId) { - this.staticId = staticId - } - - void parameterSetId(String parameterSetId) { - this.parameterSetId = parameterSetId - } - } - - String getName() { - return DynaWaltzProvider.NAME - } - - void load(Binding binding, Consumer consumer) { - ConfigSlurper config = new ConfigSlurper() - def cfg = config.parse(this.getClass().getClassLoader().getResource(GENERATORS_CONFIG)).get(SYNCHRONOUS_GENERATORS_LIBS) - for (String gen : cfg.keySet()) { - binding.setVariable(gen, generatorClosure(consumer, gen)) - } - } - - def generatorClosure = { - Consumer consumer, String generator -> - { - Closure closure -> { - def cloned = closure.clone() - GeneratorModelSpec generatorModelSpec = new GeneratorModelSpec() - - cloned.delegate = generatorModelSpec - cloned() - - if (!generatorModelSpec.staticId) {SYNCHRONOUS_GENERATORS_LIBS - throw new DslException("'staticId' field is not set") - } - if (!generatorModelSpec.parameterSetId) { - throw new DslException("'parameterSetId' field is not set") - } - - String dynamicModelId = generatorModelSpec.dynamicModelId ? generatorModelSpec.dynamicModelId : generatorModelSpec.staticId - consumer.accept(new GeneratorSynchronous(dynamicModelId, generatorModelSpec.staticId, generatorModelSpec.parameterSetId, generator)) - } - } - } -} diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/GeneratorSynchronousGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/GeneratorSynchronousGroovyExtension.groovy new file mode 100644 index 000000000..fee466c38 --- /dev/null +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/generators/GeneratorSynchronousGroovyExtension.groovy @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2020, 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/. + */ +package com.powsybl.dynawaltz.dsl.models.generators + +import com.google.auto.service.AutoService +import com.powsybl.dynamicsimulation.DynamicModel +import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension +import com.powsybl.dynawaltz.dsl.AbstractDynamicModelBuilder +import com.powsybl.dynawaltz.dsl.AbstractPowsyblDynawoGroovyExtension +import com.powsybl.dynawaltz.models.generators.GeneratorSynchronous + +/** + * @author Marcos de Miguel + */ +@AutoService(DynamicModelGroovyExtension.class) +class GeneratorSynchronousGroovyExtension extends AbstractPowsyblDynawoGroovyExtension implements DynamicModelGroovyExtension { + + protected static final String GENERATORS_CONFIG = "synchronous_generators.cfg" + protected static final String SYNCHRONOUS_GENERATORS = "synchronousGenerators" + + GeneratorSynchronousGroovyExtension() { + ConfigSlurper config = new ConfigSlurper() + modelTags = config.parse(this.getClass().getClassLoader().getResource(GENERATORS_CONFIG)).get(SYNCHRONOUS_GENERATORS).keySet() as List + } + + @Override + protected GeneratorBuilder createBuilder(String currentTag) { + new GeneratorBuilder(currentTag) + } + + static class GeneratorBuilder extends AbstractDynamicModelBuilder { + + String tag + + GeneratorBuilder(String tag) { + this.tag = tag + } + + @Override + GeneratorSynchronous build() { + checkData() + new GeneratorSynchronous(dynamicModelId, staticId, parameterSetId, tag) + } + } +} diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/lines/LineGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/lines/LineGroovyExtension.groovy index db6638caf..e6cb863f8 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/lines/LineGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/lines/LineGroovyExtension.groovy @@ -8,70 +8,46 @@ package com.powsybl.dynawaltz.dsl.models.lines import com.google.auto.service.AutoService -import com.powsybl.dsl.DslException import com.powsybl.dynamicsimulation.DynamicModel import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension -import com.powsybl.dynawaltz.DynaWaltzProvider -import com.powsybl.dynawaltz.models.buses.StandardBus +import com.powsybl.dynawaltz.dsl.AbstractDynamicModelBuilder +import com.powsybl.dynawaltz.dsl.AbstractPowsyblDynawoGroovyExtension import com.powsybl.dynawaltz.models.lines.StandardLine import com.powsybl.iidm.network.Branch -import java.util.function.Consumer - /** * An implementation of {@link DynamicModelGroovyExtension} that adds the
Line
keyword to the DSL * * @author Dimitri Baudrier */ @AutoService(DynamicModelGroovyExtension.class) -class LineGroovyExtension implements DynamicModelGroovyExtension { +class LineGroovyExtension extends AbstractPowsyblDynawoGroovyExtension implements DynamicModelGroovyExtension { - static class LineSpec { - String dynamicModelId - String staticId - String parameterSetId - Branch.Side side + LineGroovyExtension() { + modelTags = ["Line"] + } - void dynamicModelId(String dynamicModelId) { - this.dynamicModelId = dynamicModelId - } + @Override + protected LineBuilder createBuilder(String currentTag) { + new LineBuilder() + } - void staticId(String staticId) { - this.staticId = staticId - } + static class LineBuilder extends AbstractDynamicModelBuilder { - void parameterSetId(String parameterSetId) { - this.parameterSetId = parameterSetId + Branch.Side side + + LineBuilder() { + side = Branch.Side.ONE } void side(Branch.Side side) { this.side = side } - } - - String getName() { - return DynaWaltzProvider.NAME - } - - void load(Binding binding, Consumer consumer) { - binding.Line = { Closure closure -> - def cloned = closure.clone() - LineSpec lineSpec = new LineSpec() - - cloned.delegate = lineSpec - cloned() - - if (!lineSpec.staticId) { - throw new DslException("'staticId' field is not set"); - } - if (!lineSpec.parameterSetId) { - throw new DslException("'parameterSetId' field is not set") - } - String dynamicModelId = lineSpec.dynamicModelId ? lineSpec.dynamicModelId : lineSpec.staticId - Branch.Side side = lineSpec.side ? lineSpec.side : Branch.Side.ONE - consumer.accept(new StandardLine(dynamicModelId, lineSpec.staticId, lineSpec.parameterSetId, side)) + @Override + StandardLine build() { + checkData() + new StandardLine(dynamicModelId, staticId, parameterSetId, side) } } - } diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadAlphaBetaGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadAlphaBetaGroovyExtension.groovy index 2e8a17aac..58c1a2f63 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadAlphaBetaGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadAlphaBetaGroovyExtension.groovy @@ -6,14 +6,11 @@ */ package com.powsybl.dynawaltz.dsl.models.loads -import java.util.function.Consumer - import com.google.auto.service.AutoService -import com.powsybl.dsl.DslException import com.powsybl.dynamicsimulation.DynamicModel import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension - -import com.powsybl.dynawaltz.DynaWaltzProvider +import com.powsybl.dynawaltz.dsl.AbstractDynamicModelBuilder +import com.powsybl.dynawaltz.dsl.AbstractPowsyblDynawoGroovyExtension import com.powsybl.dynawaltz.models.loads.LoadAlphaBeta /** @@ -22,48 +19,22 @@ import com.powsybl.dynawaltz.models.loads.LoadAlphaBeta * @author Marcos de Miguel */ @AutoService(DynamicModelGroovyExtension.class) -class LoadAlphaBetaGroovyExtension implements DynamicModelGroovyExtension { - - static class LoadAlphaBetaSpec { - String dynamicModelId - String staticId - String parameterSetId - - void dynamicModelId(String dynamicModelId) { - this.dynamicModelId = dynamicModelId - } +class LoadAlphaBetaGroovyExtension extends AbstractPowsyblDynawoGroovyExtension implements DynamicModelGroovyExtension { - void staticId(String staticId) { - this.staticId = staticId - } - - void parameterSetId(String parameterSetId) { - this.parameterSetId = parameterSetId - } + LoadAlphaBetaGroovyExtension() { + modelTags = ["LoadAlphaBeta"] } - String getName() { - return DynaWaltzProvider.NAME + @Override + protected LoadAlphaBetaBuilder createBuilder(String currentTag) { + new LoadAlphaBetaBuilder() } - - void load(Binding binding, Consumer consumer) { - binding.LoadAlphaBeta = { Closure closure -> - def cloned = closure.clone() - LoadAlphaBetaSpec loadAlphaBetaSpec = new LoadAlphaBetaSpec() - - cloned.delegate = loadAlphaBetaSpec - cloned() - if (!loadAlphaBetaSpec.staticId) { - throw new DslException("'staticId' field is not set"); - } - if (!loadAlphaBetaSpec.parameterSetId) { - throw new DslException("'parameterSetId' field is not set") - } - - String dynamicModelId = loadAlphaBetaSpec.dynamicModelId ? loadAlphaBetaSpec.dynamicModelId : loadAlphaBetaSpec.staticId - consumer.accept(new LoadAlphaBeta(dynamicModelId, loadAlphaBetaSpec.staticId, loadAlphaBetaSpec.parameterSetId)) + static class LoadAlphaBetaBuilder extends AbstractDynamicModelBuilder { + @Override + LoadAlphaBeta build() { + checkData() + new LoadAlphaBeta(dynamicModelId, staticId, parameterSetId) } } - } diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadOneTransformerGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadOneTransformerGroovyExtension.groovy index e7d37106a..69f309a0f 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadOneTransformerGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/loads/LoadOneTransformerGroovyExtension.groovy @@ -6,15 +6,12 @@ */ package com.powsybl.dynawaltz.dsl.models.loads -import com.powsybl.dynawaltz.models.loads.LoadOneTransformer - -import java.util.function.Consumer - import com.google.auto.service.AutoService -import com.powsybl.dsl.DslException import com.powsybl.dynamicsimulation.DynamicModel import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension -import com.powsybl.dynawaltz.DynaWaltzProvider +import com.powsybl.dynawaltz.dsl.AbstractDynamicModelBuilder +import com.powsybl.dynawaltz.dsl.AbstractPowsyblDynawoGroovyExtension +import com.powsybl.dynawaltz.models.loads.LoadOneTransformer /** * An implementation of {@link DynamicModelGroovyExtension} that adds the
LoadOneTransformer
keyword to the DSL @@ -22,48 +19,22 @@ import com.powsybl.dynawaltz.DynaWaltzProvider * @author Marcos de Miguel */ @AutoService(DynamicModelGroovyExtension.class) -class LoadOneTransformerGroovyExtension implements DynamicModelGroovyExtension { - - static class LoadOneTransformerSpec { - String dynamicModelId - String staticId - String parameterSetId - - void dynamicModelId(String dynamicModelId) { - this.dynamicModelId = dynamicModelId - } - - void staticId(String staticId) { - this.staticId = staticId - } +class LoadOneTransformerGroovyExtension extends AbstractPowsyblDynawoGroovyExtension implements DynamicModelGroovyExtension { - void parameterSetId(String parameterSetId) { - this.parameterSetId = parameterSetId - } + LoadOneTransformerGroovyExtension() { + modelTags = ["LoadOneTransformer"] } - String getName() { - return DynaWaltzProvider.NAME + @Override + protected LoadOneTransformerBuilder createBuilder(String currentTag) { + new LoadOneTransformerBuilder() } - - void load(Binding binding, Consumer consumer) { - binding.LoadOneTransformer = { Closure closure -> - def cloned = closure.clone() - LoadOneTransformerSpec loadOneTransformerSpec = new LoadOneTransformerSpec() - - cloned.delegate = loadOneTransformerSpec - cloned() - - if (!loadOneTransformerSpec.staticId) { - throw new DslException("'staticId' field is not set"); - } - if (!loadOneTransformerSpec.parameterSetId) { - throw new DslException("'parameterSetId' field is not set") - } - String dynamicModelId = loadOneTransformerSpec.dynamicModelId ? loadOneTransformerSpec.dynamicModelId : loadOneTransformerSpec.staticId - consumer.accept(new LoadOneTransformer(dynamicModelId, loadOneTransformerSpec.staticId, loadOneTransformerSpec.parameterSetId)) + static class LoadOneTransformerBuilder extends AbstractDynamicModelBuilder { + @Override + LoadOneTransformer build() { + checkData() + new LoadOneTransformer(dynamicModelId, staticId, parameterSetId) } } - } diff --git a/dynawaltz-dsl/src/main/resources/synchronous_generators.cfg b/dynawaltz-dsl/src/main/resources/synchronous_generators.cfg index 7e7d83969..583ab4be9 100644 --- a/dynawaltz-dsl/src/main/resources/synchronous_generators.cfg +++ b/dynawaltz-dsl/src/main/resources/synchronous_generators.cfg @@ -1,4 +1,4 @@ -synchronousGeneratorsLibs { +synchronousGenerators { GeneratorSynchronousFourWindings GeneratorSynchronousFourWindingsGoverPropVRPropInt GeneratorSynchronousFourWindingsGovSteam1ExcIEEEST4B diff --git a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynaWaltzGroovyDynamicModelsSupplierTest.java b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynaWaltzGroovyDynamicModelsSupplierTest.java index e27b5c984..918a6d2c7 100644 --- a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynaWaltzGroovyDynamicModelsSupplierTest.java +++ b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynaWaltzGroovyDynamicModelsSupplierTest.java @@ -14,16 +14,18 @@ import com.powsybl.dynamicsimulation.groovy.GroovyDynamicModelsSupplier; import com.powsybl.dynamicsimulation.groovy.GroovyExtension; import com.powsybl.dynawaltz.DynaWaltzProvider; +import com.powsybl.dynawaltz.dsl.automatons.CurrentLimitAutomatonGroovyExtension; import com.powsybl.dynawaltz.dsl.models.buses.BusGroovyExtension; -import com.powsybl.dynawaltz.dsl.models.generators.GeneratorModelGroovyExtension; +import com.powsybl.dynawaltz.dsl.models.generators.GeneratorFictitiousGroovyExtension; +import com.powsybl.dynawaltz.dsl.models.generators.GeneratorSynchronousGroovyExtension; import com.powsybl.dynawaltz.dsl.models.lines.LineGroovyExtension; import com.powsybl.dynawaltz.dsl.models.loads.LoadAlphaBetaGroovyExtension; import com.powsybl.dynawaltz.dsl.models.loads.LoadOneTransformerGroovyExtension; import com.powsybl.dynawaltz.models.AbstractBlackBoxModel; import com.powsybl.dynawaltz.models.automatons.CurrentLimitAutomaton; -import com.powsybl.dynawaltz.dsl.automatons.CurrentLimitAutomatonGroovyExtension; import com.powsybl.dynawaltz.models.buses.StandardBus; -import com.powsybl.dynawaltz.models.generators.*; +import com.powsybl.dynawaltz.models.generators.GeneratorFictitious; +import com.powsybl.dynawaltz.models.generators.GeneratorSynchronous; import com.powsybl.dynawaltz.models.lines.StandardLine; import com.powsybl.dynawaltz.models.loads.LoadAlphaBeta; import com.powsybl.dynawaltz.models.loads.LoadOneTransformer; @@ -157,11 +159,12 @@ private static Network createEurostagTutorialExample1WithMoreGens() { } private void validateExtension(DynamicModelGroovyExtension extension) { + boolean isLoadAlphaBetaExtension = extension instanceof LoadAlphaBetaGroovyExtension; boolean isLoadOneTransformerExtension = extension instanceof LoadOneTransformerGroovyExtension; - boolean isLoadExtension = isLoadAlphaBetaExtension || isLoadOneTransformerExtension; - boolean isGeneratorExtension = extension instanceof GeneratorModelGroovyExtension; + + boolean isGeneratorExtension = extension instanceof GeneratorSynchronousGroovyExtension || extension instanceof GeneratorFictitiousGroovyExtension; boolean isBusExtension = extension instanceof BusGroovyExtension; boolean isLineExtension = extension instanceof LineGroovyExtension; boolean isDynamicModelExtension = isLoadExtension || isGeneratorExtension || isBusExtension || isLineExtension; diff --git a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynaWaltzGroovyEventModelsSupplierTest.java b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynaWaltzGroovyEventModelsSupplierTest.java index 8713ecc3d..e867a7c4e 100644 --- a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynaWaltzGroovyEventModelsSupplierTest.java +++ b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynaWaltzGroovyEventModelsSupplierTest.java @@ -14,16 +14,15 @@ import com.powsybl.dynamicsimulation.groovy.GroovyEventModelsSupplier; import com.powsybl.dynamicsimulation.groovy.GroovyExtension; import com.powsybl.dynawaltz.DynaWaltzProvider; -import com.powsybl.dynawaltz.models.AbstractPureDynamicBlackBoxModel; -import com.powsybl.dynawaltz.models.events.EventQuadripoleDisconnection; import com.powsybl.dynawaltz.dsl.events.EventQuadripoleDisconnectionGroovyExtension; import com.powsybl.dynawaltz.dsl.events.EventSetPointBooleanGroovyExtension; +import com.powsybl.dynawaltz.models.AbstractPureDynamicBlackBoxModel; +import com.powsybl.dynawaltz.models.events.EventQuadripoleDisconnection; import com.powsybl.iidm.network.Identifiable; import com.powsybl.iidm.network.Line; import com.powsybl.iidm.network.Network; import com.powsybl.iidm.network.NetworkFactory; import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; - import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -69,7 +68,7 @@ public void test() { List eventModels = supplier.get(network); int numLines = network.getLineCount(); - int expectedEventModelsSize = numLines; + int expectedEventModelsSize = numLines; assertEquals(expectedEventModelsSize, eventModels.size()); eventModels.forEach(this::validateModel); } @@ -91,7 +90,7 @@ private void validateModel(EventModel eventModel) { assertTrue(eventModel instanceof AbstractPureDynamicBlackBoxModel); AbstractPureDynamicBlackBoxModel blackBoxEventModel = (AbstractPureDynamicBlackBoxModel) eventModel; if (blackBoxEventModel instanceof EventQuadripoleDisconnection) { - Identifiable identifiable = network.getIdentifiable(((EventQuadripoleDisconnection) blackBoxEventModel).getLineStaticId()); + Identifiable identifiable = network.getIdentifiable(((EventQuadripoleDisconnection) blackBoxEventModel).getEquipmentStaticId()); assertEquals("EM_" + identifiable.getId(), blackBoxEventModel.getDynamicModelId()); assertEquals(blackBoxEventModel.getDynamicModelId(), blackBoxEventModel.getParameterSetId()); assertTrue(identifiable instanceof Line); diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/AbstractEventModel.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/AbstractEventModel.java index 256d7c3fa..fd942beb2 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/AbstractEventModel.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/AbstractEventModel.java @@ -23,13 +23,19 @@ */ public abstract class AbstractEventModel extends AbstractPureDynamicBlackBoxModel implements EventModel { + private final String equipmentStaticId; private final double startTime; - protected AbstractEventModel(String dynamicModelId, double startTime) { + protected AbstractEventModel(String dynamicModelId, String equipmentStaticId, double startTime) { super(dynamicModelId, dynamicModelId); + this.equipmentStaticId = equipmentStaticId; this.startTime = startTime; } + public String getEquipmentStaticId() { + return equipmentStaticId; + } + @Override public double getStartTime() { return startTime; diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventQuadripoleDisconnection.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventQuadripoleDisconnection.java index 47d9e14a8..6ac5316c6 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventQuadripoleDisconnection.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventQuadripoleDisconnection.java @@ -26,14 +26,12 @@ */ public class EventQuadripoleDisconnection extends AbstractEventModel { - private final String lineStaticId; private final boolean disconnectOrigin; private final boolean disconnectExtremity; - public EventQuadripoleDisconnection(String eventModelId, String staticId, double startTime, + public EventQuadripoleDisconnection(String eventModelId, String lineStaticId, double startTime, boolean disconnectOrigin, boolean disconnectExtremity) { - super(eventModelId, startTime); - this.lineStaticId = staticId; + super(eventModelId, lineStaticId, startTime); this.disconnectOrigin = disconnectOrigin; this.disconnectExtremity = disconnectExtremity; } @@ -53,17 +51,13 @@ public List getVarConnectionsWith(Model connected) { @Override public List getModelsConnectedTo(DynaWaltzContext context) { - BlackBoxModel connectedBbm = context.getStaticIdBlackBoxModelMap().get(lineStaticId); + BlackBoxModel connectedBbm = context.getStaticIdBlackBoxModelMap().get(getEquipmentStaticId()); if (connectedBbm == null) { - return List.of(context.getNetworkModel().getDefaultLineModel(lineStaticId, Branch.Side.ONE)); + return List.of(context.getNetworkModel().getDefaultLineModel(getEquipmentStaticId(), Branch.Side.ONE)); } return List.of(connectedBbm); } - public String getLineStaticId() { - return lineStaticId; - } - @Override protected void writeEventSpecificParameters(XMLStreamWriter writer, DynaWaltzContext context) throws XMLStreamException { ParametersXml.writeParameter(writer, BOOL, "event_disconnectOrigin", Boolean.toString(disconnectOrigin)); diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventSetPointBoolean.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventSetPointBoolean.java index 829b63aae..a7cae41f7 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventSetPointBoolean.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventSetPointBoolean.java @@ -25,12 +25,10 @@ */ public class EventSetPointBoolean extends AbstractEventModel { - private final String generatorStaticId; private final boolean stateEvent; - public EventSetPointBoolean(String eventModelId, String staticId, double startTime, boolean stateEvent) { - super(eventModelId, startTime); - this.generatorStaticId = staticId; + public EventSetPointBoolean(String eventModelId, String generatorStaticId, double startTime, boolean stateEvent) { + super(eventModelId, generatorStaticId, startTime); this.stateEvent = stateEvent; } @@ -49,9 +47,9 @@ public List getVarConnectionsWith(Model connected) { @Override public List getModelsConnectedTo(DynaWaltzContext context) { - BlackBoxModel connectedBbm = context.getStaticIdBlackBoxModelMap().get(generatorStaticId); + BlackBoxModel connectedBbm = context.getStaticIdBlackBoxModelMap().get(getEquipmentStaticId()); if (connectedBbm == null) { - throw new PowsyblException("Cannot find generator '" + generatorStaticId + "' among the dynamic models provided"); + throw new PowsyblException("Cannot find generator '" + getEquipmentStaticId() + "' among the dynamic models provided"); } return List.of(connectedBbm); }