Skip to content
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

Allow standByAutomaton extension to have inconsistent voltage thresho… #3268

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading