-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[68][164] Activation used LDevice and Deactivation unused LDevice
Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com> Signed-off-by: Samir Romdhani <samir.romdhani@rte-france.com>
- Loading branch information
1 parent
b527d99
commit 090141f
Showing
63 changed files
with
3,144 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SclReport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* // SPDX-FileCopyrightText: 2022 RTE FRANCE | ||
* // | ||
* // SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.lfenergy.compas.sct.commons.dto; | ||
|
||
import lombok.*; | ||
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Setter | ||
@Getter | ||
@Builder | ||
public class SclReport { | ||
|
||
private SclRootAdapter scdFile; | ||
|
||
private List<ErrorDescription> errorDescriptionList = new ArrayList<>(); | ||
|
||
public boolean isSuccess() { | ||
return errorDescriptionList.isEmpty(); | ||
} | ||
|
||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@ToString | ||
@EqualsAndHashCode | ||
@Builder | ||
public static class ErrorDescription{ | ||
private String xpath; | ||
private String message; | ||
} | ||
} |
132 changes: 132 additions & 0 deletions
132
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/LDeviceActivation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
// SPDX-FileCopyrightText: 2022 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons.scl; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
import org.lfenergy.compas.scl2007b4.model.TCompasLDeviceStatus; | ||
import org.lfenergy.compas.sct.commons.dto.ResumedDataTemplate; | ||
import org.lfenergy.compas.sct.commons.util.STValEnum; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
/** | ||
* Common class for all states that define if LDevice should be activated or not | ||
* regardless of the CompasLDeviceStatus Private, Enum Values of DO 'Beh' and if it's referenced in Substation...LNode or not | ||
*/ | ||
@Getter | ||
@Setter | ||
public class LDeviceActivation { | ||
|
||
private final List<Pair<String, String>> iedNameLdInstList; | ||
|
||
private TCompasLDeviceStatus compasLDeviceStatus; | ||
private boolean isUpdatable; | ||
private ResumedDataTemplate resumedDataTemplate; | ||
private List<String> errorMessages = new ArrayList<>(); | ||
|
||
public LDeviceActivation(List<Pair<String, String>> iedNameLdInstList) { | ||
this.iedNameLdInstList = iedNameLdInstList; | ||
} | ||
|
||
/** | ||
* checks whether LDevice status is authorized to be activated or Not | ||
* @param iedName Ied name value which LDevice appear | ||
* @param ldInst LDevice inst value | ||
* @param compasLDeviceStatus Private value | ||
* @param enumValues enum values | ||
*/ | ||
public void checkLDeviceActivationStatus(String iedName, String ldInst, TCompasLDeviceStatus compasLDeviceStatus, Set<String> enumValues) { | ||
if (!enumValues.contains(STValEnum.ON.value) && !enumValues.contains(STValEnum.OFF.value)) { | ||
errorMessages.add(String.format("Unexpected error: The IED@%s/LDevice@%s cannot be activated or desactivated because its BehaviourKind Enum contains NOT 'on' AND NOT 'off'.", | ||
iedName, ldInst)); | ||
} | ||
if (!enumValues.contains(STValEnum.ON.value) && enumValues.contains(STValEnum.OFF.value)) { | ||
if (isAuthorized(iedName, ldInst)) { | ||
errorMessages.add(String.format("Unexpected error: The IED@%s/LDevice@%s cannot be set to 'on' but has been selected into SSD: this case should not occur.", | ||
iedName, ldInst)); | ||
} else { | ||
isUpdatable = true; | ||
resumedDataTemplate.setNewVal(STValEnum.OFF.value); | ||
} | ||
} | ||
if(compasLDeviceStatus.equals(TCompasLDeviceStatus.ACTIVE) || | ||
compasLDeviceStatus.equals(TCompasLDeviceStatus.UNTESTED)){ | ||
isAuthorizedToActivateLDevice(iedName, ldInst, enumValues); | ||
} | ||
if(compasLDeviceStatus.equals(TCompasLDeviceStatus.INACTIVE)){ | ||
isAuthorizedToDeactivateLDevice(iedName, ldInst, enumValues); | ||
} | ||
} | ||
|
||
/** | ||
* checks whether LDevice status is authorized to be activated when CompasLDeviceStatus Private is ACTIVE or UNTESTED | ||
* @param iedName Ied name value which contains LDevice | ||
* @param ldInst LDevice inst value | ||
* @param enumValues enum values | ||
*/ | ||
private void isAuthorizedToActivateLDevice(String iedName, String ldInst, Set<String> enumValues) { | ||
if (!enumValues.contains(STValEnum.OFF.value) && enumValues.contains(STValEnum.ON.value)) { | ||
if (isAuthorized(iedName, ldInst)) { | ||
isUpdatable = true; | ||
resumedDataTemplate.setNewVal(STValEnum.ON.value); | ||
} else { | ||
errorMessages.add(String.format("Unexpected error: The IED@%s/LDevice@%s cannot be set to 'off' but has not been selected into SSD: this case should not occur.", | ||
iedName, ldInst)); | ||
} | ||
} | ||
if (enumValues.contains(STValEnum.ON.value) && enumValues.contains(STValEnum.OFF.value)) { | ||
isUpdatable = true; | ||
if (isAuthorized(iedName, ldInst)) { | ||
resumedDataTemplate.setNewVal(STValEnum.ON.value); | ||
} else { | ||
resumedDataTemplate.setNewVal(STValEnum.OFF.value); | ||
} | ||
} | ||
|
||
} | ||
|
||
/** | ||
* checks whether LDevice Status is authorized to be deactivated when CompasLDeviceStatus Private is INACTIVE | ||
* @param iedName Ied name value which contains LDevice | ||
* @param ldInst LDevice inst value | ||
* @param enumValues enum values | ||
*/ | ||
private void isAuthorizedToDeactivateLDevice(String iedName, String ldInst, Set<String> enumValues) { | ||
if (!enumValues.contains(STValEnum.OFF.value) && enumValues.contains(STValEnum.ON.value)) { | ||
if (isAuthorized(iedName, ldInst)) { | ||
errorMessages.add(String.format("Unexpected error: The IED@%s/LDevice@%s is not qualified into STD but has been selected into SSD: this case should not occur.", | ||
iedName, ldInst)); | ||
} else { | ||
errorMessages.add(String.format("Unexpected error: The IED@%s/LDevice@%s cannot be set to 'off' but has not been selected into SSD: this case should not occur.", | ||
iedName, ldInst)); | ||
} | ||
} | ||
if (enumValues.contains(STValEnum.ON.value) && enumValues.contains(STValEnum.OFF.value)) { | ||
if (isAuthorized(iedName, ldInst)) { | ||
errorMessages.add(String.format("Unexpected error: The IED@%s/LDevice@%s is not qualified into STD but has been selected into SSD: this case should not occur.", | ||
iedName, ldInst)); | ||
} else { | ||
isUpdatable = true; | ||
resumedDataTemplate.setNewVal(STValEnum.OFF.value); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* checks whether a pair of IED name and LDevice inst are referenced in Substation...LNode list | ||
* @param iedName Ied name value | ||
* @param ldInst LDevice inst value | ||
* @return Returns whether a pair of IED name and LDevice inst are referenced in Substation...LNode list | ||
*/ | ||
private boolean isAuthorized(String iedName, String ldInst){ | ||
return iedNameLdInstList.contains(Pair.of(iedName, ldInst)); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.