Skip to content

Commit f93220e

Browse files
committed
feat: LDEPF should not be configured when inactive, closes #501
Signed-off-by: Samir Romdhani <[email protected]>
1 parent db93195 commit f93220e

11 files changed

+263
-670
lines changed

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
@RequiredArgsConstructor
3636
public class ExtRefEditorService implements ExtRefEditor {
3737
private static final String INVALID_OR_MISSING_ATTRIBUTES_IN_EXT_REF_BINDING_INFO = "Invalid or missing attributes in ExtRef binding info";
38+
private static final String COMPAS_LNODE_STATUS = "COMPAS-LNodeStatus";
3839
private static final List<DoNameAndDaName> DO_DA_MAPPINGS = List.of(
3940
new DoNameAndDaName(CHNUM1_DO_NAME, DU_DA_NAME),
4041
new DoNameAndDaName(LEVMOD_DO_NAME, SETVAL_DA_NAME),
@@ -87,7 +88,6 @@ private List<TIED> getIedSources(SclRootAdapter sclRootAdapter, TCompasBay compa
8788
* @return list of ExtRef and associated Bay
8889
*/
8990
private List<ExtRefInfo.ExtRefWithBayReference> getExtRefWithBayReferenceInLDEPF(TDataTypeTemplates dataTypeTemplates, TIED tied, final TLDevice tlDevice, final List<SclReportItem> sclReportItems) {
90-
List<ExtRefInfo.ExtRefWithBayReference> extRefBayReferenceList = new ArrayList<>();
9191
String lDevicePath = "SCL/IED[@name=\"" + tied.getName() + "\"]/AccessPoint/Server/LDevice[@inst=\"" + tlDevice.getInst() + "\"]";
9292
Optional<TCompasBay> tCompasBay = PrivateUtils.extractCompasPrivate(tied, TCompasBay.class);
9393
if (tCompasBay.isEmpty()) {
@@ -97,16 +97,7 @@ private List<ExtRefInfo.ExtRefWithBayReference> getExtRefWithBayReferenceInLDEPF
9797
}
9898
return Collections.emptyList();
9999
}
100-
101-
if (dataTypeTemplatesService.isDoModAndDaStValExist(dataTypeTemplates, tlDevice.getLN0().getLnType())) {
102-
extRefBayReferenceList.addAll(tlDevice.getLN0()
103-
.getInputs()
104-
.getExtRef().stream()
105-
.map(extRef -> new ExtRefInfo.ExtRefWithBayReference(tied.getName(), tCompasBay.get(), extRef)).toList());
106-
} else {
107-
sclReportItems.add(SclReportItem.error(lDevicePath, "DO@name=Mod/DA@name=stVal not found in DataTypeTemplate"));
108-
}
109-
return extRefBayReferenceList;
100+
return tlDevice.getLN0().getInputs().getExtRef().stream().map(extRef -> new ExtRefInfo.ExtRefWithBayReference(tied.getName(), tCompasBay.get(), extRef)).toList();
110101
}
111102

112103
/**
@@ -274,7 +265,8 @@ public List<SclReportItem> manageBindingForLDEPF(SCL scd, EPF epf) {
274265
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
275266
if (!epf.isSetChannels()) return sclReportItems;
276267
iedService.getFilteredIeds(scd, ied -> !ied.getName().contains("TEST"))
277-
.forEach(tied -> ldeviceService.findLdevice(tied, LDEVICE_LDEPF)
268+
.forEach(tied -> ldeviceService.findLdevice(tied, tlDevice -> tlDevice.getInst().equals(LDEVICE_LDEPF)
269+
&& PrivateUtils.extractStringPrivate(tlDevice.getLN0(), COMPAS_LNODE_STATUS).map(status -> !status.equals("off")).orElse(false))
278270
.ifPresent(tlDevice -> getExtRefWithBayReferenceInLDEPF(scd.getDataTypeTemplates(), tied, tlDevice, sclReportItems)
279271
.forEach(extRefBayRef -> epf.getChannels().getChannel().stream().filter(tChannel -> doesExtRefMatchLDEPFChannel(extRefBayRef.extRef(), tChannel))
280272
.findFirst().ifPresent(channel -> {

sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ExtRefEditorServiceTest.java

Lines changed: 34 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package org.lfenergy.compas.sct.commons;
66

77
import org.assertj.core.api.SoftAssertions;
8-
import org.assertj.core.groups.Tuple;
98
import org.junit.jupiter.api.BeforeEach;
109
import org.junit.jupiter.api.Tag;
1110
import org.junit.jupiter.api.Test;
@@ -327,111 +326,6 @@ void manageBindingForLDEPF_when_extRefMatchFlowKindInternalOrExternal_should_upd
327326
assertExtRefIsBoundAccordingTOLDEPF(extRefBindExternally, analogueChannel10WithBayExternalBayScope);
328327
}
329328

330-
@Test
331-
void manageBindingForLDEPF_when_DOI_Mod_and_DAI_stVal_notExists_should_precede() {
332-
// Given
333-
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_withoutModStValInLN0.xml");
334-
// When
335-
TChannel channel = new TChannel();
336-
channel.setBayScope(TCBScopeType.BAY_INTERNAL);
337-
channel.setChannelType(TChannelType.DIGITAL);
338-
channel.setChannelNum("1");
339-
channel.setChannelShortLabel("MR.PX1");
340-
channel.setChannelLevMod(TChannelLevMod.POSITIVE_OR_RISING);
341-
channel.setChannelLevModQ(TChannelLevMod.OTHER);
342-
channel.setIEDType("BCU");
343-
channel.setIEDRedundancy(TIEDredundancy.NONE);
344-
channel.setIEDSystemVersionInstance("1");
345-
channel.setLDInst("LDPX");
346-
channel.setLNClass("PTRC");
347-
channel.setLNInst("0");
348-
channel.setDOName("Str");
349-
channel.setDOInst("0");
350-
channel.setDAName("general");
351-
352-
EPF epf = new EPF();
353-
Channels channels = new Channels();
354-
channels.getChannel().add(channel);
355-
epf.setChannels(channels);
356-
List<SclReportItem> sclReportItems = extRefEditorService.manageBindingForLDEPF(scd, epf);
357-
// Then
358-
assertThat(sclReportItems).isEmpty();
359-
TExtRef extRef1 = findExtRef(scd, "IED_NAME1", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEAN_1_general_1");
360-
assertThat(extRef1.getIedName()).isEqualTo("IED_NAME1");
361-
TExtRef extRef2 = findExtRef(scd, "IED_NAME2", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEAN_1_general_1");
362-
assertThat(extRef2.getIedName()).isEqualTo("IED_NAME2");
363-
TExtRef extRef3 = findExtRef(scd, "IED_NAME3", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEAN_1_general_1");
364-
assertThat(extRef3.getIedName()).isEqualTo("IED_NAME1");
365-
366-
assertExtRefIsBoundAccordingTOLDEPF(extRef1, channel);
367-
assertExtRefIsBoundAccordingTOLDEPF(extRef2, channel);
368-
assertExtRefIsBoundAccordingTOLDEPF(extRef3, channel);
369-
}
370-
371-
@Test
372-
void manageBindingForLDEPF_when_LDEPF_NotActive_should_precede() {
373-
//Given
374-
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_with_inactive_ldevice_ldepf.xml");
375-
TChannel channel = new TChannel();
376-
channel.setBayScope(TCBScopeType.BAY_INTERNAL);
377-
channel.setChannelType(TChannelType.DIGITAL);
378-
channel.setChannelNum("1");
379-
channel.setChannelShortLabel("MR.PX1");
380-
channel.setChannelLevMod(TChannelLevMod.POSITIVE_OR_RISING);
381-
channel.setChannelLevModQ(TChannelLevMod.OTHER);
382-
channel.setIEDType("BCU");
383-
channel.setIEDRedundancy(TIEDredundancy.NONE);
384-
channel.setIEDSystemVersionInstance("1");
385-
channel.setLDInst("LDPX");
386-
channel.setLNClass("PTRC");
387-
channel.setLNInst("0");
388-
channel.setDOName("Str");
389-
channel.setDOInst("0");
390-
channel.setDAName("general");
391-
392-
EPF epf = new EPF();
393-
Channels channels = new Channels();
394-
channels.getChannel().add(channel);
395-
epf.setChannels(channels);
396-
// When
397-
List<SclReportItem> sclReportItems = extRefEditorService.manageBindingForLDEPF(scd, epf);
398-
// Then
399-
assertThat(sclReportItems).isEmpty();
400-
TExtRef extRef1 = findExtRef(scd, "IED_NAME1", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEAN_1_general_1");
401-
assertThat(extRef1.getIedName()).isEqualTo("IED_NAME1");
402-
TExtRef extRef2 = findExtRef(scd, "IED_NAME2", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEAN_1_general_1");
403-
assertThat(extRef2.getIedName()).isEqualTo("IED_NAME2");
404-
TExtRef extRef3 = findExtRef(scd, "IED_NAME3", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEAN_1_general_1");
405-
assertThat(extRef3.getIedName()).isEqualTo("IED_NAME1");
406-
407-
assertExtRefIsBoundAccordingTOLDEPF(extRef1, channel);
408-
assertExtRefIsBoundAccordingTOLDEPF(extRef2, channel);
409-
assertExtRefIsBoundAccordingTOLDEPF(extRef3, channel);
410-
}
411-
412-
@Test
413-
void manageBindingForLDEPF_when_DO_Mod_and_DA_stVal_NotFoundInDataTypeTemplate_should_return_error() {
414-
// Given
415-
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_withoutModStValInDataTypeTemplate.xml");
416-
// When
417-
EPF epf = new EPF();
418-
epf.setChannels(new Channels());
419-
List<SclReportItem> sclReportItems = extRefEditorService.manageBindingForLDEPF(scd, epf);
420-
// Then
421-
assertThat(sclReportItems).hasSize(3);
422-
assertThat(sclReportItems)
423-
.extracting(SclReportItem::message, SclReportItem::xpath)
424-
.containsExactly(
425-
Tuple.tuple("DO@name=Mod/DA@name=stVal not found in DataTypeTemplate",
426-
"SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LDEPF\"]"),
427-
Tuple.tuple("DO@name=Mod/DA@name=stVal not found in DataTypeTemplate",
428-
"SCL/IED[@name=\"IED_NAME2\"]/AccessPoint/Server/LDevice[@inst=\"LDEPF\"]"),
429-
Tuple.tuple("DO@name=Mod/DA@name=stVal not found in DataTypeTemplate",
430-
"SCL/IED[@name=\"IED_NAME3\"]/AccessPoint/Server/LDevice[@inst=\"LDEPF\"]")
431-
);
432-
}
433-
434-
435329
private void assertExtRefIsBoundAccordingTOLDEPF(TExtRef extRef, TChannel setting) {
436330
assertThat(extRef.getLdInst()).isEqualTo(setting.getLDInst());
437331
assertThat(extRef.getLnClass()).contains(setting.getLNClass());
@@ -844,4 +738,38 @@ void manageBindingForLDEPF_should_not_update_dai_setVal_when_channelLevMod_or_ch
844738
});
845739
}
846740

741+
@Test()
742+
void manageBindingForLDEPF_should_not_been_configured_when_ldepf_ln0_is_off() {
743+
//Given
744+
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_processing_when_status_ln0_off.xml");
745+
TChannel digitalChannel = new TChannel();
746+
digitalChannel.setBayScope(TCBScopeType.BAY_INTERNAL);
747+
digitalChannel.setChannelType(TChannelType.DIGITAL);
748+
digitalChannel.setChannelNum("1");
749+
digitalChannel.setChannelShortLabel("MR.PX1");
750+
digitalChannel.setChannelLevMod(TChannelLevMod.POSITIVE_OR_RISING);
751+
digitalChannel.setChannelLevModQ(TChannelLevMod.OTHER);
752+
digitalChannel.setIEDType("BCU");
753+
digitalChannel.setIEDRedundancy(TIEDredundancy.NONE);
754+
digitalChannel.setIEDSystemVersionInstance("1");
755+
digitalChannel.setLDInst("LDPX");
756+
digitalChannel.setLNClass("PTRC");
757+
digitalChannel.setLNInst("0");
758+
digitalChannel.setDOName("Str");
759+
digitalChannel.setDOInst("0");
760+
digitalChannel.setDAName("general");
761+
EPF epf = new EPF();
762+
Channels channels = new Channels();
763+
channels.getChannel().add(digitalChannel);
764+
epf.setChannels(channels);
765+
// When
766+
List<SclReportItem> sclReportItems = extRefEditorService.manageBindingForLDEPF(scd, epf);
767+
// Then
768+
assertThat(sclReportItems).isEmpty();
769+
assertThat(scd)
770+
.usingRecursiveComparison()
771+
.isEqualTo(SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_processing_when_status_ln0_off.xml"));
772+
}
773+
774+
847775
}

sct-commons/src/test/resources/scd-ldepf/scd_ldepf_dataTypeTemplateValid.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<Authentication/>
2525
<LDevice inst="LDEPF" ldName="IED_NAME1LDEPF">
2626
<LN0 lnClass="LLN0" inst="" lnType="LLN0_ID1">
27+
<Private type="COMPAS-LNodeStatus">on</Private>
2728
<DOI name="Mod">
2829
<DAI name="stVal" valImport="true">
2930
<Val>on</Val>
@@ -117,6 +118,7 @@
117118
<Authentication/>
118119
<LDevice inst="LDPHAS1" ldName="IED_NAME2LDPHAS1">
119120
<LN0 lnClass="LLN0" inst="" lnType="LLN0_ID1">
121+
<Private type="COMPAS-LNodeStatus">on</Private>
120122
<DOI name="Mod">
121123
<DAI name="stVal">
122124
<Val>on</Val>

sct-commons/src/test/resources/scd-ldepf/scd_ldepf_extref_with_IedType_BCU.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<Authentication/>
2525
<LDevice inst="LDEPF" ldName="IED_NAME1LDEPF">
2626
<LN0 lnClass="LLN0" inst="" lnType="LLN0_ID1">
27+
<Private type="COMPAS-LNodeStatus">on</Private>
2728
<DOI name="Mod">
2829
<DAI name="stVal" valImport="true">
2930
<Val>on</Val>

sct-commons/src/test/resources/scd-ldepf/scd_ldepf_iedSources_in_different_bay.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<Authentication/>
2525
<LDevice inst="LDEPF" ldName="IED_NAME1LDEPF">
2626
<LN0 lnClass="LLN0" inst="" lnType="LLN0_ID1">
27+
<Private type="COMPAS-LNodeStatus">on</Private>
2728
<DOI name="Mod">
2829
<DAI name="stVal" valImport="true">
2930
<Val>on</Val>
@@ -140,6 +141,7 @@
140141
<Authentication/>
141142
<LDevice inst="LDEPF" ldName="IED_NAME2LDEPF">
142143
<LN0 lnClass="LLN0" inst="" lnType="LLN0_ID1">
144+
<Private type="COMPAS-LNodeStatus">on</Private>
143145
<DOI name="Mod">
144146
<DAI name="stVal" valImport="true">
145147
<Val>on</Val>
@@ -184,6 +186,7 @@
184186
<Authentication/>
185187
<LDevice inst="LDEPF" ldName="IED_NAME3LDEPF">
186188
<LN0 lnClass="LLN0" inst="" lnType="LLN0_ID1">
189+
<Private type="COMPAS-LNodeStatus">on</Private>
187190
<DOI name="Mod">
188191
<DAI name="stVal" valImport="true">
189192
<Val>on</Val>

sct-commons/src/test/resources/scd-ldepf/scd_ldepf_manyIedSources_in_same_bay.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<Authentication/>
2525
<LDevice inst="LDEPF" ldName="IED_NAME1LDEPF">
2626
<LN0 lnClass="LLN0" inst="" lnType="LLN0_ID1">
27+
<Private type="COMPAS-LNodeStatus">on</Private>
2728
<DOI name="Mod">
2829
<DAI name="stVal" valImport="true">
2930
<Val>on</Val>
@@ -64,6 +65,7 @@
6465
<Authentication/>
6566
<LDevice inst="LDEPF" ldName="IED_NAME2LDEPF">
6667
<LN0 lnClass="LLN0" inst="" lnType="LLN0_ID1">
68+
<Private type="COMPAS-LNodeStatus">on</Private>
6769
<DOI name="Mod">
6870
<DAI name="stVal" valImport="true">
6971
<Val>on</Val>
@@ -148,6 +150,7 @@
148150
<Authentication/>
149151
<LDevice inst="LDEPF" ldName="IED_NAME2LDEPF">
150152
<LN0 lnClass="LLN0" inst="" lnType="LLN0_ID1">
153+
<Private type="COMPAS-LNodeStatus">on</Private>
151154
<DOI name="Mod">
152155
<DAI name="stVal" valImport="true">
153156
<Val>on</Val>

sct-commons/src/test/resources/scd-ldepf/scd_ldepf_processing_bind_dai_update.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<Authentication/>
2525
<LDevice inst="LDEPF" ldName="IED_NAME1LDEPF">
2626
<LN0 lnClass="LLN0" inst="" lnType="LLN0_ID1">
27+
<Private type="COMPAS-LNodeStatus">on</Private>
2728
<DOI name="Mod">
2829
<DAI name="stVal" valImport="true">
2930
<Val>on</Val>

0 commit comments

Comments
 (0)