Search in sources :

Example 1 with ConditionElement

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

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

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

the class ErrorModelValidator method checkConditionElementDirection.

private void checkConditionElementDirection(ConditionElement conditionElement) {
    ErrorPropagation ep = EMV2Util.getErrorPropagation(conditionElement.getQualifiedErrorPropagationReference());
    Subcomponent sub = EMV2Util.getLastSubcomponent(conditionElement.getQualifiedErrorPropagationReference());
    if (ep == null) {
        return;
    }
    if (sub != null) {
        if (ep.getDirection() != DirectionType.OUT) {
            error(conditionElement, "Referenced subcomponent error propagation " + sub.getName() + '.' + EMV2Util.getPrintName(ep) + " must be an out propagation");
        }
    } else if (ep.getDirection() != DirectionType.IN) {
        error(conditionElement, "Referenced local error propagation " + EMV2Util.getPrintName(ep) + " must be an in propagation");
    }
}
Also used : Subcomponent(org.osate.aadl2.Subcomponent) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)

Example 4 with ConditionElement

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

the class EMV2Util method getAllConditionElementsFromConditionExpression.

private static void getAllConditionElementsFromConditionExpression(EList<ConditionElement> propagations, ConditionExpression ce) {
    if (ce instanceof ConditionElement) {
        ConditionElement element = (ConditionElement) ce;
        propagations.add(element);
    } else if (ce instanceof AndExpression) {
        AndExpression and = (AndExpression) ce;
        for (ConditionExpression foobar : and.getOperands()) {
            getAllConditionElementsFromConditionExpression(propagations, foobar);
        }
    } else if (ce instanceof OrExpression) {
        OrExpression or = (OrExpression) ce;
        for (ConditionExpression foobar : or.getOperands()) {
            getAllConditionElementsFromConditionExpression(propagations, foobar);
        }
    } else if (ce instanceof OrmoreExpression) {
        OrmoreExpression or = (OrmoreExpression) ce;
        for (ConditionExpression foobar : or.getOperands()) {
            getAllConditionElementsFromConditionExpression(propagations, foobar);
        }
    } else if (ce instanceof OrlessExpression) {
        OrlessExpression or = (OrlessExpression) ce;
        for (ConditionExpression foobar : or.getOperands()) {
            getAllConditionElementsFromConditionExpression(propagations, foobar);
        }
    } else if (ce instanceof AllExpression) {
        AllExpression or = (AllExpression) ce;
        for (ConditionExpression foobar : or.getOperands()) {
            getAllConditionElementsFromConditionExpression(propagations, foobar);
        }
    }
}
Also used : SConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.SConditionElement) ConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement) AndExpression(org.osate.xtext.aadl2.errormodel.errorModel.AndExpression) ConditionExpression(org.osate.xtext.aadl2.errormodel.errorModel.ConditionExpression) OrlessExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrlessExpression) AllExpression(org.osate.xtext.aadl2.errormodel.errorModel.AllExpression) OrmoreExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrmoreExpression) OrExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrExpression)

Example 5 with ConditionElement

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

ErrorPropagation (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)10 ConditionElement (org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement)9 TypeSet (org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)9 ErrorBehaviorState (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState)8 SConditionElement (org.osate.xtext.aadl2.errormodel.errorModel.SConditionElement)6 TypeToken (org.osate.xtext.aadl2.errormodel.errorModel.TypeToken)6 EObject (org.eclipse.emf.ecore.EObject)5 ConditionExpression (org.osate.xtext.aadl2.errormodel.errorModel.ConditionExpression)5 ErrorEvent (org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent)5 EventOrPropagation (org.osate.xtext.aadl2.errormodel.errorModel.EventOrPropagation)5 NamedElement (org.osate.aadl2.NamedElement)4 AndExpression (org.osate.xtext.aadl2.errormodel.errorModel.AndExpression)4 ErrorBehaviorTransition (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition)4 OrExpression (org.osate.xtext.aadl2.errormodel.errorModel.OrExpression)4 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)3 AllExpression (org.osate.xtext.aadl2.errormodel.errorModel.AllExpression)3 EMV2PathElement (org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement)3 OrmoreExpression (org.osate.xtext.aadl2.errormodel.errorModel.OrmoreExpression)3 QualifiedErrorBehaviorState (org.osate.xtext.aadl2.errormodel.errorModel.QualifiedErrorBehaviorState)3 LinkedList (java.util.LinkedList)2