Skip to content

Commit 4957b6b

Browse files
committed
feat(83): RSR-389 - ignore INACTIVE CompasFlow when creating Dataset
Signed-off-by: massifben <[email protected]>
1 parent e956419 commit 4957b6b

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,19 @@ public List<SclReportItem> updateAllSourceDataSetsAndControlBlocks() {
249249
return getExtRefs().stream()
250250
.filter(this::areBindingAttributesPresent)
251251
.filter(this::isExternalBound)
252-
//TODO: replace filter below by criteria of issue #93 RSR-389
253-
// - Active or Untested i.e /IED/LDevice/LN0/Inputs/Private/compas:Flow @FlowStatus="ACTIVE" OR "UNTESTED"
254-
.filter(extRef -> !getMatchingCompasFlows(extRef, compasFlows).isEmpty())
252+
.filter(extRef -> matchingCompasFlowIsActiveOrUntested(extRef, compasFlows))
255253
.map(extRef -> updateSourceDataSetsAndControlBlocks(extRef, currentBayUuid))
256254
.flatMap(Optional::stream)
257255
.toList();
258256
}
259257

258+
private boolean matchingCompasFlowIsActiveOrUntested(TExtRef extRef, List<TCompasFlow> compasFlows) {
259+
return getMatchingCompasFlows(extRef, compasFlows).stream().findFirst()
260+
.map(TCompasFlow::getFlowStatus)
261+
.filter(flowStatus -> flowStatus == TCompasFlowStatus.ACTIVE || flowStatus == TCompasFlowStatus.UNTESTED)
262+
.isPresent();
263+
}
264+
260265
private boolean isExternalBound(TExtRef tExtRef) {
261266
return !tExtRef.getIedName().equals(getIedAdapter().getName());
262267
}
@@ -300,7 +305,9 @@ private Optional<SclReportItem> updateSourceDataSetsAndControlBlocks(TExtRef ext
300305
}
301306

302307
Optional<SclReportItem> sclReportItem = removeFilteredSourceDas(extRef, sourceDas);
303-
//TODO: map to FCDA in issue #84 RSR-433 and remove print to console
308+
//TODO: #83 follow-up : grouping ExtRef by serviceType, iedName, ldInst, isBayInternal, and DA@fc
309+
// will be done by calculating DataSet Name in #84 RSR-433
310+
// TODO: map to FCDA in issue #84 RSR-433 and remove print to console
304311
String daToPrint = sourceDas.stream()
305312
.map(da -> da.getFc() + "#" + da.getDataAttributes())
306313
.collect(Collectors.joining(","));

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ public static Stream<Arguments> provideUpdateAllSourceDataSetsAndControlBlocksIg
113113
Arguments.of(named("should ignore binding internal to IED",
114114
new String[]{"test ignore internal binding"})),
115115
Arguments.of(named("should ignore extref with missing binding attributes",
116-
new String[]{"test ignore missing bindings attributes"}))
116+
new String[]{"test ignore missing bindings attributes"})),
117+
Arguments.of(named("should ignore extref when compas:Flow.FlowStatus is neither ACTIVE nor UNTESTED",
118+
new String[]{"test ignore when compas:Flow.FlowStatus is neither ACTIVE nor UNTESTED"}))
117119
);
118120
}
119121
}

sct-commons/src/test/resources/scd-extref-create-dataset-and-controlblocks/scd_create_dataset_and_controlblocks_success.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<compas:Flow dataStreamKey="test no daName and doName with instance number and SDO" FlowID="1" FlowKind="BAY_INTERNAL" ExtRefiedName="IED_NAME2" ExtReflnClass="ANCR" ExtRefldinst="LD_INST21" ExtReflnInst="1" ExtRefprefix="" FlowStatus="ACTIVE"/>
3737
<compas:Flow dataStreamKey="test ignore internal binding" FlowID="1" FlowKind="BAY_INTERNAL" ExtRefiedName="IED_NAME1" ExtReflnClass="ANCR" ExtRefldinst="LD_INST12" ExtReflnInst="1" ExtRefprefix="" FlowStatus="ACTIVE"/>
3838
<compas:Flow dataStreamKey="test ignore missing bindings attributes" FlowID="1" FlowKind="BAY_INTERNAL" ExtRefiedName="IED_NAME2" ExtReflnClass="ANCR" ExtRefldinst="LD_INST21" ExtReflnInst="1" ExtRefprefix="" FlowStatus="ACTIVE"/>
39+
<compas:Flow dataStreamKey="test ignore when compas:Flow.FlowStatus is neither ACTIVE nor UNTESTED" FlowID="1" FlowKind="BAY_EXTERNAL" ExtRefiedName="IED_NAME3" ExtReflnClass="ANCR" ExtRefldinst="LD_INST31" ExtReflnInst="1" ExtRefprefix="" FlowStatus="INACTIVE"/>
3940
</Private>
4041
<!-- bay internal -->
4142
<ExtRef desc="test bay internal" iedName="IED_NAME2" ldInst="LD_INST21" lnClass="ANCR" lnInst="1" doName="DoName" daName="daNameST" serviceType="GOOSE" intAddr="INT_ADDR11" pDO="Do11.sdo11" pDA="da11.bda111.bda112.bda113"/>
@@ -61,6 +62,9 @@
6162
<ExtRef desc="test ignore internal binding" iedName="IED_NAME1" ldInst="LD_INST12" lnClass="ANCR" lnInst="1" doName="DoName" intAddr="INT_ADDR11" pDO="Do11.sdo11" pDA="da11.bda111.bda112.bda113"/>
6263
<!-- ignore missing binding attributes -->
6364
<ExtRef desc="test ignore missing bindings attributes" intAddr="INT_ADDR11" pDO="Do11.sdo11" pDA="da11.bda111.bda112.bda113"/>
65+
<!-- ignore when compas:Flow.FlowStatus is INACTIVE -->
66+
<ExtRef desc="test ignore when compas:Flow.FlowStatus is neither ACTIVE nor UNTESTED" iedName="IED_NAME3" ldInst="LD_INST31" lnClass="ANCR" lnInst="1" doName="DoName" daName="daNameST" serviceType="GOOSE" intAddr="INT_ADDR11" pDO="Do11.sdo11" pDA="da11.bda111.bda112.bda113"/>
67+
6468
</Inputs>
6569
</LN0>
6670
</LDevice>

0 commit comments

Comments
 (0)