Skip to content

Commit

Permalink
Merge pull request #208 from com-pas/fix/185
Browse files Browse the repository at this point in the history
fix(#185): fix bug update extref cb
  • Loading branch information
AliouDIAITE authored Dec 1, 2022
2 parents 5407cda + 32116f0 commit 08b62f7
Show file tree
Hide file tree
Showing 10 changed files with 470 additions and 382 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static DataSetInfo from(TDataSet tDataSet) {
* @return Set of DataSetInfo
*/
public static Set<DataSetInfo> getDataSets(AbstractLNAdapter<? extends TAnyLN> lnAdapter){
return lnAdapter.getDataSet(null)
return lnAdapter.getDataSetMatchingExtRefInfo(null)
.stream().map(DataSetInfo::from).collect(Collectors.toSet());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@


import lombok.*;
import org.apache.commons.lang3.StringUtils;
import org.lfenergy.compas.scl2007b4.model.TExtRef;
import org.lfenergy.compas.scl2007b4.model.TFCDA;
import org.lfenergy.compas.scl2007b4.model.TLLN0Enum;
import org.lfenergy.compas.sct.commons.scl.ied.AbstractLNAdapter;

import java.util.Objects;
/**
* A representation of the model object <em><b>ExtRef</b></em>.
*
Expand Down Expand Up @@ -75,48 +70,6 @@ public static ExtRefInfo from(TExtRef tExtRef, String iedName, String ldInst,
return extRefInfo;
}

/**
* Check match between FCDA and ExtRef information (for binding)
* @param tfcda FCDA data object
* @return match state
*/
//TODO this method should be checked, return if parameter tested are not present in FCDA even if two object are different
public boolean matchFCDA(@NonNull TFCDA tfcda){
boolean returnValue = true;
if(AbstractLNAdapter.isFCDANull(tfcda)) {
returnValue = false;
}

if(tfcda.getLdInst() != null &&
(bindingInfo == null || !tfcda.getLdInst().equals(bindingInfo.getLdInst()))){
returnValue = false;
}
if (!tfcda.getLnClass().isEmpty() &&
( bindingInfo == null || !tfcda.getLnClass().contains(bindingInfo.getLnClass())) ){
returnValue = false;
}

boolean isLN0 = tfcda.getLnClass().contains(TLLN0Enum.LLN_0.value());
if (!isLN0 && tfcda.getLnInst() != null &&
(bindingInfo == null || !tfcda.getLnInst().equals(bindingInfo.getLnInst()))) {
returnValue = false;
}
if (!isLN0 && !StringUtils.isBlank(tfcda.getPrefix()) &&
(bindingInfo == null || !tfcda.getPrefix().equals(bindingInfo.getPrefix()))) {
returnValue = false;
}

if(!StringUtils.isBlank(tfcda.getDoName()) &&
(signalInfo == null || !Objects.equals(signalInfo.getPDO(),tfcda.getDoName())) ){
returnValue = false;
}

if(!StringUtils.isBlank(tfcda.getDaName()) &&
(signalInfo == null || !Objects.equals(signalInfo.getPDA(),tfcda.getDaName())) ){
returnValue = false;
}
return returnValue;
}
/**
* Check matching between FCDA and ExtRef information (for external binding)
* Check is done for parameter lDInst(mandatory), lNClass(mandatory), lNInst, prefix doName as pDO(mandatory) and daName as pDA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public static TExtRef updateExtRefSource(SCL scd, ExtRefInfo extRefInfo) throws
if (bindingInfo == null || !bindingInfo.isValid()) {
throw new ScdException(INVALID_OR_MISSING_ATTRIBUTES_IN_EXT_REF_BINDING_INFO);
}
if (bindingInfo.getIedName().equals(iedName)) {
if (bindingInfo.getIedName().equals(iedName) || TServiceType.POLL.equals(bindingInfo.getServiceType())) {
throw new ScdException("Internal binding can't have control block");
}
ExtRefSourceInfo sourceInfo = extRefInfo.getSourceInfo();
Expand All @@ -377,7 +377,7 @@ public static TExtRef updateExtRefSource(SCL scd, ExtRefInfo extRefInfo) throws
IEDAdapter iedAdapter = sclRootAdapter.getIEDAdapterByName(iedName);
LDeviceAdapter lDeviceAdapter = iedAdapter.findLDeviceAdapterByLdInst(ldInst)
.orElseThrow(() -> new ScdException(String.format(UNKNOWN_LDEVICE_S_IN_IED_S, ldInst, iedName)));
var anLNAdapter = AbstractLNAdapter.builder()
AbstractLNAdapter<?> anLNAdapter = AbstractLNAdapter.builder()
.withLDeviceAdapter(lDeviceAdapter)
.withLnClass(lnClass)
.withLnInst(lnInst)
Expand Down
Loading

0 comments on commit 08b62f7

Please sign in to comment.