Skip to content

Commit 93194d4

Browse files
Merge pull request #277 from com-pas/276-evolution-some-source-ied-are-bay-external-and-still-unique
Setting of LDEPF LDevices : evol binding Extref #256, closes #276
2 parents 594d866 + 21c23ec commit 93194d4

21 files changed

+2146
-787
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
// SPDX-FileCopyrightText: 2023 RTE FRANCE
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
package org.lfenergy.compas.sct.commons.dto;
6+
7+
import com.opencsv.bean.CsvBindByPosition;
8+
import lombok.AllArgsConstructor;
9+
import lombok.Builder;
10+
import lombok.Getter;
11+
import lombok.NoArgsConstructor;
12+
import org.lfenergy.compas.scl2007b4.model.TCompasFlowKind;
13+
import org.lfenergy.compas.scl2007b4.model.TExtRef;
14+
import org.lfenergy.compas.sct.commons.util.Utils;
15+
16+
import java.math.BigInteger;
17+
18+
/**
19+
* A representation of settings made for LDEPF LDevice
20+
*
21+
* @see <a href="https://github.com/com-pas/compas-sct/issues/256" target="_blank">Issue !256</a>
22+
*/
23+
@Getter
24+
@AllArgsConstructor
25+
@NoArgsConstructor
26+
@Builder
27+
public class LDEPFSettingData {
28+
29+
@CsvBindByPosition(position = 0)
30+
private TCompasFlowKind bayScope;
31+
@CsvBindByPosition(position = 1)
32+
private String iedType;
33+
@CsvBindByPosition(position = 2)
34+
private String iedRedundancy;
35+
@CsvBindByPosition(position = 3)
36+
private BigInteger iedInstance;
37+
@CsvBindByPosition(position = 4)
38+
private String channelShortLabel;
39+
@CsvBindByPosition(position = 5)
40+
private String channelMREP;
41+
@CsvBindByPosition(position = 6)
42+
private String channelLevModQ;
43+
@CsvBindByPosition(position = 7)
44+
private String channelLevModLevMod;
45+
@CsvBindByPosition(position = 8)
46+
private String bapVariant;
47+
@CsvBindByPosition(position = 9)
48+
private String bapIgnoredValue;
49+
@CsvBindByPosition(position = 10)
50+
private String ldInst;
51+
@CsvBindByPosition(position = 11)
52+
private String lnPrefix;
53+
@CsvBindByPosition(position = 12)
54+
private String lnClass;
55+
@CsvBindByPosition(position = 13)
56+
private String lnInst;
57+
@CsvBindByPosition(position = 14)
58+
private String doName;
59+
@CsvBindByPosition(position = 15)
60+
private String doInst;
61+
@CsvBindByPosition(position = 16)
62+
private String sdoName;
63+
@CsvBindByPosition(position = 17)
64+
private String daName;
65+
@CsvBindByPosition(position = 18)
66+
private String daType;
67+
@CsvBindByPosition(position = 19)
68+
private String dabType;
69+
@CsvBindByPosition(position = 20)
70+
private String bdaName;
71+
@CsvBindByPosition(position = 21)
72+
private String sbdaName;
73+
@CsvBindByPosition(position = 22)
74+
private Integer channelAnalogNum;
75+
@CsvBindByPosition(position = 23)
76+
private Integer channelDigitalNum;
77+
@CsvBindByPosition(position = 24)
78+
private String opt;
79+
80+
/**
81+
* verify if an Extref matches the Analog type or not.
82+
*/
83+
private Boolean isAnalogTypeMatchDesc(TExtRef extRef) {
84+
return getChannelAnalogNum() != null && getChannelDigitalNum() == null
85+
&& extRef.getDesc().startsWith("DYN_LDEPF_ANALOG CHANNEL " + getChannelAnalogNum()+"_1_AnalogueValue")
86+
&& extRef.getDesc().endsWith("_" + getDaName() + "_1");
87+
}
88+
89+
/**
90+
* verify if an Extref matches the Digital type or not.
91+
*/
92+
private Boolean isDigitalTypeMatchDesc(TExtRef extRef) {
93+
return getChannelDigitalNum() != null && getChannelAnalogNum() == null
94+
&& extRef.getDesc().startsWith("DYN_LDEPF_DIGITAL CHANNEL " + getChannelDigitalNum()+"_1_BOOLEEN")
95+
&& extRef.getDesc().endsWith("_" + getDaName() + "_1");
96+
}
97+
98+
/**
99+
* verify if an Extref matches the LDEPFSettingData or not.
100+
*/
101+
public Boolean isMatchExtRef(TExtRef extRef) {
102+
return extRef.isSetDesc() && (isAnalogTypeMatchDesc(extRef) || isDigitalTypeMatchDesc(extRef))
103+
&& extRef.isSetPLN() && Utils.lnClassEquals(extRef.getPLN(), getLnClass())
104+
&& extRef.isSetPDO() && extRef.getPDO().equals(getDoName());
105+
}
106+
107+
}

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

Lines changed: 0 additions & 131 deletions
This file was deleted.

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
import org.apache.commons.lang3.StringUtils;
88
import org.lfenergy.compas.scl2007b4.model.*;
99
import org.lfenergy.compas.sct.commons.dto.*;
10-
import org.lfenergy.compas.sct.commons.dto.LDEPFSettingsSupplier.LDEPFSetting;
1110
import org.lfenergy.compas.sct.commons.dto.ExtRefInfo.ExtRefBayReference;
1211
import org.lfenergy.compas.sct.commons.exception.ScdException;
1312
import org.lfenergy.compas.sct.commons.scl.ied.*;
1413
import org.lfenergy.compas.sct.commons.util.ControlBlockEnum;
14+
import org.lfenergy.compas.sct.commons.util.ILDEPFSettings;
1515
import org.lfenergy.compas.sct.commons.util.PrivateEnum;
1616
import org.lfenergy.compas.sct.commons.util.Utils;
1717

@@ -245,20 +245,20 @@ public static List<TExtRef> filterDuplicatedExtRefs(List<TExtRef> tExtRefs) {
245245
/**
246246
* ExtRef Binding For LDevice (inst=LDEPF) that matching LDEPF configuration
247247
* @param scd SCL
248-
* @param settingsSupplier LDEPFSettingsSupplier
248+
* @param settings ILDEPFSettings
249249
* @return a report contains errors
250250
*/
251-
public static SclReport manageBindingForLDEPF(SCL scd, LDEPFSettingsSupplier settingsSupplier) {
251+
public static SclReport manageBindingForLDEPF(SCL scd, ILDEPFSettings settings) {
252252
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
253253
List<SclReportItem> sclReportItems = new ArrayList<>();
254254
List<ExtRefBayReference> extRefBayReferences = sclRootAdapter.streamIEDAdapters()
255255
.filter(iedAdapter -> !iedAdapter.getName().equals(IED_TEST_NAME))
256256
.map(iedAdapter -> iedAdapter.getExtRefBayReferenceForActifLDEPF(sclReportItems))
257257
.flatMap(List::stream).toList();
258258
for (ExtRefBayReference extRefBayRef: extRefBayReferences){
259-
var lDPFSettingMatchingExtRef = settingsSupplier.getLDEPFSettingMatchingExtRef(extRefBayRef.extRef());
259+
var lDPFSettingMatchingExtRef = settings.getLDEPFSettingDataMatchExtRef(extRefBayRef.extRef());
260260
if(lDPFSettingMatchingExtRef.isPresent()){
261-
List<TIED> iedSources = settingsSupplier.getIedSources(sclRootAdapter, extRefBayRef.compasBay(), lDPFSettingMatchingExtRef.get());
261+
List<TIED> iedSources = settings.getIedSources(sclRootAdapter, extRefBayRef.compasBay(), lDPFSettingMatchingExtRef.get());
262262
if(iedSources.size() != 1) {
263263
if(iedSources.size() > 1) {
264264
sclReportItems.add(SclReportItem.warning(null, "There is more than one IED source to bind the signal " +
@@ -273,17 +273,17 @@ public static SclReport manageBindingForLDEPF(SCL scd, LDEPFSettingsSupplier set
273273
return new SclReport(sclRootAdapter, sclReportItems);
274274
}
275275

276-
private static void updateLDEPFExtRefBinding(TExtRef extRef, TIED iedSource, LDEPFSetting setting) {
276+
277+
private static void updateLDEPFExtRefBinding(TExtRef extRef, TIED iedSource, LDEPFSettingData setting) {
277278
extRef.setIedName(iedSource.getName());
278-
extRef.setLdInst(setting.ldInst());
279-
extRef.getLnClass().add(setting.lnClass());
280-
extRef.setLnInst(setting.lnInst());
281-
if(setting.lnPrefix() != null){
282-
extRef.setPrefix(setting.lnPrefix());
279+
extRef.setLdInst(setting.getLdInst());
280+
extRef.getLnClass().add(setting.getLnClass());
281+
extRef.setLnInst(setting.getLnInst());
282+
if(setting.getLnPrefix() != null){
283+
extRef.setPrefix(setting.getLnPrefix());
283284
}
284-
var doName = setting.doInst().equals("0") ? setting.doName() : setting.doName()+setting.doInst() ;
285+
String doName = StringUtils.isEmpty(setting.getDoInst()) || StringUtils.isBlank(setting.getDoInst()) || setting.getDoInst().equals("0") ? setting.getDoName() : setting.getDoName() + setting.getDoInst();
285286
extRef.setDoName(doName);
286-
287287
}
288288

289289
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// SPDX-FileCopyrightText: 2023 RTE FRANCE
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
package org.lfenergy.compas.sct.commons.util;
6+
7+
import org.lfenergy.compas.scl2007b4.model.*;
8+
import org.lfenergy.compas.sct.commons.dto.LDEPFSettingData;
9+
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
10+
11+
import java.util.List;
12+
import java.util.Optional;
13+
14+
15+
/**
16+
* This interface showcases the LDEPF parameters for the LDEPF LDevice.
17+
*/
18+
public interface ILDEPFSettings {
19+
20+
/**
21+
* Provides the matching setting for an ExtRef.
22+
* @param extRef The ExtRef object
23+
* @return the matching LDEPFSettingDTO for an ExtRef
24+
*/
25+
Optional<LDEPFSettingData> getLDEPFSettingDataMatchExtRef(TExtRef extRef);
26+
27+
/**
28+
* Provides valid IED sources with LDEPF configuration.<br/>
29+
* Example of LDEPF configuration include:<br/>
30+
* 1. COMPAS-Bay verification that should be closed to the provided Flow Kind<br/>
31+
* 2. COMPAS-ICDHeader verification that should match the provided parameters, see {@link Utils#isIcdHeaderMatch}<br/>
32+
* 3. Active LDevice source object that should match the provided parameters, see {@link Utils#getActiveSourceLDevice}<br/>
33+
* 4. Active LNode source object that should match the provided parameters, see {@link Utils#getActiveLNodeSource}<br/>
34+
* 5. Valid DataTypeTemplate Object hierarchy that should match the DO/DA/BDA parameters, see {@link Utils#isValidDataTypeTemplate}<br/>
35+
* @param sclRootAdapter SCL
36+
* @param compasBay TCompasBay
37+
* @param setting LDEPFSetting
38+
* @return the IED sources matching the LDEPFSetting
39+
*/
40+
List<TIED> getIedSources(SclRootAdapter sclRootAdapter, TCompasBay compasBay, LDEPFSettingData setting);
41+
42+
}

0 commit comments

Comments
 (0)