Search in sources :

Example 1 with ErrorSource

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

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

the class EMV2Util method findConnectionErrorSourceForConnection.

/**
 * Find ConnectionErrorSource with given classifier by looking through all connection error sources
 * @param conni the connection instance whose connection declarations we're using
 * @return the connection error source or null
 */
public static ErrorSource findConnectionErrorSourceForConnection(ConnectionInstance conni) {
    for (ConnectionReference connref : conni.getConnectionReferences()) {
        Connection conn = connref.getConnection();
        Classifier cl = getAssociatedClassifier(conn);
        if (cl != null) {
            Collection<ErrorSource> ceslist = getAllConnectionErrorSources(cl);
            for (ErrorSource ces : ceslist) {
                if (ces.isAll() || ces.getSourceModelElement().getName().equalsIgnoreCase(conn.getName())) {
                    return ces;
                }
            }
        }
    }
    return null;
}
Also used : ErrorSource(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource) ConnectionReference(org.osate.aadl2.instance.ConnectionReference) Connection(org.osate.aadl2.Connection) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier)

Example 3 with ErrorSource

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

the class PropagateErrorSources method startConnectionSourceFlows.

/**
 * Start with the source of a connection instance
 * @param ci component instance
 */
public void startConnectionSourceFlows(ComponentInstance root) {
    Collection<ErrorSource> ceslist = EMV2Util.getAllConnectionErrorSources(root.getComponentClassifier());
    if (ceslist.isEmpty()) {
        return;
    }
    for (ErrorSource ces : ceslist) {
        if (!Util.conditionHolds(ces, root)) {
            continue;
        }
        EMSUtil.unsetAll(root.getSystemInstance());
        // find connection instances that this connection is part of
        String connName = ces.getSourceModelElement().getName();
        ConnectionInstance conni = InstanceUtil.findConnectionInstance(root, (Connection) ces.getSourceModelElement());
        EList<PropagationPathEnd> ends = Util.getAllPropagationDestinationEnds(faultModel, conni);
        if (ends.size() == 0) {
            return;
        }
        PropagationPathEnd ppe = ends.get(0);
        ErrorPropagation destEP = ppe.getErrorPropagation();
        ComponentInstance destci = ppe.getComponentInstance();
        TypeSet fmType = ces.getFailureModeType();
        String failuremodeDesc = ces.getFailureModeDescription();
        TypeSet tsep = ces.getTypeTokenConstraint();
        EList<TypeToken> result = tsep.getTypeTokens();
        // XXX use this if we want all leaf types: EM2TypeSetUtil.generateAllLeafTypeTokens(tsep,EMV2Util.getContainingTypeUseContext(errorSource));
        for (TypeToken typeToken : result) {
            String failuremodeText;
            if (failuremodeDesc == null) {
                failuremodeText = generateOriginalFailureModeText(fmType != null ? fmType : typeToken);
            } else {
                failuremodeText = failuremodeDesc;
            }
            String effectText = generateOriginalFailureModeText(typeToken);
            String connText = generateComponentPropagationPointText(destci, destEP);
            traceErrorFlows(destci, destEP, typeToken, 0, "Connection " + connName + "," + failuremodeText + "," + effectText + " -> " + connText);
        }
    }
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) ErrorSource(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) PropagationPathEnd(org.osate.aadl2.errormodel.PropagationGraph.PropagationPathEnd) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)

Example 4 with ErrorSource

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

the class PropagateErrorSources method startExternalFlows.

/**
 * Start with an external incoming error propagation as source
 * @param ci component instance
 */
public void startExternalFlows(ComponentInstance root) {
    Collection<ErrorPropagation> eplist = EMV2Util.getAllIncomingErrorPropagations(root.getComponentClassifier());
    String componentText = generateComponentInstanceText(root);
    if (eplist.isEmpty()) {
        return;
    }
    reportExternalImpactHeading();
    reportExternalTableHeading();
    for (ErrorPropagation ep : eplist) {
        EMSUtil.unsetAll(root);
        TypeSet tsep = ep.getTypeSet();
        if (tsep != null) {
            EList<TypeToken> result = tsep.getTypeTokens();
            // XXX use this if we want all leaf types: EM2TypeSetUtil.generateAllLeafTypeTokens(tsep,EMV2Util.getContainingTypeUseContext(errorSource));
            for (TypeToken typeToken : result) {
                String failuremodeText = generateErrorPropTypeTokenText(ep, typeToken);
                traceErrorPaths(root, ep, typeToken, 2, componentText + ", " + failuremodeText);
            }
        }
    }
}
Also used : TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)

Example 5 with ErrorSource

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

the class FHAReport method processHazards.

protected void processHazards(ComponentInstance ci, WriteToFile report) {
    for (ErrorBehaviorTransition trans : EMV2Util.getAllErrorBehaviorTransitions(ci.getComponentClassifier())) {
        ConditionExpression cond = trans.getCondition();
        if (cond instanceof ConditionElement) {
            ConditionElement condElement = (ConditionElement) trans.getCondition();
            EventOrPropagation eop = EMV2Util.getErrorEventOrPropagation(condElement);
            if (eop instanceof ErrorEvent) {
                ErrorEvent errorEvent = (ErrorEvent) eop;
                List<EMV2PropertyAssociation> PA = getHazardsPropertyInCurrentFormat(ci, errorEvent, errorEvent.getTypeSet());
                List<EMV2PropertyAssociation> Sev = EMV2Properties.getSeverityProperty(ci, errorEvent, errorEvent.getTypeSet());
                List<EMV2PropertyAssociation> Like = EMV2Properties.getLikelihoodProperty(ci, errorEvent, errorEvent.getTypeSet());
                reportHazardProperty(ci, PA, Sev, Like, errorEvent, errorEvent.getTypeSet(), errorEvent, report);
            }
        // condElement.getIncoming()
        }
    }
    for (ErrorBehaviorState state : EMV2Util.getAllErrorBehaviorStates(ci)) {
        List<EMV2PropertyAssociation> PA = getHazardsPropertyInCurrentFormat(ci, state, state.getTypeSet());
        List<EMV2PropertyAssociation> Sev = EMV2Properties.getSeverityProperty(ci, state, state.getTypeSet());
        List<EMV2PropertyAssociation> Like = EMV2Properties.getLikelihoodProperty(ci, state, state.getTypeSet());
        reportHazardProperty(ci, PA, Sev, Like, state, state.getTypeSet(), state, report);
    }
    // report all error sources as hazards if they have the property
    Collection<ErrorSource> eslist = EMV2Util.getAllErrorSources(ci.getComponentClassifier());
    Collection<ErrorPropagation> oeplist = EMV2Util.getAllOutgoingErrorPropagations(ci.getComponentClassifier());
    for (ErrorSource errorSource : eslist) {
        NamedElement ne = errorSource.getSourceModelElement();
        ErrorBehaviorState failureMode = errorSource.getFailureModeReference();
        List<EMV2PropertyAssociation> HazardPA = Collections.emptyList();
        List<EMV2PropertyAssociation> Sev = Collections.emptyList();
        List<EMV2PropertyAssociation> Like = Collections.emptyList();
        TypeSet ts = null;
        NamedElement target = null;
        Element localContext = null;
        // not dealing with type set as failure mode
        if (failureMode != null) {
            // state is originating hazard, possibly with a type set
            ts = failureMode.getTypeSet();
            // error source a local context
            HazardPA = getHazardsPropertyInCurrentFormat(ci, failureMode, ts);
            Sev = EMV2Properties.getSeverityProperty(ci, failureMode, ts);
            Like = EMV2Properties.getLikelihoodProperty(ci, failureMode, ts);
            target = failureMode;
            localContext = errorSource;
        }
        if (HazardPA.isEmpty()) {
            // error source is originating hazard
            ts = errorSource.getTypeTokenConstraint();
            if (ts == null && ne instanceof ErrorPropagation) {
                ts = ((ErrorPropagation) ne).getTypeSet();
            }
            HazardPA = getHazardsPropertyInCurrentFormat(ci, errorSource, ts);
            Sev = EMV2Properties.getSeverityProperty(ci, errorSource, ts);
            Like = EMV2Properties.getLikelihoodProperty(ci, errorSource, ts);
            target = errorSource;
            localContext = null;
            if (HazardPA.isEmpty() && errorSource.getFailureModeType() != null) {
                ts = errorSource.getFailureModeType();
                HazardPA = getHazardsPropertyInCurrentFormat(ci, errorSource, ts);
                Sev = EMV2Properties.getSeverityProperty(ci, errorSource, ts);
                Like = EMV2Properties.getLikelihoodProperty(ci, errorSource, ts);
            }
        }
        if (!HazardPA.isEmpty()) {
            reportHazardProperty(ci, HazardPA, Sev, Like, target, ts, localContext, report);
        }
    }
    for (ErrorPropagation ep : oeplist) {
        TypeSet ts = null;
        NamedElement target = null;
        Element localContext = null;
        // error propagation is originating hazard
        ts = ep.getTypeSet();
        List<EMV2PropertyAssociation> HazardPA = getHazardsPropertyInCurrentFormat(ci, ep, ts);
        List<EMV2PropertyAssociation> Sev = EMV2Properties.getSeverityProperty(ci, ep, ts);
        List<EMV2PropertyAssociation> Like = EMV2Properties.getLikelihoodProperty(ci, ep, ts);
        target = ep;
        localContext = null;
        // XXX we may have more than one matching hazard
        if (!HazardPA.isEmpty()) {
            reportHazardProperty(ci, HazardPA, Sev, Like, target, ts, localContext, report);
        }
    }
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) Element(org.osate.aadl2.Element) ConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement) NamedElement(org.osate.aadl2.NamedElement) EMV2PropertyAssociation(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation) EventOrPropagation(org.osate.xtext.aadl2.errormodel.errorModel.EventOrPropagation) ConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement) ErrorBehaviorTransition(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition) ErrorSource(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource) ConditionExpression(org.osate.xtext.aadl2.errormodel.errorModel.ConditionExpression) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) NamedElement(org.osate.aadl2.NamedElement)

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