Skip to content

Commit

Permalink
Allow standByAutomaton extension to have inconsistent voltage thresho…
Browse files Browse the repository at this point in the history
…lds if not in stand by

Signed-off-by: CARON Alice <[email protected]>
  • Loading branch information
alicecaron committed Jan 13, 2025
1 parent 9c18cc5 commit a4cf99a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private static double checkB0(double b0) {

private static void checkVoltageConfig(double lowVoltageSetpoint, double highVoltageSetpoint,
double lowVoltageThreshold, double highVoltageThreshold,
StaticVarCompensator staticVarCompensator) {
StaticVarCompensator staticVarCompensator, boolean standby) {
if (Double.isNaN(lowVoltageSetpoint)) {
throw new IllegalArgumentException(
String.format("lowVoltageSetpoint (%s) is invalid for StaticVarCompensator %s",
Expand All @@ -64,11 +64,17 @@ private static void checkVoltageConfig(double lowVoltageSetpoint, double highVol
staticVarCompensator.getId()));
}
if (lowVoltageThreshold >= highVoltageThreshold) {
throw new IllegalArgumentException(
String.format("Inconsistent low (%s) and high (%s) voltage thresholds for StaticVarCompensator %s",
lowVoltageThreshold,
highVoltageThreshold,
staticVarCompensator.getId()));
if (standby) {
throw new IllegalArgumentException(
String.format("Inconsistent low (%s) and high (%s) voltage thresholds for StaticVarCompensator %s",
lowVoltageThreshold,
highVoltageThreshold,
staticVarCompensator.getId()));
} else {
LOGGER.warn("Inconsistent low {} and high ({}) voltage thresholds for StaticVarCompensator {}",
lowVoltageSetpoint, lowVoltageThreshold,
staticVarCompensator.getId());
}
}
if (lowVoltageSetpoint < lowVoltageThreshold) {
LOGGER.warn("Invalid low voltage setpoint {} < threshold {} for StaticVarCompensator {}",
Expand All @@ -86,7 +92,7 @@ public StandbyAutomatonImpl(StaticVarCompensator svc, double b0, boolean standby
double lowVoltageThreshold, double highVoltageThreshold) {
super(svc);
int variantArraySize = getVariantManagerHolder().getVariantManager().getVariantArraySize();
checkVoltageConfig(lowVoltageSetpoint, highVoltageSetpoint, lowVoltageThreshold, highVoltageThreshold, svc);
checkVoltageConfig(lowVoltageSetpoint, highVoltageSetpoint, lowVoltageThreshold, highVoltageThreshold, svc, standby);
this.b0 = checkB0(b0);
this.standby = new TBooleanArrayList(variantArraySize);
this.lowVoltageSetpoint = new TDoubleArrayList(variantArraySize);
Expand All @@ -109,6 +115,10 @@ public boolean isStandby() {

@Override
public StandbyAutomatonImpl setStandby(boolean standby) {
checkVoltageConfig(
lowVoltageSetpoint.get(getVariantIndex()), highVoltageSetpoint.get(getVariantIndex()),
lowVoltageThreshold.get(getVariantIndex()), highVoltageThreshold.get(getVariantIndex()),
this.getExtendable(), standby);
this.standby.set(getVariantIndex(), standby);
return this;
}
Expand All @@ -133,7 +143,7 @@ public double getHighVoltageSetpoint() {
public StandbyAutomatonImpl setHighVoltageSetpoint(double highVoltageSetpoint) {
checkVoltageConfig(lowVoltageSetpoint.get(getVariantIndex()), highVoltageSetpoint,
lowVoltageThreshold.get(getVariantIndex()), highVoltageThreshold.get(getVariantIndex()),
this.getExtendable());
this.getExtendable(), standby.get(getVariantIndex()));
this.highVoltageSetpoint.set(getVariantIndex(), highVoltageSetpoint);
return this;
}
Expand All @@ -147,7 +157,7 @@ public double getHighVoltageThreshold() {
public StandbyAutomatonImpl setHighVoltageThreshold(double highVoltageThreshold) {
checkVoltageConfig(lowVoltageSetpoint.get(getVariantIndex()), highVoltageSetpoint.get(getVariantIndex()),
lowVoltageThreshold.get(getVariantIndex()), highVoltageThreshold,
this.getExtendable());
this.getExtendable(), standby.get(getVariantIndex()));
this.highVoltageThreshold.set(getVariantIndex(), highVoltageThreshold);
return this;
}
Expand All @@ -161,7 +171,7 @@ public double getLowVoltageSetpoint() {
public StandbyAutomatonImpl setLowVoltageSetpoint(double lowVoltageSetpoint) {
checkVoltageConfig(lowVoltageSetpoint, highVoltageSetpoint.get(getVariantIndex()),
lowVoltageThreshold.get(getVariantIndex()), highVoltageThreshold.get(getVariantIndex()),
this.getExtendable());
this.getExtendable(), standby.get(getVariantIndex()));
this.lowVoltageSetpoint.set(getVariantIndex(), lowVoltageSetpoint);
return this;
}
Expand All @@ -175,7 +185,7 @@ public double getLowVoltageThreshold() {
public StandbyAutomatonImpl setLowVoltageThreshold(double lowVoltageThreshold) {
checkVoltageConfig(lowVoltageSetpoint.get(getVariantIndex()), highVoltageSetpoint.get(getVariantIndex()),
lowVoltageThreshold, highVoltageThreshold.get(getVariantIndex()),
this.getExtendable());
this.getExtendable(), standby.get(getVariantIndex()));
this.lowVoltageThreshold.set(getVariantIndex(), lowVoltageThreshold);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ public void test() {
assertEquals(405, standbyAutomaton.getHighVoltageThreshold(), 0.0);
standbyAutomaton.setB0(0.0002f);
assertEquals(0.0002f, standbyAutomaton.getB0(), 0.0);
standbyAutomaton.setStandby(false);
assertFalse(standbyAutomaton.isStandby());
standbyAutomaton.setLowVoltageSetpoint(391f);
assertEquals(391, standbyAutomaton.getLowVoltageSetpoint(), 0.0);
standbyAutomaton.setHighVoltageSetpoint(401f);
Expand All @@ -68,6 +66,12 @@ public void test() {
fail();
} catch (Exception ignored) {
}

// when standby is false do not throw error on inconsistent low and high voltage thresholds use case
standbyAutomaton.setStandby(false);
assertFalse(standbyAutomaton.isStandby());
standbyAutomaton.setHighVoltageThreshold(200f);
assertEquals(200f, standbyAutomaton.getHighVoltageThreshold(), 0.0);
}

@Test
Expand Down

0 comments on commit a4cf99a

Please sign in to comment.