2020import java .util .List ;
2121import java .util .Optional ;
2222
23+ import static com .powsybl .iidm .network .TwoSides .ONE ;
24+ import static com .powsybl .iidm .network .TwoSides .TWO ;
2325import static org .gridsuite .modification .NetworkModificationException .Type .*;
2426import static org .gridsuite .modification .dto .OperationalLimitsGroupInfos .Applicability .SIDE1 ;
2527import static org .gridsuite .modification .dto .OperationalLimitsGroupInfos .Applicability .SIDE2 ;
@@ -239,38 +241,6 @@ private void create2WTInOtherBreaker(Network network, VoltageLevel voltageLevel1
239241 completeTwoWindingsTransformerCreation (network , twoWindingsTransformer , modificationInfos , subReportNode );
240242 }
241243
242- private void setCurrentLimitsForSide (ReportNode reportNode , List <OperationalLimitsGroupInfos > operationalLimitsGroups , String selectedGroup , TwoWindingsTransformer transformer , TwoSides side ,
243- List <ReportNode > limitSetsOnSideReportNodes ) {
244- if (!CollectionUtils .isEmpty (operationalLimitsGroups )) {
245- getInstance ().setCurrentLimitsOnASide (reportNode , operationalLimitsGroups , transformer , side );
246- }
247- if (selectedGroup != null ) {
248- if (!ModificationUtils .hasLimitSet (operationalLimitsGroups , selectedGroup )) {
249- limitSetsOnSideReportNodes .add (ReportNode .newRootReportNode ()
250- .withMessageTemplate ("network.modification.limitSetAbsentOnSide" + side .getNum ())
251- .withUntypedValue ("selectedOperationalLimitsGroup" , selectedGroup )
252- .withSeverity (TypedValue .WARN_SEVERITY )
253- .build ());
254- return ;
255- }
256-
257- if (side == TwoSides .ONE ) {
258- transformer .setSelectedOperationalLimitsGroup1 (selectedGroup );
259- limitSetsOnSideReportNodes .add (ReportNode .newRootReportNode ().withMessageTemplate ("network.modification.limitSetSelectedOnSide1" )
260- .withUntypedValue ("selectedOperationalLimitsGroup1" , modificationInfos .getSelectedOperationalLimitsGroup1 ())
261- .withSeverity (TypedValue .INFO_SEVERITY )
262- .build ());
263- }
264- if (side == TwoSides .TWO ) {
265- transformer .setSelectedOperationalLimitsGroup2 (selectedGroup );
266- limitSetsOnSideReportNodes .add (ReportNode .newRootReportNode ().withMessageTemplate ("network.modification.limitSetSelectedOnSide2" )
267- .withUntypedValue ("selectedOperationalLimitsGroup2" , modificationInfos .getSelectedOperationalLimitsGroup2 ())
268- .withSeverity (TypedValue .INFO_SEVERITY )
269- .build ());
270- }
271- }
272- }
273-
274244 private void completeTwoWindingsTransformerCreation (Network network ,
275245 TwoWindingsTransformer twoWindingsTransformer ,
276246 TwoWindingsTransformerCreationInfos modificationInfos ,
@@ -290,12 +260,61 @@ private void completeTwoWindingsTransformerCreation(Network network,
290260 List <OperationalLimitsGroupInfos > operationalLimitsGroups2 = ModificationUtils .getOperationalLimitsGroupsOnSide (modificationInfos .getOperationalLimitsGroups (), SIDE2 );
291261
292262 List <ReportNode > limitSetsOnSideReportNodes = new ArrayList <>();
293- ReportNode reportNode = limitsReporter .newReportNode ()
294- .withSeverity (TypedValue .INFO_SEVERITY )
295- .withMessageTemplate ("network.modification.LimitSets" )
296- .add ();
297- setCurrentLimitsForSide (reportNode , operationalLimitsGroups1 , modificationInfos .getSelectedOperationalLimitsGroup1 (), twoWindingsTransformer , TwoSides .ONE , limitSetsOnSideReportNodes );
298- setCurrentLimitsForSide (reportNode , operationalLimitsGroups2 , modificationInfos .getSelectedOperationalLimitsGroup2 (), twoWindingsTransformer , TwoSides .TWO , limitSetsOnSideReportNodes );
263+ if (!CollectionUtils .isEmpty (modificationInfos .getOperationalLimitsGroups ())) {
264+ ReportNode reportNode = limitsReporter .newReportNode ()
265+ .withSeverity (TypedValue .INFO_SEVERITY )
266+ .withMessageTemplate ("network.modification.LimitSets" )
267+ .add ();
268+
269+ for (OperationalLimitsGroupInfos olgInfos : modificationInfos .getOperationalLimitsGroups ()) {
270+ ReportNode limitSetNode = reportNode .newReportNode ()
271+ .withMessageTemplate ("network.modification.limitSetAdded" )
272+ .withUntypedValue ("name" , olgInfos .getId ())
273+ .withSeverity (TypedValue .INFO_SEVERITY )
274+ .add ();
275+
276+ if (olgInfos .getApplicability () == OperationalLimitsGroupInfos .Applicability .SIDE1 || olgInfos .getApplicability () == OperationalLimitsGroupInfos .Applicability .EQUIPMENT ) {
277+ ModificationUtils .getInstance ().setCurrentLimitsOnASide (limitSetNode , olgInfos , twoWindingsTransformer , ONE );
278+ }
279+ if (olgInfos .getApplicability () == OperationalLimitsGroupInfos .Applicability .SIDE2 || olgInfos .getApplicability () == OperationalLimitsGroupInfos .Applicability .EQUIPMENT ) {
280+ ModificationUtils .getInstance ().setCurrentLimitsOnASide (limitSetNode , olgInfos , twoWindingsTransformer , TWO );
281+ }
282+ }
283+ }
284+
285+ if (modificationInfos .getSelectedOperationalLimitsGroup1 () != null ) {
286+ if (!ModificationUtils .hasLimitSet (operationalLimitsGroups1 , modificationInfos .getSelectedOperationalLimitsGroup1 ())) {
287+ limitSetsOnSideReportNodes .add (ReportNode .newRootReportNode ()
288+ .withMessageTemplate ("network.modification.limitSetAbsentOnSide1" )
289+ .withUntypedValue ("selectedOperationalLimitsGroup" , modificationInfos .getSelectedOperationalLimitsGroup1 ())
290+ .withSeverity (TypedValue .WARN_SEVERITY )
291+ .build ());
292+ } else {
293+ twoWindingsTransformer .setSelectedOperationalLimitsGroup1 (modificationInfos .getSelectedOperationalLimitsGroup1 ());
294+ limitSetsOnSideReportNodes .add (ReportNode .newRootReportNode ()
295+ .withMessageTemplate ("network.modification.limitSetSelectedOnSide1" )
296+ .withUntypedValue ("selectedOperationalLimitsGroup1" , modificationInfos .getSelectedOperationalLimitsGroup1 ())
297+ .withSeverity (TypedValue .INFO_SEVERITY )
298+ .build ());
299+ }
300+ }
301+ if (modificationInfos .getSelectedOperationalLimitsGroup2 () != null ) {
302+ if (!ModificationUtils .hasLimitSet (operationalLimitsGroups2 , modificationInfos .getSelectedOperationalLimitsGroup2 ())) {
303+ limitSetsOnSideReportNodes .add (ReportNode .newRootReportNode ()
304+ .withMessageTemplate ("network.modification.limitSetAbsentOnSide2" )
305+ .withUntypedValue ("selectedOperationalLimitsGroup" , modificationInfos .getSelectedOperationalLimitsGroup2 ())
306+ .withSeverity (TypedValue .WARN_SEVERITY )
307+ .build ());
308+ } else {
309+ twoWindingsTransformer .setSelectedOperationalLimitsGroup2 (modificationInfos .getSelectedOperationalLimitsGroup2 ());
310+ limitSetsOnSideReportNodes .add (ReportNode .newRootReportNode ()
311+ .withMessageTemplate ("network.modification.limitSetSelectedOnSide2" )
312+ .withUntypedValue ("selectedOperationalLimitsGroup2" , modificationInfos .getSelectedOperationalLimitsGroup2 ())
313+ .withSeverity (TypedValue .INFO_SEVERITY )
314+ .build ());
315+ }
316+ }
317+
299318 if (!limitSetsOnSideReportNodes .isEmpty ()) {
300319 ModificationUtils .getInstance ().reportModifications (limitsReporter , limitSetsOnSideReportNodes ,
301320 "network.modification.ActiveLimitSets" );
0 commit comments