@Test public void testConnectVoltageRegulatorOnWithAlreadyConnectedGenerators() { g2.setVoltageRegulatorOn(true); GeneratorUtil.connectGenerator(g2); assertTrue(g2.getTerminal().isConnected()); assertEquals(33., g2.getTargetV(), 0.01); }
public static void connectGenerator(Generator g) { Terminal t = g.getTerminal(); t.connect(); if (g.isVoltageRegulatorOn()) { Bus bus = t.getBusView().getBus(); if (bus != null) { double targetV = bus.getGeneratorStream() .filter(g2 -> !g2.getId().equals(g.getId())) .findFirst().map(Generator::getTargetV).orElse(Double.NaN); if (!Double.isNaN(targetV)) { g.setTargetV(targetV); } else if (!Double.isNaN(bus.getV())) { g.setTargetV(bus.getV()); } } } }
GeneratorUtil { public static void connectGenerator(Generator g) { Terminal t = g.getTerminal(); t.connect(); if (g.isVoltageRegulatorOn()) { Bus bus = t.getBusView().getBus(); if (bus != null) { double targetV = bus.getGeneratorStream() .filter(g2 -> !g2.getId().equals(g.getId())) .findFirst().map(Generator::getTargetV).orElse(Double.NaN); if (!Double.isNaN(targetV)) { g.setTargetV(targetV); } else if (!Double.isNaN(bus.getV())) { g.setTargetV(bus.getV()); } } } } }
GeneratorUtil { public static void connectGenerator(Generator g) { Terminal t = g.getTerminal(); t.connect(); if (g.isVoltageRegulatorOn()) { Bus bus = t.getBusView().getBus(); if (bus != null) { double targetV = bus.getGeneratorStream() .filter(g2 -> !g2.getId().equals(g.getId())) .findFirst().map(Generator::getTargetV).orElse(Double.NaN); if (!Double.isNaN(targetV)) { g.setTargetV(targetV); } else if (!Double.isNaN(bus.getV())) { g.setTargetV(bus.getV()); } } } } private  GeneratorUtil(); }
GeneratorUtil { public static void connectGenerator(Generator g) { Terminal t = g.getTerminal(); t.connect(); if (g.isVoltageRegulatorOn()) { Bus bus = t.getBusView().getBus(); if (bus != null) { double targetV = bus.getGeneratorStream() .filter(g2 -> !g2.getId().equals(g.getId())) .findFirst().map(Generator::getTargetV).orElse(Double.NaN); if (!Double.isNaN(targetV)) { g.setTargetV(targetV); } else if (!Double.isNaN(bus.getV())) { g.setTargetV(bus.getV()); } } } } private  GeneratorUtil(); static void connectGenerator(Generator g); }
GeneratorUtil { public static void connectGenerator(Generator g) { Terminal t = g.getTerminal(); t.connect(); if (g.isVoltageRegulatorOn()) { Bus bus = t.getBusView().getBus(); if (bus != null) { double targetV = bus.getGeneratorStream() .filter(g2 -> !g2.getId().equals(g.getId())) .findFirst().map(Generator::getTargetV).orElse(Double.NaN); if (!Double.isNaN(targetV)) { g.setTargetV(targetV); } else if (!Double.isNaN(bus.getV())) { g.setTargetV(bus.getV()); } } } } private  GeneratorUtil(); static void connectGenerator(Generator g);  }