Skip to content

Commit

Permalink
feat(EPF): Change setting file from CSV to XML
Browse files Browse the repository at this point in the history
fixes #345

Signed-off-by: Samir Romdhani <[email protected]>
  • Loading branch information
samirromdhani committed Nov 20, 2023
1 parent f5e7098 commit 4402fc7
Show file tree
Hide file tree
Showing 17 changed files with 492 additions and 1,781 deletions.
42 changes: 30 additions & 12 deletions sct-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,23 +161,41 @@
<version>3.1.0</version>
<executions>
<execution>
<id>xjc</id>
<id>scl</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<sources>
<source>${project.build.outputDirectory}/xsd/SCL2007B4/SCL.xsd</source>
<source>${project.build.outputDirectory}/xsd/SCL_CoMPAS.xsd</source>
</sources>
<xjbSources>
<xjbSource>${project.basedir}/src/main/resources/binding_configuration.xjb</xjbSource>
</xjbSources>
<packageName>org.lfenergy.compas.scl2007b4.model</packageName>
<noPackageLevelAnnotations>true</noPackageLevelAnnotations>
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
<execution>
<id>epf</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/src/main/resources/xsd/EPF.xsd</source>
</sources>
<xjbSources>
<xjbSource>${project.basedir}/src/main/resources/binding_configuration.xjb</xjbSource>
</xjbSources>
<packageName>org.lfenergy.compas.sct.commons.model.epf</packageName>
<noPackageLevelAnnotations>true</noPackageLevelAnnotations>
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
</executions>
<configuration>
<sources>
<source>${project.build.outputDirectory}/xsd/SCL2007B4/SCL.xsd</source>
<source>${project.build.outputDirectory}/xsd/SCL_CoMPAS.xsd</source>
</sources>
<xjbSources>
<xjbSource>${project.basedir}/src/main/resources/binding_configuration.xjb</xjbSource>
</xjbSources>
<packageName>org.lfenergy.compas.scl2007b4.model</packageName>
<noPackageLevelAnnotations>true</noPackageLevelAnnotations>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.lfenergy.compas.sct.commons.dto.ExtRefInfo;
import org.lfenergy.compas.sct.commons.dto.SclReportItem;
import org.lfenergy.compas.sct.commons.exception.ScdException;
import org.lfenergy.compas.sct.commons.util.ILDEPFSettings;
import org.lfenergy.compas.sct.commons.model.epf.EPF;

import java.util.List;

Expand Down Expand Up @@ -55,11 +55,11 @@ public interface ExtRefEditor {
List<SclReportItem> updateAllExtRefIedNames(SCL scd);

/**
* ExtRef Binding For LDevice (inst=LDEPF) that matching LDEPF configuration
* ExtRef Binding For LDevice (inst=LDEPF) that matching EPF configuration
* @param scd SCL
* @param settings ILDEPFSettings
* @param epf EPF
* @return list of encountered errors
*/
List<SclReportItem> manageBindingForLDEPF(SCL scd, ILDEPFSettings settings);
List<SclReportItem> manageBindingForLDEPF(SCL scd, EPF epf);

}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@
import org.apache.commons.lang3.StringUtils;
import org.lfenergy.compas.scl2007b4.model.TExtRef;
import org.lfenergy.compas.scl2007b4.model.TLLN0Enum;
import org.lfenergy.compas.scl2007b4.model.TPredefinedBasicTypeEnum;
import org.lfenergy.compas.sct.commons.dto.DaTypeName;
import org.lfenergy.compas.sct.commons.dto.DoTypeName;
import org.lfenergy.compas.sct.commons.dto.LDEPFSettingData;
import org.lfenergy.compas.sct.commons.exception.ScdException;
import org.lfenergy.compas.sct.commons.scl.ied.AbstractLNAdapter;
import org.lfenergy.compas.sct.commons.scl.ied.IEDAdapter;
import org.lfenergy.compas.sct.commons.scl.ied.LDeviceAdapter;

import javax.xml.namespace.QName;
import java.util.*;
Expand Down Expand Up @@ -394,73 +387,4 @@ public static boolean isExtRefFeedBySameControlBlock(TExtRef t1, TExtRef t2) {
&& Objects.equals(t1.getServiceType(), t2.getServiceType());
}

/**
* verify whether the IED satisfies the LDEPF settings for the private element `TCompasICDHeader`
*/
public static boolean isIcdHeaderMatch(IEDAdapter iedAdapter,LDEPFSettingData setting) {
return iedAdapter.getCompasICDHeader()
.map(compasICDHeader -> compasICDHeader.getIEDType().value().equals(setting.getIedType())
&& compasICDHeader.getIEDredundancy().value().equals(setting.getIedRedundancy())
&& compasICDHeader.getIEDSystemVersioninstance().equals(setting.getIedInstance()))
.orElse(false);
}

/**
* provides Active LDevice for LDEPF setting's inst attribute
*/
public static Optional<LDeviceAdapter> getActiveSourceLDevice(IEDAdapter iedAdapter, LDEPFSettingData setting) {
return iedAdapter.findLDeviceAdapterByLdInst(setting.getLdInst())
.filter(lDeviceAdapter -> lDeviceAdapter.getLDeviceStatus()
.map(status -> status.equals(LdeviceStatus.ON.getValue()))
.orElse(false))
.stream().findFirst();
}

/**
* provides Active LN Object that satisfies the LDEPF settings attributes (lnClass, lnInst, prefix)
*/
public static Optional<AbstractLNAdapter<?>> getActiveLNodeSource(LDeviceAdapter lDeviceAdapter, LDEPFSettingData setting) {
return lDeviceAdapter.getLNAdaptersIncludingLN0().stream()
.filter(lnAdapter -> lnAdapter.getLNClass().equals(setting.getLnClass())
&& lnAdapter.getLNInst().equals(setting.getLnInst())
&& Utils.equalsOrBothBlank(setting.getLnPrefix(), lnAdapter.getPrefix()))
.findFirst()
.filter(lnAdapter -> lnAdapter.getDaiModStValValue()
.map(status -> status.equals(LdeviceStatus.ON.getValue()))
.orElse(true));
}


/**
* verify whether the LN satisfies the LDEPF settings for Data Type Template elements.
*/
public static boolean isValidDataTypeTemplate(AbstractLNAdapter<?> lnAdapter,LDEPFSettingData setting) {
if(StringUtils.isEmpty(setting.getDoName()) || StringUtils.isBlank(setting.getDoName())){
return true;
}
String doName = StringUtils.isEmpty(setting.getDoInst()) || StringUtils.isBlank(setting.getDoInst()) || setting.getDoInst().equals("0")
? setting.getDoName() : setting.getDoName() + setting.getDoInst();
DoTypeName doTypeName = new DoTypeName(doName);
if(!StringUtils.isEmpty(setting.getSdoName()) && !StringUtils.isBlank(setting.getSdoName())){
doTypeName.getStructNames().add(setting.getSdoName());
}
DaTypeName daTypeName = new DaTypeName(setting.getDaName());
if(!StringUtils.isEmpty(setting.getBdaName()) && !StringUtils.isBlank(setting.getBdaName())){
daTypeName.setBType(TPredefinedBasicTypeEnum.STRUCT);
daTypeName.getStructNames().add(setting.getBdaName());
}
if(!StringUtils.isEmpty(setting.getSbdaName()) && !StringUtils.isBlank(setting.getSbdaName())){
daTypeName.getStructNames().add(setting.getSbdaName());
}
return lnAdapter.getDataTypeTemplateAdapter().getLNodeTypeAdapterById(lnAdapter.getLnType())
.filter(lNodeTypeAdapter -> {
try {
lNodeTypeAdapter.check(doTypeName, daTypeName);
} catch (Exception ex) {
return false;
}
return true;
}).isPresent();
}

}
Loading

0 comments on commit 4402fc7

Please sign in to comment.