-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LDEPF disturbances and faults recording: interface between the settin…
…g file reading and the SCD file (#262) Signed-off-by: Samir Romdhani <[email protected]>
- Loading branch information
1 parent
7c2bdcd
commit 8b3e0ac
Showing
5 changed files
with
338 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/LDEPFSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// SPDX-FileCopyrightText: 2023 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons.dto; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Represents a list of LDEPF settings | ||
* This is a functional interface whose functional method is getLDEPFSettings | ||
* the type of the input to the operation | ||
* | ||
* @param <T> the type of the result of the LDEPFSettings | ||
* | ||
* @see org.lfenergy.compas.sct.commons.util.SettingLDEPFCsvHelper | ||
*/ | ||
@FunctionalInterface | ||
public interface LDEPFSettings<T> { | ||
|
||
/** | ||
* This method provides list of LDEPF settings | ||
*/ | ||
List<T> getSettings(); | ||
} |
89 changes: 89 additions & 0 deletions
89
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/SettingLDEPFCsvHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// SPDX-FileCopyrightText: 2023 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons.util; | ||
|
||
import com.opencsv.bean.CsvBindByPosition; | ||
import lombok.ToString; | ||
import org.lfenergy.compas.sct.commons.dto.LDEPFSettings; | ||
|
||
import java.io.Reader; | ||
import java.util.List; | ||
|
||
|
||
/** | ||
* This class is an implementation example for interface LDEPFSettings. | ||
* It relies on a CSV file. | ||
* | ||
* @see CsvUtils | ||
*/ | ||
public class SettingLDEPFCsvHelper implements LDEPFSettings<SettingLDEPFCsvHelper.SettingLDEPF> { | ||
|
||
private final List<SettingLDEPF> settings ; | ||
|
||
/** | ||
* Constructor | ||
* @param reader input | ||
*/ | ||
public SettingLDEPFCsvHelper(Reader reader) { | ||
this.settings = CsvUtils.parseRows(reader, SettingLDEPF.class).stream().toList(); | ||
} | ||
|
||
@Override | ||
public List<SettingLDEPF> getSettings() { | ||
return this.settings; | ||
} | ||
|
||
@ToString | ||
public static class SettingLDEPF { | ||
@CsvBindByPosition(position = 0) | ||
private String rteIedType; | ||
@CsvBindByPosition(position = 1) | ||
private String iedRedundancy; | ||
@CsvBindByPosition(position = 2) | ||
private String iedInstance; | ||
@CsvBindByPosition(position = 3) | ||
private String channelShortLabel; | ||
@CsvBindByPosition(position = 4) | ||
private String channelMREP; | ||
@CsvBindByPosition(position = 5) | ||
private String channelLevModQ; | ||
@CsvBindByPosition(position = 6) | ||
private String channelLevModLevMod; | ||
@CsvBindByPosition(position = 7) | ||
private String bapVariant; | ||
@CsvBindByPosition(position = 8) | ||
private String bapIgnoredValue; | ||
@CsvBindByPosition(position = 9) | ||
private String ldInst; | ||
@CsvBindByPosition(position = 10) | ||
private String lnPrefix; | ||
@CsvBindByPosition(position = 11) | ||
private String lnName; | ||
@CsvBindByPosition(position = 12) | ||
private String lnInst; | ||
@CsvBindByPosition(position = 13) | ||
private String doName; | ||
@CsvBindByPosition(position = 14) | ||
private String doInst; | ||
@CsvBindByPosition(position = 15) | ||
private String sdoName; | ||
@CsvBindByPosition(position = 16) | ||
private String daName; | ||
@CsvBindByPosition(position = 17) | ||
private String daType; | ||
@CsvBindByPosition(position = 18) | ||
private String dabType; | ||
@CsvBindByPosition(position = 19) | ||
private String bdaName; | ||
@CsvBindByPosition(position = 20) | ||
private String sbdaName; | ||
@CsvBindByPosition(position = 21) | ||
private String channelAnalogNum; | ||
@CsvBindByPosition(position = 22) | ||
private String channelDigitalNum; | ||
@CsvBindByPosition(position = 23) | ||
private String opt; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/LDEPFSettingsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 org.junit.jupiter.api.Test; | ||
import org.lfenergy.compas.sct.commons.util.CsvUtils; | ||
import org.lfenergy.compas.sct.commons.util.SettingLDEPFCsvHelper; | ||
|
||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.util.Objects; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class LDEPFSettingsTest { | ||
|
||
@Test | ||
void getLDEPFSettings_should_return_settings() { | ||
//Given | ||
String fileName = "LDEPF_Setting_file.csv"; | ||
InputStream inputStream = Objects.requireNonNull(CsvUtils.class.getClassLoader().getResourceAsStream(fileName), "Resource not found: " + fileName); | ||
InputStreamReader reader = new InputStreamReader(inputStream); | ||
LDEPFSettings<SettingLDEPFCsvHelper.SettingLDEPF> ldepfSettings = new SettingLDEPFCsvHelper(reader); | ||
// When | ||
// Then | ||
assertThat(ldepfSettings.getSettings()).hasSize(161); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...commons/src/test/java/org/lfenergy/compas/sct/commons/util/SettingLDEPFCsvHelperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.util; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.util.Objects; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
|
||
class SettingLDEPFCsvHelperTest { | ||
|
||
@Test | ||
void readCsvFile_should_return_settings() { | ||
// Given | ||
String fileName = "LDEPF_Setting_file.csv"; | ||
InputStream inputStream = Objects.requireNonNull(CsvUtils.class.getClassLoader().getResourceAsStream(fileName), "Resource not found: " + fileName); | ||
InputStreamReader reader = new InputStreamReader(inputStream); | ||
// When | ||
// Then | ||
SettingLDEPFCsvHelper settingLDEPFCsvHelper = new SettingLDEPFCsvHelper(reader); | ||
assertThat(settingLDEPFCsvHelper.getSettings()).hasSize(161); | ||
} | ||
} |
Oops, something went wrong.