Skip to content

Commit

Permalink
Refactor the tap changer adder interfaces (#2828)
Browse files Browse the repository at this point in the history
* Factorize the tap changer adder interfaces
* Use new factorization in deserialization

Signed-off-by: Florent MILLOT <millotflo@gmail.com>
Co-authored-by: Florian Dupuy <florian.dupuy@rte-france.com>
  • Loading branch information
flomillot and flo-dup authored Jan 11, 2024
1 parent 8b1ac35 commit 450d65d
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,11 @@
package com.powsybl.iidm.network;

/**
*
* @author Geoffroy Jamgotchian {@literal <geoffroy.jamgotchian at rte-france.com>}
*/
public interface PhaseTapChangerAdder {

interface StepAdder {

StepAdder setAlpha(double alpha);

StepAdder setRho(double rho);

StepAdder setR(double r);

StepAdder setX(double x);

StepAdder setG(double g);

StepAdder setB(double b);

PhaseTapChangerAdder endStep();
}

PhaseTapChangerAdder setLowTapPosition(int lowTapPosition);

PhaseTapChangerAdder setTapPosition(int tapPosition);

PhaseTapChangerAdder setRegulating(boolean regulating);
public interface PhaseTapChangerAdder extends TapChangerAdder<PhaseTapChangerAdder, PhaseTapChangerStepAdder, PhaseTapChanger> {

PhaseTapChangerAdder setRegulationMode(PhaseTapChanger.RegulationMode regulationMode);

PhaseTapChangerAdder setRegulationValue(double regulationValue);

PhaseTapChangerAdder setRegulationTerminal(Terminal regulationTerminal);

default PhaseTapChangerAdder setTargetDeadband(double targetDeadband) {
throw new UnsupportedOperationException();
}

StepAdder beginStep();

PhaseTapChanger add();
}
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;

/**
* @author Florent MILLOT {@literal <florent.millot at rte-france.com>}
*/
public interface PhaseTapChangerStepAdder extends TapChangerStepAdder<PhaseTapChangerStepAdder, PhaseTapChangerAdder> {
PhaseTapChangerStepAdder setAlpha(double alpha);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,15 @@
package com.powsybl.iidm.network;

/**
*
* @author Geoffroy Jamgotchian {@literal <geoffroy.jamgotchian at rte-france.com>}
*/
public interface RatioTapChangerAdder {

public interface StepAdder {

StepAdder setRho(double rho);

StepAdder setR(double r);

StepAdder setX(double x);

StepAdder setG(double g);

StepAdder setB(double b);

RatioTapChangerAdder endStep();
}

RatioTapChangerAdder setLowTapPosition(int lowTapPosition);

RatioTapChangerAdder setTapPosition(int tapPosition);

RatioTapChangerAdder setLoadTapChangingCapabilities(boolean loadTapChangingCapabilities);

RatioTapChangerAdder setRegulating(boolean regulating);
public interface RatioTapChangerAdder extends TapChangerAdder<RatioTapChangerAdder, RatioTapChangerStepAdder, RatioTapChanger> {

RatioTapChangerAdder setRegulationMode(RatioTapChanger.RegulationMode regulationMode);

RatioTapChangerAdder setRegulationValue(double regulationValue);

RatioTapChangerAdder setTargetV(double targetV);

RatioTapChangerAdder setRegulationTerminal(Terminal regulationTerminal);

default RatioTapChangerAdder setTargetDeadband(double targetDeadband) {
throw new UnsupportedOperationException();
}

StepAdder beginStep();

RatioTapChanger add();
RatioTapChangerAdder setLoadTapChangingCapabilities(boolean loadTapChangingCapabilities);

RatioTapChangerAdder setTargetV(double targetV);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* 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;

/**
* @author Florent MILLOT {@literal <florent.millot at rte-france.com>}
*/
public interface RatioTapChangerStepAdder extends TapChangerStepAdder<RatioTapChangerStepAdder, RatioTapChangerAdder> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* 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;

/**
* @author Florent MILLOT {@literal <florent.millot at rte-france.com>}
*/
public interface TapChangerAdder<S extends TapChangerAdder<S, A, C>, A extends TapChangerStepAdder<A, S>, C extends TapChanger<C, ?>> {

S setLowTapPosition(int lowTapPosition);

S setTapPosition(int tapPosition);

S setRegulating(boolean regulating);

S setRegulationTerminal(Terminal regulationTerminal);

default S setTargetDeadband(double targetDeadband) {
throw new UnsupportedOperationException();
}

A beginStep();

C add();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* 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;

/**
* @author Florent MILLOT {@literal <florent.millot at rte-france.com>}
*/
public interface TapChangerStepAdder<S extends TapChangerStepAdder<S, A>, A extends TapChangerAdder<A, S, ?>> {
S setRho(double rho);

S setR(double r);

S setX(double x);

S setG(double g);

S setB(double b);

A endStep();
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PhaseTapChangerAdderImpl implements PhaseTapChangerAdder {

private TerminalExt regulationTerminal;

class StepAdderImpl implements StepAdder {
class StepAdderImpl implements PhaseTapChangerStepAdder {

private double alpha = Double.NaN;

Expand All @@ -59,37 +59,37 @@ class StepAdderImpl implements StepAdder {
private double b = 0.0;

@Override
public StepAdder setAlpha(double alpha) {
public PhaseTapChangerStepAdder setAlpha(double alpha) {
this.alpha = alpha;
return this;
}

@Override
public StepAdder setRho(double rho) {
public PhaseTapChangerStepAdder setRho(double rho) {
this.rho = rho;
return this;
}

@Override
public StepAdder setR(double r) {
public PhaseTapChangerStepAdder setR(double r) {
this.r = r;
return this;
}

@Override
public StepAdder setX(double x) {
public PhaseTapChangerStepAdder setX(double x) {
this.x = x;
return this;
}

@Override
public StepAdder setG(double g) {
public PhaseTapChangerStepAdder setG(double g) {
this.g = g;
return this;
}

@Override
public StepAdder setB(double b) {
public PhaseTapChangerStepAdder setB(double b) {
this.b = b;
return this;
}
Expand Down Expand Up @@ -172,7 +172,7 @@ public PhaseTapChangerAdder setRegulationTerminal(Terminal regulationTerminal) {
}

@Override
public StepAdder beginStep() {
public PhaseTapChangerStepAdder beginStep() {
return new StepAdderImpl();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class RatioTapChangerAdderImpl implements RatioTapChangerAdder {

private TerminalExt regulationTerminal;

class StepAdderImpl implements StepAdder {
class StepAdderImpl implements RatioTapChangerStepAdder {

private double rho = Double.NaN;

Expand All @@ -56,31 +56,31 @@ class StepAdderImpl implements StepAdder {
private double b = 0.0;

@Override
public StepAdder setRho(double rho) {
public RatioTapChangerStepAdder setRho(double rho) {
this.rho = rho;
return this;
}

@Override
public StepAdder setR(double r) {
public RatioTapChangerStepAdder setR(double r) {
this.r = r;
return this;
}

@Override
public StepAdder setX(double x) {
public RatioTapChangerStepAdder setX(double x) {
this.x = x;
return this;
}

@Override
public StepAdder setG(double g) {
public RatioTapChangerStepAdder setG(double g) {
this.g = g;
return this;
}

@Override
public StepAdder setB(double b) {
public RatioTapChangerStepAdder setB(double b) {
this.b = b;
return this;
}
Expand Down Expand Up @@ -175,7 +175,7 @@ public RatioTapChangerAdder setRegulationTerminal(Terminal regulationTerminal) {
}

@Override
public StepAdder beginStep() {
public RatioTapChangerStepAdder beginStep() {
return new StepAdderImpl();
}

Expand Down
Loading

0 comments on commit 450d65d

Please sign in to comment.