diff --git a/sct-commons/pom.xml b/sct-commons/pom.xml
index 3b9236fa4..c807d1237 100644
--- a/sct-commons/pom.xml
+++ b/sct-commons/pom.xml
@@ -195,6 +195,25 @@
false
+
+ cb_po
+
+ xjc
+
+
+
+
+
+
+ ${project.basedir}/src/main/resources/binding_configuration.xjb
+
+ org.lfenergy.compas.sct.commons.model.cb_po
+ true
+ false
+
+
diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/HmiService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/HmiService.java
index ef9477aa8..8969e7ad3 100644
--- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/HmiService.java
+++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/HmiService.java
@@ -5,21 +5,19 @@
package org.lfenergy.compas.sct.commons;
import org.lfenergy.compas.scl2007b4.model.SCL;
-import org.lfenergy.compas.scl2007b4.model.TFCDA;
import org.lfenergy.compas.sct.commons.api.HmiEditor;
+import org.lfenergy.compas.sct.commons.model.cb_po.PO;
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
import org.lfenergy.compas.sct.commons.scl.ied.IEDAdapter;
-import java.util.List;
-
public class HmiService implements HmiEditor {
@Override
- public void createAllHmiReportControlBlocks(SCL scd, List fcdas) {
+ public void createAllHmiReportControlBlocks(SCL scd, PO po) {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
sclRootAdapter.streamIEDAdapters()
.flatMap(IEDAdapter::streamLDeviceAdapters)
- .forEach(lDeviceAdapter -> lDeviceAdapter.createHmiReportControlBlocks(fcdas));
+ .forEach(lDeviceAdapter -> lDeviceAdapter.createHmiReportControlBlocks(po));
}
}
diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/HmiEditor.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/HmiEditor.java
index 548cac764..d90a55626 100644
--- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/HmiEditor.java
+++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/HmiEditor.java
@@ -5,10 +5,8 @@
package org.lfenergy.compas.sct.commons.api;
import org.lfenergy.compas.scl2007b4.model.SCL;
-import org.lfenergy.compas.scl2007b4.model.TFCDA;
import org.lfenergy.compas.scl2007b4.model.TReportControl;
-
-import java.util.List;
+import org.lfenergy.compas.sct.commons.model.cb_po.PO;
/**
* Service class that will be used to manage elements related to the HMI {@link TReportControl Report Control Blocks}.
@@ -20,7 +18,7 @@ public interface HmiEditor {
/**
* Create the DataSet and ReportControl Blocks for the HMI with the given FCDAs.
*
- * @param fcdas List of FCDA for which we must create the DataSet and ReportControl Blocks
+ * @param po object containing list of FCDA for which we must create the DataSet and ReportControl Blocks
*/
- void createAllHmiReportControlBlocks(SCL scd, List fcdas);
+ void createAllHmiReportControlBlocks(SCL scd, PO po);
}
diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceAdapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceAdapter.java
index 06d037c1f..329ad4836 100644
--- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceAdapter.java
+++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceAdapter.java
@@ -10,6 +10,8 @@
import org.lfenergy.compas.scl2007b4.model.*;
import org.lfenergy.compas.sct.commons.dto.*;
import org.lfenergy.compas.sct.commons.exception.ScdException;
+import org.lfenergy.compas.sct.commons.model.cb_po.PO;
+import org.lfenergy.compas.sct.commons.model.cb_po.TFCDAFilter;
import org.lfenergy.compas.sct.commons.scl.SclElementAdapter;
import org.lfenergy.compas.sct.commons.scl.dtt.DataTypeTemplateAdapter;
import org.lfenergy.compas.sct.commons.scl.ied.ControlBlockAdapter;
@@ -81,20 +83,20 @@ public LDeviceAdapter(IEDAdapter parentAdapter, TLDevice currentElem) {
* Create DataSet and ReportControl Blocks for the HMI with the given FCDAs.
* DataSet and ReportControl are created in LN0, even if FCDA refers to another LN.
*
- * @param fcdas List of FCDA for which we must create the DataSet and ReportControl
+ * @param po object containing list of FCDA for which we must create the DataSet and ReportControl
*/
- public void createHmiReportControlBlocks(List fcdas) {
+ public void createHmiReportControlBlocks(PO po) {
LN0Adapter ln0 = getLN0Adapter();
if (!ln0.getDaiModStValValue().map(ActiveStatus::fromValue).map(ActiveStatus.ON::equals).orElse(false)) return;
- fcdas.stream()
+ po.getFCDAs().getFCDA().stream()
.filter(fcda -> getInst().equals(fcda.getLdInst()) && fcda.isSetLnClass())
- .forEach(fcda -> (fcda.getLnClass().get(0).equals(TLLN0Enum.LLN_0.value()) ?
+ .forEach(fcda -> (fcda.getLnClass().equals(TLLN0Enum.LLN_0.value()) ?
Optional.of(ln0) // ln0 Mod stVal "ON" has already been checked, no need to check it again
:
- findLnAdapter(fcda.getLnClass().get(0), fcda.getLnInst(), fcda.getPrefix()).filter(lnAdapter -> lnAdapter.getDaiModStValValue().map(ActiveStatus::fromValue).map(ActiveStatus.ON::equals).orElse(true)))
- .map(sourceLn -> sourceLn.getDAI(new DataAttributeRef(fcda), false))
- .filter(das -> das.stream().anyMatch(da -> fcda.getFc() == da.getFc())) // getDAI does not filter on DA.
- .ifPresent(dataAttributeRefs -> createHmiReportCB(ln0, fcda)));
+ findLnAdapter(fcda.getLnClass(), fcda.getLnInst(), fcda.getPrefix()).filter(lnAdapter -> lnAdapter.getDaiModStValValue().map(ActiveStatus::fromValue).map(ActiveStatus.ON::equals).orElse(true)))
+ .map(sourceLn -> sourceLn.getDAI(new DataAttributeRef(toFCDA(fcda)), false))
+ .filter(das -> das.stream().anyMatch(da -> TFCEnum.fromValue(fcda.getFc().value()) == da.getFc())) // getDAI does not filter on DA.
+ .ifPresent(dataAttributeRefs -> createHmiReportCB(ln0, toFCDA(fcda))));
}
private void createHmiReportCB(LN0Adapter ln0, TFCDA fcda) {
@@ -514,4 +516,15 @@ public List getExtRefBayReferenceForActifLDEPF(fi
return extRefBayReferenceList;
}
+ private TFCDA toFCDA(TFCDAFilter tfcdaFilter) {
+ TFCDA tfcda = new TFCDA();
+ tfcda.setLdInst(tfcdaFilter.getLdInst());
+ tfcda.getLnClass().add(tfcdaFilter.getLnClass());
+ tfcda.setPrefix(tfcdaFilter.getPrefix());
+ tfcda.setLnInst(tfcdaFilter.getLnInst());
+ tfcda.setDoName(tfcdaFilter.getDoName());
+ tfcda.setFc(TFCEnum.fromValue(tfcdaFilter.getFc().value()));
+ return tfcda;
+ }
+
}
diff --git a/sct-commons/src/main/resources/xsd/CB_REPORT_SUPERVISION_Config_file.xsd b/sct-commons/src/main/resources/xsd/CB_REPORT_SUPERVISION_Config_file.xsd
new file mode 100644
index 000000000..8f4264086
--- /dev/null
+++ b/sct-commons/src/main/resources/xsd/CB_REPORT_SUPERVISION_Config_file.xsd
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/HmiServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/HmiServiceTest.java
index b468c1560..1a041bcb4 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/HmiServiceTest.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/HmiServiceTest.java
@@ -4,23 +4,25 @@
package org.lfenergy.compas.sct.commons;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.lfenergy.compas.scl2007b4.model.*;
+import org.lfenergy.compas.sct.commons.model.cb_po.FCDAs;
+import org.lfenergy.compas.sct.commons.model.cb_po.PO;
+import org.lfenergy.compas.sct.commons.model.cb_po.TFCDAFilter;
+import org.lfenergy.compas.sct.commons.model.cb_po.Tfc;
import org.lfenergy.compas.sct.commons.scl.ied.DataSetAdapter;
import org.lfenergy.compas.sct.commons.scl.ln.LN0Adapter;
import org.lfenergy.compas.sct.commons.scl.ln.LNAdapter;
import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller;
-import org.lfenergy.compas.sct.commons.util.CommonConstants;
import org.lfenergy.compas.sct.commons.util.ActiveStatus;
+import org.lfenergy.compas.sct.commons.util.CommonConstants;
import org.mockito.InjectMocks;
import org.mockito.junit.jupiter.MockitoExtension;
-import java.util.List;
-
import static org.assertj.core.api.Assertions.assertThat;
import static org.lfenergy.compas.sct.commons.testhelpers.SclHelper.*;
-import static org.lfenergy.compas.sct.commons.util.SclConstructorHelper.newFcda;
@ExtendWith(MockitoExtension.class)
class HmiServiceTest {
@@ -28,18 +30,27 @@ class HmiServiceTest {
@InjectMocks
HmiService hmiService;
+ private final PO po = new PO();
+
+ @BeforeEach
+ void setUp() {
+ FCDAs fcdAs = new FCDAs();
+ po.setFCDAs(fcdAs);
+ }
+
@Test
void createAllIhmReportControlBlocks_with_fc_ST_should_create_dataset_and_controlblock() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml");
- TFCDA fcda = newFcda("LdInst11", "ANCR", "1", null, "DoName1", null, TFCEnum.ST);
+ TFCDAFilter tfcdaFilter = createFCDAFilter("LdInst11", "ANCR", "1", null, "DoName1", Tfc.ST);
+ po.getFCDAs().getFCDA().add(tfcdaFilter);
// When
- hmiService.createAllHmiReportControlBlocks(scd, List.of(fcda));
+ hmiService.createAllHmiReportControlBlocks(scd, po);
// Then
// Check DataSet is created
DataSetAdapter dataSet = findDataSet(scd, "IedName1", "LdInst11", "DS_LDINST11_DQPO");
assertThat(dataSet.getCurrentElem().getFCDA()).hasSize(1).first()
- .usingRecursiveComparison().isEqualTo(fcda);
+ .usingRecursiveComparison().isEqualTo(toFCDA(tfcdaFilter));
// Check ControlBlock is created
LN0Adapter ln0 = findLn0(scd, "IedName1", "LdInst11");
assertThat(ln0.getTControlsByType(TReportControl.class)).hasSize(1);
@@ -58,14 +69,15 @@ void createAllIhmReportControlBlocks_with_fc_ST_should_create_dataset_and_contro
void createAllIhmReportControlBlocks_with_fc_MX_should_create_dataset_and_controlblock() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml");
- TFCDA fcda = newFcda("LdInst11", "PVOC", "1", null, "DoName2", null, TFCEnum.MX);
+ TFCDAFilter tfcdaFilter = createFCDAFilter("LdInst11", "PVOC", "1", null, "DoName2", Tfc.MX);
+ po.getFCDAs().getFCDA().add(tfcdaFilter);
// When
- hmiService.createAllHmiReportControlBlocks(scd, List.of(fcda));
+ hmiService.createAllHmiReportControlBlocks(scd, po);
// Then
// Check DataSet is created
DataSetAdapter dataSet = findDataSet(scd, "IedName1", "LdInst11", "DS_LDINST11_CYPO");
assertThat(dataSet.getCurrentElem().getFCDA()).hasSize(1).first()
- .usingRecursiveComparison().isEqualTo(fcda);
+ .usingRecursiveComparison().isEqualTo(toFCDA(tfcdaFilter));
// Check ControlBlock is created
LN0Adapter ln0 = findLn0(scd, "IedName1", "LdInst11");
assertThat(ln0.getTControlsByType(TReportControl.class)).hasSize(1);
@@ -85,14 +97,15 @@ void createAllIhmReportControlBlocks_with_fc_MX_should_create_dataset_and_contro
void createAllIhmReportControlBlocks_with_FCDA_on_ln0_should_create_dataset_and_controlblock() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml");
- TFCDA fcda = newFcda("LdInst11", "LLN0", null, null, "DoName0", null, TFCEnum.ST);
+ TFCDAFilter tfcdaFilter = createFCDAFilter("LdInst11", "LLN0", null, null, "DoName0", Tfc.ST);
+ po.getFCDAs().getFCDA().add(tfcdaFilter);
// When
- hmiService.createAllHmiReportControlBlocks(scd, List.of(fcda));
+ hmiService.createAllHmiReportControlBlocks(scd, po);
// Then
// Check DataSet is created
DataSetAdapter dataSet = findDataSet(scd, "IedName1", "LdInst11", "DS_LDINST11_DQPO");
assertThat(dataSet.getCurrentElem().getFCDA()).hasSize(1).first()
- .usingRecursiveComparison().isEqualTo(fcda);
+ .usingRecursiveComparison().isEqualTo(toFCDA(tfcdaFilter));
// Check ControlBlock is created
LN0Adapter ln0 = findLn0(scd, "IedName1", "LdInst11");
assertThat(ln0.getTControlsByType(TReportControl.class)).hasSize(1);
@@ -113,14 +126,15 @@ void createAllIhmReportControlBlocks_when_lDevice_ON_but_LN_Mod_StVal_missing_sh
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml");
LNAdapter ln = findLn(scd, "IedName1", "LdInst11", "ANCR", "1", null);
ln.getCurrentElem().unsetDOI();
- TFCDA fcda = newFcda("LdInst11", "ANCR", "1", null, "DoName1", null, TFCEnum.ST);
+ TFCDAFilter tfcdaFilter = createFCDAFilter("LdInst11", "ANCR", "1", null, "DoName1", Tfc.ST);
+ po.getFCDAs().getFCDA().add(tfcdaFilter);
// When
- hmiService.createAllHmiReportControlBlocks(scd, List.of(fcda));
+ hmiService.createAllHmiReportControlBlocks(scd, po);
// Then
// Check DataSet is created
DataSetAdapter dataSet = findDataSet(scd, "IedName1", "LdInst11", "DS_LDINST11_DQPO");
assertThat(dataSet.getCurrentElem().getFCDA()).hasSize(1).first()
- .usingRecursiveComparison().isEqualTo(fcda);
+ .usingRecursiveComparison().isEqualTo(toFCDA(tfcdaFilter));
// Check ControlBlock is created
LN0Adapter ln0 = findLn0(scd, "IedName1", "LdInst11");
assertThat(ln0.getTControlsByType(TReportControl.class)).hasSize(1);
@@ -137,9 +151,10 @@ void createAllIhmReportControlBlocks_when_lDevice_ON_but_LN_Mod_StVal_OFF_should
LNAdapter ln = findLn(scd, "IedName1", "LdInst11", "ANCR", "1", null);
ln.getDOIAdapterByName(CommonConstants.MOD_DO_NAME).getDataAdapterByName(CommonConstants.STVAL_DA_NAME).setVal("off");
assertThat(ln.getDaiModStValValue()).hasValue("off");
- TFCDA fcda = newFcda("LdInst11", "ANCR", "1", null, "DoName1", null, TFCEnum.ST);
+ TFCDAFilter tfcdaFilter = createFCDAFilter("LdInst11", "ANCR", "1", null, "DoName1", Tfc.ST);
+ po.getFCDAs().getFCDA().add(tfcdaFilter);
// When
- hmiService.createAllHmiReportControlBlocks(scd, List.of(fcda));
+ hmiService.createAllHmiReportControlBlocks(scd, po);
// Then
assertThat(streamAllDataSets(scd)).isEmpty();
assertThat(streamAllControlBlocks(scd, TReportControl.class)).isEmpty();
@@ -152,9 +167,10 @@ void createAllIhmReportControlBlocks_when_lDevice_OFF_should_not_create_dataset(
LN0Adapter ln0 = findLn0(scd, "IedName1", "LdInst11");
ln0.getDOIAdapterByName(CommonConstants.MOD_DO_NAME).getDataAdapterByName(CommonConstants.STVAL_DA_NAME).setVal("off");
assertThat(findLDevice(scd, "IedName1", "LdInst11").getLDeviceStatus()).hasValue(ActiveStatus.OFF.getValue());
- TFCDA fcda = newFcda("LdInst11", "ANCR", "1", null, "DoName1", null, TFCEnum.ST);
+ TFCDAFilter tfcdaFilter = createFCDAFilter("LdInst11", "ANCR", "1", null, "DoName1", Tfc.ST);
+ po.getFCDAs().getFCDA().add(tfcdaFilter);
// When
- hmiService.createAllHmiReportControlBlocks(scd, List.of(fcda));
+ hmiService.createAllHmiReportControlBlocks(scd, po);
// Then
assertThat(streamAllDataSets(scd)).isEmpty();
assertThat(streamAllControlBlocks(scd, TReportControl.class)).isEmpty();
@@ -167,12 +183,35 @@ void createAllIhmReportControlBlocks_when_LDevice_has_no_status_should_not_creat
LN0Adapter ln0 = findLn0(scd, "IedName1", "LdInst11");
ln0.getDOIAdapterByName(CommonConstants.MOD_DO_NAME).getDataAdapterByName(CommonConstants.STVAL_DA_NAME).getCurrentElem().unsetVal();
assertThat(findLDevice(scd, "IedName1", "LdInst11").getLDeviceStatus()).isEmpty();
- TFCDA fcda = newFcda("LdInst11", "ANCR", "1", null, "DoName1", null, TFCEnum.ST);
+ TFCDAFilter tfcdaFilter = createFCDAFilter("LdInst11", "ANCR", "1", null, "DoName1", Tfc.ST);
+ po.getFCDAs().getFCDA().add(tfcdaFilter);
// When
- hmiService.createAllHmiReportControlBlocks(scd, List.of(fcda));
+ hmiService.createAllHmiReportControlBlocks(scd, po);
// Then
assertThat(streamAllDataSets(scd)).isEmpty();
assertThat(streamAllControlBlocks(scd, TReportControl.class)).isEmpty();
}
+ private static TFCDAFilter createFCDAFilter(String ldInst, String lnClass, String lnInst, String prefix, String doName, Tfc tfc) {
+ TFCDAFilter tfcdaFilter = new TFCDAFilter();
+ tfcdaFilter.setLdInst("LdInst11");
+ tfcdaFilter.setLnClass(lnClass);
+ tfcdaFilter.setPrefix(null);
+ tfcdaFilter.setDoName(doName);
+ tfcdaFilter.setLnInst(lnInst);
+ tfcdaFilter.setFc(tfc);
+ return tfcdaFilter;
+ }
+
+ private static TFCDA toFCDA(TFCDAFilter tfcdaFilter) {
+ TFCDA tfcda = new TFCDA();
+ tfcda.setLdInst(tfcdaFilter.getLdInst());
+ tfcda.getLnClass().add(tfcdaFilter.getLnClass());
+ tfcda.setPrefix(tfcdaFilter.getPrefix());
+ tfcda.setLnInst(tfcdaFilter.getLnInst());
+ tfcda.setDoName(tfcdaFilter.getDoName());
+ tfcda.setFc(TFCEnum.fromValue(tfcdaFilter.getFc().value()));
+ return tfcda;
+ }
+
}