Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: massifben <[email protected]>
  • Loading branch information
massifben committed Jan 17, 2025
1 parent afdabad commit 8e20791
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-FileCopyrightText: 2024 RTE FRANCE
//
// SPDX-License-Identifier: Apache-2.0

package org.lfenergy.compas.sct;

import lombok.RequiredArgsConstructor;
import org.lfenergy.compas.scl2007b4.model.SCL;
import org.lfenergy.compas.scl2007b4.model.TLDevice;
import org.lfenergy.compas.sct.commons.LdeviceService;
import org.lfenergy.compas.sct.commons.LnService;
import org.lfenergy.compas.sct.commons.dto.SclReportItem;

import java.util.List;

@RequiredArgsConstructor
public class CtlModelService {

private final LdeviceService ldeviceService;
private final LnService lnService;

public List<SclReportItem> update(SCL scl) { // BMA fix name
scl.getIED().stream()
.flatMap(ldeviceService::getLdevices)
.filter(TLDevice::isSetLN0)
.map(TLDevice::getLN0)
.map(ln0 -> {
lnService.getDaiModStVal()

})

return List.of();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// SPDX-FileCopyrightText: 2025 RTE FRANCE
//
// SPDX-License-Identifier: Apache-2.0

package org.lfenergy.compas.sct;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.lfenergy.compas.scl2007b4.model.SCL;
import org.lfenergy.compas.sct.commons.dto.SclReportItem;
import org.lfenergy.compas.sct.commons.testhelpers.SclHelper;
import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller;

import java.util.List;
import java.util.stream.Stream;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Named.named;
import static org.lfenergy.compas.sct.commons.testhelpers.SclHelper.findDai;

class CtlModelServiceTest {

private CtlModelService ctlModelService;

@BeforeEach
void setUp() {
ctlModelService = new CtlModelService();
}

@ParameterizedTest
@MethodSource("provideUpdateModCtlModel")
void update_should_succeed(String ldInst, String lnClass, String lnInst, String expected) {
// Given
SCL scl = SclTestMarshaller.getSCLFromFile("/scl-ctlmodel/ctlmodel.scd");
// When
List<SclReportItem> sclReportItems = ctlModelService.update(scl);
// Then
assertThat(sclReportItems).isEmpty();
assertThat(findDai(scl, "IED_NAME_1", ldInst, lnClass, lnInst, "", "Mod", "ctlModel"))
.map(SclHelper::getValue)
.hasValue(expected);
}

public static Stream<Arguments> provideUpdateModCtlModel() {
return Stream.of(
// Tests on LN0
Arguments.of(named("LN0 'on' to set to 'direct-with-enhanced-security'", "LDEVICE_1"), "LLN0", "", "direct-with-enhanced-security"),
Arguments.of(named("LN0 'off' to set to 'status-only'", "LDEVICE_2"), "LLN0", "", "status-only")
);
}


}
67 changes: 67 additions & 0 deletions sct-commons/src/test/resources/scl-ctlmodel/ctlmodel.scd
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- SPDX-FileCopyrightText: 2024 RTE FRANCE -->
<!-- -->
<!-- SPDX-License-Identifier: Apache-2.0 -->

<SCL xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:compas="https://www.lfenergy.org/compas/extension/v1" version="2007" revision="B" release="4">
<Private xmlns="http://www.iec.ch/61850/2003/SCL" type="COMPAS-SclFileType">
<compas:SclFileType>SCD</compas:SclFileType>
</Private>
<Header id="3F5B212AFD42F7F990742092EB237467" version="000012" revision="A" toolID="Compas"/>
<Substation name="VENES">
<VoltageLevel nomFreq="50" numPhases="3" name="4">
<Voltage unit="V" multiplier="k">90</Voltage>
<Bay name="4BUIS.1"/>
</VoltageLevel>
</Substation>
<IED name="IED_NAME_1">
<AccessPoint name="PROCESS_AP">
<Server>
<Authentication/>
<LDevice inst="LDEVICE_1">
<LN0 lnType="lnType1" lnClass="LLN0" inst="">
<Private type="COMPAS-LNodeStatus">on;off</Private>
<DOI name="Mod">
<DAI name="stVal">
<Val>on</Val>
</DAI>
<DAI name="ctlModel"/>
</DOI>
</LN0>
</LDevice>
<LDevice inst="LDEVICE_2">
<LN0 lnType="lnType1" lnClass="LLN0" inst="">
<Private type="COMPAS-LNodeStatus">on;off</Private>
<DOI name="Mod">
<DAI name="stVal">
<Val>off</Val>
</DAI>
<DAI name="ctlModel"/>
</DOI>
</LN0>
</LDevice>
</Server>
</AccessPoint>
</IED>
<DataTypeTemplates>
<LNodeType id="lnType1" lnClass="LLN0">
<DO name="Mod" type="DO_Mod"/>
</LNodeType>
<LNodeType id="lnType2" lnClass="PDIS">
<DO name="Mod" type="DO_Mod"/>
</LNodeType>
<DOType id="DO_Mod" cdc="ENC">
<DA fc="ST" name="stVal" bType="Enum" type="DA_stVal" dchg="true"/>
<DA fc="CF" name="ctlModel" bType="Enum" type="DA_ctlModel"/>
</DOType>
<EnumType id="DA_stVal">
<EnumVal ord="1">on</EnumVal>
<EnumVal ord="2">off</EnumVal>
<EnumVal ord="3">test</EnumVal>
</EnumType>
<EnumType id="DA_ctlModel">
<EnumVal ord="1">status-only</EnumVal>
<EnumVal ord="2">direct-with-enhanced-security</EnumVal>
</EnumType>
</DataTypeTemplates>
</SCL>

0 comments on commit 8e20791

Please sign in to comment.