Skip to content

Commit 5804ec2

Browse files
committed
feat(#359): use a POJO for allowed FCDA list in CB Report for HMI creation
Signed-off-by: Aliou DIAITE <[email protected]>
1 parent b4d97c6 commit 5804ec2

File tree

8 files changed

+188
-112
lines changed

8 files changed

+188
-112
lines changed

sct-commons/pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,25 @@
195195
<clearOutputDir>false</clearOutputDir>
196196
</configuration>
197197
</execution>
198+
<execution>
199+
<id>cb_po</id>
200+
<goals>
201+
<goal>xjc</goal>
202+
</goals>
203+
<configuration>
204+
<sources>
205+
<source>
206+
${project.basedir}/src/main/resources/xsd/CB_REPORT_SUPERVISION_Config_file.xsd
207+
</source>
208+
</sources>
209+
<xjbSources>
210+
<xjbSource>${project.basedir}/src/main/resources/binding_configuration.xjb</xjbSource>
211+
</xjbSources>
212+
<packageName>org.lfenergy.compas.sct.commons.model.cb_po</packageName>
213+
<noPackageLevelAnnotations>true</noPackageLevelAnnotations>
214+
<clearOutputDir>false</clearOutputDir>
215+
</configuration>
216+
</execution>
198217
</executions>
199218
</plugin>
200219
<plugin>

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,19 @@
55
package org.lfenergy.compas.sct.commons;
66

77
import org.lfenergy.compas.scl2007b4.model.SCL;
8-
import org.lfenergy.compas.scl2007b4.model.TFCDA;
98
import org.lfenergy.compas.sct.commons.api.HmiEditor;
9+
import org.lfenergy.compas.sct.commons.model.cb_po.PO;
1010
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
1111
import org.lfenergy.compas.sct.commons.scl.ied.IEDAdapter;
1212

13-
import java.util.List;
14-
1513
public class HmiService implements HmiEditor {
1614

1715
@Override
18-
public void createAllHmiReportControlBlocks(SCL scd, List<TFCDA> fcdas) {
16+
public void createAllHmiReportControlBlocks(SCL scd, PO po) {
1917
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
2018
sclRootAdapter.streamIEDAdapters()
2119
.flatMap(IEDAdapter::streamLDeviceAdapters)
22-
.forEach(lDeviceAdapter -> lDeviceAdapter.createHmiReportControlBlocks(fcdas));
20+
.forEach(lDeviceAdapter -> lDeviceAdapter.createHmiReportControlBlocks(po));
2321
}
2422

2523
}

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/HmiEditor.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
package org.lfenergy.compas.sct.commons.api;
66

77
import org.lfenergy.compas.scl2007b4.model.SCL;
8-
import org.lfenergy.compas.scl2007b4.model.TFCDA;
98
import org.lfenergy.compas.scl2007b4.model.TReportControl;
10-
11-
import java.util.List;
9+
import org.lfenergy.compas.sct.commons.model.cb_po.PO;
1210

1311
/**
1412
* Service class that will be used to manage elements related to the HMI {@link TReportControl <em>Report Control Blocks</em>}.
@@ -20,7 +18,7 @@ public interface HmiEditor {
2018
/**
2119
* Create the DataSet and ReportControl Blocks for the HMI with the given FCDAs.
2220
*
23-
* @param fcdas List of FCDA for which we must create the DataSet and ReportControl Blocks
21+
* @param po object containing list of FCDA for which we must create the DataSet and ReportControl Blocks
2422
*/
25-
void createAllHmiReportControlBlocks(SCL scd, List<TFCDA> fcdas);
23+
void createAllHmiReportControlBlocks(SCL scd, PO po);
2624
}

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

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import org.lfenergy.compas.scl2007b4.model.*;
1111
import org.lfenergy.compas.sct.commons.dto.*;
1212
import org.lfenergy.compas.sct.commons.exception.ScdException;
13+
import org.lfenergy.compas.sct.commons.model.cb_po.PO;
14+
import org.lfenergy.compas.sct.commons.model.cb_po.TFCDAFilter;
1315
import org.lfenergy.compas.sct.commons.scl.SclElementAdapter;
1416
import org.lfenergy.compas.sct.commons.scl.dtt.DataTypeTemplateAdapter;
1517
import org.lfenergy.compas.sct.commons.scl.ied.ControlBlockAdapter;
@@ -81,20 +83,20 @@ public LDeviceAdapter(IEDAdapter parentAdapter, TLDevice currentElem) {
8183
* Create DataSet and ReportControl Blocks for the HMI with the given FCDAs.
8284
* DataSet and ReportControl are created in LN0, even if FCDA refers to another LN.
8385
*
84-
* @param fcdas List of FCDA for which we must create the DataSet and ReportControl
86+
* @param po object containing list of FCDA for which we must create the DataSet and ReportControl
8587
*/
86-
public void createHmiReportControlBlocks(List<TFCDA> fcdas) {
88+
public void createHmiReportControlBlocks(PO po) {
8789
LN0Adapter ln0 = getLN0Adapter();
8890
if (!ln0.getDaiModStValValue().map(ActiveStatus::fromValue).map(ActiveStatus.ON::equals).orElse(false)) return;
89-
fcdas.stream()
90-
.filter(fcda -> getInst().equals(fcda.getLdInst()) && fcda.isSetLnClass())
91-
.forEach(fcda -> (fcda.getLnClass().get(0).equals(TLLN0Enum.LLN_0.value()) ?
91+
po.getFCDAs().getFCDA().stream()
92+
.filter(tfcdaFilter -> getInst().equals(tfcdaFilter.getLdInst()) && tfcdaFilter.isSetLnClass())
93+
.forEach(tfcdaFilter -> (tfcdaFilter.getLnClass().equals(TLLN0Enum.LLN_0.value()) ?
9294
Optional.of(ln0) // ln0 Mod stVal "ON" has already been checked, no need to check it again
9395
:
94-
findLnAdapter(fcda.getLnClass().get(0), fcda.getLnInst(), fcda.getPrefix()).filter(lnAdapter -> lnAdapter.getDaiModStValValue().map(ActiveStatus::fromValue).map(ActiveStatus.ON::equals).orElse(true)))
95-
.map(sourceLn -> sourceLn.getDAI(new DataAttributeRef(fcda), false))
96-
.filter(das -> das.stream().anyMatch(da -> fcda.getFc() == da.getFc())) // getDAI does not filter on DA.
97-
.ifPresent(dataAttributeRefs -> createHmiReportCB(ln0, fcda)));
96+
findLnAdapter(tfcdaFilter.getLnClass(), tfcdaFilter.getLnInst(), tfcdaFilter.getPrefix()).filter(lnAdapter -> lnAdapter.getDaiModStValValue().map(ActiveStatus::fromValue).map(ActiveStatus.ON::equals).orElse(true)))
97+
.map(sourceLn -> sourceLn.getDAI(new DataAttributeRef(toFCDA(tfcdaFilter)), false))
98+
.filter(das -> das.stream().anyMatch(da -> TFCEnum.fromValue(tfcdaFilter.getFc().value()) == da.getFc())) // getDAI does not filter on DA.
99+
.ifPresent(dataAttributeRefs -> createHmiReportCB(ln0, toFCDA(tfcdaFilter))));
98100
}
99101

100102
private void createHmiReportCB(LN0Adapter ln0, TFCDA fcda) {
@@ -514,4 +516,15 @@ public List<ExtRefInfo.ExtRefBayReference> getExtRefBayReferenceForActifLDEPF(fi
514516
return extRefBayReferenceList;
515517
}
516518

519+
private TFCDA toFCDA(TFCDAFilter tfcdaFilter) {
520+
TFCDA tfcda = new TFCDA();
521+
tfcda.setLdInst(tfcdaFilter.getLdInst());
522+
tfcda.getLnClass().add(tfcdaFilter.getLnClass());
523+
tfcda.setPrefix(tfcdaFilter.getPrefix());
524+
tfcda.setLnInst(tfcdaFilter.getLnInst());
525+
tfcda.setDoName(tfcdaFilter.getDoName());
526+
tfcda.setFc(TFCEnum.fromValue(tfcdaFilter.getFc().value()));
527+
return tfcda;
528+
}
529+
517530
}

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/FcdaCsvHelper.java

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,25 @@
44

55
package org.lfenergy.compas.sct.commons.util;
66

7-
import com.opencsv.bean.CsvBindByPosition;
87
import lombok.Getter;
98
import org.lfenergy.compas.scl2007b4.model.SCL;
10-
import org.lfenergy.compas.scl2007b4.model.TFCDA;
11-
import org.lfenergy.compas.scl2007b4.model.TFCEnum;
129
import org.lfenergy.compas.sct.commons.dto.FcdaForDataSetsCreation;
1310

1411
import java.io.Reader;
1512
import java.util.HashSet;
16-
import java.util.List;
1713
import java.util.Set;
1814

1915
/**
2016
* This class is a helper method to load FCDA from a CSV files for use with
21-
* {@link org.lfenergy.compas.sct.commons.HmiService#createAllHmiReportControlBlocks(SCL, List)}
22-
* {@link org.lfenergy.compas.sct.commons.ExtRefService#createDataSetAndControlBlocks(SCL, Set)}
23-
* {@link org.lfenergy.compas.sct.commons.ExtRefService#createDataSetAndControlBlocks(SCL, String, Set)}
24-
* {@link org.lfenergy.compas.sct.commons.ExtRefService#createDataSetAndControlBlocks(SCL, String, String, Set)}
17+
* {@link org.lfenergy.compas.sct.commons.ControlBlockService#createDataSetAndControlBlocks(SCL, Set)}
18+
* {@link org.lfenergy.compas.sct.commons.ControlBlockService#createDataSetAndControlBlocks(SCL, String, Set)}
19+
* {@link org.lfenergy.compas.sct.commons.ControlBlockService#createDataSetAndControlBlocks(SCL, String, String, Set)}
2520
* Use the getter to access the list of parsed FCDA.
2621
*
2722
* @see CsvUtils
2823
*/
2924
public class FcdaCsvHelper {
3025

31-
@Getter
32-
private final List<TFCDA> fcdaForHmiReportControls;
33-
3426
@Getter
3527
private final Set<FcdaForDataSetsCreation> fcdaForDataSets;
3628

@@ -39,46 +31,11 @@ public class FcdaCsvHelper {
3931
* Provide the CSV files as a Reader. For example, you can create a reader like this :
4032
* <code>new InputStreamReader(getClass().getClassLoader().getResourceAsStream(fileName), StandardCharsets.UTF_8);</code>
4133
*
42-
* @param csvSourceForHmiReportControl a reader that provides the FCDA datas for HMI ReportControl Blocks as CSV
4334
* @param csvSourceForDataSetAndControlBlocks a reader that provides the FCDA datas for DataSets and Control Blocks creation as CSV
4435
*/
45-
public FcdaCsvHelper(Reader csvSourceForHmiReportControl, Reader csvSourceForDataSetAndControlBlocks) {
46-
fcdaForHmiReportControls = CsvUtils.parseRows(csvSourceForHmiReportControl, FcdaForHmiReportControl.class).stream()
47-
.map(fcdaForHmiReportControl ->
48-
SclConstructorHelper.newFcda(fcdaForHmiReportControl.ldInst, fcdaForHmiReportControl.lnClass, fcdaForHmiReportControl.lnInst, fcdaForHmiReportControl.prefix, fcdaForHmiReportControl.doName, null, fcdaForHmiReportControl.fc)
49-
)
50-
.toList();
36+
public FcdaCsvHelper(Reader csvSourceForDataSetAndControlBlocks) {
5137
fcdaForDataSets = new HashSet<>(CsvUtils.parseRows(csvSourceForDataSetAndControlBlocks, FcdaForDataSetsCreation.class));
5238
}
5339

54-
public static class FcdaForHmiReportControl {
55-
@CsvBindByPosition(position = 0)
56-
private String ldInst;
57-
@CsvBindByPosition(position = 1)
58-
private String prefix;
59-
@CsvBindByPosition(position = 2)
60-
private String lnClass;
61-
@CsvBindByPosition(position = 3)
62-
private String lnInst;
63-
@CsvBindByPosition(position = 4)
64-
private String doName;
65-
@CsvBindByPosition(position = 5)
66-
private TFCEnum fc;
67-
}
68-
69-
/* @NoArgsConstructor
70-
@AllArgsConstructor
71-
@Getter
72-
@EqualsAndHashCode
73-
public static class FcdaForDataSets {
74-
@CsvBindByPosition(position = 0)
75-
private String lnClass;
76-
@CsvBindByPosition(position = 1)
77-
private String doName;
78-
@CsvBindByPosition(position = 2)
79-
private String daName;
80-
@CsvBindByPosition(position = 3)
81-
private String fc;
82-
} */
8340

8441
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
SPDX-FileCopyrightText: 2023 RTE FRANCE
4+
SPDX-License-Identifier: Apache-2.0
5+
-->
6+
<xs:schema xmlns="http://www.rte-france.com"
7+
xmlns:xs="http://www.w3.org/2001/XMLSchema"
8+
targetNamespace="http://www.rte-france.com" elementFormDefault="qualified" attributeFormDefault="unqualified"
9+
version="1">
10+
11+
<xs:element name="PO">
12+
<xs:complexType>
13+
<xs:sequence>
14+
<xs:element ref="History"/>
15+
<xs:element ref="Version"/>
16+
<xs:element ref="FCDAs"/>
17+
</xs:sequence>
18+
</xs:complexType>
19+
</xs:element>
20+
21+
<xs:element name="History">
22+
<xs:complexType>
23+
<xs:sequence>
24+
<xs:element name="Hitem" type="tHitem" maxOccurs="unbounded"/>
25+
</xs:sequence>
26+
</xs:complexType>
27+
</xs:element>
28+
29+
<xs:complexType name="tHitem" mixed="true">
30+
<xs:attribute name="version" type="xs:normalizedString" use="required"/>
31+
<xs:attribute name="when" type="xs:normalizedString" use="required"/>
32+
<xs:attribute name="who" type="xs:normalizedString"/>
33+
<xs:attribute name="what" type="xs:normalizedString"/>
34+
</xs:complexType>
35+
36+
<xs:element name="Version">
37+
<xs:complexType>
38+
<xs:sequence>
39+
<xs:element name="SystemVersion" type="tSystemVersion" maxOccurs="unbounded"/>
40+
</xs:sequence>
41+
</xs:complexType>
42+
</xs:element>
43+
44+
<xs:complexType name="tSystemVersion" mixed="true">
45+
<xs:attribute name="MainSystemVersion" type="xs:normalizedString" use="required"/>
46+
</xs:complexType>
47+
48+
<xs:element name="FCDAs">
49+
<xs:complexType>
50+
<xs:sequence>
51+
<xs:element name="FCDA" type="tFCDAFilter" maxOccurs="unbounded"/>
52+
</xs:sequence>
53+
</xs:complexType>
54+
</xs:element>
55+
56+
<xs:complexType name="tFCDAFilter">
57+
<xs:attribute name="ldInst" type="xs:string" use="required"/>
58+
<xs:attribute name="prefix" type="xs:string" use="optional"/>
59+
<xs:attribute name="lnClass" type="xs:string" use="required"/>
60+
<xs:attribute name="lnInst" type="xs:string" use="required"/>
61+
<xs:attribute name="doName" type="xs:string" use="required"/>
62+
<xs:attribute name="fc" type="tfc" use="required"/>
63+
</xs:complexType>
64+
65+
<xs:simpleType name="tfc">
66+
<xs:restriction base="xs:string">
67+
<xs:enumeration value="ST"/>
68+
<xs:enumeration value="MX"/>
69+
</xs:restriction>
70+
</xs:simpleType>
71+
72+
</xs:schema>

0 commit comments

Comments
 (0)