Skip to content

Commit

Permalink
feat(#341): Création Lnode, DOI et Private domain
Browse files Browse the repository at this point in the history
Signed-off-by: gleizesDor <115622893+gleizesDor@users.noreply.github.com>
  • Loading branch information
gleizesDor committed Nov 22, 2023
1 parent f5e7098 commit d822129
Show file tree
Hide file tree
Showing 80 changed files with 2,413 additions and 734 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
</plugin>
<plugin>
Expand All @@ -145,6 +146,11 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<!--keep the existing values using @{argLine} syntax-->
<!-- https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#argLine -->
<argLine>@{argLine} --enable-preview</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.lfenergy.compas.sct.commons.exception.ScdException;
import org.lfenergy.compas.sct.commons.scl.SclElementAdapter;
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
import org.lfenergy.compas.sct.commons.scl.ied.LDeviceAdapter;
import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter;
import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller;

import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@
package org.lfenergy.compas.sct.commons;

import org.apache.commons.lang3.StringUtils;
import org.lfenergy.compas.scl2007b4.model.*;
import org.lfenergy.compas.scl2007b4.model.SCL;
import org.lfenergy.compas.sct.commons.api.ControlBlockEditor;
import org.lfenergy.compas.sct.commons.dto.*;
import org.lfenergy.compas.sct.commons.dto.ControlBlockNetworkSettings;
import org.lfenergy.compas.sct.commons.dto.ControlBlockNetworkSettings.NetworkRanges;
import org.lfenergy.compas.sct.commons.dto.ControlBlockNetworkSettings.RangesPerCbType;
import org.lfenergy.compas.sct.commons.dto.ControlBlockNetworkSettings.Settings;
import org.lfenergy.compas.sct.commons.dto.ControlBlockNetworkSettings.SettingsOrError;
import org.lfenergy.compas.sct.commons.dto.FcdaForDataSetsCreation;
import org.lfenergy.compas.sct.commons.dto.SclReportItem;
import org.lfenergy.compas.sct.commons.exception.ScdException;
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
import org.lfenergy.compas.sct.commons.scl.ied.*;
import org.lfenergy.compas.sct.commons.util.*;
import org.lfenergy.compas.sct.commons.scl.ied.ControlBlockAdapter;
import org.lfenergy.compas.sct.commons.scl.ied.IEDAdapter;
import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter;
import org.lfenergy.compas.sct.commons.scl.ln.LNAdapter;
import org.lfenergy.compas.sct.commons.util.ControlBlockEnum;
import org.lfenergy.compas.sct.commons.util.Utils;

import java.util.*;
import java.util.stream.Stream;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-FileCopyrightText: 2022 2023 RTE FRANCE
//
// SPDX-License-Identifier: Apache-2.0

package org.lfenergy.compas.sct.commons;

import org.lfenergy.compas.scl2007b4.model.LN0;
import org.lfenergy.compas.scl2007b4.model.TAnyLN;
import org.lfenergy.compas.scl2007b4.model.TDataSet;
import org.lfenergy.compas.scl2007b4.model.TLN;
import org.lfenergy.compas.sct.commons.api.DataSetReader;

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

public class DataSetService implements DataSetReader {

public Stream<TDataSet> getDataSets(TAnyLN tAnyLN) {
return switch (tAnyLN) {
case LN0 ln0 -> ln0.isSetDataSet() ? ln0.getDataSet().stream() : Stream.empty();
case TLN tln -> tln.isSetDataSet() ? tln.getDataSet().stream() : Stream.empty();
default -> throw new IllegalStateException("Unexpected value: " + tAnyLN);
};
}

public Stream<TDataSet> getFilteredDataSets(TAnyLN tAnyLN, Predicate<TDataSet> dataSetPredicate) {
return getDataSets(tAnyLN).filter(dataSetPredicate);
}

public Optional<TDataSet> findDataSet(TAnyLN tAnyLN, Predicate<TDataSet> dataSetPredicate) {
return getFilteredDataSets(tAnyLN, dataSetPredicate).findFirst();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-FileCopyrightText: 2022 RTE FRANCE
//
// SPDX-License-Identifier: Apache-2.0

package org.lfenergy.compas.sct.commons;

import org.lfenergy.compas.scl2007b4.model.TDO;
import org.lfenergy.compas.scl2007b4.model.TLNodeType;
import org.lfenergy.compas.sct.commons.api.DoReader;

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

public class DoService implements DoReader {

public Stream<TDO> getDos(TLNodeType tlNodeType) {
return tlNodeType.getDO().stream();
}

public Stream<TDO> getFilteredDos(TLNodeType tlNodeType, Predicate<TDO> tdoPredicate) {
return getDos(tlNodeType).filter(tdoPredicate);
}

public Optional<TDO> findDo(TLNodeType tlNodeType, Predicate<TDO> tdoPredicate) {
return getFilteredDos(tlNodeType, tdoPredicate).findFirst();
}

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

package org.lfenergy.compas.sct.commons;

import org.lfenergy.compas.scl2007b4.model.TDataTypeTemplates;
import org.lfenergy.compas.scl2007b4.model.TDOType;
import org.lfenergy.compas.sct.commons.api.DoTypeReader;

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

public class DoTypeService implements DoTypeReader {

public Stream<TDOType> getDoTypes(TDataTypeTemplates tDataTypeTemplates) {
return tDataTypeTemplates.getDOType().stream();
}

public Stream<TDOType> getFilteredDoTypes(TDataTypeTemplates tDataTypeTemplates, Predicate<TDOType> tdoTypePredicate) {
return getDoTypes(tDataTypeTemplates).filter(tdoTypePredicate);
}

public Optional<TDOType> findDoType(TDataTypeTemplates tDataTypeTemplates, Predicate<TDOType> tdoTypePredicate) {
return getFilteredDoTypes(tDataTypeTemplates, tdoTypePredicate).findFirst();
}

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

package org.lfenergy.compas.sct.commons;

import org.lfenergy.compas.scl2007b4.model.LN0;
import org.lfenergy.compas.scl2007b4.model.TAnyLN;
import org.lfenergy.compas.scl2007b4.model.TExtRef;
import org.lfenergy.compas.scl2007b4.model.TLN;
import org.lfenergy.compas.sct.commons.api.ExtRefReader;

import java.util.stream.Stream;

public class ExtRefReaderService implements ExtRefReader {

public Stream<TExtRef> getExtRefs(TAnyLN tAnyLN) {
return switch (tAnyLN) {
case LN0 ln0 -> ln0.isSetInputs() ? ln0.getInputs().getExtRef().stream() : Stream.empty();
case TLN tln -> tln.isSetInputs() ? tln.getInputs().getExtRef().stream() : Stream.empty();
default -> throw new IllegalStateException("Unexpected value: " + tAnyLN);
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@

import org.apache.commons.lang3.StringUtils;
import org.lfenergy.compas.scl2007b4.model.*;
import org.lfenergy.compas.sct.commons.api.ExtRefEditor;
import org.lfenergy.compas.sct.commons.dto.*;
import org.lfenergy.compas.sct.commons.dto.ControlBlockNetworkSettings.NetworkRanges;
import org.lfenergy.compas.sct.commons.dto.ControlBlockNetworkSettings.RangesPerCbType;
import org.lfenergy.compas.sct.commons.dto.ControlBlockNetworkSettings.Settings;
import org.lfenergy.compas.sct.commons.dto.ControlBlockNetworkSettings.SettingsOrError;
import org.lfenergy.compas.sct.commons.exception.ScdException;
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
import org.lfenergy.compas.sct.commons.scl.ied.*;
import org.lfenergy.compas.sct.commons.util.*;
import org.lfenergy.compas.sct.commons.scl.ied.IEDAdapter;
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.util.ILDEPFSettings;
import org.lfenergy.compas.sct.commons.util.LdeviceStatus;
import org.lfenergy.compas.sct.commons.util.PrivateEnum;
import org.lfenergy.compas.sct.commons.util.PrivateUtils;
import org.lfenergy.compas.sct.commons.api.ExtRefEditor;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.lfenergy.compas.sct.commons.util.CommonConstants.*;
import static org.lfenergy.compas.sct.commons.util.Utils.isExtRefFeedBySameControlBlock;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-FileCopyrightText: 2022 RTE FRANCE
//
// SPDX-License-Identifier: Apache-2.0

package org.lfenergy.compas.sct.commons;

import org.lfenergy.compas.scl2007b4.model.SCL;
import org.lfenergy.compas.scl2007b4.model.TIED;
import org.lfenergy.compas.sct.commons.api.IedReader;

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

public class IedService implements IedReader {

public Stream<TIED> getFilteredIeds(SCL scd, Predicate<TIED> iedPredicate) {
return scd.getIED().stream().filter(iedPredicate);
}

public Optional<TIED> findIed(SCL scd, Predicate<TIED> iedPredicate) {
return getFilteredIeds(scd, iedPredicate).findFirst();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// SPDX-FileCopyrightText: 2022 RTE FRANCE
//
// SPDX-License-Identifier: Apache-2.0

package org.lfenergy.compas.sct.commons;

import org.lfenergy.compas.scl2007b4.model.*;
import org.lfenergy.compas.sct.commons.api.LdeviceReader;
import org.lfenergy.compas.sct.commons.util.LdeviceStatus;

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

import static org.lfenergy.compas.sct.commons.util.CommonConstants.MOD_DO_NAME;
import static org.lfenergy.compas.sct.commons.util.CommonConstants.STVAL_DA_NAME;

public class LdeviceService implements LdeviceReader {

public Stream<TLDevice> getLdevices(TIED tied) {
if (!tied.isSetAccessPoint()) {
return Stream.empty();
}
return tied.getAccessPoint()
.stream()
.map(TAccessPoint::getServer)
.filter(Objects::nonNull)
.filter(TServer::isSetLDevice)
.flatMap(tServer -> tServer.getLDevice().stream());
}

public Stream<TLDevice> getActiveLdevices(TIED tied) {
return getLdevices(tied)
.filter(ldevice -> getLdeviceStatus(ldevice).map(LdeviceStatus.ON::equals).orElse(false));
}

public Stream<TLDevice> getFilteredLdevices(TIED tied, Predicate<TLDevice> ldevicePredicate) {
return getLdevices(tied).filter(ldevicePredicate);
}

public Optional<TLDevice> findLdevice(TIED tied, Predicate<TLDevice> ldevicePredicate) {
return getFilteredLdevices(tied, ldevicePredicate).findFirst();
}

public Optional<LdeviceStatus> getLdeviceStatus(TLDevice tlDevice) {
return tlDevice.getLN0()
.getDOI()
.stream()
.filter(tdoi -> MOD_DO_NAME.equals(tdoi.getName()))
.findFirst()
.flatMap(tdoi -> tdoi.getSDIOrDAI()
.stream()
.filter(dai -> dai.getClass().equals(TDAI.class))
.map(TDAI.class::cast)
.filter(tdai -> STVAL_DA_NAME.equals(tdai.getName()))
.map(TDAI::getVal)
.flatMap(Collection::stream)
.findFirst()
.map(TVal::getValue))
.map(LdeviceStatus::fromValue);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-FileCopyrightText: 2022 RTE FRANCE
//
// SPDX-License-Identifier: Apache-2.0

package org.lfenergy.compas.sct.commons;

import org.lfenergy.compas.scl2007b4.model.*;
import org.lfenergy.compas.sct.commons.api.LnReader;

import java.util.stream.Stream;

public class LnService implements LnReader {

public Stream<TAnyLN> getAnylns(TLDevice tlDevice) {
return Stream.concat(Stream.of(tlDevice.getLN0()), tlDevice.getLN().stream());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-FileCopyrightText: 2022 RTE FRANCE
//
// SPDX-License-Identifier: Apache-2.0

package org.lfenergy.compas.sct.commons;

import org.lfenergy.compas.scl2007b4.model.TDataTypeTemplates;
import org.lfenergy.compas.scl2007b4.model.TLNodeType;
import org.lfenergy.compas.sct.commons.api.LnodeTypeReader;

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

public class LnodeTypeService implements LnodeTypeReader {

public Stream<TLNodeType> getLnodeTypes(TDataTypeTemplates tDataTypeTemplates) {
return tDataTypeTemplates.getLNodeType().stream();
}

public Stream<TLNodeType> getFilteredLnodeTypes(TDataTypeTemplates tDataTypeTemplates, Predicate<TLNodeType> tlNodeTypePredicate) {
return getLnodeTypes(tDataTypeTemplates).filter(tlNodeTypePredicate);
}

public Optional<TLNodeType> findLnodeType(TDataTypeTemplates tDataTypeTemplates, Predicate<TLNodeType> tlNodeTypePredicate) {
return getFilteredLnodeTypes(tDataTypeTemplates, tlNodeTypePredicate).findFirst();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import org.lfenergy.compas.sct.commons.scl.dtt.DataTypeTemplateAdapter;
import org.lfenergy.compas.sct.commons.scl.dtt.EnumTypeAdapter;
import org.lfenergy.compas.sct.commons.scl.ied.*;
import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter;
import org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter;

import java.util.*;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -78,18 +80,14 @@ public List<ControlBlock> getExtRefSourceInfo(SCL scd, ExtRefInfo extRefInfo) th
throw new ScdException("Internal binding can't have control block");
}

SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);

// Get CBs
IEDAdapter srcIEDAdapter = sclRootAdapter.getIEDAdapterByName(bindingInfo.getIedName());
LDeviceAdapter srcLDeviceAdapter = srcIEDAdapter.findLDeviceAdapterByLdInst(extRefInfo.getBindingInfo().getLdInst())
.orElseThrow();

List<AbstractLNAdapter<?>> aLNAdapters = srcLDeviceAdapter.getLNAdaptersIncludingLN0();

return aLNAdapters.stream()
.map(abstractLNAdapter1 -> abstractLNAdapter1.getControlBlocksForMatchingFCDA(extRefInfo))
.flatMap(Collection::stream)
return new SclRootAdapter(scd)
.getIEDAdapterByName(bindingInfo.getIedName())
.findLDeviceAdapterByLdInst(extRefInfo.getBindingInfo().getLdInst())
.orElseThrow()
.getLNAdaptersIncludingLN0()
.stream()
.flatMap(lnAdapter -> lnAdapter.getControlBlocksForMatchingFCDA(extRefInfo))
.toList();
}

Expand Down
Loading

0 comments on commit d822129

Please sign in to comment.