Skip to content
Snippets Groups Projects
Commit cefc3656 authored by Dominique Marcadet's avatar Dominique Marcadet
Browse files

presence condition for DataAttribute initial implementation

parent b18bf0f8
No related branches found
No related tags found
1 merge request!11Resolve "complete validation by NSD"
/**
* Copyright (c) 2019 CentraleSupélec & EDF.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* This file is part of the RiseClipse tool
*
* Contributors:
* Computer Science Department, CentraleSupélec
* EDF R&D
* Contacts:
* dominique.marcadet@centralesupelec.fr
* aurelie.dehouck-neveu@edf.fr
* Web site:
* http://wdi.supelec.fr/software/RiseClipse/
*/
package fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.nsd;
import org.eclipse.emf.common.util.DiagnosticChain;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.CDC;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.DOType;
import fr.centralesupelec.edf.riseclipse.util.AbstractRiseClipseConsole;
public class DOTypeValidator {
private DataAttributePresenceConditionValidator dataAttributePresenceConditionValidator;
public DOTypeValidator( CDC cdc ) {
dataAttributePresenceConditionValidator = DataAttributePresenceConditionValidator.get( cdc );
}
public boolean validateDOType( DOType doType, DiagnosticChain diagnostics ) {
AbstractRiseClipseConsole.getConsole().verbose( "[NSD] validateDOType( " + doType.getId() + " )" );
dataAttributePresenceConditionValidator.reset();
doType
.getDA()
.stream()
.forEach( d -> dataAttributePresenceConditionValidator.addDA( d, diagnostics ));
return dataAttributePresenceConditionValidator.validate( doType, diagnostics );
}
}
/**
* Copyright (c) 2019 CentraleSupélec & EDF.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* This file is part of the RiseClipse tool
*
* Contributors:
* Computer Science Department, CentraleSupélec
* EDF R&D
* Contacts:
* dominique.marcadet@centralesupelec.fr
* aurelie.dehouck-neveu@edf.fr
* Web site:
* http://wdi.supelec.fr/software/RiseClipse/
*/
package fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.nsd; package fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.nsd;
import java.util.HashMap; import java.util.HashMap;
...@@ -11,7 +29,6 @@ import org.eclipse.emf.common.util.Diagnostic; ...@@ -11,7 +29,6 @@ import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.DiagnosticChain; import org.eclipse.emf.common.util.DiagnosticChain;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.AnyLNClass; import fr.centralesupelec.edf.riseclipse.iec61850.nsd.AnyLNClass;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.DataObject;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.AnyLN; import fr.centralesupelec.edf.riseclipse.iec61850.scl.AnyLN;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.DA; import fr.centralesupelec.edf.riseclipse.iec61850.scl.DA;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.DO; import fr.centralesupelec.edf.riseclipse.iec61850.scl.DO;
...@@ -23,19 +40,19 @@ import fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.RiseClipseValida ...@@ -23,19 +40,19 @@ import fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.RiseClipseValida
import fr.centralesupelec.edf.riseclipse.util.AbstractRiseClipseConsole; import fr.centralesupelec.edf.riseclipse.util.AbstractRiseClipseConsole;
import fr.centralesupelec.edf.riseclipse.util.IRiseClipseConsole; import fr.centralesupelec.edf.riseclipse.util.IRiseClipseConsole;
public class PresenceConditionValidator { public class DataObjectPresenceConditionValidator {
private static HashMap< String, PresenceConditionValidator > validators = new HashMap<>(); private static HashMap< String, DataObjectPresenceConditionValidator > validators = new HashMap<>();
public static PresenceConditionValidator get( AnyLNClass anyLNClass ) { public static DataObjectPresenceConditionValidator get( AnyLNClass anyLNClass ) {
if( ! validators.containsKey( anyLNClass.getName() )) { if( ! validators.containsKey( anyLNClass.getName() )) {
validators.put( anyLNClass.getName(), new PresenceConditionValidator( anyLNClass )); validators.put( anyLNClass.getName(), new DataObjectPresenceConditionValidator( anyLNClass ));
} }
return validators.get( anyLNClass.getName() ); return validators.get( anyLNClass.getName() );
} }
private AnyLNClass anyLNClass; private AnyLNClass anyLNClass;
private PresenceConditionValidator base; private DataObjectPresenceConditionValidator base;
private static class SingleOrMultiDO { private static class SingleOrMultiDO {
} }
...@@ -99,12 +116,14 @@ public class PresenceConditionValidator { ...@@ -99,12 +116,14 @@ public class PresenceConditionValidator {
private final IRiseClipseConsole console = AbstractRiseClipseConsole.getConsole(); private final IRiseClipseConsole console = AbstractRiseClipseConsole.getConsole();
private PresenceConditionValidator( AnyLNClass anyLNClass ) { private DataObjectPresenceConditionValidator( AnyLNClass anyLNClass ) {
this.anyLNClass = anyLNClass; this.anyLNClass = anyLNClass;
for( DataObject dObj : anyLNClass.getDataObject() ) { anyLNClass
addSpecification( dObj.getName(), dObj.getPresCond(), dObj.getPresCondArgs() ); .getDataObject()
} .stream()
.forEach( d -> addSpecification( d.getName(), d.getPresCond(), d.getPresCondArgs() ) );
checkSpecification(); checkSpecification();
AnyLNClass parent = anyLNClass.getRefersToAbstractLNClass(); AnyLNClass parent = anyLNClass.getRefersToAbstractLNClass();
...@@ -123,7 +142,7 @@ public class PresenceConditionValidator { ...@@ -123,7 +142,7 @@ public class PresenceConditionValidator {
private void addSpecification( String name, String presCond, String presCondArgs ) { private void addSpecification( String name, String presCond, String presCondArgs ) {
if( presentDO.containsKey( name )) { if( presentDO.containsKey( name )) {
console.warning( "[NSD setup] " + name + " has already been added to PresenceConditionValidator" ); console.warning( "[NSD setup] " + name + " has already been added to DataObjectPresenceConditionValidator" );
return; return;
} }
presentDO.put( name, null ); presentDO.put( name, null );
...@@ -147,7 +166,7 @@ public class PresenceConditionValidator { ...@@ -147,7 +166,7 @@ public class PresenceConditionValidator {
case "na" : case "na" :
// Element is not applicable // Element is not applicable
// -> TODO: what does it mean ? what do we have to check ? // -> TODO: what does it mean ? what do we have to check ?
console.warning( "[NSD setup] NOT IMPLEMENTED: " + name + " declared as \"na\" in PresenceCondition" ); console.warning( "[NSD setup] NOT IMPLEMENTED: DataObject " + name + " declared as \"na\" in PresenceCondition" );
// if( notApplicable == null ) notApplicable = new HashSet<>(); // if( notApplicable == null ) notApplicable = new HashSet<>();
// notApplicable.add( name ); // notApplicable.add( name );
break; break;
...@@ -373,7 +392,7 @@ public class PresenceConditionValidator { ...@@ -373,7 +392,7 @@ public class PresenceConditionValidator {
case "MFsubst" : case "MFsubst" :
// Element is mandatory if substitution is supported (for substitution, see IEC 61850-7-3), otherwise forbidden // Element is mandatory if substitution is supported (for substitution, see IEC 61850-7-3), otherwise forbidden
// TODO: how do we know if substitution is supported ? // TODO: how do we know if substitution is supported ?
console.warning( "[NSD setup] NOT IMPLEMENTED: " + name + " declared as \"MFsubst\" in PresenceCondition" ); console.warning( "[NSD setup] NOT IMPLEMENTED: DataObject " + name + " declared as \"MFsubst\" in PresenceCondition" );
// if( mandatoryIfSubstitutionElseForbidden == null ) mandatoryIfSubstitutionElseForbidden = new HashSet<>(); // if( mandatoryIfSubstitutionElseForbidden == null ) mandatoryIfSubstitutionElseForbidden = new HashSet<>();
// mandatoryIfSubstitutionElseForbidden.add( name ); // mandatoryIfSubstitutionElseForbidden.add( name );
break; break;
...@@ -390,14 +409,14 @@ public class PresenceConditionValidator { ...@@ -390,14 +409,14 @@ public class PresenceConditionValidator {
case "MOlnNs" : case "MOlnNs" :
// Element is mandatory if the name space of its logical node deviates from the name space of the containing // Element is mandatory if the name space of its logical node deviates from the name space of the containing
// logical device, otherwise optional. See IEC 61850-7-1 for use of name space // logical device, otherwise optional. See IEC 61850-7-1 for use of name space
console.warning( "[NSD setup] NOT IMPLEMENTED: " + name + " declared as \"MOlnNs\" in PresenceCondition" ); console.warning( "[NSD setup] NOT IMPLEMENTED: DataObject " + name + " declared as \"MOlnNs\" in PresenceCondition" );
// if( mandatoryIfNameSpaceOfLogicalNodeDeviatesElseOptional == null ) mandatoryIfNameSpaceOfLogicalNodeDeviatesElseOptional = new HashSet<>(); // if( mandatoryIfNameSpaceOfLogicalNodeDeviatesElseOptional == null ) mandatoryIfNameSpaceOfLogicalNodeDeviatesElseOptional = new HashSet<>();
// mandatoryIfNameSpaceOfLogicalNodeDeviatesElseOptional.add( name ); // mandatoryIfNameSpaceOfLogicalNodeDeviatesElseOptional.add( name );
break; break;
case "MOdataNs" : case "MOdataNs" :
// Element is mandatory if the name space of its data object deviates from the name space of its logical node, // Element is mandatory if the name space of its data object deviates from the name space of its logical node,
// otherwise optional. See IEC 61850-7-1 for use of name space // otherwise optional. See IEC 61850-7-1 for use of name space
console.warning( "[NSD setup] NOT IMPLEMENTED: " + name + " declared as \"MOdataNs\" in PresenceCondition" ); console.warning( "[NSD setup] NOT IMPLEMENTED: DataObject " + name + " declared as \"MOdataNs\" in PresenceCondition" );
// if( mandatoryIfNameSpaceOfDataObjectDeviatesElseOptional == null ) mandatoryIfNameSpaceOfDataObjectDeviatesElseOptional = new HashSet<>(); // if( mandatoryIfNameSpaceOfDataObjectDeviatesElseOptional == null ) mandatoryIfNameSpaceOfDataObjectDeviatesElseOptional = new HashSet<>();
// mandatoryIfNameSpaceOfDataObjectDeviatesElseOptional.add( name ); // mandatoryIfNameSpaceOfDataObjectDeviatesElseOptional.add( name );
break; break;
...@@ -405,28 +424,28 @@ public class PresenceConditionValidator { ...@@ -405,28 +424,28 @@ public class PresenceConditionValidator {
// Element is mandatory* if any sibling elements of type AnalogueValue include 'i' as a child, otherwise forbidden. // Element is mandatory* if any sibling elements of type AnalogueValue include 'i' as a child, otherwise forbidden.
// *Even though devices without floating point capability cannot exchange floating point values through ACSI services, // *Even though devices without floating point capability cannot exchange floating point values through ACSI services,
// the description of scaling remains mandatory for their (SCL) configuration // the description of scaling remains mandatory for their (SCL) configuration
console.warning( "[NSD setup] NOT IMPLEMENTED: " + name + " declared as \"MFscaledAV\" in PresenceCondition" ); console.warning( "[NSD setup] NOT IMPLEMENTED: DataObject " + name + " declared as \"MFscaledAV\" in PresenceCondition" );
// if( mandatoryIfAnalogValueIncludesIElseForbidden == null ) mandatoryIfAnalogValueIncludesIElseForbidden = new HashSet<>(); // if( mandatoryIfAnalogValueIncludesIElseForbidden == null ) mandatoryIfAnalogValueIncludesIElseForbidden = new HashSet<>();
// mandatoryIfAnalogValueIncludesIElseForbidden.add( name ); // mandatoryIfAnalogValueIncludesIElseForbidden.add( name );
break; break;
case "MFscaledMagV" : case "MFscaledMagV" :
// Element is mandatory* if any sibling elements of type Vector include 'i' as a child of their 'mag' attribute, otherwise forbidden. // Element is mandatory* if any sibling elements of type Vector include 'i' as a child of their 'mag' attribute, otherwise forbidden.
// *See MFscaledAV // *See MFscaledAV
console.warning( "[NSD setup] NOT IMPLEMENTED: " + name + " declared as \"MFscaledMagV\" in PresenceCondition" ); console.warning( "[NSD setup] NOT IMPLEMENTED: DataObject " + name + " declared as \"MFscaledMagV\" in PresenceCondition" );
// if( mandatoryIfVectorSiblingIncludesIAsChildMagElseForbidden == null ) mandatoryIfVectorSiblingIncludesIAsChildMagElseForbidden = new HashSet<>(); // if( mandatoryIfVectorSiblingIncludesIAsChildMagElseForbidden == null ) mandatoryIfVectorSiblingIncludesIAsChildMagElseForbidden = new HashSet<>();
// mandatoryIfVectorSiblingIncludesIAsChildMagElseForbidden.add( name ); // mandatoryIfVectorSiblingIncludesIAsChildMagElseForbidden.add( name );
break; break;
case "MFscaledAngV" : case "MFscaledAngV" :
// Element is mandatory* if any sibling elements of type Vector include 'i' as a child of their 'ang' attribute, otherwise forbidden. // Element is mandatory* if any sibling elements of type Vector include 'i' as a child of their 'ang' attribute, otherwise forbidden.
// *See MFscaledAV // *See MFscaledAV
console.warning( "[NSD setup] NOT IMPLEMENTED: " + name + " declared as \"MFscaledAngV\" in PresenceCondition" ); console.warning( "[NSD setup] NOT IMPLEMENTED: DataObject " + name + " declared as \"MFscaledAngV\" in PresenceCondition" );
// if( mandatoryIfVectorSiblingIncludesIAsChildAngElseForbidden == null ) mandatoryIfVectorSiblingIncludesIAsChildAngElseForbidden = new HashSet<>(); // if( mandatoryIfVectorSiblingIncludesIAsChildAngElseForbidden == null ) mandatoryIfVectorSiblingIncludesIAsChildAngElseForbidden = new HashSet<>();
// mandatoryIfVectorSiblingIncludesIAsChildAngElseForbidden.add( name ); // mandatoryIfVectorSiblingIncludesIAsChildAngElseForbidden.add( name );
break; break;
case "MOrms" : case "MOrms" :
// Element is mandatory if the harmonic values in the context are calculated as a ratio to RMS value // Element is mandatory if the harmonic values in the context are calculated as a ratio to RMS value
// (value of data attribute 'hvRef' is 'rms'), optional otherwise // (value of data attribute 'hvRef' is 'rms'), optional otherwise
console.warning( "[NSD setup] NOT IMPLEMENTED: " + name + " declared as \"MOrms\" in PresenceCondition" ); console.warning( "[NSD setup] NOT IMPLEMENTED: DataObject " + name + " declared as \"MOrms\" in PresenceCondition" );
// if( mandatoryIfHarmonicValuesCalculatedAsRatioElseOptional == null ) mandatoryIfHarmonicValuesCalculatedAsRatioElseOptional = new HashSet<>(); // if( mandatoryIfHarmonicValuesCalculatedAsRatioElseOptional == null ) mandatoryIfHarmonicValuesCalculatedAsRatioElseOptional = new HashSet<>();
// mandatoryIfHarmonicValuesCalculatedAsRatioElseOptional.add( name ); // mandatoryIfHarmonicValuesCalculatedAsRatioElseOptional.add( name );
break; break;
...@@ -437,28 +456,28 @@ public class PresenceConditionValidator { ...@@ -437,28 +456,28 @@ public class PresenceConditionValidator {
break; break;
case "MOoperTm" : case "MOoperTm" :
// Element is mandatory if at least one controlled object on the IED supports time activation service; otherwise it is optional // Element is mandatory if at least one controlled object on the IED supports time activation service; otherwise it is optional
console.warning( "[NSD setup] NOT IMPLEMENTED: " + name + " declared as \"MOoperTm\" in PresenceCondition" ); console.warning( "[NSD setup] NOT IMPLEMENTED: DataObject " + name + " declared as \"MOoperTm\" in PresenceCondition" );
// if( mandatoryIfControlSupportsTimeElseOptional == null ) mandatoryIfControlSupportsTimeElseOptional = new HashSet<>(); // if( mandatoryIfControlSupportsTimeElseOptional == null ) mandatoryIfControlSupportsTimeElseOptional = new HashSet<>();
// mandatoryIfControlSupportsTimeElseOptional.add( name ); // mandatoryIfControlSupportsTimeElseOptional.add( name );
break; break;
case "MmultiF" : case "MmultiF" :
// Parameter sibling: sibling element name. // Parameter sibling: sibling element name.
// One or more elements must be present if sibling element is present, otherwise forbidden // One or more elements must be present if sibling element is present, otherwise forbidden
console.warning( "[NSD setup] NOT IMPLEMENTED: " + name + " declared as \"MmultiF\" in PresenceCondition" ); console.warning( "[NSD setup] NOT IMPLEMENTED: DataObject " + name + " declared as \"MmultiF\" in PresenceCondition" );
// if( oneOrMoreIfSiblingPresentElseForbidden == null ) oneOrMoreIfSiblingPresentElseForbidden = new HashMap<>(); // if( oneOrMoreIfSiblingPresentElseForbidden == null ) oneOrMoreIfSiblingPresentElseForbidden = new HashMap<>();
// oneOrMoreIfSiblingPresentElseForbidden.put( name, presCondArgs ); // oneOrMoreIfSiblingPresentElseForbidden.put( name, presCondArgs );
break; break;
case "MOsbo" : case "MOsbo" :
// Element is mandatory if declared control model supports 'sbo-with-normal-security' or 'sbo-with-enhanced-security', // Element is mandatory if declared control model supports 'sbo-with-normal-security' or 'sbo-with-enhanced-security',
// otherwise optional and value is of no impact // otherwise optional and value is of no impact
console.warning( "[NSD setup] NOT IMPLEMENTED: " + name + " declared as \"MOsbo\" in PresenceCondition" ); console.warning( "[NSD setup] NOT IMPLEMENTED: DataObject " + name + " declared as \"MOsbo\" in PresenceCondition" );
// if( mandatoryIfControlSupportsSecurity1ElseOptional == null ) mandatoryIfControlSupportsSecurity1ElseOptional = new HashSet<>(); // if( mandatoryIfControlSupportsSecurity1ElseOptional == null ) mandatoryIfControlSupportsSecurity1ElseOptional = new HashSet<>();
// mandatoryIfControlSupportsSecurity1ElseOptional.add( name ); // mandatoryIfControlSupportsSecurity1ElseOptional.add( name );
break; break;
case "MOenhanced" : case "MOenhanced" :
// Element is mandatory if declared control model supports 'direct-with-enhanced-security' or 'sbo-with-enhanced-security', // Element is mandatory if declared control model supports 'direct-with-enhanced-security' or 'sbo-with-enhanced-security',
// otherwise optional and value is of no impact // otherwise optional and value is of no impact
console.warning( "[NSD setup] NOT IMPLEMENTED: " + name + " declared as \"MOenhanced\" in PresenceCondition" ); console.warning( "[NSD setup] NOT IMPLEMENTED: DataObject " + name + " declared as \"MOenhanced\" in PresenceCondition" );
// if( mandatoryIfControlSupportsSecurity2ElseOptional == null ) mandatoryIfControlSupportsSecurity2ElseOptional = new HashSet<>(); // if( mandatoryIfControlSupportsSecurity2ElseOptional == null ) mandatoryIfControlSupportsSecurity2ElseOptional = new HashSet<>();
// mandatoryIfControlSupportsSecurity2ElseOptional.add( name ); // mandatoryIfControlSupportsSecurity2ElseOptional.add( name );
break; break;
...@@ -466,7 +485,7 @@ public class PresenceConditionValidator { ...@@ -466,7 +485,7 @@ public class PresenceConditionValidator {
// Element is mandatory if the name space of its logical node deviates from the name space of the containing // Element is mandatory if the name space of its logical node deviates from the name space of the containing
// logical device, otherwise optional. See IEC 61850-7-1 for use of name space // logical device, otherwise optional. See IEC 61850-7-1 for use of name space
// TODO: same as "MOlnNs" ? // TODO: same as "MOlnNs" ?
console.warning( "[NSD setup] NOT IMPLEMENTED: " + name + " declared as \"MONamPlt\" in PresenceCondition" ); console.warning( "[NSD setup] NOT IMPLEMENTED: DataObject " + name + " declared as \"MONamPlt\" in PresenceCondition" );
// if( mandatoryIfNameSpaceOfLogicalNodeDeviatesElseOptional2 == null ) mandatoryIfNameSpaceOfLogicalNodeDeviatesElseOptional2 = new HashSet<>(); // if( mandatoryIfNameSpaceOfLogicalNodeDeviatesElseOptional2 == null ) mandatoryIfNameSpaceOfLogicalNodeDeviatesElseOptional2 = new HashSet<>();
// mandatoryIfNameSpaceOfLogicalNodeDeviatesElseOptional2.add( name ); // mandatoryIfNameSpaceOfLogicalNodeDeviatesElseOptional2.add( name );
break; break;
...@@ -479,13 +498,13 @@ public class PresenceConditionValidator { ...@@ -479,13 +498,13 @@ public class PresenceConditionValidator {
case "MORange" : case "MORange" :
// Element is mandatory if the measured value associated (amplitude respectively angle) exposes the range eventing // Element is mandatory if the measured value associated (amplitude respectively angle) exposes the range eventing
// (with the attribute range respectively rangeAng) // (with the attribute range respectively rangeAng)
console.warning( "[NSD setup] NOT IMPLEMENTED: " + name + " declared as \"MORange\" in PresenceCondition" ); console.warning( "[NSD setup] NOT IMPLEMENTED: DataObject " + name + " declared as \"MORange\" in PresenceCondition" );
// if( mandatoryIfMeasuredValueExposesRange == null ) mandatoryIfMeasuredValueExposesRange = new HashSet<>(); // if( mandatoryIfMeasuredValueExposesRange == null ) mandatoryIfMeasuredValueExposesRange = new HashSet<>();
// mandatoryIfMeasuredValueExposesRange.add( name ); // mandatoryIfMeasuredValueExposesRange.add( name );
break; break;
case "OMSynPh" : case "OMSynPh" :
// This attribute is optional if value of 'phsRef'' is Synchrophasor otherwise Mandatory]]></Doc> // This attribute is optional if value of 'phsRef'' is Synchrophasor otherwise Mandatory]]></Doc>
console.warning( "[NSD setup] NOT IMPLEMENTED: " + name + " declared as \"OMSynPh\" in PresenceCondition" ); console.warning( "[NSD setup] NOT IMPLEMENTED: DataObject " + name + " declared as \"OMSynPh\" in PresenceCondition" );
// if( optionalIfPhsRefIsSynchrophasorElseMandatory == null ) optionalIfPhsRefIsSynchrophasorElseMandatory = new HashSet<>(); // if( optionalIfPhsRefIsSynchrophasorElseMandatory == null ) optionalIfPhsRefIsSynchrophasorElseMandatory = new HashSet<>();
// optionalIfPhsRefIsSynchrophasorElseMandatory.add( name ); // optionalIfPhsRefIsSynchrophasorElseMandatory.add( name );
break; break;
...@@ -698,7 +717,7 @@ public class PresenceConditionValidator { ...@@ -698,7 +717,7 @@ public class PresenceConditionValidator {
"[NSD validation] DO " + name + " should not have an instance number in LNodeType (line " + lNodeType.getLineNumber() + ") with LNClass " + anyLNClassName, "[NSD validation] DO " + name + " should not have an instance number in LNodeType (line " + lNodeType.getLineNumber() + ") with LNClass " + anyLNClassName,
new Object[] { lNodeType } )); new Object[] { lNodeType } ));
res = false; res = false;
} }
} }
} }
...@@ -724,7 +743,7 @@ public class PresenceConditionValidator { ...@@ -724,7 +743,7 @@ public class PresenceConditionValidator {
"[NSD validation] DO " + name + " should not have an instance number in LNodeType (line " + lNodeType.getLineNumber() + ") with LNClass " + anyLNClassName, "[NSD validation] DO " + name + " should not have an instance number in LNodeType (line " + lNodeType.getLineNumber() + ") with LNClass " + anyLNClassName,
new Object[] { lNodeType } )); new Object[] { lNodeType } ));
res = false; res = false;
} }
} }
} }
...@@ -1051,7 +1070,7 @@ public class PresenceConditionValidator { ...@@ -1051,7 +1070,7 @@ public class PresenceConditionValidator {
.map( p -> p.getMixed() ) .map( p -> p.getMixed() )
.map( p -> p.get( 0 ) ) .map( p -> p.get( 0 ) )
.map( p -> p.getValue() ) .map( p -> p.getValue() )
.map( p -> p.toString() ) .map( p -> p.toString() )
.orElse( null ); .orElse( null );
diagnostics.add( new BasicDiagnostic( diagnostics.add( new BasicDiagnostic(
...@@ -1081,7 +1100,7 @@ public class PresenceConditionValidator { ...@@ -1081,7 +1100,7 @@ public class PresenceConditionValidator {
.map( p -> p.getMixed() ) .map( p -> p.getMixed() )
.map( p -> p.get( 0 ) ) .map( p -> p.get( 0 ) )
.map( p -> p.getValue() ) .map( p -> p.getValue() )
.map( p -> p.toString() ) .map( p -> p.toString() )
.orElse( null ); .orElse( null );
diagnostics.add( new BasicDiagnostic( diagnostics.add( new BasicDiagnostic(
...@@ -1111,7 +1130,7 @@ public class PresenceConditionValidator { ...@@ -1111,7 +1130,7 @@ public class PresenceConditionValidator {
.map( p -> p.getMixed() ) .map( p -> p.getMixed() )
.map( p -> p.get( 0 ) ) .map( p -> p.get( 0 ) )
.map( p -> p.getValue() ) .map( p -> p.getValue() )
.map( p -> p.toString() ) .map( p -> p.toString() )
.orElse( null ); .orElse( null );
diagnostics.add( new BasicDiagnostic( diagnostics.add( new BasicDiagnostic(
......
...@@ -18,29 +18,84 @@ ...@@ -18,29 +18,84 @@
*/ */
package fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.nsd; package fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.nsd;
import java.util.HashMap;
import org.eclipse.emf.common.util.DiagnosticChain; import org.eclipse.emf.common.util.DiagnosticChain;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.AnyLNClass; import fr.centralesupelec.edf.riseclipse.iec61850.nsd.AnyLNClass;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.CDC;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.DataObject;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.DO; import fr.centralesupelec.edf.riseclipse.iec61850.scl.DO;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.DOType;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.LNodeType; import fr.centralesupelec.edf.riseclipse.iec61850.scl.LNodeType;
import fr.centralesupelec.edf.riseclipse.util.AbstractRiseClipseConsole; import fr.centralesupelec.edf.riseclipse.util.AbstractRiseClipseConsole;
public class LNodeTypeValidator { public class LNodeTypeValidator {
private PresenceConditionValidator presenceConditionValidator; private DataObjectPresenceConditionValidator dataObjectPresenceConditionValidator;
private HashMap< String, DOTypeValidator > doTypeValidatorMap = new HashMap<>();
public LNodeTypeValidator( AnyLNClass lnClass ) { public LNodeTypeValidator( AnyLNClass anyLNClass ) {
presenceConditionValidator = PresenceConditionValidator.get( lnClass ); dataObjectPresenceConditionValidator = DataObjectPresenceConditionValidator.get( anyLNClass );
}
AnyLNClass lnClass = anyLNClass;
while( lnClass != null ) {
for( DataObject do_ : lnClass.getDataObject() ) {
CDC cdc = do_.getRefersToCDC();
if( cdc != null ) {
doTypeValidatorMap.put( do_.getName(), new DOTypeValidator( cdc ));
}
else {
AbstractRiseClipseConsole.getConsole().warning( "[NSD setup] CDC for DataObject " + do_.getName() + " not found" );
}
}
lnClass = lnClass.getRefersToAbstractLNClass();
}
}
public boolean validateLNodeType( LNodeType lNodeType, DiagnosticChain diagnostics ) { public boolean validateLNodeType( LNodeType lNodeType, DiagnosticChain diagnostics ) {
AbstractRiseClipseConsole.getConsole().verbose( "[NSD] validateLNodeType( " + lNodeType.getId() + " )" ); AbstractRiseClipseConsole.getConsole().verbose( "[NSD] validateLNodeType( " + lNodeType.getId() + " )" );
presenceConditionValidator.reset(); boolean res = true;
dataObjectPresenceConditionValidator.reset();
lNodeType
.getDO()
.stream()
.forEach( d -> dataObjectPresenceConditionValidator.addDO( d, diagnostics ));
res = res && dataObjectPresenceConditionValidator.validate( lNodeType, diagnostics );
for( DO do_ : lNodeType.getDO() ) { for( DO do_ : lNodeType.getDO() ) {
presenceConditionValidator.addDO( do_, diagnostics ); DOType doType = do_.getRefersToDOType();
if( doType != null ) {
String[] names;
if( do_.getName().matches( "[a-zA-Z]+\\d+" )) {
names = do_.getName().split( "(?=\\d)", 2 );
}
else {
names = new String[] { do_.getName() };
}
if( names.length == 0 ) {
// error should have been already displayed
//AbstractRiseClipseConsole.getConsole().error( "[NSD validation] Unexpected DO name " + do_.getName() + " in LNodeType (line " + do_.getParentLNodeType().getLineNumber() );
continue;
}
DOTypeValidator validator = doTypeValidatorMap.get( names[0] );
if( validator != null ) {
res = res && validator.validateDOType( doType, diagnostics );
}
else {
// This error will be detected in DataObjectPresenceConditionValidator.addDO() who will check if it is right if dataNs attribute is present
//AbstractRiseClipseConsole.getConsole().warning( "[NSD validation] while validating LNodeType (line " + lNodeType.getLineNumber() + "): validator for DO " + do_.getName() + " not found" );
}
}
else {
AbstractRiseClipseConsole.getConsole().warning( "[NSD validation] DOType for DO " + do_.getName() + " not found" );
}
} }
return presenceConditionValidator.validate( lNodeType, diagnostics ); return res;
} }
} }
...@@ -43,7 +43,7 @@ public class NsdEObjectValidator implements EValidator { ...@@ -43,7 +43,7 @@ public class NsdEObjectValidator implements EValidator {
private NsdResourceSetImpl nsdResourceSet; private NsdResourceSetImpl nsdResourceSet;
private HashMap< String, AnyLNValidator > anyLNValidatorMap = new HashMap<>(); private HashMap< String, AnyLNValidator > anyLNValidatorMap = new HashMap<>();
private HashMap<String,LNodeTypeValidator> lNodeTypeValidatorMap = new HashMap<>(); private HashMap< String, LNodeTypeValidator > lNodeTypeValidatorMap = new HashMap<>();
public NsdEObjectValidator( NsdResourceSetImpl nsdResourceSet ) { public NsdEObjectValidator( NsdResourceSetImpl nsdResourceSet ) {
this.nsdResourceSet = nsdResourceSet; this.nsdResourceSet = nsdResourceSet;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment