-
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 (#163)
Signed-off-by: Aliou DIAITE <[email protected]> Signed-off-by: Samir Romdhani <[email protected]> Signed-off-by: Aliou DIAITE <[email protected]>
- Loading branch information
1 parent
aa054b1
commit 4074d64
Showing
63 changed files
with
3,111 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 sclRootAdapter; | ||
|
||
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; | ||
} | ||
} |
122 changes: 122 additions & 0 deletions
122
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,122 @@ | ||
// 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.util.STValEnum; | ||
|
||
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 boolean isUpdatable; | ||
private String newVal; | ||
private String errorMessage; | ||
|
||
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)) { | ||
errorMessage = "The LDevice cannot be activated or desactivated because its BehaviourKind Enum contains NOT 'on' AND NOT 'off'."; | ||
} | ||
if (!enumValues.contains(STValEnum.ON.value) && enumValues.contains(STValEnum.OFF.value)) { | ||
if (isDeclaredInSubstation(iedName, ldInst)) { | ||
errorMessage = "The LDevice cannot be set to 'on' but has been selected into SSD."; | ||
} else { | ||
isUpdatable = true; | ||
newVal = STValEnum.OFF.value; | ||
} | ||
} | ||
if(compasLDeviceStatus.equals(TCompasLDeviceStatus.ACTIVE) || | ||
compasLDeviceStatus.equals(TCompasLDeviceStatus.UNTESTED)){ | ||
checkAuthorisationToActivateLDevice(iedName, ldInst, enumValues); | ||
} | ||
if(compasLDeviceStatus.equals(TCompasLDeviceStatus.INACTIVE)){ | ||
checkAuthorisationToDeactivateLDevice(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 checkAuthorisationToActivateLDevice(String iedName, String ldInst, Set<String> enumValues) { | ||
if (!enumValues.contains(STValEnum.OFF.value) && enumValues.contains(STValEnum.ON.value)) { | ||
if (isDeclaredInSubstation(iedName, ldInst)) { | ||
isUpdatable = true; | ||
newVal = STValEnum.ON.value; | ||
} else { | ||
errorMessage = "The LDevice cannot be set to 'off' but has not been selected into SSD."; | ||
} | ||
} | ||
if (enumValues.contains(STValEnum.ON.value) && enumValues.contains(STValEnum.OFF.value)) { | ||
isUpdatable = true; | ||
if (isDeclaredInSubstation(iedName, ldInst)) { | ||
newVal = STValEnum.ON.value; | ||
} else { | ||
newVal = 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 checkAuthorisationToDeactivateLDevice(String iedName, String ldInst, Set<String> enumValues) { | ||
if (!enumValues.contains(STValEnum.OFF.value) && enumValues.contains(STValEnum.ON.value)) { | ||
if (isDeclaredInSubstation(iedName, ldInst)) { | ||
errorMessage = "The LDevice is not qualified into STD but has been selected into SSD."; | ||
} else { | ||
errorMessage = "The LDevice cannot be set to 'off' but has not been selected into SSD."; | ||
} | ||
} | ||
if (enumValues.contains(STValEnum.ON.value) && enumValues.contains(STValEnum.OFF.value)) { | ||
if (isDeclaredInSubstation(iedName, ldInst)) { | ||
errorMessage = "The LDevice is not qualified into STD but has been selected into SSD."; | ||
} else { | ||
isUpdatable = true; | ||
newVal = 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 isDeclaredInSubstation(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
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.