Search in sources :

Example 1 with EventOrPropagation

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

the class ErrorModelValidator method checkConditionElementType.

private void checkConditionElementType(ConditionElement conditionElement) {
    EventOrPropagation ep = EMV2Util.getErrorEventOrPropagation(conditionElement);
    if (ep == null) {
        return;
    }
    TypeSet triggerTS = null;
    String triggerName = "";
    if (ep instanceof ErrorPropagation) {
        triggerTS = ((ErrorPropagation) ep).getTypeSet();
        triggerName = "propagation " + EMV2Util.getPrintName((ErrorPropagation) ep);
    } else if (ep instanceof ErrorEvent) {
        triggerTS = ((ErrorEvent) ep).getTypeSet();
        triggerName = "event " + ((ErrorBehaviorEvent) ep).getName();
    }
    TypeSet condTS = conditionElement.getConstraint();
    if (condTS == null) {
        return;
    }
    if (triggerTS == null && condTS != null) {
        // it is ok for a state not to have a type set.
        error(conditionElement, "Condition has type constraint but referenced " + triggerName + " does not.");
    } else if (!EMV2TypeSetUtil.isNoError(condTS) && !EMV2TypeSetUtil.contains(triggerTS, condTS)) {
        error(conditionElement, "Condition type constraint " + EMV2Util.getPrintName(condTS) + "is not contained in type set " + EMV2Util.getPrintName(triggerTS) + "of referenced " + triggerName);
    }
}
Also used : TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent) EventOrPropagation(org.osate.xtext.aadl2.errormodel.errorModel.EventOrPropagation) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)

Example 2 with EventOrPropagation

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

the class ErrorModelValidator method checkTransitionTargetTriggerTypes.

private void checkTransitionTargetTriggerTypes(ErrorBehaviorTransition ebt) {
    if (ebt.isSteadyState()) {
        return;
    }
    ErrorBehaviorState targetstate = ebt.getTarget();
    if (targetstate != null) {
        TypeSet targetTS = targetstate.getTypeSet();
        if (targetTS == null) {
            return;
        }
        TypeSet tt = ebt.getTargetToken();
        if (tt != null) {
            return;
        }
        // state requires a type
        if (ebt.getCondition() instanceof ConditionElement) {
            // either the event must be typed or the source state must be typed
            EventOrPropagation ep = EMV2Util.getErrorEventOrPropagation((ConditionElement) ebt.getCondition());
            if (ep instanceof ErrorEvent) {
                ErrorEvent ev = (ErrorEvent) ep;
                TypeSet evTS = ev.getTypeSet();
                if (evTS == null) {
                    TypeSet srcTS = ebt.getSource().getTypeSet();
                    if (srcTS == null) {
                        error(ebt, "Target state " + targetstate.getName() + " requires type but the triggering error event " + EMV2Util.getPrintName(ev) + " or source state " + EMV2Util.getPrintName(ebt.getSource()) + " does not have a type");
                    } else {
                        // source typeset must be contained in target type set
                        if (!EMV2TypeSetUtil.contains(targetTS, srcTS)) {
                            error(ebt, "Target state " + targetstate.getName() + " does not contain types of source state " + EMV2Util.getPrintName(ebt.getSource()));
                        }
                    }
                } else {
                    // error event has type. It must be consistent with the expected state type
                    if (!EMV2TypeSetUtil.contains(targetTS, evTS)) {
                        error(ebt, "Target state " + targetstate.getName() + " does not contain types of error event " + EMV2Util.getPrintName(ev));
                    }
                }
            } else if (ep instanceof ErrorPropagation) {
                ErrorPropagation eprop = (ErrorPropagation) ep;
                // we can check type compatibility
                if (!EMV2TypeSetUtil.contains(targetTS, eprop.getTypeSet())) {
                    error(ebt, "Target state " + targetstate.getName() + " does not contain types of error propagation " + EMV2Util.getPrintName(eprop));
                }
            }
        } else {
            // full condition expression
            // type transformation & events must be typed
            ErrorBehaviorStateMachine ebsm = (ErrorBehaviorStateMachine) targetstate.eContainer();
            if (ebsm.getUseTransformation().isEmpty()) {
                error(ebt, "Target state " + targetstate.getName() + " does not include a target type but requires types. For conditions on multiple elements a target type must be assigned explicitly or a type transformation must be specified in the error behavior state machine" + EMV2Util.getPrintName(ebsm));
            }
        }
    }
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) SConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.SConditionElement) ConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ErrorBehaviorStateMachine(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorStateMachine) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent) EventOrPropagation(org.osate.xtext.aadl2.errormodel.errorModel.EventOrPropagation) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)

Example 3 with EventOrPropagation

use of org.osate.xtext.aadl2.errormodel.errorModel.EventOrPropagation 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)

Example 4 with EventOrPropagation

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

the class PropagationGraphBackwardTraversal method handleOutgoingErrorPropagationCondition.

/**
 * Process all OutgoingPropagationConditions that match the propagation and type of interest
 * It is an OR of the OutgoingPropagationConditions that match.
 * Fore each it is an AND of the source state (if it involves an error event or propagation).
 * @param component ComponentInstance
 * @param propagation (outgoing) ErrorPropagation
 * @param type TypeToken
 * @return Event (can be null)
 */
private EObject handleOutgoingErrorPropagationCondition(ComponentInstance component, OutgoingPropagationCondition opc, TypeToken type, HashMultimap<ErrorPropagation, String> handledEOPs, BigDecimal scale) {
    EObject conditionResult = null;
    EObject stateResult = null;
    if (opc.getCondition() != null) {
        conditionResult = processCondition(component, opc.getCondition(), opc.getCondition() == null ? type : null, FaultTreeUtils.BigOne, false);
    }
    ErrorBehaviorState state = opc.getState();
    if (state != null) {
        // use constraint as we have mapping
        TypeSet newtypeset = null;
        if (opc.getTypeTokenConstraint() != null) {
            newtypeset = opc.getTypeTokenConstraint();
        } else if (state.getTypeSet() != null) {
            newtypeset = state.getTypeSet();
        }
        List<EObject> subResults = new LinkedList<EObject>();
        if (newtypeset != null) {
            EList<TypeToken> types = flattenTypesetElements(newtypeset);
            for (TypeToken typeToken : types) {
                EObject res = traverseErrorBehaviorState(component, state, typeToken, scale);
                if (res != null) {
                    addSubresult(subResults, res);
                }
            }
            if (subResults.isEmpty()) {
                stateResult = processErrorBehaviorState(component, state, type, scale);
            } else if (subResults.size() == 1) {
                stateResult = subResults.get(0);
            } else {
                stateResult = postProcessXor(component, state, type, BigOne, subResults);
            }
        } else {
            stateResult = traverseErrorBehaviorState(component, state, null, scale);
        }
    }
    if (conditionResult == null && stateResult != null) {
        for (ErrorBehaviorTransition trans : EMV2Util.getAllErrorBehaviorTransitions(component)) {
            if (state == trans.getTarget()) {
                Collection<ConditionElement> conde = EMV2Util.getAllConditionElementsFromConditionExpression(trans.getCondition());
                for (ConditionElement conditionElement : conde) {
                    EventOrPropagation eop = EMV2Util.getErrorEventOrPropagation(conditionElement);
                    if (eop instanceof ErrorPropagation) {
                        handledEOPs.put((ErrorPropagation) eop, EMV2Util.getPrintName(type));
                    }
                }
            }
        }
    } else {
        // error paths
        Collection<ConditionElement> conde = EMV2Util.getAllConditionElementsFromConditionExpression(opc.getCondition());
        for (ConditionElement conditionElement : conde) {
            EventOrPropagation eop = EMV2Util.getErrorEventOrPropagation(conditionElement);
            if (eop instanceof ErrorPropagation) {
                handledEOPs.put((ErrorPropagation) eop, EMV2Util.getPrintName(type));
            }
        }
    }
    return processOutgoingErrorPropagationCondition(component, opc, type, conditionResult, stateResult, scale);
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) QualifiedErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.QualifiedErrorBehaviorState) SConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.SConditionElement) ConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement) ErrorBehaviorTransition(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) EObject(org.eclipse.emf.ecore.EObject) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) EventOrPropagation(org.osate.xtext.aadl2.errormodel.errorModel.EventOrPropagation) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) LinkedList(java.util.LinkedList)

Example 5 with EventOrPropagation

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

the class PropagateErrorSources method processTransition.

private void processTransition(ComponentInstance ci, ErrorBehaviorEvent event, TypeToken eventtype, ErrorBehaviorTransition trans, ConditionElement conditionElement, String componentText, HashMultimap<ErrorPropagation, String> handledPropagations) {
    EventOrPropagation eop = EMV2Util.getErrorEventOrPropagation(conditionElement);
    TypeSet constraint = conditionElement.getConstraint();
    if (eop instanceof ErrorPropagation) {
        return;
    }
    if (eop.getName().equalsIgnoreCase(event.getName())) {
        // match the event
        if (eventtype != null && constraint != null && !EMV2TypeSetUtil.contains(constraint, eventtype)) {
            return;
        }
        ErrorBehaviorState targetstate = trans.getTarget();
        TypeSet statetype = null;
        if (targetstate.getTypeSet() != null) {
            statetype = trans.getTargetToken();
        }
        // we have the state and possibly a type
        for (OutgoingPropagationCondition opc : EMV2Util.getAllOutgoingPropagationConditions(ci)) {
            if (EMV2TypeSetUtil.isNoError(opc.getTypeToken()) || opc.getCondition() != null) {
                continue;
            }
            if (opc.isAllStates() || (opc.getState() != null && targetstate.getName().equalsIgnoreCase(opc.getState().getName()))) {
                // either typeless state or type is contained in opc type constraint on state
                TypeSet statetypeconstraint = opc.getTypeTokenConstraint();
                if (statetypeconstraint == null || statetype == null || EMV2TypeSetUtil.contains(statetypeconstraint, statetype)) {
                    ErrorTypes outtype = opc.getTypeToken();
                    if (outtype == null) {
                        outtype = statetype;
                    }
                    if (opc.isAllPropagations()) {
                        Collection<ErrorPropagation> oeps = EMV2Util.getAllOutgoingErrorPropagations(ci.getComponentClassifier());
                        for (ErrorPropagation ep : oeps) {
                            if (outtype == null) {
                                if (eventtype != null) {
                                    traceErrorPaths(ci, ep, eventtype, 2, componentText + ", " + "error event " + event.getName() + EMV2Util.getPrintName(eventtype));
                                    handledPropagations.put(ep, EMV2Util.getPrintName(eventtype));
                                }
                            } else {
                                EList<TypeToken> result = EMV2TypeSetUtil.generateAllLeafTypeTokens((TypeSet) outtype, EMV2Util.getUseTypes(opc));
                                for (TypeToken tt : result) {
                                    traceErrorPaths(ci, ep, tt, 2, componentText + ", " + "error event " + event.getName() + EMV2Util.getPrintName(eventtype));
                                    handledPropagations.put(ep, EMV2Util.getPrintName(tt));
                                }
                            }
                        }
                    } else {
                        ErrorPropagation ep = opc.getOutgoing();
                        if (outtype == null) {
                            if (eventtype != null) {
                                traceErrorPaths(ci, ep, eventtype, 2, componentText + ", " + "error event " + event.getName() + EMV2Util.getPrintName(eventtype));
                                handledPropagations.put(ep, EMV2Util.getPrintName(eventtype));
                            }
                        } else {
                            EList<TypeToken> result = EMV2TypeSetUtil.generateAllLeafTypeTokens((TypeSet) outtype, EMV2Util.getUseTypes(opc));
                            for (TypeToken tt : result) {
                                traceErrorPaths(ci, ep, tt, 2, componentText + ", " + "error event " + event.getName() + EMV2Util.getPrintName(eventtype));
                                handledPropagations.put(ep, EMV2Util.getPrintName(tt));
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) EventOrPropagation(org.osate.xtext.aadl2.errormodel.errorModel.EventOrPropagation) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) OutgoingPropagationCondition(org.osate.xtext.aadl2.errormodel.errorModel.OutgoingPropagationCondition) ErrorTypes(org.osate.xtext.aadl2.errormodel.errorModel.ErrorTypes)

Aggregations

ErrorPropagation (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)5 EventOrPropagation (org.osate.xtext.aadl2.errormodel.errorModel.EventOrPropagation)5 TypeSet (org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)5 ErrorBehaviorState (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState)4 ConditionElement (org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement)3 ErrorEvent (org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent)3 ErrorBehaviorTransition (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition)2 SConditionElement (org.osate.xtext.aadl2.errormodel.errorModel.SConditionElement)2 TypeToken (org.osate.xtext.aadl2.errormodel.errorModel.TypeToken)2 LinkedList (java.util.LinkedList)1 EObject (org.eclipse.emf.ecore.EObject)1 Element (org.osate.aadl2.Element)1 NamedElement (org.osate.aadl2.NamedElement)1 ConditionExpression (org.osate.xtext.aadl2.errormodel.errorModel.ConditionExpression)1 EMV2PropertyAssociation (org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation)1 ErrorBehaviorStateMachine (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorStateMachine)1 ErrorSource (org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource)1 ErrorTypes (org.osate.xtext.aadl2.errormodel.errorModel.ErrorTypes)1 OutgoingPropagationCondition (org.osate.xtext.aadl2.errormodel.errorModel.OutgoingPropagationCondition)1 QualifiedErrorBehaviorState (org.osate.xtext.aadl2.errormodel.errorModel.QualifiedErrorBehaviorState)1