Skip to content

Commit 0e63303

Browse files
authored
Fix CGMES VoltageLevel high/low voltage warnings (#3831)
* Fix CGMES VoltageLevel high/low voltage warnings * clean Signed-off-by: Damien Jeandemange <damien.jeandemange@artelys.com>
1 parent c33f49c commit 0e63303

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/VoltageLevelConversion.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,23 @@ public void convert() {
7676
addAliases(vl);
7777

7878
// Check voltage limit consistency.
79-
if (lowVoltageLimit <= highVoltageLimit) {
80-
vl.setHighVoltageLimit(highVoltageLimit);
81-
vl.setLowVoltageLimit(lowVoltageLimit);
82-
vl.setProperty(PROPERTY_HIGH_VOLTAGE_LIMIT, String.valueOf(highVoltageLimit));
83-
vl.setProperty(PROPERTY_LOW_VOLTAGE_LIMIT, String.valueOf(lowVoltageLimit));
84-
} else {
79+
if (highVoltageLimit < lowVoltageLimit) {
80+
// this code path is never reached if either of the values is NaN, i.e. not provided in input
8581
ignored("high/low voltage limits",
86-
() -> String.format("lowVoltageLimit (%f) is greater than highVoltageLimit (%f).", lowVoltageLimit, highVoltageLimit));
82+
() -> String.format("lowVoltageLimit (%f) is greater than highVoltageLimit (%f).", lowVoltageLimit, highVoltageLimit));
83+
} else {
84+
// either:
85+
// - no limits defined
86+
// - or, only one limit is defined
87+
// - or, both limits are defined and they are consistent
88+
if (!Double.isNaN(highVoltageLimit)) {
89+
vl.setHighVoltageLimit(highVoltageLimit);
90+
vl.setProperty(PROPERTY_HIGH_VOLTAGE_LIMIT, String.valueOf(highVoltageLimit));
91+
}
92+
if (!Double.isNaN(lowVoltageLimit)) {
93+
vl.setLowVoltageLimit(lowVoltageLimit);
94+
vl.setProperty(PROPERTY_LOW_VOLTAGE_LIMIT, String.valueOf(lowVoltageLimit));
95+
}
8796
}
8897
}
8998
}

0 commit comments

Comments
 (0)