Skip to content

Commit

Permalink
add Tempo extension for OverloadManagementsystem Trippings
Browse files Browse the repository at this point in the history
Signed-off-by: CHIQUET Benoit <[email protected]>
  • Loading branch information
bc-rte committed Oct 8, 2024
1 parent 473d382 commit 3186719
Show file tree
Hide file tree
Showing 18 changed files with 493 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
*/
package com.powsybl.iidm.network;

import com.powsybl.commons.extensions.Extendable;

import java.util.List;
import java.util.Optional;

/**
* An overload management system.
Expand All @@ -16,7 +19,16 @@
*/
public interface OverloadManagementSystem extends AutomationSystem<OverloadManagementSystem> {

interface Tripping {
default Optional<Tripping> getTripping(String trippingKey) {
return this.getTrippings()
.stream()
.filter(tripping -> tripping.getKey().equals(trippingKey))
.findFirst();
}

interface Tripping extends Extendable<Tripping> {
OverloadManagementSystem getOverloadManagementSystem();

enum Type {
BRANCH_TRIPPING,
THREE_WINDINGS_TRANSFORMER_TRIPPING,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* 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.iidm.network.extensions;

import com.powsybl.commons.extensions.Extension;
import com.powsybl.iidm.network.OverloadManagementSystem;

public interface TrippingTempo extends Extension<OverloadManagementSystem.Tripping> {
String NAME = "trippingTempo";

@Override
default String getName() {
return NAME;
}

int getTempo();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* 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.iidm.network.extensions;

import com.powsybl.commons.extensions.ExtensionAdder;
import com.powsybl.iidm.network.OverloadManagementSystem;

public interface TrippingTempoAdder
extends ExtensionAdder<OverloadManagementSystem.Tripping, TrippingTempo> {
TrippingTempoAdder withTempo(int tempo);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* 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.iidm.network.extensions;

import com.powsybl.commons.extensions.Extension;
import com.powsybl.iidm.network.OverloadManagementSystem;

public interface TrippingTempoContainer extends Extension<OverloadManagementSystem> {
String NAME = "trippingTempo";

@Override
default String getName() {
return NAME;
}

OverloadManagementSystem.Tripping getTripping();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* 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.iidm.network.extensions;

import com.powsybl.commons.extensions.ExtensionAdder;
import com.powsybl.iidm.network.OverloadManagementSystem;

public interface TrippingTempoContainerAdder extends ExtensionAdder<OverloadManagementSystem, TrippingTempoContainer> {
TrippingTempoContainerAdder withTempo(String tripping, int tempo);
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public OverloadManagementSystem add() {
// Add the trippings
Set<String> knownTrippingKeys = new HashSet<>();
for (AbstractTrippingAdderImpl<?> adder : trippingAdders) {
overloadManagementSystem.addTripping(createTripping(adder, id, knownTrippingKeys));
overloadManagementSystem.addTripping(createTripping(adder, overloadManagementSystem, knownTrippingKeys));
}

getNetwork().getIndex().checkAndAdd(overloadManagementSystem);
Expand All @@ -208,39 +208,39 @@ public OverloadManagementSystem add() {
return overloadManagementSystem;
}

private OverloadManagementSystem.Tripping createTripping(AbstractTrippingAdderImpl<?> adder, String overloadManagementSystemId,
private OverloadManagementSystem.Tripping createTripping(AbstractTrippingAdderImpl<?> adder, OverloadManagementSystem overloadManagementSystem,
Set<String> knownTrippingKeys) {
String key = adder.key;
if (!knownTrippingKeys.add(key)) {
throw new ValidationException(adder, "key \"" + key +
"\" is already used for another tripping in the overload management system.");
}
return switch (adder.getType()) {
case SWITCH_TRIPPING -> createTripping((SwitchTrippingAdderImpl) adder, overloadManagementSystemId);
case BRANCH_TRIPPING -> createTripping((BranchTrippingAdderImpl) adder, overloadManagementSystemId);
case SWITCH_TRIPPING -> createTripping((SwitchTrippingAdderImpl) adder, overloadManagementSystem);
case BRANCH_TRIPPING -> createTripping((BranchTrippingAdderImpl) adder, overloadManagementSystem);
case THREE_WINDINGS_TRANSFORMER_TRIPPING -> createTripping((ThreeWindingsTransformerTrippingAdderImpl) adder,
overloadManagementSystemId);
overloadManagementSystem);
};
}

private OverloadManagementSystem.Tripping createTripping(SwitchTrippingAdderImpl adder, String overloadManagementSystemId) {
private OverloadManagementSystem.Tripping createTripping(SwitchTrippingAdderImpl adder, OverloadManagementSystem overloadManagementSystem) {
return new OverloadManagementSystemImpl.SwitchTrippingImpl(
overloadManagementSystemId, adder.key, adder.name,
overloadManagementSystem, adder.key, adder.name,
adder.currentLimit, adder.openAction,
adder.checkSwitchId());
}

private OverloadManagementSystem.Tripping createTripping(BranchTrippingAdderImpl adder, String overloadManagementSystemId) {
private OverloadManagementSystem.Tripping createTripping(BranchTrippingAdderImpl adder, OverloadManagementSystem overloadManagementSystem) {
return new OverloadManagementSystemImpl.BranchTrippingImpl(
overloadManagementSystemId,
overloadManagementSystem,
adder.key, adder.name, adder.currentLimit, adder.openAction,
adder.checkBranchId(), adder.side);
}

private OverloadManagementSystem.Tripping createTripping(ThreeWindingsTransformerTrippingAdderImpl adder,
String overloadManagementSystemId) {
OverloadManagementSystem overloadManagementSystem) {
return new OverloadManagementSystemImpl.ThreeWindingsTransformerTrippingImpl(
overloadManagementSystemId,
overloadManagementSystem,
adder.key, adder.name, adder.currentLimit, adder.openAction,
adder.checkThreeWindingsTransformerId(), adder.side);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
package com.powsybl.iidm.network.impl;

import com.powsybl.commons.PowsyblException;
import com.powsybl.commons.extensions.AbstractExtendable;
import com.powsybl.iidm.network.*;

import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
* Overload management system implementation.
Expand All @@ -19,16 +23,16 @@
*/
class OverloadManagementSystemImpl extends AbstractAutomationSystem<OverloadManagementSystem> implements OverloadManagementSystem {

abstract static class AbstractTrippingImpl implements Tripping, Validable {
private final String overloadManagementSystemId;
abstract static class AbstractTrippingImpl extends AbstractExtendable<Tripping> implements Tripping, Validable {
private final OverloadManagementSystem overloadManagementSystem;
private final String key;
private String name;
private double currentLimit;
private boolean openAction;

protected AbstractTrippingImpl(String overloadManagementSystemId, String key, String name,
protected AbstractTrippingImpl(OverloadManagementSystem overloadManagementSystem, String key, String name,
double currentLimit, boolean openAction) {
this.overloadManagementSystemId = overloadManagementSystemId;
this.overloadManagementSystem = overloadManagementSystem;
this.key = Objects.requireNonNull(key);
setName(name);
setCurrentLimit(currentLimit);
Expand Down Expand Up @@ -78,23 +82,28 @@ public Tripping setOpenAction(boolean open) {
return this;
}

@Override
public OverloadManagementSystem getOverloadManagementSystem() {
return overloadManagementSystem;
}

protected String getTrippingAttribute() {
return String.format("tripping '%s'", key);
}

@Override
public String getMessageHeader() {
return String.format("Overload management system '%s' - %s:", overloadManagementSystemId, getTrippingAttribute());
return String.format("Overload management system '%s' - %s:", getOverloadManagementSystem().getId(), getTrippingAttribute());
}
}

static class SwitchTrippingImpl extends AbstractTrippingImpl implements SwitchTripping {
private String switchToOperateId;

public SwitchTrippingImpl(String overloadManagementSystemId, String key, String name,
public SwitchTrippingImpl(OverloadManagementSystem overloadManagementSystem, String key, String name,
double currentLimit, boolean openAction,
String switchToOperateId) {
super(overloadManagementSystemId, key, name, currentLimit, openAction);
super(overloadManagementSystem, key, name, currentLimit, openAction);
setSwitchToOperateId(switchToOperateId);
}

Expand All @@ -114,10 +123,10 @@ static class BranchTrippingImpl extends AbstractTrippingImpl implements Overload
private String branchToOperateId;
private TwoSides side;

protected BranchTrippingImpl(String overloadManagementSystemId, String key, String name,
protected BranchTrippingImpl(OverloadManagementSystem overloadManagementSystem, String key, String name,
double currentLimit, boolean openAction,
String branchToOperateId, TwoSides side) {
super(overloadManagementSystemId, key, name, currentLimit, openAction);
super(overloadManagementSystem, key, name, currentLimit, openAction);
setBranchToOperateId(branchToOperateId);
setSideToOperate(side);
}
Expand Down Expand Up @@ -151,10 +160,10 @@ static class ThreeWindingsTransformerTrippingImpl extends AbstractTrippingImpl
private String threeWindingsTransformerId;
private ThreeSides side;

protected ThreeWindingsTransformerTrippingImpl(String overloadManagementSystemId, String key, String name,
protected ThreeWindingsTransformerTrippingImpl(OverloadManagementSystem overloadManagementSystem, String key, String name,
double currentLimit, boolean openAction,
String threeWindingsTransformerId, ThreeSides side) {
super(overloadManagementSystemId, key, name, currentLimit, openAction);
super(overloadManagementSystem, key, name, currentLimit, openAction);
setThreeWindingsTransformerToOperateId(threeWindingsTransformerId);
setSideToOperate(side);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* 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.iidm.network.impl.extensions;

import com.powsybl.commons.extensions.AbstractExtensionAdder;
import com.powsybl.iidm.network.OverloadManagementSystem;
import com.powsybl.iidm.network.extensions.TrippingTempo;
import com.powsybl.iidm.network.extensions.TrippingTempoAdder;

public class TrippingTempoAdderImpl extends AbstractExtensionAdder<OverloadManagementSystem.Tripping, TrippingTempo> implements TrippingTempoAdder {
private int tempo;

protected TrippingTempoAdderImpl(OverloadManagementSystem.Tripping extendable) {
super(extendable);
}

@Override
protected TrippingTempo createExtension(OverloadManagementSystem.Tripping tripping) {
return new TrippingTempoImpl(tripping, tempo);
}

@Override
public TrippingTempoAdder withTempo(int tempo) {
this.tempo = tempo;
return this;
}

@Override
public Class<TrippingTempo> getExtensionClass() {
return TrippingTempo.class;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* 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.iidm.network.impl.extensions;

import com.google.auto.service.AutoService;
import com.powsybl.commons.extensions.ExtensionAdderProvider;
import com.powsybl.iidm.network.OverloadManagementSystem;
import com.powsybl.iidm.network.extensions.TrippingTempo;

@AutoService(ExtensionAdderProvider.class)
public class TrippingTempoAdderImplProvider implements
ExtensionAdderProvider<OverloadManagementSystem.Tripping, TrippingTempo, TrippingTempoAdderImpl> {
@Override
public String getImplementationName() {
return "Default";
}

@Override
public Class<TrippingTempoAdderImpl> getAdderClass() {
return TrippingTempoAdderImpl.class;
}

@Override
public TrippingTempoAdderImpl newAdder(OverloadManagementSystem.Tripping tripping) {
return new TrippingTempoAdderImpl(tripping);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* 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.iidm.network.impl.extensions;

import com.powsybl.commons.extensions.AbstractExtensionAdder;
import com.powsybl.iidm.network.OverloadManagementSystem;
import com.powsybl.iidm.network.extensions.TrippingTempoContainer;
import com.powsybl.iidm.network.extensions.TrippingTempoContainerAdder;

public class TrippingTempoContainerAdderImpl extends AbstractExtensionAdder<OverloadManagementSystem, TrippingTempoContainer> implements TrippingTempoContainerAdder {
private int tempo;
private String tripping;

protected TrippingTempoContainerAdderImpl(OverloadManagementSystem extendable) {
super(extendable);
}

@Override
protected TrippingTempoContainer createExtension(OverloadManagementSystem oms) {
return new TrippingTempoContainerImpl(oms, tripping, tempo);
}

@Override
public Class<? super TrippingTempoContainer> getExtensionClass() {
return TrippingTempoContainer.class;
}

@Override
public TrippingTempoContainerAdder withTempo(String tripping, int tempo) {
this.tripping = tripping;
this.tempo = tempo;
return this;
}
}
Loading

0 comments on commit 3186719

Please sign in to comment.