Skip to content

Commit

Permalink
revert to correct unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu DEHARBE <[email protected]>
  • Loading branch information
Mathieu-Deharbe committed Sep 18, 2024
1 parent 0a92daf commit 68e970a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static void setNewValue(TwoWindingsTransformer transformer, String twoWin
TwoWindingsTransformerField field = TwoWindingsTransformerField.valueOf(twoWindingsTransformerField);
final PhaseTapChanger phaseTapChanger = transformer.getPhaseTapChanger();
final RatioTapChanger ratioTapChanger = transformer.getRatioTapChanger();
final PhaseTapChanger.RegulationMode regulationMode = phaseTapChanger != null ? phaseTapChanger.getRegulationMode() : null;
final AttributeModification<Double> attributeModification = new AttributeModification<>(newValue, OperationType.SET);

switch (field) {
Expand All @@ -68,7 +69,7 @@ public static void setNewValue(TwoWindingsTransformer transformer, String twoWin
null, new AttributeModification<>(newValue.intValue(), OperationType.SET), null, null);
case RATIO_TARGET_DEADBAND -> modifyTargets(ratioTapChanger, null, true, null, attributeModification, null);
case REGULATION_VALUE -> processPhaseTapRegulation(
phaseTapChanger, null, null, true, attributeModification, null, null
phaseTapChanger, null, regulationMode, true, attributeModification, null, null
);
case PHASE_LOW_TAP_POSITION -> processTapChangerPositionsAndSteps(phaseTapChanger, null, true,
new AttributeModification<>(newValue.intValue(), OperationType.SET), null, null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,40 +124,37 @@ public static void modifyVoltageLevelShortCircuit(AttributeModification<Double>
oldIpMin = identifiableShortCircuit.getIpMin();
oldIpMax = identifiableShortCircuit.getIpMax();
}
updateShortCircuitLimits(ipMin, ipMax, oldIpMin, oldIpMax, identifiableShortCircuitAdder, reports);

identifiableShortCircuitAdder.add();
if (subReportNode != null) {
reports.forEach(report -> insertReportNode(subReportNode, report));
}
}

private static void updateShortCircuitLimits(AttributeModification<Double> ipMin,
AttributeModification<Double> ipMax,
Double oldIpMin,
Double oldIpMax,
IdentifiableShortCircuitAdder identifiableShortCircuitAdder,
List<ReportNode> reports) {
if (ipMin != null) {
updateShortCircuitLimit(ipMin.getValue(), oldIpMin, "Low short circuit current limit", identifiableShortCircuitAdder::withIpMin, reports);
var newIpMin = ipMin.getValue();

identifiableShortCircuitAdder.withIpMin(newIpMin);

//convert to kA to report it like the user set it.
var oldIpMinToReport = convertToKiloAmps(oldIpMin);
var newIpMinToReport = convertToKiloAmps(newIpMin);
reports.add(ModificationUtils.getInstance()
.buildModificationReport(oldIpMinToReport, newIpMinToReport, "Low short circuit current limit"));
} else if (oldIpMin != null) {
identifiableShortCircuitAdder.withIpMin(oldIpMin);
}

if (ipMax != null) {
updateShortCircuitLimit(ipMax.getValue(), oldIpMax, "High short circuit current limit", identifiableShortCircuitAdder::withIpMax, reports);
var newIpMax = ipMax.getValue();
identifiableShortCircuitAdder.withIpMax(newIpMax);

//Convert to kA to report it like the user set it.
var oldIpMaxToReport = convertToKiloAmps(oldIpMax);
var newIpMaxToReport = convertToKiloAmps(newIpMax);
reports.add(ModificationUtils.getInstance()
.buildModificationReport(oldIpMaxToReport, newIpMaxToReport, "High short circuit current limit"));
} else if (oldIpMax != null) {
identifiableShortCircuitAdder.withIpMax(oldIpMax);
}
}

private static void updateShortCircuitLimit(Double newValue,
Double oldValue,
String limitDescription,
Consumer<Double> setterMethod,
List<ReportNode> reports) {
if (newValue != null) {
setterMethod.accept(newValue);
Double oldValueToReport = convertToKiloAmps(oldValue);
Double newValueToReport = convertToKiloAmps(newValue);
reports.add(ModificationUtils.getInstance().buildModificationReport(oldValueToReport, newValueToReport, limitDescription));
} else if (oldValue != null) {
setterMethod.accept(oldValue);
identifiableShortCircuitAdder.add();
if (subReportNode != null) {
reports.forEach(report -> insertReportNode(subReportNode, report));
}
}

Expand Down

0 comments on commit 68e970a

Please sign in to comment.