-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix syncv #460
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Franck LECUYER <[email protected]>
Add new test with multiple buses in bus view and bus breaker view in a voltage level Signed-off-by: Franck LECUYER <[email protected]>
Signed-off-by: Franck LECUYER <[email protected]>
Signed-off-by: HARPER Jon <[email protected]>
Signed-off-by: HARPER Jon <[email protected]>
Signed-off-by: HARPER Jon <[email protected]>
example fixes for #452 |
Signed-off-by: Franck LECUYER <[email protected]>
Signed-off-by: Franck LECUYER <[email protected]>
Signed-off-by: Franck LECUYER <[email protected]>
…tWithSwitchTest, with buses in bus breaker view between retained switches and with no equipments. Signed-off-by: Franck LECUYER <[email protected]>
0d58627
to
16edded
Compare
Signed-off-by: Franck LECUYER <[email protected]>
if (foundConfiguredBus.get() != null) { | ||
v.set(foundConfiguredBus.get().getResource().getAttributes().getV()); | ||
angle.set(foundConfiguredBus.get().getResource().getAttributes().getAngle()); | ||
if (foundConfiguredBus.get() == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
break early instead of checking if found in the loop
LineImpl l1 = (LineImpl) network.getLine("L1"); | ||
|
||
// Update angle using BusView | ||
l1.getTerminal1().getBusView().getBus().setAngle(111); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for better coverage, start the angle busbreaker topology test with a setAngle in the busbreakerview
and the nodebreaker topology test start with a setAngle in the busview
to do the opposite of the setV test
String busbreakerviewbusid = entry.getKey(); | ||
String busviewbusid = entry.getValue(); | ||
|
||
for (Bus bbvb : vl.getBusBreakerView().getBuses()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to refactor these test to allow testing with or without already calculated buses. Here because we force getBuses before the tests, we always run with calculated bus already computed
AtomicDouble v, | ||
AtomicDouble angle, | ||
boolean isBusView) { | ||
if (voltageLevelResource.getAttributes().getTopologyKind() == TopologyKind.NODE_BREAKER) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we use if (isCalculatedBusesValid(voltageLevelResource, !isBusView)) {
like in getCalculatedBusAttributesList ?
…istence Signed-off-by: HARPER Jon <[email protected]>
Quality Gate passedIssues Measures |
@FranckLecuyer can you take a look ? |
…ws, simplify code, throw exceptions instead of silently doing nothing Signed-off-by: HARPER Jon <[email protected]>
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick reading of this PR, no tests
private CalculatedBusAttributes createCalculatedBusAttributesWithVAndAngle(NetworkObjectIndex index, | ||
Resource<VoltageLevelAttributes> voltageLevelResource, | ||
ConnectedSetResult<T> connectedSet, | ||
boolean isBusView) { | ||
double v = Double.NaN; | ||
double angle = Double.NaN; | ||
if (voltageLevelResource.getAttributes().getTopologyKind() == TopologyKind.NODE_BREAKER) { | ||
CalculatedBusAttributes busAttributes = findFirstMatchingNodeBreakerCalculatedBusAttributes(voltageLevelResource, connectedSet, isBusView); | ||
if (busAttributes != null) { | ||
v = busAttributes.getV(); | ||
angle = busAttributes.getAngle(); | ||
} | ||
} else { // BUS_BREAKER | ||
// currently for busbreakertopology the values are always preserved | ||
// when using only the busbreakerview. So mimic the behavior and always preserve them | ||
// when using the busview: get V and Angle values from configured buses | ||
String configuredBusId = ((ConnectedSetResult<String>) connectedSet).getConnectedNodesOrBuses().iterator().next(); // nondeterministic | ||
Bus b = index.getConfiguredBus(configuredBusId).orElseThrow(); | ||
v = b.getV(); | ||
angle = b.getAngle(); | ||
} | ||
return new CalculatedBusAttributes(connectedSet.getConnectedVertices(), null, null, v, angle); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if/else makes me think that this should be implemented in BusBreakerTopology/NodeBreakerTopology classes ? Maybe an abstraction here
@@ -471,4 +509,43 @@ public <E extends Extension<Bus>, B extends ExtensionAdder<Bus, E>> B newExtensi | |||
public int getCalculatedBusNum() { | |||
return calculatedBusNum; | |||
} | |||
|
|||
private void updateBusesAttributes(double value, ObjDoubleConsumer<CalculatedBusAttributes> setValue) { | |||
// busnum of this bus -> nodes in this bus -> busnums in the other view -> buses of the other view |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is not clear
List<CalculatedBusAttributes> calculatedBusAttributes = isBusView | ||
? vlAttributes.getCalculatedBusesForBusBreakerView() | ||
: vlAttributes.getCalculatedBusesForBusView(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this inside the for loop? It looks like it's constant? Similarly to nodesToCalculatedBuses, etc
private void setVInCalculatedBus(CalculatedBusAttributes calculatedBusAttributes, double value) { | ||
calculatedBusAttributes.setV(value); | ||
} | ||
|
||
private void setVInConfiguredBus(ConfiguredBusImpl configuredBus, double value) { | ||
configuredBus.setConfiguredBusV(value); | ||
} | ||
|
||
private void setAngleInCalculatedBus(CalculatedBusAttributes calculatedBusAttributes, double value) { | ||
calculatedBusAttributes.setAngle(value); | ||
} | ||
|
||
private void setAngleInConfiguredBus(ConfiguredBusImpl configuredBus, double value) { | ||
configuredBus.setConfiguredBusAngle(value); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have some consistency in naming?
setAngleInConfiguredBus // setConfiguredBusAngle
setAngleInCalculatedBus // setAngle
same for V
return this; | ||
} | ||
|
||
void setAngle(double angle, boolean updateCalculatedBus) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private?
.add(); | ||
|
||
// add busbar sections in star coupling to have a bus in the middle without any equipment. It will | ||
// exist in the busbreaker view but not in the busview. For this one use closed switches so that it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lot of suspense...
/** | ||
* @author Jon Harper <jon.harper at rte-france.com> | ||
* | ||
* complex specific exhaustive tests for setV and setAngle interactions with calculated views. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
// currently for busbreakertopology the values are always preserved | ||
// when using only the busbreakerview. So mimic the behavior and always preserve them | ||
// when using the busview: get V and Angle values from configured buses | ||
String configuredBusId = ((ConnectedSetResult<String>) connectedSet).getConnectedNodesOrBuses().iterator().next(); // nondeterministic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe check iterator with hasNext before calling next ...
// when using only the busbreakerview. So mimic the behavior and always preserve them | ||
// when using the busview: get V and Angle values from configured buses | ||
String configuredBusId = ((ConnectedSetResult<String>) connectedSet).getConnectedNodesOrBuses().iterator().next(); // nondeterministic | ||
Bus b = index.getConfiguredBus(configuredBusId).orElseThrow(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe customize the exception, in order to have a more accurate message ...
for (Map.Entry<String, String > entry : busBreakerViewBusToBusViewBus.entrySet()) { | ||
String busbreakerviewbusid = entry.getKey(); | ||
String busviewbusid = entry.getValue(); | ||
setAllBbvbAndBvb(vl, Double.NaN, setter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setAllBusBreakerViewBusAndBusViewBus ?
if (vl.getTopologyKind() == TopologyKind.NODE_BREAKER) { | ||
// test one same view | ||
vl = networkVoltageLevelSupplier.get(); | ||
setAllBbvb(vl, 1.0, setter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setAllBusBreakerViewBus ?
|
||
// test one other view | ||
vl = networkVoltageLevelSupplier.get(); | ||
setAllBvb(vl, 1.0, setter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setAllBusViewBus ?
// so test only with busview view | ||
// NOTE: for busbreakertopology we keep the previous values. | ||
vl = networkVoltageLevelSupplier.get(); | ||
setAllBvb(vl, 1.0, setter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setAllBusViewBus ?
for (Map.Entry<String, List<String> > entry : busViewBusToBusBreakerViewBus.entrySet()) { | ||
String busviewbusid = entry.getKey(); | ||
List<String> busbreakerviewbusids = entry.getValue(); | ||
setAllBbvbAndBvb(vl, Double.NaN, setter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setAllBusBreakerViewBusAndBusViewBus ?
// test one same view, nodebreakertopology and busbreakertopology behave the same here | ||
if (vl.getTopologyKind() == TopologyKind.NODE_BREAKER) { | ||
vl = networkVoltageLevelSupplier.get(); | ||
setAllBvb(vl, 1.0, setter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setAllBusViewBus ?
|
||
// test one other view | ||
vl = networkVoltageLevelSupplier.get(); | ||
setAllBvb(vl, 1.0, setter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setAllBusViewBus ?
// so test only with busview view | ||
// NOTE: for busbreakertopology we keep the previous values. | ||
vl = networkVoltageLevelSupplier.get(); | ||
setAllBvb(vl, 1.0, setter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setAllBusViewBus ?
No description provided.