-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework of LineConnectionAction to TerminalsConnectionAction (#2843)
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com> Co-authored-by: Damien Jeandemange <damien.jeandemange@artelys.com>
- Loading branch information
1 parent
15eec73
commit e148a02
Showing
10 changed files
with
185 additions
and
144 deletions.
There are no files selected for viewing
62 changes: 0 additions & 62 deletions
62
...security-analysis-api/src/main/java/com/powsybl/security/action/LineConnectionAction.java
This file was deleted.
Oops, something went wrong.
84 changes: 84 additions & 0 deletions
84
...ity-analysis-api/src/main/java/com/powsybl/security/action/TerminalsConnectionAction.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,84 @@ | ||
/** | ||
* 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.security.action; | ||
|
||
import com.powsybl.iidm.network.ThreeSides; | ||
|
||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
/** | ||
* An action of opening or closing an equipment terminal(s). | ||
* | ||
* @author Anne Tilloy {@literal <anne.tilloy@rte-france.com>} | ||
*/ | ||
public class TerminalsConnectionAction extends AbstractAction { | ||
|
||
public static final String NAME = "TERMINALS_CONNECTION"; | ||
private final String elementId; | ||
private ThreeSides side; | ||
private final boolean open; | ||
|
||
/** | ||
* @param id the id of the action. | ||
* @param elementId the id of the element which terminals are operated. | ||
* The element can be any connectable, including a tie line by referring the terminal of | ||
* an underlying dangling line. | ||
* @param side the side of the element to operate in the action. | ||
* @param open the status for the terminal to operate. {@code true} means terminal opening. | ||
*/ | ||
public TerminalsConnectionAction(String id, String elementId, ThreeSides side, boolean open) { | ||
super(id); | ||
this.elementId = Objects.requireNonNull(elementId); | ||
this.side = Objects.requireNonNull(side); | ||
this.open = open; | ||
} | ||
|
||
/** | ||
* @param id the id of the action. | ||
* @param elementId the id of the element which terminals are operated. | ||
* The element can be any connectable, including a tie line by referring the terminal of | ||
* an underlying dangling line. | ||
* @param open the status for all the terminals of the element to operate. {@code true} means all terminals opening. | ||
*/ | ||
public TerminalsConnectionAction(String id, String elementId, boolean open) { | ||
super(id); | ||
this.elementId = Objects.requireNonNull(elementId); | ||
this.open = open; | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return NAME; | ||
} | ||
|
||
/** | ||
* @return the element id. | ||
*/ | ||
public String getElementId() { | ||
return elementId; | ||
} | ||
|
||
/** | ||
* The side is optional. Empty means that all the terminals of the element will be operated | ||
* in the action with the defined open or close status. | ||
* @return the optional side of the connection/disconnection action. | ||
*/ | ||
public Optional<ThreeSides> getSide() { | ||
return Optional.ofNullable(side); | ||
} | ||
|
||
/** | ||
* If {@code true}, applying the action will open the terminal reference with side is given, | ||
* else it will close it. If the side is not given, if {@code true}, applying the action will open all the terminals | ||
* of the element, else it will close them. | ||
*/ | ||
public boolean isOpen() { | ||
return open; | ||
} | ||
} |
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
35 changes: 0 additions & 35 deletions
35
...is-api/src/main/java/com/powsybl/security/json/action/LineConnectionActionSerializer.java
This file was deleted.
Oops, something went wrong.
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
42 changes: 42 additions & 0 deletions
42
...i/src/main/java/com/powsybl/security/json/action/TerminalsConnectionActionSerializer.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,42 @@ | ||
/** | ||
* 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.security.json.action; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import com.fasterxml.jackson.databind.ser.std.StdSerializer; | ||
import com.powsybl.commons.json.JsonUtil; | ||
import com.powsybl.iidm.network.ThreeSides; | ||
import com.powsybl.security.action.TerminalsConnectionAction; | ||
|
||
import java.io.IOException; | ||
import java.util.Optional; | ||
|
||
/** | ||
* @author Anne Tilloy {@literal <anne.tilloy@rte-france.com>} | ||
*/ | ||
public class TerminalsConnectionActionSerializer extends StdSerializer<TerminalsConnectionAction> { | ||
|
||
public TerminalsConnectionActionSerializer() { | ||
super(TerminalsConnectionAction.class); | ||
} | ||
|
||
@Override | ||
public void serialize(TerminalsConnectionAction action, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { | ||
jsonGenerator.writeStartObject(); | ||
jsonGenerator.writeStringField("type", action.getType()); | ||
jsonGenerator.writeStringField("id", action.getId()); | ||
jsonGenerator.writeStringField("elementId", action.getElementId()); | ||
Optional<ThreeSides> side = action.getSide(); | ||
if (side.isPresent()) { | ||
JsonUtil.writeOptionalStringField(jsonGenerator, "side", String.valueOf(side.get())); | ||
} | ||
jsonGenerator.writeBooleanField("open", action.isOpen()); | ||
jsonGenerator.writeEndObject(); | ||
} | ||
} |
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.