Skip to content

Commit

Permalink
Refactor.
Browse files Browse the repository at this point in the history
Signed-off-by: parvy <[email protected]>
  • Loading branch information
p-arvy committed Oct 11, 2023
1 parent f6e326a commit 5aa6b77
Showing 1 changed file with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ public void checkIntegrity(Network network) throws InvalidParametersException {

}

/**
* @param network the network on which voltage levels are verified.
* @return true if the voltage level limits are correct taking into account voltage limit overrides, false otherwise.
*/
boolean checkVoltageLevelLimits(Network network) {
boolean integrityVoltageLevelLimits = true;

Expand Down Expand Up @@ -238,7 +242,7 @@ boolean checkVoltageLevelLimits(Network network) {

/**
* @param network the network on which are applied voltage limit overrides.
* @return true if the integrity of voltage limit overrides is verifies, false otherwise.
* @return true if the integrity of voltage limit overrides is verified, false otherwise.
*/
boolean checkVoltageLimitOverrides(Network network) {
// Check integrity of voltage overrides
Expand All @@ -251,21 +255,22 @@ boolean checkVoltageLimitOverrides(Network network) {
if (voltageLevel == null) {
LOGGER.warn("Voltage level {} not found in the network.", voltageLevelId);
integrityVoltageLimitOverrides = false;
} else {
if (voltageLimitOverride.isRelative()) {
double value = voltageLimitOverride.getVoltageLimitType() == VoltageLimitOverride.VoltageLimitType.LOW_VOLTAGE_LIMIT ?
voltageLevel.getLowVoltageLimit() : voltageLevel.getHighVoltageLimit(); // FIXME?
if (Double.isNaN(value)) {
LOGGER.warn("Voltage level {} has undefined {}, relative voltage limit override is impossible.",
voltageLevelId, voltageLimitOverride.getVoltageLimitType());
integrityVoltageLimitOverrides = false;
}
if (voltageLimitOverride.getVoltageLimitType() == VoltageLimitOverride.VoltageLimitType.LOW_VOLTAGE_LIMIT
&& voltageLimitOverride.getLimit() + voltageLevel.getLowVoltageLimit() < 0) {
// ... verify low voltage limit override does not lead to negative limit value
LOGGER.warn("Voltage level {} low relative override leads to a negative low voltage limit.", voltageLevelId);
integrityVoltageLimitOverrides = false;
}
continue;
}

if (voltageLimitOverride.isRelative()) {
double value = voltageLimitOverride.getVoltageLimitType() == VoltageLimitOverride.VoltageLimitType.LOW_VOLTAGE_LIMIT ?
voltageLevel.getLowVoltageLimit() : voltageLevel.getHighVoltageLimit(); // FIXME?
if (Double.isNaN(value)) {
LOGGER.warn("Voltage level {} has undefined {}, relative voltage limit override is impossible.",
voltageLevelId, voltageLimitOverride.getVoltageLimitType());
integrityVoltageLimitOverrides = false;
}
if (voltageLimitOverride.getVoltageLimitType() == VoltageLimitOverride.VoltageLimitType.LOW_VOLTAGE_LIMIT
&& voltageLimitOverride.getLimit() + voltageLevel.getLowVoltageLimit() < 0) {
// ... verify low voltage limit override does not lead to negative limit value
LOGGER.warn("Voltage level {} low relative override leads to a negative low voltage limit.", voltageLevelId);
integrityVoltageLimitOverrides = false;
}
}
}
Expand Down

0 comments on commit 5aa6b77

Please sign in to comment.