Skip to content

Commit

Permalink
Open NetworkGraphBuilder for custom implementation (#395)
Browse files Browse the repository at this point in the history
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@gmail.com>
  • Loading branch information
geofjamg authored Jun 1, 2022
1 parent e855eb2 commit c348091
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,11 @@ public void visitThreeWindingsTransformer(ThreeWindingsTransformer transformer,
}
}

private static class NodeBreakerGraphBuilder extends AbstractGraphBuilder {
public static class NodeBreakerGraphBuilder extends AbstractGraphBuilder {

private final Map<Integer, Node> nodesByNumber;

NodeBreakerGraphBuilder(VoltageLevelGraph graph, Map<Integer, Node> nodesByNumber) {
protected NodeBreakerGraphBuilder(VoltageLevelGraph graph, Map<Integer, Node> nodesByNumber) {
super(graph);
this.nodesByNumber = Objects.requireNonNull(nodesByNumber);
}
Expand Down Expand Up @@ -471,13 +471,13 @@ public void visitBusbarSection(BusbarSection busbarSection) {
}
}

private static class BusBreakerGraphBuilder extends AbstractGraphBuilder {
public static class BusBreakerGraphBuilder extends AbstractGraphBuilder {

private final Map<String, Node> nodesByBusId;

private int order = 1;

BusBreakerGraphBuilder(VoltageLevelGraph graph, Map<String, Node> nodesByBusId) {
protected BusBreakerGraphBuilder(VoltageLevelGraph graph, Map<String, Node> nodesByBusId) {
super(graph);
this.nodesByBusId = Objects.requireNonNull(nodesByBusId);
}
Expand Down Expand Up @@ -507,6 +507,10 @@ protected void add3wtFeeder(Middle3WTNode middleNode, Feeder3WTLegNode firstOthe
}
}

protected BusBreakerGraphBuilder createBusBreakerGraphBuilder(VoltageLevelGraph graph, Map<String, Node> nodesByBusId) {
return new BusBreakerGraphBuilder(graph, nodesByBusId);
}

private void buildBusBreakerGraph(VoltageLevelGraph graph, VoltageLevel vl) {
Map<String, Node> nodesByBusId = new HashMap<>();

Expand All @@ -518,7 +522,7 @@ private void buildBusBreakerGraph(VoltageLevelGraph graph, VoltageLevel vl) {
}

// visit equipments
vl.visitEquipments(new BusBreakerGraphBuilder(graph, nodesByBusId));
vl.visitEquipments(createBusBreakerGraphBuilder(graph, nodesByBusId));

// switches
for (Switch sw : vl.getBusBreakerView().getSwitches()) {
Expand All @@ -531,11 +535,15 @@ private void buildBusBreakerGraph(VoltageLevelGraph graph, VoltageLevel vl) {
}
}

protected NodeBreakerGraphBuilder createNodeBreakerGraphBuilder(VoltageLevelGraph graph, Map<Integer, Node> nodesByNumber) {
return new NodeBreakerGraphBuilder(graph, nodesByNumber);
}

private void buildNodeBreakerGraph(VoltageLevelGraph graph, VoltageLevel vl) {
Map<Integer, Node> nodesByNumber = new HashMap<>();

// visit equipments
vl.visitEquipments(new NodeBreakerGraphBuilder(graph, nodesByNumber));
vl.visitEquipments(createNodeBreakerGraphBuilder(graph, nodesByNumber));

// switches
for (Switch sw : vl.getNodeBreakerView().getSwitches()) {
Expand Down

0 comments on commit c348091

Please sign in to comment.