Skip to content

Commit 8e20791

Browse files
committed
WIP
Signed-off-by: massifben <105049157+massifben@users.noreply.github.com>
1 parent afdabad commit 8e20791

File tree

3 files changed

+156
-0
lines changed

3 files changed

+156
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// SPDX-FileCopyrightText: 2024 RTE FRANCE
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
package org.lfenergy.compas.sct;
6+
7+
import lombok.RequiredArgsConstructor;
8+
import org.lfenergy.compas.scl2007b4.model.SCL;
9+
import org.lfenergy.compas.scl2007b4.model.TLDevice;
10+
import org.lfenergy.compas.sct.commons.LdeviceService;
11+
import org.lfenergy.compas.sct.commons.LnService;
12+
import org.lfenergy.compas.sct.commons.dto.SclReportItem;
13+
14+
import java.util.List;
15+
16+
@RequiredArgsConstructor
17+
public class CtlModelService {
18+
19+
private final LdeviceService ldeviceService;
20+
private final LnService lnService;
21+
22+
public List<SclReportItem> update(SCL scl) { // BMA fix name
23+
scl.getIED().stream()
24+
.flatMap(ldeviceService::getLdevices)
25+
.filter(TLDevice::isSetLN0)
26+
.map(TLDevice::getLN0)
27+
.map(ln0 -> {
28+
lnService.getDaiModStVal()
29+
30+
})
31+
32+
return List.of();
33+
}
34+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// SPDX-FileCopyrightText: 2025 RTE FRANCE
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
package org.lfenergy.compas.sct;
6+
7+
import org.junit.jupiter.api.BeforeEach;
8+
import org.junit.jupiter.params.ParameterizedTest;
9+
import org.junit.jupiter.params.provider.Arguments;
10+
import org.junit.jupiter.params.provider.MethodSource;
11+
import org.lfenergy.compas.scl2007b4.model.SCL;
12+
import org.lfenergy.compas.sct.commons.dto.SclReportItem;
13+
import org.lfenergy.compas.sct.commons.testhelpers.SclHelper;
14+
import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller;
15+
16+
import java.util.List;
17+
import java.util.stream.Stream;
18+
19+
import static org.assertj.core.api.Assertions.assertThat;
20+
import static org.junit.jupiter.api.Named.named;
21+
import static org.lfenergy.compas.sct.commons.testhelpers.SclHelper.findDai;
22+
23+
class CtlModelServiceTest {
24+
25+
private CtlModelService ctlModelService;
26+
27+
@BeforeEach
28+
void setUp() {
29+
ctlModelService = new CtlModelService();
30+
}
31+
32+
@ParameterizedTest
33+
@MethodSource("provideUpdateModCtlModel")
34+
void update_should_succeed(String ldInst, String lnClass, String lnInst, String expected) {
35+
// Given
36+
SCL scl = SclTestMarshaller.getSCLFromFile("/scl-ctlmodel/ctlmodel.scd");
37+
// When
38+
List<SclReportItem> sclReportItems = ctlModelService.update(scl);
39+
// Then
40+
assertThat(sclReportItems).isEmpty();
41+
assertThat(findDai(scl, "IED_NAME_1", ldInst, lnClass, lnInst, "", "Mod", "ctlModel"))
42+
.map(SclHelper::getValue)
43+
.hasValue(expected);
44+
}
45+
46+
public static Stream<Arguments> provideUpdateModCtlModel() {
47+
return Stream.of(
48+
// Tests on LN0
49+
Arguments.of(named("LN0 'on' to set to 'direct-with-enhanced-security'", "LDEVICE_1"), "LLN0", "", "direct-with-enhanced-security"),
50+
Arguments.of(named("LN0 'off' to set to 'status-only'", "LDEVICE_2"), "LLN0", "", "status-only")
51+
);
52+
}
53+
54+
55+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- SPDX-FileCopyrightText: 2024 RTE FRANCE -->
3+
<!-- -->
4+
<!-- SPDX-License-Identifier: Apache-2.0 -->
5+
6+
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:compas="https://www.lfenergy.org/compas/extension/v1" version="2007" revision="B" release="4">
7+
<Private xmlns="http://www.iec.ch/61850/2003/SCL" type="COMPAS-SclFileType">
8+
<compas:SclFileType>SCD</compas:SclFileType>
9+
</Private>
10+
<Header id="3F5B212AFD42F7F990742092EB237467" version="000012" revision="A" toolID="Compas"/>
11+
<Substation name="VENES">
12+
<VoltageLevel nomFreq="50" numPhases="3" name="4">
13+
<Voltage unit="V" multiplier="k">90</Voltage>
14+
<Bay name="4BUIS.1"/>
15+
</VoltageLevel>
16+
</Substation>
17+
<IED name="IED_NAME_1">
18+
<AccessPoint name="PROCESS_AP">
19+
<Server>
20+
<Authentication/>
21+
<LDevice inst="LDEVICE_1">
22+
<LN0 lnType="lnType1" lnClass="LLN0" inst="">
23+
<Private type="COMPAS-LNodeStatus">on;off</Private>
24+
<DOI name="Mod">
25+
<DAI name="stVal">
26+
<Val>on</Val>
27+
</DAI>
28+
<DAI name="ctlModel"/>
29+
</DOI>
30+
</LN0>
31+
</LDevice>
32+
<LDevice inst="LDEVICE_2">
33+
<LN0 lnType="lnType1" lnClass="LLN0" inst="">
34+
<Private type="COMPAS-LNodeStatus">on;off</Private>
35+
<DOI name="Mod">
36+
<DAI name="stVal">
37+
<Val>off</Val>
38+
</DAI>
39+
<DAI name="ctlModel"/>
40+
</DOI>
41+
</LN0>
42+
</LDevice>
43+
</Server>
44+
</AccessPoint>
45+
</IED>
46+
<DataTypeTemplates>
47+
<LNodeType id="lnType1" lnClass="LLN0">
48+
<DO name="Mod" type="DO_Mod"/>
49+
</LNodeType>
50+
<LNodeType id="lnType2" lnClass="PDIS">
51+
<DO name="Mod" type="DO_Mod"/>
52+
</LNodeType>
53+
<DOType id="DO_Mod" cdc="ENC">
54+
<DA fc="ST" name="stVal" bType="Enum" type="DA_stVal" dchg="true"/>
55+
<DA fc="CF" name="ctlModel" bType="Enum" type="DA_ctlModel"/>
56+
</DOType>
57+
<EnumType id="DA_stVal">
58+
<EnumVal ord="1">on</EnumVal>
59+
<EnumVal ord="2">off</EnumVal>
60+
<EnumVal ord="3">test</EnumVal>
61+
</EnumType>
62+
<EnumType id="DA_ctlModel">
63+
<EnumVal ord="1">status-only</EnumVal>
64+
<EnumVal ord="2">direct-with-enhanced-security</EnumVal>
65+
</EnumType>
66+
</DataTypeTemplates>
67+
</SCL>

0 commit comments

Comments
 (0)