Search in sources :

Example 11 with ErrorPath

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

the class EMV2Util method findReverseErrorFlowFrom.

/**
 * find the error flow whose outgoing error propagation point is flowSource
 * @param eps List of error propagations
 * @param flowSource ErrorPropagation
 * @return ErrorFlow list
 */
public static EList<ErrorFlow> findReverseErrorFlowFrom(Collection<ErrorFlow> efs, ErrorPropagation flowSource) {
    EList<ErrorFlow> result = new BasicEList<ErrorFlow>();
    for (ErrorFlow ef : efs) {
        ErrorPropagation eprop = null;
        boolean isall = false;
        if (ef instanceof ErrorPath) {
            ErrorPath ep = (ErrorPath) ef;
            eprop = ep.getOutgoing();
            isall = ep.isAllOutgoing();
        } else if (ef instanceof ErrorSource && ((ErrorSource) ef).getSourceModelElement() instanceof ErrorPropagation) {
            ErrorSource es = (ErrorSource) ef;
            eprop = (ErrorPropagation) es.getSourceModelElement();
            isall = es.isAll();
        }
        if ((eprop != null && eprop == flowSource) || isall) {
            result.add(ef);
        }
    }
    return result;
}
Also used : ErrorSource(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource) ErrorFlow(org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow) BasicEList(org.eclipse.emf.common.util.BasicEList) ErrorPath(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)

Example 12 with ErrorPath

use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath 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 13 with ErrorPath

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

the class EMV2Util method findErrorFlowFromComponentInstance.

public static EList<ErrorFlow> findErrorFlowFromComponentInstance(ComponentInstance component, ErrorPropagation flowSource) {
    EList<ErrorFlow> result = new BasicEList<ErrorFlow>();
    Collection<ErrorFlow> efs = EMV2Util.getAllErrorFlows(component.getComponentClassifier());
    ErrorFlow toAdd;
    for (ErrorFlow ef : efs) {
        ErrorPropagation eprop = null;
        toAdd = ef;
        boolean isall = false;
        if (ef instanceof ErrorPath) {
            ErrorPath ep = (ErrorPath) ef;
            eprop = ep.getIncoming();
            isall = ep.isAllIncoming();
        } else if (ef instanceof ErrorSink) {
            ErrorSink es = (ErrorSink) ef;
            eprop = es.getIncoming();
            isall = es.isAllIncoming();
        }
        if ((eprop != null && eprop == flowSource) || isall) {
            result.add(toAdd);
        }
    }
    return result;
}
Also used : ErrorFlow(org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow) BasicEList(org.eclipse.emf.common.util.BasicEList) ErrorPath(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) ErrorSink(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSink)

Example 14 with ErrorPath

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

the class ErrorModelValidator method checkErrorPathTypes.

private void checkErrorPathTypes(ErrorPath ef) {
    ErrorPropagation epin = ef.getIncoming();
    ErrorPropagation epout = ef.getOutgoing();
    if (ef.getTypeTokenConstraint() != null) {
        // in prop
        if (epin != null) {
            if (!EMV2TypeSetUtil.contains(epin.getTypeSet(), ef.getTypeTokenConstraint())) {
                error(ef, "Type token constraint is not contained in type set of incoming propagation " + EMV2Util.getPrintName(epin));
            }
        } else {
            // check containment for all of the incoming propagation points
            Classifier cl = ef.getContainingClassifier();
            Collection<ErrorPropagation> eps = EMV2Util.getAllIncomingErrorPropagations(cl);
            for (ErrorPropagation errorPropagation : eps) {
                if (!EMV2TypeSetUtil.contains(errorPropagation.getTypeSet(), ef.getTypeTokenConstraint())) {
                    error(ef, "Type token constraint is not contained in type set of incoming propagation " + EMV2Util.getPrintName(errorPropagation));
                }
            }
        }
    }
    if (ef.getTargetToken() != null) {
        // check that outoging flow type token is contained in that of prop
        if (epout != null) {
            if (!EMV2TypeSetUtil.contains(epout.getTypeSet(), ef.getTargetToken())) {
                error(ef, "Target token is not contained in type set of outgoing propagation " + EMV2Util.getPrintName(epout));
            }
        } else {
            // check containment for all of the outgoing propagation points
            Classifier cl = ef.getContainingClassifier();
            Collection<ErrorPropagation> eps = EMV2Util.getAllOutgoingErrorPropagations(cl);
            for (ErrorPropagation errorPropagation : eps) {
                if (!EMV2TypeSetUtil.contains(errorPropagation.getTypeSet(), ef.getTargetToken())) {
                    error(ef, "Target token is not contained in type set of outgoing propagation " + EMV2Util.getPrintName(errorPropagation));
                }
            }
        }
        // ensures only one error type is associated with the target error type
        TypeSet ts = ef.getTargetToken();
        if (ts.getTypeTokens().size() > 1) {
            error(ef, "Outgoing propagation may only have a single error type");
        }
        TypeToken tt = ts.getTypeTokens().get(0);
        if (tt != null && tt.getType() != null && !(tt.getType().get(0) instanceof ErrorType)) {
            error(ef, "Outgoing propagation may only have a single error type");
        }
    } else {
        // no outgoing path type token
        if (ef.getTypeTokenConstraint() != null) {
            // match the incoming path constraint
            if (epout != null) {
                // need to handle use mappings
                if (!EMV2TypeSetUtil.contains(epout.getTypeSet(), ef.getTypeTokenConstraint())) {
                    error(ef, "Incoming path type constraint is not contained in type set of outgoing propagation " + EMV2Util.getPrintName(epout));
                }
            } else {
                // check containment for all of the outgoing propagation
                // points
                Classifier cl = ef.getContainingClassifier();
                Collection<ErrorPropagation> eps = EMV2Util.getAllOutgoingErrorPropagations(cl);
                for (ErrorPropagation errorPropagation : eps) {
                    if (!EMV2TypeSetUtil.contains(errorPropagation.getTypeSet(), ef.getTypeTokenConstraint())) {
                        error(ef, "Incoming path type constraint is not contained in type set of outgoing propagation " + EMV2Util.getPrintName(errorPropagation));
                    }
                }
            }
        } else {
            // check in to out type set of propagations for the flow
            if (epout != null && epin != null) {
                if (!EMV2TypeSetUtil.contains(epout.getTypeSet(), epin.getTypeSet())) {
                    error(ef, "Incoming error propagation " + EMV2Util.getPrintName(epin) + " constraint is not contained in type set of outgoing propagation " + EMV2Util.getPrintName(epout));
                }
            } else if (epout == null && epin != null) {
                // check containment for all of the outgoing propagation
                // points against one incoming
                Classifier cl = ef.getContainingClassifier();
                Collection<ErrorPropagation> eps = EMV2Util.getAllOutgoingErrorPropagations(cl);
                for (ErrorPropagation allepout : eps) {
                    if (!EMV2TypeSetUtil.contains(allepout.getTypeSet(), epin.getTypeSet())) {
                        error(ef, "Incoming error propagation " + EMV2Util.getPrintName(epin) + " constraint is not contained in type set of outgoing propagation " + EMV2Util.getPrintName(allepout));
                    }
                }
            } else if (epout != null && epin == null) {
                // check containment for all of the outgoing propagation
                // points against one incoming
                Classifier cl = ef.getContainingClassifier();
                Collection<ErrorPropagation> eps = EMV2Util.getAllIncomingErrorPropagations(cl);
                for (ErrorPropagation errorPropagation : eps) {
                    if (!EMV2TypeSetUtil.contains(epout.getTypeSet(), errorPropagation.getTypeSet())) {
                        error(ef, "Incoming error propagation " + EMV2Util.getPrintName(errorPropagation) + " constraint is not contained in type set of outgoing propagation " + EMV2Util.getPrintName(epout));
                    }
                }
            } else if (epout == null && epin == null) {
                // check containment for all of the outgoing propagation
                // points against one incoming
                Classifier cl = ef.getContainingClassifier();
                Collection<ErrorPropagation> epsin = EMV2Util.getAllIncomingErrorPropagations(cl);
                Collection<ErrorPropagation> epsout = EMV2Util.getAllOutgoingErrorPropagations(cl);
                for (ErrorPropagation allepout : epsout) {
                    for (ErrorPropagation allepin : epsin) {
                        if (!EMV2TypeSetUtil.contains(allepout.getTypeSet(), allepin.getTypeSet())) {
                            error(ef, "Incoming error propagation " + EMV2Util.getPrintName(allepin) + " constraint is not contained in type set of outgoing propagation " + EMV2Util.getPrintName(allepout));
                        }
                    }
                }
            }
        }
    }
}
Also used : ErrorType(org.osate.xtext.aadl2.errormodel.errorModel.ErrorType) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) Collection(java.util.Collection) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) Classifier(org.osate.aadl2.Classifier)

Example 15 with ErrorPath

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

the class ErrorModelValidator method checkFlowDirection.

private void checkFlowDirection(ErrorPath errorPath) {
    ErrorPropagation ep = errorPath.getIncoming();
    if (!Aadl2Util.isNull(ep)) {
        DirectionType epd = ep.getDirection();
        if (!(epd.equals(DirectionType.IN))) {
            error(errorPath, "Source " + EMV2Util.getPrintName(ep) + " of error path is not an incoming propagation point.");
        }
    }
    ep = errorPath.getOutgoing();
    if (!Aadl2Util.isNull(ep)) {
        DirectionType epd = ep.getDirection();
        if (!(epd.equals(DirectionType.OUT))) {
            error(errorPath, "Target " + EMV2Util.getPrintName(ep) + " of error path is not an outgoing propagation point.");
        }
    }
}
Also used : DirectionType(org.osate.aadl2.DirectionType) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)

Aggregations

ErrorPath (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath)11 ErrorPropagation (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)10 ErrorFlow (org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow)8 ErrorSink (org.osate.xtext.aadl2.errormodel.errorModel.ErrorSink)6 ErrorSource (org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource)5 TypeSet (org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)5 TypeToken (org.osate.xtext.aadl2.errormodel.errorModel.TypeToken)5 Collection (java.util.Collection)3 BasicEList (org.eclipse.emf.common.util.BasicEList)3 Classifier (org.osate.aadl2.Classifier)3 Optional (java.util.Optional)2 EObject (org.eclipse.emf.ecore.EObject)2 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)2 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)2 DirectionType (org.osate.aadl2.DirectionType)2 NamedElement (org.osate.aadl2.NamedElement)2 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)2 Graphic (org.osate.ge.graphics.Graphic)2 StyleBuilder (org.osate.ge.graphics.StyleBuilder)2 EMV2PathElement (org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement)2