powsybl-core icon indicating copy to clipboard operation
powsybl-core copied to clipboard

First try at creating builders from existing object

Open miovd opened this issue 3 years ago • 4 comments

Signed-off-by: RALAMBOTIANA MIORA [email protected]

Please check if the PR fulfills these requirements (please use '[x]' to check the checkboxes, or submit the PR and then click the checkboxes)

  • [x] The commit message follows our guidelines
  • [x] Tests for the changes have been added (for bug fixes / features)
  • [ ] Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem ? If so, link to this issue using '#XXX' and skip the rest

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...) Feature: create components from existing components (e.g. a new generator initialized with all the values of an existing generator)

Does this PR introduce a breaking change or deprecate an API? If yes, check the following: No

Other information:

Documentation not complete: adders for partial contained objects must be documented (if everyone agrees)

miovd avatar Jul 16 '21 06:07 miovd

Nice feature!

Maybe we should be more clear about what is copied from the reference element and what is not. For instance, with lines I think that we could also copy the voltageLevelId1 and voltageLevelId2 so the only thing that would need to be specified would be the node1 and node2, because this is the only builder parameter that have to be unique.

So

l2 = n.newLine(l1)
  .setId("l2")
  .setNode1(3)
  .setNode(4)
  .add();

Would create a l2 which is exactly like l2 (in parallel) but with a different connection point.

In case of bus/breaker this is different, it is allowed to have multiple elements connected to same bus so we would only need to specify a new id.

l2 = n.newLine(l1)
 .setId("l2")
 .add();

geofjamg avatar Jul 26 '21 09:07 geofjamg

Nice feature!

Maybe we should be more clear about what is copied from the reference element and what is not. For instance, with lines I think that we could also copy the voltageLevelId1 and voltageLevelId2 so the only thing that would need to be specified would be the node1 and node2, because this is the only builder parameter that have to be unique.

So

l2 = n.newLine(l1)
  .setId("l2")
  .setNode1(3)
  .setNode(4)
  .add();

Would create a l2 which is exactly like l2 (in parallel) but with a different connection point.

In case of bus/breaker this is different, it is allowed to have multiple elements connected to same bus so we would only need to specify a new id.

l2 = n.newLine(l1)
 .setId("l2")
 .add();

I have modified the PR for the builder to copy everything in any case from the existing object (which would be what a user expects). No field is left blank, the user has to rewrite the ones they need/want to define.

miovd avatar Oct 11 '22 10:10 miovd