Skip to content

Commit cb36862

Browse files
Merge pull request #504 from com-pas/feat/503_RSR-1241-ldepf-configuration-support-goose-and-smv-servicetype-in-extref-based-on-channel-type
feat: LDEPF added support GOOSE and SMV serviceType in ExtRef Based on Channel Type, closes #503, RSR-1241
2 parents 8d24a5f + b182e62 commit cb36862

File tree

4 files changed

+359
-10
lines changed

4 files changed

+359
-10
lines changed

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public List<SclReportItem> manageBindingForLDEPF(SCL scd, EPF epf) {
276276
.findFirst().ifPresent(channel -> {
277277
List<TIED> iedSources = getIedSources(sclRootAdapter, extRefBayRef.compasBay(), channel);
278278
if (iedSources.size() == 1) {
279-
updateLDEPFExtRefBinding(extRefBayRef.extRef(), iedSources.getFirst(), channel);
279+
updateLDEPFExtRefBinding(extRefBayRef, iedSources.getFirst(), channel);
280280
LDeviceAdapter lDeviceAdapter = new LDeviceAdapter(new IEDAdapter(sclRootAdapter, tied.getName()), ldepfLdevice);
281281
updateLDEPFDos(lDeviceAdapter, extRefBayRef.extRef(), channel);
282282
} else {
@@ -323,16 +323,25 @@ public void epfPostProcessing(SCL scd) {
323323
})));
324324
}
325325

326-
private void updateLDEPFExtRefBinding(TExtRef extRef, TIED iedSource, TChannel setting) {
327-
extRef.setIedName(iedSource.getName());
328-
extRef.setLdInst(setting.getLDInst());
329-
extRef.getLnClass().add(setting.getLNClass());
330-
extRef.setLnInst(setting.getLNInst());
326+
private void updateLDEPFExtRefBinding(ExtRefInfo.ExtRefWithBayReference extRefWithBay, TIED iedSource, TChannel setting) {
327+
TExtRef tExtRef = extRefWithBay.extRef();
328+
tExtRef.setIedName(iedSource.getName());
329+
tExtRef.setLdInst(setting.getLDInst());
330+
tExtRef.getLnClass().add(setting.getLNClass());
331+
tExtRef.setLnInst(setting.getLNInst());
331332
if (!isBlank(setting.getLNPrefix())) {
332-
extRef.setPrefix(setting.getLNPrefix());
333+
tExtRef.setPrefix(setting.getLNPrefix());
333334
}
334335
String doName = isBlank(setting.getDOInst()) || setting.getDOInst().equals("0") ? setting.getDOName() : setting.getDOName() + setting.getDOInst();
335-
extRef.setDoName(doName);
336+
tExtRef.setDoName(doName);
337+
// This is true for External Binding
338+
if (!extRefWithBay.iedName().equals(iedSource.getName())) {
339+
tExtRef.setServiceType(
340+
switch (setting.getChannelType()) {
341+
case DIGITAL -> TServiceType.GOOSE;
342+
case ANALOG -> TServiceType.SMV;
343+
});
344+
}
336345
}
337346

338347
private void updateLDEPFDos(LDeviceAdapter lDeviceAdapter, TExtRef extRef, TChannel setting) {

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

Lines changed: 132 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import static org.assertj.core.api.Assertions.assertThat;
2929
import static org.assertj.core.api.Assertions.assertThatThrownBy;
30+
import static org.assertj.core.api.Assertions.tuple;
3031
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
3132
import static org.lfenergy.compas.sct.commons.testhelpers.SclHelper.*;
3233
import static org.lfenergy.compas.sct.commons.util.CommonConstants.*;
@@ -610,7 +611,7 @@ void epfPostProcessing_when_exist_unused_channel_should_update_setSrcRef() {
610611
@CsvSource({"'',''", "NA,NA"})
611612
void manageBindingForLDEPF_should_not_update_dai_setVal_when_channelLevMod_or_channelLevModq_are_empty_or_NA(String channelLevMod, String channelLevModq) {
612613
//Given
613-
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_processing_bind_dai_update.xml");
614+
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_processing_internal_bind.xml");
614615
TChannel digitalChannel = new TChannel();
615616
digitalChannel.setBayScope(TCBScopeType.BAY_INTERNAL);
616617
digitalChannel.setChannelType(TChannelType.DIGITAL);
@@ -710,7 +711,7 @@ void manageBindingForLDEPF_should_not_update_dai_setVal_when_channelLevMod_or_ch
710711
@Test
711712
void manageBindingForLDEPF_should_return_error_report_when_missing_mandatory_privates() {
712713
//Given
713-
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_processing_bind_dai_update.xml");
714+
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_processing_internal_bind.xml");
714715
scd.getIED().forEach(tied -> tied.getPrivate().removeIf(tPrivate -> tPrivate.getType().equals(PrivateEnum.COMPAS_BAY.getPrivateType())
715716
|| tPrivate.getType().equals(PrivateEnum.COMPAS_ICDHEADER.getPrivateType())));
716717

@@ -774,5 +775,134 @@ void manageBindingForLDEPF_should_not_been_configured_when_ldepf_ln0_is_off() {
774775
.isEqualTo(SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_processing_when_status_ln0_off.xml"));
775776
}
776777

778+
@Test
779+
void manageBindingForLDEPF_should_update_binding_properties_when_internal_binding() {
780+
//Given
781+
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_processing_internal_bind.xml");
782+
TChannel digitalChannel = new TChannel();
783+
digitalChannel.setBayScope(TCBScopeType.BAY_INTERNAL);
784+
digitalChannel.setChannelType(TChannelType.DIGITAL);
785+
digitalChannel.setChannelNum("1");
786+
digitalChannel.setChannelShortLabel("MR.PX1");
787+
digitalChannel.setChannelLevMod(TChannelLevMod.POSITIVE_OR_RISING);
788+
digitalChannel.setChannelLevModQ(TChannelLevMod.OTHER);
789+
digitalChannel.setIEDType("BCU");
790+
digitalChannel.setIEDRedundancy(TIEDredundancy.NONE);
791+
digitalChannel.setIEDSystemVersionInstance("1");
792+
digitalChannel.setLDInst("LDPX");
793+
digitalChannel.setLNClass("PTRC");
794+
digitalChannel.setLNInst("0");
795+
digitalChannel.setDOName("Str");
796+
digitalChannel.setDOInst("0");
797+
digitalChannel.setDAName("general");
798+
799+
TChannel analogChannel = new TChannel();
800+
analogChannel.setBayScope(TCBScopeType.BAY_INTERNAL);
801+
analogChannel.setChannelType(TChannelType.ANALOG);
802+
analogChannel.setChannelNum("1");
803+
analogChannel.setChannelShortLabel("MR.PX1");
804+
analogChannel.setChannelLevMod(TChannelLevMod.POSITIVE_OR_RISING);
805+
analogChannel.setChannelLevModQ(TChannelLevMod.OTHER);
806+
analogChannel.setIEDType("BCU");
807+
analogChannel.setIEDRedundancy(TIEDredundancy.NONE);
808+
analogChannel.setIEDSystemVersionInstance("1");
809+
analogChannel.setLDInst("LDPX");
810+
analogChannel.setLNClass("PTRC");
811+
analogChannel.setLNInst("0");
812+
analogChannel.setDOName("Str");
813+
analogChannel.setDOInst("0");
814+
analogChannel.setDAName("general");
815+
816+
EPF epf = new EPF();
817+
Channels channels = new Channels();
818+
channels.getChannel().addAll(List.of(digitalChannel, analogChannel));
819+
epf.setChannels(channels);
820+
// When
821+
List<SclReportItem> sclReportItems = extRefEditorService.manageBindingForLDEPF(scd, epf);
822+
// Then
823+
assertThat(sclReportItems).isEmpty();
824+
assertThat(scd.getIED())
825+
.filteredOn(tied -> tied.getName().equals("IED_NAME1"))
826+
.flatExtracting(TIED::getAccessPoint)
827+
.extracting(TAccessPoint::getServer)
828+
.flatExtracting(TServer::getLDevice)
829+
.filteredOn(tlDevice -> tlDevice.getInst().equals(LDEVICE_LDEPF))
830+
// Binding properties should be set
831+
.allSatisfy(tlDevice -> {
832+
assertThat(tlDevice.getLN0().getInputs().getExtRef())
833+
.filteredOn(tExtRef -> tExtRef.getDesc().contains("DIGITAL"))
834+
.extracting(TExtRef::getIedName, TExtRef::getLdInst, TExtRef::getLnClass, TExtRef::getLnInst, TExtRef::getDoName, TExtRef::isSetServiceType)
835+
.containsExactlyInAnyOrder(tuple("IED_NAME1", "LDPX", List.of("PTRC"), "0", "Str", false));
836+
assertThat(tlDevice.getLN0().getInputs().getExtRef())
837+
.filteredOn(tExtRef -> tExtRef.getDesc().contains("ANALOG"))
838+
.extracting(TExtRef::getIedName, TExtRef::getLdInst, TExtRef::getLnClass, TExtRef::getLnInst, TExtRef::getDoName, TExtRef::isSetServiceType)
839+
.containsExactlyInAnyOrder(tuple("IED_NAME1", "LDPX", List.of("PTRC"), "0", "Str", false));
840+
});
841+
}
842+
843+
@Test
844+
void manageBindingForLDEPF_should_update_binding_properties_when_external_binding() {
845+
//Given
846+
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_processing_external_bind.xml");
847+
TChannel digitalChannel = new TChannel();
848+
digitalChannel.setBayScope(TCBScopeType.BAY_EXTERNAL);
849+
digitalChannel.setChannelType(TChannelType.DIGITAL);
850+
digitalChannel.setChannelNum("1");
851+
digitalChannel.setChannelShortLabel("MR.PX1");
852+
digitalChannel.setChannelLevMod(TChannelLevMod.POSITIVE_OR_RISING);
853+
digitalChannel.setChannelLevModQ(TChannelLevMod.OTHER);
854+
digitalChannel.setIEDType("BCU");
855+
digitalChannel.setIEDRedundancy(TIEDredundancy.NONE);
856+
digitalChannel.setIEDSystemVersionInstance("1");
857+
digitalChannel.setLDInst("LDPX");
858+
digitalChannel.setLNClass("PTRC");
859+
digitalChannel.setLNInst("0");
860+
digitalChannel.setDOName("Str");
861+
digitalChannel.setDOInst("0");
862+
digitalChannel.setDAName("general");
863+
864+
TChannel analogChannel = new TChannel();
865+
analogChannel.setBayScope(TCBScopeType.BAY_EXTERNAL);
866+
analogChannel.setChannelType(TChannelType.ANALOG);
867+
analogChannel.setChannelNum("1");
868+
analogChannel.setChannelShortLabel("MR.PX1");
869+
analogChannel.setChannelLevMod(TChannelLevMod.POSITIVE_OR_RISING);
870+
analogChannel.setChannelLevModQ(TChannelLevMod.OTHER);
871+
analogChannel.setIEDType("BCU");
872+
analogChannel.setIEDRedundancy(TIEDredundancy.NONE);
873+
analogChannel.setIEDSystemVersionInstance("1");
874+
analogChannel.setLDInst("LDPX");
875+
analogChannel.setLNClass("PTRC");
876+
analogChannel.setLNInst("0");
877+
analogChannel.setDOName("Str");
878+
analogChannel.setDOInst("0");
879+
analogChannel.setDAName("general");
880+
881+
EPF epf = new EPF();
882+
Channels channels = new Channels();
883+
channels.getChannel().addAll(List.of(digitalChannel, analogChannel));
884+
epf.setChannels(channels);
885+
// When
886+
List<SclReportItem> sclReportItems = extRefEditorService.manageBindingForLDEPF(scd, epf);
887+
// Then
888+
assertThat(sclReportItems).isEmpty();
889+
assertThat(scd.getIED())
890+
.filteredOn(tied -> tied.getName().equals("IED_NAME1"))
891+
.flatExtracting(TIED::getAccessPoint)
892+
.extracting(TAccessPoint::getServer)
893+
.flatExtracting(TServer::getLDevice)
894+
.filteredOn(tlDevice -> tlDevice.getInst().equals(LDEVICE_LDEPF))
895+
// Binding properties should be set including Service Type
896+
.allSatisfy(tlDevice -> {
897+
assertThat(tlDevice.getLN0().getInputs().getExtRef())
898+
.filteredOn(tExtRef -> tExtRef.getDesc().contains("DIGITAL"))
899+
.extracting(TExtRef::getIedName, TExtRef::getLdInst, TExtRef::getLnClass, TExtRef::getLnInst, TExtRef::getDoName, TExtRef::getServiceType)
900+
.containsExactlyInAnyOrder(tuple("IED_NAME2", "LDPX", List.of("PTRC"), "0", "Str", TServiceType.GOOSE));
901+
assertThat(tlDevice.getLN0().getInputs().getExtRef())
902+
.filteredOn(tExtRef -> tExtRef.getDesc().contains("ANALOG"))
903+
.extracting(TExtRef::getIedName, TExtRef::getLdInst, TExtRef::getLnClass, TExtRef::getLnInst, TExtRef::getDoName, TExtRef::getServiceType)
904+
.containsExactlyInAnyOrder(tuple("IED_NAME2", "LDPX", List.of("PTRC"), "0", "Str", TServiceType.SMV));
905+
});
906+
}
777907

778908
}

0 commit comments

Comments
 (0)