Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.2.35 #468

Merged
merged 12 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SclAutomationServiceIntegrationTest {
private SclAutomationService sclAutomationService ;
private static final SclEditor sclEditor = new SclService() ;
private static final SubstationEditor substationEditor = new SubstationService(new VoltageLevelService()) ;
private static final ControlBlockEditor controlBlockEditor = new ControlBlockEditorService(new ControlService(), new LdeviceService()) ;
private static final ControlBlockEditor controlBlockEditor = new ControlBlockEditorService(new ControlService(), new LdeviceService(new LnService()));

private HeaderDTO headerDTO;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,21 @@ public Optional<DoLinkedToDa> findDoLinkedToDa(TDataTypeTemplates dtt, String lN
));
}

@Override
public Stream<String> getEnumValues(TDataTypeTemplates dataTypeTemplates, String lnType, DoLinkedToDaFilter doLinkedToDaFilter) {
return findDoLinkedToDa(dataTypeTemplates, lnType, doLinkedToDaFilter)
.map(DoLinkedToDa::dataAttribute)
.filter(dataAttribute -> TPredefinedBasicTypeEnum.ENUM.equals(dataAttribute.getBType()))
.map(DataAttribute::getType)
.flatMap(enumId ->
dataTypeTemplates.getEnumType().stream()
.filter(tEnumType -> tEnumType.getId().equals(enumId))
.findFirst())
.stream()
.flatMap(tEnumType -> tEnumType.getEnumVal().stream())
.map(TEnumVal::getValue);
}

private Optional<TDAType> getDATypeByDaName(TDataTypeTemplates dtt, TDOType tdoType, String daName) {
return sdoOrDAService.findDA(tdoType, tda -> tda.getName().equals(daName))
.flatMap(tda -> daTypeService.findDaType(dtt, tda.getType()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
import org.lfenergy.compas.sct.commons.util.PrivateUtils;
import org.lfenergy.compas.sct.commons.util.Utils;

import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

import static org.apache.commons.lang3.StringUtils.*;
import static org.lfenergy.compas.sct.commons.util.CommonConstants.*;
Expand Down Expand Up @@ -51,7 +54,7 @@ public class ExtRefEditorService implements ExtRefEditor {
* @param channel TChannel represent parameters
* @return the IED sources matching the LDEPF parameters
*/
private static List<TIED> getIedSources(SclRootAdapter sclRootAdapter, TCompasBay compasBay, TChannel channel) {
private List<TIED> getIedSources(SclRootAdapter sclRootAdapter, TCompasBay compasBay, TChannel channel) {
return sclRootAdapter.streamIEDAdapters()
.filter(iedAdapter -> (channel.getBayScope().equals(TCBScopeType.BAY_EXTERNAL)
&& iedAdapter.getPrivateCompasBay().stream().noneMatch(bay -> bay.getUUID().equals(compasBay.getUUID())))
Expand Down Expand Up @@ -140,8 +143,7 @@ private static boolean doesIcdHeaderMatchLDEPFChannel(IEDAdapter iedAdapter, TCh
* @param channel TChannel
* @return LDeviceAdapter object that matches the EPF channel
*/
private static Optional<LDeviceAdapter> getActiveSourceLDeviceByLDEPFChannel(IEDAdapter iedAdapter, TChannel channel) {
LdeviceService ldeviceService = new LdeviceService();
private Optional<LDeviceAdapter> getActiveSourceLDeviceByLDEPFChannel(IEDAdapter iedAdapter, TChannel channel) {
return ldeviceService.findLdevice(iedAdapter.getCurrentElem(), tlDevice -> tlDevice.getInst().equals(channel.getLDInst()))
.filter(tlDevice -> ldeviceService.getLdeviceStatus(tlDevice).map(ActiveStatus.ON::equals).orElse(false))
.map(tlDevice -> new LDeviceAdapter(iedAdapter, tlDevice));
Expand Down Expand Up @@ -271,7 +273,7 @@ public List<SclReportItem> manageBindingForLDEPF(SCL scd, EPF epf) {
.findFirst().ifPresent(channel -> {
List<TIED> iedSources = getIedSources(sclRootAdapter, extRefBayRef.compasBay(), channel);
if (iedSources.size() == 1) {
updateLDEPFExtRefBinding(extRefBayRef.extRef(), iedSources.get(0), channel);
updateLDEPFExtRefBinding(extRefBayRef.extRef(), iedSources.getFirst(), channel);
LDeviceAdapter lDeviceAdapter = new LDeviceAdapter(new IEDAdapter(sclRootAdapter, tied.getName()), tlDevice);
sclReportItems.addAll(updateLDEPFDos(lDeviceAdapter, extRefBayRef.extRef(), channel));
} else {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@

package org.lfenergy.compas.sct.commons;

import org.lfenergy.compas.scl2007b4.model.*;
import lombok.RequiredArgsConstructor;
import org.lfenergy.compas.scl2007b4.model.TAccessPoint;
import org.lfenergy.compas.scl2007b4.model.TIED;
import org.lfenergy.compas.scl2007b4.model.TLDevice;
import org.lfenergy.compas.scl2007b4.model.TServer;
import org.lfenergy.compas.sct.commons.util.ActiveStatus;

import java.util.Objects;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Stream;

@RequiredArgsConstructor
public class LdeviceService {

private final LnService lnService;

public Stream<TLDevice> getLdevices(TIED tied) {
if (!tied.isSetAccessPoint()) {
return Stream.empty();
Expand All @@ -40,7 +47,6 @@ public Optional<TLDevice> findLdevice(TIED tied, Predicate<TLDevice> ldevicePred
}

public Optional<ActiveStatus> getLdeviceStatus(TLDevice tlDevice) {
LnService lnService = new LnService();
return lnService.getDaiModStValValue(tlDevice.getLN0());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
@Slf4j
public class LnService implements LnEditor {

private static final DoLinkedToDaFilter DAI_FILTER_MOD_STVAL = DoLinkedToDaFilter.from(MOD_DO_NAME, STVAL_DA_NAME);

public Stream<TAnyLN> getAnylns(TLDevice tlDevice) {
return Stream.concat(Stream.of(tlDevice.getLN0()), tlDevice.getLN().stream());
}
Expand Down Expand Up @@ -73,15 +75,7 @@ public Optional<ActiveStatus> getDaiModStValValue(TAnyLN tAnyLN) {
}

public Optional<TDAI> getDaiModStVal(TAnyLN tAnyLN) {
return tAnyLN
.getDOI()
.stream()
.filter(tdoi -> MOD_DO_NAME.equals(tdoi.getName()))
.flatMap(tdoi -> tdoi.getSDIOrDAI().stream())
.filter(TDAI.class::isInstance)
.map(TDAI.class::cast)
.filter(tdai -> STVAL_DA_NAME.equals(tdai.getName()))
.findFirst();
return getDOAndDAInstances(tAnyLN, DAI_FILTER_MOD_STVAL);
}

public Stream<TAnyLN> getActiveLns(TLDevice tlDevice) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.Pair;
import org.lfenergy.compas.scl2007b4.model.*;
import org.lfenergy.compas.sct.commons.api.SclEditor;
import org.lfenergy.compas.sct.commons.dto.*;
Expand All @@ -24,7 +23,6 @@
import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter;
import org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter;
import org.lfenergy.compas.sct.commons.scl.ln.LN0Adapter;
import org.lfenergy.compas.sct.commons.scl.sstation.SubstationAdapter;
import org.lfenergy.compas.sct.commons.util.PrivateUtils;
import org.lfenergy.compas.sct.commons.util.Utils;

Expand Down Expand Up @@ -187,19 +185,6 @@ public void importSTDElementsInSCD(SCL scd, List<SCL> stds) throws ScdException
});
}

@Override
public List<SclReportItem> updateLDeviceStatus(SCL scd) {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
SubstationAdapter substationAdapter = sclRootAdapter.getSubstationAdapter();
final List<Pair<String, String>> iedNameLdInstList = substationAdapter.getIedAndLDeviceNamesForLN0FromLNode();
return sclRootAdapter.streamIEDAdapters()
.flatMap(IEDAdapter::streamLDeviceAdapters)
.map(LDeviceAdapter::getLN0Adapter)
.map(ln0Adapter -> ln0Adapter.updateLDeviceStatus(iedNameLdInstList))
.flatMap(Optional::stream)
.toList();
}

@Override
public List<SclReportItem> updateDoInRef(SCL scd) {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ public interface DataTypeTemplateReader {

Optional<DoLinkedToDa> findDoLinkedToDa(TDataTypeTemplates dtt, String lNodeTypeId, DoLinkedToDaFilter doLinkedToDaFilter);

Stream<String> getEnumValues(TDataTypeTemplates dataTypeTemplates, String lnType, DoLinkedToDaFilter doLinkedToDaFilter);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
import org.lfenergy.compas.scl2007b4.model.TDAI;
import org.lfenergy.compas.sct.commons.domain.DoLinkedToDa;
import org.lfenergy.compas.sct.commons.domain.DoLinkedToDaFilter;
import org.lfenergy.compas.sct.commons.util.ActiveStatus;

import java.util.Optional;

public interface LnEditor {

Optional<ActiveStatus> getDaiModStValValue(TAnyLN tAnyLN);

Optional<TDAI> getDaiModStVal(TAnyLN tAnyLN);

Optional<TDAI> getDOAndDAInstances(TAnyLN tAnyLN, DoLinkedToDaFilter doLinkedToDaFilter);

void updateOrCreateDOAndDAInstances(TAnyLN tAnyLN, DoLinkedToDa doLinkedToDa);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import lombok.NonNull;
import org.lfenergy.compas.scl2007b4.model.SCL;
import org.lfenergy.compas.scl2007b4.model.TLNode;
import org.lfenergy.compas.sct.commons.dto.*;
import org.lfenergy.compas.sct.commons.exception.ScdException;

Expand Down Expand Up @@ -137,14 +136,6 @@ public interface SclEditor {
*/
void importSTDElementsInSCD(SCL scd, List<SCL> stds) throws ScdException;

/**
* Activate used LDevice and Deactivate unused LDevice in {@link TLNode <em><b>TLNode </b></em>}
*
* @param scd SCL file for which LDevice should be activated or deactivated
* @return list of encountered errors
*/
List<SclReportItem> updateLDeviceStatus(SCL scd);

/**
* Update DAIs of DO InRef in all LN0 of the SCD using matching ExtRef information.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

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

import lombok.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.lfenergy.compas.scl2007b4.model.TPredefinedCDCEnum;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,33 @@ public DoLinkedToDaFilter(String doName, List<String> sdoNames, String daName, L
this.daName = StringUtils.isBlank(daName) ? null : daName;
this.bdaNames = bdaNames == null ? Collections.emptyList() : List.copyOf(bdaNames);
}
public DoLinkedToDaFilter(){
this(null,null,null,null);
}

public static DoLinkedToDaFilter from(String doNames, String daNames) {
String doName = null;
List<String> sdoNames = null;
String daName = null;
List<String> bdaNames = null;
if (StringUtils.isNotBlank(doNames)){
if (StringUtils.isNotBlank(doNames)) {
doName = doNames.split("\\.")[0];
sdoNames = Arrays.stream(doNames.split("\\.")).skip(1).toList();
}
if (StringUtils.isNotBlank(daNames)){
if (StringUtils.isNotBlank(daNames)) {
daName = daNames.split("\\.")[0];
bdaNames = Arrays.stream(daNames.split("\\.")).skip(1).toList();
}
return new DoLinkedToDaFilter(doName, sdoNames, daName, bdaNames);
}

public String getDoRef() {
return doName + (sdoNames().isEmpty() ? StringUtils.EMPTY : "." + String.join(".", sdoNames()));
}
public String getDoRef() {
return doName + (sdoNames().isEmpty() ? StringUtils.EMPTY : "." + String.join(".", sdoNames()));
}

public String getDaRef() {
return daName + (bdaNames().isEmpty() ? StringUtils.EMPTY : "." + String.join(".", bdaNames()));
}
public String getDaRef() {
return daName + (bdaNames().isEmpty() ? StringUtils.EMPTY : "." + String.join(".", bdaNames()));
}

@Override
public String toString() {
return getDoRef() + "." + getDaRef();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.lfenergy.compas.scl2007b4.model.*;
import org.lfenergy.compas.scl2007b4.model.SCL;
import org.lfenergy.compas.scl2007b4.model.TAnyLN;
import org.lfenergy.compas.scl2007b4.model.TExtRef;
import org.lfenergy.compas.scl2007b4.model.TLNodeType;
import org.lfenergy.compas.sct.commons.DataSetService;
import org.lfenergy.compas.sct.commons.ExtRefReaderService;
import org.lfenergy.compas.sct.commons.LnodeTypeService;
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
import org.lfenergy.compas.sct.commons.scl.dtt.DataTypeTemplateAdapter;
import org.lfenergy.compas.sct.commons.scl.dtt.LNodeTypeAdapter;
import org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter;
import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter;
import org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter;
import org.lfenergy.compas.sct.commons.scl.ln.LNAdapter;
import org.lfenergy.compas.sct.commons.scl.ln.LnId;
import org.lfenergy.compas.sct.commons.util.Utils;
Expand Down
Loading
Loading