Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

removed service that Activate used LDevice and Deactivate unused LDevice, closes #464 #467

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

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

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

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

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

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

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

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

/**
* Update DAIs of DO InRef in all LN0 of the SCD using matching ExtRef information.
*
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@
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.ObjectReference;
import org.lfenergy.compas.sct.commons.scl.ied.InputsAdapter;
import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceActivation;
import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter;
import org.lfenergy.compas.sct.commons.util.PrivateUtils;

import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -68,8 +62,6 @@
*/
public class LN0Adapter extends AbstractLNAdapter<LN0> {

public static final DoTypeName BEHAVIOUR_DO_TYPE_NAME = new DoTypeName(BEHAVIOUR_DO_NAME);
public static final DaTypeName BEHAVIOUR_DA_TYPE_NAME = getDaTypeNameForBeh();
private static final Pattern LDEFP_DIGITAL_CHANNEL_PATTERN = Pattern.compile("DYN_LDEPF_DIGITAL CHANNEL \\d+_\\d+_BOOLEAN");

/**
Expand Down Expand Up @@ -169,58 +161,6 @@ public void removeAllControlBlocksAndDatasets() {
currentElem.unsetSampledValueControl();
}

/**
* Verify and update LDevice status in parent Node
*
* @param iedNameLDeviceInstList pair of Ied name and LDevice inst attributes
* @return Set of Errors
*/
public Optional<SclReportItem> updateLDeviceStatus(List<Pair<String, String>> iedNameLDeviceInstList) {
LDeviceActivation lDeviceActivation = new LDeviceActivation(iedNameLDeviceInstList);
final String iedName = getParentAdapter().getParentAdapter().getName();
final String ldInst = getParentAdapter().getInst();
DataAttributeRef daiBehFilter = new DataAttributeRef(this, BEHAVIOUR_DO_TYPE_NAME, BEHAVIOUR_DA_TYPE_NAME);
List<DataAttributeRef> daiBehList = getDAI(daiBehFilter, false);
if (daiBehList.isEmpty()) {
return Optional.of(buildFatalReportItem("The LDevice doesn't have a DO @name='Beh' OR its associated DA@fc='ST' AND DA@name='stVal'"));
}
Set<String> enumValues = getEnumValues(daiBehList.getFirst().getDaName().getType());
Optional<TCompasLDevice> optionalTCompasLDevice = PrivateUtils.extractCompasPrivate(getParentAdapter().getCurrentElem(), TCompasLDevice.class);
if (optionalTCompasLDevice.isEmpty()) {
return Optional.of(buildFatalReportItem("The LDevice doesn't have a Private compas:LDevice."));
}
if (!optionalTCompasLDevice.get().isSetLDeviceStatus()) {
return Optional.of(buildFatalReportItem("The Private compas:LDevice doesn't have the attribute 'LDeviceStatus'"));
}
TCompasLDeviceStatus compasLDeviceStatus = optionalTCompasLDevice.get().getLDeviceStatus();
Optional<DataAttributeRef> optionalModStVal = getDaiModStVal();
if (optionalModStVal.isEmpty()) {
return Optional.of(buildFatalReportItem("The LDevice doesn't have a DO @name='Mod'"));
}
DataAttributeRef newDaModToSetInLN0 = optionalModStVal.get();
String initialValue = newDaModToSetInLN0.findFirstValue().orElse("");
lDeviceActivation.checkLDeviceActivationStatus(iedName, ldInst, compasLDeviceStatus, enumValues);
if (lDeviceActivation.isUpdatable()) {
if (!initialValue.equals(lDeviceActivation.getNewVal())) {
newDaModToSetInLN0.setVal(lDeviceActivation.getNewVal());
updateDAI(newDaModToSetInLN0);
}
} else {
if (lDeviceActivation.getErrorMessage() != null) {
return Optional.of(buildFatalReportItem(lDeviceActivation.getErrorMessage()));
}
}
return Optional.empty();
}

private static DaTypeName getDaTypeNameForBeh() {
DaTypeName daTypeNameBeh = new DaTypeName();
daTypeNameBeh.setName(STVAL_DA_NAME);
daTypeNameBeh.setBType(TPredefinedBasicTypeEnum.ENUM);
daTypeNameBeh.setFc(TFCEnum.ST);
return daTypeNameBeh;
}

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

package org.lfenergy.compas.sct.commons.scl.sstation;

import org.apache.commons.lang3.tuple.Pair;
import org.lfenergy.compas.scl2007b4.model.TLLN0Enum;
import org.lfenergy.compas.scl2007b4.model.TSubstation;
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.util.Utils;

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
Expand Down Expand Up @@ -119,18 +115,4 @@ public Stream<VoltageLevelAdapter> streamVoltageLevelAdapters() {
return currentElem.getVoltageLevel().stream().map(tVoltageLevel -> new VoltageLevelAdapter(this, tVoltageLevel));
}

/**
* Gets a pair of IedName and LDevice inst from Substation LNodes for LN0 type object
* @return a pair of Ied name and LDevice inst attributes
*/
public List<Pair<String, String>> getIedAndLDeviceNamesForLN0FromLNode() {
return streamVoltageLevelAdapters()
.flatMap(VoltageLevelAdapter::streamBayAdapters)
.flatMap(BayAdapter::streamFunctionAdapters)
.flatMap(functionAdapter -> functionAdapter.getCurrentElem().getLNode().stream())
.filter(tlNode -> tlNode.getLnClass().contains(TLLN0Enum.LLN_0.value()))
.map(tlNode -> Pair.of(tlNode.getIedName(), tlNode.getLdInst()))
.collect(Collectors.toList());
}

}
Loading
Loading