|
8 | 8 |
|
9 | 9 | import com.powsybl.openrao.data.cracapi.*; |
10 | 10 | import com.powsybl.openrao.data.cracapi.cnec.Cnec; |
11 | | -import com.powsybl.openrao.data.cracapi.cnec.FlowCnec; |
12 | | -import com.powsybl.openrao.data.cracapi.cnec.VoltageCnec; |
13 | 11 | import com.powsybl.openrao.data.cracapi.networkaction.*; |
14 | 12 | import com.powsybl.openrao.data.cracapi.usagerule.*; |
15 | 13 | import com.powsybl.openrao.data.craccreation.creator.api.ImportStatus; |
@@ -117,25 +115,11 @@ private boolean addOnConstraintUsageRules(String remedialActionId, Set<AssessedE |
117 | 115 | Cnec<?> cnec = crac.getCnec(cnecId); |
118 | 116 | UsageMethod usageMethod = getUsageMethod(cnecStatus.elementCombinationConstraintKind(), isSchemeRemedialAction, instant, remedialActionType); |
119 | 117 | if (isOnConstraintInstantCoherent(cnec.getState().getInstant(), instant)) { |
120 | | - if (cnec instanceof FlowCnec) { |
121 | | - remedialActionAdder.newOnFlowConstraintUsageRule() |
122 | | - .withInstant(instant.getId()) |
123 | | - .withFlowCnec(cnecId) |
124 | | - .withUsageMethod(usageMethod) |
125 | | - .add(); |
126 | | - } else if (cnec instanceof VoltageCnec) { |
127 | | - remedialActionAdder.newOnVoltageConstraintUsageRule() |
128 | | - .withInstant(instant.getId()) |
129 | | - .withVoltageCnec(cnecId) |
130 | | - .withUsageMethod(usageMethod) |
131 | | - .add(); |
132 | | - } else { |
133 | | - remedialActionAdder.newOnAngleConstraintUsageRule() |
134 | | - .withInstant(instant.getId()) |
135 | | - .withAngleCnec(cnecId) |
136 | | - .withUsageMethod(usageMethod) |
137 | | - .add(); |
138 | | - } |
| 118 | + remedialActionAdder.newOnConstraintUsageRule() |
| 119 | + .withInstant(instant.getId()) |
| 120 | + .withCnec(cnecId) |
| 121 | + .withUsageMethod(usageMethod) |
| 122 | + .add(); |
139 | 123 | } |
140 | 124 | } else { |
141 | 125 | alterations.add(cnecStatus.statusDetails()); |
@@ -259,9 +243,7 @@ private Set<String> createRemedialActionGroups() { |
259 | 243 | standaloneRasImplicatedIntoAGroup.addAll(dependingEnabledRemedialActions.stream().map(RemedialActionDependency::remedialAction).collect(Collectors.toSet())); |
260 | 244 | throw new OpenRaoImportException(ImportStatus.INCONSISTENCY_IN_DATA, "Remedial action group " + remedialActionGroup.mrid() + " will not be imported because the remedial action " + refRemedialActionDependency.remedialAction() + " does not exist or not imported. All RA's depending in that group will be ignored: " + printRaIds(dependingEnabledRemedialActions)); |
261 | 245 | } |
262 | | - List<UsageRule> onAngleConstraintUsageRules = refNetworkAction.getUsageRules().stream().filter(OnAngleConstraint.class::isInstance).toList(); |
263 | | - List<UsageRule> onFlowConstraintUsageRules = refNetworkAction.getUsageRules().stream().filter(OnFlowConstraint.class::isInstance).toList(); |
264 | | - List<UsageRule> onVoltageConstraintUsageRules = refNetworkAction.getUsageRules().stream().filter(OnVoltageConstraint.class::isInstance).toList(); |
| 246 | + List<UsageRule> onConstraintUsageRules = refNetworkAction.getUsageRules().stream().filter(OnConstraint.class::isInstance).toList(); |
265 | 247 | List<UsageRule> onContingencyStateUsageRules = refNetworkAction.getUsageRules().stream().filter(OnContingencyState.class::isInstance).toList(); |
266 | 248 | List<UsageRule> onInstantUsageRules = refNetworkAction.getUsageRules().stream().filter(OnInstant.class::isInstance).toList(); |
267 | 249 |
|
@@ -289,7 +271,7 @@ private Set<String> createRemedialActionGroups() { |
289 | 271 | if (operators.size() == 1) { |
290 | 272 | networkActionAdder.withOperator(operators.iterator().next()); |
291 | 273 | } |
292 | | - addUsageRulesToGroup(onAngleConstraintUsageRules, onFlowConstraintUsageRules, onVoltageConstraintUsageRules, onContingencyStateUsageRules, onInstantUsageRules, injectionSetpoints, pstSetPoints, topologicalActions, networkActionAdder); |
| 274 | + addUsageRulesToGroup(onConstraintUsageRules, onContingencyStateUsageRules, onInstantUsageRules, injectionSetpoints, pstSetPoints, topologicalActions, networkActionAdder); |
293 | 275 | addElementaryActionsToGroup(injectionSetpoints, pstSetPoints, topologicalActions, networkActionAdder); |
294 | 276 | networkActionAdder.add(); |
295 | 277 | contextByRaId.put(remedialActionGroup.mrid(), CsaProfileElementaryCreationContext.imported(remedialActionGroup.mrid(), remedialActionGroup.mrid(), groupName, "The RemedialActionGroup with mRID " + remedialActionGroup.mrid() + " was turned into a remedial action from the following remedial actions: " + printRaIds(dependingEnabledRemedialActions), true)); |
@@ -328,29 +310,13 @@ private static void addElementaryActionsToGroup(List<ElementaryAction> injection |
328 | 310 | }); |
329 | 311 | } |
330 | 312 |
|
331 | | - private static void addUsageRulesToGroup(List<UsageRule> onAngleConstraintUsageRules, List<UsageRule> onFlowConstraintUsageRules, List<UsageRule> onVoltageConstraintUsageRules, List<UsageRule> onContingencyStateUsageRules, List<UsageRule> onInstantUsageRules, List<ElementaryAction> injectionSetpoints, List<ElementaryAction> pstSetPoints, List<ElementaryAction> topologicalActions, NetworkActionAdder networkActionAdder) { |
332 | | - onAngleConstraintUsageRules.forEach(ur -> { |
333 | | - OnAngleConstraint onAngleConstraintUsageRule = (OnAngleConstraint) ur; |
334 | | - networkActionAdder.newOnAngleConstraintUsageRule() |
335 | | - .withInstant(onAngleConstraintUsageRule.getInstant().getId()) |
336 | | - .withUsageMethod(onAngleConstraintUsageRule.getUsageMethod()) |
337 | | - .withAngleCnec(onAngleConstraintUsageRule.getAngleCnec().getId()) |
338 | | - .add(); |
339 | | - }); |
340 | | - onFlowConstraintUsageRules.forEach(ur -> { |
341 | | - OnFlowConstraint onFlowConstraintUsageRule = (OnFlowConstraint) ur; |
342 | | - networkActionAdder.newOnFlowConstraintUsageRule() |
343 | | - .withInstant(onFlowConstraintUsageRule.getInstant().getId()) |
344 | | - .withUsageMethod(onFlowConstraintUsageRule.getUsageMethod()) |
345 | | - .withFlowCnec(onFlowConstraintUsageRule.getFlowCnec().getId()) |
346 | | - .add(); |
347 | | - }); |
348 | | - onVoltageConstraintUsageRules.forEach(ur -> { |
349 | | - OnVoltageConstraint onVoltageConstraintUsageRule = (OnVoltageConstraint) ur; |
350 | | - networkActionAdder.newOnVoltageConstraintUsageRule() |
351 | | - .withInstant(onVoltageConstraintUsageRule.getInstant().getId()) |
352 | | - .withUsageMethod(onVoltageConstraintUsageRule.getUsageMethod()) |
353 | | - .withVoltageCnec(onVoltageConstraintUsageRule.getVoltageCnec().getId()) |
| 313 | + private static void addUsageRulesToGroup(List<UsageRule> onConstraintUsageRules, List<UsageRule> onContingencyStateUsageRules, List<UsageRule> onInstantUsageRules, List<ElementaryAction> injectionSetpoints, List<ElementaryAction> pstSetPoints, List<ElementaryAction> topologicalActions, NetworkActionAdder networkActionAdder) { |
| 314 | + onConstraintUsageRules.forEach(ur -> { |
| 315 | + OnConstraint<?> onConstraintUsageRule = (OnConstraint<?>) ur; |
| 316 | + networkActionAdder.newOnConstraintUsageRule() |
| 317 | + .withInstant(onConstraintUsageRule.getInstant().getId()) |
| 318 | + .withUsageMethod(onConstraintUsageRule.getUsageMethod()) |
| 319 | + .withCnec(onConstraintUsageRule.getCnec().getId()) |
354 | 320 | .add(); |
355 | 321 | }); |
356 | 322 | onContingencyStateUsageRules.forEach(ur -> { |
|
0 commit comments