private void setIdEraseName(String id) { objectStore.remove(this); this.id = id; name = null; // reset the name objectStore.checkAndAdd(this); }
/** * Merge an other object store into this one. At the end of the call the * other object store is empty. * @param other the object store to merge */ void merge(ObjectStore other) { for (Identifiable obj : other.objectsById.values()) { checkAndAdd(obj); } other.clean(); }
NetworkImpl(String id, String name, String sourceFormat) { super(id, name); Objects.requireNonNull(sourceFormat, "source format is null"); this.sourceFormat = sourceFormat; variantManager = new VariantManagerImpl(objectStore); variants = new VariantArray<>(ref, VariantImpl::new); // add the network the object list as it is a multi variant object // and it needs to be notified when and extension or a reduction of // the variant array is requested objectStore.checkAndAdd(this); }
void addBus(ConfiguredBus bus) { getNetwork().getObjectStore().checkAndAdd(bus); int v = graph.addVertex(); graph.setVertexObject(v, bus); buses.put(bus.getId(), v); }
private void addSwitch(SwitchImpl aSwitch, String busId1, String busId2) { int v1 = getVertex(busId1, true); int v2 = getVertex(busId2, true); getNetwork().getObjectStore().checkAndAdd(aSwitch); int e = graph.addEdge(v1, v2, aSwitch); switches.put(aSwitch.getId(), e); }
@Override public Substation add() { String id = checkAndGetUniqueId(); ValidationUtil.checkCountry(this, country); SubstationImpl substation = new SubstationImpl(id, getName(), country, tso, networkRef); if (tags != null) { for (String tag : tags) { substation.addGeographicalTag(tag); } } getNetwork().getObjectStore().checkAndAdd(substation); getNetwork().getListeners().notifyCreation(substation); return substation; }
@Override public Switch add() { String id = checkAndGetUniqueId(); if (node1 == null) { throw new ValidationException(this, "first connection node is not set"); } if (node2 == null) { throw new ValidationException(this, "second connection node is not set"); } if (kind == null) { throw new ValidationException(this, "kind is not set"); } SwitchImpl aSwitch = new SwitchImpl(NodeBreakerVoltageLevel.this, id, getName(), kind, open, retained, fictitious); getNetwork().getObjectStore().checkAndAdd(aSwitch); int e = graph.addEdge(node1, node2, aSwitch); switches.put(id, e); invalidateCache(); getNetwork().getListeners().notifyCreation(aSwitch); return aSwitch; }
@Override public VoltageLevel add() { String id = checkAndGetUniqueId(); // TODO : ckeck that there are not another voltage level with same base voltage ValidationUtil.checkNominalV(this, nominalV); ValidationUtil.checkVoltageLimits(this, lowVoltageLimit, highVoltageLimit); ValidationUtil.checkTopologyKind(this, topologyKind); VoltageLevelExt voltageLevel; switch (topologyKind) { case NODE_BREAKER: voltageLevel = new NodeBreakerVoltageLevel(id, getName(), substation, nominalV, lowVoltageLimit, highVoltageLimit); break; case BUS_BREAKER: voltageLevel = new BusBreakerVoltageLevel(id, getName(), substation, nominalV, lowVoltageLimit, highVoltageLimit); break; default: throw new AssertionError(); } getNetwork().getObjectStore().checkAndAdd(voltageLevel); substation.addVoltageLevel(voltageLevel); getNetwork().getListeners().notifyCreation(voltageLevel); return voltageLevel; }
@Override public BusbarSection add() { String id = checkAndGetUniqueId(); TerminalExt terminal = new NodeTerminal(getNetwork().getRef(), node); BusbarSectionImpl section = new BusbarSectionImpl(id, getName()); section.addTerminal(terminal); voltageLevel.attach(terminal, false); getNetwork().getObjectStore().checkAndAdd(section); getNetwork().getListeners().notifyCreation(section); return section; }
@Override public LccConverterStation add() { String id = checkAndGetUniqueId(); String name = getName(); TerminalExt terminal = checkAndGetTerminal(); validate(); LccConverterStationImpl converterStation = new LccConverterStationImpl(id, name, getLossFactor(), powerFactor); converterStation.addTerminal(terminal); getVoltageLevel().attach(terminal, false); getNetwork().getObjectStore().checkAndAdd(converterStation); getNetwork().getListeners().notifyCreation(converterStation); return converterStation; }
@Override public ShuntCompensatorImpl add() { String id = checkAndGetUniqueId(); TerminalExt terminal = checkAndGetTerminal(); ValidationUtil.checkbPerSection(this, bPerSection); ValidationUtil.checkSections(this, currentSectionCount, maximumSectionCount); ShuntCompensatorImpl shunt = new ShuntCompensatorImpl(getNetwork().getRef(), id, getName(), bPerSection, maximumSectionCount, currentSectionCount); shunt.addTerminal(terminal); voltageLevel.attach(terminal, false); getNetwork().getObjectStore().checkAndAdd(shunt); getNetwork().getListeners().notifyCreation(shunt); return shunt; }
@Override public VscConverterStationImpl add() { String id = checkAndGetUniqueId(); String name = getName(); TerminalExt terminal = checkAndGetTerminal(); validate(); VscConverterStationImpl converterStation = new VscConverterStationImpl(id, name, getLossFactor(), getNetwork().getRef(), voltageRegulatorOn, reactivePowerSetpoint, voltageSetpoint); converterStation.addTerminal(terminal); getVoltageLevel().attach(terminal, false); getNetwork().getObjectStore().checkAndAdd(converterStation); getNetwork().getListeners().notifyCreation(converterStation); return converterStation; }
@Override public LoadImpl add() { String id = checkAndGetUniqueId(); TerminalExt terminal = checkAndGetTerminal(); ValidationUtil.checkLoadType(this, loadType); ValidationUtil.checkP0(this, p0); ValidationUtil.checkQ0(this, q0); LoadImpl load = new LoadImpl(getNetwork().getRef(), id, getName(), loadType, p0, q0); load.addTerminal(terminal); voltageLevel.attach(terminal, false); getNetwork().getObjectStore().checkAndAdd(load); getNetwork().getListeners().notifyCreation(load); return load; }
@Override public StaticVarCompensatorImpl add() { String id = checkAndGetUniqueId(); String name = getName(); TerminalExt terminal = checkAndGetTerminal(); ValidationUtil.checkBmin(this, bMin); ValidationUtil.checkBmax(this, bMax); ValidationUtil.checkSvcRegulator(this, voltageSetPoint, reactivePowerSetPoint, regulationMode); StaticVarCompensatorImpl svc = new StaticVarCompensatorImpl(id, name, bMin, bMax, voltageSetPoint, reactivePowerSetPoint, regulationMode, getNetwork().getRef()); svc.addTerminal(terminal); vl.attach(terminal, false); getNetwork().getObjectStore().checkAndAdd(svc); getNetwork().getListeners().notifyCreation(svc); return svc; }
@Override public DanglingLineImpl add() { String id = checkAndGetUniqueId(); TerminalExt terminal = checkAndGetTerminal(); ValidationUtil.checkP0(this, p0); ValidationUtil.checkQ0(this, q0); ValidationUtil.checkR(this, r); ValidationUtil.checkX(this, x); ValidationUtil.checkG(this, g); ValidationUtil.checkB(this, b); DanglingLineImpl danglingLine = new DanglingLineImpl(getNetwork().getRef(), id, getName(), p0, q0, r, x, g, b, ucteXnodeCode); danglingLine.addTerminal(terminal); voltageLevel.attach(terminal, false); getNetwork().getObjectStore().checkAndAdd(danglingLine); getNetwork().getListeners().notifyCreation(danglingLine); return danglingLine; }
@Override public HvdcLine add() { String id = checkAndGetUniqueId(); String name = getName(); ValidationUtil.checkR(this, r); ValidationUtil.checkConvertersMode(this, convertersMode); ValidationUtil.checkNominalV(this, nominalV); ValidationUtil.checkActivePowerSetpoint(this, activePowerSetpoint); ValidationUtil.checkMaxP(this, maxP); AbstractHvdcConverterStation<?> converterStation1 = getNetwork().getHvdcConverterStation(converterStationId1); if (converterStation1 == null) { throw new PowsyblException("Side 1 converter station " + converterStationId1 + " not found"); } AbstractHvdcConverterStation<?> converterStation2 = getNetwork().getHvdcConverterStation(converterStationId2); if (converterStation2 == null) { throw new PowsyblException("Side 2 converter station " + converterStationId2 + " not found"); } HvdcLineImpl hvdcLine = new HvdcLineImpl(id, name, r, nominalV, maxP, convertersMode, activePowerSetpoint, converterStation1, converterStation2, networkRef); getNetwork().getObjectStore().checkAndAdd(hvdcLine); getNetwork().getListeners().notifyCreation(hvdcLine); return hvdcLine; }
@Override public TieLineImpl add() { String id = checkAndGetUniqueId(); VoltageLevelExt voltageLevel1 = checkAndGetVoltageLevel1(); VoltageLevelExt voltageLevel2 = checkAndGetVoltageLevel2(); TerminalExt terminal1 = checkAndGetTerminal1(); TerminalExt terminal2 = checkAndGetTerminal2(); if (ucteXnodeCode == null) { throw new ValidationException(this, "ucteXnodeCode is not set"); } checkHalf(half1, 1); checkHalf(half2, 2); // check that the line is attachable on both side voltageLevel1.attach(terminal1, true); voltageLevel2.attach(terminal2, true); TieLineImpl line = new TieLineImpl(id, getName(), ucteXnodeCode, half1, half2); terminal1.setNum(1); terminal2.setNum(2); line.addTerminal(terminal1); line.addTerminal(terminal2); voltageLevel1.attach(terminal1, false); voltageLevel2.attach(terminal2, false); network.getObjectStore().checkAndAdd(line); return line; }
@Override public GeneratorImpl add() { String id = checkAndGetUniqueId(); TerminalExt terminal = checkAndGetTerminal(); ValidationUtil.checkEnergySource(this, energySource); ValidationUtil.checkMinP(this, minP); ValidationUtil.checkMaxP(this, maxP); ValidationUtil.checkRegulatingTerminal(this, regulatingTerminal, getNetwork()); ValidationUtil.checkActivePowerSetpoint(this, targetP); ValidationUtil.checkVoltageControl(this, voltageRegulatorOn, targetV, targetQ); ValidationUtil.checkActiveLimits(this, minP, maxP); ValidationUtil.checkRatedS(this, ratedS); GeneratorImpl generator = new GeneratorImpl(getNetwork().getRef(), id, getName(), energySource, minP, maxP, voltageRegulatorOn, regulatingTerminal != null ? regulatingTerminal : terminal, targetP, targetQ, targetV, ratedS); generator.addTerminal(terminal); voltageLevel.attach(terminal, false); getNetwork().getObjectStore().checkAndAdd(generator); getNetwork().getListeners().notifyCreation(generator); return generator; }
@Override public LineImpl add() { String id = checkAndGetUniqueId(); VoltageLevelExt voltageLevel1 = checkAndGetVoltageLevel1(); VoltageLevelExt voltageLevel2 = checkAndGetVoltageLevel2(); TerminalExt terminal1 = checkAndGetTerminal1(); TerminalExt terminal2 = checkAndGetTerminal2(); ValidationUtil.checkR(this, r); ValidationUtil.checkX(this, x); ValidationUtil.checkG1(this, g1); ValidationUtil.checkG2(this, g2); ValidationUtil.checkB1(this, b1); ValidationUtil.checkB2(this, b2); // check that the line is attachable on both side voltageLevel1.attach(terminal1, true); voltageLevel2.attach(terminal2, true); LineImpl line = new LineImpl(id, getName(), r, x, g1, b1, g2, b2); terminal1.setNum(1); terminal2.setNum(2); line.addTerminal(terminal1); line.addTerminal(terminal2); voltageLevel1.attach(terminal1, false); voltageLevel2.attach(terminal2, false); network.getObjectStore().checkAndAdd(line); getNetwork().getListeners().notifyCreation(line); return line; }
getNetwork().getObjectStore().checkAndAdd(transformer); getNetwork().getListeners().notifyCreation(transformer); return transformer;