Skip to content

Commit

Permalink
Merge pull request #277 from com-pas/276-evolution-some-source-ied-ar…
Browse files Browse the repository at this point in the history
…e-bay-external-and-still-unique

Setting of LDEPF LDevices : evol binding Extref #256, closes #276
  • Loading branch information
samirromdhani authored May 17, 2023
2 parents 594d866 + 21c23ec commit 93194d4
Show file tree
Hide file tree
Showing 21 changed files with 2,146 additions and 787 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// SPDX-FileCopyrightText: 2023 RTE FRANCE
//
// SPDX-License-Identifier: Apache-2.0

package org.lfenergy.compas.sct.commons.dto;

import com.opencsv.bean.CsvBindByPosition;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.lfenergy.compas.scl2007b4.model.TCompasFlowKind;
import org.lfenergy.compas.scl2007b4.model.TExtRef;
import org.lfenergy.compas.sct.commons.util.Utils;

import java.math.BigInteger;

/**
* A representation of settings made for LDEPF LDevice
*
* @see <a href="https://github.com/com-pas/compas-sct/issues/256" target="_blank">Issue !256</a>
*/
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class LDEPFSettingData {

@CsvBindByPosition(position = 0)
private TCompasFlowKind bayScope;
@CsvBindByPosition(position = 1)
private String iedType;
@CsvBindByPosition(position = 2)
private String iedRedundancy;
@CsvBindByPosition(position = 3)
private BigInteger iedInstance;
@CsvBindByPosition(position = 4)
private String channelShortLabel;
@CsvBindByPosition(position = 5)
private String channelMREP;
@CsvBindByPosition(position = 6)
private String channelLevModQ;
@CsvBindByPosition(position = 7)
private String channelLevModLevMod;
@CsvBindByPosition(position = 8)
private String bapVariant;
@CsvBindByPosition(position = 9)
private String bapIgnoredValue;
@CsvBindByPosition(position = 10)
private String ldInst;
@CsvBindByPosition(position = 11)
private String lnPrefix;
@CsvBindByPosition(position = 12)
private String lnClass;
@CsvBindByPosition(position = 13)
private String lnInst;
@CsvBindByPosition(position = 14)
private String doName;
@CsvBindByPosition(position = 15)
private String doInst;
@CsvBindByPosition(position = 16)
private String sdoName;
@CsvBindByPosition(position = 17)
private String daName;
@CsvBindByPosition(position = 18)
private String daType;
@CsvBindByPosition(position = 19)
private String dabType;
@CsvBindByPosition(position = 20)
private String bdaName;
@CsvBindByPosition(position = 21)
private String sbdaName;
@CsvBindByPosition(position = 22)
private Integer channelAnalogNum;
@CsvBindByPosition(position = 23)
private Integer channelDigitalNum;
@CsvBindByPosition(position = 24)
private String opt;

/**
* verify if an Extref matches the Analog type or not.
*/
private Boolean isAnalogTypeMatchDesc(TExtRef extRef) {
return getChannelAnalogNum() != null && getChannelDigitalNum() == null
&& extRef.getDesc().startsWith("DYN_LDEPF_ANALOG CHANNEL " + getChannelAnalogNum()+"_1_AnalogueValue")
&& extRef.getDesc().endsWith("_" + getDaName() + "_1");
}

/**
* verify if an Extref matches the Digital type or not.
*/
private Boolean isDigitalTypeMatchDesc(TExtRef extRef) {
return getChannelDigitalNum() != null && getChannelAnalogNum() == null
&& extRef.getDesc().startsWith("DYN_LDEPF_DIGITAL CHANNEL " + getChannelDigitalNum()+"_1_BOOLEEN")
&& extRef.getDesc().endsWith("_" + getDaName() + "_1");
}

/**
* verify if an Extref matches the LDEPFSettingData or not.
*/
public Boolean isMatchExtRef(TExtRef extRef) {
return extRef.isSetDesc() && (isAnalogTypeMatchDesc(extRef) || isDigitalTypeMatchDesc(extRef))
&& extRef.isSetPLN() && Utils.lnClassEquals(extRef.getPLN(), getLnClass())
&& extRef.isSetPDO() && extRef.getPDO().equals(getDoName());
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import org.apache.commons.lang3.StringUtils;
import org.lfenergy.compas.scl2007b4.model.*;
import org.lfenergy.compas.sct.commons.dto.*;
import org.lfenergy.compas.sct.commons.dto.LDEPFSettingsSupplier.LDEPFSetting;
import org.lfenergy.compas.sct.commons.dto.ExtRefInfo.ExtRefBayReference;
import org.lfenergy.compas.sct.commons.exception.ScdException;
import org.lfenergy.compas.sct.commons.scl.ied.*;
import org.lfenergy.compas.sct.commons.util.ControlBlockEnum;
import org.lfenergy.compas.sct.commons.util.ILDEPFSettings;
import org.lfenergy.compas.sct.commons.util.PrivateEnum;
import org.lfenergy.compas.sct.commons.util.Utils;

Expand Down Expand Up @@ -245,20 +245,20 @@ public static List<TExtRef> filterDuplicatedExtRefs(List<TExtRef> tExtRefs) {
/**
* ExtRef Binding For LDevice (inst=LDEPF) that matching LDEPF configuration
* @param scd SCL
* @param settingsSupplier LDEPFSettingsSupplier
* @param settings ILDEPFSettings
* @return a report contains errors
*/
public static SclReport manageBindingForLDEPF(SCL scd, LDEPFSettingsSupplier settingsSupplier) {
public static SclReport manageBindingForLDEPF(SCL scd, ILDEPFSettings settings) {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
List<SclReportItem> sclReportItems = new ArrayList<>();
List<ExtRefBayReference> extRefBayReferences = sclRootAdapter.streamIEDAdapters()
.filter(iedAdapter -> !iedAdapter.getName().equals(IED_TEST_NAME))
.map(iedAdapter -> iedAdapter.getExtRefBayReferenceForActifLDEPF(sclReportItems))
.flatMap(List::stream).toList();
for (ExtRefBayReference extRefBayRef: extRefBayReferences){
var lDPFSettingMatchingExtRef = settingsSupplier.getLDEPFSettingMatchingExtRef(extRefBayRef.extRef());
var lDPFSettingMatchingExtRef = settings.getLDEPFSettingDataMatchExtRef(extRefBayRef.extRef());
if(lDPFSettingMatchingExtRef.isPresent()){
List<TIED> iedSources = settingsSupplier.getIedSources(sclRootAdapter, extRefBayRef.compasBay(), lDPFSettingMatchingExtRef.get());
List<TIED> iedSources = settings.getIedSources(sclRootAdapter, extRefBayRef.compasBay(), lDPFSettingMatchingExtRef.get());
if(iedSources.size() != 1) {
if(iedSources.size() > 1) {
sclReportItems.add(SclReportItem.warning(null, "There is more than one IED source to bind the signal " +
Expand All @@ -273,17 +273,17 @@ public static SclReport manageBindingForLDEPF(SCL scd, LDEPFSettingsSupplier set
return new SclReport(sclRootAdapter, sclReportItems);
}

private static void updateLDEPFExtRefBinding(TExtRef extRef, TIED iedSource, LDEPFSetting setting) {

private static void updateLDEPFExtRefBinding(TExtRef extRef, TIED iedSource, LDEPFSettingData setting) {
extRef.setIedName(iedSource.getName());
extRef.setLdInst(setting.ldInst());
extRef.getLnClass().add(setting.lnClass());
extRef.setLnInst(setting.lnInst());
if(setting.lnPrefix() != null){
extRef.setPrefix(setting.lnPrefix());
extRef.setLdInst(setting.getLdInst());
extRef.getLnClass().add(setting.getLnClass());
extRef.setLnInst(setting.getLnInst());
if(setting.getLnPrefix() != null){
extRef.setPrefix(setting.getLnPrefix());
}
var doName = setting.doInst().equals("0") ? setting.doName() : setting.doName()+setting.doInst() ;
String doName = StringUtils.isEmpty(setting.getDoInst()) || StringUtils.isBlank(setting.getDoInst()) || setting.getDoInst().equals("0") ? setting.getDoName() : setting.getDoName() + setting.getDoInst();
extRef.setDoName(doName);

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// SPDX-FileCopyrightText: 2023 RTE FRANCE
//
// SPDX-License-Identifier: Apache-2.0

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

import org.lfenergy.compas.scl2007b4.model.*;
import org.lfenergy.compas.sct.commons.dto.LDEPFSettingData;
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;

import java.util.List;
import java.util.Optional;


/**
* This interface showcases the LDEPF parameters for the LDEPF LDevice.
*/
public interface ILDEPFSettings {

/**
* Provides the matching setting for an ExtRef.
* @param extRef The ExtRef object
* @return the matching LDEPFSettingDTO for an ExtRef
*/
Optional<LDEPFSettingData> getLDEPFSettingDataMatchExtRef(TExtRef extRef);

/**
* Provides valid IED sources with LDEPF configuration.<br/>
* Example of LDEPF configuration include:<br/>
* 1. COMPAS-Bay verification that should be closed to the provided Flow Kind<br/>
* 2. COMPAS-ICDHeader verification that should match the provided parameters, see {@link Utils#isIcdHeaderMatch}<br/>
* 3. Active LDevice source object that should match the provided parameters, see {@link Utils#getActiveSourceLDevice}<br/>
* 4. Active LNode source object that should match the provided parameters, see {@link Utils#getActiveLNodeSource}<br/>
* 5. Valid DataTypeTemplate Object hierarchy that should match the DO/DA/BDA parameters, see {@link Utils#isValidDataTypeTemplate}<br/>
* @param sclRootAdapter SCL
* @param compasBay TCompasBay
* @param setting LDEPFSetting
* @return the IED sources matching the LDEPFSetting
*/
List<TIED> getIedSources(SclRootAdapter sclRootAdapter, TCompasBay compasBay, LDEPFSettingData setting);

}
Loading

0 comments on commit 93194d4

Please sign in to comment.