diff --git a/pom.xml b/pom.xml index b31c36062..17e482332 100644 --- a/pom.xml +++ b/pom.xml @@ -134,6 +134,7 @@ ${java.version} ${java.version} + --enable-preview @@ -145,6 +146,11 @@ org.apache.maven.plugins maven-surefire-plugin 2.22.2 + + + + @{argLine} --enable-preview + org.apache.maven.plugins diff --git a/sct-app/src/test/java/org.lfenergy.compas.sct.app/SclAutomationServiceIntegrationTest.java b/sct-app/src/test/java/org.lfenergy.compas.sct.app/SclAutomationServiceIntegrationTest.java index 5ccc21468..d4aaea1ca 100644 --- a/sct-app/src/test/java/org.lfenergy.compas.sct.app/SclAutomationServiceIntegrationTest.java +++ b/sct-app/src/test/java/org.lfenergy.compas.sct.app/SclAutomationServiceIntegrationTest.java @@ -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; diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ControlBlockService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ControlBlockService.java index eafecb9ea..5f28d9e61 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ControlBlockService.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ControlBlockService.java @@ -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; diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/DataSetService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/DataSetService.java new file mode 100644 index 000000000..1bb894e2f --- /dev/null +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/DataSetService.java @@ -0,0 +1,33 @@ +// 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 java.util.Optional; +import java.util.function.Predicate; +import java.util.stream.Stream; + +public class DataSetService { + + public Stream 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 getFilteredDataSets(TAnyLN tAnyLN, Predicate dataSetPredicate) { + return getDataSets(tAnyLN).filter(dataSetPredicate); + } + + public Optional findDataSet(TAnyLN tAnyLN, Predicate dataSetPredicate) { + return getFilteredDataSets(tAnyLN, dataSetPredicate).findFirst(); + } +} diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/DoService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/DoService.java new file mode 100644 index 000000000..9b2683a81 --- /dev/null +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/DoService.java @@ -0,0 +1,28 @@ +// SPDX-FileCopyrightText: 2023 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 java.util.Optional; +import java.util.function.Predicate; +import java.util.stream.Stream; + +public class DoService { + + public Stream getDos(TLNodeType tlNodeType) { + return tlNodeType.getDO().stream(); + } + + public Stream getFilteredDos(TLNodeType tlNodeType, Predicate tdoPredicate) { + return getDos(tlNodeType).filter(tdoPredicate); + } + + public Optional findDo(TLNodeType tlNodeType, Predicate tdoPredicate) { + return getFilteredDos(tlNodeType, tdoPredicate).findFirst(); + } + +} diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/DoTypeService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/DoTypeService.java new file mode 100644 index 000000000..477c867a5 --- /dev/null +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/DoTypeService.java @@ -0,0 +1,28 @@ +// SPDX-FileCopyrightText: 2023 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 java.util.Optional; +import java.util.function.Predicate; +import java.util.stream.Stream; + +public class DoTypeService { + + public Stream getDoTypes(TDataTypeTemplates tDataTypeTemplates) { + return tDataTypeTemplates.getDOType().stream(); + } + + public Stream getFilteredDoTypes(TDataTypeTemplates tDataTypeTemplates, Predicate tdoTypePredicate) { + return getDoTypes(tDataTypeTemplates).filter(tdoTypePredicate); + } + + public Optional findDoType(TDataTypeTemplates tDataTypeTemplates, Predicate tdoTypePredicate) { + return getFilteredDoTypes(tDataTypeTemplates, tdoTypePredicate).findFirst(); + } + +} diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefReaderService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefReaderService.java new file mode 100644 index 000000000..380a2d75f --- /dev/null +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefReaderService.java @@ -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 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); + }; + } +} diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefService.java index bdfe88d38..ac5f6f4ff 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefService.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefService.java @@ -8,10 +8,19 @@ import org.lfenergy.compas.sct.commons.api.ExtRefEditor; import org.lfenergy.compas.sct.commons.dto.*; import org.lfenergy.compas.sct.commons.exception.ScdException; -import org.lfenergy.compas.sct.commons.model.epf.*; +import org.lfenergy.compas.sct.commons.model.epf.EPF; +import org.lfenergy.compas.sct.commons.model.epf.TCBscopeType; +import org.lfenergy.compas.sct.commons.model.epf.TChannel; +import org.lfenergy.compas.sct.commons.model.epf.TChannelType; 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.ActiveStatus; +import org.lfenergy.compas.sct.commons.util.PrivateEnum; +import org.lfenergy.compas.sct.commons.util.PrivateUtils; +import org.lfenergy.compas.sct.commons.util.Utils; import java.util.*; import java.util.function.Function; @@ -19,7 +28,7 @@ import static org.apache.commons.lang3.StringUtils.*; import static org.lfenergy.compas.sct.commons.util.CommonConstants.*; -import static org.lfenergy.compas.sct.commons.util.Utils.*; +import static org.lfenergy.compas.sct.commons.util.Utils.isExtRefFeedBySameControlBlock; public class ExtRefService implements ExtRefEditor { private static final String INVALID_OR_MISSING_ATTRIBUTES_IN_EXT_REF_BINDING_INFO = "Invalid or missing attributes in ExtRef binding info"; @@ -217,7 +226,9 @@ private static List getIedSources(SclRootAdapter sclRootAdapter, TCompasBa .map(lnAdapter -> isValidDataTypeTemplate(lnAdapter, channel)) .orElse(false)) .orElse(false)) - .map(IEDAdapter::getCurrentElem).limit(2).toList(); + .map(IEDAdapter::getCurrentElem) + .limit(2) + .toList(); } /** @@ -259,10 +270,10 @@ private static boolean doesIcdHeaderMatchLDEPFChannel(IEDAdapter iedAdapter, TCh * @return LDeviceAdapter object that matches the EPF channel */ private static Optional getActiveSourceLDeviceByLDEPFChannel(IEDAdapter iedAdapter, TChannel channel) { - return iedAdapter.findLDeviceAdapterByLdInst(channel.getLDInst()) - .filter(lDeviceAdapter -> new Ldevice(lDeviceAdapter.getCurrentElem()).getLdeviceStatus() - .map(status -> status.equals(LdeviceStatus.ON)) - .orElse(false)); + LdeviceService ldeviceService = new LdeviceService(); + 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)); } /** @@ -272,13 +283,14 @@ private static Optional getActiveSourceLDeviceByLDEPFChannel(IED * @return AbstractLNAdapter object that matches the EPF channel */ private static Optional> getActiveLNSourceByLDEPFChannel(LDeviceAdapter lDeviceAdapter, TChannel channel) { - return lDeviceAdapter.getLNAdaptersIncludingLN0().stream() + return lDeviceAdapter.getLNAdaptersIncludingLN0() + .stream() .filter(lnAdapter -> lnAdapter.getLNClass().equals(channel.getLNClass()) && lnAdapter.getLNInst().equals(channel.getLNInst()) && trimToEmpty(channel.getLNPrefix()).equals(trimToEmpty(lnAdapter.getPrefix()))) .findFirst() .filter(lnAdapter -> lnAdapter.getDaiModStValValue() - .map(status -> status.equals(LdeviceStatus.ON.getValue())) + .map(status -> status.equals(ActiveStatus.ON.getValue())) .orElse(true)); } @@ -308,7 +320,7 @@ private static boolean isValidDataTypeTemplate(AbstractLNAdapter lnAdapter, T return lnAdapter.getDataTypeTemplateAdapter().getLNodeTypeAdapterById(lnAdapter.getLnType()) .filter(lNodeTypeAdapter -> { try { - lNodeTypeAdapter.check(doTypeName, daTypeName); + lNodeTypeAdapter.checkDoAndDaTypeName(doTypeName, daTypeName); } catch (ScdException ex) { return false; } @@ -358,7 +370,7 @@ private Optional updateVal(AbstractLNAdapter lnAdapter, String case DU_DA_NAME -> setting.getChannelShortLabel(); case SETVAL_DA_NAME -> LN_PREFIX_B.equals(lnAdapter.getPrefix()) || LN_PREFIX_A.equals(lnAdapter.getPrefix()) ? setting.getChannelLevModQ().value() : setting.getChannelLevMod().value(); - case STVAL_DA_NAME -> LdeviceStatus.ON.getValue(); + case STVAL_DA_NAME -> ActiveStatus.ON.getValue(); case SETSRCREF_DA_NAME -> computeDaiValue(lnAdapter, extRef, setting.getDAName()); default -> null; }; diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/IedService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/IedService.java new file mode 100644 index 000000000..4e2250910 --- /dev/null +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/IedService.java @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2023 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 java.util.Optional; +import java.util.function.Predicate; +import java.util.stream.Stream; + +public class IedService { + + public Stream getFilteredIeds(SCL scd, Predicate iedPredicate) { + return scd.getIED().stream().filter(iedPredicate); + } + + public Optional findIed(SCL scd, Predicate iedPredicate) { + return getFilteredIeds(scd, iedPredicate).findFirst(); + } +} diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LdeviceService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LdeviceService.java new file mode 100644 index 000000000..008aad426 --- /dev/null +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LdeviceService.java @@ -0,0 +1,46 @@ +// SPDX-FileCopyrightText: 2023 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.util.ActiveStatus; + +import java.util.Objects; +import java.util.Optional; +import java.util.function.Predicate; +import java.util.stream.Stream; + +public class LdeviceService { + + public Stream 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 getActiveLdevices(TIED tied) { + return getLdevices(tied) + .filter(ldevice -> getLdeviceStatus(ldevice).map(ActiveStatus.ON::equals).orElse(false)); + } + + public Stream getFilteredLdevices(TIED tied, Predicate ldevicePredicate) { + return getLdevices(tied).filter(ldevicePredicate); + } + + public Optional findLdevice(TIED tied, Predicate ldevicePredicate) { + return getFilteredLdevices(tied, ldevicePredicate).findFirst(); + } + + public Optional getLdeviceStatus(TLDevice tlDevice) { + LnService lnService = new LnService(); + return lnService.getDaiModStval(tlDevice.getLN0()); + } +} diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LnService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LnService.java new file mode 100644 index 000000000..bf4b616b8 --- /dev/null +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LnService.java @@ -0,0 +1,64 @@ +// SPDX-FileCopyrightText: 2023 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.util.ActiveStatus; + +import java.util.Collection; +import java.util.Optional; +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 LnService { + + public Stream getAnylns(TLDevice tlDevice) { + return Stream.concat(Stream.of(tlDevice.getLN0()), tlDevice.getLN().stream()); + } + + /** + * The Lnode status depends on the LN0 status. + * If Ln stVAl = null => we take the LN0 status + * If Ln stVAl = OFF => the status is OFF + * If Ln stVAl = ON => we take the LN0 status + * + * @param tAnyLN the Lnode whose the status is required + * @param ln0 the LN0 + * @return the Lnode Status + */ + public ActiveStatus getLnStatus(TAnyLN tAnyLN, LN0 ln0) { + Optional ln0Status = getDaiModStval(ln0); + return getDaiModStval(tAnyLN).filter(ActiveStatus.OFF::equals).orElseGet(() -> ln0Status.orElse(ActiveStatus.OFF)); + } + + public Optional getDaiModStval(TAnyLN tAnyLN) { + return tAnyLN + .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(ActiveStatus::fromValue); + } + + public Stream getActiveLns(TLDevice tlDevice) { + LN0 ln0 = tlDevice.getLN0(); + Stream tlnStream = tlDevice.getLN() + .stream() + .filter(tln -> ActiveStatus.ON.equals(getLnStatus(tln, ln0))); + Stream ln0Stream = Stream.of(ln0).filter(ln02 -> getDaiModStval(ln02).map(ActiveStatus.ON::equals).orElse(false)); + return Stream.concat(ln0Stream, tlnStream); + } +} diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LnodeTypeService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LnodeTypeService.java new file mode 100644 index 000000000..f89be724e --- /dev/null +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LnodeTypeService.java @@ -0,0 +1,28 @@ +// SPDX-FileCopyrightText: 2023 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 java.util.Optional; +import java.util.function.Predicate; +import java.util.stream.Stream; + +public class LnodeTypeService { + + public Stream getLnodeTypes(TDataTypeTemplates tDataTypeTemplates) { + return tDataTypeTemplates.getLNodeType().stream(); + } + + public Stream getFilteredLnodeTypes(TDataTypeTemplates tDataTypeTemplates, Predicate tlNodeTypePredicate) { + return getLnodeTypes(tDataTypeTemplates).filter(tlNodeTypePredicate); + } + + public Optional findLnodeType(TDataTypeTemplates tDataTypeTemplates, Predicate tlNodeTypePredicate) { + return getFilteredLnodeTypes(tDataTypeTemplates, tlNodeTypePredicate).findFirst(); + } + +} diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/SclElementsProviderService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/SclElementsProviderService.java index 51c9f46d4..77303b8ae 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/SclElementsProviderService.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/SclElementsProviderService.java @@ -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; @@ -78,18 +80,14 @@ public List 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> 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(); } diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/SclService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/SclService.java index 3364bdf52..9019c8dbe 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/SclService.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/SclService.java @@ -19,7 +19,11 @@ import org.lfenergy.compas.sct.commons.scl.dtt.LNodeTypeAdapter; import org.lfenergy.compas.sct.commons.scl.header.HeaderAdapter; import org.lfenergy.compas.sct.commons.scl.icd.IcdHeader; -import org.lfenergy.compas.sct.commons.scl.ied.*; +import org.lfenergy.compas.sct.commons.scl.ied.DAITracker; +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.scl.sstation.SubstationAdapter; import org.lfenergy.compas.sct.commons.util.PrivateUtils; import org.lfenergy.compas.sct.commons.util.Utils; @@ -107,7 +111,7 @@ public void updateDAI(SCL scd, String iedName, String ldInst, DataAttributeRef d DataTypeTemplateAdapter dttAdapter = sclRootAdapter.getDataTypeTemplateAdapter(); LNodeTypeAdapter lNodeTypeAdapter = dttAdapter.getLNodeTypeAdapterById(dataAttributeRef.getLnType()) .orElseThrow(() -> new ScdException("Unknown LNodeType : " + dataAttributeRef.getLnType())); - lNodeTypeAdapter.check(dataAttributeRef.getDoName(), dataAttributeRef.getDaName()); + lNodeTypeAdapter.checkDoAndDaTypeName(dataAttributeRef.getDoName(), dataAttributeRef.getDaName()); if (TPredefinedBasicTypeEnum.OBJ_REF == dataAttributeRef.getBType()) { Long sGroup = dataAttributeRef.getDaName().getDaiValues().keySet().stream().findFirst().orElse(-1L); diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/ExtRefReader.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/ExtRefReader.java new file mode 100644 index 000000000..68853e5ec --- /dev/null +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/ExtRefReader.java @@ -0,0 +1,15 @@ +// SPDX-FileCopyrightText: 2023 RTE FRANCE +// +// SPDX-License-Identifier: Apache-2.0 + +package org.lfenergy.compas.sct.commons.api; + +import org.lfenergy.compas.scl2007b4.model.TAnyLN; +import org.lfenergy.compas.scl2007b4.model.TExtRef; + +import java.util.stream.Stream; + +public interface ExtRefReader { + + Stream getExtRefs(TAnyLN tAnyLN); +} diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/DataAttributeRef.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/DataAttributeRef.java index e373f2871..ce1403818 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/DataAttributeRef.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/DataAttributeRef.java @@ -8,7 +8,7 @@ import lombok.*; import org.apache.commons.lang3.StringUtils; import org.lfenergy.compas.scl2007b4.model.*; -import org.lfenergy.compas.sct.commons.scl.ied.AbstractLNAdapter; +import org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter; import org.lfenergy.compas.sct.commons.util.SclConstructorHelper; import java.util.ArrayList; diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/DataSetInfo.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/DataSetInfo.java index 8ef98c1b1..02ad929a1 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/DataSetInfo.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/DataSetInfo.java @@ -5,15 +5,10 @@ import lombok.Getter; import lombok.NoArgsConstructor; -import org.lfenergy.compas.scl2007b4.model.TAnyLN; import org.lfenergy.compas.scl2007b4.model.TDataSet; -import org.lfenergy.compas.sct.commons.scl.ied.AbstractLNAdapter; import java.util.ArrayList; -import java.util.Collections; import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; /** * A representation of the model object Data Set. @@ -23,82 +18,33 @@ *

*
    *
  • {@link DataSetInfo#getName() Name}
  • - *
  • {@link DataSetInfo#getFCDAInfos() Refers to FCDA infos}
  • + *
  • {@link DataSetInfo#getFcdaInfos()} Refers to FCDA infos}
  • *
* * @see org.lfenergy.compas.scl2007b4.model.TDataSet */ @Getter @NoArgsConstructor -public class DataSetInfo extends LNodeMetaDataEmbedder{ +public class DataSetInfo extends LNodeMetaDataEmbedder { + //TODO this is a DTO object; it's meant to be used for carry information; he must be created be the one responsible for carying the info private String name; private List fcdaInfos = new ArrayList<>(); - /** - * Constructor - * @param name input - */ - public DataSetInfo(String name){ + public DataSetInfo(TDataSet tDataSet) { super(); - this.name = name; - } - - /** - * Convert DataSet object to DataSetInfo object - * @param tDataSet object - * @return DataSetInfo object value - */ - public static DataSetInfo from(TDataSet tDataSet) { - DataSetInfo dataSetInfo = new DataSetInfo(); - dataSetInfo.name = tDataSet.getName(); - dataSetInfo.fcdaInfos.addAll( - tDataSet.getFCDA().stream() - .map(tfcda -> new FCDAInfo(dataSetInfo.name, tfcda)) - .collect(Collectors.toList()) - ); - return dataSetInfo; - } - - /** - * Get Set of DataSet from LnAdapter - * @param lnAdapter object LnAdapter - * @return Set of DataSetInfo - */ - public static Set getDataSets(AbstractLNAdapter lnAdapter){ - return lnAdapter.getDataSetMatchingExtRefInfo(null) - .stream().map(DataSetInfo::from).collect(Collectors.toSet()); - } - - /** - * Add FCDA to FCDA list - * @param fcdaInfo object FCDAInfo containing FCDA datas - */ - public void addFCDAInfo(FCDAInfo fcdaInfo){ - fcdaInfos.add(fcdaInfo); - } - - /** - * Get FCDA list from DtaSetInfo - * @return FCDA list - */ - public List getFCDAInfos(){ - return Collections.unmodifiableList(fcdaInfos); - } - - /** - * Set DataSet name - * @param name string DataSet name - */ - public void setName(String name){ - this.name = name; + this.name = tDataSet.getName(); + this.fcdaInfos = tDataSet.getFCDA() + .stream() + .map(fcda -> new FCDAInfo(name, fcda.getFc(), fcda.getLdInst(), fcda.getPrefix(), fcda.getLnClass().get(0), fcda.getLnInst(), new DoTypeName(fcda.getDoName()), new DaTypeName(fcda.getDaName()), fcda.getIx())) + .toList(); } /** * Check DataSet validity * @return validity state */ - public boolean isValid(){ - if(name.length() > 32 || fcdaInfos.isEmpty()){ + public boolean isValid() { + if (name.length() > 32 || fcdaInfos.isEmpty()) { return false; } return fcdaInfos.stream().allMatch(FCDAInfo::isValid); diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/ExtRefInfo.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/ExtRefInfo.java index 1ed007267..fa8b2d300 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/ExtRefInfo.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/ExtRefInfo.java @@ -9,6 +9,11 @@ import org.lfenergy.compas.scl2007b4.model.TCompasBay; import org.lfenergy.compas.scl2007b4.model.TExtRef; import org.lfenergy.compas.scl2007b4.model.TFCDA; + +import java.util.Objects; + +import static org.apache.commons.lang3.StringUtils.trimToEmpty; + /** * A representation of the model object ExtRef. * @@ -33,7 +38,7 @@ @NoArgsConstructor @AllArgsConstructor public class ExtRefInfo extends LNodeMetaDataEmbedder{ - + //TODO this is a DTO object; it's meant to be used for carry information; he must be created be the one responsible for carying the info private ExtRefSignalInfo signalInfo; private ExtRefBindingInfo bindingInfo; private ExtRefSourceInfo sourceInfo; @@ -59,8 +64,7 @@ public ExtRefInfo(TExtRef tExtRef) { * @param prefix input * @return ExtRefInfo object */ - public static ExtRefInfo from(TExtRef tExtRef, String iedName, String ldInst, - String lnClass, String lnInst, String prefix){ + public static ExtRefInfo from(TExtRef tExtRef, String iedName, String ldInst, String lnClass, String lnInst, String prefix) { ExtRefInfo extRefInfo = new ExtRefInfo(tExtRef); extRefInfo.setHolderLDInst(ldInst); extRefInfo.setHolderIEDName(iedName); @@ -78,18 +82,15 @@ public static ExtRefInfo from(TExtRef tExtRef, String iedName, String ldInst, * @param tfcda FCDA data to check compatibilities with ExtRef * @return true if ExtRef matches FCDA for parameters ahead false otherwise */ - public boolean checkMatchingFCDA(@NonNull TFCDA tfcda){ - if(bindingInfo == null || signalInfo == null) return false; - FCDAInfo fcdaInfo = new FCDAInfo(tfcda); - FCDAInfo fcdaOfBinding = FCDAInfo.builder() - .ldInst(bindingInfo.getLdInst()) - .lnClass(bindingInfo.getLnClass()) - .lnInst(bindingInfo.getLnInst()) - .prefix(bindingInfo.getPrefix()) - .doName(new DoTypeName(signalInfo.getPDO())) - .daName(new DaTypeName(signalInfo.getPDA())) - .build(); - return fcdaInfo.checkFCDACompatibilitiesForBinding(fcdaOfBinding); + public boolean checkMatchingFCDA(@NonNull TFCDA tfcda) { + if (bindingInfo == null || signalInfo == null) return false; + + return trimToEmpty(tfcda.getLdInst()).equals(trimToEmpty(bindingInfo.getLdInst())) + && trimToEmpty(tfcda.getPrefix()).equals(trimToEmpty(bindingInfo.getPrefix())) + && trimToEmpty(tfcda.getLnClass().get(0)).equals(trimToEmpty(bindingInfo.getLnClass())) + && trimToEmpty(tfcda.getLnInst()).equals(trimToEmpty(bindingInfo.getLnInst())) + && Objects.equals(tfcda.getDoName(), signalInfo.getPDO()) + && Objects.equals(tfcda.getDaName(), signalInfo.getPDA()); } /** diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/FCDAInfo.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/FCDAInfo.java index 453f5b590..341c1d935 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/FCDAInfo.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/FCDAInfo.java @@ -10,10 +10,6 @@ import org.lfenergy.compas.scl2007b4.model.TFCDA; import org.lfenergy.compas.scl2007b4.model.TFCEnum; -import java.util.Objects; - -import static org.lfenergy.compas.sct.commons.util.Utils.equalsOrBothBlank; - /** * A representation of the model object FCDA. * @@ -34,10 +30,8 @@ * @see org.lfenergy.compas.scl2007b4.model.TFCDA */ @Getter -@Setter @AllArgsConstructor @NoArgsConstructor -@Builder public class FCDAInfo { private String dataSet; @@ -51,62 +45,6 @@ public class FCDAInfo { private DaTypeName daName; //daName.[...bdaNames] private Long ix; - /** - * Constructor - * @param dataSet input - * @param tfcda input - */ - public FCDAInfo(String dataSet, TFCDA tfcda) { - this(tfcda); - this.dataSet = dataSet; - } - - public FCDAInfo(TFCDA tfcda) { - fc = tfcda.getFc(); - ldInst = tfcda.getLdInst(); - prefix = tfcda.getPrefix(); - if (!tfcda.getLnClass().isEmpty()) { - this.lnClass = tfcda.getLnClass().get(0); - } - lnInst = tfcda.getLnInst(); - doName = new DoTypeName(tfcda.getDoName()); - daName = new DaTypeName(tfcda.getDaName()); - ix = tfcda.isSetIx() ? tfcda.getIx() : null; - } - - /** - * Gets FCDA - * @return FCDA object - */ - @JsonIgnore - public TFCDA getFCDA(){ - TFCDA tfcda = new TFCDA(); - tfcda.setLdInst(ldInst); - tfcda.setFc(fc); - if(!StringUtils.isBlank(lnClass)){ - tfcda.getLnClass().add(lnClass); - if(!StringUtils.isBlank(lnInst)){ - tfcda.setLnInst(lnInst); - } - if(!StringUtils.isBlank(prefix)){ - tfcda.setPrefix(prefix); - } - } - - if(doName != null && doName.isDefined()){ - tfcda.setDoName(doName.toString()); - } - - if(daName != null && daName.isDefined()){ - tfcda.setDaName(daName.toString()); - } - - if(ix != null){ - tfcda.setIx(ix); - } - return tfcda; - } - /** * Checks FCDAInfo validity * @return validity state @@ -115,17 +53,4 @@ public boolean isValid() { return doName != null && doName.isDefined(); } - /** - * Checks if two FCDAInfo object match for ldInst, lnInst, lnClass, lnPrefix doName and daName for search of binding control blocks - * @param fcdaInfo FCDA to copare with - * @return true if FCDAs match for binding, otherwise false - */ - public boolean checkFCDACompatibilitiesForBinding(FCDAInfo fcdaInfo) { - return equalsOrBothBlank(getLdInst(), fcdaInfo.getLdInst()) - && equalsOrBothBlank(getPrefix(), fcdaInfo.getPrefix()) - && equalsOrBothBlank(getLnClass(), fcdaInfo.getLnClass()) - && equalsOrBothBlank(getLnInst(), fcdaInfo.getLnInst()) - && Objects.equals(getDoName(), fcdaInfo.getDoName()) - && Objects.equals(getDaName(), fcdaInfo.getDaName()); - } } diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/GooseControlBlock.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/GooseControlBlock.java index 25c2fa3bf..652ef691f 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/GooseControlBlock.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/GooseControlBlock.java @@ -36,6 +36,7 @@ @Getter @Setter public class GooseControlBlock extends ControlBlock { + //TODO this is a DTO object; it's meant to be used for carry information; he must be created be the one responsible for carying the info private boolean fixedOffs = false; private TProtocol protocol; private TGSEControlTypeEnum type = TGSEControlTypeEnum.GOOSE; diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/LDeviceDTO.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/LDeviceDTO.java index b9aa8c641..479e887c6 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/LDeviceDTO.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/LDeviceDTO.java @@ -7,8 +7,8 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.lfenergy.compas.sct.commons.scl.ied.LDeviceAdapter; -import org.lfenergy.compas.sct.commons.scl.ied.LNAdapter; +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.Utils; import java.util.HashSet; diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/LNodeDTO.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/LNodeDTO.java index adba8b9f2..ecc3986cf 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/LNodeDTO.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/LNodeDTO.java @@ -4,16 +4,21 @@ package org.lfenergy.compas.sct.commons.dto; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.lfenergy.compas.scl2007b4.model.TAnyLN; -import org.lfenergy.compas.scl2007b4.model.TExtRef; +import org.lfenergy.compas.scl2007b4.model.*; +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.ied.AbstractLNAdapter; -import org.lfenergy.compas.sct.commons.scl.ied.LDeviceAdapter; -import org.lfenergy.compas.sct.commons.scl.ied.LNAdapter; +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.LNAdapter; +import org.lfenergy.compas.sct.commons.scl.ln.LnKey; import org.lfenergy.compas.sct.commons.util.Utils; import java.util.HashSet; @@ -41,21 +46,25 @@ * * @see org.lfenergy.compas.scl2007b4.model.TLNode */ - @Slf4j @Getter @NoArgsConstructor +@EqualsAndHashCode(onlyExplicitlyIncluded = true) public class LNodeDTO { + //TODO this is a DTO object; it's meant to be used for carry information; he must be created be the one responsible for carying the info + @EqualsAndHashCode.Include private String inst; + @EqualsAndHashCode.Include private String nodeClass; private String nodeType; + @EqualsAndHashCode.Include private String prefix; - private Set extRefs = new HashSet<>(); - private Set gooseControlBlocks = new HashSet<>(); - private Set smvControlBlocks = new HashSet<>(); - private Set reportControlBlocks = new HashSet<>(); + private final Set extRefs = new HashSet<>(); + private final Set gooseControlBlocks = new HashSet<>(); + private final Set smvControlBlocks = new HashSet<>(); + private final Set reportControlBlocks = new HashSet<>(); private Set datSets = new HashSet<>(); - private Set dataAttributeRefs = new HashSet<>(); + private final Set dataAttributeRefs = new HashSet<>(); /** * Constructor @@ -110,7 +119,8 @@ public static LNodeDTO from(AbstractLNAdapter nodeAdapter, } if(options.isWithDatSet()) { - lNodeDTO.datSets = DataSetInfo.getDataSets(nodeAdapter); + DataSetService dataSetService = new DataSetService(); + lNodeDTO.datSets = dataSetService.getDataSets(nodeAdapter.getCurrentElem()).map(DataSetInfo::new).collect(Collectors.toSet()); } if(options.isWithDataAttributeRef()) { @@ -140,6 +150,50 @@ public static LNodeDTO from(AbstractLNAdapter nodeAdapter, return lNodeDTO; } + public static LNodeDTO from(TAnyLN tAnyLN, LogicalNodeOptions options, String iedName, String ldInst, SCL scl) { + log.info(Utils.entering()); + LnKey lnKey = switch (tAnyLN) { + case LN0 ln0 -> new LnKey(ln0); + case TLN tln -> new LnKey(tln); + default -> throw new IllegalStateException("Unexpected value: " + tAnyLN); + }; + String inst = lnKey.getInst(); + String lnClass = lnKey.getLnClass(); + String prefix = lnKey.getPrefix(); + String lnType = tAnyLN.getLnType(); + LNodeDTO lNodeDTO = new LNodeDTO(inst, lnClass, prefix, lnType); + if (options.isWithExtRef()) { + List extRefInfos = new ExtRefReaderService().getExtRefs(tAnyLN) + .map(extRef -> ExtRefInfo.from(extRef, iedName, ldInst, lnClass, inst, prefix)) + .toList(); + lNodeDTO.addAllExtRefInfo(extRefInfos); + } + if (options.isWithDatSet()) { + List dataSetInfos = new DataSetService().getDataSets(tAnyLN) + .map(DataSetInfo::new) + .distinct() + .toList(); + lNodeDTO.addAllDatSets(dataSetInfos); + } + + if (options.isWithDataAttributeRef()) { + DataAttributeRef filter = DataAttributeRef.builder() + .lnInst(inst) + .lnClass(lnClass) + .prefix(prefix) + .lnType(lnType) + .build(); + + TLNodeType lnodeType = new LnodeTypeService().findLnodeType(scl.getDataTypeTemplates(), lnodeType1 -> lnodeType1.getId().equals(lnType)) + .orElseThrow(() -> new IllegalArgumentException("Corrupted SCD file: reference to unknown lnType(" + lnType + ")")); + List dataAttributeRefList = new LNodeTypeAdapter(new DataTypeTemplateAdapter(new SclRootAdapter(scl), scl.getDataTypeTemplates()), lnodeType) + .getDataAttributeRefs(filter); + lNodeDTO.addAllDataAttributeRef(dataAttributeRefList); + } + log.info(Utils.leaving()); + return lNodeDTO; + } + /** * Sets LNode Inst value * @param inst input diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/LNodeMetaData.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/LNodeMetaData.java index c59cc0227..b739ab12e 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/LNodeMetaData.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/LNodeMetaData.java @@ -8,8 +8,8 @@ import lombok.NoArgsConstructor; import lombok.NonNull; import lombok.Setter; -import org.lfenergy.compas.sct.commons.scl.ied.AbstractLNAdapter; -import org.lfenergy.compas.sct.commons.scl.ied.LDeviceAdapter; +import org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter; +import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter; /** * A representation of common attributes that defines LDName, LNName. diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/ReportControlBlock.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/ReportControlBlock.java index 27353cfa9..eec1d8b6f 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/ReportControlBlock.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/ReportControlBlock.java @@ -40,7 +40,7 @@ @Getter @Setter public class ReportControlBlock extends ControlBlock { - + //TODO this is a DTO object; it's meant to be used for carry information; he must be created be the one responsible for carying the info private TReportControl.OptFields optFields = newDefaultOptFields(); protected TTrgOps trgOps = newDefaultTrgOps(); protected long intgPd = 60000L; diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SMVControlBlock.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SMVControlBlock.java index defd366fd..5bcc74452 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SMVControlBlock.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SMVControlBlock.java @@ -39,8 +39,8 @@ */ @Getter @Setter -public class SMVControlBlock extends ControlBlock{ - +public class SMVControlBlock extends ControlBlock { + //TODO this is a DTO object; it's meant to be used for carry information; he must be created be the one responsible for carying the info private TSampledValueControl.SmvOpts smvOpts = newDefaultSmvOpts(); private TProtocol protocol; private boolean multicast = true; diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ObjectReference.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ObjectReference.java index 9f1c02d31..e7539addf 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ObjectReference.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ObjectReference.java @@ -9,6 +9,8 @@ import org.lfenergy.compas.scl2007b4.model.TExtRef; import org.lfenergy.compas.scl2007b4.model.TLLN0Enum; import org.lfenergy.compas.sct.commons.dto.ExtrefTarget; +import org.lfenergy.compas.sct.commons.scl.ln.LN0Adapter; +import org.lfenergy.compas.sct.commons.scl.ln.LNAdapter; /** * A representation of the model object @@ -31,8 +33,8 @@ * LDName = "name" attribute of IEDName element + "inst" attribute of LDevice element * LNName = "prefix" + "lnClass" + "lnInst" * - * @see org.lfenergy.compas.sct.commons.scl.ied.LNAdapter - * @see org.lfenergy.compas.sct.commons.scl.ied.LN0Adapter + * @see LNAdapter + * @see LN0Adapter * @see org.lfenergy.compas.sct.commons.scl.ied.IEDAdapter */ @Getter diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/dtt/DOTypeAdapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/dtt/DOTypeAdapter.java index 50577f3ae..32195a88c 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/dtt/DOTypeAdapter.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/dtt/DOTypeAdapter.java @@ -466,9 +466,8 @@ public List getDataAttributeRefs(DataAttributeRef rootDataAttr } DataAttributeRef currentDataAttributeRef = DataAttributeRef.copyFrom(rootDataAttributeRef); currentDataAttributeRef.addDoStructName(tsdo.getName()); - parentAdapter.getDOTypeAdapterById(tsdo.getType()).ifPresent( - doTypeAdapter -> - resultDataAttributeRefs.addAll(doTypeAdapter.getDataAttributeRefs(currentDataAttributeRef, filter))); + parentAdapter.getDOTypeAdapterById(tsdo.getType()) + .ifPresent(doTypeAdapter -> resultDataAttributeRefs.addAll(doTypeAdapter.getDataAttributeRefs(currentDataAttributeRef, filter))); } } return resultDataAttributeRefs; @@ -486,8 +485,8 @@ public List getDataAttributeRefs(DataAttributeRef rootDataAttr * @param da DA containing information to summarize * @return list of completed Data Attribute References beginning from this DoType. */ - private List getDataAttributeRefsOfDA(DataAttributeRef rootDataAttributeRef, DataAttributeRef filter, TDA da){ - if(excludedByFilter(filter, da)){ + private List getDataAttributeRefsOfDA(DataAttributeRef rootDataAttributeRef, DataAttributeRef filter, TDA da) { + if (excludedByFilter(filter, da)) { return Collections.emptyList(); } DataAttributeRef currentDataAttributeRef = DataAttributeRef.copyFrom(rootDataAttributeRef); @@ -496,8 +495,8 @@ private List getDataAttributeRefsOfDA(DataAttributeRef rootDat currentDataAttributeRef.getDaName().setBType(da.getBType()); if(da.getBType() == TPredefinedBasicTypeEnum.STRUCT){ return parentAdapter.getDATypeAdapterById(da.getType()) - .map(daTypeAdapter -> daTypeAdapter.getDataAttributeRefs(currentDataAttributeRef, filter)) - .orElse(Collections.emptyList()); + .map(daTypeAdapter -> daTypeAdapter.getDataAttributeRefs(currentDataAttributeRef, filter)) + .orElse(Collections.emptyList()); } else { currentDataAttributeRef.getDaName().setType(da.getType()); currentDataAttributeRef.getDaName().setValImport(da.isValImport()); diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/dtt/LNodeTypeAdapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/dtt/LNodeTypeAdapter.java index ae3f530af..78b312f61 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/dtt/LNodeTypeAdapter.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/dtt/LNodeTypeAdapter.java @@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.tuple.Pair; import org.lfenergy.compas.scl2007b4.model.TDO; +import org.lfenergy.compas.scl2007b4.model.TDOType; import org.lfenergy.compas.scl2007b4.model.TLNodeType; import org.lfenergy.compas.scl2007b4.model.TPredefinedBasicTypeEnum; import org.lfenergy.compas.sct.commons.dto.DaTypeName; @@ -166,37 +167,31 @@ public Optional getDOTypeId(String doName) { */ public List getDataAttributeRefs(@NonNull DataAttributeRef filter) { - List dataAttributeRefs = new ArrayList<>(); - if (filter.isDaNameDefined()) { + if (filter.getDaName().isDefined()) { try { - check(filter.getDoName(), filter.getDaName()); + checkDoAndDaTypeName(filter.getDoName(), filter.getDaName()); } catch (ScdException e) { log.error(e.getMessage()); - return dataAttributeRefs; + return new ArrayList<>(); } } - DataAttributeRef rootDataAttributeRef = new DataAttributeRef(); - rootDataAttributeRef.setLnType(currentElem.getId()); - rootDataAttributeRef.setLnClass(filter.getLnClass()); - rootDataAttributeRef.setLnInst(filter.getLnInst()); - rootDataAttributeRef.setPrefix(filter.getPrefix()); - - for (TDO tdo : currentElem.getDO()) { - if (filter.isDoNameDefined() && - !filter.getDoName().getName().equals(tdo.getName())) { - continue; - } - parentAdapter.getDOTypeAdapterById(tdo.getType()).ifPresent( - doTypeAdapter -> { - DataAttributeRef currentDataAttributeRef = DataAttributeRef.copyFrom(rootDataAttributeRef); - currentDataAttributeRef.getDoName().setName(tdo.getName()); - currentDataAttributeRef.getDoName().setCdc(doTypeAdapter.getCdc()); - dataAttributeRefs.addAll(doTypeAdapter.getDataAttributeRefs(currentDataAttributeRef, filter)); - } - ); // else this should never happen or the scd won't be built in the first place and we'd never be here - } - return dataAttributeRefs; + return currentElem.getDO() + .stream() + .filter(tdo -> !filter.isDoNameDefined() || filter.getDoName().getName().equals(tdo.getName())) + .flatMap(tdo -> { + TDOType tdoType = parentAdapter.getCurrentElem().getDOType().stream().filter(tdoTypeLambda -> tdoTypeLambda.getId().equals(tdo.getType())).findFirst().orElseThrow(); + DataAttributeRef dataAttributeRef = new DataAttributeRef(); + dataAttributeRef.setPrefix(filter.getPrefix()); + dataAttributeRef.setLnClass(filter.getLnClass()); + dataAttributeRef.setLnInst(filter.getLnInst()); + dataAttributeRef.setLnType(currentElem.getId()); + dataAttributeRef.getDoName().setName(tdo.getName()); + dataAttributeRef.getDoName().setCdc(tdoType.getCdc()); + + return new DOTypeAdapter(parentAdapter, tdoType).getDataAttributeRefs(dataAttributeRef, filter).stream(); + }) + .toList(); } /** @@ -321,44 +316,31 @@ Pair findPathFromDo2DA(String doName, String daName) thro * @throws ScdException when inconsistency are found in th SCL's * DataTypeTemplate (unknown reference for example). Which should normally not happens. */ - public void check(@NonNull DoTypeName doTypeName, @NonNull DaTypeName daTypeName) throws ScdException { + public void checkDoAndDaTypeName(@NonNull DoTypeName doTypeName, @NonNull DaTypeName daTypeName) throws ScdException { if (!doTypeName.isDefined() || !daTypeName.isDefined()) { throw new ScdException("Invalid Data: data attributes information are missing"); } // check Data Object information - DOAdapter doAdapter = this.getDOAdapterByName(doTypeName.getName()).orElseThrow( - () -> new ScdException( - String.format("Unknown DO(%s) in LNodeType(%s)", doTypeName.getName(), currentElem.getId()) - ) - ); - - DOTypeAdapter doTypeAdapter = doAdapter.getDoTypeAdapter().orElseThrow( - () -> new ScdException("Corrupted SCL DataTypeTemplate, Unknown DOType id: " + doAdapter.getType()) - ); + DOAdapter doAdapter = getDOAdapterByName(doTypeName.getName()) + .orElseThrow(() -> new ScdException(String.format("Unknown DO(%s) in LNodeType(%s)", doTypeName.getName(), currentElem.getId()))); - Pair adapterPair = doTypeAdapter.checkAndCompleteStructData(doTypeName) - .orElse(null); + Optional> adapterPairOptional = doAdapter.getDoTypeAdapter() + .orElseThrow(() -> new ScdException("Corrupted SCL DataTypeTemplate, Unknown DOType id: " + doAdapter.getType())) + .checkAndCompleteStructData(doTypeName); // check coherence between Data Object and Data Attributes information - DOTypeAdapter lastDoTypeAdapter; - if (adapterPair == null) { - adapterPair = findPathFromDo2DA(doTypeName.getName(), daTypeName.getName()); - lastDoTypeAdapter = adapterPair.getValue(); - } else { - if (adapterPair.getRight().containsDAWithDAName(daTypeName.getName())) { - lastDoTypeAdapter = adapterPair.getValue(); - } else { - adapterPair = adapterPair.getRight().findPathDoTypeToDA(daTypeName.getName()); - lastDoTypeAdapter = adapterPair.getValue(); - } - } - - DAAdapter daAdapter = lastDoTypeAdapter.getDAAdapterByName(daTypeName.getName()) - .orElseThrow( - () -> new ScdException( - String.format("Unknown DA (%s) in DOType (%s) ", daTypeName.getName(), "leafSdoId") - ) - ); + DAAdapter daAdapter = adapterPairOptional + .map(Pair::getValue) + .map(doTypeAdapter -> { + if (doTypeAdapter.containsDAWithDAName(daTypeName.getName())) { + return doTypeAdapter; + } else { + return doTypeAdapter.findPathDoTypeToDA(daTypeName.getName()).getValue(); + } + }) + .orElseGet(() -> findPathFromDo2DA(doTypeName.getName(), daTypeName.getName()).getValue()) + .getDAAdapterByName(daTypeName.getName()) + .orElseThrow(() -> new ScdException(String.format("Unknown DA (%s) in DOType (%s) ", daTypeName.getName(), "leafSdoId"))); // check Data Attributes if (!daTypeName.getStructNames().isEmpty() && daAdapter.getBType() != TPredefinedBasicTypeEnum.STRUCT) { @@ -369,10 +351,8 @@ public void check(@NonNull DoTypeName doTypeName, @NonNull DaTypeName daTypeName daAdapter.check(daTypeName); } else { daTypeName.setFc(daAdapter.getCurrentElem().getFc()); - DATypeAdapter daTypeAdapter = parentAdapter.getDATypeAdapterById(daAdapter.getType()).orElseThrow( - () -> new ScdException( - String.format("Unknown DAType (%s) referenced by DA(%s)", daAdapter.getType(), daAdapter.getName()) - ) + DATypeAdapter daTypeAdapter = parentAdapter.getDATypeAdapterById(daAdapter.getType()) + .orElseThrow(() -> new ScdException(String.format("Unknown DAType (%s) referenced by DA(%s)", daAdapter.getType(), daAdapter.getName())) ); daTypeAdapter.check(daTypeName); } diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/AccessPointAdapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/AccessPointAdapter.java index 07b6167cd..9c64f66da 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/AccessPointAdapter.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/AccessPointAdapter.java @@ -10,6 +10,8 @@ import org.lfenergy.compas.sct.commons.dto.SclReportItem; import org.lfenergy.compas.sct.commons.exception.ScdException; import org.lfenergy.compas.sct.commons.scl.SclElementAdapter; +import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter; +import org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter; import org.lfenergy.compas.sct.commons.util.ServicesConfigEnum; import org.lfenergy.compas.sct.commons.util.Utils; diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/ControlBlockAdapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/ControlBlockAdapter.java index a2a887624..6902f2f5e 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/ControlBlockAdapter.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/ControlBlockAdapter.java @@ -11,6 +11,8 @@ import org.lfenergy.compas.sct.commons.scl.SclElementAdapter; import org.lfenergy.compas.sct.commons.scl.SclRootAdapter; import org.lfenergy.compas.sct.commons.scl.com.ConnectedAPAdapter; +import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter; +import org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter; import org.lfenergy.compas.sct.commons.util.ControlBlockEnum; import org.lfenergy.compas.sct.commons.util.Utils; diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/DAITracker.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/DAITracker.java index 40ee993c7..d3a522a8d 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/DAITracker.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/DAITracker.java @@ -14,6 +14,7 @@ import org.lfenergy.compas.sct.commons.exception.ScdException; 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 java.util.List; import java.util.Map; diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/DOIAdapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/DOIAdapter.java index 29ab05073..5f46b012e 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/DOIAdapter.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/DOIAdapter.java @@ -8,6 +8,7 @@ import org.lfenergy.compas.sct.commons.dto.*; import org.lfenergy.compas.sct.commons.scl.ObjectReference; import org.lfenergy.compas.sct.commons.scl.SclElementAdapter; +import org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter; import org.lfenergy.compas.sct.commons.util.Utils; import java.util.*; @@ -51,7 +52,7 @@ public class DOIAdapter extends SclElementAdapter parentAdapter, TDOI currentElem) { + public DOIAdapter(AbstractLNAdapter parentAdapter, TDOI currentElem) { super(parentAdapter, currentElem); } diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/DataSetAdapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/DataSetAdapter.java index b51440f2a..4f442c13f 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/DataSetAdapter.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/DataSetAdapter.java @@ -11,6 +11,7 @@ import org.lfenergy.compas.scl2007b4.model.TFCDA; import org.lfenergy.compas.scl2007b4.model.TFCEnum; import org.lfenergy.compas.sct.commons.scl.SclElementAdapter; +import org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter; import org.lfenergy.compas.sct.commons.util.Utils; import java.util.Comparator; diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/IEDAdapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/IEDAdapter.java index 130d1044f..c890626e2 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/IEDAdapter.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/IEDAdapter.java @@ -11,6 +11,9 @@ import org.lfenergy.compas.sct.commons.dto.SclReportItem; import org.lfenergy.compas.sct.commons.exception.ScdException; import org.lfenergy.compas.sct.commons.scl.ObjectReference; +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.PrivateUtils; import org.lfenergy.compas.sct.commons.scl.SclElementAdapter; import org.lfenergy.compas.sct.commons.scl.SclRootAdapter; @@ -52,8 +55,8 @@ * * * - * @see org.lfenergy.compas.sct.commons.scl.ied.LDeviceAdapter - * @see org.lfenergy.compas.sct.commons.scl.ied.AbstractLNAdapter + * @see LDeviceAdapter + * @see AbstractLNAdapter * @see org.lfenergy.compas.sct.commons.scl.ied.AbstractDAIAdapter * @see org.lfenergy.compas.scl2007b4.model.TSettingGroups * @see Issue !3 (Add new IEDs) diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/InputsAdapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/InputsAdapter.java index 8f1a76823..b15ed6bfc 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/InputsAdapter.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/InputsAdapter.java @@ -15,8 +15,11 @@ 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.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.ActiveStatus; import org.lfenergy.compas.sct.commons.util.ControlBlockEnum; -import org.lfenergy.compas.sct.commons.util.LdeviceStatus; import org.lfenergy.compas.sct.commons.util.PrivateUtils; import org.lfenergy.compas.sct.commons.util.Utils; @@ -96,12 +99,11 @@ public List updateAllExtRefIedNames(Map icdSy return List.of(getLDeviceAdapter().buildFatalReportItem(MESSAGE_LDEVICE_STATUS_UNDEFINED)); } try { - LdeviceStatus lDeviceStatus = LdeviceStatus.fromValue(optionalLDeviceStatus.get()); + ActiveStatus lDeviceStatus = ActiveStatus.fromValue(optionalLDeviceStatus.get()); return switch (lDeviceStatus) { case ON -> getExtRefs().stream() .filter(tExtRef -> StringUtils.isNotBlank(tExtRef.getIedName()) && StringUtils.isNotBlank(tExtRef.getDesc())) - .map(extRef -> - updateExtRefIedName(extRef, icdSystemVersionToIed.get(extRef.getIedName()))) + .map(extRef -> updateExtRefIedName(extRef, icdSystemVersionToIed.get(extRef.getIedName()))) .flatMap(Optional::stream) .toList(); case OFF -> { @@ -175,7 +177,7 @@ private Optional validateExtRefSource(TExtRef extRef, IEDAdapter } return optionalSourceLDeviceStatus.map(sourceLDeviceStatus -> { try { - LdeviceStatus lDeviceStatus = LdeviceStatus.fromValue(sourceLDeviceStatus); + ActiveStatus lDeviceStatus = ActiveStatus.fromValue(sourceLDeviceStatus); return switch (lDeviceStatus) { case OFF -> SclReportItem.warning(extRefXPath(extRef.getDesc()), String.format(MESSAGE_SOURCE_LDEVICE_STATUS_OFF, sourceLDevice.getXPath())); case ON -> null; diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/Ldevice.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/Ldevice.java deleted file mode 100644 index 4dcfa5dfa..000000000 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/Ldevice.java +++ /dev/null @@ -1,52 +0,0 @@ -// SPDX-FileCopyrightText: 2021 RTE FRANCE -// -// SPDX-License-Identifier: Apache-2.0 - -package org.lfenergy.compas.sct.commons.scl.ied; - -import lombok.Getter; -import org.lfenergy.compas.scl2007b4.model.TDAI; -import org.lfenergy.compas.scl2007b4.model.TLDevice; -import org.lfenergy.compas.scl2007b4.model.TVal; -import org.lfenergy.compas.sct.commons.util.LdeviceStatus; - -import java.util.Collection; -import java.util.Optional; - -import static org.lfenergy.compas.sct.commons.util.CommonConstants.MOD_DO_NAME; -import static org.lfenergy.compas.sct.commons.util.CommonConstants.STVAL_DA_NAME; - -/** - * Object representing '' , but with utility methods to manipulate the business - * Do not include "currentElements" and so on inside this class - */ -@Getter -public class Ldevice { - - //Object is supposed to grow by the needs we have - private final String inst; - private final String ldName; - private final String description; - private final Optional ldeviceStatus; - - public Ldevice(TLDevice tlDevice) { - inst = tlDevice.getInst(); - ldName = tlDevice.getLdName(); - description = tlDevice.getDesc(); - ldeviceStatus = 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); - } -} diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/LDeviceActivation.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceActivation.java similarity index 79% rename from sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/LDeviceActivation.java rename to sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceActivation.java index cd1d995ce..284c3c863 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/LDeviceActivation.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceActivation.java @@ -2,13 +2,13 @@ // // SPDX-License-Identifier: Apache-2.0 -package org.lfenergy.compas.sct.commons.scl; +package org.lfenergy.compas.sct.commons.scl.ldevice; import lombok.Getter; import lombok.Setter; import org.apache.commons.lang3.tuple.Pair; import org.lfenergy.compas.scl2007b4.model.TCompasLDeviceStatus; -import org.lfenergy.compas.sct.commons.util.LdeviceStatus; +import org.lfenergy.compas.sct.commons.util.ActiveStatus; import java.util.List; import java.util.Set; @@ -38,15 +38,15 @@ public LDeviceActivation(List> iedNameLdInstList) { * @param enumValues enum values */ public void checkLDeviceActivationStatus(String iedName, String ldInst, TCompasLDeviceStatus compasLDeviceStatus, Set enumValues) { - if (!enumValues.contains(LdeviceStatus.ON.getValue()) && !enumValues.contains(LdeviceStatus.OFF.getValue())) { + if (!enumValues.contains(ActiveStatus.ON.getValue()) && !enumValues.contains(ActiveStatus.OFF.getValue())) { errorMessage = "The LDevice cannot be activated or desactivated because its BehaviourKind Enum contains NOT 'on' AND NOT 'off'."; } - if (!enumValues.contains(LdeviceStatus.ON.getValue()) && enumValues.contains(LdeviceStatus.OFF.getValue())) { + if (!enumValues.contains(ActiveStatus.ON.getValue()) && enumValues.contains(ActiveStatus.OFF.getValue())) { if (isDeclaredInSubstation(iedName, ldInst)) { errorMessage = "The LDevice cannot be set to 'on' but has been selected into SSD."; } else { isUpdatable = true; - newVal = LdeviceStatus.OFF.getValue(); + newVal = ActiveStatus.OFF.getValue(); } } if(compasLDeviceStatus.equals(TCompasLDeviceStatus.ACTIVE) || @@ -65,20 +65,20 @@ public void checkLDeviceActivationStatus(String iedName, String ldInst, TCompasL * @param enumValues enum values */ private void checkAuthorisationToActivateLDevice(String iedName, String ldInst, Set enumValues) { - if (!enumValues.contains(LdeviceStatus.OFF.getValue()) && enumValues.contains(LdeviceStatus.ON.getValue())) { + if (!enumValues.contains(ActiveStatus.OFF.getValue()) && enumValues.contains(ActiveStatus.ON.getValue())) { if (isDeclaredInSubstation(iedName, ldInst)) { isUpdatable = true; - newVal = LdeviceStatus.ON.getValue(); + newVal = ActiveStatus.ON.getValue(); } else { errorMessage = "The LDevice cannot be set to 'off' but has not been selected into SSD."; } } - if (enumValues.contains(LdeviceStatus.ON.getValue()) && enumValues.contains(LdeviceStatus.OFF.getValue())) { + if (enumValues.contains(ActiveStatus.ON.getValue()) && enumValues.contains(ActiveStatus.OFF.getValue())) { isUpdatable = true; if (isDeclaredInSubstation(iedName, ldInst)) { - newVal = LdeviceStatus.ON.getValue(); + newVal = ActiveStatus.ON.getValue(); } else { - newVal = LdeviceStatus.OFF.getValue(); + newVal = ActiveStatus.OFF.getValue(); } } @@ -91,19 +91,19 @@ private void checkAuthorisationToActivateLDevice(String iedName, String ldInst, * @param enumValues enum values */ private void checkAuthorisationToDeactivateLDevice(String iedName, String ldInst, Set enumValues) { - if (!enumValues.contains(LdeviceStatus.OFF.getValue()) && enumValues.contains(LdeviceStatus.ON.getValue())) { + if (!enumValues.contains(ActiveStatus.OFF.getValue()) && enumValues.contains(ActiveStatus.ON.getValue())) { if (isDeclaredInSubstation(iedName, ldInst)) { errorMessage = "The LDevice is not qualified into STD but has been selected into SSD."; } else { errorMessage = "The LDevice cannot be set to 'off' but has not been selected into SSD."; } } - if (enumValues.contains(LdeviceStatus.ON.getValue()) && enumValues.contains(LdeviceStatus.OFF.getValue())) { + if (enumValues.contains(ActiveStatus.ON.getValue()) && enumValues.contains(ActiveStatus.OFF.getValue())) { if (isDeclaredInSubstation(iedName, ldInst)) { errorMessage = "The LDevice is not qualified into STD but has been selected into SSD."; } else { isUpdatable = true; - newVal = LdeviceStatus.OFF.getValue(); + newVal = ActiveStatus.OFF.getValue(); } } } diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/LDeviceAdapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceAdapter.java similarity index 93% rename from sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/LDeviceAdapter.java rename to sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceAdapter.java index e0e12caa6..06d037c1f 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/LDeviceAdapter.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceAdapter.java @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: Apache-2.0 -package org.lfenergy.compas.sct.commons.scl.ied; +package org.lfenergy.compas.sct.commons.scl.ldevice; import lombok.extern.slf4j.Slf4j; @@ -12,15 +12,21 @@ import org.lfenergy.compas.sct.commons.exception.ScdException; import org.lfenergy.compas.sct.commons.scl.SclElementAdapter; import org.lfenergy.compas.sct.commons.scl.dtt.DataTypeTemplateAdapter; +import org.lfenergy.compas.sct.commons.scl.ied.ControlBlockAdapter; +import org.lfenergy.compas.sct.commons.scl.ied.DataSetAdapter; +import org.lfenergy.compas.sct.commons.scl.ied.IEDAdapter; +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.ln.LNAdapter; +import org.lfenergy.compas.sct.commons.util.ActiveStatus; import org.lfenergy.compas.sct.commons.util.ControlBlockEnum; -import org.lfenergy.compas.sct.commons.util.LdeviceStatus; import org.lfenergy.compas.sct.commons.util.MonitoringLnClassEnum; import org.lfenergy.compas.sct.commons.util.Utils; import java.util.*; -import static org.lfenergy.compas.sct.commons.scl.ied.AbstractLNAdapter.MOD_DO_TYPE_NAME; -import static org.lfenergy.compas.sct.commons.scl.ied.AbstractLNAdapter.STVAL_DA_TYPE_NAME; +import static org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter.MOD_DO_TYPE_NAME; +import static org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter.STVAL_DA_TYPE_NAME; import static org.lfenergy.compas.sct.commons.util.CommonConstants.*; import static org.lfenergy.compas.sct.commons.util.Utils.copySclElement; @@ -47,8 +53,8 @@ * * * - * @see org.lfenergy.compas.sct.commons.scl.ied.LNAdapter - * @see org.lfenergy.compas.sct.commons.scl.ied.LN0Adapter + * @see LNAdapter + * @see LN0Adapter * @see org.lfenergy.compas.scl2007b4.model.TLDevice * @see org.lfenergy.compas.scl2007b4.model.TDOI * @see org.lfenergy.compas.scl2007b4.model.TDAI @@ -79,13 +85,13 @@ public LDeviceAdapter(IEDAdapter parentAdapter, TLDevice currentElem) { */ public void createHmiReportControlBlocks(List fcdas) { LN0Adapter ln0 = getLN0Adapter(); - if (!ln0.getDaiModStValValue().map(LdeviceStatus::fromValue).map(LdeviceStatus.ON::equals).orElse(false)) return; + if (!ln0.getDaiModStValValue().map(ActiveStatus::fromValue).map(ActiveStatus.ON::equals).orElse(false)) return; fcdas.stream() .filter(fcda -> getInst().equals(fcda.getLdInst()) && fcda.isSetLnClass()) .forEach(fcda -> (fcda.getLnClass().get(0).equals(TLLN0Enum.LLN_0.value()) ? Optional.of(ln0) // ln0 Mod stVal "ON" has already been checked, no need to check it again : - findLnAdapter(fcda.getLnClass().get(0), fcda.getLnInst(), fcda.getPrefix()).filter(lnAdapter -> lnAdapter.getDaiModStValValue().map(LdeviceStatus::fromValue).map(LdeviceStatus.ON::equals).orElse(true))) + findLnAdapter(fcda.getLnClass().get(0), fcda.getLnInst(), fcda.getPrefix()).filter(lnAdapter -> lnAdapter.getDaiModStValValue().map(ActiveStatus::fromValue).map(ActiveStatus.ON::equals).orElse(true))) .map(sourceLn -> sourceLn.getDAI(new DataAttributeRef(fcda), false)) .filter(das -> das.stream().anyMatch(da -> fcda.getFc() == da.getFc())) // getDAI does not filter on DA. .ifPresent(dataAttributeRefs -> createHmiReportCB(ln0, fcda))); @@ -94,12 +100,12 @@ public void createHmiReportControlBlocks(List fcdas) { private void createHmiReportCB(LN0Adapter ln0, TFCDA fcda) { boolean isFcMx = fcda.getFc() == TFCEnum.MX; String dataSetSuffix = getInst().toUpperCase(Locale.ENGLISH) + ATTRIBUTE_VALUE_SEPARATOR + (isFcMx ? "CYPO" : "DQPO"); - DataSetAdapter dataSet = ln0.createDataSetIfNotExists(DATASET_NAME_PREFIX + dataSetSuffix, ControlBlockEnum.REPORT); + String dataSetName = DATASET_NAME_PREFIX + dataSetSuffix; + DataSetAdapter dataSet = ln0.createDataSetIfNotExists(dataSetName, ControlBlockEnum.REPORT); dataSet.createFCDAIfNotExists(fcda.getLdInst(), fcda.getPrefix(), fcda.getLnClass().get(0), fcda.getLnInst(), fcda.getDoName(), fcda.getDaName(), fcda.getFc()); String cbName = CONTROLBLOCK_NAME_PREFIX + dataSetSuffix; String cbId = ln0.generateControlBlockId(getLdName(), cbName); - String datSet = dataSet.getCurrentElem().getName(); - ControlBlockAdapter controlBlockAdapter = ln0.createControlBlockIfNotExists(cbName, cbId, datSet, ControlBlockEnum.REPORT); + ControlBlockAdapter controlBlockAdapter = ln0.createControlBlockIfNotExists(cbName, cbId, dataSetName, ControlBlockEnum.REPORT); if (isFcMx) { TReportControl tReportControl = (TReportControl) controlBlockAdapter.getCurrentElem(); tReportControl.setIntgPd(INTG_PD_VALUE_FOR_FC_MX); @@ -378,7 +384,7 @@ public Set findSourceDA(TExtRef extRef) { * @param controlBlockEnum the type of DataSet we want to check for creation capability. * @return true if parent AccessPoint has the capability, false otherwise */ - protected boolean hasDataSetCreationCapability(ControlBlockEnum controlBlockEnum) { + public boolean hasDataSetCreationCapability(ControlBlockEnum controlBlockEnum) { Objects.requireNonNull(controlBlockEnum); TAccessPoint accessPoint = getAccessPoint(); if (!accessPoint.isSetServices()) { @@ -404,7 +410,7 @@ private boolean hasDatSetConfOrDyn(TServiceSettings tServiceSettings) { * @param controlBlockEnum the type of ControlBlock we want to check for creation capability. * @return true if parent AccessPoint has the capability, false otherwise */ - protected boolean hasControlBlockCreationCapability(ControlBlockEnum controlBlockEnum) { + public boolean hasControlBlockCreationCapability(ControlBlockEnum controlBlockEnum) { Objects.requireNonNull(controlBlockEnum); TAccessPoint accessPoint = getAccessPoint(); if (!accessPoint.isSetServices()) { @@ -500,8 +506,8 @@ public List getExtRefBayReferenceForActifLDEPF(fi return Collections.emptyList(); } - getLDeviceStatus().map(LdeviceStatus::fromValue).ifPresentOrElse(s -> { - if (LdeviceStatus.ON.equals(s)) { + getLDeviceStatus().map(ActiveStatus::fromValue).ifPresentOrElse(s -> { + if (ActiveStatus.ON.equals(s)) { extRefBayReferenceList.addAll(getLN0Adapter().getInputsAdapter().getCurrentElem().getExtRef().stream().map(extRef -> new ExtRefInfo.ExtRefBayReference(parentIedAdapter.getName(), parentIedAdapter.getPrivateCompasBay().get(), extRef)).toList()); } }, () -> sclReportItems.add(SclReportItem.error(getXPath(), "There is no DOI@name=" + MOD_DO_TYPE_NAME + "/DAI@name=" + STVAL_DA_TYPE_NAME + "/Val for LDevice@inst" + LDEVICE_LDEPF))); diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/AbstractLNAdapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/AbstractLNAdapter.java similarity index 91% rename from sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/AbstractLNAdapter.java rename to sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/AbstractLNAdapter.java index 31e00995d..10bec3295 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/AbstractLNAdapter.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/AbstractLNAdapter.java @@ -1,13 +1,14 @@ // SPDX-FileCopyrightText: 2021 RTE FRANCE // // SPDX-License-Identifier: Apache-2.0 -package org.lfenergy.compas.sct.commons.scl.ied; +package org.lfenergy.compas.sct.commons.scl.ln; import lombok.Getter; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.lfenergy.compas.scl2007b4.model.*; +import org.lfenergy.compas.sct.commons.DataSetService; import org.lfenergy.compas.sct.commons.dto.*; import org.lfenergy.compas.sct.commons.exception.ScdException; import org.lfenergy.compas.sct.commons.scl.ObjectReference; @@ -16,6 +17,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.dtt.LNodeTypeAdapter; +import org.lfenergy.compas.sct.commons.scl.ied.*; +import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter; import org.lfenergy.compas.sct.commons.util.ControlBlockEnum; import java.util.*; @@ -28,7 +31,7 @@ /** * A representation of the model object - * {@link org.lfenergy.compas.sct.commons.scl.ied.AbstractLNAdapter AbstractLNAdapter}. + * {@link AbstractLNAdapter AbstractLNAdapter}. *

* The following features are supported: *

@@ -321,22 +324,10 @@ protected void updateExtRefBindingInfo(TExtRef extRef, ExtRefInfo extRefInfo) { * @param extRefInfo ExtRef signal data for which Control Blocks should be found (contain binding info to match with FCDA) * @return list of ControlBlock object as ControlBlocks of LNode matching FCDA and ExtRef */ - public List getControlBlocksForMatchingFCDA(@NonNull ExtRefInfo extRefInfo) { - List tDataSets = this.getDataSetMatchingExtRefInfo(extRefInfo); - return getControlBlocks(tDataSets, extRefInfo.getBindingInfo().getServiceType()); - } - - /** - * Gets all Control Blocks from LNode for specified Service Type (GOOSE, SMV and REPORT) and Data Sets - * - * @param tDataSets Data Sets for which Control Blocks are needed - * @param serviceType Service Type of Control Blocks needed - * @return list of ControlBlock objects - */ - protected List getControlBlocks(List tDataSets, TServiceType serviceType) { - return tDataSets.stream() - .map(tDataSet -> getControlBlocksByDataSetRef(tDataSet.getName(), serviceType)) - .flatMap(Collection::stream).toList(); + public Stream getControlBlocksForMatchingFCDA(@NonNull ExtRefInfo extRefInfo) { + return getDataSetMatchingExtRefInfo(extRefInfo) + .map(TDataSet::getName) + .flatMap(dataSetName -> getControlBlocksByDataSetRef(dataSetName, extRefInfo.getBindingInfo().getServiceType())); } /** @@ -346,34 +337,39 @@ protected List getControlBlocks(List tDataSets, TService * @param serviceType service type to be filtered * @return all Control Blocks matching dataSetRef and a Service Type or all Service Types */ - private List getControlBlocksByDataSetRef(String dataSetRef, TServiceType serviceType) { + public Stream getControlBlocksByDataSetRef(String dataSetRef, TServiceType serviceType) { Stream streamGSEControl = Stream.empty(); Stream streamSMVControl = Stream.empty(); Stream streamReportControl = Stream.empty(); LNodeMetaData metaData = LNodeMetaData.from(this); - if (isLN0() && (serviceType == null || serviceType == TServiceType.GOOSE)) { - streamGSEControl = getTControlsByType(TGSEControl.class) - .stream() - .filter(tControl -> dataSetRef.equals(tControl.getDatSet())) - .map(tgseControl -> { - GooseControlBlock gseCbl = new GooseControlBlock(tgseControl); - gseCbl.setMetaData(metaData); - return gseCbl; - }); + if (isLN0()) { + LN0 ln0 = (LN0) currentElem; + if (serviceType == null || serviceType == TServiceType.GOOSE) { + streamGSEControl = ln0.getGSEControl() + .stream() + .filter(tControl -> dataSetRef.equals(tControl.getDatSet())) + .map(tgseControl -> { + GooseControlBlock gseCbl = new GooseControlBlock(tgseControl); + gseCbl.setMetaData(metaData); + return gseCbl; + }); + + } + if (serviceType == null || serviceType == TServiceType.SMV) { + streamSMVControl = ln0.getSampledValueControl() + .stream() + .filter(tControl -> dataSetRef.equals(tControl.getDatSet())) + .map(sampledValueControl -> { + SMVControlBlock smvCbl = new SMVControlBlock(sampledValueControl); + smvCbl.setMetaData(metaData); + return smvCbl; + }); + } } - if (isLN0() && (serviceType == null || serviceType == TServiceType.SMV)) { - streamSMVControl = getTControlsByType(TSampledValueControl.class) - .stream() - .filter(tControl -> dataSetRef.equals(tControl.getDatSet())) - .map(sampledValueControl -> { - SMVControlBlock smvCbl = new SMVControlBlock(sampledValueControl); - smvCbl.setMetaData(metaData); - return smvCbl; - }); - } + //REPORT if (serviceType == null || serviceType == TServiceType.REPORT) { - streamReportControl = getTControlsByType(TReportControl.class) + streamReportControl = currentElem.getReportControl() .stream() .filter(tControl -> dataSetRef.equals(tControl.getDatSet())) .map(reportControl -> { @@ -382,7 +378,7 @@ private List getControlBlocksByDataSetRef(String dataSetRef, TServ return rptCbl; }); } - return Stream.concat(Stream.concat(streamGSEControl, streamSMVControl), streamReportControl).toList(); + return Stream.concat(Stream.concat(streamGSEControl, streamSMVControl), streamReportControl); } /** @@ -400,7 +396,7 @@ public List getTControlsByType(Class cls) { } else if (TReportControl.class.equals(cls)) { return (List) currentElem.getReportControl(); } - throw new IllegalArgumentException("Unsupported ControlBlock %s for %s element".formatted(cls.getSimpleName(), elementXPath())); + throw new IllegalArgumentException("Unsupported ControlBlock "+cls.getSimpleName()+" for Lnode"); } /** @@ -431,20 +427,13 @@ public boolean hasControlBlock(String cbName, ControlBlockEnum controlBlockEnum) /** * retrieves all DataSets for which at least one FCDA matches with data given in ExtRefInfo for external binding * - * @param filter contains data for external binding which should match with FCDAs values + * @param extRefInfo contains data for external binding which should match with FCDAs values * @return list of Data for which at least one FCDA matches with filter datas */ - public List getDataSetMatchingExtRefInfo(ExtRefInfo filter) { - if (filter == null) { - return currentElem.getDataSet(); - } + public Stream getDataSetMatchingExtRefInfo(@NonNull ExtRefInfo extRefInfo) { return currentElem.getDataSet() .stream() - .filter(tDataSet -> tDataSet.getFCDA() - .stream() - .anyMatch(filter::checkMatchingFCDA) - ) - .toList(); + .filter(tDataSet -> tDataSet.getFCDA().stream().anyMatch(extRefInfo::checkMatchingFCDA)); } /** @@ -834,20 +823,6 @@ protected boolean matchesDataAttributes(String dataAttribute) { currentElem.getReportControl().stream().anyMatch(rptCtl -> rptCtl.getName().equals(dataAttribute)); } - /** - * Gets Data Set in LNode by its name - * - * @param dataSetName Data Set name - * @return optional of DataSetInfo - */ - public Optional getDataSetByName(String dataSetName) { - return currentElem.getDataSet() - .stream() - .filter(tDataSet -> tDataSet.getName().equals(dataSetName)) - .map(DataSetInfo::from) - .findFirst(); - } - /** * Gets DAI values for specified DA in summaraized Data Type Template * @@ -917,16 +892,16 @@ private void removeExtRefSourceBinding(final TExtRef tExtRef) { * @see LDeviceAdapter#hasDataSetCreationCapability */ public DataSetAdapter createDataSetIfNotExists(String dataSetName, ControlBlockEnum controlBlockEnum) { - return findDataSetByName(dataSetName).orElseGet(() -> { - if (!getParentLDevice().hasDataSetCreationCapability(controlBlockEnum)) { - throw new ScdException("IED/AccessPoint does not have capability to create DataSet of type %s in %s" - .formatted(controlBlockEnum, getXPath())); - } - TDataSet newDataSet = new TDataSet(); - newDataSet.setName(dataSetName); - currentElem.getDataSet().add(newDataSet); - return new DataSetAdapter(this, newDataSet); - }); + return findDataSetByName(dataSetName) + .orElseGet(() -> { + if (!getParentLDevice().hasDataSetCreationCapability(controlBlockEnum)) { + throw new ScdException("IED/AccessPoint does not have capability to create DataSet of type " + controlBlockEnum + " in " + getXPath()); + } + TDataSet newDataSet = new TDataSet(); + newDataSet.setName(dataSetName); + getCurrentElem().getDataSet().add(newDataSet); + return new DataSetAdapter(this, newDataSet); + }); } /** @@ -952,7 +927,8 @@ public ControlBlockAdapter addControlBlock(ControlBlock controlBlock) { ); } - if (this.getDataSetByName(controlBlock.getDataSetRef()).isEmpty()) { + DataSetService dataSetService = new DataSetService(); + if (dataSetService.findDataSet(currentElem, tDataSet -> tDataSet.getName().equals(controlBlock.getDataSetRef())).isEmpty()) { throw new ScdException("Cannot create ControlBlock %s %s because target DataSet %s does not exists in %s" .formatted(controlBlock.getClass().getSimpleName(), controlBlock.getName(), controlBlock.getDataSetRef(), getXPath()) ); diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/LN0Adapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LN0Adapter.java similarity index 97% rename from sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/LN0Adapter.java rename to sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LN0Adapter.java index 98d8e8b0c..cab641278 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/LN0Adapter.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LN0Adapter.java @@ -2,14 +2,16 @@ // // SPDX-License-Identifier: Apache-2.0 -package org.lfenergy.compas.sct.commons.scl.ied; +package org.lfenergy.compas.sct.commons.scl.ln; import org.apache.commons.lang3.tuple.Pair; import org.lfenergy.compas.scl2007b4.model.*; import org.lfenergy.compas.sct.commons.dto.*; -import org.lfenergy.compas.sct.commons.scl.LDeviceActivation; +import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceActivation; import org.lfenergy.compas.sct.commons.scl.ObjectReference; +import org.lfenergy.compas.sct.commons.scl.ied.InputsAdapter; +import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter; import org.lfenergy.compas.sct.commons.util.PrivateUtils; import java.util.List; @@ -22,7 +24,7 @@ /** * A representation of the model object - * {@link org.lfenergy.compas.sct.commons.scl.ied.LN0Adapter LN0Adapter}. + * {@link LN0Adapter LN0Adapter}. *

* The following features are supported: *

@@ -65,7 +67,7 @@ * * * @see org.lfenergy.compas.scl2007b4.model.TLN0 - * @see org.lfenergy.compas.sct.commons.scl.ied.AbstractLNAdapter + * @see AbstractLNAdapter */ public class LN0Adapter extends AbstractLNAdapter { diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/LNAdapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LNAdapter.java similarity index 95% rename from sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/LNAdapter.java rename to sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LNAdapter.java index 983156336..3a5002b4e 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/LNAdapter.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LNAdapter.java @@ -2,13 +2,14 @@ // // SPDX-License-Identifier: Apache-2.0 -package org.lfenergy.compas.sct.commons.scl.ied; +package org.lfenergy.compas.sct.commons.scl.ln; import org.lfenergy.compas.scl2007b4.model.TLN; import org.lfenergy.compas.scl2007b4.model.TServiceType; import org.lfenergy.compas.sct.commons.dto.ExtRefSignalInfo; import org.lfenergy.compas.sct.commons.dto.DataAttributeRef; import org.lfenergy.compas.sct.commons.scl.ObjectReference; +import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter; import org.lfenergy.compas.sct.commons.util.Utils; import java.util.List; @@ -16,7 +17,7 @@ /** * A representation of the model object - * {@link org.lfenergy.compas.sct.commons.scl.ied.LNAdapter LNAdapter}. + * {@link LNAdapter LNAdapter}. *

* The following features are supported: *

@@ -58,9 +59,9 @@ * LNName = "prefix" + "lnClass" + "lnInst" * * @see org.lfenergy.compas.scl2007b4.model.TAnyLN - * @see org.lfenergy.compas.sct.commons.scl.ied.AbstractLNAdapter + * @see AbstractLNAdapter */ -public class LNAdapter extends AbstractLNAdapter{ +public class LNAdapter extends AbstractLNAdapter { /** * Constructor diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/LNAdapterBuilder.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LNAdapterBuilder.java similarity index 90% rename from sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/LNAdapterBuilder.java rename to sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LNAdapterBuilder.java index 326acdf40..47bb6dc52 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/LNAdapterBuilder.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LNAdapterBuilder.java @@ -2,14 +2,15 @@ // // SPDX-License-Identifier: Apache-2.0 -package org.lfenergy.compas.sct.commons.scl.ied; +package org.lfenergy.compas.sct.commons.scl.ln; import org.lfenergy.compas.scl2007b4.model.TLLN0Enum; import org.lfenergy.compas.sct.commons.exception.ScdException; +import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter; /** * A representation of the model object - * {@link org.lfenergy.compas.sct.commons.scl.ied.LNAdapterBuilder LNAdapterBuilder}. + * {@link LNAdapterBuilder LNAdapterBuilder}. *

* The following features are supported: *

diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LnKey.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LnKey.java new file mode 100644 index 000000000..a8aa67c41 --- /dev/null +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LnKey.java @@ -0,0 +1,37 @@ +// SPDX-FileCopyrightText: 2021 RTE FRANCE +// +// SPDX-License-Identifier: Apache-2.0 +package org.lfenergy.compas.sct.commons.scl.ln; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import org.apache.commons.lang3.StringUtils; +import org.lfenergy.compas.scl2007b4.model.LN0; +import org.lfenergy.compas.scl2007b4.model.TLN; + +@Getter +@EqualsAndHashCode +public class LnKey { + + private final String inst; + @EqualsAndHashCode.Exclude + private final String lnType; + private final String lnClass; + /** empty for LN0 */ + private final String prefix; + + public LnKey(LN0 ln0) { + this.inst = ln0.getInst(); + this.lnType = ln0.getLnType(); + this.lnClass = ln0.getLnClass().get(0); + this.prefix = StringUtils.EMPTY; + } + + public LnKey(TLN tln) { + this.inst = tln.getInst(); + this.lnType = tln.getLnType(); + this.lnClass = tln.getLnClass().get(0); + this.prefix = tln.getPrefix(); + } +} + diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/ActiveStatus.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/ActiveStatus.java new file mode 100644 index 000000000..ef04b8681 --- /dev/null +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/ActiveStatus.java @@ -0,0 +1,31 @@ +// SPDX-FileCopyrightText: 2021 RTE FRANCE +// +// SPDX-License-Identifier: Apache-2.0 + +package org.lfenergy.compas.sct.commons.util; + +import lombok.Getter; + +import java.util.Arrays; + +/** + * Object describing Status, prefere this to LdeviceStatus constants as we can get the list of constants here. + */ +public enum ActiveStatus { + ON("on"), + OFF("off"); + + @Getter + private final String value; + + ActiveStatus(String value) { + this.value = value; + } + + public static ActiveStatus fromValue(String activeStatus) { + return Arrays.stream(ActiveStatus.values()) + .filter(status -> status.getValue().equals(activeStatus)) + .findFirst() + .orElseThrow(() -> new IllegalArgumentException("The status " + activeStatus + " does not exist. It should be among " + Arrays.stream(ActiveStatus.values()).map(ActiveStatus::getValue).toList())); + } +} diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/LdeviceStatus.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/LdeviceStatus.java deleted file mode 100644 index 18fe45118..000000000 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/LdeviceStatus.java +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-FileCopyrightText: 2021 RTE FRANCE -// -// SPDX-License-Identifier: Apache-2.0 - -package org.lfenergy.compas.sct.commons.util; - -import lombok.Getter; - -import java.util.Arrays; - -/** - * Object describing Ldevice Status, prefere this to LdeviceStatus constants as we can get the list of constants here. - */ -public enum LdeviceStatus { - ON("on"), - OFF("off"); - - @Getter - private final String value; - - LdeviceStatus(String value) { - this.value = value; - } - - public static LdeviceStatus fromValue(String ldeviceStatus) { - return Arrays.stream(LdeviceStatus.values()) - .filter(status -> status.getValue().equals(ldeviceStatus)) - .findFirst() - .orElseThrow(() -> new IllegalArgumentException("The Ldevice status " + ldeviceStatus + " does not exist. It should be among " + Arrays.stream(LdeviceStatus.values()).map(LdeviceStatus::getValue).toList())); - } -} diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/Utils.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/Utils.java index 89e72a82b..b5d155e69 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/Utils.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/Utils.java @@ -13,6 +13,9 @@ import org.lfenergy.compas.scl2007b4.model.TExtRef; import org.lfenergy.compas.scl2007b4.model.TLLN0Enum; import org.lfenergy.compas.sct.commons.exception.ScdException; +import org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter; +import org.lfenergy.compas.sct.commons.scl.ied.IEDAdapter; +import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter; import javax.xml.namespace.QName; import java.util.*; diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ControlBlockServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ControlBlockServiceTest.java index f5b28b367..9045762fa 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ControlBlockServiceTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ControlBlockServiceTest.java @@ -12,16 +12,19 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import org.lfenergy.compas.scl2007b4.model.*; -import org.lfenergy.compas.sct.commons.dto.*; +import org.lfenergy.compas.sct.commons.dto.ControlBlockNetworkSettings; +import org.lfenergy.compas.sct.commons.dto.ControlBlockTarget; +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.SclElementAdapter; import org.lfenergy.compas.sct.commons.scl.SclRootAdapter; import org.lfenergy.compas.sct.commons.scl.ied.DataSetAdapter; -import org.lfenergy.compas.sct.commons.scl.ied.LDeviceAdapter; import org.lfenergy.compas.sct.commons.scl.ied.IEDAdapter; -import org.lfenergy.compas.sct.commons.scl.ied.AbstractLNAdapter; -import org.lfenergy.compas.sct.commons.scl.ied.LNAdapter; -import org.lfenergy.compas.sct.commons.scl.ied.LN0Adapter; +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.ln.LNAdapter; import org.lfenergy.compas.sct.commons.testhelpers.FCDARecord; import org.lfenergy.compas.sct.commons.testhelpers.MarshallerWrapper; import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; @@ -39,7 +42,6 @@ import java.util.stream.Stream; import static org.assertj.core.api.Assertions.*; -import static org.assertj.core.api.Assertions.assertThatCode; import static org.lfenergy.compas.scl2007b4.model.TFCEnum.ST; import static org.lfenergy.compas.sct.commons.dto.ControlBlockNetworkSettings.*; import static org.lfenergy.compas.sct.commons.testhelpers.SclHelper.*; diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/DataSetServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/DataSetServiceTest.java new file mode 100644 index 000000000..325a9d868 --- /dev/null +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/DataSetServiceTest.java @@ -0,0 +1,49 @@ +// SPDX-FileCopyrightText: 2022 2023 RTE FRANCE +// +// SPDX-License-Identifier: Apache-2.0 + +package org.lfenergy.compas.sct.commons; + +import org.junit.jupiter.api.Test; +import org.lfenergy.compas.scl2007b4.model.TDataSet; +import org.lfenergy.compas.scl2007b4.model.TLN; + +import java.util.Set; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; + +class DataSetServiceTest { + + @Test + void getDataSets_whenCalledWithLNContainsMatchingFCDA_shouldReturnDataSet() { + //Given + TDataSet dataSet = new TDataSet(); + dataSet.setName("datasetName"); + TLN tln = new TLN(); + tln.getDataSet().add(dataSet); + DataSetService dataSetService = new DataSetService(); + + //When + Set dataSetInfos = dataSetService.getDataSets(tln).collect(Collectors.toSet()); + + //Then + assertThat(dataSetInfos) + .hasSize(1) + .extracting(TDataSet::getName) + .containsExactly("datasetName"); + } + + @Test + void getDataSets_whenCalledWithNoDataSetInLN_shouldReturnEmptyList(){ + //Given + TLN tln = new TLN(); + DataSetService dataSetService = new DataSetService(); + + //When + Set dataSetInfos = dataSetService.getDataSets(tln).collect(Collectors.toSet()); + + //Then + assertThat(dataSetInfos).isEmpty(); + } +} \ No newline at end of file diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/DoServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/DoServiceTest.java new file mode 100644 index 000000000..c6633b0fb --- /dev/null +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/DoServiceTest.java @@ -0,0 +1,82 @@ +// SPDX-FileCopyrightText: 2023 RTE FRANCE +// +// SPDX-License-Identifier: Apache-2.0 + +package org.lfenergy.compas.sct.commons; + +import org.assertj.core.groups.Tuple; +import org.junit.jupiter.api.Test; +import org.lfenergy.compas.scl2007b4.model.SCL; +import org.lfenergy.compas.scl2007b4.model.TDO; +import org.lfenergy.compas.scl2007b4.model.TLNodeType; +import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +class DoServiceTest { + + @Test + void getDos() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + TLNodeType lnodeType = std.getDataTypeTemplates().getLNodeType().get(0); + DoService doService = new DoService(); + + //When + List dos = doService.getDos(lnodeType).toList(); + + //Then + assertThat(dos) + .hasSize(14) + .extracting(TDO::getName) + .containsExactly("NumInput1", + "PolConnRef1", + "BrdPos", + "ConnName1", + "PhyHealth", + "ConnRef1", + "NamPlt", + "RfHz1", + "PhyNam", + "Beh", + "BrdNum", + "ARtgLow1", + "ARtgHigh1", + "AnIn1"); + } + + @Test + void getFilteredDos() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + TLNodeType lnodeType = std.getDataTypeTemplates().getLNodeType().get(0); + DoService doService = new DoService(); + + //When + List dos = doService.getFilteredDos(lnodeType, tdo -> "NumInput1".equals(tdo.getName())).toList(); + + //Then + assertThat(dos) + .hasSize(1) + .extracting(TDO::getName, TDO::getType) + .containsExactly(Tuple.tuple("NumInput1", "RTE_X_X_X_553F8AE90EC0448B1518B00F5EAABB58_ING_V1.0.0")); + } + + @Test + void findDo() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + TLNodeType lnodeType = std.getDataTypeTemplates().getLNodeType().get(0); + DoService doService = new DoService(); + + //When + TDO tdo1 = doService.findDo(lnodeType, tdo -> "NumInput1".equals(tdo.getName())).orElseThrow(); + + //Then + assertThat(tdo1) + .extracting(TDO::getName, TDO::getType) + .containsExactly("NumInput1", "RTE_X_X_X_553F8AE90EC0448B1518B00F5EAABB58_ING_V1.0.0"); + } +} \ No newline at end of file diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/DoTypeServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/DoTypeServiceTest.java new file mode 100644 index 000000000..53a730973 --- /dev/null +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/DoTypeServiceTest.java @@ -0,0 +1,71 @@ +// SPDX-FileCopyrightText: 2023 RTE FRANCE +// +// SPDX-License-Identifier: Apache-2.0 + +package org.lfenergy.compas.sct.commons; + +import org.assertj.core.groups.Tuple; +import org.junit.jupiter.api.Test; +import org.lfenergy.compas.scl2007b4.model.SCL; +import org.lfenergy.compas.scl2007b4.model.TDOType; +import org.lfenergy.compas.scl2007b4.model.TDataTypeTemplates; +import org.lfenergy.compas.scl2007b4.model.TPredefinedCDCEnum; +import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +class DoTypeServiceTest { + + @Test + void getDoTypes() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + TDataTypeTemplates dataTypeTemplates = std.getDataTypeTemplates(); + DoTypeService doTypeService = new DoTypeService(); + + //When + List tdoTypes = doTypeService.getDoTypes(dataTypeTemplates).toList(); + + //Then + assertThat(tdoTypes) + .hasSize(47); + } + + @Test + void getFilteredDoTypes() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + TDataTypeTemplates dataTypeTemplates = std.getDataTypeTemplates(); + DoTypeService doTypeService = new DoTypeService(); + + //When + List tdoTypes = + doTypeService.getFilteredDoTypes(dataTypeTemplates, tdoType -> TPredefinedCDCEnum.DPL.equals(tdoType.getCdc())).toList(); + + //Then + assertThat(tdoTypes) + .hasSize(2) + .extracting(TDOType::getCdc, TDOType::getId) + .containsExactly(Tuple.tuple(TPredefinedCDCEnum.DPL, "RTE_X_X_X_48BA5C40D0913654FA5291A28C0D9716_DPL_V1.0.0"), + Tuple.tuple(TPredefinedCDCEnum.DPL, "RTE_X_X_X_D93000A2D6F9B026504B48576A914DA3_DPL_V1.0.0")); + + } + + @Test + void findDoType() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + TDataTypeTemplates dataTypeTemplates = std.getDataTypeTemplates(); + DoTypeService doTypeService = new DoTypeService(); + + //When + TDOType tdoType = doTypeService.findDoType(dataTypeTemplates, tdoType1 -> TPredefinedCDCEnum.DPL.equals(tdoType1.getCdc())).orElseThrow(); + + //Then + assertThat(tdoType) + .extracting(TDOType::getCdc, TDOType::getId) + .containsExactly(TPredefinedCDCEnum.DPL, "RTE_X_X_X_48BA5C40D0913654FA5291A28C0D9716_DPL_V1.0.0"); + } +} \ No newline at end of file diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ExtRefServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ExtRefServiceTest.java index 04492391a..7cfb52394 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ExtRefServiceTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ExtRefServiceTest.java @@ -16,17 +16,24 @@ import org.lfenergy.compas.sct.commons.exception.ScdException; import org.lfenergy.compas.sct.commons.model.epf.*; import org.lfenergy.compas.sct.commons.scl.SclRootAdapter; -import org.lfenergy.compas.sct.commons.scl.ied.AbstractLNAdapter; -import org.lfenergy.compas.sct.commons.scl.ied.LDeviceAdapter; +import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter; +import org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter; import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; import org.lfenergy.compas.sct.commons.util.PrivateUtils; import org.mockito.InjectMocks; import org.mockito.junit.jupiter.MockitoExtension; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.math.BigInteger; +import java.util.List; +import java.util.Objects; +import java.util.Optional; import java.util.*; import java.util.stream.Stream; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.lfenergy.compas.sct.commons.testhelpers.SclHelper.*; import static org.lfenergy.compas.sct.commons.util.CommonConstants.*; @@ -96,7 +103,7 @@ public static Stream updateAllExtRefIedNamesErrors() { "The signal ExtRef has more than one matching compas:Flow Private"), SclReportItem.error( "/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST13\"]", - "The Ldevice status test does not exist. It should be among [on, off]"), + "The status test does not exist. It should be among [on, off]"), SclReportItem.error( "/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST14\"]", "The LDevice status is undefined"), diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/HmiServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/HmiServiceTest.java index a13a86efb..b468c1560 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/HmiServiceTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/HmiServiceTest.java @@ -8,11 +8,11 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.lfenergy.compas.scl2007b4.model.*; import org.lfenergy.compas.sct.commons.scl.ied.DataSetAdapter; -import org.lfenergy.compas.sct.commons.scl.ied.LN0Adapter; -import org.lfenergy.compas.sct.commons.scl.ied.LNAdapter; +import org.lfenergy.compas.sct.commons.scl.ln.LN0Adapter; +import org.lfenergy.compas.sct.commons.scl.ln.LNAdapter; import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; import org.lfenergy.compas.sct.commons.util.CommonConstants; -import org.lfenergy.compas.sct.commons.util.LdeviceStatus; +import org.lfenergy.compas.sct.commons.util.ActiveStatus; import org.mockito.InjectMocks; import org.mockito.junit.jupiter.MockitoExtension; @@ -151,7 +151,7 @@ void createAllIhmReportControlBlocks_when_lDevice_OFF_should_not_create_dataset( SCL scd = SclTestMarshaller.getSCLFromFile("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml"); LN0Adapter ln0 = findLn0(scd, "IedName1", "LdInst11"); ln0.getDOIAdapterByName(CommonConstants.MOD_DO_NAME).getDataAdapterByName(CommonConstants.STVAL_DA_NAME).setVal("off"); - assertThat(findLDevice(scd, "IedName1", "LdInst11").getLDeviceStatus()).hasValue(LdeviceStatus.OFF.getValue()); + assertThat(findLDevice(scd, "IedName1", "LdInst11").getLDeviceStatus()).hasValue(ActiveStatus.OFF.getValue()); TFCDA fcda = newFcda("LdInst11", "ANCR", "1", null, "DoName1", null, TFCEnum.ST); // When hmiService.createAllHmiReportControlBlocks(scd, List.of(fcda)); diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/IedServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/IedServiceTest.java new file mode 100644 index 000000000..8b339c795 --- /dev/null +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/IedServiceTest.java @@ -0,0 +1,50 @@ +// SPDX-FileCopyrightText: 2023 RTE FRANCE +// +// SPDX-License-Identifier: Apache-2.0 + +package org.lfenergy.compas.sct.commons; + +import org.assertj.core.groups.Tuple; +import org.junit.jupiter.api.Test; +import org.lfenergy.compas.scl2007b4.model.SCL; +import org.lfenergy.compas.scl2007b4.model.TIED; +import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +class IedServiceTest { + + @Test + void getFilteredIeds_should_return_ldevices() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + IedService ldeviceService = new IedService(); + + //When + List tieds = ldeviceService.getFilteredIeds(std, tied -> "IED4d4fe1a8cda64cf88a5ee4176a1a0eef".equals(tied.getName())).toList(); + + //Then + assertThat(tieds) + .hasSize(1) + .extracting(TIED::getName, TIED::getType) + .containsExactly(Tuple.tuple("IED4d4fe1a8cda64cf88a5ee4176a1a0eef", "ADU")); + } + + @Test + void findIed_should_return_ldevice() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + IedService ldeviceService = new IedService(); + + //When + TIED tied = ldeviceService.findIed(std, ied -> "IED4d4fe1a8cda64cf88a5ee4176a1a0eef".equals(ied.getName())).orElseThrow(); + + //Then + assertThat(tied) + .extracting(TIED::getName, TIED::getType) + .containsExactly("IED4d4fe1a8cda64cf88a5ee4176a1a0eef", "ADU"); + } + +} \ No newline at end of file diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LdeviceServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LdeviceServiceTest.java new file mode 100644 index 000000000..445fcf09b --- /dev/null +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LdeviceServiceTest.java @@ -0,0 +1,104 @@ +// SPDX-FileCopyrightText: 2022 2023 RTE FRANCE +// +// SPDX-License-Identifier: Apache-2.0 + +package org.lfenergy.compas.sct.commons; + +import org.assertj.core.groups.Tuple; +import org.junit.jupiter.api.Test; +import org.lfenergy.compas.scl2007b4.model.SCL; +import org.lfenergy.compas.scl2007b4.model.TIED; +import org.lfenergy.compas.scl2007b4.model.TLDevice; +import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; +import org.lfenergy.compas.sct.commons.util.ActiveStatus; + +import java.util.List; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; + +class LdeviceServiceTest { + + @Test + void getLdeviceStatus_should_return_status() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + TLDevice tlDevice = std.getIED().get(0).getAccessPoint().get(0).getServer().getLDevice().get(0); + LdeviceService ldeviceService = new LdeviceService(); + + //When + Optional ldeviceStatus = ldeviceService.getLdeviceStatus(tlDevice); + + //Then + assertThat(ldeviceStatus).contains(ActiveStatus.ON); + } + + @Test + void getLdevices_should_return_ldevices() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + TIED tied = std.getIED().get(0); + LdeviceService ldeviceService = new LdeviceService(); + + //When + List tlDevices = ldeviceService.getLdevices(tied).toList(); + + //Then + assertThat(tlDevices) + .hasSize(2) + .extracting(TLDevice::getInst, TLDevice::getLdName) + .containsExactly(Tuple.tuple("LDSUIED", "VirtualSAMULDSUIED"), + Tuple.tuple("LDTM", "VirtualSAMULDTM")); + } + + @Test + void getFilteredLdevices_should_return_ldevices() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + TIED tied = std.getIED().get(0); + LdeviceService ldeviceService = new LdeviceService(); + + //When + List tlDevices = ldeviceService.getFilteredLdevices(tied, tlDevice -> "LDTM".equals(tlDevice.getInst())).toList(); + + //Then + assertThat(tlDevices) + .hasSize(1) + .extracting(TLDevice::getInst, TLDevice::getLdName) + .containsExactly(Tuple.tuple("LDTM", "VirtualSAMULDTM")); + } + + @Test + void findLdevice_should_return_ldevice() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + TIED tied = std.getIED().get(0); + LdeviceService ldeviceService = new LdeviceService(); + + //When + TLDevice ldevice = ldeviceService.findLdevice(tied, tlDevice -> "LDTM".equals(tlDevice.getInst())).orElseThrow(); + + //Then + assertThat(ldevice) + .extracting(TLDevice::getInst, TLDevice::getLdName) + .containsExactly("LDTM", "VirtualSAMULDTM"); + } + + @Test + void getActiveLdevices_should_return_ldevices() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + TIED tied = std.getIED().get(0); + LdeviceService ldeviceService = new LdeviceService(); + + //When + List tlDevices = ldeviceService.getActiveLdevices(tied).toList(); + + //Then + assertThat(tlDevices) + .hasSize(1) + .extracting(TLDevice::getInst, TLDevice::getLdName) + .containsExactly(Tuple.tuple("LDSUIED", "VirtualSAMULDSUIED")); + } + +} \ No newline at end of file diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LnServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LnServiceTest.java new file mode 100644 index 000000000..447e69f03 --- /dev/null +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LnServiceTest.java @@ -0,0 +1,84 @@ +// SPDX-FileCopyrightText: 2023 RTE FRANCE +// +// SPDX-License-Identifier: Apache-2.0 + +package org.lfenergy.compas.sct.commons; + +import org.assertj.core.groups.Tuple; +import org.junit.jupiter.api.Test; +import org.lfenergy.compas.scl2007b4.model.SCL; +import org.lfenergy.compas.scl2007b4.model.TAnyLN; +import org.lfenergy.compas.scl2007b4.model.TLDevice; +import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; +import org.lfenergy.compas.sct.commons.util.ActiveStatus; + +import java.util.List; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; + +class LnServiceTest { + + @Test + void getAnylns_should_return_lns() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + TLDevice tlDevice = std.getIED().get(0).getAccessPoint().get(0).getServer().getLDevice().get(0); + LnService lnService = new LnService(); + + //When + List tAnyLNS = lnService.getAnylns(tlDevice).toList(); + + //Then + assertThat(tAnyLNS) + .hasSize(2) + .extracting(TAnyLN::getLnType) + .containsExactly("RTE_080BBB4D93E4E704CF69E8616CAF1A74_LLN0_V1.0.0", "RTE_8884DBCF760D916CCE3EE9D1846CE46F_LPAI_V1.0.0"); + } + + @Test + void getDaiModStval_should_return_status() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + TLDevice tlDevice = std.getIED().get(0).getAccessPoint().get(0).getServer().getLDevice().get(0); + LnService lnService = new LnService(); + + //When + Optional daiModStval = lnService.getDaiModStval(tlDevice.getLN0()); + + //Then + assertThat(daiModStval).contains(ActiveStatus.ON); + } + + @Test + void getLnStatus_should_return_status() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + TLDevice tlDevice = std.getIED().get(0).getAccessPoint().get(0).getServer().getLDevice().get(0); + LnService lnService = new LnService(); + + //When + ActiveStatus lnStatus = lnService.getLnStatus(tlDevice.getLN().get(0), tlDevice.getLN0()); + + //Then + assertThat(lnStatus).isEqualTo(ActiveStatus.ON); + } + + @Test + void getActiveLns_should_return_lns() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + TLDevice tlDevice = std.getIED().get(0).getAccessPoint().get(0).getServer().getLDevice().get(0); + LnService lnService = new LnService(); + + //When + List tAnyLNS = lnService.getActiveLns(tlDevice).toList(); + + //Then + assertThat(tAnyLNS) + .hasSize(2) + .extracting(TAnyLN::getLnType, TAnyLN::getDesc) + .containsExactly(Tuple.tuple("RTE_080BBB4D93E4E704CF69E8616CAF1A74_LLN0_V1.0.0", ""), + Tuple.tuple("RTE_8884DBCF760D916CCE3EE9D1846CE46F_LPAI_V1.0.0", "")); + } +} \ No newline at end of file diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LnodeTypeServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LnodeTypeServiceTest.java new file mode 100644 index 000000000..f9af01e84 --- /dev/null +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LnodeTypeServiceTest.java @@ -0,0 +1,86 @@ +// SPDX-FileCopyrightText: 2023 RTE FRANCE +// +// SPDX-License-Identifier: Apache-2.0 + +package org.lfenergy.compas.sct.commons; + +import org.assertj.core.groups.Tuple; +import org.junit.jupiter.api.Test; +import org.lfenergy.compas.scl2007b4.model.SCL; +import org.lfenergy.compas.scl2007b4.model.TDO; +import org.lfenergy.compas.scl2007b4.model.TDataTypeTemplates; +import org.lfenergy.compas.scl2007b4.model.TLNodeType; +import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +class LnodeTypeServiceTest { + + @Test + void getLnodeTypes() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + TDataTypeTemplates dataTypeTemplates = std.getDataTypeTemplates(); + LnodeTypeService lnodeTypeService = new LnodeTypeService(); + + //When + List tlnodeTypes = lnodeTypeService.getLnodeTypes(dataTypeTemplates).toList(); + + //Then + assertThat(tlnodeTypes) + .hasSize(15) + .flatExtracting(TLNodeType::getLnClass) + .containsExactly("LPAI", + "LLN0", + "LLN0", + "TCTR", + "LSET", + "LCCH", + "LPCP", + "LGOS", + "LTMS", + "XSWI", + "GAPC", + "TVTR", + "LSYN", + "XSWI", + "LSET"); + } + + @Test + void getFilteredLnodeTypes() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + TDataTypeTemplates dataTypeTemplates = std.getDataTypeTemplates(); + LnodeTypeService lnodeTypeService = new LnodeTypeService(); + + //When + List tlnodeTypes = + lnodeTypeService.getFilteredLnodeTypes(dataTypeTemplates, tlNodeType -> tlNodeType.getLnClass().contains("LPAI")).toList(); + + //Then + assertThat(tlnodeTypes) + .hasSize(1) + .extracting(TLNodeType::getLnClass, TLNodeType::getId) + .containsExactly(Tuple.tuple(List.of("LPAI"), "RTE_8884DBCF760D916CCE3EE9D1846CE46F_LPAI_V1.0.0")); + } + + @Test + void findLnodeType() { + //Given + SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); + TDataTypeTemplates dataTypeTemplates = std.getDataTypeTemplates(); + LnodeTypeService lnodeTypeService = new LnodeTypeService(); + + //When + TLNodeType tlnodeType = + lnodeTypeService.findLnodeType(dataTypeTemplates, tlNodeType -> tlNodeType.getLnClass().contains("LPAI")).orElseThrow(); + + //Then + assertThat(tlnodeType) + .extracting(TLNodeType::getLnClass, TLNodeType::getId) + .containsExactly(List.of("LPAI"), "RTE_8884DBCF760D916CCE3EE9D1846CE46F_LPAI_V1.0.0"); + } +} \ No newline at end of file diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/SclElementsProviderServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/SclElementsProviderServiceTest.java index 16c9bbe6f..a6729e8d2 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/SclElementsProviderServiceTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/SclElementsProviderServiceTest.java @@ -13,6 +13,8 @@ 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.scl.ldevice.LDeviceAdapter; +import org.lfenergy.compas.sct.commons.scl.ln.LN0Adapter; import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; import org.mockito.InjectMocks; import org.mockito.junit.jupiter.MockitoExtension; diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/SclServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/SclServiceTest.java index b482ad8ad..3c28cdaed 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/SclServiceTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/SclServiceTest.java @@ -16,12 +16,21 @@ import org.lfenergy.compas.sct.commons.dto.*; import org.lfenergy.compas.sct.commons.exception.ScdException; import org.lfenergy.compas.sct.commons.scl.SclRootAdapter; +import org.lfenergy.compas.sct.commons.scl.ied.DOIAdapter; +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.LN0Adapter; +import org.lfenergy.compas.sct.commons.scl.ln.LNAdapter; +import org.lfenergy.compas.sct.commons.testhelpers.MarshallerWrapper; +import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; import org.lfenergy.compas.sct.commons.scl.ied.*; import org.lfenergy.compas.sct.commons.testhelpers.*; import org.mockito.InjectMocks; import org.mockito.junit.jupiter.MockitoExtension; -import java.util.*; +import java.util.List; +import java.util.Optional; +import java.util.UUID; import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/DataAttributeRefTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/DataAttributeRefTest.java index 566261db8..792f4c409 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/DataAttributeRefTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/DataAttributeRefTest.java @@ -10,7 +10,7 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import org.lfenergy.compas.scl2007b4.model.*; -import org.lfenergy.compas.sct.commons.scl.ied.LNAdapter; +import org.lfenergy.compas.sct.commons.scl.ln.LNAdapter; import java.util.List; import java.util.Map; diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/DataSetInfoTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/DataSetInfoTest.java index e500555e6..111b3e71f 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/DataSetInfoTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/DataSetInfoTest.java @@ -4,106 +4,63 @@ package org.lfenergy.compas.sct.commons.dto; -import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.lfenergy.compas.scl2007b4.model.TDataSet; -import org.lfenergy.compas.scl2007b4.model.TLN; -import org.lfenergy.compas.sct.commons.scl.ied.LNAdapter; - -import java.util.Set; import static org.assertj.core.api.Assertions.assertThat; class DataSetInfoTest { - @Test - @Tag("issue-321") - void testConstructor(){ - //Given When - DataSetInfo dataSetInfo = new DataSetInfo(); - assertThat(dataSetInfo.getName()).isNull(); - //When - dataSetInfo = new DataSetInfo("DATA_INFO"); - //Then - assertThat(dataSetInfo.getName()).isEqualTo("DATA_INFO"); - //Given - dataSetInfo.setName("DATA_INFO1"); - dataSetInfo.addFCDAInfo(new FCDAInfo()); - //When - assertThat(dataSetInfo.getName()).isEqualTo("DATA_INFO1"); - assertThat(dataSetInfo.getFCDAInfos()).isNotEmpty(); - } - @Test void from_WhenCalledWithDataSet_ThenValuesAreFilled(){ //Given - TDataSet dataSet = new TDataSet(); - dataSet.setName("dataset"); - dataSet.getFCDA().add(DTO.createFCDA()); - //When - DataSetInfo dataSetInfo = DataSetInfo.from(dataSet); - //Then - assertThat(dataSetInfo.getName()).isEqualTo("dataset"); - assertThat(dataSetInfo.getFCDAInfos()).hasSize(1); - } + TDataSet tDataSet = new TDataSet(); + tDataSet.setName("dataset"); + tDataSet.getFCDA().add(DTO.createFCDA()); - @Test - void getDataSets_whenCalledWithNoDataSetInLN_shouldReturnEmptyList(){ - //Given - LNAdapter lnAdapter = new LNAdapter(null, new TLN()); //When - Set dataSetInfos = DataSetInfo.getDataSets(lnAdapter); - //Then - assertThat(dataSetInfos).isEmpty(); - } + DataSetInfo dataSetInfo = new DataSetInfo(tDataSet); - @Test - void getDataSets_whenCalledWithLNContainsMatchingFCDA_shouldReturnDataSet(){ - //Given - TDataSet dataSet = new TDataSet(); - dataSet.setName("datasetName"); - dataSet.getFCDA().add(DTO.createFCDA()); - TLN tln = new TLN(); - tln.getDataSet().add(dataSet); - LNAdapter lnAdapter = new LNAdapter(null, tln); - //When - Set dataSetInfos = DataSetInfo.getDataSets(lnAdapter); //Then - assertThat(dataSetInfos).hasSize(1) - .extracting(DataSetInfo::getName).contains("datasetName"); + assertThat(dataSetInfo.getName()).isEqualTo("dataset"); + assertThat(dataSetInfo.getFcdaInfos()).hasSize(1); } - @Test void isValid_whenNameSizeMore32_shouldReturnFalse() { //Given - DataSetInfo dataSetInfo = new DataSetInfo(); - assertThat(dataSetInfo.getName()).isNull(); - dataSetInfo = new DataSetInfo("DATA_INFO_TEST_CHARACTERE_NAME_MORE_THAN_32_CHARACTERES"); + TDataSet tDataSet = new TDataSet(); + tDataSet.setName("DATA_INFO_TEST_CHARACTERE_NAME_MORE_THAN_32_CHARACTERES"); + tDataSet.getFCDA().add(DTO.createFCDA()); + DataSetInfo dataSetInfo = new DataSetInfo(tDataSet); + //When boolean isValid = dataSetInfo.isValid(); + //Then assertThat(isValid).isFalse(); } @Test void isValid_whenFCDAInfoEmpty_shouldReturnFalse() { - DataSetInfo dataSetInfo = new DataSetInfo(); - assertThat(dataSetInfo.getName()).isNull(); - dataSetInfo = new DataSetInfo("DATA_INFO"); + TDataSet tDataSet = new TDataSet(); + tDataSet.setName("DATA_INFO"); + DataSetInfo dataSetInfo = new DataSetInfo(tDataSet); + //When boolean isValid = dataSetInfo.isValid(); + //Then - assertThat(dataSetInfo.getFCDAInfos()).isEmpty(); + assertThat(dataSetInfo.getFcdaInfos()).isEmpty(); assertThat(isValid).isFalse(); } @Test void isValid_whenFCDAInfosValidshouldReturnTrue() { //Given - TDataSet dataSet = new TDataSet(); - dataSet.setName("dataset"); - dataSet.getFCDA().add(DTO.createFCDA()); - DataSetInfo dataSetInfo = DataSetInfo.from(dataSet); + TDataSet tDataSet = new TDataSet(); + tDataSet.setName("dataset"); + tDataSet.getFCDA().add(DTO.createFCDA()); + DataSetInfo dataSetInfo = new DataSetInfo(tDataSet); //When boolean isValid = dataSetInfo.isValid(); //Then diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/FCDAInfoTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/FCDAInfoTest.java index 2cc2612d9..2cc9ea284 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/FCDAInfoTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/FCDAInfoTest.java @@ -6,14 +6,8 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.lfenergy.compas.scl2007b4.model.TFCDA; import org.lfenergy.compas.scl2007b4.model.TFCEnum; -import java.util.stream.Stream; - import static org.assertj.core.api.Assertions.assertThat; class FCDAInfoTest { @@ -22,102 +16,24 @@ class FCDAInfoTest { @Tag("issue-321") void constructor_whenCalled_shouldFillValues(){ // Given - TFCDA tfcda = new TFCDA(); - tfcda.setDoName("doName"); - tfcda.setDaName("daName.bda1.bda2.bda3"); - tfcda.setLdInst("LDInst"); - tfcda.setFc(TFCEnum.CF); - tfcda.getLnClass().add("LN_Class"); - tfcda.setLnInst("LNInst"); - tfcda.setPrefix("pre"); - tfcda.setIx(1L); + String dataSetName = "dataSet"; + String ldInst = "LDInst"; + String prefix = "pre"; + String lnClass = "LN_Class"; + String lnInst = "LNInst"; + DoTypeName doName = new DoTypeName("doName"); + DaTypeName daName = new DaTypeName("daName.bda1.bda2.bda3"); + long ix = 1L; + // When - FCDAInfo fcdaInfo = new FCDAInfo("dataSet",tfcda); + FCDAInfo fcdaInfo = new FCDAInfo(dataSetName, TFCEnum.CF, ldInst, prefix, lnClass, lnInst, doName, daName, ix); // Then assertThat(fcdaInfo.getDaName().getName()).isEqualTo("daName"); assertThat(fcdaInfo.getDoName().getName()).isEqualTo("doName"); - assertThat(fcdaInfo.getDaName()).hasToString(tfcda.getDaName()); + assertThat(fcdaInfo.getDaName()).hasToString("daName.bda1.bda2.bda3"); assertThat(fcdaInfo.getDaName().getStructNames()).hasSize(3); - // When - FCDAInfo fcdaInfo1 = new FCDAInfo(); - fcdaInfo1.setIx(fcdaInfo.getIx()); - fcdaInfo1.setLdInst(fcdaInfo.getLdInst()); - fcdaInfo1.setLnInst(fcdaInfo.getLnInst()); - fcdaInfo1.setLnClass(fcdaInfo.getLnClass()); - fcdaInfo1.setDaName(fcdaInfo.getDaName()); - fcdaInfo1.setDoName(fcdaInfo.getDoName()); - fcdaInfo1.setFc(fcdaInfo.getFc()); - fcdaInfo1.setPrefix(fcdaInfo.getPrefix()); - // Then - assertThat(fcdaInfo1.getDaName().getName()).isEqualTo("daName"); - assertThat(fcdaInfo1.getDoName().getName()).isEqualTo("doName"); - assertThat(fcdaInfo1.getDaName()).hasToString(tfcda.getDaName()); - TFCDA tfcda1 = fcdaInfo1.getFCDA(); - assertThat(fcdaInfo1.getFc()).isEqualTo(tfcda1.getFc()); - assertThat(fcdaInfo1.isValid()).isTrue(); - } - - @ParameterizedTest(name = "{0}") - @MethodSource("providerFCDAInfoObjects") - void checkFCDACompatibilitiesForBinding_whenCalled_shouldReturnFalse(String testCase, FCDAInfo fcdaInfo, FCDAInfo expectedFcdaInfo) { - assertThat(fcdaInfo.checkFCDACompatibilitiesForBinding(expectedFcdaInfo)).isFalse(); + assertThat(fcdaInfo.getFc()).isEqualTo(TFCEnum.CF); + assertThat(fcdaInfo.isValid()).isTrue(); } - @Test - void checkFCDACompatibilitiesForBinding_whenCalledWithSameContent_shouldReturnTrue() { - //Given - TFCDA tfcda = new TFCDA(); - tfcda.setLdInst(DTO.createExtRefBindingInfo_Remote().getLdInst()); - tfcda.getLnClass().add(DTO.createExtRefBindingInfo_Remote().getLnClass()); - tfcda.setLnInst(DTO.createExtRefBindingInfo_Remote().getLnInst()); - tfcda.setDoName(DTO.createExtRefSignalInfo().getPDO()); - tfcda.setDaName(DTO.createExtRefSignalInfo().getPDA()); - - FCDAInfo fcdaInfo = new FCDAInfo(tfcda); - FCDAInfo expectedFcdaInfo = new FCDAInfo(tfcda); - //When Then - assertThat(fcdaInfo.checkFCDACompatibilitiesForBinding(expectedFcdaInfo)).isTrue(); - } - - private static Stream providerFCDAInfoObjects(){ - - TFCDA tfcda = new TFCDA(); - tfcda.setLdInst(DTO.createExtRefBindingInfo_Remote().getLdInst()); - tfcda.getLnClass().add(DTO.createExtRefBindingInfo_Remote().getLnClass()); - tfcda.setLnInst(DTO.createExtRefBindingInfo_Remote().getLnInst()); - tfcda.setDoName(DTO.createExtRefSignalInfo().getPDO()); - tfcda.setDaName(DTO.createExtRefSignalInfo().getPDA()); - - FCDAInfo fcdaInfo = new FCDAInfo(tfcda); - - FCDAInfo expectedFcdaInfo = new FCDAInfo(tfcda); - - FCDAInfo expectedLDInstNotMatch = new FCDAInfo(tfcda); - expectedLDInstNotMatch.setLdInst("LDCMDDJ"); - - FCDAInfo expectedLNClassNotMatch = new FCDAInfo(tfcda); - expectedLNClassNotMatch.setLnClass("CSWI"); - - FCDAInfo expectedLNInstNotMatch = new FCDAInfo(tfcda); - expectedLNInstNotMatch.setLnInst("5"); - - FCDAInfo expectedPrefixNotMatch = new FCDAInfo(tfcda); - expectedPrefixNotMatch.setPrefix("Prefix"); - - FCDAInfo expectedDONotMatch = new FCDAInfo(tfcda); - expectedDONotMatch.setDoName(new DoTypeName("do.do1")); - - FCDAInfo expectedDANotMatch = new FCDAInfo(tfcda); - expectedDANotMatch.setDaName(new DaTypeName("da.bda.bda1")); - - return Stream.of( - Arguments.of("return false when LdInst not match ", fcdaInfo, expectedLDInstNotMatch), - Arguments.of("return false when lnClass not match ", fcdaInfo, expectedLNClassNotMatch), - Arguments.of("return false when lnInst not match ", fcdaInfo, expectedLNInstNotMatch), - Arguments.of("return false when Prefix not match ", fcdaInfo, expectedPrefixNotMatch), - Arguments.of("return false when DO not match ", fcdaInfo, expectedDONotMatch), - Arguments.of("return false when DO not match ", fcdaInfo, expectedDANotMatch) - - ); - } } \ No newline at end of file diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/LDeviceDTOTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/LDeviceDTOTest.java index 128e29246..aeeb1c508 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/LDeviceDTOTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/LDeviceDTOTest.java @@ -10,33 +10,28 @@ import org.lfenergy.compas.scl2007b4.model.SCL; import org.lfenergy.compas.sct.commons.scl.SclRootAdapter; import org.lfenergy.compas.sct.commons.scl.ied.IEDAdapter; -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.Set; - import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertAll; +import static org.lfenergy.compas.sct.commons.dto.DTO.HOLDER_LD_INST; +import static org.lfenergy.compas.sct.commons.dto.DTO.LD_NAME; class LDeviceDTOTest { @Test - void constructor_whenCalled_shouldFillValues() { + void constructor_should_fill_values() { + // Given // When - LDeviceDTO lDeviceDTO = DTO.createLdDTO(); + LDeviceDTO lDeviceDTO = new LDeviceDTO(HOLDER_LD_INST, LD_NAME); + // Then - assertAll("LD_DTO", - () -> assertThat(lDeviceDTO.getLdInst()).isEqualTo(DTO.HOLDER_LD_INST), - () -> assertThat(lDeviceDTO.getLdName()).isEqualTo(DTO.LD_NAME), - () -> assertThat(lDeviceDTO.getLNodes()).isNotEmpty() - ); - Set nodeDTOs = Set.of(DTO.createLNodeDTO(),DTO.createLNodeDTO()); - lDeviceDTO.addAll(nodeDTOs); - assertThat(lDeviceDTO.getLNodes()).hasSize(3); + assertThat(lDeviceDTO.getLdInst()).isEqualTo(HOLDER_LD_INST); + assertThat(lDeviceDTO.getLdName()).isEqualTo(LD_NAME); + assertThat(lDeviceDTO.getLNodes()).isEmpty(); } - @Test void addLNode_whenCalled_shouldNotUpdateLNodeList(){ // Given diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/LNodeDTOTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/LNodeDTOTest.java index 3d827e4b0..72f2c5dbc 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/LNodeDTOTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/LNodeDTOTest.java @@ -10,8 +10,8 @@ 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.ied.IEDAdapter; -import org.lfenergy.compas.sct.commons.scl.ied.LDeviceAdapter; -import org.lfenergy.compas.sct.commons.scl.ied.LNAdapter; +import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter; +import org.lfenergy.compas.sct.commons.scl.ln.LNAdapter; import java.util.List; import java.util.Optional; diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/dtt/DOTypeAdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/dtt/DOTypeAdapterTest.java index 25c92db6a..3e4b8d355 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/dtt/DOTypeAdapterTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/dtt/DOTypeAdapterTest.java @@ -110,15 +110,22 @@ void hasSameContentAs() { void testCheckAndCompleteStructData() { //Given DataTypeTemplateAdapter dttAdapter = initDttAdapterFromFile(SCD_DTT_DIFF_CONTENT_SAME_ID); - //When Then DOTypeAdapter doTypeAdapter = assertDoesNotThrow(() -> dttAdapter.getDOTypeAdapterById("DO2").get()); DoTypeName doTypeName = new DoTypeName("Op","origin"); - //When Then + //When assertThatCode(() -> doTypeAdapter.checkAndCompleteStructData(doTypeName)).doesNotThrowAnyException(); assertThat(doTypeName.getCdc()).isEqualTo(TPredefinedCDCEnum.WYE); - DoTypeName doTypeName1 = new DoTypeName("Op","toto"); + } + + @Test + @Tag("issue-321") + void testCheckAndCompleteStructData2() { + //Given + DataTypeTemplateAdapter dttAdapter = initDttAdapterFromFile(SCD_DTT_DIFF_CONTENT_SAME_ID); + DOTypeAdapter doTypeAdapter = assertDoesNotThrow(() -> dttAdapter.getDOTypeAdapterById("DO2").get()); + DoTypeName doTypeName = new DoTypeName("Op","toto"); //When Then - assertThatThrownBy(() -> doTypeAdapter.checkAndCompleteStructData(doTypeName1)).isInstanceOf(ScdException.class); + assertThatThrownBy(() -> doTypeAdapter.checkAndCompleteStructData(doTypeName)).isInstanceOf(ScdException.class); } @Test diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/dtt/LNodeTypeAdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/dtt/LNodeTypeAdapterTest.java index c0da58c3f..319c2ee14 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/dtt/LNodeTypeAdapterTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/dtt/LNodeTypeAdapterTest.java @@ -211,26 +211,26 @@ void testCheck() { DoTypeName doTypeName1 = new DoTypeName(""); DaTypeName daTypeName1 = new DaTypeName(""); // When Then - assertThatThrownBy(() -> lNodeTypeAdapter.check(doTypeName1,daTypeName1)).isInstanceOf(ScdException.class); + assertThatThrownBy(() -> lNodeTypeAdapter.checkDoAndDaTypeName(doTypeName1,daTypeName1)).isInstanceOf(ScdException.class); DoTypeName doTypeName2 = new DoTypeName("do"); DaTypeName daTypeName2 = new DaTypeName(""); // When Then - assertThatThrownBy(() -> lNodeTypeAdapter.check(doTypeName2,daTypeName2)).isInstanceOf(ScdException.class); + assertThatThrownBy(() -> lNodeTypeAdapter.checkDoAndDaTypeName(doTypeName2,daTypeName2)).isInstanceOf(ScdException.class); DoTypeName doTypeName3 = new DoTypeName("do"); DaTypeName daTypeName3 = new DaTypeName("da"); // When Then - assertThatThrownBy(() -> lNodeTypeAdapter.check(doTypeName3,daTypeName3)).isInstanceOf(ScdException.class); + assertThatThrownBy(() -> lNodeTypeAdapter.checkDoAndDaTypeName(doTypeName3,daTypeName3)).isInstanceOf(ScdException.class); DoTypeName doTypeName = new DoTypeName("Op.res"); DaTypeName daTypeName = new DaTypeName("d"); // When Then - assertThatCode(() -> lNodeTypeAdapter.check(doTypeName,daTypeName)).doesNotThrowAnyException(); + assertThatCode(() -> lNodeTypeAdapter.checkDoAndDaTypeName(doTypeName,daTypeName)).doesNotThrowAnyException(); doTypeName.setName("StrVal"); doTypeName.getStructNames().clear(); daTypeName.setName("origin"); daTypeName.getStructNames().clear(); daTypeName.setStructNames(List.of("origin","ctlVal")); // When Then - assertThatCode(() -> lNodeTypeAdapter.check(doTypeName,daTypeName)).doesNotThrowAnyException(); + assertThatCode(() -> lNodeTypeAdapter.checkDoAndDaTypeName(doTypeName,daTypeName)).doesNotThrowAnyException(); } diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/ControlBlockAdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/ControlBlockAdapterTest.java index ada6a9645..2e419e3d4 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/ControlBlockAdapterTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/ControlBlockAdapterTest.java @@ -9,6 +9,8 @@ import org.junit.jupiter.api.Test; import org.lfenergy.compas.scl2007b4.model.*; import org.lfenergy.compas.sct.commons.dto.SclReportItem; +import org.lfenergy.compas.sct.commons.scl.ln.LN0Adapter; +import org.lfenergy.compas.sct.commons.scl.ln.LNAdapter; import org.lfenergy.compas.sct.commons.testhelpers.SclHelper; import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; import org.lfenergy.compas.sct.commons.util.ControlBlockEnum; diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/DAITrackerTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/DAITrackerTest.java index 001ed76c7..a0c3acb9c 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/DAITrackerTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/DAITrackerTest.java @@ -11,6 +11,9 @@ import org.lfenergy.compas.sct.commons.dto.DoTypeName; import org.lfenergy.compas.sct.commons.exception.ScdException; import org.lfenergy.compas.sct.commons.scl.SclRootAdapter; +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.testhelpers.SclTestMarshaller; import static org.assertj.core.api.AssertionsForClassTypes.*; diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/DOIAdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/DOIAdapterTest.java index 43df3a0d4..fff80f1c6 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/DOIAdapterTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/DOIAdapterTest.java @@ -14,6 +14,8 @@ 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.ldevice.LDeviceAdapter; +import org.lfenergy.compas.sct.commons.scl.ln.LN0Adapter; import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; import org.lfenergy.compas.sct.commons.util.CommonConstants; diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/DataSetAdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/DataSetAdapterTest.java index 654ac3285..c42fa2df6 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/DataSetAdapterTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/DataSetAdapterTest.java @@ -9,6 +9,7 @@ import org.lfenergy.compas.scl2007b4.model.TDataSet; import org.lfenergy.compas.scl2007b4.model.TFCDA; import org.lfenergy.compas.scl2007b4.model.TFCEnum; +import org.lfenergy.compas.sct.commons.scl.ln.LN0Adapter; import java.util.List; import java.util.Optional; diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/IEDAdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/IEDAdapterTest.java index 5b7bcea31..830c5cbe1 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/IEDAdapterTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/IEDAdapterTest.java @@ -15,6 +15,8 @@ import org.lfenergy.compas.sct.commons.dto.SclReportItem; import org.lfenergy.compas.sct.commons.exception.ScdException; import org.lfenergy.compas.sct.commons.scl.ObjectReference; +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.PrivateUtils; import org.lfenergy.compas.sct.commons.scl.SclRootAdapter; import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/InputsAdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/InputsAdapterTest.java index f63950867..92a570c6b 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/InputsAdapterTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/InputsAdapterTest.java @@ -14,6 +14,9 @@ import org.lfenergy.compas.sct.commons.dto.FcdaForDataSetsCreation; import org.lfenergy.compas.sct.commons.dto.SclReportItem; import org.lfenergy.compas.sct.commons.scl.SclRootAdapter; +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.testhelpers.FCDARecord; import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; import org.lfenergy.compas.sct.commons.util.CsvUtils; diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LdeviceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LdeviceTest.java deleted file mode 100644 index 7682b07b7..000000000 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LdeviceTest.java +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-FileCopyrightText: 2021 RTE FRANCE -// -// SPDX-License-Identifier: Apache-2.0 - -package org.lfenergy.compas.sct.commons.scl.ied; - -import org.junit.jupiter.api.Test; -import org.lfenergy.compas.scl2007b4.model.SCL; -import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; -import org.lfenergy.compas.sct.commons.util.LdeviceStatus; - -import java.util.Optional; - -import static org.assertj.core.api.Assertions.assertThat; - -class LdeviceTest { - - @Test - void getLdeviceStatus_should_return_status() { - //Given - SCL std = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std.xml"); - Ldevice ldevice = new Ldevice(std.getIED().get(0).getAccessPoint().get(0).getServer().getLDevice().get(0)); - //When - Optional ldeviceStatus = ldevice.getLdeviceStatus(); - //Then - assertThat(ldeviceStatus).contains(LdeviceStatus.OFF); - } -} \ No newline at end of file diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/LDeviceActivationTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceActivationTest.java similarity index 99% rename from sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/LDeviceActivationTest.java rename to sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceActivationTest.java index c553282be..8858ed3ac 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/LDeviceActivationTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceActivationTest.java @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: Apache-2.0 -package org.lfenergy.compas.sct.commons.scl; +package org.lfenergy.compas.sct.commons.scl.ldevice; import org.apache.commons.lang3.tuple.Pair; import org.junit.jupiter.api.Test; diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LDeviceAdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceAdapterTest.java similarity index 98% rename from sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LDeviceAdapterTest.java rename to sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceAdapterTest.java index b2a775cc4..f97034241 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LDeviceAdapterTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceAdapterTest.java @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: Apache-2.0 -package org.lfenergy.compas.sct.commons.scl.ied; +package org.lfenergy.compas.sct.commons.scl.ldevice; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; @@ -17,6 +17,10 @@ import org.lfenergy.compas.sct.commons.dto.*; import org.lfenergy.compas.sct.commons.exception.ScdException; import org.lfenergy.compas.sct.commons.scl.SclRootAdapter; +import org.lfenergy.compas.sct.commons.scl.ied.IEDAdapter; +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.ln.LNAdapter; import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; import org.lfenergy.compas.sct.commons.util.ControlBlockEnum; import org.lfenergy.compas.sct.commons.util.MonitoringLnClassEnum; @@ -29,8 +33,8 @@ import static org.assertj.core.api.Assertions.*; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.lfenergy.compas.sct.commons.scl.ied.AbstractLNAdapter.MOD_DO_TYPE_NAME; -import static org.lfenergy.compas.sct.commons.scl.ied.AbstractLNAdapter.STVAL_DA_TYPE_NAME; +import static org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter.MOD_DO_TYPE_NAME; +import static org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter.STVAL_DA_TYPE_NAME; import static org.lfenergy.compas.sct.commons.testhelpers.SclHelper.*; import static org.lfenergy.compas.sct.commons.util.CommonConstants.LDEVICE_LDEPF; import static org.lfenergy.compas.sct.commons.util.ControlBlockEnum.*; diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LN0AdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ln/LN0AdapterTest.java similarity index 94% rename from sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LN0AdapterTest.java rename to sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ln/LN0AdapterTest.java index 33ce8d924..10233f345 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LN0AdapterTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ln/LN0AdapterTest.java @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: Apache-2.0 -package org.lfenergy.compas.sct.commons.scl.ied; +package org.lfenergy.compas.sct.commons.scl.ln; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -15,6 +15,8 @@ import org.lfenergy.compas.sct.commons.dto.*; 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.scl.ldevice.LDeviceAdapter; import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; import org.lfenergy.compas.sct.commons.util.ControlBlockEnum; import org.mockito.Mockito; @@ -212,103 +214,115 @@ void testGetDataSetWith() { // Given TDataSet tDataSet = new TDataSet(); ln0.getDataSet().add(tDataSet); - // When - List tDataSets = ln0Adapter.getDataSetMatchingExtRefInfo(null); - // Then - assertThat(tDataSets).isNotEmpty(); - - // Given ExtRefInfo extRefInfo = DTO.createExtRefInfo(); extRefInfo = Mockito.spy(extRefInfo); - TFCDA tfcda = new TFCDA(); tDataSet.getFCDA().add(tfcda); // When - tDataSets = ln0Adapter.getDataSetMatchingExtRefInfo(extRefInfo); + List tDataSets = ln0Adapter.getDataSetMatchingExtRefInfo(extRefInfo).toList(); // Then assertThat(tDataSets).isEmpty(); doReturn(true).when(extRefInfo).checkMatchingFCDA(any(TFCDA.class)); // When - tDataSets = ln0Adapter.getDataSetMatchingExtRefInfo(extRefInfo); + tDataSets = ln0Adapter.getDataSetMatchingExtRefInfo(extRefInfo).toList(); // Then assertThat(tDataSets).isNotEmpty(); } @Test - @Tag("issue-321") void testGetControlBlocks() { // Given - LDeviceAdapter lDeviceAdapter = mock(LDeviceAdapter.class); - IEDAdapter iedAdapter = mock(IEDAdapter.class); - TLDevice tlDevice = mock(TLDevice.class); - when(lDeviceAdapter.getCurrentElem()).thenReturn(tlDevice); - when(lDeviceAdapter.getParentAdapter()).thenReturn(iedAdapter); - when(iedAdapter.getName()).thenReturn("IED_NAME"); LN0 ln0 = new LN0(); - when(tlDevice.getLN0()).thenReturn(ln0); - // When Then - LN0Adapter ln0Adapter = assertDoesNotThrow(() -> new LN0Adapter(lDeviceAdapter, ln0)); - // Given - TGSEControl tgseControl = new TGSEControl(); - tgseControl.setDatSet("GSE_REF"); - TSampledValueControl tSampledValueControl = new TSampledValueControl(); - tSampledValueControl.setDatSet("SMV_REF"); TReportControl tReportControl = new TReportControl(); - tReportControl.setDatSet("RPT_REF"); - ln0Adapter.getCurrentElem().getGSEControl().add(tgseControl); - ln0Adapter.getCurrentElem().getSampledValueControl().add(tSampledValueControl); - ln0Adapter.getCurrentElem().getReportControl().add(tReportControl); - - TDataSet tDataSetGSE = new TDataSet(); - tDataSetGSE.setName(DTO.CB_DATASET_REF); - - // When Then - List controlBlocks = ln0Adapter.getControlBlocks(List.of(tDataSetGSE), null); - assertThat(controlBlocks).isEmpty(); + tReportControl.setDatSet("dataSetName"); + ln0.getReportControl().add(tReportControl); + TSampledValueControl tSampledValueControl = new TSampledValueControl(); + tSampledValueControl.setDatSet("dataSetName"); + ln0.getSampledValueControl().add(tSampledValueControl); + TGSEControl tgseControl = new TGSEControl(); + tgseControl.setDatSet("dataSetName"); + ln0.getGSEControl().add(tgseControl); - tDataSetGSE.setName("GSE_REF"); - TDataSet tDataSetSMV = new TDataSet(); - tDataSetSMV.setName("SMV_REF"); - TDataSet tDataSetRPT = new TDataSet(); - tDataSetRPT.setName("RPT_REF"); + TInputs tInputs = new TInputs(); + TExtRef extRef = DTO.createExtRef(); + tInputs.getExtRef().add(extRef); + ln0.setInputs(tInputs); + TDataSet tDataSet = new TDataSet(); + tDataSet.setName("dataSetName"); + TFCDA tfcda = new TFCDA(); + tfcda.setDaName("d"); + tfcda.setDoName("FACntRs1.res"); + tfcda.setPrefix("LN_PREFIX_R"); + tfcda.setLdInst("LD_INST_R"); + tfcda.setLnInst("1"); + tfcda.getLnClass().add("LN_CLASS_R"); + tDataSet.getFCDA().add(tfcda); + ln0.getDataSet().add(tDataSet); + ExtRefInfo extRefInfo = DTO.createExtRefInfo(); + ExtRefBindingInfo extRefBindingInfo = DTO.createExtRefBindingInfo_Remote(); + extRefBindingInfo.setServiceType(null); + extRefInfo.setBindingInfo(extRefBindingInfo); - List tDataSets = List.of(tDataSetGSE, tDataSetSMV, tDataSetRPT); + LN0Adapter ln0Adapter = new LN0Adapter(null, ln0); - // When Then - controlBlocks = ln0Adapter.getControlBlocks(tDataSets, TServiceType.REPORT); - assertThat(controlBlocks).hasSize(1); - // When Then - controlBlocks = ln0Adapter.getControlBlocks(tDataSets, TServiceType.SMV); - assertThat(controlBlocks).hasSize(1); - // When Then - controlBlocks = ln0Adapter.getControlBlocks(tDataSets, TServiceType.GOOSE); - assertThat(controlBlocks).hasSize(1); - // When Then - controlBlocks = ln0Adapter.getControlBlocks(tDataSets, null); + // When + List controlBlocks = ln0Adapter.getControlBlocksForMatchingFCDA(extRefInfo).toList(); + // Then assertThat(controlBlocks).hasSize(3); } - @Test - void getControlBlocksForMatchingFCDA_should_return_expected_Items() { + @ParameterizedTest + @MethodSource("provideServiceType") + void getControlBlocksForMatchingFCDA_should_return_expected_Items(LN0 ln0, TServiceType serviceType) { // Given - LN0 ln0 = new LN0(); - LN0Adapter ln0Adapter = Mockito.spy(new LN0Adapter(null, ln0)); - - when(ln0Adapter.getCurrentElem()).thenReturn(ln0); TInputs tInputs = new TInputs(); TExtRef extRef = DTO.createExtRef(); tInputs.getExtRef().add(extRef); ln0.setInputs(tInputs); - ExtRefInfo extRefBindingInfo = DTO.createExtRefInfo(); - doReturn(List.of(new TDataSet())).when(ln0Adapter).getDataSetMatchingExtRefInfo(any(ExtRefInfo.class)); - doReturn(List.of(new ReportControlBlock("rpt", "rptID", "rptDatSet"))) - .when(ln0Adapter).getControlBlocks(any(List.class), any(TServiceType.class)); + TDataSet tDataSet = new TDataSet(); + tDataSet.setName("dataSetName"); + TFCDA tfcda = new TFCDA(); + tfcda.setDaName("d"); + tfcda.setDoName("FACntRs1.res"); + tfcda.setPrefix("LN_PREFIX_R"); + tfcda.setLdInst("LD_INST_R"); + tfcda.setLnInst("1"); + tfcda.getLnClass().add("LN_CLASS_R"); + tDataSet.getFCDA().add(tfcda); + ln0.getDataSet().add(tDataSet); + ExtRefInfo extRefInfo = DTO.createExtRefInfo(); + ExtRefBindingInfo extRefBindingInfo = DTO.createExtRefBindingInfo_Remote(); + extRefBindingInfo.setServiceType(serviceType); + extRefInfo.setBindingInfo(extRefBindingInfo); + + LN0Adapter ln0Adapter = new LN0Adapter(null, ln0); + // When - List controlBlocks = ln0Adapter.getControlBlocksForMatchingFCDA(extRefBindingInfo); + List controlBlocks = ln0Adapter.getControlBlocksForMatchingFCDA(extRefInfo).toList(); // Then - assertThat(controlBlocks).isNotEmpty(); - assertThat(controlBlocks.get(0).getServiceType()).isEqualTo(TServiceType.REPORT); + assertThat(controlBlocks).hasSize(1); + assertThat(controlBlocks.get(0).getServiceType()).isEqualTo(serviceType); + } + + private static Stream provideServiceType() { + LN0 ln0Report = new LN0(); + TReportControl tReportControl = new TReportControl(); + tReportControl.setDatSet("dataSetName"); + ln0Report.getReportControl().add(tReportControl); + LN0 ln0Smv = new LN0(); + TSampledValueControl tSampledValueControl = new TSampledValueControl(); + tSampledValueControl.setDatSet("dataSetName"); + ln0Smv.getSampledValueControl().add(tSampledValueControl); + LN0 ln0Goose = new LN0(); + TGSEControl tgseControl = new TGSEControl(); + tgseControl.setDatSet("dataSetName"); + ln0Goose.getGSEControl().add(tgseControl); + return Stream.of( + Arguments.of(ln0Report, TServiceType.REPORT), + Arguments.of(ln0Smv, TServiceType.SMV), + Arguments.of(ln0Goose, TServiceType.GOOSE) + ); } @Test @@ -386,7 +400,6 @@ void getDOIAdapterByName_should_return_expected_DOIAdapter() { when(iedAdapter.getName()).thenReturn("IED_NAME"); LDeviceAdapter lDeviceAdapter = mock(LDeviceAdapter.class); TLDevice tlDevice = new TLDevice(); - when(lDeviceAdapter.amChildElementRef()).thenReturn(true); when(lDeviceAdapter.getCurrentElem()).thenReturn(tlDevice); when(lDeviceAdapter.getParentAdapter()).thenReturn(iedAdapter); LN0 ln0 = new LN0(); diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LNAdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ln/LNAdapterTest.java similarity index 97% rename from sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LNAdapterTest.java rename to sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ln/LNAdapterTest.java index e38d29529..a4371332b 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LNAdapterTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ln/LNAdapterTest.java @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: Apache-2.0 -package org.lfenergy.compas.sct.commons.scl.ied; +package org.lfenergy.compas.sct.commons.scl.ln; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; @@ -16,6 +16,8 @@ import org.lfenergy.compas.sct.commons.dto.*; 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.scl.ldevice.LDeviceAdapter; import org.lfenergy.compas.sct.commons.testhelpers.MarshallerWrapper; import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; @@ -832,13 +834,22 @@ void getControlBlocks_should_find_ControlBlock_by_name() { .withLDeviceAdapter(lDeviceAdapter) .withLnClass(TLLN0Enum.LLN_0.value()) .build(); - List tDataSets = lnAdapter.getCurrentElem().getDataSet(); + lnAdapter.getCurrentElem().getDataSet().forEach(tDataSet -> tDataSet.getFCDA().forEach(tfcda -> { + tfcda.getLnClass().add("lnClass"); + tfcda.setDoName("FACntRs1.res"); + tfcda.setDaName("d"); + })); + + ExtRefInfo extRefInfo = DTO.createExtRefInfo(); + ExtRefBindingInfo extRefBindingInfo = new ExtRefBindingInfo(); + extRefBindingInfo.setServiceType(TServiceType.GOOSE); + extRefBindingInfo.setLnClass("lnClass"); + extRefInfo.setBindingInfo(extRefBindingInfo); //When - List tControls = lnAdapter.getControlBlocks(tDataSets, TServiceType.GOOSE); + List controlBlocks = lnAdapter.getControlBlocksForMatchingFCDA(extRefInfo).toList(); //Then - assertThat(tControls).isNotEmpty() - .hasSize(1); + assertThat(controlBlocks).hasSize(1); } @Test diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/testhelpers/SclHelper.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/testhelpers/SclHelper.java index 239cce3e8..fdea655ab 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/testhelpers/SclHelper.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/testhelpers/SclHelper.java @@ -8,6 +8,10 @@ import org.lfenergy.compas.scl2007b4.model.*; import org.lfenergy.compas.sct.commons.scl.SclRootAdapter; 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 org.lfenergy.compas.sct.commons.scl.ln.LN0Adapter; +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 org.opentest4j.AssertionFailedError; diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/util/LdeviceStatusEnumTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/util/ActiveStatusEnumTest.java similarity index 69% rename from sct-commons/src/test/java/org/lfenergy/compas/sct/commons/util/LdeviceStatusEnumTest.java rename to sct-commons/src/test/java/org/lfenergy/compas/sct/commons/util/ActiveStatusEnumTest.java index e7d9f48ef..0ecba282b 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/util/LdeviceStatusEnumTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/util/ActiveStatusEnumTest.java @@ -11,16 +11,16 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; -class LdeviceStatusEnumTest { +class ActiveStatusEnumTest { @ParameterizedTest @CsvSource({"on,ON", "off,OFF"}) void fromValue_withKnownStatus_shouldNotThrowException(String ldeviceStatus, String expected) { //Given //When - LdeviceStatus ldeviceStatusEnum = LdeviceStatus.fromValue(ldeviceStatus); + ActiveStatus activeStatusEnum = ActiveStatus.fromValue(ldeviceStatus); //Then - assertThat(ldeviceStatusEnum).isEqualTo(LdeviceStatus.valueOf(expected)); + assertThat(activeStatusEnum).isEqualTo(ActiveStatus.valueOf(expected)); } @Test @@ -29,8 +29,8 @@ void fromValue_withUnknownStatus_shouldThrowException() { String ldeviceStatus = "patate"; //When //Then - assertThatCode(() -> LdeviceStatus.fromValue(ldeviceStatus)) + assertThatCode(() -> ActiveStatus.fromValue(ldeviceStatus)) .isInstanceOf(IllegalArgumentException.class) - .hasMessage("The Ldevice status patate does not exist. It should be among [on, off]"); + .hasMessage("The status patate does not exist. It should be among [on, off]"); } } \ No newline at end of file diff --git a/sct-commons/src/test/resources/std/std_sample.std b/sct-commons/src/test/resources/std/std_sample.std new file mode 100644 index 000000000..e9d714db5 --- /dev/null +++ b/sct-commons/src/test/resources/std/std_sample.std @@ -0,0 +1,1230 @@ + + + + + STD + +
+ + + +
+ + + +
+

00000001

+

0001

+

0001

+

1,3,9999,24

+

24

+

300

+

3

+

400

+

4

+

0.0.0.0

+

0.0.0.0

+

0.0.0.0

+
+
+
+ + +
+

Adresse IP du serveur Syslog

+

udp;tcp;tcp/tls

+

Valeur du code de la catégorie des messages

+

0.0.0.0

+

Nom d utilisateur pour la connexion

+

none;hmac-128-sha-224;hmac-192-sha-256;hmac-256-sha-384;hmac-384-sha-512

+

Password cle pour l'authentification

+

none;aes-cfb-128;aes-cfb-192;aes-cfb-256

+

Password cle pour la confidentialite

+
+
+
+
+ + SAMU + SAMU + + + + + + + + + + + + + + + + Phase 1_Pilotes + 9d13ab59-1ec8-4c46-91c8-0326e6a5408e + 1 + 1.0 + + + + Ldevice current status + + + + + Health of the LDSUIED function + + + + + on + + + 1000 + + + Activation_deactivation command + + + + + 10 + + + 10 + + + Name plate of the logical node + + + 01.01.00 + + + + + VDF + + + + + + + + m + + + A + + + + + 10 + + + + + 20 + + + + + 20 + + + + + 10 + + + + Rated Input Current High + + + + + + m + + + A + + + + + 0 + + + + + 4 + + + + + 4 + + + + + 2 + + + + Rated Input Current Low + + + + + + + ADU + + + + + ADU + + + + + ADU + + + + + ADU + + + + + ADU + + + + + ADU + + + + ADU + + + + + m + + + A + + + + ADU + + + ADU + + + ADU + + + ADU + + + ADU + + + Analogue Input One instance for each analog input + + + + + Mandatory but not used + + + + + + Phase 1_Pilotes + 9de78c12-6b02-4914-9944-dc87648433da + 1 + 1.0 + + + + Ldevice current status + + + + + Health of the LDTM + + + + + + + + + + + + + + + + 1000 + + + + + 5000 + + + + + 5 + + + + + A + + + + + + + + 0 + + + + Rated primary current of current transformer + + + + + + + + + 300 + + + + + 5000 + + + + + 10 + + + + + + + + + + + + + 0 + + + + Winding ratio of current transformer + + + + + + + + + + + + + + + + + + + + 4800 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IEC 61850-7-4:2007B + + + + + + + + + + + + + + + + + + + + direct-with-enhanced-security + + + + + + + + + + + + + + + + + + + + + direct-with-enhanced-security + + + + + + + + + + + + + + + + + + + + + + + + + status-only + + + + + + + + + + + + + + + + + + + + + + direct-with-enhanced-security + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IEC 61869-9:2016 + + + + + + + + + + + + + status-only + + + + + + + + + + + + + status-only + + + + + + + + + status-only + + + + + + + + (Tr)IEC 61850-90-4:2013 + + + + + + + + RTE:2019A + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IEC 61850-8-1:2003 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IEC 61850-8-1:2003 + + + + + + + + + IEC 61850-8-1:2003 + + + + + + + + IEC 61850-8-1:2003 + + + Ok + Warning + Alarm + + + on + blocked + test + test/blocked + off + + + InternalClock + LocalAreaClock + + + red + orange + yellow + green + blue + white + off + + + y + z + a + f + p + n + µ + m + c + d + + da + h + k + M + G + T + P + E + Z + Y + + + Active high + Active low + + + normal + high + low + high-high + low-low + + + ok + warning + alarm + + + Unknown + PTP + + + red + orange + yellow + green + blue + white + off + + + fix + slow blinking + fast blinking + + + ph0 + ph3 + ph4 + ph7 + ph8 + ph11 + + + pulse + persistent + persistent-feedback + + + + m + kg + s + A + K + mol + cd + deg + rad + sr + Gy + Bq + °C + Sv + F + C + S + H + V + ohm + J + N + Hz + lx + Lm + Wb + T + W + Pa + + + m/s + m/s² + m³/s + m/m³ + M + kg/m³ + m²/s + W/m K + J/K + ppm + 1/s + rad/s + W/m² + J/m² + S/m + K/s + Pa/s + J/kg K + VA + Watts + VAr + phi + cos(phi) + Vs + + As + + A²t + VAh + Wh + VArh + V/Hz + Hz/s + char + char/s + kgm² + dB + J/Wh + W/s + l/s + dBm + h + min + Ohm/m + percent/s + A/V + A/Vs + + + status-only + + + status-only + direct-with-enhanced-security + + + on + off + + + direct-with-enhanced-security + + + Disconnector + + + not-supported + bay-control + station-control + remote-control + automatic-bay + automatic-station + automatic-remote + maintenance + process + + + latched + non latched + + +
\ No newline at end of file