Skip to content

Commit

Permalink
Merge pull request #338 from com-pas/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
massifben authored Oct 12, 2023
2 parents fdc489d + 986df2e commit c382daf
Show file tree
Hide file tree
Showing 27 changed files with 538 additions and 20,542 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/automate_javadoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
DEPENDABOT_BRANCH: dependabot/javadoc-${{ github.head_ref || github.ref_name }}-${{ github.event.pull_request.number }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
Expand All @@ -40,7 +40,7 @@ jobs:
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v5
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY_BOT}}
git_user_signingkey: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reuse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1
uses: fsfe/reuse-action@v2
2 changes: 1 addition & 1 deletion .github/workflows/sonarcloud-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
full_name: ${{ github.event.repository.full_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: ${{ github.event.workflow_run.head_repository.full_name }}
ref: ${{ github.event.workflow_run.head_branch }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonarcloud-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
if: ${{ (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') || (github.actor == 'dependabot[bot]' && github.event_name == 'pull_request_target') }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,41 +112,50 @@ public List<SclReportItem> updateAllExtRefIedNames(SCL scd) {
}

@Override
public List<SclReportItem> createDataSetAndControlBlocks(SCL scd) {
public List<SclReportItem> createDataSetAndControlBlocks(SCL scd, Set<FcdaForDataSetsCreation> allowedFcdas) {
checkFcdaInitDataPresence(allowedFcdas);
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
Stream<LDeviceAdapter> lDeviceAdapters = sclRootAdapter.streamIEDAdapters().flatMap(IEDAdapter::streamLDeviceAdapters);
return createDataSetAndControlBlocks(lDeviceAdapters);
return createDataSetAndControlBlocks(lDeviceAdapters, allowedFcdas);
}

@Override
public List<SclReportItem> createDataSetAndControlBlocks(SCL scd, String targetIedName) {
public List<SclReportItem> createDataSetAndControlBlocks(SCL scd, String targetIedName, Set<FcdaForDataSetsCreation> allowedFcdas) {
checkFcdaInitDataPresence(allowedFcdas);
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
IEDAdapter iedAdapter = sclRootAdapter.getIEDAdapterByName(targetIedName);
return createDataSetAndControlBlocks(iedAdapter.streamLDeviceAdapters());
return createDataSetAndControlBlocks(iedAdapter.streamLDeviceAdapters(), allowedFcdas);

}

@Override
public List<SclReportItem> createDataSetAndControlBlocks(SCL scd, String targetIedName, String targetLDeviceInst) {
public List<SclReportItem> createDataSetAndControlBlocks(SCL scd, String targetIedName, String targetLDeviceInst, Set<FcdaForDataSetsCreation> allowedFcdas) {
if (StringUtils.isBlank(targetIedName)) {
throw new ScdException("IED.name parameter is missing");
}
checkFcdaInitDataPresence(allowedFcdas);
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
IEDAdapter iedAdapter = sclRootAdapter.getIEDAdapterByName(targetIedName);
LDeviceAdapter lDeviceAdapter = iedAdapter.getLDeviceAdapterByLdInst(targetLDeviceInst);
return createDataSetAndControlBlocks(Stream.of(lDeviceAdapter));
return createDataSetAndControlBlocks(Stream.of(lDeviceAdapter), allowedFcdas);
}

private List<SclReportItem> createDataSetAndControlBlocks(Stream<LDeviceAdapter> lDeviceAdapters) {
private void checkFcdaInitDataPresence(Set<FcdaForDataSetsCreation> allowedFcdas) {
if (allowedFcdas == null || allowedFcdas.isEmpty()) {
throw new ScdException("Accepted FCDAs list is empty, you should initialize allowed FCDA lists with CsvHelper class before");
}
}

private List<SclReportItem> createDataSetAndControlBlocks(Stream<LDeviceAdapter> lDeviceAdapters, Set<FcdaForDataSetsCreation> allowedFcdas) {
return lDeviceAdapters
.map(LDeviceAdapter::createDataSetAndControlBlocks)
.map(lDeviceAdapter -> lDeviceAdapter.createDataSetAndControlBlocks(allowedFcdas))
.flatMap(List::stream)
.toList();
}

@Override
public List<SclReportItem> configureNetworkForAllControlBlocks(SCL scd, ControlBlockNetworkSettings controlBlockNetworkSettings,
RangesPerCbType rangesPerCbType) {
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 @@ -6,12 +6,16 @@

import org.lfenergy.compas.scl2007b4.model.SCL;
import org.lfenergy.compas.scl2007b4.model.TExtRef;
import org.lfenergy.compas.sct.commons.dto.*;
import org.lfenergy.compas.sct.commons.dto.ControlBlockNetworkSettings;
import org.lfenergy.compas.sct.commons.dto.ExtRefInfo;
import org.lfenergy.compas.sct.commons.dto.FcdaForDataSetsCreation;
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.util.Utils;

import java.util.List;
import java.util.Set;

/**
* Service class that will be used to create, update or delete elements related to the {@link TExtRef <em>TExtRef</em>} object.
Expand Down Expand Up @@ -61,29 +65,32 @@ public interface ExtRefEditor {
/**
* Create All DataSet and ControlBlock in the SCL based on the ExtRef
*
* @param scd input SCD object. It could be modified by adding new DataSet and ControlBlocks
* @param scd input SCD object. It could be modified by adding new DataSet and ControlBlocks
* @param allowedFcdas List of allowed FCDA for DataSets and Control Blocks creation
* @return list of encountered errors
*/
List<SclReportItem> createDataSetAndControlBlocks(SCL scd);
List<SclReportItem> createDataSetAndControlBlocks(SCL scd, Set<FcdaForDataSetsCreation> allowedFcdas);

/**
* Create All DataSet and ControlBlock for the ExtRef in given IED
*
* @param scd input SCD object. The object will be modified with the new DataSet and ControlBlocks
* @param targetIedName the name of the IED where the ExtRef are
* @param allowedFcdas List of allowed FCDA for DataSets and Control Blocks creation
* @return list of encountered errors
*/
List<SclReportItem> createDataSetAndControlBlocks(SCL scd, String targetIedName);
List<SclReportItem> createDataSetAndControlBlocks(SCL scd, String targetIedName, Set<FcdaForDataSetsCreation> allowedFcdas);

/**
* Create All DataSet and ControlBlock for the ExtRef in given IED and LDevice
*
* @param scd input SCD object. The object will be modified with the new DataSet and ControlBlocks
* @param targetIedName the name of the IED where the ExtRef are
* @param targetLDeviceInst the name of the LDevice where the ExtRef are
* @param allowedFcdas List of allowed FCDA for DataSets and Control Blocks creation
* @return list of encountered errors
*/
List<SclReportItem> createDataSetAndControlBlocks(SCL scd, String targetIedName, String targetLDeviceInst);
List<SclReportItem> createDataSetAndControlBlocks(SCL scd, String targetIedName, String targetLDeviceInst, Set<FcdaForDataSetsCreation> allowedFcdas);

/**
* Configure the network for all the ControlBlocks.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* // SPDX-FileCopyrightText: 2023 RTE FRANCE
* //
* // SPDX-License-Identifier: Apache-2.0
*/

package org.lfenergy.compas.sct.commons.dto;

import com.opencsv.bean.CsvBindByPosition;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Getter
@EqualsAndHashCode
public class FcdaForDataSetsCreation {

@CsvBindByPosition(position = 0)
private String lnClass;
@CsvBindByPosition(position = 1)
private String doName;
@CsvBindByPosition(position = 2)
private String daName;
@CsvBindByPosition(position = 3)
private String fc;
}
Original file line number Diff line number Diff line change
Expand Up @@ -252,21 +252,22 @@ public Pair<String,DOTypeAdapter> findPathDoTypeToDA(String daName) throws ScdEx

/**
* Find path from a SDO to DA (defined by names)
*
* @param sdoName SDO from which find a path
* @param daName DA for which find a path to
* @param daName DA for which find a path to
* @return pair of DO/SDO and DoType. DO/SDO references the DOType
* @throws ScdException when inconsistency are found in th SCL's
* DataTypeTemplate (unknown reference for example). Which should normally not happens.
* DataTypeTemplate (unknown reference for example). Which should normally not happens.
*/
Pair<String,DOTypeAdapter> findPathSDOToDA(String sdoName, String daName) throws ScdException {
String errMsg = String.format("No coherence or path between DO/SDO(%s) and DA(%s)", sdoName,daName);
public Pair<String, DOTypeAdapter> findPathSDOToDA(String sdoName, String daName) throws ScdException {
String errMsg = String.format("No coherence or path between DO/SDO(%s) and DA(%s)", sdoName, daName);
Optional<TSDO> opSdo = getSDOByName(sdoName);
if(opSdo.isEmpty()) {
if (opSdo.isEmpty()) {
throw new ScdException(errMsg);
}

DOTypeAdapter doTypeAdapter = parentAdapter.getDOTypeAdapterById(opSdo.get().getType()).orElse(null);
if(doTypeAdapter == null) {
if (doTypeAdapter == null) {
throw new ScdException(errMsg);
}
if(doTypeAdapter.containsDAWithDAName(daName)){
Expand Down
Loading

0 comments on commit c382daf

Please sign in to comment.