Skip to content

Commit

Permalink
Merge pull request #223 from com-pas/feat/216-analyse-data-groups
Browse files Browse the repository at this point in the history
feat(216): check that Datasets, FCDAs, ControlBlocks (GOOSE, REPORT a…
  • Loading branch information
AliouDIAITE authored Feb 2, 2023
2 parents 580d56c + dee9358 commit 851223c
Show file tree
Hide file tree
Showing 16 changed files with 1,411 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
public class ExtRefService {

private static final String MESSAGE_MISSING_IED_NAME_PARAMETER = "IED.name parameter is missing";
private static final String CLIENT_IED_NAME = "The Client IED ";

/**
* Updates iedName attribute of all ExtRefs in the Scd.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ public static List<ExtRefInfo> getExtRefInfo(SCL scd, String iedName, String ldI

/**
* Create LDevice
* @param scd
* @param iedName
* @param ldInst
* @return
* @param scd SCL file in which LDevice should be found
* @param iedName name of IED in which LDevice is localized
* @param ldInst LdInst of LDevice for which adapter is created
* @return created LDevice adapter
*/
private static LDeviceAdapter createLDeviceAdapter(SCL scd, String iedName, String ldInst) {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
Expand Down Expand Up @@ -572,4 +572,22 @@ public static SclReport updateLDeviceStatus(SCL scd) {
sclReport.setSclRootAdapter(sclRootAdapter);
return sclReport;
}

/**
* Checks Control Blocks, DataSets and FCDA number limitation into Access Points
* @param scd SCL file for which LDevice should be activated or deactivated
* @return SclReport Object that contain SCL file and set of errors
*/
public static SclReport analyzeDataGroups(SCL scd) {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
List<SclReportItem> sclReportItems = sclRootAdapter.streamIEDAdapters()
.map(iedAdapter -> {
List<SclReportItem> list = new ArrayList<>();
list.addAll(iedAdapter.checkDataGroupCoherence());
list.addAll(iedAdapter.checkBindingDataGroupCoherence());
return list;
}).flatMap(Collection::stream).toList();

return new SclReport(sclRootAdapter, sclReportItems);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -961,14 +961,31 @@ public Optional<ControlBlockAdapter> findControlBlock(String name, ControlBlockE

public ControlBlockAdapter createControlBlockIfNotExists(String cbName, String id, String datSet, ControlBlockEnum controlBlockEnum) {
return findControlBlock(cbName, controlBlockEnum)
.orElseGet(() -> addControlBlock(
switch (controlBlockEnum) {
case GSE -> new GooseControlBlock(cbName, id, datSet);
case SAMPLED_VALUE -> new SMVControlBlock(cbName, id, datSet);
case REPORT -> new ReportControlBlock(cbName, id, datSet);
default -> throw new IllegalArgumentException("Unsupported ControlBlock Type " + controlBlockEnum);
}
)
);
.orElseGet(() -> addControlBlock(
switch (controlBlockEnum) {
case GSE -> new GooseControlBlock(cbName, id, datSet);
case SAMPLED_VALUE -> new SMVControlBlock(cbName, id, datSet);
case REPORT -> new ReportControlBlock(cbName, id, datSet);
default -> throw new IllegalArgumentException("Unsupported ControlBlock Type " + controlBlockEnum);
}
)
);
}

/**
* Finds all FCDAs in DataSet of Control Block feeding ExtRef
* @param tExtRef Fed ExtRef
* @return list of all FCDA in DataSet of Control Block
*/
public List<TFCDA> getFCDAs(TExtRef tExtRef){
TControl tControl = getTControlsByType(ControlBlockEnum.from(tExtRef.getServiceType()).getControlBlockClass()).stream()
.filter(tCtrl -> tExtRef.getSrcCBName() != null && tExtRef.getSrcCBName().equals(tCtrl.getName()))
.findFirst().orElseThrow(() ->
new ScdException(String.format("Control Block %s not found in %s", tExtRef.getSrcCBName(), getXPath())));
return getCurrentElem().getDataSet().stream()
.filter(tDataSet -> tDataSet.getName().equals(tControl.getDatSet()))
.map(TDataSet::getFCDA)
.flatMap(Collection::stream)
.toList();
}
}
Loading

0 comments on commit 851223c

Please sign in to comment.