Skip to content

Commit eb0d524

Browse files
authored
Merge branch 'main' into dgs_import_bom_issue
2 parents 0115efe + a860186 commit eb0d524

File tree

18 files changed

+780
-109
lines changed

18 files changed

+780
-109
lines changed

action-ial/action-ial-simulator/src/test/java/com/powsybl/action/ial/simulator/tools/SecurityAnalysisResultBuilderTest.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,27 @@ private Contingency createContingency() {
3434
}
3535

3636
private List<LimitViolation> createPreContingencyViolations() {
37-
return Collections.singletonList(new LimitViolation("line1", LimitViolationType.CURRENT, "IST", Integer.MAX_VALUE, 0.0, 100f, 101, TwoSides.ONE));
37+
return Collections.singletonList(LimitViolation.builder()
38+
.subject("line1")
39+
.type(LimitViolationType.CURRENT)
40+
.limitName("IST")
41+
.limit(0.0)
42+
.reduction(100f)
43+
.value(101)
44+
.side(TwoSides.ONE)
45+
.build());
3846
}
3947

4048
private List<LimitViolation> createPostContingencyViolations() {
41-
return Collections.singletonList(new LimitViolation("line2", LimitViolationType.CURRENT, "IST", Integer.MAX_VALUE, 0.0, 100f, 110, TwoSides.ONE));
49+
return Collections.singletonList(LimitViolation.builder()
50+
.subject("line2")
51+
.type(LimitViolationType.CURRENT)
52+
.limitName("IST")
53+
.limit(0.0)
54+
.reduction(100f)
55+
.value(110)
56+
.side(TwoSides.ONE)
57+
.build());
4258
}
4359

4460
private void testLimitViolation(LimitViolationsResult result, boolean convergent, List<String> equipmentsId, List<String> actionsId) {

contingency/contingency-api/src/main/java/com/powsybl/contingency/violations/LimitViolation.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public class LimitViolation extends AbstractExtendable<LimitViolation> {
6060
* @param limitReduction The limit reduction factor used for violation detection.
6161
* @param value The actual value of the physical value which triggered the detection of a violation.
6262
* @param side The side of the equipment where the violation occurred. May be {@code null} for non-branch, non-three windings transformer equipments.
63+
* @param voltageLocation Detailed information about the location of the violation.
6364
*/
6465
public LimitViolation(String subjectId, @Nullable String subjectName, String operationalLimitsGroupId, LimitViolationType limitType, @Nullable String limitName, int acceptableDuration,
6566
double limit, double limitReduction, double value, @Nullable ThreeSides side, @Nullable ViolationLocation voltageLocation) {
@@ -90,7 +91,9 @@ public LimitViolation(String subjectId, @Nullable String subjectName, String ope
9091
* @param limitReduction The limit reduction factor used for violation detection.
9192
* @param value The actual value of the physical value which triggered the detection of a violation.
9293
* @param side The side of the equipment where the violation occurred. May be {@code null} for non-branch, non-three windings transformer equipments.
94+
* @deprecated use {@link LimitViolationBuilder} or {@link LimitViolation#LimitViolation(String, String, String, LimitViolationType, String, int, double, double, double, ThreeSides, ViolationLocation)}
9395
*/
96+
@Deprecated(since = "7.3.0", forRemoval = true)
9497
public LimitViolation(String subjectId, @Nullable String subjectName, LimitViolationType limitType, @Nullable String limitName, int acceptableDuration,
9598
double limit, double limitReduction, double value, @Nullable ThreeSides side, @Nullable ViolationLocation voltageLocation) {
9699
this(subjectId, subjectName, "", limitType, limitName, acceptableDuration, limit, limitReduction, value, side, voltageLocation);
@@ -110,7 +113,9 @@ public LimitViolation(String subjectId, @Nullable String subjectName, LimitViola
110113
* @param limitReduction The limit reduction factor used for violation detection.
111114
* @param value The actual value of the physical value which triggered the detection of a violation.
112115
* @param side The side of the equipment where the violation occurred. May be {@code null} for non-branch, non-three windings transformer equipments.
116+
* @deprecated use {@link LimitViolationBuilder} or {@link LimitViolation#LimitViolation(String, String, String, LimitViolationType, String, int, double, double, double, ThreeSides, ViolationLocation)}
113117
*/
118+
@Deprecated(since = "7.3.0", forRemoval = true)
114119
public LimitViolation(String subjectId, @Nullable String subjectName, LimitViolationType limitType, @Nullable String limitName, int acceptableDuration,
115120
double limit, double limitReduction, double value, @Nullable ThreeSides side) {
116121
this(subjectId, subjectName, limitType, limitName, acceptableDuration, limit, limitReduction, value, side, null);
@@ -129,7 +134,9 @@ public LimitViolation(String subjectId, @Nullable String subjectName, LimitViola
129134
* @param limit The value of the limit which has been violated.
130135
* @param limitReduction The limit reduction factor used for violation detection.
131136
* @param value The actual value of the physical value which triggered the detection of a violation.
137+
* @deprecated use {@link LimitViolationBuilder} or {@link LimitViolation#LimitViolation(String, String, String, LimitViolationType, String, int, double, double, double, ThreeSides, ViolationLocation)}
132138
*/
139+
@Deprecated(since = "7.3.0", forRemoval = true)
133140
public LimitViolation(String subjectId, @Nullable String subjectName, LimitViolationType limitType, @Nullable String limitName, int acceptableDuration,
134141
double limit, double limitReduction, double value) {
135142
this(subjectId, subjectName, limitType, limitName, acceptableDuration, limit, limitReduction, value, (ThreeSides) null);
@@ -150,7 +157,9 @@ public LimitViolation(String subjectId, @Nullable String subjectName, LimitViola
150157
* @param limitReduction The limit reduction factor used for violation detection.
151158
* @param value The actual value of the physical value which triggered the detection of a violation.
152159
* @param side The side of the equipment where the violation occurred. May be {@code null} for non-branch, non-three windings transformer equipments.
160+
* @deprecated use {@link LimitViolationBuilder} or {@link LimitViolation#LimitViolation(String, String, String, LimitViolationType, String, int, double, double, double, ThreeSides, ViolationLocation)}
153161
*/
162+
@Deprecated(since = "7.3.0", forRemoval = true)
154163
public LimitViolation(String subjectId, @Nullable String subjectName, LimitViolationType limitType, @Nullable String limitName, int acceptableDuration,
155164
double limit, double limitReduction, double value, TwoSides side) {
156165
this(subjectId, subjectName, limitType, limitName, acceptableDuration, limit, limitReduction, value, Objects.requireNonNull(side).toThreeSides());
@@ -169,7 +178,9 @@ public LimitViolation(String subjectId, @Nullable String subjectName, LimitViola
169178
* @param limitReduction The limit reduction factor used for violation detection.
170179
* @param value The actual value of the physical value which triggered the detection of a violation.
171180
* @param side The side of the equipment where the violation occurred. May be {@code null} for non-branch, non-three windings transformer equipments.
181+
* @deprecated use {@link LimitViolationBuilder} or {@link LimitViolation#LimitViolation(String, String, String, LimitViolationType, String, int, double, double, double, ThreeSides, ViolationLocation)}
172182
*/
183+
@Deprecated(since = "7.3.0", forRemoval = true)
173184
public LimitViolation(String subjectId, LimitViolationType limitType, String limitName, int acceptableDuration,
174185
double limit, double limitReduction, double value, TwoSides side) {
175186
this(subjectId, null, limitType, limitName, acceptableDuration, limit, limitReduction, value, Objects.requireNonNull(side).toThreeSides());
@@ -187,7 +198,9 @@ public LimitViolation(String subjectId, LimitViolationType limitType, String lim
187198
* @param limit The value of the limit which has been violated.
188199
* @param limitReduction The limit reduction factor used for violation detection.
189200
* @param value The actual value of the physical value which triggered the detection of a violation.
201+
* @deprecated use {@link LimitViolationBuilder} or {@link LimitViolation#LimitViolation(String, String, String, LimitViolationType, String, int, double, double, double, ThreeSides, ViolationLocation)}
190202
*/
203+
@Deprecated(since = "7.3.0", forRemoval = true)
191204
public LimitViolation(String subjectId, LimitViolationType limitType, String limitName, int acceptableDuration,
192205
double limit, double limitReduction, double value) {
193206
this(subjectId, null, limitType, limitName, acceptableDuration, limit, limitReduction, value, (ThreeSides) null);
@@ -206,7 +219,7 @@ public LimitViolation(String subjectId, LimitViolationType limitType, String lim
206219
* @param voltageLocation Detailed information about the location of the violation.
207220
*/
208221
public LimitViolation(String subjectId, LimitViolationType limitType, double limit, double limitReduction, double value, ViolationLocation voltageLocation) {
209-
this(subjectId, null, limitType, null, Integer.MAX_VALUE, limit, limitReduction, value, null, voltageLocation);
222+
this(subjectId, null, null, limitType, null, Integer.MAX_VALUE, limit, limitReduction, value, null, voltageLocation);
210223
}
211224

212225
/**
@@ -220,7 +233,9 @@ public LimitViolation(String subjectId, LimitViolationType limitType, double lim
220233
* @param limit The value of the limit which has been violated.
221234
* @param limitReduction The limit reduction factor used for violation detection.
222235
* @param value The actual value of the physical value which triggered the detection of a violation.
236+
* @deprecated use {@link LimitViolationBuilder} or {@link LimitViolation#LimitViolation(String, String, String, LimitViolationType, String, int, double, double, double, ThreeSides, ViolationLocation)}
223237
*/
238+
@Deprecated(since = "7.3.0", forRemoval = true)
224239
public LimitViolation(String subjectId, String subjectName, LimitViolationType limitType, double limit, double limitReduction, double value) {
225240
this(subjectId, subjectName, limitType, null, Integer.MAX_VALUE, limit, limitReduction, value, null, null);
226241
}
@@ -237,7 +252,9 @@ public LimitViolation(String subjectId, String subjectName, LimitViolationType l
237252
* @param limitReduction The limit reduction factor used for violation detection.
238253
* @param value The actual value of the physical value which triggered the detection of a violation.
239254
* @param voltageLocation Detailed information about the location of the violation.
255+
* @deprecated use {@link LimitViolationBuilder} or {@link LimitViolation#LimitViolation(String, String, String, LimitViolationType, String, int, double, double, double, ThreeSides, ViolationLocation)}
240256
*/
257+
@Deprecated(since = "7.3.0", forRemoval = true)
241258
public LimitViolation(String subjectId, String subjectName, LimitViolationType limitType, double limit, double limitReduction, double value, ViolationLocation voltageLocation) {
242259
this(subjectId, subjectName, limitType, null, Integer.MAX_VALUE, limit, limitReduction, value, null, voltageLocation);
243260
}
@@ -252,11 +269,17 @@ public LimitViolation(String subjectId, String subjectName, LimitViolationType l
252269
* @param limit The value of the limit which has been violated.
253270
* @param limitReduction The limit reduction factor used for violation detection.
254271
* @param value The actual value of the physical value which triggered the detection of a violation.
272+
* @deprecated use {@link LimitViolationBuilder} or {@link LimitViolation#LimitViolation(String, String, String, LimitViolationType, String, int, double, double, double, ThreeSides, ViolationLocation)}
255273
*/
274+
@Deprecated(since = "7.3.0", forRemoval = true)
256275
public LimitViolation(String subjectId, LimitViolationType limitType, double limit, double limitReduction, double value) {
257276
this(subjectId, null, limitType, null, Integer.MAX_VALUE, limit, limitReduction, value, null, null);
258277
}
259278

279+
public static LimitViolationBuilder builder() {
280+
return new LimitViolationBuilder();
281+
}
282+
260283
/**
261284
* The identifier of the network equipment on which the violation occurred.
262285
*

contingency/contingency-api/src/main/java/com/powsybl/contingency/violations/LimitViolationBuilder.java

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
package com.powsybl.contingency.violations;
99

10+
import com.powsybl.iidm.network.OperationalLimitsGroup;
1011
import com.powsybl.iidm.network.ThreeSides;
1112
import com.powsybl.iidm.network.TwoSides;
1213

@@ -27,84 +28,159 @@ public class LimitViolationBuilder {
2728
private LimitViolationType type;
2829
private Double limit;
2930
private String limitName;
30-
private Integer duration;
31+
private Integer duration = Integer.MAX_VALUE;
3132
private double reduction = 1.0;
3233
private Double value;
3334
private ThreeSides side;
3435
private ViolationLocation violationLocation;
3536

37+
/**
38+
* @param type The type of limit which has been violated.
39+
* @return this {@link LimitViolationBuilder}
40+
*/
3641
public LimitViolationBuilder type(LimitViolationType type) {
3742
this.type = requireNonNull(type);
3843
return this;
3944
}
4045

46+
/**
47+
* @param subjectId The identifier of the network equipment on which the violation occurred.
48+
* @return this {@link LimitViolationBuilder}
49+
*/
4150
public LimitViolationBuilder subject(String subjectId) {
4251
this.subjectId = requireNonNull(subjectId);
4352
return this;
4453
}
4554

55+
/**
56+
* @param subjectName An optional name of the network equipment on which the violation occurred.
57+
* @return this {@link LimitViolationBuilder}
58+
*/
4659
public LimitViolationBuilder subjectName(String subjectName) {
4760
this.subjectName = subjectName;
4861
return this;
4962
}
5063

64+
/**
65+
* @param id The {@link OperationalLimitsGroup} due to which this violation occurred.
66+
* @return this {@link LimitViolationBuilder}
67+
*/
5168
public LimitViolationBuilder operationalLimitsGroupId(String id) {
5269
this.operationalLimitsGroupId = id;
5370
return this;
5471
}
5572

73+
/**
74+
* @param location Detailed information about the location of the violation.
75+
* @return this {@link LimitViolationBuilder}
76+
*/
5677
public LimitViolationBuilder violationLocation(ViolationLocation location) {
5778
this.violationLocation = location;
5879
return this;
5980
}
6081

82+
/**
83+
* @param name An optional name for the limit which has been violated.
84+
* @return this {@link LimitViolationBuilder}
85+
*/
6186
public LimitViolationBuilder limitName(String name) {
6287
this.limitName = name;
6388
return this;
6489
}
6590

91+
/**
92+
* @param duration The acceptable duration, in seconds, associated to the violation value.
93+
* Default is {@link Integer#MAX_VALUE}.
94+
* @return this {@link LimitViolationBuilder}
95+
*/
6696
public LimitViolationBuilder duration(int duration) {
6797
this.duration = duration;
6898
return this;
6999
}
70100

101+
/**
102+
* @param duration The acceptable duration, in <code>unit</code> of time, associated to the violation value.
103+
* @param unit the time unit to be used.
104+
* @return this {@link LimitViolationBuilder}
105+
*/
71106
public LimitViolationBuilder duration(int duration, TimeUnit unit) {
72107
this.duration = (int) unit.toSeconds(duration);
73108
return this;
74109
}
75110

111+
/**
112+
* @param limit The value of the limit which has been violated.
113+
* @return this {@link LimitViolationBuilder}
114+
*/
76115
public LimitViolationBuilder limit(double limit) {
77116
this.limit = limit;
78117
return this;
79118
}
80119

120+
/**
121+
* @param value The actual value of the physical value which triggered the detection of a violation.
122+
* @return this {@link LimitViolationBuilder}
123+
*/
81124
public LimitViolationBuilder value(double value) {
82125
this.value = value;
83126
return this;
84127
}
85128

129+
/**
130+
* @param reduction The limit reduction factor used for violation detection.
131+
* Default is 1.
132+
* @return this {@link LimitViolationBuilder}
133+
*/
86134
public LimitViolationBuilder reduction(double reduction) {
87135
this.reduction = reduction;
88136
return this;
89137
}
90138

139+
/**
140+
* @param side The side of the equipment where the violation occurred. May be {@code null} for non-branch, non-three windings transformer equipments.
141+
* @return this {@link LimitViolationBuilder}
142+
*/
91143
public LimitViolationBuilder side(ThreeSides side) {
92144
this.side = requireNonNull(side);
93145
return this;
94146
}
95147

148+
/**
149+
* @param side side The side of the equipment where the violation occurred. May be {@code null} for non-branch, non-three windings transformer equipments.
150+
* @return this {@link LimitViolationBuilder}
151+
*/
96152
public LimitViolationBuilder side(TwoSides side) {
97153
return side(requireNonNull(side).toThreeSides());
98154
}
99155

156+
/**
157+
* Sets the side as {@link ThreeSides#ONE}.
158+
* @return this {@link LimitViolationBuilder}
159+
*/
100160
public LimitViolationBuilder side1() {
101161
return side(TwoSides.ONE);
102162
}
103163

164+
/**
165+
* Sets the side as {@link ThreeSides#TWO}.
166+
* @return this {@link LimitViolationBuilder}
167+
*/
104168
public LimitViolationBuilder side2() {
105169
return side(TwoSides.TWO);
106170
}
107171

172+
/**
173+
* Sets the side as {@link ThreeSides#THREE}.
174+
* @return this {@link LimitViolationBuilder}
175+
*/
176+
public LimitViolationBuilder side3() {
177+
return side(ThreeSides.THREE);
178+
}
179+
180+
/**
181+
* Sets the violation type as {@link LimitViolationType#CURRENT}.
182+
* @return this {@link LimitViolationBuilder}
183+
*/
108184
public LimitViolationBuilder current() {
109185
return type(LimitViolationType.CURRENT);
110186
}

0 commit comments

Comments
 (0)