Skip to content

Commit

Permalink
Fix IIDM consistency checks
Browse files Browse the repository at this point in the history
  • Loading branch information
geofjamg committed Jul 28, 2016
1 parent c7822d8 commit 7a70bd8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public float getLowVoltageLimit() {

@Override
public VoltageLevel setLowVoltageLimit(float lowVoltageLimit) {
ValidationUtil.checkLowVoltageLimit(this, lowVoltageLimit);
ValidationUtil.checkVoltageLimits(this, lowVoltageLimit, highVoltageLimit);
float oldValue = this.lowVoltageLimit;
this.lowVoltageLimit = lowVoltageLimit;
notifyUpdate("lowVoltageLimit", oldValue, lowVoltageLimit);
Expand All @@ -85,7 +85,7 @@ public float getHighVoltageLimit() {

@Override
public VoltageLevel setHighVoltageLimit(float highVoltageLimit) {
ValidationUtil.checkHighVoltageLimit(this, highVoltageLimit);
ValidationUtil.checkVoltageLimits(this, lowVoltageLimit, highVoltageLimit);
float oldValue = this.highVoltageLimit;
this.highVoltageLimit = highVoltageLimit;
notifyUpdate("highVoltageLimit", oldValue, highVoltageLimit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ public boolean isValid(UndirectedGraph<? extends TerminalExt, SwitchImpl> graph,
case GENERATOR:
case SHUNT_COMPENSATOR:
case DANGLING_LINE:
case STATIC_VAR_COMPENSATOR:
feederCount++;
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,6 @@ public RatioTapChanger add() {
"a regulation terminal has to be set for a regulating ratio tap changer");
}
}
} else {
if (regulating != null) {
throw new ValidationException(parent,
"a regulating status is useless for a ratio tap changer without any load tap changing capabilities");
}
if (!Float.isNaN(targetV)) {
throw new ValidationException(parent,
"a target voltage is useless for a ratio tap changer without any load tap changing capabilities");
}
if (terminal != null) {
throw new ValidationException(parent,
"a regulation terminal is useless for a ratio tap changer without any load tap changing capabilities");
}
}
if (terminal != null && terminal.getVoltageLevel().getNetwork() != getNetwork()) {
throw new ValidationException(parent, "regulation terminal is not part of the network");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,16 @@ static void checkNominalV(Validable validable, float nominalV) {
}
}

static void checkLowVoltageLimit(Validable validable, float lowVoltageLimit) {
if (lowVoltageLimit <= 0) {
throw new ValidationException(validable, "low voltage limit is <= 0");
static void checkVoltageLimits(Validable validable, float lowVoltageLimit, float highVoltageLimit) {
if (lowVoltageLimit < 0) {
throw new ValidationException(validable, "low voltage limit is < 0");
}
}

static void checkHighVoltageLimit(Validable validable, float highVoltageLimit) {
if (highVoltageLimit <= 0) {
throw new ValidationException(validable, "high voltage limit is <= 0");
if (highVoltageLimit < 0) {
throw new ValidationException(validable, "high voltage limit is < 0");
}
if (lowVoltageLimit >= highVoltageLimit) {
throw new ValidationException(validable, "Inconsistent voltage limit range ["
+ lowVoltageLimit + ", " + highVoltageLimit + "]");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ public VoltageLevel add() {
// TODO : ckeck that there are not another voltage level with same base voltage

ValidationUtil.checkNominalV(this, nominalV);
ValidationUtil.checkLowVoltageLimit(this, lowVoltageLimit);
ValidationUtil.checkHighVoltageLimit(this, highVoltageLimit);
ValidationUtil.checkVoltageLimits(this, lowVoltageLimit, highVoltageLimit);
ValidationUtil.checkTopologyKind(this, topologyKind);

VoltageLevelExt voltageLevel;
Expand Down

0 comments on commit 7a70bd8

Please sign in to comment.