-
Notifications
You must be signed in to change notification settings - Fork 0
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
stores and apply several limit sets in the branch creation #9
base: main
Are you sure you want to change the base?
Changes from 9 commits
a6634b6
28ad43f
1f00dc0
58a77ef
0c57651
eccbc5e
d05d9be
e0942a2
4ede9ef
5eae6c8
ad86424
13d096f
c20b3a8
a52072a
1c71d77
e5e03d9
2e16fd5
6e93a4a
ba0de6a
d080a43
a07090d
cbc5f73
31cfb43
dc771ee
44c9e25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ | |
import lombok.ToString; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author Sylvain Bouzols <sylvain.bouzols at rte-france.com> | ||
*/ | ||
|
@@ -43,11 +45,17 @@ public class BranchCreationInfos extends EquipmentCreationInfos { | |
@Schema(description = "Bus or Busbar section id Side 2") | ||
private String busOrBusbarSectionId2; | ||
|
||
@Schema(description = "Current limits Side 1") | ||
private CurrentLimitsInfos currentLimits1; | ||
@Schema(description = "Current limits on side 1") | ||
private List<CurrentLimitsInfos> currentLimits1; | ||
|
||
@Schema(description = "Current limits on side 2") | ||
private List<CurrentLimitsInfos> currentLimits2; | ||
|
||
@Schema(description = "Selected operational limits group id on Side 1") | ||
private String selectedOperationalLimitsGroupId1; | ||
|
||
@Schema(description = "Current limits Side 2") | ||
private CurrentLimitsInfos currentLimits2; | ||
@Schema(description = "Selected operational limits group id on Side 2") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Selected operational limits group on Side 2 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK why not. |
||
private String selectedOperationalLimitsGroupId2; | ||
|
||
@Schema(description = "Connection Name 1") | ||
private String connectionName1; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,16 +7,14 @@ | |
package org.gridsuite.modification.dto; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
import lombok.*; | ||
basseche marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import lombok.experimental.SuperBuilder; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author Sylvain Bouzols <sylvain.bouzols at rte-france.com> | ||
* ~= environ operational limit group, ~= limit set | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to be removed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. I instead createa an OperationalLimitsGroup class to be closer to IIDM. |
||
*/ | ||
|
||
@SuperBuilder | ||
|
@@ -27,6 +25,9 @@ | |
@Schema(description = "Current Limits") | ||
public class CurrentLimitsInfos { | ||
|
||
@Schema(description = "Operational limit group name") | ||
private String operationalLimitGroupId; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. operationalLimitsGroupId ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also change the description There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This class member has been removed. But yep the 's' was missing. |
||
|
||
@Schema(description = "Permanent current limit") | ||
private Double permanentLimit; | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -17,6 +17,8 @@ | |||||
import org.gridsuite.modification.utils.ModificationUtils; | ||||||
import org.gridsuite.modification.utils.PropertiesUtils; | ||||||
|
||||||
import java.util.List; | ||||||
|
||||||
import static org.gridsuite.modification.NetworkModificationException.Type.*; | ||||||
|
||||||
/** | ||||||
|
@@ -67,16 +69,25 @@ public void apply(Network network, ReportNode subReportNode) { | |||||
} | ||||||
|
||||||
// Set permanent and temporary current limits | ||||||
CurrentLimitsInfos currentLimitsInfos1 = modificationInfos.getCurrentLimits1(); | ||||||
CurrentLimitsInfos currentLimitsInfos2 = modificationInfos.getCurrentLimits2(); | ||||||
if (currentLimitsInfos1 != null || currentLimitsInfos2 != null) { | ||||||
List<CurrentLimitsInfos> currentLimitsSide1 = modificationInfos.getCurrentLimits1(); | ||||||
List<CurrentLimitsInfos> currentLimitsSide2 = modificationInfos.getCurrentLimits2(); | ||||||
if (currentLimitsSide1 != null && !currentLimitsSide1.isEmpty()) { | ||||||
var line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK done. |
||||||
ModificationUtils.getInstance().setCurrentLimitsOnASide(currentLimitsSide1, line, ModificationUtils.Side.SIDE1); | ||||||
} | ||||||
if (currentLimitsSide2 != null && !currentLimitsSide2.isEmpty()) { | ||||||
var line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); | ||||||
ModificationUtils.getInstance().setCurrentLimits(currentLimitsInfos1, line.newCurrentLimits1()); | ||||||
ModificationUtils.getInstance().setCurrentLimits(currentLimitsInfos2, line.newCurrentLimits2()); | ||||||
ModificationUtils.getInstance().setCurrentLimitsOnASide(currentLimitsSide2, line, ModificationUtils.Side.SIDE2); | ||||||
} | ||||||
ModificationUtils.getInstance().disconnectBranch(modificationInfos, network.getLine(modificationInfos.getEquipmentId()), subReportNode); | ||||||
// properties | ||||||
Line line = network.getLine(modificationInfos.getEquipmentId()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can place this line before (for example, line 74) to avoid calling getLine three times and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I thought about this but didn't dare because it looks like whoever wrote this like this did it on purpose. And I didn't want to take the risk. But ok you look motivated I did it ! |
||||||
if (modificationInfos.getSelectedOperationalLimitsGroupId1() != null) { | ||||||
line.setSelectedOperationalLimitsGroup1(modificationInfos.getSelectedOperationalLimitsGroupId1()); | ||||||
} | ||||||
if (modificationInfos.getSelectedOperationalLimitsGroupId2() != null) { | ||||||
line.setSelectedOperationalLimitsGroup2(modificationInfos.getSelectedOperationalLimitsGroupId2()); | ||||||
} | ||||||
PropertiesUtils.applyProperties(line, subReportNode, modificationInfos.getProperties(), "LineProperties"); | ||||||
} | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,11 @@ | |
// TODO remove public qualifier for all methods | ||
public final class ModificationUtils { | ||
|
||
public enum Side { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you don't need this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True. I changed it, thank you. |
||
SIDE1, | ||
SIDE2 | ||
} | ||
|
||
public static final String DISCONNECTOR = "disconnector_"; | ||
public static final String BREAKER = "breaker_"; | ||
public static final String BUS_BAR_SECTION_ID = "busbarSectionId"; | ||
|
@@ -1010,24 +1015,34 @@ public Identifiable<?> getEquipmentByIdentifiableType(Network network, Identifia | |
}; | ||
} | ||
|
||
public void setCurrentLimits(CurrentLimitsInfos currentLimitsInfos, CurrentLimitsAdder limitsAdder) { | ||
if (currentLimitsInfos != null) { | ||
/** | ||
* @param allCurrentLimitsInfos added current limits | ||
* @param branch branch to which limits are going to be added | ||
* @param side which side of the branch receives the limits | ||
*/ | ||
public void setCurrentLimitsOnASide(List<CurrentLimitsInfos> allCurrentLimitsInfos, Branch<?> branch, Side side) { | ||
for (CurrentLimitsInfos currentLimitsInfos : allCurrentLimitsInfos) { | ||
boolean hasPermanent = currentLimitsInfos.getPermanentLimit() != null; | ||
boolean hasTemporary = currentLimitsInfos.getTemporaryLimits() != null && !currentLimitsInfos.getTemporaryLimits().isEmpty(); | ||
if (hasPermanent) { | ||
limitsAdder.setPermanentLimit(currentLimitsInfos.getPermanentLimit()); | ||
} | ||
if (hasTemporary) { | ||
for (CurrentTemporaryLimitCreationInfos limit : currentLimitsInfos.getTemporaryLimits()) { | ||
limitsAdder | ||
.beginTemporaryLimit() | ||
.setName(limit.getName()) | ||
.setValue(limit.getValue() == null ? Double.MAX_VALUE : limit.getValue()) | ||
.setAcceptableDuration(limit.getAcceptableDuration() == null ? Integer.MAX_VALUE : limit.getAcceptableDuration()) | ||
.endTemporaryLimit(); | ||
boolean hasTemporary = !CollectionUtils.isEmpty(currentLimitsInfos.getTemporaryLimits()); | ||
boolean hasLimits = hasPermanent || hasTemporary; | ||
if (hasLimits) { | ||
basseche marked this conversation as resolved.
Show resolved
Hide resolved
|
||
OperationalLimitsGroup opGroup = side == Side.SIDE1 | ||
? branch.newOperationalLimitsGroup1(currentLimitsInfos.getOperationalLimitGroupId()) | ||
: branch.newOperationalLimitsGroup2(currentLimitsInfos.getOperationalLimitGroupId()); | ||
CurrentLimitsAdder limitsAdder = opGroup.newCurrentLimits(); | ||
if (hasPermanent) { | ||
limitsAdder.setPermanentLimit(currentLimitsInfos.getPermanentLimit()); | ||
} | ||
if (hasTemporary) { | ||
for (CurrentTemporaryLimitCreationInfos limit : currentLimitsInfos.getTemporaryLimits()) { | ||
limitsAdder | ||
.beginTemporaryLimit() | ||
.setName(limit.getName()) | ||
.setValue(limit.getValue() == null ? Double.MAX_VALUE : limit.getValue()) | ||
.setAcceptableDuration(limit.getAcceptableDuration() == null ? Integer.MAX_VALUE : limit.getAcceptableDuration()) | ||
.endTemporaryLimit(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can suggest here to use the functional approach (with forEach)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK done. And it reduces cognitive complexity. Nice. |
||
} | ||
} | ||
if (hasPermanent || hasTemporary) { | ||
limitsAdder.add(); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private String selectedOperationalLimitsGroup1;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK done.