-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: BAUDRIER Dimitri <dimitri.baudrier@rte-france.com>
- Loading branch information
Showing
15 changed files
with
243 additions
and
31 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
...main/groovy/com/powsybl/dynawaltz/dsl/models/generators/GeneratorPQGroovyExtension.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2022, 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.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.models.generators.GeneratorPQ | ||
|
||
import java.util.function.Consumer | ||
|
||
/** | ||
* An implementation of {@link DynamicModelGroovyExtension} that adds the <pre>GeneratorPQ</pre> keyword to the DSL | ||
* | ||
*/ | ||
@AutoService(DynamicModelGroovyExtension.class) | ||
class GeneratorPQGroovyExtension extends GeneratorModelGroovyExtension { | ||
|
||
void load(Binding binding, Consumer<DynamicModel> consumer) { | ||
binding.GeneratorPQ = { Closure<Void> closure -> | ||
def cloned = closure.clone() | ||
GeneratorModelSpec generatorModelSpec = new GeneratorModelSpec() | ||
|
||
cloned.delegate = generatorModelSpec | ||
cloned() | ||
|
||
if (!generatorModelSpec.staticId) { | ||
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 GeneratorPQ(dynamicModelId, generatorModelSpec.staticId, generatorModelSpec.parameterSetId)) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...va/com/powsybl/dynawaltz/models/generators/AbstractGeneratorConnectedToOmegaRefModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Copyright (c) 2022, 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.models.generators; | ||
|
||
public abstract class AbstractGeneratorConnectedToOmegaRefModel extends AbstractGeneratorModel implements GeneratorConnectedToOmegaRefModel { | ||
|
||
protected AbstractGeneratorConnectedToOmegaRefModel(String dynamicModelId, String staticId, String parameterSetId, | ||
String terminalVarName, String switchOffSignalNodeVarName, | ||
String switchOffSignalEventVarName, String switchOffSignalAutomatonVarName, | ||
String runningVarName) { | ||
super(dynamicModelId, staticId, parameterSetId, | ||
terminalVarName, switchOffSignalNodeVarName, | ||
switchOffSignalEventVarName, switchOffSignalAutomatonVarName, | ||
runningVarName); | ||
} | ||
|
||
@Override | ||
public String getOmegaRefPuVarName() { | ||
return "generator_omegaRefPu"; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
.../main/java/com/powsybl/dynawaltz/models/generators/GeneratorConnectedToOmegaRefModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Copyright (c) 2022, 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.models.generators; | ||
|
||
public interface GeneratorConnectedToOmegaRefModel extends GeneratorModel { | ||
String getOmegaRefPuVarName(); | ||
} |
26 changes: 26 additions & 0 deletions
26
dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/GeneratorPQ.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright (c) 2022, 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.models.generators; | ||
|
||
public class GeneratorPQ extends AbstractGeneratorConnectedToOmegaRefModel implements GeneratorConnectedToOmegaRefModel { | ||
|
||
public GeneratorPQ(String dynamicModelId, String staticId, String parameterSetId) { | ||
super(dynamicModelId, staticId, parameterSetId, | ||
"generator_terminal", | ||
"generator_switchOffSignal1", | ||
"generator_switchOffSignal2", | ||
"generator_switchOffSignal3", | ||
"generator_running"); | ||
} | ||
|
||
@Override | ||
public String getLib() { | ||
return "GeneratorPQ"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.