Search in sources :

Example 21 with ErrorSource

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

the class EMV2Util method getErrorModelElement.

/**
 * Get the error model element pointed to by the EMV2Path.
 * An error model element can be ErrorSource, ErrorSink, ErrorPath, ErrorPropagaiton, ErrorState,
 * ErrorBehaviorEvent (ErrorEvent, RecoverEvent, RepairEvent), ErrorBehaviorTransition
 * This works for condition elements (ConditionElement, SConditionElement)
 * @param epath EMV2Path
 * @return NamedElement
 */
public static NamedElement getErrorModelElement(EMV2Path epath) {
    if (epath == null) {
        return null;
    }
    EMV2PathElement target = getLast(epath.getEmv2Target());
    if (target.getNamedElement() instanceof ErrorTypes) {
        EObject prev = target.eContainer();
        if (prev instanceof EMV2PathElement) {
            target = (EMV2PathElement) prev;
        } else {
            return null;
        }
    }
    NamedElement prop = target.getNamedElement();
    if (prop != null) {
        return prop;
    }
    String kind = target.getEmv2PropagationKind();
    Classifier cxtcl = EMV2Util.getAssociatedClassifier(epath);
    if (target.eContainer() instanceof EMV2PathElement) {
        // should be a subcomponent reference
        NamedElement cxt = ((EMV2PathElement) target.eContainer()).getNamedElement();
        if (cxt instanceof Subcomponent) {
            cxtcl = ((Subcomponent) cxt).getAllClassifier();
        }
    } else {
        if (epath.getContainmentPath() != null) {
            ContainmentPathElement last = getLast(epath.getContainmentPath());
            if (last.getNamedElement() instanceof Subcomponent) {
                cxtcl = ((Subcomponent) last.getNamedElement()).getAllClassifier();
            }
        }
    }
    ErrorPropagation ep = findErrorPropagation(cxtcl, kind, DirectionType.IN);
    if (ep == null) {
        ep = findErrorPropagation(cxtcl, kind, DirectionType.OUT);
    }
    return ep;
}
Also used : EMV2PathElement(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement) EObject(org.eclipse.emf.ecore.EObject) Subcomponent(org.osate.aadl2.Subcomponent) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) ErrorTypes(org.osate.xtext.aadl2.errormodel.errorModel.ErrorTypes)

Example 22 with ErrorSource

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

the class EMV2Util method getAllConnectionErrorSources.

/**
 * return list of ConnectionErrorSource including those inherited from classifiers being extended
 * @param cl Classifier
 * @return Collection<ConnectionErrorSource> list of ConnectionErrorSource excluding duplicates
 */
public static Collection<ErrorSource> getAllConnectionErrorSources(Classifier cl) {
    HashMap<String, ErrorSource> result = new LinkedHashMap<>();
    EList<ErrorModelSubclause> emslist = getAllContainingClassifierEMV2Subclauses(cl);
    for (ErrorModelSubclause errorModelSubclause : emslist) {
        EList<ErrorSource> eflist = errorModelSubclause.getConnectionErrorSources();
        for (ErrorSource errorProp : eflist) {
            String epname = EMV2Util.getPrintName(errorProp);
            if (!result.containsKey(epname)) {
                result.put(epname, errorProp);
            }
        }
    }
    return result.values();
}
Also used : ErrorSource(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource) ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) LinkedHashMap(java.util.LinkedHashMap)

Example 23 with ErrorSource

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

the class ErrorModelValidator method checkFlowDirection.

private void checkFlowDirection(ErrorSource errorSource) {
    NamedElement ne = errorSource.getSourceModelElement();
    if (ne instanceof ErrorPropagation) {
        if (!Aadl2Util.isNull(ne) && ne instanceof ErrorPropagation) {
            ErrorPropagation ep = (ErrorPropagation) ne;
            DirectionType epd = ep.getDirection();
            if (!(epd.equals(DirectionType.OUT))) {
                error(errorSource, EMV2Util.getPrintName(ep) + " of error source is not an outgoing propagation point.");
            }
        }
    }
}
Also used : DirectionType(org.osate.aadl2.DirectionType) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement)

Example 24 with ErrorSource

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

the class EMV2Util method getAllErrorSinks.

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

Aggregations

ErrorSource (org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource)16 ErrorPropagation (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)13 TypeSet (org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)9 ErrorFlow (org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow)7 TypeToken (org.osate.xtext.aadl2.errormodel.errorModel.TypeToken)7 ErrorEvent (org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent)6 ErrorPath (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath)6 EObject (org.eclipse.emf.ecore.EObject)5 NamedElement (org.osate.aadl2.NamedElement)5 ErrorModelSubclause (org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause)5 LinkedHashMap (java.util.LinkedHashMap)4 ErrorBehaviorState (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState)4 ErrorSink (org.osate.xtext.aadl2.errormodel.errorModel.ErrorSink)4 Classifier (org.osate.aadl2.Classifier)3 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)3 PropagationPathEnd (org.osate.aadl2.errormodel.PropagationGraph.PropagationPathEnd)3 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)3 ConditionExpression (org.osate.xtext.aadl2.errormodel.errorModel.ConditionExpression)3 ErrorBehaviorTransition (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition)3 LinkedList (java.util.LinkedList)2