Skip to content

Commit e98e619

Browse files
authored
Merge pull request #272 from com-pas/fix/271-compas-creation-report-cb-for-the-hmi-cb-not-created-when-ln-mod-stval-is-missing
fix(#271): RSR-724 ReportControl for the HMI was not created when LN Mod stVal is missing
2 parents f21f422 + 0dfa557 commit e98e619

File tree

4 files changed

+28
-48
lines changed

4 files changed

+28
-48
lines changed

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/AbstractLNAdapter.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,15 +1045,6 @@ public Optional<String> getDaiModStValValue() {
10451045
.flatMap(ResumedDataTemplate::findFirstValue);
10461046
}
10471047

1048-
/**
1049-
* Check the status ("Mod.stVal" value) of the current LN
1050-
*
1051-
* @return true if data Mod.stVal is present and has value equals to LnStatus.ON
1052-
*/
1053-
public boolean isDaiModStValOn() {
1054-
return DAI_MOD_STVAL_VALUE_ON.equals(getDaiModStValValue().orElse(null));
1055-
}
1056-
10571048
protected Optional<ResumedDataTemplate> getDaiModStVal() {
10581049
ResumedDataTemplate daiModFilter = new ResumedDataTemplate(this, MOD_DO_TYPE_NAME, STVAL_DA_TYPE_NAME);
10591050
return getDAI(daiModFilter, false).stream()

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/LDeviceAdapter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.lfenergy.compas.sct.commons.scl.SclElementAdapter;
1414
import org.lfenergy.compas.sct.commons.scl.dtt.DataTypeTemplateAdapter;
1515
import org.lfenergy.compas.sct.commons.util.ControlBlockEnum;
16+
import org.lfenergy.compas.sct.commons.util.LDeviceStatus;
1617
import org.lfenergy.compas.sct.commons.util.MonitoringLnClassEnum;
1718
import org.lfenergy.compas.sct.commons.util.Utils;
1819

@@ -76,12 +77,12 @@ public LDeviceAdapter(IEDAdapter parentAdapter, TLDevice currentElem) {
7677
*/
7778
public void createHmiReportControlBlocks(List<TFCDA> fcdas) {
7879
LN0Adapter ln0 = getLN0Adapter();
79-
if (!ln0.isDaiModStValOn()) return;
80+
if (!ln0.getDaiModStValValue().map(LDeviceStatus.ON::equals).orElse(false)) return;
8081
fcdas.stream()
8182
.filter(fcda -> getInst().equals(fcda.getLdInst()) && fcda.isSetLnClass())
8283
.forEach(fcda -> (fcda.getLnClass().get(0).equals(TLLN0Enum.LLN_0.value()) ?
8384
Optional.of(ln0) // ln0 Mod stVal "ON" has already been checked, no need to check it again
84-
: findLnAdapter(fcda.getLnClass().get(0), fcda.getLnInst(), fcda.getPrefix()).filter(AbstractLNAdapter::isDaiModStValOn))
85+
: findLnAdapter(fcda.getLnClass().get(0), fcda.getLnInst(), fcda.getPrefix()).filter(lnAdapter -> lnAdapter.getDaiModStValValue().map(LDeviceStatus.ON::equals).orElse(true)))
8586
.map(sourceLn -> sourceLn.getDAI(new ResumedDataTemplate(fcda), false))
8687
.filter(das -> das.stream().anyMatch(da -> fcda.getFc() == da.getFc())) // getDAI does not filter on DA.
8788
.ifPresent(resumedDataTemplates -> createHmiReportCB(ln0, fcda)));

sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/HmiServiceTest.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,31 @@ void createAllIhmReportControlBlocks_with_FCDA_on_ln0_should_create_dataset_and_
104104
}
105105

106106
@Test
107-
void createAllIhmReportControlBlocks_when_lDevice_ON_but_LN_status_OFF_should_not_create_dataset() {
107+
void createAllIhmReportControlBlocks_when_lDevice_ON_but_LN_Mod_StVal_missing_should_create_dataset_and_controlblock() {
108+
// Given
109+
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml");
110+
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
111+
LNAdapter ln = findLn(sclRootAdapter, "IedName1", "LdInst11", "ANCR", "1", null);
112+
ln.getCurrentElem().unsetDOI();
113+
TFCDA fcda = newFcda("LdInst11", "ANCR", "1", null, "DoName1", null, TFCEnum.ST);
114+
// When
115+
HmiService.createAllHmiReportControlBlocks(scd, List.of(fcda));
116+
// Then
117+
// Check DataSet is created
118+
DataSetAdapter dataSet = findDataSet(sclRootAdapter, "IedName1", "LdInst11", "DS_LDINST11_DQPO");
119+
assertThat(dataSet.getCurrentElem().getFCDA()).hasSize(1).first()
120+
.usingRecursiveComparison().isEqualTo(fcda);
121+
// Check ControlBlock is created
122+
LN0Adapter ln0 = findLn0(sclRootAdapter, "IedName1", "LdInst11");
123+
assertThat(ln0.getTControlsByType(TReportControl.class)).hasSize(1);
124+
TReportControl reportControl = findControlBlock(sclRootAdapter, "IedName1", "LdInst11", "CB_LDINST11_DQPO", TReportControl.class);
125+
assertThat(reportControl).extracting(TReportControl::getRptID, TControl::getDatSet, TReportControl::getConfRev, TReportControl::isBuffered, TReportControl::getBufTime, TReportControl::isIndexed,
126+
TControlWithTriggerOpt::getIntgPd)
127+
.containsExactly("IedName1LdInst11/LLN0.CB_LDINST11_DQPO", "DS_LDINST11_DQPO", 1L, true, 0L, true, 60000L);
128+
}
129+
130+
@Test
131+
void createAllIhmReportControlBlocks_when_lDevice_ON_but_LN_Mod_StVal_OFF_should_not_create_dataset() {
108132
// Given
109133
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml");
110134
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);

sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LN0AdapterTest.java

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -701,42 +701,6 @@ void getLnStatus_should_return_empty_Optional() {
701701
assertThat(lnStatus).isEmpty();
702702
}
703703

704-
@Test
705-
void isStatusOn_when_ModStVal_is_on_should_return_true() {
706-
// Given
707-
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-iedname/scd_set_extref_iedname_with_extref_errors.xml");
708-
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
709-
LN0Adapter ln0 = findLn0(sclRootAdapter, "IED_NAME1", "LD_INST11");
710-
// When
711-
boolean isStatusOn = ln0.isDaiModStValOn();
712-
// Then
713-
assertThat(isStatusOn).isTrue();
714-
}
715-
716-
@Test
717-
void isStatusOn_when_ModStVal_is_not_on_should_return_false() {
718-
// Given
719-
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-iedname/scd_set_extref_iedname_with_extref_errors.xml");
720-
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
721-
LN0Adapter ln0 = findLn0(sclRootAdapter, "IED_NAME1", "LD_INST13");
722-
// When
723-
boolean isStatusOn = ln0.isDaiModStValOn();
724-
// Then
725-
assertThat(isStatusOn).isFalse();
726-
}
727-
728-
@Test
729-
void isStatusOn_when_ModStVal_has_no_value_should_return_false() {
730-
// Given
731-
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-iedname/scd_set_extref_iedname_with_extref_errors.xml");
732-
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
733-
LN0Adapter ln0 = findLn0(sclRootAdapter, "IED_NAME1", "LD_INST14");
734-
// When
735-
boolean isStatusOn = ln0.isDaiModStValOn();
736-
// Then
737-
assertThat(isStatusOn).isFalse();
738-
}
739-
740704
@Test
741705
void createDataSetIfNotExists_should_create_dataSet() {
742706
// Given

0 commit comments

Comments
 (0)