Search in sources :

Example 11 with PropagationPathEnd

use of org.osate.aadl2.errormodel.PropagationGraph.PropagationPathEnd in project osate2 by osate.

the class Util method addPropagationpathRecord.

private static void addPropagationpathRecord(PropagationGraph pg, ComponentInstance srcCI, ErrorPropagation srcprop, ComponentInstance dstCI, ErrorPropagation dstprop) {
    if (!existsPropagationPath(pg, srcCI, srcprop, dstCI, dstprop)) {
        PropagationGraphPath path = PropagationGraphFactory.eINSTANCE.createPropagationGraphPath();
        PropagationPathEnd srcPE = PropagationGraphFactory.eINSTANCE.createPropagationPathEnd();
        PropagationPathEnd dstPE = PropagationGraphFactory.eINSTANCE.createPropagationPathEnd();
        srcPE.setComponentInstance(srcCI);
        srcPE.setErrorPropagation(srcprop);
        dstPE.setComponentInstance(dstCI);
        dstPE.setErrorPropagation(dstprop);
        path.setPathSrc(srcPE);
        path.setPathDst(dstPE);
        pg.getPropagationGraphPaths().add(path);
        pg.getComponents().add(srcCI);
        pg.getComponents().add(dstCI);
    }
}
Also used : PropagationPathEnd(org.osate.aadl2.errormodel.PropagationGraph.PropagationPathEnd) PropagationGraphPath(org.osate.aadl2.errormodel.PropagationGraph.PropagationGraphPath)

Example 12 with PropagationPathEnd

use of org.osate.aadl2.errormodel.PropagationGraph.PropagationPathEnd in project osate2 by osate.

the class PropagateErrorSources method traceErrorPaths.

/**
 * traverse to the destination of the propagation path
 * @param conni
 */
protected void traceErrorPaths(ComponentInstance ci, ErrorPropagation ep, TypeToken tt, int depth, String entryText) {
    ErrorModelState st = null;
    FeatureInstance fi = EMV2Util.findFeatureInstance(ep, ci);
    if (fi != null) {
        st = (ErrorModelState) ErrorModelStateAdapterFactory.INSTANCE.adapt(fi, ErrorModelState.class);
    } else {
        st = (ErrorModelState) ErrorModelStateAdapterFactory.INSTANCE.adapt(ci, ErrorModelState.class);
    }
    if (st.visited(ep, tt)) {
        // we were there before.
        String effectText = "," + generateTypeTokenErrorPropText(ep, tt);
        reportEntry(entryText + effectText + " -> [Propagation Cycle],,", depth);
        return;
    } else {
        st.setVisitToken(ep, tt);
    }
    EList<PropagationGraphPath> paths = Util.getAllPropagationPaths(faultModel, ci, ep);
    String effectText = "," + generateTypeTokenErrorPropText(ep, tt);
    if (paths.isEmpty()) {
        if (fi != null) {
            EList<ConnectionInstance> conns = fi.getSrcConnectionInstances();
            if (conns.isEmpty()) {
                reportEntry(entryText + effectText + " -> [No Outgoing Connection],,", depth);
            } else {
                for (ConnectionInstance connectionInstance : conns) {
                    reportEntry(entryText + "," + (tt != null ? EMV2Util.getPrintName(tt) + " " : "") + connectionInstance.getName() + "[No In Propagation],,", depth);
                }
            }
        } else if (EMV2Util.getPropagationPoint(ep) != null) {
            reportEntry(entryText + effectText + " -> [No Propagation Point Connection],,", depth);
        } else if (ep.getKind() != null) {
            reportEntry(entryText + effectText + " -> [No Binding],,", depth);
        } else {
            reportEntry(entryText + effectText + " -> [Could not find propagation feature],,", depth);
        }
    } else {
        for (PropagationGraphPath path : paths) {
            ConnectionInstance pathConni = path.getConnection();
            TypeMappingSet typeEquivalence = EMV2Util.getAllTypeEquivalenceMapping(ci.getContainingComponentInstance());
            TypeToken mappedtt = tt;
            TypeToken resulttt = tt;
            TypeToken xformedtt = tt;
            if (typeEquivalence != null) {
                mappedtt = EMV2TypeSetUtil.mapTypeToken(tt, typeEquivalence);
                if (mappedtt != null) {
                    resulttt = mappedtt;
                }
            }
            if (pathConni != null) {
                // find the connection transformation rules if we have a connection path
                ComponentInstance contextCI = pathConni.getComponentInstance();
                TypeTransformationSet tts = EMV2Util.getAllTypeTransformationSet(contextCI);
                // TODO find contributor type token by looking for the state/out prop type.
                if (tts != null) {
                    xformedtt = EMV2TypeSetUtil.mapTypeToken(tt, null, tts);
                    if (xformedtt == null && mappedtt != null) {
                        xformedtt = EMV2TypeSetUtil.mapTypeToken(mappedtt, null, tts);
                    }
                    if (xformedtt != null) {
                        resulttt = xformedtt;
                    }
                }
            }
            EList<PropagationPathEnd> dstEnds;
            ConnectionInstance dstConni = path.getPathDst().getConnectionInstance();
            String connSymbol = " -> ";
            if (dstConni != null) {
                // we have a connection binding path with a connection instance as target
                dstEnds = Util.getAllPropagationDestinationEnds(faultModel, dstConni);
                connSymbol = " -Conn-> ";
                // find the connection transformation rules
                ComponentInstance contextCI = dstConni.getComponentInstance();
                TypeTransformationSet tts = EMV2Util.getAllTypeTransformationSet(contextCI);
                // TODO find source type token by looking for the state/out prop type.
                if (tts != null) {
                    xformedtt = EMV2TypeSetUtil.mapTypeToken(null, tt, tts);
                    if (xformedtt == null && mappedtt != null) {
                        xformedtt = EMV2TypeSetUtil.mapTypeToken(null, mappedtt, tts);
                    }
                    if (xformedtt != null) {
                        resulttt = xformedtt;
                    }
                }
            } else {
                dstEnds = new BasicEList<PropagationPathEnd>();
                dstEnds.add(path.getPathDst());
            }
            for (PropagationPathEnd propagationPathEnd : dstEnds) {
                ComponentInstance destci = propagationPathEnd.getComponentInstance();
                ErrorPropagation destEP = propagationPathEnd.getErrorPropagation();
                if (destEP != null) {
                    TypeSet dstTS = destEP.getTypeSet();
                    TypeToken targettt = null;
                    if (tt != null && EMV2TypeSetUtil.contains(dstTS, tt)) {
                        targettt = tt;
                    } else if (mappedtt != null && EMV2TypeSetUtil.contains(dstTS, mappedtt)) {
                        targettt = mappedtt;
                    } else if (xformedtt != null && EMV2TypeSetUtil.contains(dstTS, xformedtt)) {
                        targettt = xformedtt;
                    }
                    if (targettt == null) {
                        // type token or mapped/xformed type token is not contained in incoming EP
                        String connText = connSymbol + generateComponentPropagationPointTypeTokenText(destci, destEP, resulttt) + " [Unhandled Type]";
                        reportEntry(entryText + effectText + connText, depth);
                    } else if (destci instanceof SystemInstance) {
                        // we have an external propagation (out only connection)
                        String connText = connSymbol + generateComponentPropagationPointText(destci, destEP) + " [External Effect]";
                        reportEntry(entryText + effectText + connText, depth);
                    } else if (pathConni != null && Aadl2InstanceUtil.outOnly(pathConni) && !pathConni.isComplete()) {
                        // outgoing only, but not ending at root
                        String connText = connSymbol + generateComponentPropagationPointText(destci, destEP) + " [External Effect]";
                        reportEntry(entryText + effectText + connText, depth);
                    } else if (destci != null) {
                        String connText = connSymbol + generateComponentPropagationPointText(destci, destEP);
                        traceErrorFlows(destci, destEP, targettt, depth, entryText + effectText + connText);
                    }
                }
            }
        }
    }
    st.removeVisitedToken(ep, tt);
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) PropagationPathEnd(org.osate.aadl2.errormodel.PropagationGraph.PropagationPathEnd) PropagationGraphPath(org.osate.aadl2.errormodel.PropagationGraph.PropagationGraphPath) ErrorModelState(org.osate.xtext.aadl2.errormodel.util.ErrorModelState) TypeTransformationSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeTransformationSet) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) SystemInstance(org.osate.aadl2.instance.SystemInstance) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) TypeMappingSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeMappingSet) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)

Example 13 with PropagationPathEnd

use of org.osate.aadl2.errormodel.PropagationGraph.PropagationPathEnd in project osate2 by osate.

the class AnalysisModel method getAllPropagationPaths.

/**
 * return all propagation paths out of the outgoing error propagation we
 * assume that any type token to be propagated meets the ep type constraint
 *
 * @param ci
 * @param outEP
 * @return
 */
public EList<PropagationPathRecord> getAllPropagationPaths(ComponentInstance ci, ErrorPropagation outEP) {
    EList<PropagationPathRecord> result = new BasicEList<PropagationPathRecord>();
    for (PropagationPathRecord propagationPathRecord : propagationPaths) {
        PropagationPathEnd src = propagationPathRecord.getPathSrc();
        if (src.getComponentInstance() == ci) {
            if (src.getErrorPropagation() == outEP) {
                result.add(propagationPathRecord);
            } else {
                // check if one EP is in an ancestor feature instance
                FeatureInstance outepfi = EMV2Util.findFeatureInstance(outEP, ci);
                FeatureInstance srcfi = EMV2Util.findFeatureInstance(src.getErrorPropagation(), ci);
                if (Aadl2InstanceUtil.containedIn(outepfi, srcfi) || Aadl2InstanceUtil.containedIn(srcfi, outepfi)) {
                    result.add(propagationPathRecord);
                }
            }
        }
    }
    return result;
}
Also used : FeatureInstance(org.osate.aadl2.instance.FeatureInstance) BasicEList(org.eclipse.emf.common.util.BasicEList)

Aggregations

PropagationPathEnd (org.osate.aadl2.errormodel.PropagationGraph.PropagationPathEnd)9 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)6 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)6 ErrorPropagation (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)6 PropagationGraphPath (org.osate.aadl2.errormodel.PropagationGraph.PropagationGraphPath)5 TypeSet (org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)4 TypeToken (org.osate.xtext.aadl2.errormodel.errorModel.TypeToken)4 BasicEList (org.eclipse.emf.common.util.BasicEList)3 ErrorSource (org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource)3 ErrorModelState (org.osate.xtext.aadl2.errormodel.util.ErrorModelState)3 LinkedList (java.util.LinkedList)2 EObject (org.eclipse.emf.ecore.EObject)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 NamedElement (org.osate.aadl2.NamedElement)2 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)2 TypeTransformationSet (org.osate.xtext.aadl2.errormodel.errorModel.TypeTransformationSet)2 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1