Skip to content

terminal adder missing node/connectablebus: take voltagelevel topology into account to give the correct error message  #3106

@jonenst

Description

@jonenst

Describe the current behavior

VoltageLevel s1vl1 = s1.newVoltageLevel()
            .setTopologyKind(TopologyKind.NODE_BREAKER)
s1vl1.newLoad().setId("load1").setP0(10.).setQ0(1.).add();

errors with

Exception in thread "main" com.powsybl.iidm.network.ValidationException: Load 'load1': connectable bus is not set
	at com.powsybl.iidm.network.impl.TerminalBuilder.build(TerminalBuilder.java:65)
	at com.powsybl.iidm.network.impl.AbstractInjectionAdder.checkAndGetTerminal(AbstractInjectionAdder.java:55)
	at com.powsybl.iidm.network.impl.LoadAdderImpl.add(LoadAdderImpl.java:71)
	at com.powsybl.iidm.network.impl.LoadAdderImpl.add(LoadAdderImpl.java:16)

should be
Load 'load1': node is not set

In this line we use node == null to differentiate between busterminal and nodeterminal but we should use the voltage level topology instead

throw new ValidationException(validable, "connectable bus is not set");

NOTE: if you use the wrong node/connectablebus, you do get an exception just after:

 com.powsybl.iidm.network.ValidationException: Load 'load1': voltage level S1VL1 has a node/breaker topology, a node connection should be specified instead of a bus connection
	at com.powsybl.iidm.network.impl.NodeBreakerVoltageLevel.checkTerminal(NodeBreakerVoltageLevel.java:1109)
	at com.powsybl.iidm.network.impl.NodeBreakerVoltageLevel.attach(NodeBreakerVoltageLevel.java:1125)
	at com.powsybl.iidm.network.impl.LoadAdderImpl.add(LoadAdderImpl.java:80)
	at com.powsybl.iidm.network.impl.LoadAdderImpl.add(LoadAdderImpl.java:16)

Describe the expected behavior

get the correct exception the first time

Describe the motivation

simplicity

Extra Information

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions