Search in sources :

Example 1 with ErrorModelSubclause

use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause in project osate2 by osate.

the class ErrorModelValidator method caseErrorModelSubclause.

@Check(CheckType.FAST)
public void caseErrorModelSubclause(ErrorModelSubclause subclause) {
    if (EcoreUtil2.getContainerOfType(subclause, FeatureGroupType.class) != null) {
        error("Error model subclauses are not permitted in feature group types.", EcoreUtil2.getContainerOfType(subclause, DefaultAnnexSubclause.class), Aadl2Package.eINSTANCE.getNamedElement_Name());
        return;
    }
    checkSubclauseAssociationToClassifier(subclause);
    checkDuplicateSubclause(subclause);
    checkOnePropagationAndContainmentPoint(subclause);
    Collection<NamedElement> names = EMV2Util.getAllNamedElements(subclause);
    List<NamedElement> doubles = EMV2Util.findDoubleNamedElementsInList(names);
    for (NamedElement namedElement : doubles) {
        if (!(namedElement instanceof ErrorPropagation)) {
            error(namedElement, "Subclause has more than one element with the name '" + namedElement.getName() + "'.");
        }
    }
    Collection<ErrorPropagation> ins = EMV2Util.getAllIncomingErrorPropagations(subclause.getContainingClassifier());
    for (ErrorPropagation errorPropagation : ins) {
        checkTypePropagationAndContainment(errorPropagation);
    }
    Collection<ErrorPropagation> outs = EMV2Util.getAllOutgoingErrorPropagations(subclause.getContainingClassifier());
    for (ErrorPropagation errorPropagation : outs) {
        checkTypePropagationAndContainment(errorPropagation);
    }
    checkUseBehavior(subclause);
}
Also used : FeatureGroupType(org.osate.aadl2.FeatureGroupType) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) DefaultAnnexSubclause(org.osate.aadl2.DefaultAnnexSubclause) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) Check(org.eclipse.xtext.validation.Check)

Example 2 with ErrorModelSubclause

use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause in project osate2 by osate.

the class ErrorModelValidator method checkOnePropagationAndContainmentPoint.

private void checkOnePropagationAndContainmentPoint(ErrorModelSubclause ems) {
    EList<ErrorPropagation> eps = ems.getPropagations();
    int epssize = eps.size();
    for (int i = 0; i < epssize - 1; i++) {
        ErrorPropagation ep1 = eps.get(i);
        for (int k = i + 1; k < epssize; k++) {
            ErrorPropagation ep2 = eps.get(k);
            if (EMV2Util.getPrintName(ep1).equalsIgnoreCase(EMV2Util.getPrintName(ep2))) {
                // uniqueness needs to take into account direction
                if (((ep1.isNot() && ep2.isNot()) || (!ep1.isNot() && !ep2.isNot())) && ep1.getDirection() == ep2.getDirection()) {
                    error(ep2, (ep1.isNot() ? "Error containment " : "Error propagation ") + EMV2Util.getPrintName(ep2) + " can only be declared once [E.7.1 (L1)].");
                }
            }
        }
    }
}
Also used : ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) PropagationPoint(org.osate.xtext.aadl2.errormodel.errorModel.PropagationPoint)

Example 3 with ErrorModelSubclause

use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause in project osate2 by osate.

the class EMV2Util method getAllErrorPaths.

/**
 * return list of error paths including those inherited from classifiers being extended
 * @param cl Classifier
 * @return Collection<ErrorSource> list of error paths declared in the flow section
 */
public static Collection<ErrorPath> getAllErrorPaths(Classifier cl) {
    HashMap<String, ErrorPath> result = new LinkedHashMap<>();
    EList<ErrorModelSubclause> emslist = getAllContainingClassifierEMV2Subclauses(cl);
    for (ErrorModelSubclause errorModelSubclause : emslist) {
        EList<ErrorFlow> eflist = errorModelSubclause.getFlows();
        for (ErrorFlow errorFlow : eflist) {
            if (errorFlow instanceof ErrorPath) {
                if (!result.containsKey(errorFlow.getName())) {
                    result.put(errorFlow.getName(), (ErrorPath) errorFlow);
                }
            }
        }
    }
    return result.values();
}
Also used : ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) ErrorFlow(org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow) ErrorPath(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with ErrorModelSubclause

use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause in project osate2 by osate.

the class EMV2Util method getAllCompositeStates.

/**
 * return list of CompositeState including those inherited from classifiers being extended
 * @param cl Classifier
 * @param unnamed Collection of unnamed CompositeState
 * @return Collection<CompositeState> list of CompositeState as HashMap for quick lookup of names
 */
private static HashMap<String, CompositeState> getAllCompositeStates(Classifier cl, Collection<CompositeState> unnamed) {
    HashMap<String, CompositeState> result = new LinkedHashMap<>();
    EList<ErrorModelSubclause> emslist = getAllContainingClassifierEMV2Subclauses(cl);
    for (ErrorModelSubclause errorModelSubclause : emslist) {
        EList<CompositeState> eslist = errorModelSubclause.getStates();
        for (CompositeState es : eslist) {
            if (es.getName() == null) {
                unnamed.add(es);
            } else {
                if (!result.containsKey(es.getName())) {
                    result.put(es.getName(), es);
                }
            }
        }
    }
    return result;
}
Also used : ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) CompositeState(org.osate.xtext.aadl2.errormodel.errorModel.CompositeState) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with ErrorModelSubclause

use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause in project osate2 by osate.

the class EMV2Util method getAllPropagationPaths.

/**
 * return list of PropagationPaths including those inherited from classifiers being extended
 * @param cl Classifier
 * @return Collection<PropagationPath> list of PropagationPaths as HashMap for quick lookup of names
 */
public static Collection<PropagationPath> getAllPropagationPaths(Classifier cl) {
    HashMap<String, PropagationPath> result = new LinkedHashMap<>();
    EList<ErrorModelSubclause> emslist = getAllContainingClassifierEMV2Subclauses(cl);
    for (ErrorModelSubclause errorModelSubclause : emslist) {
        EList<PropagationPath> eflist = errorModelSubclause.getPaths();
        for (PropagationPath propPointConn : eflist) {
            if (!result.containsKey(propPointConn.getName())) {
                result.put(propPointConn.getName(), propPointConn);
            }
        }
    }
    return result.values();
}
Also used : PropagationPath(org.osate.xtext.aadl2.errormodel.errorModel.PropagationPath) ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ErrorModelSubclause (org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause)32 LinkedHashMap (java.util.LinkedHashMap)15 Classifier (org.osate.aadl2.Classifier)9 ErrorBehaviorStateMachine (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorStateMachine)7 NamedElement (org.osate.aadl2.NamedElement)6 ErrorPropagation (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)5 URI (org.eclipse.emf.common.util.URI)4 ComponentClassifier (org.osate.aadl2.ComponentClassifier)4 ComponentImplementation (org.osate.aadl2.ComponentImplementation)4 EObject (org.eclipse.emf.ecore.EObject)3 AadlPackage (org.osate.aadl2.AadlPackage)3 ComponentType (org.osate.aadl2.ComponentType)3 Subcomponent (org.osate.aadl2.Subcomponent)3 AadlGraphicalEditorException (org.osate.ge.aadl2.AadlGraphicalEditorException)3 EMV2PropertyAssociation (org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation)3 ErrorFlow (org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow)3 List (java.util.List)2 Optional (java.util.Optional)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)2 ErrorModelLibrary (org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary)2