From 4c9d03e5b4aac714a292451410c43ce54916a1c4 Mon Sep 17 00:00:00 2001 From: MarinPinchinatLoth <98109016+MarinPinchinatLoth@users.noreply.github.com> Date: Fri, 11 Feb 2022 13:58:58 +0100 Subject: [PATCH] Adding order and direction to SwitchNode serialization (#346) Signed-off-by: Marin Pinchinat-Loth --- .../src/main/java/com/powsybl/sld/model/SwitchNode.java | 8 ++++++++ .../test/resources/TestInternCellExplicitPosition.json | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/single-line-diagram-core/src/main/java/com/powsybl/sld/model/SwitchNode.java b/single-line-diagram-core/src/main/java/com/powsybl/sld/model/SwitchNode.java index 08027a18d..29fb85795 100644 --- a/single-line-diagram-core/src/main/java/com/powsybl/sld/model/SwitchNode.java +++ b/single-line-diagram-core/src/main/java/com/powsybl/sld/model/SwitchNode.java @@ -11,6 +11,7 @@ import java.io.IOException; import java.util.Objects; +import java.util.Optional; /** * @author Benoit Jeanson @@ -50,5 +51,12 @@ public Node getOtherAdjNode(Node adj) { protected void writeJsonContent(JsonGenerator generator, boolean includeCoordinates) throws IOException { super.writeJsonContent(generator, includeCoordinates); generator.writeStringField("kind", kind.name()); + Optional optOrder = getOrder(); + if (optOrder.isPresent()) { + generator.writeNumberField("order", optOrder.get()); + } + if (getDirection() != null && getDirection() != BusCell.Direction.UNDEFINED) { + generator.writeStringField("direction", getDirection().name()); + } } } diff --git a/single-line-diagram-core/src/test/resources/TestInternCellExplicitPosition.json b/single-line-diagram-core/src/test/resources/TestInternCellExplicitPosition.json index 2f395dd23..57b122f72 100644 --- a/single-line-diagram-core/src/test/resources/TestInternCellExplicitPosition.json +++ b/single-line-diagram-core/src/test/resources/TestInternCellExplicitPosition.json @@ -123,7 +123,9 @@ "y" : 345.0, "rotationAngle" : 90.0, "open" : false, - "kind" : "BREAKER" + "kind" : "BREAKER", + "order" : 2, + "direction" : "BOTTOM" }, { "type" : "SWITCH", "id" : "bc2", @@ -135,7 +137,8 @@ "y" : 240.0, "rotationAngle" : 90.0, "open" : false, - "kind" : "BREAKER" + "kind" : "BREAKER", + "order" : 4 }, { "type" : "SWITCH", "id" : "bl1",