DefaultLimitViolationDetector extends AbstractContingencyBlindDetector { @Override public void checkVoltage(Bus bus, double value, Consumer<LimitViolation> consumer) { VoltageLevel vl = bus.getVoltageLevel(); if (!Double.isNaN(vl.getLowVoltageLimit()) && value <= vl.getLowVoltageLimit()) { consumer.accept(new LimitViolation(vl.getId(), vl.getOptionalName().orElse(null), LimitViolationType.LOW_VOLTAGE, vl.getLowVoltageLimit(), limitReduction, value)); } if (!Double.isNaN(vl.getHighVoltageLimit()) && value >= vl.getHighVoltageLimit()) { consumer.accept(new LimitViolation(vl.getId(), vl.getOptionalName().orElse(null), LimitViolationType.HIGH_VOLTAGE, vl.getHighVoltageLimit(), limitReduction, value)); } } DefaultLimitViolationDetector(float limitReduction, Collection<Security.CurrentLimitType> currentLimitTypes);  DefaultLimitViolationDetector(Collection<Security.CurrentLimitType> currentLimitTypes);  DefaultLimitViolationDetector(); @Override void checkCurrent(Branch branch, Branch.Side side, double value, Consumer<LimitViolation> consumer); @Override void checkVoltage(Bus bus, double value, Consumer<LimitViolation> consumer);  }
@Test public void detectHighVoltageViolation() { voltageLevelHv1.getBusView().getBusStream() .forEach(b -> detector.checkVoltage(b, 520, violationsCollector::add)); Assertions.assertThat(violationsCollector) .hasSize(1) .allSatisfy(v -> { Assert.assertEquals(LimitViolationType.HIGH_VOLTAGE, v.getLimitType()); assertEquals(500, v.getLimit(), 0d); assertEquals(520, v.getValue(), 0d); assertNull(v.getSide()); assertEquals(Integer.MAX_VALUE, v.getAcceptableDuration()); }); }
@Test public void detectLowVoltageViolation() { voltageLevelHv1.getBusView().getBusStream() .forEach(b -> detector.checkVoltage(b, 380, violationsCollector::add)); Assertions.assertThat(violationsCollector) .hasSize(1) .allSatisfy(v -> { assertEquals(LimitViolationType.LOW_VOLTAGE, v.getLimitType()); assertEquals(400, v.getLimit(), 0d); assertEquals(380, v.getValue(), 0d); assertNull(v.getSide()); assertEquals(Integer.MAX_VALUE, v.getAcceptableDuration()); }); }