Skip to content

Commit abce60a

Browse files
samirromdhanimassifben
authored andcommitted
feat Remove service that Activate used LDevice and Deactivate unused LDevice, closes #464
Signed-off-by: Samir Romdhani <[email protected]>
1 parent c807c33 commit abce60a

17 files changed

+0
-2312
lines changed

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/SclService.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import lombok.NonNull;
88
import lombok.extern.slf4j.Slf4j;
9-
import org.apache.commons.lang3.tuple.Pair;
109
import org.lfenergy.compas.scl2007b4.model.*;
1110
import org.lfenergy.compas.sct.commons.api.SclEditor;
1211
import org.lfenergy.compas.sct.commons.dto.*;
@@ -24,7 +23,6 @@
2423
import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter;
2524
import org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter;
2625
import org.lfenergy.compas.sct.commons.scl.ln.LN0Adapter;
27-
import org.lfenergy.compas.sct.commons.scl.sstation.SubstationAdapter;
2826
import org.lfenergy.compas.sct.commons.util.PrivateUtils;
2927
import org.lfenergy.compas.sct.commons.util.Utils;
3028

@@ -187,19 +185,6 @@ public void importSTDElementsInSCD(SCL scd, List<SCL> stds) throws ScdException
187185
});
188186
}
189187

190-
@Override
191-
public List<SclReportItem> updateLDeviceStatus(SCL scd) {
192-
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
193-
SubstationAdapter substationAdapter = sclRootAdapter.getSubstationAdapter();
194-
final List<Pair<String, String>> iedNameLdInstList = substationAdapter.getIedAndLDeviceNamesForLN0FromLNode();
195-
return sclRootAdapter.streamIEDAdapters()
196-
.flatMap(IEDAdapter::streamLDeviceAdapters)
197-
.map(LDeviceAdapter::getLN0Adapter)
198-
.map(ln0Adapter -> ln0Adapter.updateLDeviceStatus(iedNameLdInstList))
199-
.flatMap(Optional::stream)
200-
.toList();
201-
}
202-
203188
@Override
204189
public List<SclReportItem> updateDoInRef(SCL scd) {
205190
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/SclEditor.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import lombok.NonNull;
88
import org.lfenergy.compas.scl2007b4.model.SCL;
9-
import org.lfenergy.compas.scl2007b4.model.TLNode;
109
import org.lfenergy.compas.sct.commons.dto.*;
1110
import org.lfenergy.compas.sct.commons.exception.ScdException;
1211

@@ -137,14 +136,6 @@ public interface SclEditor {
137136
*/
138137
void importSTDElementsInSCD(SCL scd, List<SCL> stds) throws ScdException;
139138

140-
/**
141-
* Activate used LDevice and Deactivate unused LDevice in {@link TLNode <em><b>TLNode </b></em>}
142-
*
143-
* @param scd SCL file for which LDevice should be activated or deactivated
144-
* @return list of encountered errors
145-
*/
146-
List<SclReportItem> updateLDeviceStatus(SCL scd);
147-
148139
/**
149140
* Update DAIs of DO InRef in all LN0 of the SCD using matching ExtRef information.
150141
*

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceActivation.java

Lines changed: 0 additions & 122 deletions
This file was deleted.

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LN0Adapter.java

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,12 @@
55
package org.lfenergy.compas.sct.commons.scl.ln;
66

77

8-
import org.apache.commons.lang3.tuple.Pair;
98
import org.lfenergy.compas.scl2007b4.model.*;
109
import org.lfenergy.compas.sct.commons.dto.*;
1110
import org.lfenergy.compas.sct.commons.scl.ObjectReference;
1211
import org.lfenergy.compas.sct.commons.scl.ied.InputsAdapter;
13-
import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceActivation;
1412
import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter;
15-
import org.lfenergy.compas.sct.commons.util.PrivateUtils;
16-
1713
import java.util.List;
18-
import java.util.Optional;
19-
import java.util.Set;
2014
import java.util.regex.Pattern;
2115
import java.util.stream.Collectors;
2216

@@ -68,8 +62,6 @@
6862
*/
6963
public class LN0Adapter extends AbstractLNAdapter<LN0> {
7064

71-
public static final DoTypeName BEHAVIOUR_DO_TYPE_NAME = new DoTypeName(BEHAVIOUR_DO_NAME);
72-
public static final DaTypeName BEHAVIOUR_DA_TYPE_NAME = getDaTypeNameForBeh();
7365
private static final Pattern LDEFP_DIGITAL_CHANNEL_PATTERN = Pattern.compile("DYN_LDEPF_DIGITAL CHANNEL \\d+_\\d+_BOOLEAN");
7466

7567
/**
@@ -169,58 +161,6 @@ public void removeAllControlBlocksAndDatasets() {
169161
currentElem.unsetSampledValueControl();
170162
}
171163

172-
/**
173-
* Verify and update LDevice status in parent Node
174-
*
175-
* @param iedNameLDeviceInstList pair of Ied name and LDevice inst attributes
176-
* @return Set of Errors
177-
*/
178-
public Optional<SclReportItem> updateLDeviceStatus(List<Pair<String, String>> iedNameLDeviceInstList) {
179-
LDeviceActivation lDeviceActivation = new LDeviceActivation(iedNameLDeviceInstList);
180-
final String iedName = getParentAdapter().getParentAdapter().getName();
181-
final String ldInst = getParentAdapter().getInst();
182-
DataAttributeRef daiBehFilter = new DataAttributeRef(this, BEHAVIOUR_DO_TYPE_NAME, BEHAVIOUR_DA_TYPE_NAME);
183-
List<DataAttributeRef> daiBehList = getDAI(daiBehFilter, false);
184-
if (daiBehList.isEmpty()) {
185-
return Optional.of(buildFatalReportItem("The LDevice doesn't have a DO @name='Beh' OR its associated DA@fc='ST' AND DA@name='stVal'"));
186-
}
187-
Set<String> enumValues = getEnumValues(daiBehList.getFirst().getDaName().getType());
188-
Optional<TCompasLDevice> optionalTCompasLDevice = PrivateUtils.extractCompasPrivate(getParentAdapter().getCurrentElem(), TCompasLDevice.class);
189-
if (optionalTCompasLDevice.isEmpty()) {
190-
return Optional.of(buildFatalReportItem("The LDevice doesn't have a Private compas:LDevice."));
191-
}
192-
if (!optionalTCompasLDevice.get().isSetLDeviceStatus()) {
193-
return Optional.of(buildFatalReportItem("The Private compas:LDevice doesn't have the attribute 'LDeviceStatus'"));
194-
}
195-
TCompasLDeviceStatus compasLDeviceStatus = optionalTCompasLDevice.get().getLDeviceStatus();
196-
Optional<DataAttributeRef> optionalModStVal = getDaiModStVal();
197-
if (optionalModStVal.isEmpty()) {
198-
return Optional.of(buildFatalReportItem("The LDevice doesn't have a DO @name='Mod'"));
199-
}
200-
DataAttributeRef newDaModToSetInLN0 = optionalModStVal.get();
201-
String initialValue = newDaModToSetInLN0.findFirstValue().orElse("");
202-
lDeviceActivation.checkLDeviceActivationStatus(iedName, ldInst, compasLDeviceStatus, enumValues);
203-
if (lDeviceActivation.isUpdatable()) {
204-
if (!initialValue.equals(lDeviceActivation.getNewVal())) {
205-
newDaModToSetInLN0.setVal(lDeviceActivation.getNewVal());
206-
updateDAI(newDaModToSetInLN0);
207-
}
208-
} else {
209-
if (lDeviceActivation.getErrorMessage() != null) {
210-
return Optional.of(buildFatalReportItem(lDeviceActivation.getErrorMessage()));
211-
}
212-
}
213-
return Optional.empty();
214-
}
215-
216-
private static DaTypeName getDaTypeNameForBeh() {
217-
DaTypeName daTypeNameBeh = new DaTypeName();
218-
daTypeNameBeh.setName(STVAL_DA_NAME);
219-
daTypeNameBeh.setBType(TPredefinedBasicTypeEnum.ENUM);
220-
daTypeNameBeh.setFc(TFCEnum.ST);
221-
return daTypeNameBeh;
222-
}
223-
224164
/**
225165
* Update DAIs of DO InRef in all LN0 of the SCD using matching ExtRef information.
226166
*

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/sstation/SubstationAdapter.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@
44

55
package org.lfenergy.compas.sct.commons.scl.sstation;
66

7-
import org.apache.commons.lang3.tuple.Pair;
8-
import org.lfenergy.compas.scl2007b4.model.TLLN0Enum;
97
import org.lfenergy.compas.scl2007b4.model.TSubstation;
108
import org.lfenergy.compas.sct.commons.exception.ScdException;
119
import org.lfenergy.compas.sct.commons.scl.SclElementAdapter;
1210
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
1311
import org.lfenergy.compas.sct.commons.util.Utils;
1412

15-
import java.util.List;
1613
import java.util.Optional;
17-
import java.util.stream.Collectors;
1814
import java.util.stream.Stream;
1915

2016
/**
@@ -119,18 +115,4 @@ public Stream<VoltageLevelAdapter> streamVoltageLevelAdapters() {
119115
return currentElem.getVoltageLevel().stream().map(tVoltageLevel -> new VoltageLevelAdapter(this, tVoltageLevel));
120116
}
121117

122-
/**
123-
* Gets a pair of IedName and LDevice inst from Substation LNodes for LN0 type object
124-
* @return a pair of Ied name and LDevice inst attributes
125-
*/
126-
public List<Pair<String, String>> getIedAndLDeviceNamesForLN0FromLNode() {
127-
return streamVoltageLevelAdapters()
128-
.flatMap(VoltageLevelAdapter::streamBayAdapters)
129-
.flatMap(BayAdapter::streamFunctionAdapters)
130-
.flatMap(functionAdapter -> functionAdapter.getCurrentElem().getLNode().stream())
131-
.filter(tlNode -> tlNode.getLnClass().contains(TLLN0Enum.LLN_0.value()))
132-
.map(tlNode -> Pair.of(tlNode.getIedName(), tlNode.getLdInst()))
133-
.collect(Collectors.toList());
134-
}
135-
136118
}

0 commit comments

Comments
 (0)