Skip to content

Commit

Permalink
Merge pull request #281 from com-pas/feat/RSR-588_rename_ResumedDataT…
Browse files Browse the repository at this point in the history
…emplate

feat(#280): RSR-588 rename ResumedDataType to a better name
  • Loading branch information
GuillaumeJAFFRE authored May 11, 2023
2 parents db735e7 + da7e00a commit 594d866
Show file tree
Hide file tree
Showing 30 changed files with 742 additions and 667 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* <li>{@link LNodeDTO#getGooseControlBlocks <em>Refers To GooseControl Blocks</em>}</li>
* <li>{@link LNodeDTO#getSmvControlBlocks <em>Refers To SmvControl Blocks</em>}</li>
* <li>{@link LNodeDTO#getReportControlBlocks <em>Refers To ReportControl Blocks</em>}</li>
* <li>{@link LNodeDTO#getResumedDataTemplates <em>Refers To DataTemplates Objects</em>}</li>
* <li>{@link LNodeDTO#getDataAttributeRefs <em>Refers To DataTemplates Objects</em>}</li>
* </ul>
*
* @see org.lfenergy.compas.scl2007b4.model.TLNode
Expand All @@ -55,7 +55,7 @@ public class LNodeDTO {
private Set<SMVControlBlock> smvControlBlocks = new HashSet<>();
private Set<ReportControlBlock> reportControlBlocks = new HashSet<>();
private Set<DataSetInfo> datSets = new HashSet<>();
private Set<ResumedDataTemplate> resumedDataTemplates = new HashSet<>();
private Set<DataAttributeRef> dataAttributeRefs = new HashSet<>();

/**
* Constructor
Expand Down Expand Up @@ -113,7 +113,7 @@ public static <T extends TAnyLN> LNodeDTO from(AbstractLNAdapter<T> nodeAdapter,
lNodeDTO.datSets = DataSetInfo.getDataSets(nodeAdapter);
}

if(options.isWithResumedDtt()) {
if(options.isWithDataAttributeRef()) {
DataTypeTemplateAdapter dttAdapter = nodeAdapter.getDataTypeTemplateAdapter();
LNodeTypeAdapter lNodeTypeAdapter = dttAdapter.getLNodeTypeAdapterById(nodeAdapter.getLnType())
.orElseThrow(
Expand All @@ -124,13 +124,13 @@ public static <T extends TAnyLN> LNodeDTO from(AbstractLNAdapter<T> nodeAdapter,
)
)
);
ResumedDataTemplate filter = ResumedDataTemplate.builder()
DataAttributeRef filter = DataAttributeRef.builder()
.lnInst(nodeAdapter.getLNInst())
.lnClass(nodeAdapter.getLNClass())
.prefix(nodeAdapter.getPrefix())
.lnType(nodeAdapter.getLnType()).build();
List<ResumedDataTemplate> resumedDataTemplateList = lNodeTypeAdapter.getResumedDTTs(filter);
lNodeDTO.addAllResumedDataTemplate(resumedDataTemplateList);
List<DataAttributeRef> dataAttributeRefList = lNodeTypeAdapter.getDataAttributeRefs(filter);
lNodeDTO.addAllDataAttributeRef(dataAttributeRefList);
}

if(options.isWithCB()) {
Expand Down Expand Up @@ -241,26 +241,26 @@ public void addAllDatSets(List<DataSetInfo> dataSetList) {

/**
* Adds DataTypeTemplate's sumarised data
* @param dtt input
* @param dataAttributeRef input
*/
public void addResumedDataTemplate(ResumedDataTemplate dtt) {
resumedDataTemplates.add(dtt);
public void addDataAttributeRef(DataAttributeRef dataAttributeRef) {
dataAttributeRefs.add(dataAttributeRef);
}

/**
* Adds list of DataTypeTemplate's sumarised data
* @param dtt input
* @param dataAttributeRefs input
*/
public void addAllResumedDataTemplate(List<ResumedDataTemplate> dtt) {
this.resumedDataTemplates.addAll(dtt);
public void addAllDataAttributeRef(List<DataAttributeRef> dataAttributeRefs) {
this.dataAttributeRefs.addAll(dataAttributeRefs);
}

/**
* Gets DataTypeTemplate's sumarised data
* @return Set of ResumedDataTemplate object
* @return Set of DataAttributeRef object
*/
public Set<ResumedDataTemplate> getResumedDataTemplates(){
return Set.of(resumedDataTemplates.toArray(new ResumedDataTemplate[0]));
public Set<DataAttributeRef> getDataAttributeRefs(){
return Set.of(dataAttributeRefs.toArray(new DataAttributeRef[0]));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* </p>
* <ul>
* <li>{@link LogicalNodeOptions#withExtRef <em>withExtRef</em>}</li>
* <li>{@link LogicalNodeOptions#withResumedDtt <em>withResumedDtt</em>}</li>
* <li>{@link LogicalNodeOptions#withDataAttributeRef <em>withDataAttributeRef</em>}</li>
* <li>{@link LogicalNodeOptions#withDatSet <em>withDatSet</em>}</li>
* <li>{@link LogicalNodeOptions#withCB <em>withCB</em>}</li>
* </ul>
Expand All @@ -25,20 +25,20 @@
@NoArgsConstructor
public class LogicalNodeOptions {
private boolean withExtRef = false;
private boolean withResumedDtt = false;
private boolean withDataAttributeRef = false;
private boolean withCB = false;
private boolean withDatSet = false;

/**
* Constructor
* @param withExtRef input
* @param withResumedDtt input
* @param withDataAttributeRef input
* @param withCB input
* @param withDatSet input
*/
public LogicalNodeOptions(boolean withExtRef, boolean withResumedDtt, boolean withCB, boolean withDatSet) {
public LogicalNodeOptions(boolean withExtRef, boolean withDataAttributeRef, boolean withCB, boolean withDatSet) {
this.withExtRef = withExtRef;
this.withResumedDtt = withResumedDtt;
this.withDataAttributeRef = withDataAttributeRef;
this.withCB = withCB;
this.withDatSet = withDatSet;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
* </ol>
* <li>DAI features</li>
* <ol>
* <li>{@link SclService#getDAI <em>Returns list of <b>ResumedDataTemplate </b></em>}</li>
* <li>{@link SclService#updateDAI(SCL, String, String, ResumedDataTemplate)
* <em>Update the <b>TDAI </b> reference object for given <b>iedName</b>, <b>ldInst </b> and <b>ResumedDataTemplate </b> model</em>}</li>
* <li>{@link SclService#getDAI <em>Returns list of <b>DataAttributeRef </b></em>}</li>
* <li>{@link SclService#updateDAI(SCL, String, String, DataAttributeRef)
* <em>Update the <b>TDAI </b> reference object for given <b>iedName</b>, <b>ldInst </b> and <b>DataAttributeRef </b> model</em>}</li>
* </ol>
* <li>EnumType features</li>
* <ol>
Expand Down Expand Up @@ -392,43 +392,43 @@ public static TExtRef updateExtRefSource(SCL scd, ExtRefInfo extRefInfo) throws

/**
* Gets a list of summarized DataTypeTemplate for DataAttribute DA (updatable or not) related to the one given
* in <em>rDtt</em>
* in <em>dataAttributeRef</em>
*
* @param scd SCL file in which DataTypeTemplate of DAIs should be found
* @param iedName name of IED in which DAs are localized
* @param ldInst ldInst of LDevice in which DAIs are localized
* @param rDtt reference summarized DataTypeTemplate related to IED DAIs
* @param dataAttributeRef reference summarized DataTypeTemplate related to IED DAIs
* @param updatable true to retrieve DataTypeTemplate's related to only updatable DAIs, false to retrieve all
* @return List of resumed DataTypeTemplate for DataAttribute (updatable or not)
* @return Set of Data Attribute Reference for DataAttribute (updatable or not)
* @throws ScdException SCD illegal arguments exception, missing mandatory data
*/
public static Set<ResumedDataTemplate> getDAI(SCL scd, String iedName, String ldInst, ResumedDataTemplate rDtt, boolean updatable) throws ScdException {
public static Set<DataAttributeRef> getDAI(SCL scd, String iedName, String ldInst, DataAttributeRef dataAttributeRef, boolean updatable) throws ScdException {
LDeviceAdapter lDeviceAdapter = createLDeviceAdapter(scd, iedName, ldInst);
return lDeviceAdapter.getDAI(rDtt, updatable);
return lDeviceAdapter.getDAI(dataAttributeRef, updatable);
}

/**
* Updates DAI based on given data in <em>rDtt</em>
* Updates DAI based on given data in <em>dataAttributeRef</em>
*
* @param scd SCL file in which DataTypeTemplate of DAI should be found
* @param iedName name of IED in which DAI is localized
* @param ldInst ldInst of LDevice in which DAI is localized
* @param rDtt reference summarized DataTypeTemplate related to DAI to update
* @param dataAttributeRef reference summarized DataTypeTemplate related to DAI to update
* @throws ScdException when inconsistency are found in th SCL's
* DataTypeTemplate. Which should normally not happens.
*/
public static void updateDAI(SCL scd, String iedName, String ldInst, ResumedDataTemplate rDtt) throws ScdException {
public static void updateDAI(SCL scd, String iedName, String ldInst, DataAttributeRef dataAttributeRef) throws ScdException {
long startTime = System.nanoTime();
log.info(Utils.entering());
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
DataTypeTemplateAdapter dttAdapter = sclRootAdapter.getDataTypeTemplateAdapter();
LNodeTypeAdapter lNodeTypeAdapter = dttAdapter.getLNodeTypeAdapterById(rDtt.getLnType())
.orElseThrow(() -> new ScdException("Unknown LNodeType : " + rDtt.getLnType()));
lNodeTypeAdapter.check(rDtt.getDoName(), rDtt.getDaName());
LNodeTypeAdapter lNodeTypeAdapter = dttAdapter.getLNodeTypeAdapterById(dataAttributeRef.getLnType())
.orElseThrow(() -> new ScdException("Unknown LNodeType : " + dataAttributeRef.getLnType()));
lNodeTypeAdapter.check(dataAttributeRef.getDoName(), dataAttributeRef.getDaName());

if (TPredefinedBasicTypeEnum.OBJ_REF == rDtt.getBType()) {
Long sGroup = rDtt.getDaName().getDaiValues().keySet().stream().findFirst().orElse(-1L);
String val = sGroup < 0 ? null : rDtt.getDaName().getDaiValues().get(sGroup);
if (TPredefinedBasicTypeEnum.OBJ_REF == dataAttributeRef.getBType()) {
Long sGroup = dataAttributeRef.getDaName().getDaiValues().keySet().stream().findFirst().orElse(-1L);
String val = sGroup < 0 ? null : dataAttributeRef.getDaName().getDaiValues().get(sGroup);
sclRootAdapter.checkObjRef(val);
}

Expand All @@ -438,16 +438,16 @@ public static void updateDAI(SCL scd, String iedName, String ldInst, ResumedData

AbstractLNAdapter<?> lnAdapter = AbstractLNAdapter.builder()
.withLDeviceAdapter(lDeviceAdapter)
.withLnClass(rDtt.getLnClass())
.withLnInst(rDtt.getLnInst())
.withLnPrefix(rDtt.getPrefix())
.withLnClass(dataAttributeRef.getLnClass())
.withLnInst(dataAttributeRef.getLnInst())
.withLnPrefix(dataAttributeRef.getPrefix())
.build();

if (TPredefinedCDCEnum.ING == rDtt.getCdc() || TPredefinedCDCEnum.ASG == rDtt.getCdc()) {
DAITracker daiTracker = new DAITracker(lnAdapter, rDtt.getDoName(), rDtt.getDaName());
if (TPredefinedCDCEnum.ING == dataAttributeRef.getCdc() || TPredefinedCDCEnum.ASG == dataAttributeRef.getCdc()) {
DAITracker daiTracker = new DAITracker(lnAdapter, dataAttributeRef.getDoName(), dataAttributeRef.getDaName());
daiTracker.validateBoundedDAI();
}
lnAdapter.updateDAI(rDtt);
lnAdapter.updateDAI(dataAttributeRef);
log.info(Utils.leaving(startTime));
}

Expand Down
Loading

0 comments on commit 594d866

Please sign in to comment.