Skip to content

Commit

Permalink
feat(#341): Création Lnode, DOI et Private domain
Browse files Browse the repository at this point in the history
Signed-off-by: gleizesDor <115622893+gleizesDor@users.noreply.github.com>
  • Loading branch information
gleizesDor committed Nov 10, 2023
1 parent ce70880 commit 2f602d5
Show file tree
Hide file tree
Showing 70 changed files with 865 additions and 488 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
</plugin>
<plugin>
Expand All @@ -145,6 +146,10 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<!--Ajout de ${argLine} pour ne pas remplacer les arguments-->
<argLine>@{argLine} --enable-preview</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
9 changes: 9 additions & 0 deletions sct-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,19 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!--Ajout de ${argLine} pour ne pas remplacer les arguments-->
<argLine>@{argLine} --enable-preview</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.lfenergy.compas.sct.commons.exception.ScdException;
import org.lfenergy.compas.sct.commons.scl.SclElementAdapter;
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
import org.lfenergy.compas.sct.commons.scl.ied.LDeviceAdapter;
import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter;
import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller;

import java.util.Arrays;
Expand Down
9 changes: 9 additions & 0 deletions sct-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,19 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!--Ajout de ${argLine} pour ne pas remplacer les arguments-->
<argLine>@{argLine} --enable-preview</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
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.lnode.AbstractLNAdapter;
import org.lfenergy.compas.sct.commons.scl.lnode.LN0Adapter;
import org.lfenergy.compas.sct.commons.util.*;

import java.util.*;
Expand Down Expand Up @@ -154,8 +157,7 @@ private List<SclReportItem> createDataSetAndControlBlocks(Stream<LDeviceAdapter>
}

@Override
public List<SclReportItem> configureNetworkForAllControlBlocks(SCL scd, ControlBlockNetworkSettings controlBlockNetworkSettings,
RangesPerCbType rangesPerCbType) {
public List<SclReportItem> configureNetworkForAllControlBlocks(SCL scd, ControlBlockNetworkSettings controlBlockNetworkSettings, RangesPerCbType rangesPerCbType) {
List<SclReportItem> sclReportItems = new ArrayList<>();
sclReportItems.addAll(configureNetworkForControlBlocks(scd, controlBlockNetworkSettings, rangesPerCbType.gse(), ControlBlockEnum.GSE));
sclReportItems.addAll(configureNetworkForControlBlocks(scd, controlBlockNetworkSettings, rangesPerCbType.sampledValue(), ControlBlockEnum.SAMPLED_VALUE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
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.ldevice.LDeviceAdapter;
import org.lfenergy.compas.sct.commons.scl.lnode.AbstractLNAdapter;
import org.lfenergy.compas.sct.commons.scl.lnode.LN0Adapter;
import org.lfenergy.compas.sct.commons.scl.lnode.LNAdapter;
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 @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import org.lfenergy.compas.sct.commons.scl.dtt.DataTypeTemplateAdapter;
import org.lfenergy.compas.sct.commons.scl.dtt.EnumTypeAdapter;
import org.lfenergy.compas.sct.commons.scl.ied.*;
import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter;
import org.lfenergy.compas.sct.commons.scl.lnode.AbstractLNAdapter;

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

SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.lnode.AbstractLNAdapter;
import org.lfenergy.compas.sct.commons.util.SclConstructorHelper;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
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 org.lfenergy.compas.sct.commons.scl.lnode.AbstractLNAdapter;
import org.lfenergy.compas.sct.commons.scl.lnode.DataSet;
import org.lfenergy.compas.sct.commons.scl.lnode.Fcda;

import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -30,75 +31,72 @@
*/
@Getter
@NoArgsConstructor
public class DataSetInfo extends LNodeMetaDataEmbedder{
public class DataSetInfo extends LNodeMetaDataEmbedder {
//TODO cet objet est un DTO; il est utilisé pour transporter l'information; il doit être créé par celui qui transporte l'info -> RCONF
private String name;
private List<FCDAInfo> fcdaInfos = new ArrayList<>();

/**
* Constructor
* @param name input
*/
public DataSetInfo(String name){
public DataSetInfo(String name) {
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;
public DataSetInfo(String name, List<Fcda> fcdas) {
super();
this.name = name;
this.fcdaInfos = fcdas.stream()
.map(fcda -> fcda.toDto(name))
.toList();
}

/**
* Get Set of DataSet from LnAdapter
* @param lnAdapter object LnAdapter
* @return Set of DataSetInfo
*/
public static Set<DataSetInfo> getDataSets(AbstractLNAdapter<? extends TAnyLN> lnAdapter){
return lnAdapter.getDataSetMatchingExtRefInfo(null)
.stream().map(DataSetInfo::from).collect(Collectors.toSet());
public static Set<DataSetInfo> getDataSets(AbstractLNAdapter<? extends TAnyLN> lnAdapter) {
return lnAdapter.getCurrentElem()
.getDataSet()
.stream()
.map(DataSet::new)
.map(DataSet::toDto)
.collect(Collectors.toSet());
}

/**
* Add FCDA to FCDA list
* @param fcdaInfo object FCDAInfo containing FCDA datas
*/
public void addFCDAInfo(FCDAInfo fcdaInfo){
public void addFCDAInfo(FCDAInfo fcdaInfo) {
fcdaInfos.add(fcdaInfo);
}

/**
* Get FCDA list from DtaSetInfo
* @return FCDA list
*/
public List<FCDAInfo> getFCDAInfos(){
public List<FCDAInfo> getFCDAInfos() {
return Collections.unmodifiableList(fcdaInfos);
}

/**
* Set DataSet name
* @param name string DataSet name
*/
public void setName(String name){
public void setName(String name) {
this.name = name;
}

/**
* 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <em><b>ExtRef</b></em>.
*
Expand All @@ -33,7 +38,7 @@
@NoArgsConstructor
@AllArgsConstructor
public class ExtRefInfo extends LNodeMetaDataEmbedder{

//TODO cet objet est un DTO; il est utilisé pour transporter l'information; il doit être créé par celui qui transporte l'info -> RCONF
private ExtRefSignalInfo signalInfo;
private ExtRefBindingInfo bindingInfo;
private ExtRefSourceInfo sourceInfo;
Expand All @@ -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);
Expand All @@ -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());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <em><b>FCDA</b></em>.
*
Expand All @@ -34,7 +30,6 @@
* @see org.lfenergy.compas.scl2007b4.model.TFCDA
*/
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
Expand All @@ -51,29 +46,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
Expand Down Expand Up @@ -115,17 +87,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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
@Getter
@Setter
public class GooseControlBlock extends ControlBlock {
//TODO cet objet est un DTO; il est utilisé pour transporter l'information; il doit être créé par celui qui transporte l'info -> RCONF
private boolean fixedOffs = false;
private TProtocol protocol;
private TGSEControlTypeEnum type = TGSEControlTypeEnum.GOOSE;
Expand Down
Loading

0 comments on commit 2f602d5

Please sign in to comment.