Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operational limits group #2802

Merged
merged 26 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2d28fa3
Replace the 3 OperationalLimits Current, ApparentPower and ActivePowe…
Nov 27, 2023
26b9b10
Factorize code that will be change
Jan 8, 2024
e14420f
new iidm
Jan 5, 2024
f4262a5
SerDe new optional limits read and write
Jan 9, 2024
2d375e3
Update xml, xiidm
Jan 15, 2024
1f6d1ca
restore cgmes before 1.12
Jan 15, 2024
104fbf2
Remove new interfaces, add authorship
Jan 16, 2024
b628b80
Merge branch 'main' into add_operational_limits_set
flo-dup Jan 17, 2024
bfcf452
Add operational limits group default id constant, change it to "DEFAULT"
flo-dup Jan 17, 2024
582ded7
setXxxTo() -> setXxx()
flo-dup Jan 17, 2024
4355045
Remove AbstractOperationalLimits
flo-dup Jan 17, 2024
25caa5a
Remove GroupValidable
flo-dup Jan 17, 2024
d8e00be
Remove duplicate getDefault
flo-dup Jan 17, 2024
1ee9e76
Remove LimitsGroups from xsd
flo-dup Jan 17, 2024
d756780
Various fixes
flo-dup Jan 17, 2024
8817e1e
Fix the case where no default group is present and the limits additio…
olperr1 Jan 18, 2024
846c8ce
Update psse unit test references
flo-dup Jan 18, 2024
84a794b
Validate limits before creating default group
olperr1 Jan 18, 2024
efe56d9
Replace "default" keyword with "selected"
flo-dup Jan 18, 2024
855d657
Remove OperationalLimitsGroups duplicate of FlowsLimitsHolder
flo-dup Jan 18, 2024
3a00930
Remove Ref to selected, centralize access to it and to the map
flo-dup Jan 18, 2024
7439030
Notify update with enriched record
flo-dup Jan 18, 2024
7e0295f
Add intermediate method for setting selected group with nullable id
flo-dup Jan 18, 2024
cc1b879
Use orElseGet for compact code
flo-dup Jan 18, 2024
6336147
Add Javadoc
olperr1 Jan 19, 2024
7d538ab
Merge branch 'main' into add_operational_limits_set
olperr1 Jan 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
253 changes: 230 additions & 23 deletions iidm/iidm-api/src/main/java/com/powsybl/iidm/network/Branch.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package com.powsybl.iidm.network;

import java.util.Collection;
import java.util.Collections;
import java.util.Optional;

/**
Expand Down Expand Up @@ -116,52 +115,260 @@ public interface Branch<I extends Branch<I>> extends Identifiable<I> {

TwoSides getSide(Terminal terminal);

default Collection<OperationalLimits> getOperationalLimits1() {
return getCurrentLimits1()
.map(l -> Collections.singletonList((OperationalLimits) l))
.orElseGet(Collections::emptyList);
}
/**
* Get the collection of the defined {@link OperationalLimitsGroup} on side 1.
* @return the {@link OperationalLimitsGroup} s on side 1.
*/
Collection<OperationalLimitsGroup> getOperationalLimitsGroups1();

/**
* Get the {@link OperationalLimitsGroup} corresponding to an ID on side 1.
* @return the {@link OperationalLimitsGroup} of the given ID on side 1 if any, an empty {@link Optional} otherwise.
*/
Optional<String> getSelectedOperationalLimitsGroupId1();

/**
* Get the {@link OperationalLimitsGroup} corresponding to an ID on side 1.
* @return the {@link OperationalLimitsGroup} of the given ID on side 1 if any, an empty {@link Optional} otherwise.
*/
Optional<OperationalLimitsGroup> getOperationalLimitsGroup1(String id);

/**
* Get the selected {@link OperationalLimitsGroup} on side 1.
* @return the selected {@link OperationalLimitsGroup} on side 1 if any, an empty {@link Optional} otherwise.
*/
Optional<OperationalLimitsGroup> getSelectedOperationalLimitsGroup1();

/**
* <p>Create a new {@link OperationalLimitsGroup} on side 1 with the given ID.</p>
* <p>If a group of the given ID already exists, it is replaced silently.</p>
* @return the newly created group {@link OperationalLimitsGroup}.
*/
OperationalLimitsGroup newOperationalLimitsGroup1(String id);

/**
* <p>Set the {@link OperationalLimitsGroup} corresponding to the given ID as as the selected one on side 1.</p>
* <p>Throw a {@link com.powsybl.commons.PowsyblException} if the ID doesn't correspond to any existing group.</p>
* <p>Throw an {@link NullPointerException} if the ID is <code>null</code>.
* To reset the selected group, use {@link #cancelSelectedOperationalLimitsGroup1}.</p>
* @param id an ID of {@link OperationalLimitsGroup}
*/
void setSelectedOperationalLimitsGroup1(String id);

/**
* <p>Remove the {@link OperationalLimitsGroup} corresponding to the given ID on side 1.</p>
* <p>Throw an {@link NullPointerException} if the ID is <code>null</code>.
* @param id an ID of {@link OperationalLimitsGroup}
*/
void removeOperationalLimitsGroup1(String id);

/**
* <p>Cancel the selected {@link OperationalLimitsGroup} on side 1.</p>
* <p>After calling this method, no {@link OperationalLimitsGroup} is selected on side 1.</p>
*/
void cancelSelectedOperationalLimitsGroup1();

Optional<CurrentLimits> getCurrentLimits1();
/**
* Get the {@link CurrentLimits} of the selected {@link OperationalLimitsGroup} on side 1.
* @return {@link CurrentLimits} of the selected {@link OperationalLimitsGroup} on side 1 if any, <code>null</code> otherwise.
*/
default Optional<CurrentLimits> getCurrentLimits1() {
return getSelectedOperationalLimitsGroup1().flatMap(OperationalLimitsGroup::getCurrentLimits);
}

CurrentLimits getNullableCurrentLimits1();
/**
* Get the {@link CurrentLimits} of the selected {@link OperationalLimitsGroup} on side 1.
* @return {@link CurrentLimits} of the selected {@link OperationalLimitsGroup} on side 1 if any, <code>null</code> otherwise.
*/
default CurrentLimits getNullableCurrentLimits1() {
return getCurrentLimits1().orElse(null);
}

Optional<ActivePowerLimits> getActivePowerLimits1();
/**
* Get the {@link ActivePowerLimits} of the selected {@link OperationalLimitsGroup} on side 1.
* @return {@link ActivePowerLimits} of the selected {@link OperationalLimitsGroup} on side 1 if any, an empty {@link Optional} otherwise.
*/
default Optional<ActivePowerLimits> getActivePowerLimits1() {
return getSelectedOperationalLimitsGroup1().flatMap(OperationalLimitsGroup::getActivePowerLimits);
}

ActivePowerLimits getNullableActivePowerLimits1();
/**
* Get the {@link ActivePowerLimits} of the selected {@link OperationalLimitsGroup} on side 1.
* @return {@link ActivePowerLimits} of the selected {@link OperationalLimitsGroup} on side 1 if any, <code>null</code> otherwise.
*/
default ActivePowerLimits getNullableActivePowerLimits1() {
return getActivePowerLimits1().orElse(null);
}

Optional<ApparentPowerLimits> getApparentPowerLimits1();
/**
* Get the {@link ApparentPowerLimits} of the selected {@link OperationalLimitsGroup} on side 1.
* @return {@link ApparentPowerLimits} of the selected {@link OperationalLimitsGroup} on side 1 if any, an empty {@link Optional} otherwise.
*/
default Optional<ApparentPowerLimits> getApparentPowerLimits1() {
return getSelectedOperationalLimitsGroup1().flatMap(OperationalLimitsGroup::getApparentPowerLimits);
}

ApparentPowerLimits getNullableApparentPowerLimits1();
/**
* Get the {@link ApparentPowerLimits} of the selected {@link OperationalLimitsGroup} on side 1.
* @return {@link ApparentPowerLimits} of the selected {@link OperationalLimitsGroup} on side 1 if any, <code>null</code> otherwise.
*/
default ApparentPowerLimits getNullableApparentPowerLimits1() {
return getApparentPowerLimits1().orElse(null);
}

/**
* <p>Create an adder to add a new {@link CurrentLimits} in the selected {@link OperationalLimitsGroup} on side 1.</p>
* <p>If there's no selected group, the adder will also create a new group with the default name and set it as selected.
* This operation is performed when the limits are created via {@link CurrentLimitsAdder#add()}, only if the limits to add
* are valid.</p>
* @return an adder allowing to create a new {@link CurrentLimits} in the selected {@link OperationalLimitsGroup} on side 1.
*/
CurrentLimitsAdder newCurrentLimits1();

/**
* <p>Create an adder to add a new {@link ActivePowerLimits} in the selected {@link OperationalLimitsGroup} on side 1.</p>
* <p>If there's no selected group, the adder will also create a new group with the default name and set it as selected.
* This operation is performed when the limits are created via {@link CurrentLimitsAdder#add()}, only if the limits to add
* are valid.</p>
* @return an adder allowing to create a new {@link ActivePowerLimits} in the selected {@link OperationalLimitsGroup} on side 1.
*/
ActivePowerLimitsAdder newActivePowerLimits1();

/**
* <p>Create an adder to add a new {@link ApparentPowerLimits} in the selected {@link OperationalLimitsGroup} on side 1.</p>
* <p>If there's no selected group, the adder will also create a new group with the default name and set it as selected.
* This operation is performed when the limits are created via {@link CurrentLimitsAdder#add()}, only if the limits to add
* are valid.</p>
* @return an adder allowing to create a new {@link ApparentPowerLimits} in the selected {@link OperationalLimitsGroup} on side 1.
*/
ApparentPowerLimitsAdder newApparentPowerLimits1();

default Collection<OperationalLimits> getOperationalLimits2() {
return getCurrentLimits2()
.map(l -> Collections.singletonList((OperationalLimits) l))
.orElseGet(Collections::emptyList);
}
/**
* Get the collection of the defined {@link OperationalLimitsGroup} on side 2.
* @return the {@link OperationalLimitsGroup} s on side 2.
*/
Collection<OperationalLimitsGroup> getOperationalLimitsGroups2();

/**
* Get the {@link OperationalLimitsGroup} corresponding to an ID on side 2.
* @return the {@link OperationalLimitsGroup} of the given ID on side 2 if any, an empty {@link Optional} otherwise.
*/
Optional<String> getSelectedOperationalLimitsGroupId2();

/**
* Get the {@link OperationalLimitsGroup} corresponding to an ID on side 2.
* @return the {@link OperationalLimitsGroup} of the given ID on side 2 if any, an empty {@link Optional} otherwise.
*/
Optional<OperationalLimitsGroup> getOperationalLimitsGroup2(String id);

/**
* Get the selected {@link OperationalLimitsGroup} on side 2.
* @return the selected {@link OperationalLimitsGroup} on side 2 if any, an empty {@link Optional} otherwise.
*/
Optional<OperationalLimitsGroup> getSelectedOperationalLimitsGroup2();

/**
* <p>Create a new {@link OperationalLimitsGroup} on side 2 with the given ID.</p>
* <p>If a group of the given ID already exists, it is replaced silently.</p>
* @return the newly created group {@link OperationalLimitsGroup}.
*/
OperationalLimitsGroup newOperationalLimitsGroup2(String id);

/**
* <p>Set the {@link OperationalLimitsGroup} corresponding to the given ID as as the selected one on side 2.</p>
* <p>Throw a {@link com.powsybl.commons.PowsyblException} if the ID doesn't correspond to any existing group.</p>
* <p>Throw an {@link NullPointerException} if the ID is <code>null</code>.
* To reset the selected group, use {@link #cancelSelectedOperationalLimitsGroup2}.</p>
* @param id an ID of {@link OperationalLimitsGroup}
*/
void setSelectedOperationalLimitsGroup2(String id);

/**
* <p>Remove the {@link OperationalLimitsGroup} corresponding to the given ID on side 2.</p>
* <p>Throw an {@link NullPointerException} if the ID is <code>null</code>.
* @param id an ID of {@link OperationalLimitsGroup}
*/
void removeOperationalLimitsGroup2(String id);

/**
* <p>Cancel the selected {@link OperationalLimitsGroup} on side 2.</p>
* <p>After calling this method, no {@link OperationalLimitsGroup} is selected on side 2.</p>
*/
void cancelSelectedOperationalLimitsGroup2();

Optional<CurrentLimits> getCurrentLimits2();
/**
* Get the {@link CurrentLimits} of the selected {@link OperationalLimitsGroup} on side 2.
* @return {@link CurrentLimits} of the selected {@link OperationalLimitsGroup} on side 2 if any, <code>null</code> otherwise.
*/
default Optional<CurrentLimits> getCurrentLimits2() {
return getSelectedOperationalLimitsGroup2().flatMap(OperationalLimitsGroup::getCurrentLimits);
}

CurrentLimits getNullableCurrentLimits2();
/**
* Get the {@link CurrentLimits} of the selected {@link OperationalLimitsGroup} on side 2.
* @return {@link CurrentLimits} of the selected {@link OperationalLimitsGroup} on side 2 if any, <code>null</code> otherwise.
*/
default CurrentLimits getNullableCurrentLimits2() {
return getCurrentLimits2().orElse(null);
}

Optional<ActivePowerLimits> getActivePowerLimits2();
/**
* Get the {@link ActivePowerLimits} of the selected {@link OperationalLimitsGroup} on side 2.
* @return {@link ActivePowerLimits} of the selected {@link OperationalLimitsGroup} on side 2 if any, an empty {@link Optional} otherwise.
*/
default Optional<ActivePowerLimits> getActivePowerLimits2() {
return getSelectedOperationalLimitsGroup2().flatMap(OperationalLimitsGroup::getActivePowerLimits);
}

ActivePowerLimits getNullableActivePowerLimits2();
/**
* Get the {@link ActivePowerLimits} of the selected {@link OperationalLimitsGroup} on side 2.
* @return {@link ActivePowerLimits} of the selected {@link OperationalLimitsGroup} on side 2 if any, <code>null</code> otherwise.
*/
default ActivePowerLimits getNullableActivePowerLimits2() {
return getActivePowerLimits2().orElse(null);
}

Optional<ApparentPowerLimits> getApparentPowerLimits2();
/**
* Get the {@link ApparentPowerLimits} of the selected {@link OperationalLimitsGroup} on side 2.
* @return {@link ApparentPowerLimits} of the selected {@link OperationalLimitsGroup} on side 2 if any, an empty {@link Optional} otherwise.
*/
default Optional<ApparentPowerLimits> getApparentPowerLimits2() {
return getSelectedOperationalLimitsGroup2().flatMap(OperationalLimitsGroup::getApparentPowerLimits);
}

ApparentPowerLimits getNullableApparentPowerLimits2();
/**
* Get the {@link ApparentPowerLimits} of the selected {@link OperationalLimitsGroup} on side 2.
* @return {@link ApparentPowerLimits} of the selected {@link OperationalLimitsGroup} on side 2 if any, <code>null</code> otherwise.
*/
default ApparentPowerLimits getNullableApparentPowerLimits2() {
return getApparentPowerLimits2().orElse(null);
}

/**
* <p>Create an adder to add a new {@link CurrentLimits} in the selected {@link OperationalLimitsGroup} on side 2.</p>
* <p>If there's no selected group, the adder will also create a new group with the default name and set it as selected.
* This operation is performed when the limits are created via {@link CurrentLimitsAdder#add()}, only if the limits to add
* are valid.</p>
* @return an adder allowing to create a new {@link CurrentLimits} in the selected {@link OperationalLimitsGroup} on side 2.
*/
CurrentLimitsAdder newCurrentLimits2();

/**
* <p>Create an adder to add a new {@link ActivePowerLimits} in the selected {@link OperationalLimitsGroup} on side 2.</p>
* <p>If there's no selected group, the adder will also create a new group with the default name and set it as selected.
* This operation is performed when the limits are created via {@link CurrentLimitsAdder#add()}, only if the limits to add
* are valid.</p>
* @return an adder allowing to create a new {@link ActivePowerLimits} in the selected {@link OperationalLimitsGroup} on side 2.
*/
ActivePowerLimitsAdder newActivePowerLimits2();

/**
* <p>Create an adder to add a new {@link ApparentPowerLimits} in the selected {@link OperationalLimitsGroup} on side 2.</p>
* <p>If there's no selected group, the adder will also create a new group with the default name and set it as selected.
* This operation is performed when the limits are created via {@link CurrentLimitsAdder#add()}, only if the limits to add
* are valid.</p>
* @return an adder allowing to create a new {@link ApparentPowerLimits} in the selected {@link OperationalLimitsGroup} on side 2.
*/
ApparentPowerLimitsAdder newApparentPowerLimits2();

default Optional<CurrentLimits> getCurrentLimits(TwoSides side) {
Expand Down
Loading