-
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.
Add Phase Shifter Blocking I automation system (#364)
Signed-off-by: lisrte <[email protected]>
- Loading branch information
Showing
20 changed files
with
425 additions
and
28 deletions.
There are no files selected for viewing
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
39 changes: 39 additions & 0 deletions
39
...src/main/java/com/powsybl/dynawaltz/models/automationsystems/ConnectionStatefulModel.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,39 @@ | ||
/** | ||
* Copyright (c) 2024, 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.automationsystems; | ||
|
||
import com.powsybl.dynawaltz.models.macroconnections.MacroConnectionsAdder; | ||
|
||
/** | ||
* Indicates the connection state of a dynamic model | ||
* Used when dynamic model try to connect to a pure dynamic model | ||
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>} | ||
*/ | ||
public interface ConnectionStatefulModel { | ||
|
||
/** | ||
* Dynamic model connection state | ||
*/ | ||
enum ConnectionState { | ||
/** | ||
* Connected to specified equipments | ||
*/ | ||
CONNECTED, | ||
/** | ||
* Can not be connected | ||
*/ | ||
CANNOT_CONNECT | ||
} | ||
|
||
ConnectionState getConnectionState(); | ||
|
||
/** | ||
* Verifies if the model is connected, if null try to createMacroConnections | ||
*/ | ||
boolean connect(MacroConnectionsAdder adder); | ||
} |
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
62 changes: 62 additions & 0 deletions
62
...nawaltz/models/automationsystems/phaseshifters/PhaseShifterBlockingIAutomationSystem.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,62 @@ | ||
/** | ||
* Copyright (c) 2024, 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.automationsystems.phaseshifters; | ||
|
||
import com.powsybl.dynawaltz.DynaWaltzContext; | ||
import com.powsybl.dynawaltz.DynawaltzReports; | ||
import com.powsybl.dynawaltz.models.AbstractPureDynamicBlackBoxModel; | ||
import com.powsybl.dynawaltz.models.VarConnection; | ||
import com.powsybl.dynawaltz.models.macroconnections.MacroConnectionsAdder; | ||
import com.powsybl.dynawaltz.models.transformers.TransformerModel; | ||
import com.powsybl.dynawaltz.models.utils.ImmutableLateInit; | ||
import com.powsybl.iidm.network.TwoWindingsTransformer; | ||
|
||
import javax.xml.stream.XMLStreamException; | ||
import javax.xml.stream.XMLStreamWriter; | ||
import java.util.List; | ||
|
||
/** | ||
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>} | ||
*/ | ||
public class PhaseShifterBlockingIAutomationSystem extends AbstractPureDynamicBlackBoxModel { | ||
|
||
private final String phaseShifterIDynamicId; | ||
private final ImmutableLateInit<TwoWindingsTransformer> transformer = new ImmutableLateInit<>(); | ||
private boolean isConnected = true; | ||
|
||
protected PhaseShifterBlockingIAutomationSystem(String dynamicModelId, String phaseShifterIDynamicId, String parameterSetId, String lib) { | ||
super(dynamicModelId, parameterSetId, lib); | ||
this.phaseShifterIDynamicId = phaseShifterIDynamicId; | ||
} | ||
|
||
@Override | ||
public void createMacroConnections(MacroConnectionsAdder adder) { | ||
isConnected = !adder.createMacroConnectionsOrSkip(this, phaseShifterIDynamicId, PhaseShifterIAutomationSystem.class, this::getVarConnectionsWith); | ||
if (isConnected) { | ||
adder.createMacroConnections(this, transformer.getValue(), TransformerModel.class, this::getVarConnectionsWith); | ||
} else { | ||
DynawaltzReports.reportEmptyAutomaton(adder.getReportNode(), getName(), getDynamicModelId(), phaseShifterIDynamicId, PhaseShifterIModel.class.getSimpleName()); | ||
} | ||
} | ||
|
||
protected List<VarConnection> getVarConnectionsWith(PhaseShifterIModel connected) { | ||
transformer.setValue(connected.getConnectedTransformer()); | ||
return List.of(new VarConnection("phaseShifterBlockingI_locked", connected.getLockedVarName())); | ||
} | ||
|
||
protected List<VarConnection> getVarConnectionsWith(TransformerModel connected) { | ||
return List.of(new VarConnection("phaseShifterBlockingI_IMonitored", connected.getIMonitoredVarName())); | ||
} | ||
|
||
@Override | ||
public void write(XMLStreamWriter writer, DynaWaltzContext context) throws XMLStreamException { | ||
if (isConnected) { | ||
super.write(writer, context); | ||
} | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
.../models/automationsystems/phaseshifters/PhaseShifterBlockingIAutomationSystemBuilder.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,82 @@ | ||
/** | ||
* Copyright (c) 2024, 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.automationsystems.phaseshifters; | ||
|
||
import com.powsybl.commons.report.ReportNode; | ||
import com.powsybl.dynawaltz.builders.BuilderReports; | ||
import com.powsybl.dynawaltz.builders.ModelConfig; | ||
import com.powsybl.dynawaltz.builders.ModelConfigs; | ||
import com.powsybl.dynawaltz.builders.ModelConfigsHandler; | ||
import com.powsybl.dynawaltz.models.automationsystems.AbstractAutomationSystemModelBuilder; | ||
import com.powsybl.iidm.network.Network; | ||
|
||
import java.util.Set; | ||
|
||
/** | ||
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>} | ||
*/ | ||
public class PhaseShifterBlockingIAutomationSystemBuilder extends AbstractAutomationSystemModelBuilder<PhaseShifterBlockingIAutomationSystemBuilder> { | ||
|
||
public static final String CATEGORY = "PHASE_SHIFTER_BLOCKING_I"; | ||
private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); | ||
|
||
public static PhaseShifterBlockingIAutomationSystemBuilder of(Network network) { | ||
return of(network, ReportNode.NO_OP); | ||
} | ||
|
||
public static PhaseShifterBlockingIAutomationSystemBuilder of(Network network, ReportNode reportNode) { | ||
return new PhaseShifterBlockingIAutomationSystemBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reportNode); | ||
} | ||
|
||
public static PhaseShifterBlockingIAutomationSystemBuilder of(Network network, String lib) { | ||
return of(network, lib, ReportNode.NO_OP); | ||
} | ||
|
||
public static PhaseShifterBlockingIAutomationSystemBuilder of(Network network, String lib, ReportNode reportNode) { | ||
ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); | ||
if (modelConfig == null) { | ||
BuilderReports.reportLibNotFound(reportNode, PhaseShifterBlockingIAutomationSystemBuilder.class.getSimpleName(), lib); | ||
return null; | ||
} | ||
return new PhaseShifterBlockingIAutomationSystemBuilder(network, modelConfig, reportNode); | ||
} | ||
|
||
public static Set<String> getSupportedLibs() { | ||
return MODEL_CONFIGS.getSupportedLibs(); | ||
} | ||
|
||
private String phaseShifterIDynamicId; | ||
|
||
protected PhaseShifterBlockingIAutomationSystemBuilder(Network network, ModelConfig modelConfig, ReportNode reportNode) { | ||
super(network, modelConfig, reportNode); | ||
} | ||
|
||
public PhaseShifterBlockingIAutomationSystemBuilder phaseShifterId(String phaseShifterIDynamicId) { | ||
this.phaseShifterIDynamicId = phaseShifterIDynamicId; | ||
return self(); | ||
} | ||
|
||
@Override | ||
protected void checkData() { | ||
super.checkData(); | ||
if (phaseShifterIDynamicId == null) { | ||
BuilderReports.reportFieldNotSet(reportNode, "phaseShifterId"); | ||
isInstantiable = false; | ||
} | ||
} | ||
|
||
@Override | ||
public PhaseShifterBlockingIAutomationSystem build() { | ||
return isInstantiable() ? new PhaseShifterBlockingIAutomationSystem(dynamicModelId, phaseShifterIDynamicId, parameterSetId, getLib()) : null; | ||
} | ||
|
||
@Override | ||
protected PhaseShifterBlockingIAutomationSystemBuilder self() { | ||
return this; | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
...java/com/powsybl/dynawaltz/models/automationsystems/phaseshifters/PhaseShifterIModel.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,21 @@ | ||
/** | ||
* Copyright (c) 2024, 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.automationsystems.phaseshifters; | ||
|
||
import com.powsybl.dynawaltz.models.Model; | ||
import com.powsybl.iidm.network.TwoWindingsTransformer; | ||
|
||
/** | ||
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>} | ||
*/ | ||
public interface PhaseShifterIModel extends Model { | ||
|
||
TwoWindingsTransformer getConnectedTransformer(); | ||
|
||
String getLockedVarName(); | ||
} |
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.