Skip to content

Commit c5e74c7

Browse files
authored
Merge pull request #275 from com-pas/develop
New Release
2 parents 6cb2401 + c4c1c2d commit c5e74c7

File tree

66 files changed

+1282
-386
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1282
-386
lines changed

pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@
3030

3131
<properties>
3232
<java.version>17</java.version>
33-
<compas.core.version>local-SNAPSHOT</compas.core.version>
3433
<maven.compiler.target>${java.version}</maven.compiler.target>
3534
<maven.compiler.source>${java.version}</maven.compiler.source>
3635
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3736
<sonar.coverage.exclusions>sct-coverage/**</sonar.coverage.exclusions>
3837
<aggregate.report.dir>../sct-coverage/target/site/jacoco-aggregate/jacoco.xml</aggregate.report.dir>
3938
<sonar.coverage.jacoco.xmlReportPaths>${basedir}/${aggregate.report.dir}</sonar.coverage.jacoco.xmlReportPaths>
40-
<compas-core.version>0.13.0</compas-core.version>
39+
<compas-core.version>0.14.0</compas-core.version>
4140
<compas-scl-xsd.version>0.0.4</compas-scl-xsd.version>
4241
<maven.plugin.javadoc>3.4.1</maven.plugin.javadoc>
4342
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>

sct-app/src/test/resources/std_1.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
<compas:SystemVersion MainSystemVersion="01.00" MinorSystemVersion="009.001.001"/>
3535
</Private>
3636
<Private type="COMPAS-ICDHeader">
37-
<compas:ICDHeader IEDType="SCU" ICDSystemVersionUUID="b4f8089e-4170-47f1-b6ad-dd1f50885518" VendorName="RTE" IEDredundancy="A" IEDmodel="ICDfromModeling" hwRev="01.00.00" swRev="01.00.00" headerId="f8dbc8c1-2db7-4652-a9d6-0b414bdeccfa" headerVersion="01.00.00" headerRevision="01.00.00"/>
37+
<compas:ICDHeader IEDType="SCU" ICDSystemVersionUUID="b4f8089e-4170-47f1-b6ad-dd1f50885518"
38+
IEDSystemVersioninstance="1" IEDSubstationinstance="1" VendorName="RTE" IEDredundancy="A"
39+
IEDmodel="ICDfromModeling" hwRev="01.00.00" swRev="01.00.00"
40+
headerId="f8dbc8c1-2db7-4652-a9d6-0b414bdeccfa" headerVersion="01.00.00"
41+
headerRevision="01.00.00"/>
3842
</Private>
3943
<Services nameLength="64">
4044
<ConfLNs fixPrefix="true" fixLnInst="true"/>

sct-app/src/test/resources/std_2.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
<compas:SystemVersion MainSystemVersion="01.00" MinorSystemVersion="009.001.001"/>
3535
</Private>
3636
<Private type="COMPAS-ICDHeader">
37-
<compas:ICDHeader IEDType="PDB" ICDSystemVersionUUID="ad27d262-7c90-46df-b480-68088f9fe8a4" VendorName="RTE" IEDredundancy="A" IEDmodel="ICDfromModeling" hwRev="01.00.00" swRev="01.00.00" headerId="6b4d51eb-c391-4eef-b118-f516bc09f20c" headerVersion="01.00.00" headerRevision="01.00.00"/>
37+
<compas:ICDHeader IEDType="PDB" ICDSystemVersionUUID="ad27d262-7c90-46df-b480-68088f9fe8a4"
38+
IEDSubstationinstance="1" IEDSystemVersioninstance="1" VendorName="RTE" IEDredundancy="A"
39+
IEDmodel="ICDfromModeling" hwRev="01.00.00" swRev="01.00.00"
40+
headerId="6b4d51eb-c391-4eef-b118-f516bc09f20c" headerVersion="01.00.00"
41+
headerRevision="01.00.00"/>
3842
</Private>
3943
<Services nameLength="64">
4044
<ConfLNs fixPrefix="true" fixLnInst="true"/>

sct-app/src/test/resources/std_3.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
<compas:SystemVersion MainSystemVersion="01.00" MinorSystemVersion="009.001.001"/>
3535
</Private>
3636
<Private type="COMPAS-ICDHeader">
37-
<compas:ICDHeader IEDType="BCU" ICDSystemVersionUUID="ed36220c-5577-4f0c-aaef-c6efa9f7d7c8" VendorName="RTE" IEDredundancy="A" IEDmodel="ICDfromModeling" hwRev="01.00.00" swRev="01.00.00" headerId="9aea4c6f-7ab8-4341-8d84-14c17d73a57d" headerVersion="01.00.00" headerRevision="01.00.00"/>
37+
<compas:ICDHeader IEDType="BCU" ICDSystemVersionUUID="ed36220c-5577-4f0c-aaef-c6efa9f7d7c8"
38+
IEDSubstationinstance="1" IEDSystemVersioninstance="1" VendorName="RTE" IEDredundancy="A"
39+
IEDmodel="ICDfromModeling" hwRev="01.00.00" swRev="01.00.00"
40+
headerId="9aea4c6f-7ab8-4341-8d84-14c17d73a57d" headerVersion="01.00.00"
41+
headerRevision="01.00.00"/>
3842
</Private>
3943
<Services nameLength="64">
4044
<ConfLNs fixPrefix="true" fixLnInst="true"/>

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/ControlBlockTarget.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import java.util.Objects;
1212

1313
import static org.lfenergy.compas.scl2007b4.model.TControlWithIEDName.IEDName;
14-
import static org.lfenergy.compas.sct.commons.util.Utils.emptyIfBlank;
15-
import static org.lfenergy.compas.sct.commons.util.Utils.nullIfBlank;
1614

1715
/**
1816
* Record that hold the data for TClientLN and TControlWithIEDName.IEDName which have the same fields.
@@ -50,8 +48,8 @@ public TClientLN toTClientLn() {
5048
newTClientLn.getLnClass().add(lnClass);
5149
}
5250
// LnInst is required on TClientLN, so it cannot be null, but it can be empty
53-
newTClientLn.setLnInst(emptyIfBlank(lnInst));
54-
newTClientLn.setPrefix(nullIfBlank(prefix));
51+
newTClientLn.setLnInst(StringUtils.trimToEmpty(lnInst));
52+
newTClientLn.setPrefix(StringUtils.trimToNull(prefix));
5553
newTClientLn.setDesc(desc);
5654
return newTClientLn;
5755
}
@@ -69,8 +67,8 @@ public IEDName toIedName() {
6967
newIedName.getLnClass().add(lnClass);
7068
}
7169
// LnInst is optional on IEDName, so it can be null, but cannot be empty
72-
newIedName.setLnInst(nullIfBlank(lnInst));
73-
newIedName.setPrefix(nullIfBlank(prefix));
70+
newIedName.setLnInst(StringUtils.trimToNull(lnInst));
71+
newIedName.setPrefix(StringUtils.trimToNull(prefix));
7472
return newIedName;
7573
}
7674

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/ResumedDataTemplate.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import com.fasterxml.jackson.annotation.JsonIgnore;
88
import lombok.*;
9+
import org.apache.commons.lang3.StringUtils;
910
import org.lfenergy.compas.scl2007b4.model.*;
1011
import org.lfenergy.compas.sct.commons.scl.ied.AbstractLNAdapter;
1112
import org.lfenergy.compas.sct.commons.util.SclConstructorHelper;
@@ -15,7 +16,7 @@
1516
import java.util.Optional;
1617

1718
import static org.lfenergy.compas.sct.commons.util.CommonConstants.MOD_DO_NAME;
18-
import static org.lfenergy.compas.sct.commons.util.CommonConstants.STVAL;
19+
import static org.lfenergy.compas.sct.commons.util.CommonConstants.STVAL_DA_NAME;
1920

2021

2122
/**
@@ -54,13 +55,23 @@ public class ResumedDataTemplate {
5455
/**
5556
* Constructor
5657
*/
57-
public ResumedDataTemplate(AbstractLNAdapter<?> lnAdapter, String doName, String daName) {
58+
public ResumedDataTemplate(AbstractLNAdapter<?> lnAdapter, DoTypeName doName, DaTypeName daName) {
5859
this.lnClass = lnAdapter.getLNClass();
5960
this.lnInst = lnAdapter.getLNInst();
6061
this.prefix = lnAdapter.getPrefix();
6162
this.lnType = lnAdapter.getLnType();
62-
this.doName = new DoTypeName(doName);
63-
this.daName = new DaTypeName(daName);
63+
this.doName = doName;
64+
this.daName = daName;
65+
}
66+
67+
public ResumedDataTemplate(TFCDA fcda) {
68+
this.lnClass = fcda.isSetLnClass() ? fcda.getLnClass().get(0) : null;
69+
this.lnInst = fcda.getLnInst();
70+
this.prefix = fcda.getPrefix();
71+
this.lnType = null;
72+
this.doName = new DoTypeName(StringUtils.trimToEmpty(fcda.getDoName()));
73+
this.daName = new DaTypeName(StringUtils.trimToEmpty(fcda.getDaName()));
74+
if (daName.isDefined()) this.setFc(fcda.getFc());
6475
}
6576

6677
/**
@@ -94,7 +105,7 @@ public boolean isUpdatable(){
94105
* @return true if DO is "Mod" and DA is "stVal", false otherwise
95106
*/
96107
private boolean isDOModDAstVal(){
97-
return doName.getName().equals(MOD_DO_NAME) && daName.getName().equals(STVAL);
108+
return doName.getName().equals(MOD_DO_NAME) && daName.getName().equals(STVAL_DA_NAME);
98109
}
99110

100111
@JsonIgnore

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

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

7-
import lombok.experimental.UtilityClass;
87
import org.apache.commons.lang3.StringUtils;
98
import org.lfenergy.compas.scl2007b4.model.SCL;
109
import org.lfenergy.compas.scl2007b4.model.TCompasICDHeader;
@@ -30,11 +29,14 @@
3029
import static org.lfenergy.compas.sct.commons.dto.ControlBlockNetworkSettings.*;
3130
import static org.lfenergy.compas.sct.commons.util.Utils.isExtRefFeedBySameControlBlock;
3231

33-
@UtilityClass
34-
public class ExtRefService {
32+
public final class ExtRefService {
3533

3634
private static final String MESSAGE_MISSING_IED_NAME_PARAMETER = "IED.name parameter is missing";
3735

36+
private ExtRefService() {
37+
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
38+
}
39+
3840
/**
3941
* Updates iedName attribute of all ExtRefs in the Scd.
4042
*
@@ -203,7 +205,7 @@ private static List<SclReportItem> configureNetworkForControlBlocks(SCL scd, Con
203205

204206
private static Optional<SclReportItem> configureControlBlockNetwork(ControlBlockNetworkSettings controlBlockNetworkSettings, PrimitiveIterator.OfLong appIdIterator, Iterator<String> macAddressIterator, ControlBlockAdapter controlBlockAdapter) {
205207
SettingsOrError settingsOrError = controlBlockNetworkSettings.getNetworkSettings(controlBlockAdapter);
206-
if (settingsOrError.errorMessage() != null){
208+
if (settingsOrError.errorMessage() != null) {
207209
return Optional.of(controlBlockAdapter.buildFatalReportItem(
208210
"Cannot configure network for this ControlBlock because: " + settingsOrError.errorMessage()));
209211
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// SPDX-FileCopyrightText: 2023 RTE FRANCE
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
package org.lfenergy.compas.sct.commons.scl;
6+
7+
import org.lfenergy.compas.scl2007b4.model.SCL;
8+
import org.lfenergy.compas.scl2007b4.model.TFCDA;
9+
import org.lfenergy.compas.sct.commons.scl.ied.IEDAdapter;
10+
11+
import java.util.List;
12+
13+
public final class HmiService {
14+
15+
private HmiService() {
16+
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
17+
}
18+
19+
/**
20+
* Create the DataSet and ReportControl Blocks for the HMI with the given FCDAs.
21+
*
22+
* @param fcdas List of FCDA for which we must create the DataSet and ReportControl Blocks
23+
*/
24+
public static void createAllHmiReportControlBlocks(SCL scd, List<TFCDA> fcdas) {
25+
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
26+
sclRootAdapter.streamIEDAdapters()
27+
.flatMap(IEDAdapter::streamLDeviceAdapters)
28+
.forEach(lDeviceAdapter -> lDeviceAdapter.createHmiReportControlBlocks(fcdas));
29+
}
30+
31+
}

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import org.lfenergy.compas.scl2007b4.model.TExtRef;
1010
import org.lfenergy.compas.scl2007b4.model.TLLN0Enum;
1111
import org.lfenergy.compas.sct.commons.dto.ExtrefTarget;
12-
import org.lfenergy.compas.sct.commons.util.Utils;
1312

1413
/**
1514
* A representation of the model object
@@ -55,16 +54,22 @@ public ObjectReference(String reference) {
5554
public ObjectReference(TExtRef extRef, ExtrefTarget target) {
5655
this.ldName = extRef.getIedName() + extRef.getLdInst();
5756
if(target.equals(ExtrefTarget.SRC_REF)) {
58-
this.lNodeName = Utils.emptyIfBlank(extRef.getPrefix())
59-
+ (extRef.isSetLnClass() ? extRef.getLnClass().get(0): TLLN0Enum.LLN_0.value())
60-
+ Utils.emptyIfBlank(extRef.getLnInst());
61-
this.dataAttributes = Utils.emptyIfBlank(extRef.getDoName());
57+
String s1 = extRef.getLnInst();
58+
String s2 = extRef.getPrefix();
59+
this.lNodeName = StringUtils.trimToEmpty(s2)
60+
+ (extRef.isSetLnClass() ? extRef.getLnClass().get(0) : TLLN0Enum.LLN_0.value())
61+
+ StringUtils.trimToEmpty(s1);
62+
String s = extRef.getDoName();
63+
this.dataAttributes = StringUtils.trimToEmpty(s);
6264
}
6365
if(target.equals(ExtrefTarget.SRC_CB)) {
64-
this.lNodeName = Utils.emptyIfBlank(extRef.getSrcPrefix())
65-
+ (extRef.isSetSrcLNClass() ? extRef.getSrcLNClass().get(0): TLLN0Enum.LLN_0.value())
66-
+ Utils.emptyIfBlank(extRef.getSrcLNInst());
67-
this.dataAttributes = Utils.emptyIfBlank(extRef.getSrcCBName());
66+
String s1 = extRef.getSrcLNInst();
67+
String s2 = extRef.getSrcPrefix();
68+
this.lNodeName = StringUtils.trimToEmpty(s2)
69+
+ (extRef.isSetSrcLNClass() ? extRef.getSrcLNClass().get(0) : TLLN0Enum.LLN_0.value())
70+
+ StringUtils.trimToEmpty(s1);
71+
String s = extRef.getSrcCBName();
72+
this.dataAttributes = StringUtils.trimToEmpty(s);
6873
}
6974
this.reference = this.ldName + "/" + this.lNodeName + "." + this.dataAttributes;
7075
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void setValImport(boolean b) {
5757

5858
private boolean isDOModDAstVal() {
5959
if (parentAdapter.getCurrentElem() instanceof final TDOI tdoi) {
60-
return currentElem.getName().equals(CommonConstants.STVAL) && tdoi.getName().equals(CommonConstants.MOD_DO_NAME);
60+
return currentElem.getName().equals(CommonConstants.STVAL_DA_NAME) && tdoi.getName().equals(CommonConstants.MOD_DO_NAME);
6161
}
6262
return false;
6363
}

0 commit comments

Comments
 (0)